]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.11-201305011917.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.11-201305011917.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..b47493f 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,6 +75,7 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 @@ -80,6 +87,7 @@ aic7*seq.h*
53 aicasm
54 aicdb.h*
55 altivec*.c
56 +ashldi3.S
57 asm-offsets.h
58 asm_offsets.h
59 autoconf.h*
60 @@ -92,19 +100,24 @@ bounds.h
61 bsetup
62 btfixupprep
63 build
64 +builtin-policy.h
65 bvmlinux
66 bzImage*
67 capability_names.h
68 capflags.c
69 classlist.h*
70 +clut_vga16.c
71 +common-cmds.h
72 comp*.log
73 compile.h*
74 conf
75 config
76 config-*
77 config_data.h*
78 +config.c
79 config.mak
80 config.mak.autogen
81 +config.tmp
82 conmakehash
83 consolemap_deftbl.c*
84 cpustr.h
85 @@ -115,9 +128,11 @@ devlist.h*
86 dnotify_test
87 docproc
88 dslm
89 +dtc-lexer.lex.c
90 elf2ecoff
91 elfconfig.h*
92 evergreen_reg_safe.h
93 +exception_policy.conf
94 fixdep
95 flask.h
96 fore200e_mkfirm
97 @@ -125,12 +140,15 @@ fore200e_pca_fw.c*
98 gconf
99 gconf.glade.h
100 gen-devlist
101 +gen-kdb_cmds.c
102 gen_crc32table
103 gen_init_cpio
104 generated
105 genheaders
106 genksyms
107 *_gray256.c
108 +hash
109 +hid-example
110 hpet_example
111 hugepage-mmap
112 hugepage-shm
113 @@ -145,14 +163,14 @@ int32.c
114 int4.c
115 int8.c
116 kallsyms
117 -kconfig
118 +kern_constants.h
119 keywords.c
120 ksym.c*
121 ksym.h*
122 kxgettext
123 lex.c
124 lex.*.c
125 -linux
126 +lib1funcs.S
127 logo_*.c
128 logo_*_clut224.c
129 logo_*_mono.c
130 @@ -162,14 +180,15 @@ mach-types.h
131 machtypes.h
132 map
133 map_hugetlb
134 -media
135 mconf
136 +mdp
137 miboot*
138 mk_elfconfig
139 mkboot
140 mkbugboot
141 mkcpustr
142 mkdep
143 +mkpiggy
144 mkprep
145 mkregtable
146 mktables
147 @@ -185,6 +204,8 @@ oui.c*
148 page-types
149 parse.c
150 parse.h
151 +parse-events*
152 +pasyms.h
153 patches*
154 pca200e.bin
155 pca200e_ecd.bin2
156 @@ -194,6 +215,7 @@ perf-archive
157 piggyback
158 piggy.gzip
159 piggy.S
160 +pmu-*
161 pnmtologo
162 ppc_defs.h*
163 pss_boot.h
164 @@ -203,7 +225,10 @@ r200_reg_safe.h
165 r300_reg_safe.h
166 r420_reg_safe.h
167 r600_reg_safe.h
168 +realmode.lds
169 +realmode.relocs
170 recordmcount
171 +regdb.c
172 relocs
173 rlim_names.h
174 rn50_reg_safe.h
175 @@ -213,8 +238,12 @@ series
176 setup
177 setup.bin
178 setup.elf
179 +signing_key*
180 +size_overflow_hash.h
181 sImage
182 +slabinfo
183 sm_tbl*
184 +sortextable
185 split-include
186 syscalltab.h
187 tables.c
188 @@ -224,6 +253,7 @@ tftpboot.img
189 timeconst.h
190 times.h*
191 trix_boot.h
192 +user_constants.h
193 utsrelease.h*
194 vdso-syms.lds
195 vdso.lds
196 @@ -235,13 +265,17 @@ vdso32.lds
197 vdso32.so.dbg
198 vdso64.lds
199 vdso64.so.dbg
200 +vdsox32.lds
201 +vdsox32-syms.lds
202 version.h*
203 vmImage
204 vmlinux
205 vmlinux-*
206 vmlinux.aout
207 vmlinux.bin.all
208 +vmlinux.bin.bz2
209 vmlinux.lds
210 +vmlinux.relocs
211 vmlinuz
212 voffset.h
213 vsyscall.lds
214 @@ -249,9 +283,12 @@ vsyscall_32.lds
215 wanxlfw.inc
216 uImage
217 unifdef
218 +utsrelease.h
219 wakeup.bin
220 wakeup.elf
221 wakeup.lds
222 +x509*
223 zImage*
224 zconf.hash.c
225 +zconf.lex.c
226 zoffset.h
227 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
228 index 986614d..e8bfedc 100644
229 --- a/Documentation/kernel-parameters.txt
230 +++ b/Documentation/kernel-parameters.txt
231 @@ -922,6 +922,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
232 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
233 Default: 1024
234
235 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
236 + ignore grsecurity's /proc restrictions
237 +
238 +
239 hashdist= [KNL,NUMA] Large hashes allocated during boot
240 are distributed across NUMA nodes. Defaults on
241 for 64-bit NUMA, off otherwise.
242 @@ -2121,6 +2125,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
243 the specified number of seconds. This is to be used if
244 your oopses keep scrolling off the screen.
245
246 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
247 + virtualization environments that don't cope well with the
248 + expand down segment used by UDEREF on X86-32 or the frequent
249 + page table updates on X86-64.
250 +
251 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
252 +
253 + pax_extra_latent_entropy
254 + Enable a very simple form of latent entropy extraction
255 + from the first 4GB of memory as the bootmem allocator
256 + passes the memory pages to the buddy allocator.
257 +
258 pcbit= [HW,ISDN]
259
260 pcd. [PARIDE]
261 diff --git a/Makefile b/Makefile
262 index 7e4eee5..271e75e 100644
263 --- a/Makefile
264 +++ b/Makefile
265 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
266
267 HOSTCC = gcc
268 HOSTCXX = g++
269 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
270 -HOSTCXXFLAGS = -O2
271 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
272 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
273 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
274
275 # Decide whether to build built-in, modular, or both.
276 # Normally, just do built-in.
277 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
278 # Rules shared between *config targets and build targets
279
280 # Basic helpers built in scripts/
281 -PHONY += scripts_basic
282 -scripts_basic:
283 +PHONY += scripts_basic gcc-plugins
284 +scripts_basic: gcc-plugins
285 $(Q)$(MAKE) $(build)=scripts/basic
286 $(Q)rm -f .tmp_quiet_recordmcount
287
288 @@ -575,6 +576,65 @@ else
289 KBUILD_CFLAGS += -O2
290 endif
291
292 +ifndef DISABLE_PAX_PLUGINS
293 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
294 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
295 +else
296 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
297 +endif
298 +ifneq ($(PLUGINCC),)
299 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
300 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
301 +endif
302 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
303 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
304 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
305 +endif
306 +ifdef CONFIG_KALLOCSTAT_PLUGIN
307 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
308 +endif
309 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
310 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
311 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
312 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
313 +endif
314 +ifdef CONFIG_CHECKER_PLUGIN
315 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
316 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
317 +endif
318 +endif
319 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
320 +ifdef CONFIG_PAX_SIZE_OVERFLOW
321 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
322 +endif
323 +ifdef CONFIG_PAX_LATENT_ENTROPY
324 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
325 +endif
326 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
327 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
328 +endif
329 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
330 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
331 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
332 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
333 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
334 +ifeq ($(KBUILD_EXTMOD),)
335 +gcc-plugins:
336 + $(Q)$(MAKE) $(build)=tools/gcc
337 +else
338 +gcc-plugins: ;
339 +endif
340 +else
341 +gcc-plugins:
342 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
343 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
344 +else
345 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
346 +endif
347 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
348 +endif
349 +endif
350 +
351 include $(srctree)/arch/$(SRCARCH)/Makefile
352
353 ifdef CONFIG_READABLE_ASM
354 @@ -731,7 +791,7 @@ export mod_sign_cmd
355
356
357 ifeq ($(KBUILD_EXTMOD),)
358 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
359 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
360
361 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
362 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
363 @@ -778,6 +838,8 @@ endif
364
365 # The actual objects are generated when descending,
366 # make sure no implicit rule kicks in
367 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
368 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
369 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
370
371 # Handle descending into subdirectories listed in $(vmlinux-dirs)
372 @@ -787,7 +849,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
373 # Error messages still appears in the original language
374
375 PHONY += $(vmlinux-dirs)
376 -$(vmlinux-dirs): prepare scripts
377 +$(vmlinux-dirs): gcc-plugins prepare scripts
378 $(Q)$(MAKE) $(build)=$@
379
380 # Store (new) KERNELRELASE string in include/config/kernel.release
381 @@ -831,6 +893,7 @@ prepare0: archprepare FORCE
382 $(Q)$(MAKE) $(build)=.
383
384 # All the preparing..
385 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
386 prepare: prepare0
387
388 # Generate some files
389 @@ -938,6 +1001,8 @@ all: modules
390 # using awk while concatenating to the final file.
391
392 PHONY += modules
393 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
396 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
397 @$(kecho) ' Building modules, stage 2.';
398 @@ -953,7 +1018,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
399
400 # Target to prepare building external modules
401 PHONY += modules_prepare
402 -modules_prepare: prepare scripts
403 +modules_prepare: gcc-plugins prepare scripts
404
405 # Target to install modules
406 PHONY += modules_install
407 @@ -1019,7 +1084,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
408 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
409 signing_key.priv signing_key.x509 x509.genkey \
410 extra_certificates signing_key.x509.keyid \
411 - signing_key.x509.signer
412 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
413
414 # clean - Delete most, but leave enough to build external modules
415 #
416 @@ -1059,6 +1124,7 @@ distclean: mrproper
417 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
418 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
419 -o -name '.*.rej' \
420 + -o -name '.*.rej' -o -name '*.so' \
421 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
422 -type f -print | xargs rm -f
423
424 @@ -1219,6 +1285,8 @@ PHONY += $(module-dirs) modules
425 $(module-dirs): crmodverdir $(objtree)/Module.symvers
426 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
427
428 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
429 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
430 modules: $(module-dirs)
431 @$(kecho) ' Building modules, stage 2.';
432 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
433 @@ -1355,17 +1423,21 @@ else
434 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
435 endif
436
437 -%.s: %.c prepare scripts FORCE
438 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
439 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
440 +%.s: %.c gcc-plugins prepare scripts FORCE
441 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
442 %.i: %.c prepare scripts FORCE
443 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
444 -%.o: %.c prepare scripts FORCE
445 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
446 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
447 +%.o: %.c gcc-plugins prepare scripts FORCE
448 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
449 %.lst: %.c prepare scripts FORCE
450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
451 -%.s: %.S prepare scripts FORCE
452 +%.s: %.S gcc-plugins prepare scripts FORCE
453 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
454 -%.o: %.S prepare scripts FORCE
455 +%.o: %.S gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.symtypes: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 @@ -1375,11 +1447,15 @@ endif
460 $(cmd_crmodverdir)
461 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
462 $(build)=$(build-dir)
463 -%/: prepare scripts FORCE
464 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
465 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
466 +%/: gcc-plugins prepare scripts FORCE
467 $(cmd_crmodverdir)
468 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
469 $(build)=$(build-dir)
470 -%.ko: prepare scripts FORCE
471 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
472 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
473 +%.ko: gcc-plugins prepare scripts FORCE
474 $(cmd_crmodverdir)
475 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
476 $(build)=$(build-dir) $(@:.ko=.o)
477 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
478 index c2cbe4f..f7264b4 100644
479 --- a/arch/alpha/include/asm/atomic.h
480 +++ b/arch/alpha/include/asm/atomic.h
481 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
482 #define atomic_dec(v) atomic_sub(1,(v))
483 #define atomic64_dec(v) atomic64_sub(1,(v))
484
485 +#define atomic64_read_unchecked(v) atomic64_read(v)
486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
494 +
495 #define smp_mb__before_atomic_dec() smp_mb()
496 #define smp_mb__after_atomic_dec() smp_mb()
497 #define smp_mb__before_atomic_inc() smp_mb()
498 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
499 index ad368a9..fbe0f25 100644
500 --- a/arch/alpha/include/asm/cache.h
501 +++ b/arch/alpha/include/asm/cache.h
502 @@ -4,19 +4,19 @@
503 #ifndef __ARCH_ALPHA_CACHE_H
504 #define __ARCH_ALPHA_CACHE_H
505
506 +#include <linux/const.h>
507
508 /* Bytes per L1 (data) cache line. */
509 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
510 -# define L1_CACHE_BYTES 64
511 # define L1_CACHE_SHIFT 6
512 #else
513 /* Both EV4 and EV5 are write-through, read-allocate,
514 direct-mapped, physical.
515 */
516 -# define L1_CACHE_BYTES 32
517 # define L1_CACHE_SHIFT 5
518 #endif
519
520 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
521 #define SMP_CACHE_BYTES L1_CACHE_BYTES
522
523 #endif
524 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
525 index 968d999..d36b2df 100644
526 --- a/arch/alpha/include/asm/elf.h
527 +++ b/arch/alpha/include/asm/elf.h
528 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
529
530 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
531
532 +#ifdef CONFIG_PAX_ASLR
533 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
534 +
535 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
536 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
537 +#endif
538 +
539 /* $0 is set by ld.so to a pointer to a function which might be
540 registered using atexit. This provides a mean for the dynamic
541 linker to call DT_FINI functions for shared libraries that have
542 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
543 index bc2a0da..8ad11ee 100644
544 --- a/arch/alpha/include/asm/pgalloc.h
545 +++ b/arch/alpha/include/asm/pgalloc.h
546 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
547 pgd_set(pgd, pmd);
548 }
549
550 +static inline void
551 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
552 +{
553 + pgd_populate(mm, pgd, pmd);
554 +}
555 +
556 extern pgd_t *pgd_alloc(struct mm_struct *mm);
557
558 static inline void
559 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
560 index 81a4342..348b927 100644
561 --- a/arch/alpha/include/asm/pgtable.h
562 +++ b/arch/alpha/include/asm/pgtable.h
563 @@ -102,6 +102,17 @@ struct vm_area_struct;
564 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
565 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
566 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
567 +
568 +#ifdef CONFIG_PAX_PAGEEXEC
569 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
570 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
571 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
572 +#else
573 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
574 +# define PAGE_COPY_NOEXEC PAGE_COPY
575 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
576 +#endif
577 +
578 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
579
580 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
581 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
582 index 2fd00b7..cfd5069 100644
583 --- a/arch/alpha/kernel/module.c
584 +++ b/arch/alpha/kernel/module.c
585 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
586
587 /* The small sections were sorted to the end of the segment.
588 The following should definitely cover them. */
589 - gp = (u64)me->module_core + me->core_size - 0x8000;
590 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
591 got = sechdrs[me->arch.gotsecindex].sh_addr;
592
593 for (i = 0; i < n; i++) {
594 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
595 index 14db93e..47bed62 100644
596 --- a/arch/alpha/kernel/osf_sys.c
597 +++ b/arch/alpha/kernel/osf_sys.c
598 @@ -1295,16 +1295,16 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
599 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
600
601 static unsigned long
602 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
603 - unsigned long limit)
604 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
605 + unsigned long limit, unsigned long flags)
606 {
607 struct vm_area_struct *vma = find_vma(current->mm, addr);
608 -
609 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
610 while (1) {
611 /* At this point: (!vma || addr < vma->vm_end). */
612 if (limit - len < addr)
613 return -ENOMEM;
614 - if (!vma || addr + len <= vma->vm_start)
615 + if (check_heap_stack_gap(vma, addr, len, offset))
616 return addr;
617 addr = vma->vm_end;
618 vma = vma->vm_next;
619 @@ -1340,20 +1340,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
620 merely specific addresses, but regions of memory -- perhaps
621 this feature should be incorporated into all ports? */
622
623 +#ifdef CONFIG_PAX_RANDMMAP
624 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
625 +#endif
626 +
627 if (addr) {
628 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
629 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
630 if (addr != (unsigned long) -ENOMEM)
631 return addr;
632 }
633
634 /* Next, try allocating at TASK_UNMAPPED_BASE. */
635 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
636 - len, limit);
637 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
638 +
639 if (addr != (unsigned long) -ENOMEM)
640 return addr;
641
642 /* Finally, try allocating in low memory. */
643 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
644 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
645
646 return addr;
647 }
648 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
649 index 0c4132d..88f0d53 100644
650 --- a/arch/alpha/mm/fault.c
651 +++ b/arch/alpha/mm/fault.c
652 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
653 __reload_thread(pcb);
654 }
655
656 +#ifdef CONFIG_PAX_PAGEEXEC
657 +/*
658 + * PaX: decide what to do with offenders (regs->pc = fault address)
659 + *
660 + * returns 1 when task should be killed
661 + * 2 when patched PLT trampoline was detected
662 + * 3 when unpatched PLT trampoline was detected
663 + */
664 +static int pax_handle_fetch_fault(struct pt_regs *regs)
665 +{
666 +
667 +#ifdef CONFIG_PAX_EMUPLT
668 + int err;
669 +
670 + do { /* PaX: patched PLT emulation #1 */
671 + unsigned int ldah, ldq, jmp;
672 +
673 + err = get_user(ldah, (unsigned int *)regs->pc);
674 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
675 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
676 +
677 + if (err)
678 + break;
679 +
680 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
681 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
682 + jmp == 0x6BFB0000U)
683 + {
684 + unsigned long r27, addr;
685 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
686 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
687 +
688 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
689 + err = get_user(r27, (unsigned long *)addr);
690 + if (err)
691 + break;
692 +
693 + regs->r27 = r27;
694 + regs->pc = r27;
695 + return 2;
696 + }
697 + } while (0);
698 +
699 + do { /* PaX: patched PLT emulation #2 */
700 + unsigned int ldah, lda, br;
701 +
702 + err = get_user(ldah, (unsigned int *)regs->pc);
703 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
704 + err |= get_user(br, (unsigned int *)(regs->pc+8));
705 +
706 + if (err)
707 + break;
708 +
709 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
710 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
711 + (br & 0xFFE00000U) == 0xC3E00000U)
712 + {
713 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
714 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
715 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
716 +
717 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
718 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
719 + return 2;
720 + }
721 + } while (0);
722 +
723 + do { /* PaX: unpatched PLT emulation */
724 + unsigned int br;
725 +
726 + err = get_user(br, (unsigned int *)regs->pc);
727 +
728 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
729 + unsigned int br2, ldq, nop, jmp;
730 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
731 +
732 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
733 + err = get_user(br2, (unsigned int *)addr);
734 + err |= get_user(ldq, (unsigned int *)(addr+4));
735 + err |= get_user(nop, (unsigned int *)(addr+8));
736 + err |= get_user(jmp, (unsigned int *)(addr+12));
737 + err |= get_user(resolver, (unsigned long *)(addr+16));
738 +
739 + if (err)
740 + break;
741 +
742 + if (br2 == 0xC3600000U &&
743 + ldq == 0xA77B000CU &&
744 + nop == 0x47FF041FU &&
745 + jmp == 0x6B7B0000U)
746 + {
747 + regs->r28 = regs->pc+4;
748 + regs->r27 = addr+16;
749 + regs->pc = resolver;
750 + return 3;
751 + }
752 + }
753 + } while (0);
754 +#endif
755 +
756 + return 1;
757 +}
758 +
759 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
760 +{
761 + unsigned long i;
762 +
763 + printk(KERN_ERR "PAX: bytes at PC: ");
764 + for (i = 0; i < 5; i++) {
765 + unsigned int c;
766 + if (get_user(c, (unsigned int *)pc+i))
767 + printk(KERN_CONT "???????? ");
768 + else
769 + printk(KERN_CONT "%08x ", c);
770 + }
771 + printk("\n");
772 +}
773 +#endif
774
775 /*
776 * This routine handles page faults. It determines the address,
777 @@ -133,8 +251,29 @@ retry:
778 good_area:
779 si_code = SEGV_ACCERR;
780 if (cause < 0) {
781 - if (!(vma->vm_flags & VM_EXEC))
782 + if (!(vma->vm_flags & VM_EXEC)) {
783 +
784 +#ifdef CONFIG_PAX_PAGEEXEC
785 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
786 + goto bad_area;
787 +
788 + up_read(&mm->mmap_sem);
789 + switch (pax_handle_fetch_fault(regs)) {
790 +
791 +#ifdef CONFIG_PAX_EMUPLT
792 + case 2:
793 + case 3:
794 + return;
795 +#endif
796 +
797 + }
798 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
799 + do_group_exit(SIGKILL);
800 +#else
801 goto bad_area;
802 +#endif
803 +
804 + }
805 } else if (!cause) {
806 /* Allow reads even for write-only mappings */
807 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
808 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
809 index 67874b8..9aa2d62 100644
810 --- a/arch/arm/Kconfig
811 +++ b/arch/arm/Kconfig
812 @@ -1427,6 +1427,16 @@ config ARM_ERRATA_775420
813 to deadlock. This workaround puts DSB before executing ISB if
814 an abort may occur on cache maintenance.
815
816 +config ARM_ERRATA_798181
817 + bool "ARM errata: TLBI/DSB failure on Cortex-A15"
818 + depends on CPU_V7 && SMP
819 + help
820 + On Cortex-A15 (r0p0..r3p2) the TLBI*IS/DSB operations are not
821 + adequately shooting down all use of the old entries. This
822 + option enables the Linux kernel workaround for this erratum
823 + which sends an IPI to the CPUs that are running the same ASID
824 + as the one being invalidated.
825 +
826 endmenu
827
828 source "arch/arm/common/Kconfig"
829 @@ -1813,7 +1823,7 @@ config ALIGNMENT_TRAP
830
831 config UACCESS_WITH_MEMCPY
832 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
833 - depends on MMU
834 + depends on MMU && !PAX_MEMORY_UDEREF
835 default y if CPU_FEROCEON
836 help
837 Implement faster copy_to_user and clear_user methods for CPU
838 diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
839 index 87dfa902..3a523fc 100644
840 --- a/arch/arm/common/gic.c
841 +++ b/arch/arm/common/gic.c
842 @@ -81,7 +81,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
843 * Supported arch specific GIC irq extension.
844 * Default make them NULL.
845 */
846 -struct irq_chip gic_arch_extn = {
847 +irq_chip_no_const gic_arch_extn __read_only = {
848 .irq_eoi = NULL,
849 .irq_mask = NULL,
850 .irq_unmask = NULL,
851 @@ -329,7 +329,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
852 chained_irq_exit(chip, desc);
853 }
854
855 -static struct irq_chip gic_chip = {
856 +static irq_chip_no_const gic_chip __read_only = {
857 .name = "GIC",
858 .irq_mask = gic_mask_irq,
859 .irq_unmask = gic_unmask_irq,
860 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
861 index c79f61f..9ac0642 100644
862 --- a/arch/arm/include/asm/atomic.h
863 +++ b/arch/arm/include/asm/atomic.h
864 @@ -17,17 +17,35 @@
865 #include <asm/barrier.h>
866 #include <asm/cmpxchg.h>
867
868 +#ifdef CONFIG_GENERIC_ATOMIC64
869 +#include <asm-generic/atomic64.h>
870 +#endif
871 +
872 #define ATOMIC_INIT(i) { (i) }
873
874 #ifdef __KERNEL__
875
876 +#define _ASM_EXTABLE(from, to) \
877 +" .pushsection __ex_table,\"a\"\n"\
878 +" .align 3\n" \
879 +" .long " #from ", " #to"\n" \
880 +" .popsection"
881 +
882 /*
883 * On ARM, ordinary assignment (str instruction) doesn't clear the local
884 * strex/ldrex monitor on some implementations. The reason we can use it for
885 * atomic_set() is the clrex or dummy strex done on every exception return.
886 */
887 #define atomic_read(v) (*(volatile int *)&(v)->counter)
888 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
889 +{
890 + return v->counter;
891 +}
892 #define atomic_set(v,i) (((v)->counter) = (i))
893 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
894 +{
895 + v->counter = i;
896 +}
897
898 #if __LINUX_ARM_ARCH__ >= 6
899
900 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
901 int result;
902
903 __asm__ __volatile__("@ atomic_add\n"
904 +"1: ldrex %1, [%3]\n"
905 +" adds %0, %1, %4\n"
906 +
907 +#ifdef CONFIG_PAX_REFCOUNT
908 +" bvc 3f\n"
909 +"2: bkpt 0xf103\n"
910 +"3:\n"
911 +#endif
912 +
913 +" strex %1, %0, [%3]\n"
914 +" teq %1, #0\n"
915 +" bne 1b"
916 +
917 +#ifdef CONFIG_PAX_REFCOUNT
918 +"\n4:\n"
919 + _ASM_EXTABLE(2b, 4b)
920 +#endif
921 +
922 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
923 + : "r" (&v->counter), "Ir" (i)
924 + : "cc");
925 +}
926 +
927 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
928 +{
929 + unsigned long tmp;
930 + int result;
931 +
932 + __asm__ __volatile__("@ atomic_add_unchecked\n"
933 "1: ldrex %0, [%3]\n"
934 " add %0, %0, %4\n"
935 " strex %1, %0, [%3]\n"
936 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
937 smp_mb();
938
939 __asm__ __volatile__("@ atomic_add_return\n"
940 +"1: ldrex %1, [%3]\n"
941 +" adds %0, %1, %4\n"
942 +
943 +#ifdef CONFIG_PAX_REFCOUNT
944 +" bvc 3f\n"
945 +" mov %0, %1\n"
946 +"2: bkpt 0xf103\n"
947 +"3:\n"
948 +#endif
949 +
950 +" strex %1, %0, [%3]\n"
951 +" teq %1, #0\n"
952 +" bne 1b"
953 +
954 +#ifdef CONFIG_PAX_REFCOUNT
955 +"\n4:\n"
956 + _ASM_EXTABLE(2b, 4b)
957 +#endif
958 +
959 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
960 + : "r" (&v->counter), "Ir" (i)
961 + : "cc");
962 +
963 + smp_mb();
964 +
965 + return result;
966 +}
967 +
968 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
969 +{
970 + unsigned long tmp;
971 + int result;
972 +
973 + smp_mb();
974 +
975 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
976 "1: ldrex %0, [%3]\n"
977 " add %0, %0, %4\n"
978 " strex %1, %0, [%3]\n"
979 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
980 int result;
981
982 __asm__ __volatile__("@ atomic_sub\n"
983 +"1: ldrex %1, [%3]\n"
984 +" subs %0, %1, %4\n"
985 +
986 +#ifdef CONFIG_PAX_REFCOUNT
987 +" bvc 3f\n"
988 +"2: bkpt 0xf103\n"
989 +"3:\n"
990 +#endif
991 +
992 +" strex %1, %0, [%3]\n"
993 +" teq %1, #0\n"
994 +" bne 1b"
995 +
996 +#ifdef CONFIG_PAX_REFCOUNT
997 +"\n4:\n"
998 + _ASM_EXTABLE(2b, 4b)
999 +#endif
1000 +
1001 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1002 + : "r" (&v->counter), "Ir" (i)
1003 + : "cc");
1004 +}
1005 +
1006 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1007 +{
1008 + unsigned long tmp;
1009 + int result;
1010 +
1011 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1012 "1: ldrex %0, [%3]\n"
1013 " sub %0, %0, %4\n"
1014 " strex %1, %0, [%3]\n"
1015 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1016 smp_mb();
1017
1018 __asm__ __volatile__("@ atomic_sub_return\n"
1019 -"1: ldrex %0, [%3]\n"
1020 -" sub %0, %0, %4\n"
1021 +"1: ldrex %1, [%3]\n"
1022 +" subs %0, %1, %4\n"
1023 +
1024 +#ifdef CONFIG_PAX_REFCOUNT
1025 +" bvc 3f\n"
1026 +" mov %0, %1\n"
1027 +"2: bkpt 0xf103\n"
1028 +"3:\n"
1029 +#endif
1030 +
1031 " strex %1, %0, [%3]\n"
1032 " teq %1, #0\n"
1033 " bne 1b"
1034 +
1035 +#ifdef CONFIG_PAX_REFCOUNT
1036 +"\n4:\n"
1037 + _ASM_EXTABLE(2b, 4b)
1038 +#endif
1039 +
1040 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1041 : "r" (&v->counter), "Ir" (i)
1042 : "cc");
1043 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1044 return oldval;
1045 }
1046
1047 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1048 +{
1049 + unsigned long oldval, res;
1050 +
1051 + smp_mb();
1052 +
1053 + do {
1054 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1055 + "ldrex %1, [%3]\n"
1056 + "mov %0, #0\n"
1057 + "teq %1, %4\n"
1058 + "strexeq %0, %5, [%3]\n"
1059 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1060 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1061 + : "cc");
1062 + } while (res);
1063 +
1064 + smp_mb();
1065 +
1066 + return oldval;
1067 +}
1068 +
1069 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1070 {
1071 unsigned long tmp, tmp2;
1072 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1073
1074 return val;
1075 }
1076 +
1077 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1078 +{
1079 + return atomic_add_return(i, v);
1080 +}
1081 +
1082 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1083 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1084 +{
1085 + (void) atomic_add_return(i, v);
1086 +}
1087
1088 static inline int atomic_sub_return(int i, atomic_t *v)
1089 {
1090 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1091 return val;
1092 }
1093 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1094 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1095 +{
1096 + (void) atomic_sub_return(i, v);
1097 +}
1098
1099 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1100 {
1101 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1102 return ret;
1103 }
1104
1105 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1106 +{
1107 + return atomic_cmpxchg(v, old, new);
1108 +}
1109 +
1110 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1111 {
1112 unsigned long flags;
1113 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1114 #endif /* __LINUX_ARM_ARCH__ */
1115
1116 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1117 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1118 +{
1119 + return xchg(&v->counter, new);
1120 +}
1121
1122 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1123 {
1124 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1125 }
1126
1127 #define atomic_inc(v) atomic_add(1, v)
1128 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1129 +{
1130 + atomic_add_unchecked(1, v);
1131 +}
1132 #define atomic_dec(v) atomic_sub(1, v)
1133 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1134 +{
1135 + atomic_sub_unchecked(1, v);
1136 +}
1137
1138 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1139 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1140 +{
1141 + return atomic_add_return_unchecked(1, v) == 0;
1142 +}
1143 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1144 #define atomic_inc_return(v) (atomic_add_return(1, v))
1145 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1146 +{
1147 + return atomic_add_return_unchecked(1, v);
1148 +}
1149 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1150 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1151
1152 @@ -241,6 +428,14 @@ typedef struct {
1153 u64 __aligned(8) counter;
1154 } atomic64_t;
1155
1156 +#ifdef CONFIG_PAX_REFCOUNT
1157 +typedef struct {
1158 + u64 __aligned(8) counter;
1159 +} atomic64_unchecked_t;
1160 +#else
1161 +typedef atomic64_t atomic64_unchecked_t;
1162 +#endif
1163 +
1164 #define ATOMIC64_INIT(i) { (i) }
1165
1166 static inline u64 atomic64_read(const atomic64_t *v)
1167 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1168 return result;
1169 }
1170
1171 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1172 +{
1173 + u64 result;
1174 +
1175 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1176 +" ldrexd %0, %H0, [%1]"
1177 + : "=&r" (result)
1178 + : "r" (&v->counter), "Qo" (v->counter)
1179 + );
1180 +
1181 + return result;
1182 +}
1183 +
1184 static inline void atomic64_set(atomic64_t *v, u64 i)
1185 {
1186 u64 tmp;
1187 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1188 : "cc");
1189 }
1190
1191 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1192 +{
1193 + u64 tmp;
1194 +
1195 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1196 +"1: ldrexd %0, %H0, [%2]\n"
1197 +" strexd %0, %3, %H3, [%2]\n"
1198 +" teq %0, #0\n"
1199 +" bne 1b"
1200 + : "=&r" (tmp), "=Qo" (v->counter)
1201 + : "r" (&v->counter), "r" (i)
1202 + : "cc");
1203 +}
1204 +
1205 static inline void atomic64_add(u64 i, atomic64_t *v)
1206 {
1207 u64 result;
1208 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1209 __asm__ __volatile__("@ atomic64_add\n"
1210 "1: ldrexd %0, %H0, [%3]\n"
1211 " adds %0, %0, %4\n"
1212 +" adcs %H0, %H0, %H4\n"
1213 +
1214 +#ifdef CONFIG_PAX_REFCOUNT
1215 +" bvc 3f\n"
1216 +"2: bkpt 0xf103\n"
1217 +"3:\n"
1218 +#endif
1219 +
1220 +" strexd %1, %0, %H0, [%3]\n"
1221 +" teq %1, #0\n"
1222 +" bne 1b"
1223 +
1224 +#ifdef CONFIG_PAX_REFCOUNT
1225 +"\n4:\n"
1226 + _ASM_EXTABLE(2b, 4b)
1227 +#endif
1228 +
1229 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1230 + : "r" (&v->counter), "r" (i)
1231 + : "cc");
1232 +}
1233 +
1234 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1235 +{
1236 + u64 result;
1237 + unsigned long tmp;
1238 +
1239 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1240 +"1: ldrexd %0, %H0, [%3]\n"
1241 +" adds %0, %0, %4\n"
1242 " adc %H0, %H0, %H4\n"
1243 " strexd %1, %0, %H0, [%3]\n"
1244 " teq %1, #0\n"
1245 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1246
1247 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1248 {
1249 - u64 result;
1250 - unsigned long tmp;
1251 + u64 result, tmp;
1252
1253 smp_mb();
1254
1255 __asm__ __volatile__("@ atomic64_add_return\n"
1256 +"1: ldrexd %1, %H1, [%3]\n"
1257 +" adds %0, %1, %4\n"
1258 +" adcs %H0, %H1, %H4\n"
1259 +
1260 +#ifdef CONFIG_PAX_REFCOUNT
1261 +" bvc 3f\n"
1262 +" mov %0, %1\n"
1263 +" mov %H0, %H1\n"
1264 +"2: bkpt 0xf103\n"
1265 +"3:\n"
1266 +#endif
1267 +
1268 +" strexd %1, %0, %H0, [%3]\n"
1269 +" teq %1, #0\n"
1270 +" bne 1b"
1271 +
1272 +#ifdef CONFIG_PAX_REFCOUNT
1273 +"\n4:\n"
1274 + _ASM_EXTABLE(2b, 4b)
1275 +#endif
1276 +
1277 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1278 + : "r" (&v->counter), "r" (i)
1279 + : "cc");
1280 +
1281 + smp_mb();
1282 +
1283 + return result;
1284 +}
1285 +
1286 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1287 +{
1288 + u64 result;
1289 + unsigned long tmp;
1290 +
1291 + smp_mb();
1292 +
1293 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1294 "1: ldrexd %0, %H0, [%3]\n"
1295 " adds %0, %0, %4\n"
1296 " adc %H0, %H0, %H4\n"
1297 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1298 __asm__ __volatile__("@ atomic64_sub\n"
1299 "1: ldrexd %0, %H0, [%3]\n"
1300 " subs %0, %0, %4\n"
1301 +" sbcs %H0, %H0, %H4\n"
1302 +
1303 +#ifdef CONFIG_PAX_REFCOUNT
1304 +" bvc 3f\n"
1305 +"2: bkpt 0xf103\n"
1306 +"3:\n"
1307 +#endif
1308 +
1309 +" strexd %1, %0, %H0, [%3]\n"
1310 +" teq %1, #0\n"
1311 +" bne 1b"
1312 +
1313 +#ifdef CONFIG_PAX_REFCOUNT
1314 +"\n4:\n"
1315 + _ASM_EXTABLE(2b, 4b)
1316 +#endif
1317 +
1318 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1319 + : "r" (&v->counter), "r" (i)
1320 + : "cc");
1321 +}
1322 +
1323 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1324 +{
1325 + u64 result;
1326 + unsigned long tmp;
1327 +
1328 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1329 +"1: ldrexd %0, %H0, [%3]\n"
1330 +" subs %0, %0, %4\n"
1331 " sbc %H0, %H0, %H4\n"
1332 " strexd %1, %0, %H0, [%3]\n"
1333 " teq %1, #0\n"
1334 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1335
1336 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1337 {
1338 - u64 result;
1339 - unsigned long tmp;
1340 + u64 result, tmp;
1341
1342 smp_mb();
1343
1344 __asm__ __volatile__("@ atomic64_sub_return\n"
1345 -"1: ldrexd %0, %H0, [%3]\n"
1346 -" subs %0, %0, %4\n"
1347 -" sbc %H0, %H0, %H4\n"
1348 +"1: ldrexd %1, %H1, [%3]\n"
1349 +" subs %0, %1, %4\n"
1350 +" sbcs %H0, %H1, %H4\n"
1351 +
1352 +#ifdef CONFIG_PAX_REFCOUNT
1353 +" bvc 3f\n"
1354 +" mov %0, %1\n"
1355 +" mov %H0, %H1\n"
1356 +"2: bkpt 0xf103\n"
1357 +"3:\n"
1358 +#endif
1359 +
1360 " strexd %1, %0, %H0, [%3]\n"
1361 " teq %1, #0\n"
1362 " bne 1b"
1363 +
1364 +#ifdef CONFIG_PAX_REFCOUNT
1365 +"\n4:\n"
1366 + _ASM_EXTABLE(2b, 4b)
1367 +#endif
1368 +
1369 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1370 : "r" (&v->counter), "r" (i)
1371 : "cc");
1372 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1373 return oldval;
1374 }
1375
1376 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1377 +{
1378 + u64 oldval;
1379 + unsigned long res;
1380 +
1381 + smp_mb();
1382 +
1383 + do {
1384 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1385 + "ldrexd %1, %H1, [%3]\n"
1386 + "mov %0, #0\n"
1387 + "teq %1, %4\n"
1388 + "teqeq %H1, %H4\n"
1389 + "strexdeq %0, %5, %H5, [%3]"
1390 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1391 + : "r" (&ptr->counter), "r" (old), "r" (new)
1392 + : "cc");
1393 + } while (res);
1394 +
1395 + smp_mb();
1396 +
1397 + return oldval;
1398 +}
1399 +
1400 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1401 {
1402 u64 result;
1403 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1404
1405 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1406 {
1407 - u64 result;
1408 - unsigned long tmp;
1409 + u64 result, tmp;
1410
1411 smp_mb();
1412
1413 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1414 -"1: ldrexd %0, %H0, [%3]\n"
1415 -" subs %0, %0, #1\n"
1416 -" sbc %H0, %H0, #0\n"
1417 +"1: ldrexd %1, %H1, [%3]\n"
1418 +" subs %0, %1, #1\n"
1419 +" sbcs %H0, %H1, #0\n"
1420 +
1421 +#ifdef CONFIG_PAX_REFCOUNT
1422 +" bvc 3f\n"
1423 +" mov %0, %1\n"
1424 +" mov %H0, %H1\n"
1425 +"2: bkpt 0xf103\n"
1426 +"3:\n"
1427 +#endif
1428 +
1429 " teq %H0, #0\n"
1430 -" bmi 2f\n"
1431 +" bmi 4f\n"
1432 " strexd %1, %0, %H0, [%3]\n"
1433 " teq %1, #0\n"
1434 " bne 1b\n"
1435 -"2:"
1436 +"4:\n"
1437 +
1438 +#ifdef CONFIG_PAX_REFCOUNT
1439 + _ASM_EXTABLE(2b, 4b)
1440 +#endif
1441 +
1442 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1443 : "r" (&v->counter)
1444 : "cc");
1445 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1446 " teq %0, %5\n"
1447 " teqeq %H0, %H5\n"
1448 " moveq %1, #0\n"
1449 -" beq 2f\n"
1450 +" beq 4f\n"
1451 " adds %0, %0, %6\n"
1452 -" adc %H0, %H0, %H6\n"
1453 +" adcs %H0, %H0, %H6\n"
1454 +
1455 +#ifdef CONFIG_PAX_REFCOUNT
1456 +" bvc 3f\n"
1457 +"2: bkpt 0xf103\n"
1458 +"3:\n"
1459 +#endif
1460 +
1461 " strexd %2, %0, %H0, [%4]\n"
1462 " teq %2, #0\n"
1463 " bne 1b\n"
1464 -"2:"
1465 +"4:\n"
1466 +
1467 +#ifdef CONFIG_PAX_REFCOUNT
1468 + _ASM_EXTABLE(2b, 4b)
1469 +#endif
1470 +
1471 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1472 : "r" (&v->counter), "r" (u), "r" (a)
1473 : "cc");
1474 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1475
1476 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1477 #define atomic64_inc(v) atomic64_add(1LL, (v))
1478 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1479 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1480 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1481 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1482 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1483 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1484 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1485 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1486 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1487 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1488 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1489 index 75fe66b..ba3dee4 100644
1490 --- a/arch/arm/include/asm/cache.h
1491 +++ b/arch/arm/include/asm/cache.h
1492 @@ -4,8 +4,10 @@
1493 #ifndef __ASMARM_CACHE_H
1494 #define __ASMARM_CACHE_H
1495
1496 +#include <linux/const.h>
1497 +
1498 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1499 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1500 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1501
1502 /*
1503 * Memory returned by kmalloc() may be used for DMA, so we must make
1504 @@ -24,5 +26,6 @@
1505 #endif
1506
1507 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1508 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1509
1510 #endif
1511 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1512 index e1489c5..d418304 100644
1513 --- a/arch/arm/include/asm/cacheflush.h
1514 +++ b/arch/arm/include/asm/cacheflush.h
1515 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1516 void (*dma_unmap_area)(const void *, size_t, int);
1517
1518 void (*dma_flush_range)(const void *, const void *);
1519 -};
1520 +} __no_const;
1521
1522 /*
1523 * Select the calling method
1524 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1525 index 6dcc164..b14d917 100644
1526 --- a/arch/arm/include/asm/checksum.h
1527 +++ b/arch/arm/include/asm/checksum.h
1528 @@ -37,7 +37,19 @@ __wsum
1529 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1530
1531 __wsum
1532 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1533 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1534 +
1535 +static inline __wsum
1536 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1537 +{
1538 + __wsum ret;
1539 + pax_open_userland();
1540 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1541 + pax_close_userland();
1542 + return ret;
1543 +}
1544 +
1545 +
1546
1547 /*
1548 * Fold a partial checksum without adding pseudo headers
1549 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1550 index 7eb18c1..e38b6d2 100644
1551 --- a/arch/arm/include/asm/cmpxchg.h
1552 +++ b/arch/arm/include/asm/cmpxchg.h
1553 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1554
1555 #define xchg(ptr,x) \
1556 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1557 +#define xchg_unchecked(ptr,x) \
1558 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1559
1560 #include <asm-generic/cmpxchg-local.h>
1561
1562 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1563 index 6ddbe44..b5e38b1 100644
1564 --- a/arch/arm/include/asm/domain.h
1565 +++ b/arch/arm/include/asm/domain.h
1566 @@ -48,18 +48,37 @@
1567 * Domain types
1568 */
1569 #define DOMAIN_NOACCESS 0
1570 -#define DOMAIN_CLIENT 1
1571 #ifdef CONFIG_CPU_USE_DOMAINS
1572 +#define DOMAIN_USERCLIENT 1
1573 +#define DOMAIN_KERNELCLIENT 1
1574 #define DOMAIN_MANAGER 3
1575 +#define DOMAIN_VECTORS DOMAIN_USER
1576 #else
1577 +
1578 +#ifdef CONFIG_PAX_KERNEXEC
1579 #define DOMAIN_MANAGER 1
1580 +#define DOMAIN_KERNEXEC 3
1581 +#else
1582 +#define DOMAIN_MANAGER 1
1583 +#endif
1584 +
1585 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1586 +#define DOMAIN_USERCLIENT 0
1587 +#define DOMAIN_UDEREF 1
1588 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1589 +#else
1590 +#define DOMAIN_USERCLIENT 1
1591 +#define DOMAIN_VECTORS DOMAIN_USER
1592 +#endif
1593 +#define DOMAIN_KERNELCLIENT 1
1594 +
1595 #endif
1596
1597 #define domain_val(dom,type) ((type) << (2*(dom)))
1598
1599 #ifndef __ASSEMBLY__
1600
1601 -#ifdef CONFIG_CPU_USE_DOMAINS
1602 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1603 static inline void set_domain(unsigned val)
1604 {
1605 asm volatile(
1606 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1607 isb();
1608 }
1609
1610 -#define modify_domain(dom,type) \
1611 - do { \
1612 - struct thread_info *thread = current_thread_info(); \
1613 - unsigned int domain = thread->cpu_domain; \
1614 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1615 - thread->cpu_domain = domain | domain_val(dom, type); \
1616 - set_domain(thread->cpu_domain); \
1617 - } while (0)
1618 -
1619 +extern void modify_domain(unsigned int dom, unsigned int type);
1620 #else
1621 static inline void set_domain(unsigned val) { }
1622 static inline void modify_domain(unsigned dom, unsigned type) { }
1623 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1624 index 38050b1..9d90e8b 100644
1625 --- a/arch/arm/include/asm/elf.h
1626 +++ b/arch/arm/include/asm/elf.h
1627 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1628 the loader. We need to make sure that it is out of the way of the program
1629 that it will "exec", and that there is sufficient room for the brk. */
1630
1631 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1632 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1633 +
1634 +#ifdef CONFIG_PAX_ASLR
1635 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1636 +
1637 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1638 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1639 +#endif
1640
1641 /* When the program starts, a1 contains a pointer to a function to be
1642 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1643 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1644 extern void elf_set_personality(const struct elf32_hdr *);
1645 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1646
1647 -struct mm_struct;
1648 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1649 -#define arch_randomize_brk arch_randomize_brk
1650 -
1651 #endif
1652 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1653 index de53547..52b9a28 100644
1654 --- a/arch/arm/include/asm/fncpy.h
1655 +++ b/arch/arm/include/asm/fncpy.h
1656 @@ -81,7 +81,9 @@
1657 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1658 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1659 \
1660 + pax_open_kernel(); \
1661 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1662 + pax_close_kernel(); \
1663 flush_icache_range((unsigned long)(dest_buf), \
1664 (unsigned long)(dest_buf) + (size)); \
1665 \
1666 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1667 index e42cf59..7b94b8f 100644
1668 --- a/arch/arm/include/asm/futex.h
1669 +++ b/arch/arm/include/asm/futex.h
1670 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1671 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1672 return -EFAULT;
1673
1674 + pax_open_userland();
1675 +
1676 smp_mb();
1677 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1678 "1: ldrex %1, [%4]\n"
1679 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1680 : "cc", "memory");
1681 smp_mb();
1682
1683 + pax_close_userland();
1684 +
1685 *uval = val;
1686 return ret;
1687 }
1688 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1689 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1690 return -EFAULT;
1691
1692 + pax_open_userland();
1693 +
1694 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1695 "1: " TUSER(ldr) " %1, [%4]\n"
1696 " teq %1, %2\n"
1697 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1698 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1699 : "cc", "memory");
1700
1701 + pax_close_userland();
1702 +
1703 *uval = val;
1704 return ret;
1705 }
1706 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1707 return -EFAULT;
1708
1709 pagefault_disable(); /* implies preempt_disable() */
1710 + pax_open_userland();
1711
1712 switch (op) {
1713 case FUTEX_OP_SET:
1714 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1715 ret = -ENOSYS;
1716 }
1717
1718 + pax_close_userland();
1719 pagefault_enable(); /* subsumes preempt_enable() */
1720
1721 if (!ret) {
1722 diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h
1723 index 4b1ce6c..bea3f73 100644
1724 --- a/arch/arm/include/asm/hardware/gic.h
1725 +++ b/arch/arm/include/asm/hardware/gic.h
1726 @@ -34,9 +34,10 @@
1727
1728 #ifndef __ASSEMBLY__
1729 #include <linux/irqdomain.h>
1730 +#include <linux/irq.h>
1731 struct device_node;
1732
1733 -extern struct irq_chip gic_arch_extn;
1734 +extern irq_chip_no_const gic_arch_extn;
1735
1736 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
1737 u32 offset, struct device_node *);
1738 diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
1739 index 8c5e828..91b99ab 100644
1740 --- a/arch/arm/include/asm/highmem.h
1741 +++ b/arch/arm/include/asm/highmem.h
1742 @@ -41,6 +41,13 @@ extern void kunmap_high(struct page *page);
1743 #endif
1744 #endif
1745
1746 +/*
1747 + * Needed to be able to broadcast the TLB invalidation for kmap.
1748 + */
1749 +#ifdef CONFIG_ARM_ERRATA_798181
1750 +#undef ARCH_NEEDS_KMAP_HIGH_GET
1751 +#endif
1752 +
1753 #ifdef ARCH_NEEDS_KMAP_HIGH_GET
1754 extern void *kmap_high_get(struct page *page);
1755 #else
1756 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1757 index 83eb2f7..ed77159 100644
1758 --- a/arch/arm/include/asm/kmap_types.h
1759 +++ b/arch/arm/include/asm/kmap_types.h
1760 @@ -4,6 +4,6 @@
1761 /*
1762 * This is the "bare minimum". AIO seems to require this.
1763 */
1764 -#define KM_TYPE_NR 16
1765 +#define KM_TYPE_NR 17
1766
1767 #endif
1768 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1769 index 9e614a1..3302cca 100644
1770 --- a/arch/arm/include/asm/mach/dma.h
1771 +++ b/arch/arm/include/asm/mach/dma.h
1772 @@ -22,7 +22,7 @@ struct dma_ops {
1773 int (*residue)(unsigned int, dma_t *); /* optional */
1774 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1775 const char *type;
1776 -};
1777 +} __do_const;
1778
1779 struct dma_struct {
1780 void *addr; /* single DMA address */
1781 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1782 index 2fe141f..192dc01 100644
1783 --- a/arch/arm/include/asm/mach/map.h
1784 +++ b/arch/arm/include/asm/mach/map.h
1785 @@ -27,13 +27,16 @@ struct map_desc {
1786 #define MT_MINICLEAN 6
1787 #define MT_LOW_VECTORS 7
1788 #define MT_HIGH_VECTORS 8
1789 -#define MT_MEMORY 9
1790 +#define MT_MEMORY_RWX 9
1791 #define MT_ROM 10
1792 -#define MT_MEMORY_NONCACHED 11
1793 +#define MT_MEMORY_NONCACHED_RX 11
1794 #define MT_MEMORY_DTCM 12
1795 #define MT_MEMORY_ITCM 13
1796 #define MT_MEMORY_SO 14
1797 #define MT_MEMORY_DMA_READY 15
1798 +#define MT_MEMORY_RW 16
1799 +#define MT_MEMORY_RX 17
1800 +#define MT_MEMORY_NONCACHED_RW 18
1801
1802 #ifdef CONFIG_MMU
1803 extern void iotable_init(struct map_desc *, int);
1804 diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
1805 index 863a661..a7b85e0 100644
1806 --- a/arch/arm/include/asm/mmu_context.h
1807 +++ b/arch/arm/include/asm/mmu_context.h
1808 @@ -27,6 +27,8 @@ void __check_vmalloc_seq(struct mm_struct *mm);
1809 void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
1810 #define init_new_context(tsk,mm) ({ atomic64_set(&mm->context.id, 0); 0; })
1811
1812 +DECLARE_PER_CPU(atomic64_t, active_asids);
1813 +
1814 #else /* !CONFIG_CPU_HAS_ASID */
1815
1816 #ifdef CONFIG_MMU
1817 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1818 index 53426c6..c7baff3 100644
1819 --- a/arch/arm/include/asm/outercache.h
1820 +++ b/arch/arm/include/asm/outercache.h
1821 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1822 #endif
1823 void (*set_debug)(unsigned long);
1824 void (*resume)(void);
1825 -};
1826 +} __no_const;
1827
1828 #ifdef CONFIG_OUTER_CACHE
1829
1830 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1831 index 812a494..71fc0b6 100644
1832 --- a/arch/arm/include/asm/page.h
1833 +++ b/arch/arm/include/asm/page.h
1834 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1835 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1836 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1837 unsigned long vaddr, struct vm_area_struct *vma);
1838 -};
1839 +} __no_const;
1840
1841 #ifdef MULTI_USER
1842 extern struct cpu_user_fns cpu_user;
1843 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1844 index 943504f..c37a730 100644
1845 --- a/arch/arm/include/asm/pgalloc.h
1846 +++ b/arch/arm/include/asm/pgalloc.h
1847 @@ -17,6 +17,7 @@
1848 #include <asm/processor.h>
1849 #include <asm/cacheflush.h>
1850 #include <asm/tlbflush.h>
1851 +#include <asm/system_info.h>
1852
1853 #define check_pgt_cache() do { } while (0)
1854
1855 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1856 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1857 }
1858
1859 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1860 +{
1861 + pud_populate(mm, pud, pmd);
1862 +}
1863 +
1864 #else /* !CONFIG_ARM_LPAE */
1865
1866 /*
1867 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1868 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1869 #define pmd_free(mm, pmd) do { } while (0)
1870 #define pud_populate(mm,pmd,pte) BUG()
1871 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1872
1873 #endif /* CONFIG_ARM_LPAE */
1874
1875 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1876 __free_page(pte);
1877 }
1878
1879 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1880 +{
1881 +#ifdef CONFIG_ARM_LPAE
1882 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1883 +#else
1884 + if (addr & SECTION_SIZE)
1885 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1886 + else
1887 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1888 +#endif
1889 + flush_pmd_entry(pmdp);
1890 +}
1891 +
1892 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1893 pmdval_t prot)
1894 {
1895 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1896 static inline void
1897 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1898 {
1899 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1900 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1901 }
1902 #define pmd_pgtable(pmd) pmd_page(pmd)
1903
1904 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1905 index 5cfba15..f415e1a 100644
1906 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1907 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1908 @@ -20,12 +20,15 @@
1909 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1910 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1911 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1912 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1913 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1914 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1915 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1916 +
1917 /*
1918 * - section
1919 */
1920 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1921 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1922 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1923 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1924 @@ -37,6 +40,7 @@
1925 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1926 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1927 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1928 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1929
1930 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1931 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1932 @@ -66,6 +70,7 @@
1933 * - extended small page/tiny page
1934 */
1935 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1936 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1937 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1938 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1939 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1940 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1941 index f97ee02..07f1be5 100644
1942 --- a/arch/arm/include/asm/pgtable-2level.h
1943 +++ b/arch/arm/include/asm/pgtable-2level.h
1944 @@ -125,6 +125,7 @@
1945 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1946 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1947 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1948 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1949
1950 /*
1951 * These are the memory types, defined to be compatible with
1952 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1953 index d795282..a43ea90 100644
1954 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1955 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1956 @@ -32,15 +32,18 @@
1957 #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
1958 #define PMD_BIT4 (_AT(pmdval_t, 0))
1959 #define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
1960 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 59) /* PXNTable */
1961
1962 /*
1963 * - section
1964 */
1965 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1966 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1967 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1968 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1969 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1970 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1971 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
1972 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54)
1973 #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0))
1974 #define PMD_SECT_AP_READ (_AT(pmdval_t, 0))
1975 @@ -66,6 +69,7 @@
1976 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1977 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1978 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1979 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1980 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1981
1982 /*
1983 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1984 index a3f3792..7b932a6 100644
1985 --- a/arch/arm/include/asm/pgtable-3level.h
1986 +++ b/arch/arm/include/asm/pgtable-3level.h
1987 @@ -74,6 +74,7 @@
1988 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1989 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1990 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1991 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1992 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1993 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1994 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1995 @@ -82,6 +83,7 @@
1996 /*
1997 * To be used in assembly code with the upper page attributes.
1998 */
1999 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
2000 #define L_PTE_XN_HIGH (1 << (54 - 32))
2001 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2002
2003 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2004 index c094749..a6ff605 100644
2005 --- a/arch/arm/include/asm/pgtable.h
2006 +++ b/arch/arm/include/asm/pgtable.h
2007 @@ -30,6 +30,9 @@
2008 #include <asm/pgtable-2level.h>
2009 #endif
2010
2011 +#define ktla_ktva(addr) (addr)
2012 +#define ktva_ktla(addr) (addr)
2013 +
2014 /*
2015 * Just any arbitrary offset to the start of the vmalloc VM area: the
2016 * current 8MB value just means that there will be a 8MB "hole" after the
2017 @@ -45,6 +48,9 @@
2018 #define LIBRARY_TEXT_START 0x0c000000
2019
2020 #ifndef __ASSEMBLY__
2021 +extern pteval_t __supported_pte_mask;
2022 +extern pmdval_t __supported_pmd_mask;
2023 +
2024 extern void __pte_error(const char *file, int line, pte_t);
2025 extern void __pmd_error(const char *file, int line, pmd_t);
2026 extern void __pgd_error(const char *file, int line, pgd_t);
2027 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2028 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2029 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2030
2031 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2032 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2033 +
2034 +#ifdef CONFIG_PAX_KERNEXEC
2035 +#include <asm/domain.h>
2036 +#include <linux/thread_info.h>
2037 +#include <linux/preempt.h>
2038 +#endif
2039 +
2040 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2041 +static inline int test_domain(int domain, int domaintype)
2042 +{
2043 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2044 +}
2045 +#endif
2046 +
2047 +#ifdef CONFIG_PAX_KERNEXEC
2048 +static inline unsigned long pax_open_kernel(void) {
2049 +#ifdef CONFIG_ARM_LPAE
2050 + /* TODO */
2051 +#else
2052 + preempt_disable();
2053 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2054 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2055 +#endif
2056 + return 0;
2057 +}
2058 +
2059 +static inline unsigned long pax_close_kernel(void) {
2060 +#ifdef CONFIG_ARM_LPAE
2061 + /* TODO */
2062 +#else
2063 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2064 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2065 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2066 + preempt_enable_no_resched();
2067 +#endif
2068 + return 0;
2069 +}
2070 +#else
2071 +static inline unsigned long pax_open_kernel(void) { return 0; }
2072 +static inline unsigned long pax_close_kernel(void) { return 0; }
2073 +#endif
2074 +
2075 /*
2076 * This is the lowest virtual address we can permit any user space
2077 * mapping to be mapped at. This is particularly important for
2078 @@ -63,8 +113,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2079 /*
2080 * The pgprot_* and protection_map entries will be fixed up in runtime
2081 * to include the cachable and bufferable bits based on memory policy,
2082 - * as well as any architecture dependent bits like global/ASID and SMP
2083 - * shared mapping bits.
2084 + * as well as any architecture dependent bits like global/ASID, PXN,
2085 + * and SMP shared mapping bits.
2086 */
2087 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2088
2089 @@ -241,7 +291,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2090 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2091 {
2092 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2093 - L_PTE_NONE | L_PTE_VALID;
2094 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2095 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2096 return pte;
2097 }
2098 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2099 index f3628fb..a0672dd 100644
2100 --- a/arch/arm/include/asm/proc-fns.h
2101 +++ b/arch/arm/include/asm/proc-fns.h
2102 @@ -75,7 +75,7 @@ extern struct processor {
2103 unsigned int suspend_size;
2104 void (*do_suspend)(void *);
2105 void (*do_resume)(void *);
2106 -} processor;
2107 +} __do_const processor;
2108
2109 #ifndef MULTI_CPU
2110 extern void cpu_proc_init(void);
2111 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2112 index 06e7d50..8a8e251 100644
2113 --- a/arch/arm/include/asm/processor.h
2114 +++ b/arch/arm/include/asm/processor.h
2115 @@ -65,9 +65,8 @@ struct thread_struct {
2116 regs->ARM_cpsr |= PSR_ENDSTATE; \
2117 regs->ARM_pc = pc & ~1; /* pc */ \
2118 regs->ARM_sp = sp; /* sp */ \
2119 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2120 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2121 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2122 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2123 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2124 nommu_start_thread(regs); \
2125 })
2126
2127 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2128 index d3a22be..3a69ad5 100644
2129 --- a/arch/arm/include/asm/smp.h
2130 +++ b/arch/arm/include/asm/smp.h
2131 @@ -107,7 +107,7 @@ struct smp_operations {
2132 int (*cpu_disable)(unsigned int cpu);
2133 #endif
2134 #endif
2135 -};
2136 +} __no_const;
2137
2138 /*
2139 * set platform specific SMP operations
2140 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2141 index cddda1f..ff357f7 100644
2142 --- a/arch/arm/include/asm/thread_info.h
2143 +++ b/arch/arm/include/asm/thread_info.h
2144 @@ -77,9 +77,9 @@ struct thread_info {
2145 .flags = 0, \
2146 .preempt_count = INIT_PREEMPT_COUNT, \
2147 .addr_limit = KERNEL_DS, \
2148 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2149 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2150 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2151 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2152 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2153 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2154 .restart_block = { \
2155 .fn = do_no_restart_syscall, \
2156 }, \
2157 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2158 #define TIF_SYSCALL_AUDIT 9
2159 #define TIF_SYSCALL_TRACEPOINT 10
2160 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2161 +
2162 +/* within 8 bits of TIF_SYSCALL_TRACE
2163 + * to meet flexible second operand requirements
2164 + */
2165 +#define TIF_GRSEC_SETXID 12
2166 +
2167 #define TIF_USING_IWMMXT 17
2168 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2169 #define TIF_RESTORE_SIGMASK 20
2170 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2171 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2172 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2173 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2174 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2175
2176 /* Checks for any syscall work in entry-common.S */
2177 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2178 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2179 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2180
2181 /*
2182 * Change these and you break ASM code in entry-common.S
2183 diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h
2184 index 6e924d3..a9f3ddf 100644
2185 --- a/arch/arm/include/asm/tlbflush.h
2186 +++ b/arch/arm/include/asm/tlbflush.h
2187 @@ -430,6 +430,21 @@ static inline void local_flush_tlb_kernel_page(unsigned long kaddr)
2188 }
2189 }
2190
2191 +#ifdef CONFIG_ARM_ERRATA_798181
2192 +static inline void dummy_flush_tlb_a15_erratum(void)
2193 +{
2194 + /*
2195 + * Dummy TLBIMVAIS. Using the unmapped address 0 and ASID 0.
2196 + */
2197 + asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0));
2198 + dsb();
2199 +}
2200 +#else
2201 +static inline void dummy_flush_tlb_a15_erratum(void)
2202 +{
2203 +}
2204 +#endif
2205 +
2206 /*
2207 * flush_pmd_entry
2208 *
2209 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2210 index 7e1f760..752fcb7 100644
2211 --- a/arch/arm/include/asm/uaccess.h
2212 +++ b/arch/arm/include/asm/uaccess.h
2213 @@ -18,6 +18,7 @@
2214 #include <asm/domain.h>
2215 #include <asm/unified.h>
2216 #include <asm/compiler.h>
2217 +#include <asm/pgtable.h>
2218
2219 #define VERIFY_READ 0
2220 #define VERIFY_WRITE 1
2221 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2222 #define USER_DS TASK_SIZE
2223 #define get_fs() (current_thread_info()->addr_limit)
2224
2225 +static inline void pax_open_userland(void)
2226 +{
2227 +
2228 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2229 + if (get_fs() == USER_DS) {
2230 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2231 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2232 + }
2233 +#endif
2234 +
2235 +}
2236 +
2237 +static inline void pax_close_userland(void)
2238 +{
2239 +
2240 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2241 + if (get_fs() == USER_DS) {
2242 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2243 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2244 + }
2245 +#endif
2246 +
2247 +}
2248 +
2249 static inline void set_fs(mm_segment_t fs)
2250 {
2251 current_thread_info()->addr_limit = fs;
2252 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2253 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2254 }
2255
2256 #define segment_eq(a,b) ((a) == (b))
2257 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2258
2259 #define get_user(x,p) \
2260 ({ \
2261 + int __e; \
2262 might_fault(); \
2263 - __get_user_check(x,p); \
2264 + pax_open_userland(); \
2265 + __e = __get_user_check(x,p); \
2266 + pax_close_userland(); \
2267 + __e; \
2268 })
2269
2270 extern int __put_user_1(void *, unsigned int);
2271 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2272
2273 #define put_user(x,p) \
2274 ({ \
2275 + int __e; \
2276 might_fault(); \
2277 - __put_user_check(x,p); \
2278 + pax_open_userland(); \
2279 + __e = __put_user_check(x,p); \
2280 + pax_close_userland(); \
2281 + __e; \
2282 })
2283
2284 #else /* CONFIG_MMU */
2285 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2286 #define __get_user(x,ptr) \
2287 ({ \
2288 long __gu_err = 0; \
2289 + pax_open_userland(); \
2290 __get_user_err((x),(ptr),__gu_err); \
2291 + pax_close_userland(); \
2292 __gu_err; \
2293 })
2294
2295 #define __get_user_error(x,ptr,err) \
2296 ({ \
2297 + pax_open_userland(); \
2298 __get_user_err((x),(ptr),err); \
2299 + pax_close_userland(); \
2300 (void) 0; \
2301 })
2302
2303 @@ -312,13 +349,17 @@ do { \
2304 #define __put_user(x,ptr) \
2305 ({ \
2306 long __pu_err = 0; \
2307 + pax_open_userland(); \
2308 __put_user_err((x),(ptr),__pu_err); \
2309 + pax_close_userland(); \
2310 __pu_err; \
2311 })
2312
2313 #define __put_user_error(x,ptr,err) \
2314 ({ \
2315 + pax_open_userland(); \
2316 __put_user_err((x),(ptr),err); \
2317 + pax_close_userland(); \
2318 (void) 0; \
2319 })
2320
2321 @@ -418,11 +459,44 @@ do { \
2322
2323
2324 #ifdef CONFIG_MMU
2325 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2326 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2327 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2328 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2329 +
2330 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2331 +{
2332 + unsigned long ret;
2333 +
2334 + check_object_size(to, n, false);
2335 + pax_open_userland();
2336 + ret = ___copy_from_user(to, from, n);
2337 + pax_close_userland();
2338 + return ret;
2339 +}
2340 +
2341 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2342 +{
2343 + unsigned long ret;
2344 +
2345 + check_object_size(from, n, true);
2346 + pax_open_userland();
2347 + ret = ___copy_to_user(to, from, n);
2348 + pax_close_userland();
2349 + return ret;
2350 +}
2351 +
2352 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2353 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2354 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2355 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2356 +
2357 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2358 +{
2359 + unsigned long ret;
2360 + pax_open_userland();
2361 + ret = ___clear_user(addr, n);
2362 + pax_close_userland();
2363 + return ret;
2364 +}
2365 +
2366 #else
2367 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2368 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2369 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2370
2371 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2372 {
2373 + if ((long)n < 0)
2374 + return n;
2375 +
2376 if (access_ok(VERIFY_READ, from, n))
2377 n = __copy_from_user(to, from, n);
2378 else /* security hole - plug it */
2379 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2380
2381 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2382 {
2383 + if ((long)n < 0)
2384 + return n;
2385 +
2386 if (access_ok(VERIFY_WRITE, to, n))
2387 n = __copy_to_user(to, from, n);
2388 return n;
2389 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2390 index 96ee092..37f1844 100644
2391 --- a/arch/arm/include/uapi/asm/ptrace.h
2392 +++ b/arch/arm/include/uapi/asm/ptrace.h
2393 @@ -73,7 +73,7 @@
2394 * ARMv7 groups of PSR bits
2395 */
2396 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2397 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2398 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2399 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2400 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2401
2402 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2403 index 60d3b73..d27ee09 100644
2404 --- a/arch/arm/kernel/armksyms.c
2405 +++ b/arch/arm/kernel/armksyms.c
2406 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2407 #ifdef CONFIG_MMU
2408 EXPORT_SYMBOL(copy_page);
2409
2410 -EXPORT_SYMBOL(__copy_from_user);
2411 -EXPORT_SYMBOL(__copy_to_user);
2412 -EXPORT_SYMBOL(__clear_user);
2413 +EXPORT_SYMBOL(___copy_from_user);
2414 +EXPORT_SYMBOL(___copy_to_user);
2415 +EXPORT_SYMBOL(___clear_user);
2416
2417 EXPORT_SYMBOL(__get_user_1);
2418 EXPORT_SYMBOL(__get_user_2);
2419 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2420 index 0f82098..3dbd3ee 100644
2421 --- a/arch/arm/kernel/entry-armv.S
2422 +++ b/arch/arm/kernel/entry-armv.S
2423 @@ -47,6 +47,87 @@
2424 9997:
2425 .endm
2426
2427 + .macro pax_enter_kernel
2428 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2429 + @ make aligned space for saved DACR
2430 + sub sp, sp, #8
2431 + @ save regs
2432 + stmdb sp!, {r1, r2}
2433 + @ read DACR from cpu_domain into r1
2434 + mov r2, sp
2435 + @ assume 8K pages, since we have to split the immediate in two
2436 + bic r2, r2, #(0x1fc0)
2437 + bic r2, r2, #(0x3f)
2438 + ldr r1, [r2, #TI_CPU_DOMAIN]
2439 + @ store old DACR on stack
2440 + str r1, [sp, #8]
2441 +#ifdef CONFIG_PAX_KERNEXEC
2442 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2443 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2444 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2445 +#endif
2446 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2447 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2448 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2449 +#endif
2450 + @ write r1 to current_thread_info()->cpu_domain
2451 + str r1, [r2, #TI_CPU_DOMAIN]
2452 + @ write r1 to DACR
2453 + mcr p15, 0, r1, c3, c0, 0
2454 + @ instruction sync
2455 + instr_sync
2456 + @ restore regs
2457 + ldmia sp!, {r1, r2}
2458 +#endif
2459 + .endm
2460 +
2461 + .macro pax_open_userland
2462 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2463 + @ save regs
2464 + stmdb sp!, {r0, r1}
2465 + @ read DACR from cpu_domain into r1
2466 + mov r0, sp
2467 + @ assume 8K pages, since we have to split the immediate in two
2468 + bic r0, r0, #(0x1fc0)
2469 + bic r0, r0, #(0x3f)
2470 + ldr r1, [r0, #TI_CPU_DOMAIN]
2471 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2472 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2473 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2474 + @ write r1 to current_thread_info()->cpu_domain
2475 + str r1, [r0, #TI_CPU_DOMAIN]
2476 + @ write r1 to DACR
2477 + mcr p15, 0, r1, c3, c0, 0
2478 + @ instruction sync
2479 + instr_sync
2480 + @ restore regs
2481 + ldmia sp!, {r0, r1}
2482 +#endif
2483 + .endm
2484 +
2485 + .macro pax_close_userland
2486 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2487 + @ save regs
2488 + stmdb sp!, {r0, r1}
2489 + @ read DACR from cpu_domain into r1
2490 + mov r0, sp
2491 + @ assume 8K pages, since we have to split the immediate in two
2492 + bic r0, r0, #(0x1fc0)
2493 + bic r0, r0, #(0x3f)
2494 + ldr r1, [r0, #TI_CPU_DOMAIN]
2495 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2496 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2497 + @ write r1 to current_thread_info()->cpu_domain
2498 + str r1, [r0, #TI_CPU_DOMAIN]
2499 + @ write r1 to DACR
2500 + mcr p15, 0, r1, c3, c0, 0
2501 + @ instruction sync
2502 + instr_sync
2503 + @ restore regs
2504 + ldmia sp!, {r0, r1}
2505 +#endif
2506 + .endm
2507 +
2508 .macro pabt_helper
2509 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2510 #ifdef MULTI_PABORT
2511 @@ -89,11 +170,15 @@
2512 * Invalid mode handlers
2513 */
2514 .macro inv_entry, reason
2515 +
2516 + pax_enter_kernel
2517 +
2518 sub sp, sp, #S_FRAME_SIZE
2519 ARM( stmib sp, {r1 - lr} )
2520 THUMB( stmia sp, {r0 - r12} )
2521 THUMB( str sp, [sp, #S_SP] )
2522 THUMB( str lr, [sp, #S_LR] )
2523 +
2524 mov r1, #\reason
2525 .endm
2526
2527 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2528 .macro svc_entry, stack_hole=0
2529 UNWIND(.fnstart )
2530 UNWIND(.save {r0 - pc} )
2531 +
2532 + pax_enter_kernel
2533 +
2534 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2535 +
2536 #ifdef CONFIG_THUMB2_KERNEL
2537 SPFIX( str r0, [sp] ) @ temporarily saved
2538 SPFIX( mov r0, sp )
2539 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2540 ldmia r0, {r3 - r5}
2541 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2542 mov r6, #-1 @ "" "" "" ""
2543 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 + @ offset sp by 8 as done in pax_enter_kernel
2545 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2546 +#else
2547 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2548 +#endif
2549 SPFIX( addeq r2, r2, #4 )
2550 str r3, [sp, #-4]! @ save the "real" r0 copied
2551 @ from the exception stack
2552 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2553 .macro usr_entry
2554 UNWIND(.fnstart )
2555 UNWIND(.cantunwind ) @ don't unwind the user space
2556 +
2557 + pax_enter_kernel_user
2558 +
2559 sub sp, sp, #S_FRAME_SIZE
2560 ARM( stmib sp, {r1 - r12} )
2561 THUMB( stmia sp, {r0 - r12} )
2562 @@ -456,7 +553,9 @@ __und_usr:
2563 tst r3, #PSR_T_BIT @ Thumb mode?
2564 bne __und_usr_thumb
2565 sub r4, r2, #4 @ ARM instr at LR - 4
2566 + pax_open_userland
2567 1: ldrt r0, [r4]
2568 + pax_close_userland
2569 #ifdef CONFIG_CPU_ENDIAN_BE8
2570 rev r0, r0 @ little endian instruction
2571 #endif
2572 @@ -491,10 +590,14 @@ __und_usr_thumb:
2573 */
2574 .arch armv6t2
2575 #endif
2576 + pax_open_userland
2577 2: ldrht r5, [r4]
2578 + pax_close_userland
2579 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2580 blo __und_usr_fault_16 @ 16bit undefined instruction
2581 + pax_open_userland
2582 3: ldrht r0, [r2]
2583 + pax_close_userland
2584 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2585 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2586 orr r0, r0, r5, lsl #16
2587 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2588 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2589 THUMB( str sp, [ip], #4 )
2590 THUMB( str lr, [ip], #4 )
2591 -#ifdef CONFIG_CPU_USE_DOMAINS
2592 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2593 ldr r6, [r2, #TI_CPU_DOMAIN]
2594 #endif
2595 set_tls r3, r4, r5
2596 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2597 ldr r8, =__stack_chk_guard
2598 ldr r7, [r7, #TSK_STACK_CANARY]
2599 #endif
2600 -#ifdef CONFIG_CPU_USE_DOMAINS
2601 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2602 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2603 #endif
2604 mov r5, r0
2605 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2606 index a6c301e..908821b 100644
2607 --- a/arch/arm/kernel/entry-common.S
2608 +++ b/arch/arm/kernel/entry-common.S
2609 @@ -10,18 +10,46 @@
2610
2611 #include <asm/unistd.h>
2612 #include <asm/ftrace.h>
2613 +#include <asm/domain.h>
2614 #include <asm/unwind.h>
2615
2616 +#include "entry-header.S"
2617 +
2618 #ifdef CONFIG_NEED_RET_TO_USER
2619 #include <mach/entry-macro.S>
2620 #else
2621 .macro arch_ret_to_user, tmp1, tmp2
2622 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2623 + @ save regs
2624 + stmdb sp!, {r1, r2}
2625 + @ read DACR from cpu_domain into r1
2626 + mov r2, sp
2627 + @ assume 8K pages, since we have to split the immediate in two
2628 + bic r2, r2, #(0x1fc0)
2629 + bic r2, r2, #(0x3f)
2630 + ldr r1, [r2, #TI_CPU_DOMAIN]
2631 +#ifdef CONFIG_PAX_KERNEXEC
2632 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2633 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2634 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2635 +#endif
2636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2637 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2638 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2639 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2640 +#endif
2641 + @ write r1 to current_thread_info()->cpu_domain
2642 + str r1, [r2, #TI_CPU_DOMAIN]
2643 + @ write r1 to DACR
2644 + mcr p15, 0, r1, c3, c0, 0
2645 + @ instruction sync
2646 + instr_sync
2647 + @ restore regs
2648 + ldmia sp!, {r1, r2}
2649 +#endif
2650 .endm
2651 #endif
2652
2653 -#include "entry-header.S"
2654 -
2655 -
2656 .align 5
2657 /*
2658 * This is the fast syscall return path. We do as little as
2659 @@ -339,6 +367,7 @@ ENDPROC(ftrace_stub)
2660
2661 .align 5
2662 ENTRY(vector_swi)
2663 +
2664 sub sp, sp, #S_FRAME_SIZE
2665 stmia sp, {r0 - r12} @ Calling r0 - r12
2666 ARM( add r8, sp, #S_PC )
2667 @@ -388,6 +417,12 @@ ENTRY(vector_swi)
2668 ldr scno, [lr, #-4] @ get SWI instruction
2669 #endif
2670
2671 + /*
2672 + * do this here to avoid a performance hit of wrapping the code above
2673 + * that directly dereferences userland to parse the SWI instruction
2674 + */
2675 + pax_enter_kernel_user
2676 +
2677 #ifdef CONFIG_ALIGNMENT_TRAP
2678 ldr ip, __cr_alignment
2679 ldr ip, [ip]
2680 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2681 index 9a8531e..812e287 100644
2682 --- a/arch/arm/kernel/entry-header.S
2683 +++ b/arch/arm/kernel/entry-header.S
2684 @@ -73,9 +73,66 @@
2685 msr cpsr_c, \rtemp @ switch back to the SVC mode
2686 .endm
2687
2688 + .macro pax_enter_kernel_user
2689 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2690 + @ save regs
2691 + stmdb sp!, {r0, r1}
2692 + @ read DACR from cpu_domain into r1
2693 + mov r0, sp
2694 + @ assume 8K pages, since we have to split the immediate in two
2695 + bic r0, r0, #(0x1fc0)
2696 + bic r0, r0, #(0x3f)
2697 + ldr r1, [r0, #TI_CPU_DOMAIN]
2698 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2699 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2700 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2701 +#endif
2702 +#ifdef CONFIG_PAX_KERNEXEC
2703 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2704 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2705 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2706 +#endif
2707 + @ write r1 to current_thread_info()->cpu_domain
2708 + str r1, [r0, #TI_CPU_DOMAIN]
2709 + @ write r1 to DACR
2710 + mcr p15, 0, r1, c3, c0, 0
2711 + @ instruction sync
2712 + instr_sync
2713 + @ restore regs
2714 + ldmia sp!, {r0, r1}
2715 +#endif
2716 + .endm
2717 +
2718 + .macro pax_exit_kernel
2719 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2720 + @ save regs
2721 + stmdb sp!, {r0, r1}
2722 + @ read old DACR from stack into r1
2723 + ldr r1, [sp, #(8 + S_SP)]
2724 + sub r1, r1, #8
2725 + ldr r1, [r1]
2726 +
2727 + @ write r1 to current_thread_info()->cpu_domain
2728 + mov r0, sp
2729 + @ assume 8K pages, since we have to split the immediate in two
2730 + bic r0, r0, #(0x1fc0)
2731 + bic r0, r0, #(0x3f)
2732 + str r1, [r0, #TI_CPU_DOMAIN]
2733 + @ write r1 to DACR
2734 + mcr p15, 0, r1, c3, c0, 0
2735 + @ instruction sync
2736 + instr_sync
2737 + @ restore regs
2738 + ldmia sp!, {r0, r1}
2739 +#endif
2740 + .endm
2741 +
2742 #ifndef CONFIG_THUMB2_KERNEL
2743 .macro svc_exit, rpsr
2744 msr spsr_cxsf, \rpsr
2745 +
2746 + pax_exit_kernel
2747 +
2748 #if defined(CONFIG_CPU_V6)
2749 ldr r0, [sp]
2750 strex r1, r2, [sp] @ clear the exclusive monitor
2751 @@ -121,6 +178,9 @@
2752 .endm
2753 #else /* CONFIG_THUMB2_KERNEL */
2754 .macro svc_exit, rpsr
2755 +
2756 + pax_exit_kernel
2757 +
2758 ldr lr, [sp, #S_SP] @ top of the stack
2759 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2760 clrex @ clear the exclusive monitor
2761 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2762 index 2adda11..7fbe958 100644
2763 --- a/arch/arm/kernel/fiq.c
2764 +++ b/arch/arm/kernel/fiq.c
2765 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2766 #if defined(CONFIG_CPU_USE_DOMAINS)
2767 memcpy((void *)0xffff001c, start, length);
2768 #else
2769 + pax_open_kernel();
2770 memcpy(vectors_page + 0x1c, start, length);
2771 + pax_close_kernel();
2772 #endif
2773 flush_icache_range(0xffff001c, 0xffff001c + length);
2774 if (!vectors_high())
2775 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2776 index e0eb9a1..caee108 100644
2777 --- a/arch/arm/kernel/head.S
2778 +++ b/arch/arm/kernel/head.S
2779 @@ -52,7 +52,9 @@
2780 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2781
2782 .macro pgtbl, rd, phys
2783 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2784 + mov \rd, #TEXT_OFFSET
2785 + sub \rd, #PG_DIR_SIZE
2786 + add \rd, \rd, \phys
2787 .endm
2788
2789 /*
2790 @@ -267,7 +269,7 @@ __create_page_tables:
2791 addne r6, r6, #1 << SECTION_SHIFT
2792 strne r6, [r3]
2793
2794 -#if defined(CONFIG_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2795 +#if defined(CONFIG_ARM_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2796 sub r4, r4, #4 @ Fixup page table pointer
2797 @ for 64-bit descriptors
2798 #endif
2799 @@ -434,7 +436,7 @@ __enable_mmu:
2800 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2801 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2802 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2803 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2804 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2805 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2806 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2807 #endif
2808 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2809 index 5ff2e77..556d030 100644
2810 --- a/arch/arm/kernel/hw_breakpoint.c
2811 +++ b/arch/arm/kernel/hw_breakpoint.c
2812 @@ -1011,7 +1011,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2813 return NOTIFY_OK;
2814 }
2815
2816 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2817 +static struct notifier_block dbg_reset_nb = {
2818 .notifier_call = dbg_reset_notify,
2819 };
2820
2821 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2822 index 1e9be5d..03edbc2 100644
2823 --- a/arch/arm/kernel/module.c
2824 +++ b/arch/arm/kernel/module.c
2825 @@ -37,12 +37,37 @@
2826 #endif
2827
2828 #ifdef CONFIG_MMU
2829 -void *module_alloc(unsigned long size)
2830 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2831 {
2832 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2833 + return NULL;
2834 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2835 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2836 + GFP_KERNEL, prot, -1,
2837 __builtin_return_address(0));
2838 }
2839 +
2840 +void *module_alloc(unsigned long size)
2841 +{
2842 +
2843 +#ifdef CONFIG_PAX_KERNEXEC
2844 + return __module_alloc(size, PAGE_KERNEL);
2845 +#else
2846 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2847 +#endif
2848 +
2849 +}
2850 +
2851 +#ifdef CONFIG_PAX_KERNEXEC
2852 +void module_free_exec(struct module *mod, void *module_region)
2853 +{
2854 + module_free(mod, module_region);
2855 +}
2856 +
2857 +void *module_alloc_exec(unsigned long size)
2858 +{
2859 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2860 +}
2861 +#endif
2862 #endif
2863
2864 int
2865 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2866 index 07314af..c46655c 100644
2867 --- a/arch/arm/kernel/patch.c
2868 +++ b/arch/arm/kernel/patch.c
2869 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2870 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2871 int size;
2872
2873 + pax_open_kernel();
2874 if (thumb2 && __opcode_is_thumb16(insn)) {
2875 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2876 size = sizeof(u16);
2877 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2878 *(u32 *)addr = insn;
2879 size = sizeof(u32);
2880 }
2881 + pax_close_kernel();
2882
2883 flush_icache_range((uintptr_t)(addr),
2884 (uintptr_t)(addr) + size);
2885 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2886 index 5f66206..dce492f 100644
2887 --- a/arch/arm/kernel/perf_event_cpu.c
2888 +++ b/arch/arm/kernel/perf_event_cpu.c
2889 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2890 return NOTIFY_OK;
2891 }
2892
2893 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2894 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2895 .notifier_call = cpu_pmu_notify,
2896 };
2897
2898 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2899 index c6dec5f..e0fddd1 100644
2900 --- a/arch/arm/kernel/process.c
2901 +++ b/arch/arm/kernel/process.c
2902 @@ -28,7 +28,6 @@
2903 #include <linux/tick.h>
2904 #include <linux/utsname.h>
2905 #include <linux/uaccess.h>
2906 -#include <linux/random.h>
2907 #include <linux/hw_breakpoint.h>
2908 #include <linux/cpuidle.h>
2909 #include <linux/leds.h>
2910 @@ -256,9 +255,10 @@ void machine_power_off(void)
2911 machine_shutdown();
2912 if (pm_power_off)
2913 pm_power_off();
2914 + BUG();
2915 }
2916
2917 -void machine_restart(char *cmd)
2918 +__noreturn void machine_restart(char *cmd)
2919 {
2920 machine_shutdown();
2921
2922 @@ -283,8 +283,8 @@ void __show_regs(struct pt_regs *regs)
2923 init_utsname()->release,
2924 (int)strcspn(init_utsname()->version, " "),
2925 init_utsname()->version);
2926 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2927 - print_symbol("LR is at %s\n", regs->ARM_lr);
2928 + printk("PC is at %pA\n", instruction_pointer(regs));
2929 + printk("LR is at %pA\n", regs->ARM_lr);
2930 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2931 "sp : %08lx ip : %08lx fp : %08lx\n",
2932 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2933 @@ -452,12 +452,6 @@ unsigned long get_wchan(struct task_struct *p)
2934 return 0;
2935 }
2936
2937 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2938 -{
2939 - unsigned long range_end = mm->brk + 0x02000000;
2940 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2941 -}
2942 -
2943 #ifdef CONFIG_MMU
2944 /*
2945 * The vectors page is always readable from user space for the
2946 @@ -470,9 +464,8 @@ static int __init gate_vma_init(void)
2947 {
2948 gate_vma.vm_start = 0xffff0000;
2949 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2950 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2951 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2952 - VM_MAYREAD | VM_MAYEXEC;
2953 + gate_vma.vm_flags = VM_NONE;
2954 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2955 return 0;
2956 }
2957 arch_initcall(gate_vma_init);
2958 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2959 index 03deeff..741ce88 100644
2960 --- a/arch/arm/kernel/ptrace.c
2961 +++ b/arch/arm/kernel/ptrace.c
2962 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2963 return current_thread_info()->syscall;
2964 }
2965
2966 +#ifdef CONFIG_GRKERNSEC_SETXID
2967 +extern void gr_delayed_cred_worker(void);
2968 +#endif
2969 +
2970 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2971 {
2972 current_thread_info()->syscall = scno;
2973
2974 +#ifdef CONFIG_GRKERNSEC_SETXID
2975 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2976 + gr_delayed_cred_worker();
2977 +#endif
2978 +
2979 /* Do the secure computing check first; failures should be fast. */
2980 if (secure_computing(scno) == -1)
2981 return -1;
2982 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2983 index 3f6cbb2..39305c7 100644
2984 --- a/arch/arm/kernel/setup.c
2985 +++ b/arch/arm/kernel/setup.c
2986 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
2987 unsigned int elf_hwcap __read_mostly;
2988 EXPORT_SYMBOL(elf_hwcap);
2989
2990 +pteval_t __supported_pte_mask __read_only;
2991 +pmdval_t __supported_pmd_mask __read_only;
2992
2993 #ifdef MULTI_CPU
2994 -struct processor processor __read_mostly;
2995 +struct processor processor;
2996 #endif
2997 #ifdef MULTI_TLB
2998 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2999 +struct cpu_tlb_fns cpu_tlb __read_only;
3000 #endif
3001 #ifdef MULTI_USER
3002 -struct cpu_user_fns cpu_user __read_mostly;
3003 +struct cpu_user_fns cpu_user __read_only;
3004 #endif
3005 #ifdef MULTI_CACHE
3006 -struct cpu_cache_fns cpu_cache __read_mostly;
3007 +struct cpu_cache_fns cpu_cache __read_only;
3008 #endif
3009 #ifdef CONFIG_OUTER_CACHE
3010 -struct outer_cache_fns outer_cache __read_mostly;
3011 +struct outer_cache_fns outer_cache __read_only;
3012 EXPORT_SYMBOL(outer_cache);
3013 #endif
3014
3015 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3016 asm("mrc p15, 0, %0, c0, c1, 4"
3017 : "=r" (mmfr0));
3018 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3019 - (mmfr0 & 0x000000f0) >= 0x00000030)
3020 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3021 cpu_arch = CPU_ARCH_ARMv7;
3022 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3023 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3024 + __supported_pte_mask |= L_PTE_PXN;
3025 + __supported_pmd_mask |= PMD_PXNTABLE;
3026 + }
3027 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3028 (mmfr0 & 0x000000f0) == 0x00000020)
3029 cpu_arch = CPU_ARCH_ARMv6;
3030 else
3031 @@ -462,7 +468,7 @@ static void __init setup_processor(void)
3032 __cpu_architecture = __get_cpu_architecture();
3033
3034 #ifdef MULTI_CPU
3035 - processor = *list->proc;
3036 + memcpy((void *)&processor, list->proc, sizeof processor);
3037 #endif
3038 #ifdef MULTI_TLB
3039 cpu_tlb = *list->tlb;
3040 @@ -524,7 +530,7 @@ int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
3041 size -= start & ~PAGE_MASK;
3042 bank->start = PAGE_ALIGN(start);
3043
3044 -#ifndef CONFIG_LPAE
3045 +#ifndef CONFIG_ARM_LPAE
3046 if (bank->start + size < bank->start) {
3047 printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
3048 "32-bit physical address space\n", (long long)start);
3049 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3050 index 56f72d2..6924200 100644
3051 --- a/arch/arm/kernel/signal.c
3052 +++ b/arch/arm/kernel/signal.c
3053 @@ -433,22 +433,14 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
3054 __put_user(sigreturn_codes[idx+1], rc+1))
3055 return 1;
3056
3057 - if (cpsr & MODE32_BIT) {
3058 - /*
3059 - * 32-bit code can use the new high-page
3060 - * signal return code support.
3061 - */
3062 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3063 - } else {
3064 - /*
3065 - * Ensure that the instruction cache sees
3066 - * the return code written onto the stack.
3067 - */
3068 - flush_icache_range((unsigned long)rc,
3069 - (unsigned long)(rc + 2));
3070 + /*
3071 + * Ensure that the instruction cache sees
3072 + * the return code written onto the stack.
3073 + */
3074 + flush_icache_range((unsigned long)rc,
3075 + (unsigned long)(rc + 2));
3076
3077 - retcode = ((unsigned long)rc) + thumb;
3078 - }
3079 + retcode = ((unsigned long)rc) + thumb;
3080 }
3081
3082 regs->ARM_r0 = usig;
3083 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3084 index 58af91c..343ce99 100644
3085 --- a/arch/arm/kernel/smp.c
3086 +++ b/arch/arm/kernel/smp.c
3087 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3088
3089 static DECLARE_COMPLETION(cpu_running);
3090
3091 -static struct smp_operations smp_ops;
3092 +static struct smp_operations smp_ops __read_only;
3093
3094 void __init smp_set_ops(struct smp_operations *ops)
3095 {
3096 diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
3097 index 02c5d2c..e5695ad 100644
3098 --- a/arch/arm/kernel/smp_tlb.c
3099 +++ b/arch/arm/kernel/smp_tlb.c
3100 @@ -12,6 +12,7 @@
3101
3102 #include <asm/smp_plat.h>
3103 #include <asm/tlbflush.h>
3104 +#include <asm/mmu_context.h>
3105
3106 /**********************************************************************/
3107
3108 @@ -64,12 +65,72 @@ static inline void ipi_flush_tlb_kernel_range(void *arg)
3109 local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
3110 }
3111
3112 +#ifdef CONFIG_ARM_ERRATA_798181
3113 +static int erratum_a15_798181(void)
3114 +{
3115 + unsigned int midr = read_cpuid_id();
3116 +
3117 + /* Cortex-A15 r0p0..r3p2 affected */
3118 + if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
3119 + return 0;
3120 + return 1;
3121 +}
3122 +#else
3123 +static int erratum_a15_798181(void)
3124 +{
3125 + return 0;
3126 +}
3127 +#endif
3128 +
3129 +static void ipi_flush_tlb_a15_erratum(void *arg)
3130 +{
3131 + dmb();
3132 +}
3133 +
3134 +static void broadcast_tlb_a15_erratum(void)
3135 +{
3136 + if (!erratum_a15_798181())
3137 + return;
3138 +
3139 + dummy_flush_tlb_a15_erratum();
3140 + smp_call_function_many(cpu_online_mask, ipi_flush_tlb_a15_erratum,
3141 + NULL, 1);
3142 +}
3143 +
3144 +static void broadcast_tlb_mm_a15_erratum(struct mm_struct *mm)
3145 +{
3146 + int cpu;
3147 + cpumask_t mask = { CPU_BITS_NONE };
3148 +
3149 + if (!erratum_a15_798181())
3150 + return;
3151 +
3152 + dummy_flush_tlb_a15_erratum();
3153 + for_each_online_cpu(cpu) {
3154 + if (cpu == smp_processor_id())
3155 + continue;
3156 + /*
3157 + * We only need to send an IPI if the other CPUs are running
3158 + * the same ASID as the one being invalidated. There is no
3159 + * need for locking around the active_asids check since the
3160 + * switch_mm() function has at least one dmb() (as required by
3161 + * this workaround) in case a context switch happens on
3162 + * another CPU after the condition below.
3163 + */
3164 + if (atomic64_read(&mm->context.id) ==
3165 + atomic64_read(&per_cpu(active_asids, cpu)))
3166 + cpumask_set_cpu(cpu, &mask);
3167 + }
3168 + smp_call_function_many(&mask, ipi_flush_tlb_a15_erratum, NULL, 1);
3169 +}
3170 +
3171 void flush_tlb_all(void)
3172 {
3173 if (tlb_ops_need_broadcast())
3174 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
3175 else
3176 local_flush_tlb_all();
3177 + broadcast_tlb_a15_erratum();
3178 }
3179
3180 void flush_tlb_mm(struct mm_struct *mm)
3181 @@ -78,6 +139,7 @@ void flush_tlb_mm(struct mm_struct *mm)
3182 on_each_cpu_mask(mm_cpumask(mm), ipi_flush_tlb_mm, mm, 1);
3183 else
3184 local_flush_tlb_mm(mm);
3185 + broadcast_tlb_mm_a15_erratum(mm);
3186 }
3187
3188 void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3189 @@ -90,6 +152,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3190 &ta, 1);
3191 } else
3192 local_flush_tlb_page(vma, uaddr);
3193 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3194 }
3195
3196 void flush_tlb_kernel_page(unsigned long kaddr)
3197 @@ -100,6 +163,7 @@ void flush_tlb_kernel_page(unsigned long kaddr)
3198 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
3199 } else
3200 local_flush_tlb_kernel_page(kaddr);
3201 + broadcast_tlb_a15_erratum();
3202 }
3203
3204 void flush_tlb_range(struct vm_area_struct *vma,
3205 @@ -114,6 +178,7 @@ void flush_tlb_range(struct vm_area_struct *vma,
3206 &ta, 1);
3207 } else
3208 local_flush_tlb_range(vma, start, end);
3209 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3210 }
3211
3212 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3213 @@ -125,5 +190,6 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3214 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
3215 } else
3216 local_flush_tlb_kernel_range(start, end);
3217 + broadcast_tlb_a15_erratum();
3218 }
3219
3220 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3221 index b0179b8..829510e 100644
3222 --- a/arch/arm/kernel/traps.c
3223 +++ b/arch/arm/kernel/traps.c
3224 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3225 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3226 {
3227 #ifdef CONFIG_KALLSYMS
3228 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3229 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3230 #else
3231 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3232 #endif
3233 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3234 static int die_owner = -1;
3235 static unsigned int die_nest_count;
3236
3237 +extern void gr_handle_kernel_exploit(void);
3238 +
3239 static unsigned long oops_begin(void)
3240 {
3241 int cpu;
3242 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3243 panic("Fatal exception in interrupt");
3244 if (panic_on_oops)
3245 panic("Fatal exception");
3246 +
3247 + gr_handle_kernel_exploit();
3248 +
3249 if (signr)
3250 do_exit(signr);
3251 }
3252 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3253 * The user helper at 0xffff0fe0 must be used instead.
3254 * (see entry-armv.S for details)
3255 */
3256 + pax_open_kernel();
3257 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3258 + pax_close_kernel();
3259 }
3260 return 0;
3261
3262 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3263 */
3264 kuser_get_tls_init(vectors);
3265
3266 - /*
3267 - * Copy signal return handlers into the vector page, and
3268 - * set sigreturn to be a pointer to these.
3269 - */
3270 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3271 - sigreturn_codes, sizeof(sigreturn_codes));
3272 -
3273 flush_icache_range(vectors, vectors + PAGE_SIZE);
3274 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3275 +
3276 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3277 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3278 +#endif
3279 +
3280 }
3281 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3282 index 11c1785..1b209f4 100644
3283 --- a/arch/arm/kernel/vmlinux.lds.S
3284 +++ b/arch/arm/kernel/vmlinux.lds.S
3285 @@ -8,7 +8,11 @@
3286 #include <asm/thread_info.h>
3287 #include <asm/memory.h>
3288 #include <asm/page.h>
3289 -
3290 +
3291 +#ifdef CONFIG_PAX_KERNEXEC
3292 +#include <asm/pgtable.h>
3293 +#endif
3294 +
3295 #define PROC_INFO \
3296 . = ALIGN(4); \
3297 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3298 @@ -90,6 +94,11 @@ SECTIONS
3299 _text = .;
3300 HEAD_TEXT
3301 }
3302 +
3303 +#ifdef CONFIG_PAX_KERNEXEC
3304 + . = ALIGN(1<<SECTION_SHIFT);
3305 +#endif
3306 +
3307 .text : { /* Real text segment */
3308 _stext = .; /* Text and read-only data */
3309 __exception_text_start = .;
3310 @@ -112,6 +121,8 @@ SECTIONS
3311 ARM_CPU_KEEP(PROC_INFO)
3312 }
3313
3314 + _etext = .; /* End of text section */
3315 +
3316 RO_DATA(PAGE_SIZE)
3317
3318 . = ALIGN(4);
3319 @@ -142,7 +153,9 @@ SECTIONS
3320
3321 NOTES
3322
3323 - _etext = .; /* End of text and rodata section */
3324 +#ifdef CONFIG_PAX_KERNEXEC
3325 + . = ALIGN(1<<SECTION_SHIFT);
3326 +#endif
3327
3328 #ifndef CONFIG_XIP_KERNEL
3329 . = ALIGN(PAGE_SIZE);
3330 @@ -203,6 +216,11 @@ SECTIONS
3331 . = PAGE_OFFSET + TEXT_OFFSET;
3332 #else
3333 __init_end = .;
3334 +
3335 +#ifdef CONFIG_PAX_KERNEXEC
3336 + . = ALIGN(1<<SECTION_SHIFT);
3337 +#endif
3338 +
3339 . = ALIGN(THREAD_SIZE);
3340 __data_loc = .;
3341 #endif
3342 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3343 index 14a0d98..7771a7d 100644
3344 --- a/arch/arm/lib/clear_user.S
3345 +++ b/arch/arm/lib/clear_user.S
3346 @@ -12,14 +12,14 @@
3347
3348 .text
3349
3350 -/* Prototype: int __clear_user(void *addr, size_t sz)
3351 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3352 * Purpose : clear some user memory
3353 * Params : addr - user memory address to clear
3354 * : sz - number of bytes to clear
3355 * Returns : number of bytes NOT cleared
3356 */
3357 ENTRY(__clear_user_std)
3358 -WEAK(__clear_user)
3359 +WEAK(___clear_user)
3360 stmfd sp!, {r1, lr}
3361 mov r2, #0
3362 cmp r1, #4
3363 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3364 USER( strnebt r2, [r0])
3365 mov r0, #0
3366 ldmfd sp!, {r1, pc}
3367 -ENDPROC(__clear_user)
3368 +ENDPROC(___clear_user)
3369 ENDPROC(__clear_user_std)
3370
3371 .pushsection .fixup,"ax"
3372 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3373 index 66a477a..bee61d3 100644
3374 --- a/arch/arm/lib/copy_from_user.S
3375 +++ b/arch/arm/lib/copy_from_user.S
3376 @@ -16,7 +16,7 @@
3377 /*
3378 * Prototype:
3379 *
3380 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3381 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3382 *
3383 * Purpose:
3384 *
3385 @@ -84,11 +84,11 @@
3386
3387 .text
3388
3389 -ENTRY(__copy_from_user)
3390 +ENTRY(___copy_from_user)
3391
3392 #include "copy_template.S"
3393
3394 -ENDPROC(__copy_from_user)
3395 +ENDPROC(___copy_from_user)
3396
3397 .pushsection .fixup,"ax"
3398 .align 0
3399 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3400 index 6ee2f67..d1cce76 100644
3401 --- a/arch/arm/lib/copy_page.S
3402 +++ b/arch/arm/lib/copy_page.S
3403 @@ -10,6 +10,7 @@
3404 * ASM optimised string functions
3405 */
3406 #include <linux/linkage.h>
3407 +#include <linux/const.h>
3408 #include <asm/assembler.h>
3409 #include <asm/asm-offsets.h>
3410 #include <asm/cache.h>
3411 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3412 index d066df6..df28194 100644
3413 --- a/arch/arm/lib/copy_to_user.S
3414 +++ b/arch/arm/lib/copy_to_user.S
3415 @@ -16,7 +16,7 @@
3416 /*
3417 * Prototype:
3418 *
3419 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3420 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3421 *
3422 * Purpose:
3423 *
3424 @@ -88,11 +88,11 @@
3425 .text
3426
3427 ENTRY(__copy_to_user_std)
3428 -WEAK(__copy_to_user)
3429 +WEAK(___copy_to_user)
3430
3431 #include "copy_template.S"
3432
3433 -ENDPROC(__copy_to_user)
3434 +ENDPROC(___copy_to_user)
3435 ENDPROC(__copy_to_user_std)
3436
3437 .pushsection .fixup,"ax"
3438 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3439 index 7d08b43..f7ca7ea 100644
3440 --- a/arch/arm/lib/csumpartialcopyuser.S
3441 +++ b/arch/arm/lib/csumpartialcopyuser.S
3442 @@ -57,8 +57,8 @@
3443 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3444 */
3445
3446 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3447 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3448 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3449 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3450
3451 #include "csumpartialcopygeneric.S"
3452
3453 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3454 index 6b93f6a..4aa5e85 100644
3455 --- a/arch/arm/lib/delay.c
3456 +++ b/arch/arm/lib/delay.c
3457 @@ -28,7 +28,7 @@
3458 /*
3459 * Default to the loop-based delay implementation.
3460 */
3461 -struct arm_delay_ops arm_delay_ops = {
3462 +struct arm_delay_ops arm_delay_ops __read_only = {
3463 .delay = __loop_delay,
3464 .const_udelay = __loop_const_udelay,
3465 .udelay = __loop_udelay,
3466 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3467 index 025f742..8432b08 100644
3468 --- a/arch/arm/lib/uaccess_with_memcpy.c
3469 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3470 @@ -104,7 +104,7 @@ out:
3471 }
3472
3473 unsigned long
3474 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3475 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3476 {
3477 /*
3478 * This test is stubbed out of the main function above to keep
3479 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3480 index bac21a5..b67ef8e 100644
3481 --- a/arch/arm/mach-kirkwood/common.c
3482 +++ b/arch/arm/mach-kirkwood/common.c
3483 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3484 clk_gate_ops.disable(hw);
3485 }
3486
3487 -static struct clk_ops clk_gate_fn_ops;
3488 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3489 +{
3490 + return clk_gate_ops.is_enabled(hw);
3491 +}
3492 +
3493 +static struct clk_ops clk_gate_fn_ops = {
3494 + .enable = clk_gate_fn_enable,
3495 + .disable = clk_gate_fn_disable,
3496 + .is_enabled = clk_gate_fn_is_enabled,
3497 +};
3498
3499 static struct clk __init *clk_register_gate_fn(struct device *dev,
3500 const char *name,
3501 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3502 gate_fn->fn_en = fn_en;
3503 gate_fn->fn_dis = fn_dis;
3504
3505 - /* ops is the gate ops, but with our enable/disable functions */
3506 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3507 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3508 - clk_gate_fn_ops = clk_gate_ops;
3509 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3510 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3511 - }
3512 -
3513 clk = clk_register(dev, &gate_fn->gate.hw);
3514
3515 if (IS_ERR(clk))
3516 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3517 index 0abb30f..54064da 100644
3518 --- a/arch/arm/mach-omap2/board-n8x0.c
3519 +++ b/arch/arm/mach-omap2/board-n8x0.c
3520 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3521 }
3522 #endif
3523
3524 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3525 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3526 .late_init = n8x0_menelaus_late_init,
3527 };
3528
3529 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3530 index 8033cb7..2f7cb62 100644
3531 --- a/arch/arm/mach-omap2/gpmc.c
3532 +++ b/arch/arm/mach-omap2/gpmc.c
3533 @@ -139,7 +139,6 @@ struct omap3_gpmc_regs {
3534 };
3535
3536 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3537 -static struct irq_chip gpmc_irq_chip;
3538 static unsigned gpmc_irq_start;
3539
3540 static struct resource gpmc_mem_root;
3541 @@ -700,6 +699,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3542
3543 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3544
3545 +static struct irq_chip gpmc_irq_chip = {
3546 + .name = "gpmc",
3547 + .irq_startup = gpmc_irq_noop_ret,
3548 + .irq_enable = gpmc_irq_enable,
3549 + .irq_disable = gpmc_irq_disable,
3550 + .irq_shutdown = gpmc_irq_noop,
3551 + .irq_ack = gpmc_irq_noop,
3552 + .irq_mask = gpmc_irq_noop,
3553 + .irq_unmask = gpmc_irq_noop,
3554 +
3555 +};
3556 +
3557 static int gpmc_setup_irq(void)
3558 {
3559 int i;
3560 @@ -714,15 +725,6 @@ static int gpmc_setup_irq(void)
3561 return gpmc_irq_start;
3562 }
3563
3564 - gpmc_irq_chip.name = "gpmc";
3565 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3566 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3567 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3568 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3569 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3570 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3571 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3572 -
3573 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3574 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3575
3576 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3577 index 5d3b4f4..ddba3c0 100644
3578 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3579 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3580 @@ -340,7 +340,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3581 return NOTIFY_OK;
3582 }
3583
3584 -static struct notifier_block __refdata irq_hotplug_notifier = {
3585 +static struct notifier_block irq_hotplug_notifier = {
3586 .notifier_call = irq_cpu_hotplug_notify,
3587 };
3588
3589 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3590 index e065daa..7b1ad9b 100644
3591 --- a/arch/arm/mach-omap2/omap_device.c
3592 +++ b/arch/arm/mach-omap2/omap_device.c
3593 @@ -686,7 +686,7 @@ void omap_device_delete(struct omap_device *od)
3594 * passes along the return value of omap_device_build_ss().
3595 */
3596 struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
3597 - struct omap_hwmod *oh, void *pdata,
3598 + struct omap_hwmod *oh, const void *pdata,
3599 int pdata_len,
3600 struct omap_device_pm_latency *pm_lats,
3601 int pm_lats_cnt, int is_early_device)
3602 @@ -720,7 +720,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
3603 */
3604 struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
3605 struct omap_hwmod **ohs, int oh_cnt,
3606 - void *pdata, int pdata_len,
3607 + const void *pdata, int pdata_len,
3608 struct omap_device_pm_latency *pm_lats,
3609 int pm_lats_cnt, int is_early_device)
3610 {
3611 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3612 index 0933c59..42b8e2d 100644
3613 --- a/arch/arm/mach-omap2/omap_device.h
3614 +++ b/arch/arm/mach-omap2/omap_device.h
3615 @@ -91,14 +91,14 @@ int omap_device_shutdown(struct platform_device *pdev);
3616 /* Core code interface */
3617
3618 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3619 - struct omap_hwmod *oh, void *pdata,
3620 + struct omap_hwmod *oh, const void *pdata,
3621 int pdata_len,
3622 struct omap_device_pm_latency *pm_lats,
3623 int pm_lats_cnt, int is_early_device);
3624
3625 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3626 struct omap_hwmod **oh, int oh_cnt,
3627 - void *pdata, int pdata_len,
3628 + const void *pdata, int pdata_len,
3629 struct omap_device_pm_latency *pm_lats,
3630 int pm_lats_cnt, int is_early_device);
3631
3632 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3633 index 4653efb..8c60bf7 100644
3634 --- a/arch/arm/mach-omap2/omap_hwmod.c
3635 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3636 @@ -189,10 +189,10 @@ struct omap_hwmod_soc_ops {
3637 int (*init_clkdm)(struct omap_hwmod *oh);
3638 void (*update_context_lost)(struct omap_hwmod *oh);
3639 int (*get_context_lost)(struct omap_hwmod *oh);
3640 -};
3641 +} __no_const;
3642
3643 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3644 -static struct omap_hwmod_soc_ops soc_ops;
3645 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3646
3647 /* omap_hwmod_list contains all registered struct omap_hwmods */
3648 static LIST_HEAD(omap_hwmod_list);
3649 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3650 index 7c2b4ed..b2ea51f 100644
3651 --- a/arch/arm/mach-omap2/wd_timer.c
3652 +++ b/arch/arm/mach-omap2/wd_timer.c
3653 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3654 struct omap_hwmod *oh;
3655 char *oh_name = "wd_timer2";
3656 char *dev_name = "omap_wdt";
3657 - struct omap_wd_timer_platform_data pdata;
3658 + static struct omap_wd_timer_platform_data pdata = {
3659 + .read_reset_sources = prm_read_reset_sources
3660 + };
3661
3662 if (!cpu_class_is_omap2() || of_have_populated_dt())
3663 return 0;
3664 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3665 return -EINVAL;
3666 }
3667
3668 - pdata.read_reset_sources = prm_read_reset_sources;
3669 -
3670 pdev = omap_device_build(dev_name, id, oh, &pdata,
3671 sizeof(struct omap_wd_timer_platform_data),
3672 NULL, 0, 0);
3673 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3674 index 6be4c4d..32ac32a 100644
3675 --- a/arch/arm/mach-ux500/include/mach/setup.h
3676 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3677 @@ -38,13 +38,6 @@ extern struct sys_timer ux500_timer;
3678 .type = MT_DEVICE, \
3679 }
3680
3681 -#define __MEM_DEV_DESC(x, sz) { \
3682 - .virtual = IO_ADDRESS(x), \
3683 - .pfn = __phys_to_pfn(x), \
3684 - .length = sz, \
3685 - .type = MT_MEMORY, \
3686 -}
3687 -
3688 extern struct smp_operations ux500_smp_ops;
3689 extern void ux500_cpu_die(unsigned int cpu);
3690
3691 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3692 index 3fd629d..8b1aca9 100644
3693 --- a/arch/arm/mm/Kconfig
3694 +++ b/arch/arm/mm/Kconfig
3695 @@ -425,7 +425,7 @@ config CPU_32v5
3696
3697 config CPU_32v6
3698 bool
3699 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3700 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3701 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3702
3703 config CPU_32v6K
3704 @@ -577,6 +577,7 @@ config CPU_CP15_MPU
3705
3706 config CPU_USE_DOMAINS
3707 bool
3708 + depends on !ARM_LPAE && !PAX_KERNEXEC
3709 help
3710 This option enables or disables the use of domain switching
3711 via the set_fs() function.
3712 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3713 index db26e2e..ee44569 100644
3714 --- a/arch/arm/mm/alignment.c
3715 +++ b/arch/arm/mm/alignment.c
3716 @@ -211,10 +211,12 @@ union offset_union {
3717 #define __get16_unaligned_check(ins,val,addr) \
3718 do { \
3719 unsigned int err = 0, v, a = addr; \
3720 + pax_open_userland(); \
3721 __get8_unaligned_check(ins,v,a,err); \
3722 val = v << ((BE) ? 8 : 0); \
3723 __get8_unaligned_check(ins,v,a,err); \
3724 val |= v << ((BE) ? 0 : 8); \
3725 + pax_close_userland(); \
3726 if (err) \
3727 goto fault; \
3728 } while (0)
3729 @@ -228,6 +230,7 @@ union offset_union {
3730 #define __get32_unaligned_check(ins,val,addr) \
3731 do { \
3732 unsigned int err = 0, v, a = addr; \
3733 + pax_open_userland(); \
3734 __get8_unaligned_check(ins,v,a,err); \
3735 val = v << ((BE) ? 24 : 0); \
3736 __get8_unaligned_check(ins,v,a,err); \
3737 @@ -236,6 +239,7 @@ union offset_union {
3738 val |= v << ((BE) ? 8 : 16); \
3739 __get8_unaligned_check(ins,v,a,err); \
3740 val |= v << ((BE) ? 0 : 24); \
3741 + pax_close_userland(); \
3742 if (err) \
3743 goto fault; \
3744 } while (0)
3745 @@ -249,6 +253,7 @@ union offset_union {
3746 #define __put16_unaligned_check(ins,val,addr) \
3747 do { \
3748 unsigned int err = 0, v = val, a = addr; \
3749 + pax_open_userland(); \
3750 __asm__( FIRST_BYTE_16 \
3751 ARM( "1: "ins" %1, [%2], #1\n" ) \
3752 THUMB( "1: "ins" %1, [%2]\n" ) \
3753 @@ -268,6 +273,7 @@ union offset_union {
3754 " .popsection\n" \
3755 : "=r" (err), "=&r" (v), "=&r" (a) \
3756 : "0" (err), "1" (v), "2" (a)); \
3757 + pax_close_userland(); \
3758 if (err) \
3759 goto fault; \
3760 } while (0)
3761 @@ -281,6 +287,7 @@ union offset_union {
3762 #define __put32_unaligned_check(ins,val,addr) \
3763 do { \
3764 unsigned int err = 0, v = val, a = addr; \
3765 + pax_open_userland(); \
3766 __asm__( FIRST_BYTE_32 \
3767 ARM( "1: "ins" %1, [%2], #1\n" ) \
3768 THUMB( "1: "ins" %1, [%2]\n" ) \
3769 @@ -310,6 +317,7 @@ union offset_union {
3770 " .popsection\n" \
3771 : "=r" (err), "=&r" (v), "=&r" (a) \
3772 : "0" (err), "1" (v), "2" (a)); \
3773 + pax_close_userland(); \
3774 if (err) \
3775 goto fault; \
3776 } while (0)
3777 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3778 index d07df17..59d5493 100644
3779 --- a/arch/arm/mm/context.c
3780 +++ b/arch/arm/mm/context.c
3781 @@ -45,7 +45,7 @@ static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3782 static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3783 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3784
3785 -static DEFINE_PER_CPU(atomic64_t, active_asids);
3786 +DEFINE_PER_CPU(atomic64_t, active_asids);
3787 static DEFINE_PER_CPU(u64, reserved_asids);
3788 static cpumask_t tlb_flush_pending;
3789
3790 @@ -209,8 +209,10 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3791 atomic64_set(&mm->context.id, asid);
3792 }
3793
3794 - if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending))
3795 + if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) {
3796 local_flush_tlb_all();
3797 + dummy_flush_tlb_a15_erratum();
3798 + }
3799
3800 atomic64_set(&per_cpu(active_asids, cpu), asid);
3801 cpumask_set_cpu(cpu, mm_cpumask(mm));
3802 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3803 index 5dbf13f..1a60561 100644
3804 --- a/arch/arm/mm/fault.c
3805 +++ b/arch/arm/mm/fault.c
3806 @@ -25,6 +25,7 @@
3807 #include <asm/system_misc.h>
3808 #include <asm/system_info.h>
3809 #include <asm/tlbflush.h>
3810 +#include <asm/sections.h>
3811
3812 #include "fault.h"
3813
3814 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3815 if (fixup_exception(regs))
3816 return;
3817
3818 +#ifdef CONFIG_PAX_KERNEXEC
3819 + if ((fsr & FSR_WRITE) &&
3820 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3821 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3822 + {
3823 + if (current->signal->curr_ip)
3824 + 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),
3825 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3826 + else
3827 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3828 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3829 + }
3830 +#endif
3831 +
3832 /*
3833 * No handler, we'll have to terminate things with extreme prejudice.
3834 */
3835 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3836 }
3837 #endif
3838
3839 +#ifdef CONFIG_PAX_PAGEEXEC
3840 + if (fsr & FSR_LNX_PF) {
3841 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3842 + do_group_exit(SIGKILL);
3843 + }
3844 +#endif
3845 +
3846 tsk->thread.address = addr;
3847 tsk->thread.error_code = fsr;
3848 tsk->thread.trap_no = 14;
3849 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3850 }
3851 #endif /* CONFIG_MMU */
3852
3853 +#ifdef CONFIG_PAX_PAGEEXEC
3854 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3855 +{
3856 + long i;
3857 +
3858 + printk(KERN_ERR "PAX: bytes at PC: ");
3859 + for (i = 0; i < 20; i++) {
3860 + unsigned char c;
3861 + if (get_user(c, (__force unsigned char __user *)pc+i))
3862 + printk(KERN_CONT "?? ");
3863 + else
3864 + printk(KERN_CONT "%02x ", c);
3865 + }
3866 + printk("\n");
3867 +
3868 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3869 + for (i = -1; i < 20; i++) {
3870 + unsigned long c;
3871 + if (get_user(c, (__force unsigned long __user *)sp+i))
3872 + printk(KERN_CONT "???????? ");
3873 + else
3874 + printk(KERN_CONT "%08lx ", c);
3875 + }
3876 + printk("\n");
3877 +}
3878 +#endif
3879 +
3880 /*
3881 * First Level Translation Fault Handler
3882 *
3883 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3884 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3885 struct siginfo info;
3886
3887 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3888 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3889 + if (current->signal->curr_ip)
3890 + 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),
3891 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3892 + else
3893 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3894 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3895 + goto die;
3896 + }
3897 +#endif
3898 +
3899 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3900 return;
3901
3902 +die:
3903 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3904 inf->name, fsr, addr);
3905
3906 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3907 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3908 struct siginfo info;
3909
3910 + if (user_mode(regs)) {
3911 + if (addr == 0xffff0fe0UL) {
3912 + /*
3913 + * PaX: __kuser_get_tls emulation
3914 + */
3915 + regs->ARM_r0 = current_thread_info()->tp_value;
3916 + regs->ARM_pc = regs->ARM_lr;
3917 + return;
3918 + }
3919 + }
3920 +
3921 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3922 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3923 + if (current->signal->curr_ip)
3924 + 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),
3925 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3926 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3927 + else
3928 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3929 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3930 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3931 + goto die;
3932 + }
3933 +#endif
3934 +
3935 +#ifdef CONFIG_PAX_REFCOUNT
3936 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3937 + unsigned int bkpt;
3938 +
3939 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3940 + current->thread.error_code = ifsr;
3941 + current->thread.trap_no = 0;
3942 + pax_report_refcount_overflow(regs);
3943 + fixup_exception(regs);
3944 + return;
3945 + }
3946 + }
3947 +#endif
3948 +
3949 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3950 return;
3951
3952 +die:
3953 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3954 inf->name, ifsr, addr);
3955
3956 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3957 index cf08bdf..772656c 100644
3958 --- a/arch/arm/mm/fault.h
3959 +++ b/arch/arm/mm/fault.h
3960 @@ -3,6 +3,7 @@
3961
3962 /*
3963 * Fault status register encodings. We steal bit 31 for our own purposes.
3964 + * Set when the FSR value is from an instruction fault.
3965 */
3966 #define FSR_LNX_PF (1 << 31)
3967 #define FSR_WRITE (1 << 11)
3968 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3969 }
3970 #endif
3971
3972 +/* valid for LPAE and !LPAE */
3973 +static inline int is_xn_fault(unsigned int fsr)
3974 +{
3975 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3976 +}
3977 +
3978 +static inline int is_domain_fault(unsigned int fsr)
3979 +{
3980 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3981 +}
3982 +
3983 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3984 unsigned long search_exception_table(unsigned long addr);
3985
3986 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3987 index ad722f1..763fdd3 100644
3988 --- a/arch/arm/mm/init.c
3989 +++ b/arch/arm/mm/init.c
3990 @@ -30,6 +30,8 @@
3991 #include <asm/setup.h>
3992 #include <asm/tlb.h>
3993 #include <asm/fixmap.h>
3994 +#include <asm/system_info.h>
3995 +#include <asm/cp15.h>
3996
3997 #include <asm/mach/arch.h>
3998 #include <asm/mach/map.h>
3999 @@ -736,7 +738,46 @@ void free_initmem(void)
4000 {
4001 #ifdef CONFIG_HAVE_TCM
4002 extern char __tcm_start, __tcm_end;
4003 +#endif
4004
4005 +#ifdef CONFIG_PAX_KERNEXEC
4006 + unsigned long addr;
4007 + pgd_t *pgd;
4008 + pud_t *pud;
4009 + pmd_t *pmd;
4010 + int cpu_arch = cpu_architecture();
4011 + unsigned int cr = get_cr();
4012 +
4013 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4014 + /* make pages tables, etc before .text NX */
4015 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4016 + pgd = pgd_offset_k(addr);
4017 + pud = pud_offset(pgd, addr);
4018 + pmd = pmd_offset(pud, addr);
4019 + __section_update(pmd, addr, PMD_SECT_XN);
4020 + }
4021 + /* make init NX */
4022 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4023 + pgd = pgd_offset_k(addr);
4024 + pud = pud_offset(pgd, addr);
4025 + pmd = pmd_offset(pud, addr);
4026 + __section_update(pmd, addr, PMD_SECT_XN);
4027 + }
4028 + /* make kernel code/rodata RX */
4029 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4030 + pgd = pgd_offset_k(addr);
4031 + pud = pud_offset(pgd, addr);
4032 + pmd = pmd_offset(pud, addr);
4033 +#ifdef CONFIG_ARM_LPAE
4034 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4035 +#else
4036 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4037 +#endif
4038 + }
4039 + }
4040 +#endif
4041 +
4042 +#ifdef CONFIG_HAVE_TCM
4043 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4044 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
4045 __phys_to_pfn(__pa(&__tcm_end)),
4046 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4047 index 88fd86c..7a224ce 100644
4048 --- a/arch/arm/mm/ioremap.c
4049 +++ b/arch/arm/mm/ioremap.c
4050 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4051 unsigned int mtype;
4052
4053 if (cached)
4054 - mtype = MT_MEMORY;
4055 + mtype = MT_MEMORY_RX;
4056 else
4057 - mtype = MT_MEMORY_NONCACHED;
4058 + mtype = MT_MEMORY_NONCACHED_RX;
4059
4060 return __arm_ioremap_caller(phys_addr, size, mtype,
4061 __builtin_return_address(0));
4062 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4063 index 10062ce..aa96dd7 100644
4064 --- a/arch/arm/mm/mmap.c
4065 +++ b/arch/arm/mm/mmap.c
4066 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4067 struct vm_area_struct *vma;
4068 int do_align = 0;
4069 int aliasing = cache_is_vipt_aliasing();
4070 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4071 struct vm_unmapped_area_info info;
4072
4073 /*
4074 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4075 if (len > TASK_SIZE)
4076 return -ENOMEM;
4077
4078 +#ifdef CONFIG_PAX_RANDMMAP
4079 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4080 +#endif
4081 +
4082 if (addr) {
4083 if (do_align)
4084 addr = COLOUR_ALIGN(addr, pgoff);
4085 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4086 addr = PAGE_ALIGN(addr);
4087
4088 vma = find_vma(mm, addr);
4089 - if (TASK_SIZE - len >= addr &&
4090 - (!vma || addr + len <= vma->vm_start))
4091 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4092 return addr;
4093 }
4094
4095 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4096 unsigned long addr = addr0;
4097 int do_align = 0;
4098 int aliasing = cache_is_vipt_aliasing();
4099 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4100 struct vm_unmapped_area_info info;
4101
4102 /*
4103 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4104 return addr;
4105 }
4106
4107 +#ifdef CONFIG_PAX_RANDMMAP
4108 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4109 +#endif
4110 +
4111 /* requesting a specific address */
4112 if (addr) {
4113 if (do_align)
4114 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4115 else
4116 addr = PAGE_ALIGN(addr);
4117 vma = find_vma(mm, addr);
4118 - if (TASK_SIZE - len >= addr &&
4119 - (!vma || addr + len <= vma->vm_start))
4120 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4121 return addr;
4122 }
4123
4124 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4125 VM_BUG_ON(addr != -ENOMEM);
4126 info.flags = 0;
4127 info.low_limit = mm->mmap_base;
4128 +
4129 +#ifdef CONFIG_PAX_RANDMMAP
4130 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4131 + info.low_limit += mm->delta_mmap;
4132 +#endif
4133 +
4134 info.high_limit = TASK_SIZE;
4135 addr = vm_unmapped_area(&info);
4136 }
4137 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4138 {
4139 unsigned long random_factor = 0UL;
4140
4141 +#ifdef CONFIG_PAX_RANDMMAP
4142 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4143 +#endif
4144 +
4145 /* 8 bits of randomness in 20 address space bits */
4146 if ((current->flags & PF_RANDOMIZE) &&
4147 !(current->personality & ADDR_NO_RANDOMIZE))
4148 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4149
4150 if (mmap_is_legacy()) {
4151 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4152 +
4153 +#ifdef CONFIG_PAX_RANDMMAP
4154 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4155 + mm->mmap_base += mm->delta_mmap;
4156 +#endif
4157 +
4158 mm->get_unmapped_area = arch_get_unmapped_area;
4159 mm->unmap_area = arch_unmap_area;
4160 } else {
4161 mm->mmap_base = mmap_base(random_factor);
4162 +
4163 +#ifdef CONFIG_PAX_RANDMMAP
4164 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4165 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4166 +#endif
4167 +
4168 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4169 mm->unmap_area = arch_unmap_area_topdown;
4170 }
4171 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4172 index ce328c7..35b88dc 100644
4173 --- a/arch/arm/mm/mmu.c
4174 +++ b/arch/arm/mm/mmu.c
4175 @@ -35,6 +35,23 @@
4176
4177 #include "mm.h"
4178
4179 +
4180 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4181 +void modify_domain(unsigned int dom, unsigned int type)
4182 +{
4183 + struct thread_info *thread = current_thread_info();
4184 + unsigned int domain = thread->cpu_domain;
4185 + /*
4186 + * DOMAIN_MANAGER might be defined to some other value,
4187 + * use the arch-defined constant
4188 + */
4189 + domain &= ~domain_val(dom, 3);
4190 + thread->cpu_domain = domain | domain_val(dom, type);
4191 + set_domain(thread->cpu_domain);
4192 +}
4193 +EXPORT_SYMBOL(modify_domain);
4194 +#endif
4195 +
4196 /*
4197 * empty_zero_page is a special page that is used for
4198 * zero-initialized data and COW.
4199 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4200 }
4201 #endif
4202
4203 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4204 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4205 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4206
4207 -static struct mem_type mem_types[] = {
4208 +#ifdef CONFIG_PAX_KERNEXEC
4209 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4210 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4211 +#else
4212 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4213 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4214 +#endif
4215 +
4216 +static struct mem_type mem_types[] __read_only = {
4217 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4218 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4219 L_PTE_SHARED,
4220 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4221 [MT_UNCACHED] = {
4222 .prot_pte = PROT_PTE_DEVICE,
4223 .prot_l1 = PMD_TYPE_TABLE,
4224 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4225 + .prot_sect = PROT_SECT_DEVICE,
4226 .domain = DOMAIN_IO,
4227 },
4228 [MT_CACHECLEAN] = {
4229 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4230 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4231 .domain = DOMAIN_KERNEL,
4232 },
4233 #ifndef CONFIG_ARM_LPAE
4234 [MT_MINICLEAN] = {
4235 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4236 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4237 .domain = DOMAIN_KERNEL,
4238 },
4239 #endif
4240 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4241 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4242 L_PTE_RDONLY,
4243 .prot_l1 = PMD_TYPE_TABLE,
4244 - .domain = DOMAIN_USER,
4245 + .domain = DOMAIN_VECTORS,
4246 },
4247 [MT_HIGH_VECTORS] = {
4248 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4249 - L_PTE_USER | L_PTE_RDONLY,
4250 + L_PTE_RDONLY,
4251 .prot_l1 = PMD_TYPE_TABLE,
4252 - .domain = DOMAIN_USER,
4253 + .domain = DOMAIN_VECTORS,
4254 },
4255 - [MT_MEMORY] = {
4256 + [MT_MEMORY_RWX] = {
4257 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4258 .prot_l1 = PMD_TYPE_TABLE,
4259 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4260 .domain = DOMAIN_KERNEL,
4261 },
4262 + [MT_MEMORY_RW] = {
4263 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4264 + .prot_l1 = PMD_TYPE_TABLE,
4265 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4266 + .domain = DOMAIN_KERNEL,
4267 + },
4268 + [MT_MEMORY_RX] = {
4269 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4270 + .prot_l1 = PMD_TYPE_TABLE,
4271 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4272 + .domain = DOMAIN_KERNEL,
4273 + },
4274 [MT_ROM] = {
4275 - .prot_sect = PMD_TYPE_SECT,
4276 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4277 .domain = DOMAIN_KERNEL,
4278 },
4279 - [MT_MEMORY_NONCACHED] = {
4280 + [MT_MEMORY_NONCACHED_RW] = {
4281 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4282 L_PTE_MT_BUFFERABLE,
4283 .prot_l1 = PMD_TYPE_TABLE,
4284 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4285 .domain = DOMAIN_KERNEL,
4286 },
4287 + [MT_MEMORY_NONCACHED_RX] = {
4288 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4289 + L_PTE_MT_BUFFERABLE,
4290 + .prot_l1 = PMD_TYPE_TABLE,
4291 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4292 + .domain = DOMAIN_KERNEL,
4293 + },
4294 [MT_MEMORY_DTCM] = {
4295 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4296 - L_PTE_XN,
4297 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4298 .prot_l1 = PMD_TYPE_TABLE,
4299 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4300 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4301 .domain = DOMAIN_KERNEL,
4302 },
4303 [MT_MEMORY_ITCM] = {
4304 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4305 },
4306 [MT_MEMORY_SO] = {
4307 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4308 - L_PTE_MT_UNCACHED | L_PTE_XN,
4309 + L_PTE_MT_UNCACHED,
4310 .prot_l1 = PMD_TYPE_TABLE,
4311 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4312 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4313 + PMD_SECT_UNCACHED,
4314 .domain = DOMAIN_KERNEL,
4315 },
4316 [MT_MEMORY_DMA_READY] = {
4317 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4318 * to prevent speculative instruction fetches.
4319 */
4320 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4321 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4322 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4323 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4324 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4325 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4326 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4327 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4328 +
4329 + /* Mark other regions on ARMv6+ as execute-never */
4330 +
4331 +#ifdef CONFIG_PAX_KERNEXEC
4332 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4333 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4334 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4335 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4336 +#ifndef CONFIG_ARM_LPAE
4337 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4338 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4339 +#endif
4340 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4341 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4342 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4343 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4344 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4345 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4346 +#endif
4347 +
4348 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4349 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4350 }
4351 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4352 /*
4353 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4354 * from SVC mode and no access from userspace.
4355 */
4356 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4357 +#ifdef CONFIG_PAX_KERNEXEC
4358 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4359 +#endif
4360 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4361 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4362 #endif
4363 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4364 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4365 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4366 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4367 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4368 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4369 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4370 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4371 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4372 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4373 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4374 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4375 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4376 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4377 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4378 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4379 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4380 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4381 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4382 }
4383 }
4384
4385 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4386 if (cpu_arch >= CPU_ARCH_ARMv6) {
4387 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4388 /* Non-cacheable Normal is XCB = 001 */
4389 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4390 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4391 + PMD_SECT_BUFFERED;
4392 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4393 PMD_SECT_BUFFERED;
4394 } else {
4395 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4396 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4397 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4398 + PMD_SECT_TEX(1);
4399 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4400 PMD_SECT_TEX(1);
4401 }
4402 } else {
4403 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4404 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4405 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4406 }
4407
4408 #ifdef CONFIG_ARM_LPAE
4409 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4410 vecs_pgprot |= PTE_EXT_AF;
4411 #endif
4412
4413 + user_pgprot |= __supported_pte_mask;
4414 +
4415 for (i = 0; i < 16; i++) {
4416 pteval_t v = pgprot_val(protection_map[i]);
4417 protection_map[i] = __pgprot(v | user_pgprot);
4418 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4419
4420 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4421 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4422 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4423 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4424 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4425 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4426 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4427 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4428 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4429 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4430 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4431 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4432 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4433 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4434 mem_types[MT_ROM].prot_sect |= cp->pmd;
4435
4436 switch (cp->pmd) {
4437 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4438 * called function. This means you can't use any function or debugging
4439 * method which may touch any device, otherwise the kernel _will_ crash.
4440 */
4441 +
4442 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4443 +
4444 static void __init devicemaps_init(struct machine_desc *mdesc)
4445 {
4446 struct map_desc map;
4447 unsigned long addr;
4448 - void *vectors;
4449
4450 - /*
4451 - * Allocate the vector page early.
4452 - */
4453 - vectors = early_alloc(PAGE_SIZE);
4454 -
4455 - early_trap_init(vectors);
4456 + early_trap_init(&vectors);
4457
4458 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4459 pmd_clear(pmd_off_k(addr));
4460 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4461 * location (0xffff0000). If we aren't using high-vectors, also
4462 * create a mapping at the low-vectors virtual address.
4463 */
4464 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4465 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4466 map.virtual = 0xffff0000;
4467 map.length = PAGE_SIZE;
4468 map.type = MT_HIGH_VECTORS;
4469 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4470 map.pfn = __phys_to_pfn(start);
4471 map.virtual = __phys_to_virt(start);
4472 map.length = end - start;
4473 - map.type = MT_MEMORY;
4474
4475 +#ifdef CONFIG_PAX_KERNEXEC
4476 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4477 + struct map_desc kernel;
4478 + struct map_desc initmap;
4479 +
4480 + /* when freeing initmem we will make this RW */
4481 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4482 + initmap.virtual = (unsigned long)__init_begin;
4483 + initmap.length = _sdata - __init_begin;
4484 + initmap.type = MT_MEMORY_RWX;
4485 + create_mapping(&initmap);
4486 +
4487 + /* when freeing initmem we will make this RX */
4488 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4489 + kernel.virtual = (unsigned long)_stext;
4490 + kernel.length = __init_begin - _stext;
4491 + kernel.type = MT_MEMORY_RWX;
4492 + create_mapping(&kernel);
4493 +
4494 + if (map.virtual < (unsigned long)_stext) {
4495 + map.length = (unsigned long)_stext - map.virtual;
4496 + map.type = MT_MEMORY_RWX;
4497 + create_mapping(&map);
4498 + }
4499 +
4500 + map.pfn = __phys_to_pfn(__pa(_sdata));
4501 + map.virtual = (unsigned long)_sdata;
4502 + map.length = end - __pa(_sdata);
4503 + }
4504 +#endif
4505 +
4506 + map.type = MT_MEMORY_RW;
4507 create_mapping(&map);
4508 }
4509 }
4510 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4511 index 6d98c13..3cfb174 100644
4512 --- a/arch/arm/mm/proc-v7-2level.S
4513 +++ b/arch/arm/mm/proc-v7-2level.S
4514 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4515 tst r1, #L_PTE_XN
4516 orrne r3, r3, #PTE_EXT_XN
4517
4518 + tst r1, #L_PTE_PXN
4519 + orrne r3, r3, #PTE_EXT_PXN
4520 +
4521 tst r1, #L_PTE_YOUNG
4522 tstne r1, #L_PTE_VALID
4523 #ifndef CONFIG_CPU_USE_DOMAINS
4524 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4525 index a5bc92d..0bb4730 100644
4526 --- a/arch/arm/plat-omap/sram.c
4527 +++ b/arch/arm/plat-omap/sram.c
4528 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4529 * Looks like we need to preserve some bootloader code at the
4530 * beginning of SRAM for jumping to flash for reboot to work...
4531 */
4532 + pax_open_kernel();
4533 memset_io(omap_sram_base + omap_sram_skip, 0,
4534 omap_sram_size - omap_sram_skip);
4535 + pax_close_kernel();
4536 }
4537 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4538 index f5144cd..71f6d1f 100644
4539 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4540 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4541 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4542 int (*started)(unsigned ch);
4543 int (*flush)(unsigned ch);
4544 int (*stop)(unsigned ch);
4545 -};
4546 +} __no_const;
4547
4548 extern void *samsung_dmadev_get_ops(void);
4549 extern void *s3c_dma_get_ops(void);
4550 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4551 index 0c3ba9f..95722b3 100644
4552 --- a/arch/arm64/kernel/debug-monitors.c
4553 +++ b/arch/arm64/kernel/debug-monitors.c
4554 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4555 return NOTIFY_OK;
4556 }
4557
4558 -static struct notifier_block __cpuinitdata os_lock_nb = {
4559 +static struct notifier_block os_lock_nb = {
4560 .notifier_call = os_lock_notify,
4561 };
4562
4563 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4564 index 5ab825c..96aaec8 100644
4565 --- a/arch/arm64/kernel/hw_breakpoint.c
4566 +++ b/arch/arm64/kernel/hw_breakpoint.c
4567 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4568 return NOTIFY_OK;
4569 }
4570
4571 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4572 +static struct notifier_block hw_breakpoint_reset_nb = {
4573 .notifier_call = hw_breakpoint_reset_notify,
4574 };
4575
4576 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4577 index c3a58a1..78fbf54 100644
4578 --- a/arch/avr32/include/asm/cache.h
4579 +++ b/arch/avr32/include/asm/cache.h
4580 @@ -1,8 +1,10 @@
4581 #ifndef __ASM_AVR32_CACHE_H
4582 #define __ASM_AVR32_CACHE_H
4583
4584 +#include <linux/const.h>
4585 +
4586 #define L1_CACHE_SHIFT 5
4587 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4588 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4589
4590 /*
4591 * Memory returned by kmalloc() may be used for DMA, so we must make
4592 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4593 index e2c3287..6c4f98c 100644
4594 --- a/arch/avr32/include/asm/elf.h
4595 +++ b/arch/avr32/include/asm/elf.h
4596 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4597 the loader. We need to make sure that it is out of the way of the program
4598 that it will "exec", and that there is sufficient room for the brk. */
4599
4600 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4601 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4602
4603 +#ifdef CONFIG_PAX_ASLR
4604 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4605 +
4606 +#define PAX_DELTA_MMAP_LEN 15
4607 +#define PAX_DELTA_STACK_LEN 15
4608 +#endif
4609
4610 /* This yields a mask that user programs can use to figure out what
4611 instruction set this CPU supports. This could be done in user space,
4612 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4613 index 479330b..53717a8 100644
4614 --- a/arch/avr32/include/asm/kmap_types.h
4615 +++ b/arch/avr32/include/asm/kmap_types.h
4616 @@ -2,9 +2,9 @@
4617 #define __ASM_AVR32_KMAP_TYPES_H
4618
4619 #ifdef CONFIG_DEBUG_HIGHMEM
4620 -# define KM_TYPE_NR 29
4621 +# define KM_TYPE_NR 30
4622 #else
4623 -# define KM_TYPE_NR 14
4624 +# define KM_TYPE_NR 15
4625 #endif
4626
4627 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4628 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4629 index b2f2d2d..d1c85cb 100644
4630 --- a/arch/avr32/mm/fault.c
4631 +++ b/arch/avr32/mm/fault.c
4632 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4633
4634 int exception_trace = 1;
4635
4636 +#ifdef CONFIG_PAX_PAGEEXEC
4637 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4638 +{
4639 + unsigned long i;
4640 +
4641 + printk(KERN_ERR "PAX: bytes at PC: ");
4642 + for (i = 0; i < 20; i++) {
4643 + unsigned char c;
4644 + if (get_user(c, (unsigned char *)pc+i))
4645 + printk(KERN_CONT "???????? ");
4646 + else
4647 + printk(KERN_CONT "%02x ", c);
4648 + }
4649 + printk("\n");
4650 +}
4651 +#endif
4652 +
4653 /*
4654 * This routine handles page faults. It determines the address and the
4655 * problem, and then passes it off to one of the appropriate routines.
4656 @@ -174,6 +191,16 @@ bad_area:
4657 up_read(&mm->mmap_sem);
4658
4659 if (user_mode(regs)) {
4660 +
4661 +#ifdef CONFIG_PAX_PAGEEXEC
4662 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4663 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4664 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4665 + do_group_exit(SIGKILL);
4666 + }
4667 + }
4668 +#endif
4669 +
4670 if (exception_trace && printk_ratelimit())
4671 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4672 "sp %08lx ecr %lu\n",
4673 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4674 index 568885a..f8008df 100644
4675 --- a/arch/blackfin/include/asm/cache.h
4676 +++ b/arch/blackfin/include/asm/cache.h
4677 @@ -7,6 +7,7 @@
4678 #ifndef __ARCH_BLACKFIN_CACHE_H
4679 #define __ARCH_BLACKFIN_CACHE_H
4680
4681 +#include <linux/const.h>
4682 #include <linux/linkage.h> /* for asmlinkage */
4683
4684 /*
4685 @@ -14,7 +15,7 @@
4686 * Blackfin loads 32 bytes for cache
4687 */
4688 #define L1_CACHE_SHIFT 5
4689 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4690 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4691 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4692
4693 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4694 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4695 index aea2718..3639a60 100644
4696 --- a/arch/cris/include/arch-v10/arch/cache.h
4697 +++ b/arch/cris/include/arch-v10/arch/cache.h
4698 @@ -1,8 +1,9 @@
4699 #ifndef _ASM_ARCH_CACHE_H
4700 #define _ASM_ARCH_CACHE_H
4701
4702 +#include <linux/const.h>
4703 /* Etrax 100LX have 32-byte cache-lines. */
4704 -#define L1_CACHE_BYTES 32
4705 #define L1_CACHE_SHIFT 5
4706 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4707
4708 #endif /* _ASM_ARCH_CACHE_H */
4709 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4710 index 7caf25d..ee65ac5 100644
4711 --- a/arch/cris/include/arch-v32/arch/cache.h
4712 +++ b/arch/cris/include/arch-v32/arch/cache.h
4713 @@ -1,11 +1,12 @@
4714 #ifndef _ASM_CRIS_ARCH_CACHE_H
4715 #define _ASM_CRIS_ARCH_CACHE_H
4716
4717 +#include <linux/const.h>
4718 #include <arch/hwregs/dma.h>
4719
4720 /* A cache-line is 32 bytes. */
4721 -#define L1_CACHE_BYTES 32
4722 #define L1_CACHE_SHIFT 5
4723 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4724
4725 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4726
4727 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4728 index b86329d..6709906 100644
4729 --- a/arch/frv/include/asm/atomic.h
4730 +++ b/arch/frv/include/asm/atomic.h
4731 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4732 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4733 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4734
4735 +#define atomic64_read_unchecked(v) atomic64_read(v)
4736 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4737 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4738 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4739 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4740 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4741 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4742 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4743 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4744 +
4745 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4746 {
4747 int c, old;
4748 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4749 index 2797163..c2a401d 100644
4750 --- a/arch/frv/include/asm/cache.h
4751 +++ b/arch/frv/include/asm/cache.h
4752 @@ -12,10 +12,11 @@
4753 #ifndef __ASM_CACHE_H
4754 #define __ASM_CACHE_H
4755
4756 +#include <linux/const.h>
4757
4758 /* bytes per L1 cache line */
4759 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4760 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4761 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4762
4763 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4764 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4765 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4766 index 43901f2..0d8b865 100644
4767 --- a/arch/frv/include/asm/kmap_types.h
4768 +++ b/arch/frv/include/asm/kmap_types.h
4769 @@ -2,6 +2,6 @@
4770 #ifndef _ASM_KMAP_TYPES_H
4771 #define _ASM_KMAP_TYPES_H
4772
4773 -#define KM_TYPE_NR 17
4774 +#define KM_TYPE_NR 18
4775
4776 #endif
4777 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4778 index 385fd30..3aaf4fe 100644
4779 --- a/arch/frv/mm/elf-fdpic.c
4780 +++ b/arch/frv/mm/elf-fdpic.c
4781 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4782 {
4783 struct vm_area_struct *vma;
4784 unsigned long limit;
4785 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4786
4787 if (len > TASK_SIZE)
4788 return -ENOMEM;
4789 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4790 if (addr) {
4791 addr = PAGE_ALIGN(addr);
4792 vma = find_vma(current->mm, addr);
4793 - if (TASK_SIZE - len >= addr &&
4794 - (!vma || addr + len <= vma->vm_start))
4795 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4796 goto success;
4797 }
4798
4799 @@ -89,7 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4800 for (; vma; vma = vma->vm_next) {
4801 if (addr > limit)
4802 break;
4803 - if (addr + len <= vma->vm_start)
4804 + if (check_heap_stack_gap(vma, addr, len, offset))
4805 goto success;
4806 addr = vma->vm_end;
4807 }
4808 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4809 for (; vma; vma = vma->vm_next) {
4810 if (addr > limit)
4811 break;
4812 - if (addr + len <= vma->vm_start)
4813 + if (check_heap_stack_gap(vma, addr, len, offset))
4814 goto success;
4815 addr = vma->vm_end;
4816 }
4817 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4818 index f4ca594..adc72fd6 100644
4819 --- a/arch/hexagon/include/asm/cache.h
4820 +++ b/arch/hexagon/include/asm/cache.h
4821 @@ -21,9 +21,11 @@
4822 #ifndef __ASM_CACHE_H
4823 #define __ASM_CACHE_H
4824
4825 +#include <linux/const.h>
4826 +
4827 /* Bytes per L1 cache line */
4828 -#define L1_CACHE_SHIFT (5)
4829 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4830 +#define L1_CACHE_SHIFT 5
4831 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4832
4833 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4834 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4835 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4836 index 6e6fe18..a6ae668 100644
4837 --- a/arch/ia64/include/asm/atomic.h
4838 +++ b/arch/ia64/include/asm/atomic.h
4839 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4840 #define atomic64_inc(v) atomic64_add(1, (v))
4841 #define atomic64_dec(v) atomic64_sub(1, (v))
4842
4843 +#define atomic64_read_unchecked(v) atomic64_read(v)
4844 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4845 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4846 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4847 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4848 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4849 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4850 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4851 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4852 +
4853 /* Atomic operations are already serializing */
4854 #define smp_mb__before_atomic_dec() barrier()
4855 #define smp_mb__after_atomic_dec() barrier()
4856 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4857 index 988254a..e1ee885 100644
4858 --- a/arch/ia64/include/asm/cache.h
4859 +++ b/arch/ia64/include/asm/cache.h
4860 @@ -1,6 +1,7 @@
4861 #ifndef _ASM_IA64_CACHE_H
4862 #define _ASM_IA64_CACHE_H
4863
4864 +#include <linux/const.h>
4865
4866 /*
4867 * Copyright (C) 1998-2000 Hewlett-Packard Co
4868 @@ -9,7 +10,7 @@
4869
4870 /* Bytes per L1 (data) cache line. */
4871 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4872 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4873 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4874
4875 #ifdef CONFIG_SMP
4876 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4877 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4878 index b5298eb..67c6e62 100644
4879 --- a/arch/ia64/include/asm/elf.h
4880 +++ b/arch/ia64/include/asm/elf.h
4881 @@ -42,6 +42,13 @@
4882 */
4883 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4884
4885 +#ifdef CONFIG_PAX_ASLR
4886 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4887 +
4888 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4889 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4890 +#endif
4891 +
4892 #define PT_IA_64_UNWIND 0x70000001
4893
4894 /* IA-64 relocations: */
4895 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4896 index 96a8d92..617a1cf 100644
4897 --- a/arch/ia64/include/asm/pgalloc.h
4898 +++ b/arch/ia64/include/asm/pgalloc.h
4899 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4900 pgd_val(*pgd_entry) = __pa(pud);
4901 }
4902
4903 +static inline void
4904 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4905 +{
4906 + pgd_populate(mm, pgd_entry, pud);
4907 +}
4908 +
4909 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4910 {
4911 return quicklist_alloc(0, GFP_KERNEL, NULL);
4912 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4913 pud_val(*pud_entry) = __pa(pmd);
4914 }
4915
4916 +static inline void
4917 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4918 +{
4919 + pud_populate(mm, pud_entry, pmd);
4920 +}
4921 +
4922 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4923 {
4924 return quicklist_alloc(0, GFP_KERNEL, NULL);
4925 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4926 index 815810c..d60bd4c 100644
4927 --- a/arch/ia64/include/asm/pgtable.h
4928 +++ b/arch/ia64/include/asm/pgtable.h
4929 @@ -12,7 +12,7 @@
4930 * David Mosberger-Tang <davidm@hpl.hp.com>
4931 */
4932
4933 -
4934 +#include <linux/const.h>
4935 #include <asm/mman.h>
4936 #include <asm/page.h>
4937 #include <asm/processor.h>
4938 @@ -142,6 +142,17 @@
4939 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4940 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4941 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4942 +
4943 +#ifdef CONFIG_PAX_PAGEEXEC
4944 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4945 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4946 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4947 +#else
4948 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4949 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4950 +# define PAGE_COPY_NOEXEC PAGE_COPY
4951 +#endif
4952 +
4953 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4954 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4955 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4956 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4957 index 54ff557..70c88b7 100644
4958 --- a/arch/ia64/include/asm/spinlock.h
4959 +++ b/arch/ia64/include/asm/spinlock.h
4960 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4961 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4962
4963 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4964 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4965 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4966 }
4967
4968 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4969 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4970 index 449c8c0..18965fb 100644
4971 --- a/arch/ia64/include/asm/uaccess.h
4972 +++ b/arch/ia64/include/asm/uaccess.h
4973 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4974 static inline unsigned long
4975 __copy_to_user (void __user *to, const void *from, unsigned long count)
4976 {
4977 + if (count > INT_MAX)
4978 + return count;
4979 +
4980 + if (!__builtin_constant_p(count))
4981 + check_object_size(from, count, true);
4982 +
4983 return __copy_user(to, (__force void __user *) from, count);
4984 }
4985
4986 static inline unsigned long
4987 __copy_from_user (void *to, const void __user *from, unsigned long count)
4988 {
4989 + if (count > INT_MAX)
4990 + return count;
4991 +
4992 + if (!__builtin_constant_p(count))
4993 + check_object_size(to, count, false);
4994 +
4995 return __copy_user((__force void __user *) to, from, count);
4996 }
4997
4998 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4999 ({ \
5000 void __user *__cu_to = (to); \
5001 const void *__cu_from = (from); \
5002 - long __cu_len = (n); \
5003 + unsigned long __cu_len = (n); \
5004 \
5005 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5006 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5007 + if (!__builtin_constant_p(n)) \
5008 + check_object_size(__cu_from, __cu_len, true); \
5009 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5010 + } \
5011 __cu_len; \
5012 })
5013
5014 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5015 ({ \
5016 void *__cu_to = (to); \
5017 const void __user *__cu_from = (from); \
5018 - long __cu_len = (n); \
5019 + unsigned long __cu_len = (n); \
5020 \
5021 __chk_user_ptr(__cu_from); \
5022 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5023 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5024 + if (!__builtin_constant_p(n)) \
5025 + check_object_size(__cu_to, __cu_len, false); \
5026 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5027 + } \
5028 __cu_len; \
5029 })
5030
5031 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
5032 index 2d67317..07d8bfa 100644
5033 --- a/arch/ia64/kernel/err_inject.c
5034 +++ b/arch/ia64/kernel/err_inject.c
5035 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
5036 return NOTIFY_OK;
5037 }
5038
5039 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
5040 +static struct notifier_block err_inject_cpu_notifier =
5041 {
5042 .notifier_call = err_inject_cpu_callback,
5043 };
5044 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
5045 index 65bf9cd..794f06b 100644
5046 --- a/arch/ia64/kernel/mca.c
5047 +++ b/arch/ia64/kernel/mca.c
5048 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
5049 return NOTIFY_OK;
5050 }
5051
5052 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
5053 +static struct notifier_block mca_cpu_notifier = {
5054 .notifier_call = mca_cpu_callback
5055 };
5056
5057 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5058 index 24603be..948052d 100644
5059 --- a/arch/ia64/kernel/module.c
5060 +++ b/arch/ia64/kernel/module.c
5061 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5062 void
5063 module_free (struct module *mod, void *module_region)
5064 {
5065 - if (mod && mod->arch.init_unw_table &&
5066 - module_region == mod->module_init) {
5067 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5068 unw_remove_unwind_table(mod->arch.init_unw_table);
5069 mod->arch.init_unw_table = NULL;
5070 }
5071 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5072 }
5073
5074 static inline int
5075 +in_init_rx (const struct module *mod, uint64_t addr)
5076 +{
5077 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5078 +}
5079 +
5080 +static inline int
5081 +in_init_rw (const struct module *mod, uint64_t addr)
5082 +{
5083 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5084 +}
5085 +
5086 +static inline int
5087 in_init (const struct module *mod, uint64_t addr)
5088 {
5089 - return addr - (uint64_t) mod->module_init < mod->init_size;
5090 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5091 +}
5092 +
5093 +static inline int
5094 +in_core_rx (const struct module *mod, uint64_t addr)
5095 +{
5096 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5097 +}
5098 +
5099 +static inline int
5100 +in_core_rw (const struct module *mod, uint64_t addr)
5101 +{
5102 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5103 }
5104
5105 static inline int
5106 in_core (const struct module *mod, uint64_t addr)
5107 {
5108 - return addr - (uint64_t) mod->module_core < mod->core_size;
5109 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5110 }
5111
5112 static inline int
5113 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5114 break;
5115
5116 case RV_BDREL:
5117 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5118 + if (in_init_rx(mod, val))
5119 + val -= (uint64_t) mod->module_init_rx;
5120 + else if (in_init_rw(mod, val))
5121 + val -= (uint64_t) mod->module_init_rw;
5122 + else if (in_core_rx(mod, val))
5123 + val -= (uint64_t) mod->module_core_rx;
5124 + else if (in_core_rw(mod, val))
5125 + val -= (uint64_t) mod->module_core_rw;
5126 break;
5127
5128 case RV_LTV:
5129 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5130 * addresses have been selected...
5131 */
5132 uint64_t gp;
5133 - if (mod->core_size > MAX_LTOFF)
5134 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5135 /*
5136 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5137 * at the end of the module.
5138 */
5139 - gp = mod->core_size - MAX_LTOFF / 2;
5140 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5141 else
5142 - gp = mod->core_size / 2;
5143 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5144 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5145 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5146 mod->arch.gp = gp;
5147 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5148 }
5149 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5150 index 77597e5..189dd62f 100644
5151 --- a/arch/ia64/kernel/palinfo.c
5152 +++ b/arch/ia64/kernel/palinfo.c
5153 @@ -977,7 +977,7 @@ create_palinfo_proc_entries(unsigned int cpu)
5154 struct proc_dir_entry **pdir;
5155 struct proc_dir_entry *cpu_dir;
5156 int j;
5157 - char cpustr[sizeof(CPUSTR)];
5158 + char cpustr[3+4+1];
5159
5160
5161 /*
5162 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5163 return NOTIFY_OK;
5164 }
5165
5166 -static struct notifier_block __refdata palinfo_cpu_notifier =
5167 +static struct notifier_block palinfo_cpu_notifier =
5168 {
5169 .notifier_call = palinfo_cpu_callback,
5170 .priority = 0,
5171 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5172 index 79802e5..1a89ec5 100644
5173 --- a/arch/ia64/kernel/salinfo.c
5174 +++ b/arch/ia64/kernel/salinfo.c
5175 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5176 return NOTIFY_OK;
5177 }
5178
5179 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5180 +static struct notifier_block salinfo_cpu_notifier =
5181 {
5182 .notifier_call = salinfo_cpu_callback,
5183 .priority = 0,
5184 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5185 index d9439ef..d0cac6b 100644
5186 --- a/arch/ia64/kernel/sys_ia64.c
5187 +++ b/arch/ia64/kernel/sys_ia64.c
5188 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5189 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
5190 struct mm_struct *mm = current->mm;
5191 struct vm_area_struct *vma;
5192 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5193
5194 if (len > RGN_MAP_LIMIT)
5195 return -ENOMEM;
5196 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5197 if (REGION_NUMBER(addr) == RGN_HPAGE)
5198 addr = 0;
5199 #endif
5200 +
5201 +#ifdef CONFIG_PAX_RANDMMAP
5202 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5203 + addr = mm->free_area_cache;
5204 + else
5205 +#endif
5206 +
5207 if (!addr)
5208 addr = mm->free_area_cache;
5209
5210 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5211 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5212 /* At this point: (!vma || addr < vma->vm_end). */
5213 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5214 - if (start_addr != TASK_UNMAPPED_BASE) {
5215 + if (start_addr != mm->mmap_base) {
5216 /* Start a new search --- just in case we missed some holes. */
5217 - addr = TASK_UNMAPPED_BASE;
5218 + addr = mm->mmap_base;
5219 goto full_search;
5220 }
5221 return -ENOMEM;
5222 }
5223 - if (!vma || addr + len <= vma->vm_start) {
5224 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5225 /* Remember the address where we stopped this search: */
5226 mm->free_area_cache = addr + len;
5227 return addr;
5228 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5229 index dc00b2c..cce53c2 100644
5230 --- a/arch/ia64/kernel/topology.c
5231 +++ b/arch/ia64/kernel/topology.c
5232 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5233 return NOTIFY_OK;
5234 }
5235
5236 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5237 +static struct notifier_block cache_cpu_notifier =
5238 {
5239 .notifier_call = cache_cpu_callback
5240 };
5241 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5242 index 0ccb28f..8992469 100644
5243 --- a/arch/ia64/kernel/vmlinux.lds.S
5244 +++ b/arch/ia64/kernel/vmlinux.lds.S
5245 @@ -198,7 +198,7 @@ SECTIONS {
5246 /* Per-cpu data: */
5247 . = ALIGN(PERCPU_PAGE_SIZE);
5248 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5249 - __phys_per_cpu_start = __per_cpu_load;
5250 + __phys_per_cpu_start = per_cpu_load;
5251 /*
5252 * ensure percpu data fits
5253 * into percpu page size
5254 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5255 index 6cf0341..d352594 100644
5256 --- a/arch/ia64/mm/fault.c
5257 +++ b/arch/ia64/mm/fault.c
5258 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5259 return pte_present(pte);
5260 }
5261
5262 +#ifdef CONFIG_PAX_PAGEEXEC
5263 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5264 +{
5265 + unsigned long i;
5266 +
5267 + printk(KERN_ERR "PAX: bytes at PC: ");
5268 + for (i = 0; i < 8; i++) {
5269 + unsigned int c;
5270 + if (get_user(c, (unsigned int *)pc+i))
5271 + printk(KERN_CONT "???????? ");
5272 + else
5273 + printk(KERN_CONT "%08x ", c);
5274 + }
5275 + printk("\n");
5276 +}
5277 +#endif
5278 +
5279 # define VM_READ_BIT 0
5280 # define VM_WRITE_BIT 1
5281 # define VM_EXEC_BIT 2
5282 @@ -149,8 +166,21 @@ retry:
5283 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5284 goto bad_area;
5285
5286 - if ((vma->vm_flags & mask) != mask)
5287 + if ((vma->vm_flags & mask) != mask) {
5288 +
5289 +#ifdef CONFIG_PAX_PAGEEXEC
5290 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5291 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5292 + goto bad_area;
5293 +
5294 + up_read(&mm->mmap_sem);
5295 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5296 + do_group_exit(SIGKILL);
5297 + }
5298 +#endif
5299 +
5300 goto bad_area;
5301 + }
5302
5303 /*
5304 * If for any reason at all we couldn't handle the fault, make
5305 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5306 index 5ca674b..127c3cb 100644
5307 --- a/arch/ia64/mm/hugetlbpage.c
5308 +++ b/arch/ia64/mm/hugetlbpage.c
5309 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5310 unsigned long pgoff, unsigned long flags)
5311 {
5312 struct vm_area_struct *vmm;
5313 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5314
5315 if (len > RGN_MAP_LIMIT)
5316 return -ENOMEM;
5317 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5318 /* At this point: (!vmm || addr < vmm->vm_end). */
5319 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5320 return -ENOMEM;
5321 - if (!vmm || (addr + len) <= vmm->vm_start)
5322 + if (check_heap_stack_gap(vmm, addr, len, offset))
5323 return addr;
5324 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5325 }
5326 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5327 index b755ea9..b9a969e 100644
5328 --- a/arch/ia64/mm/init.c
5329 +++ b/arch/ia64/mm/init.c
5330 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5331 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5332 vma->vm_end = vma->vm_start + PAGE_SIZE;
5333 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5334 +
5335 +#ifdef CONFIG_PAX_PAGEEXEC
5336 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5337 + vma->vm_flags &= ~VM_EXEC;
5338 +
5339 +#ifdef CONFIG_PAX_MPROTECT
5340 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5341 + vma->vm_flags &= ~VM_MAYEXEC;
5342 +#endif
5343 +
5344 + }
5345 +#endif
5346 +
5347 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5348 down_write(&current->mm->mmap_sem);
5349 if (insert_vm_struct(current->mm, vma)) {
5350 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5351 index 40b3ee9..8c2c112 100644
5352 --- a/arch/m32r/include/asm/cache.h
5353 +++ b/arch/m32r/include/asm/cache.h
5354 @@ -1,8 +1,10 @@
5355 #ifndef _ASM_M32R_CACHE_H
5356 #define _ASM_M32R_CACHE_H
5357
5358 +#include <linux/const.h>
5359 +
5360 /* L1 cache line size */
5361 #define L1_CACHE_SHIFT 4
5362 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5363 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5364
5365 #endif /* _ASM_M32R_CACHE_H */
5366 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5367 index 82abd15..d95ae5d 100644
5368 --- a/arch/m32r/lib/usercopy.c
5369 +++ b/arch/m32r/lib/usercopy.c
5370 @@ -14,6 +14,9 @@
5371 unsigned long
5372 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5373 {
5374 + if ((long)n < 0)
5375 + return n;
5376 +
5377 prefetch(from);
5378 if (access_ok(VERIFY_WRITE, to, n))
5379 __copy_user(to,from,n);
5380 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5381 unsigned long
5382 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5383 {
5384 + if ((long)n < 0)
5385 + return n;
5386 +
5387 prefetchw(to);
5388 if (access_ok(VERIFY_READ, from, n))
5389 __copy_user_zeroing(to,from,n);
5390 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5391 index 0395c51..5f26031 100644
5392 --- a/arch/m68k/include/asm/cache.h
5393 +++ b/arch/m68k/include/asm/cache.h
5394 @@ -4,9 +4,11 @@
5395 #ifndef __ARCH_M68K_CACHE_H
5396 #define __ARCH_M68K_CACHE_H
5397
5398 +#include <linux/const.h>
5399 +
5400 /* bytes per L1 cache line */
5401 #define L1_CACHE_SHIFT 4
5402 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5403 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5404
5405 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5406
5407 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5408 index 4efe96a..60e8699 100644
5409 --- a/arch/microblaze/include/asm/cache.h
5410 +++ b/arch/microblaze/include/asm/cache.h
5411 @@ -13,11 +13,12 @@
5412 #ifndef _ASM_MICROBLAZE_CACHE_H
5413 #define _ASM_MICROBLAZE_CACHE_H
5414
5415 +#include <linux/const.h>
5416 #include <asm/registers.h>
5417
5418 #define L1_CACHE_SHIFT 5
5419 /* word-granular cache in microblaze */
5420 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5421 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5422
5423 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5424
5425 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5426 index 01cc6ba..bcb7a5d 100644
5427 --- a/arch/mips/include/asm/atomic.h
5428 +++ b/arch/mips/include/asm/atomic.h
5429 @@ -21,6 +21,10 @@
5430 #include <asm/cmpxchg.h>
5431 #include <asm/war.h>
5432
5433 +#ifdef CONFIG_GENERIC_ATOMIC64
5434 +#include <asm-generic/atomic64.h>
5435 +#endif
5436 +
5437 #define ATOMIC_INIT(i) { (i) }
5438
5439 /*
5440 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5441 */
5442 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5443
5444 +#define atomic64_read_unchecked(v) atomic64_read(v)
5445 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5446 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5447 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5448 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5449 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5450 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5451 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5452 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5453 +
5454 #endif /* CONFIG_64BIT */
5455
5456 /*
5457 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5458 index b4db69f..8f3b093 100644
5459 --- a/arch/mips/include/asm/cache.h
5460 +++ b/arch/mips/include/asm/cache.h
5461 @@ -9,10 +9,11 @@
5462 #ifndef _ASM_CACHE_H
5463 #define _ASM_CACHE_H
5464
5465 +#include <linux/const.h>
5466 #include <kmalloc.h>
5467
5468 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5469 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5470 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5471
5472 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5473 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5474 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5475 index 455c0ac..ad65fbe 100644
5476 --- a/arch/mips/include/asm/elf.h
5477 +++ b/arch/mips/include/asm/elf.h
5478 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5479 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5480 #endif
5481
5482 +#ifdef CONFIG_PAX_ASLR
5483 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5484 +
5485 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5486 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5487 +#endif
5488 +
5489 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5490 struct linux_binprm;
5491 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5492 int uses_interp);
5493
5494 -struct mm_struct;
5495 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5496 -#define arch_randomize_brk arch_randomize_brk
5497 -
5498 #endif /* _ASM_ELF_H */
5499 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5500 index c1f6afa..38cc6e9 100644
5501 --- a/arch/mips/include/asm/exec.h
5502 +++ b/arch/mips/include/asm/exec.h
5503 @@ -12,6 +12,6 @@
5504 #ifndef _ASM_EXEC_H
5505 #define _ASM_EXEC_H
5506
5507 -extern unsigned long arch_align_stack(unsigned long sp);
5508 +#define arch_align_stack(x) ((x) & ~0xfUL)
5509
5510 #endif /* _ASM_EXEC_H */
5511 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5512 index 21bff32..9f0c3b8 100644
5513 --- a/arch/mips/include/asm/page.h
5514 +++ b/arch/mips/include/asm/page.h
5515 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5516 #ifdef CONFIG_CPU_MIPS32
5517 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5518 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5519 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5520 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5521 #else
5522 typedef struct { unsigned long long pte; } pte_t;
5523 #define pte_val(x) ((x).pte)
5524 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5525 index 881d18b..cea38bc 100644
5526 --- a/arch/mips/include/asm/pgalloc.h
5527 +++ b/arch/mips/include/asm/pgalloc.h
5528 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5529 {
5530 set_pud(pud, __pud((unsigned long)pmd));
5531 }
5532 +
5533 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5534 +{
5535 + pud_populate(mm, pud, pmd);
5536 +}
5537 #endif
5538
5539 /*
5540 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5541 index b2050b9..d71bb1b 100644
5542 --- a/arch/mips/include/asm/thread_info.h
5543 +++ b/arch/mips/include/asm/thread_info.h
5544 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5545 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5546 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5547 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5548 +/* li takes a 32bit immediate */
5549 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5550 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5551
5552 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5553 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5554 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5555 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5556 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5557 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5558 +
5559 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5560
5561 /* work to do in syscall_trace_leave() */
5562 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5563 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5564
5565 /* work to do on interrupt/exception return */
5566 #define _TIF_WORK_MASK \
5567 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5568 /* work to do on any return to u-space */
5569 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5570 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5571
5572 #endif /* __KERNEL__ */
5573
5574 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5575 index 9fdd8bc..4bd7f1a 100644
5576 --- a/arch/mips/kernel/binfmt_elfn32.c
5577 +++ b/arch/mips/kernel/binfmt_elfn32.c
5578 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5579 #undef ELF_ET_DYN_BASE
5580 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5581
5582 +#ifdef CONFIG_PAX_ASLR
5583 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5584 +
5585 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5586 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5587 +#endif
5588 +
5589 #include <asm/processor.h>
5590 #include <linux/module.h>
5591 #include <linux/elfcore.h>
5592 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5593 index ff44823..97f8906 100644
5594 --- a/arch/mips/kernel/binfmt_elfo32.c
5595 +++ b/arch/mips/kernel/binfmt_elfo32.c
5596 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5597 #undef ELF_ET_DYN_BASE
5598 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5599
5600 +#ifdef CONFIG_PAX_ASLR
5601 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5602 +
5603 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5604 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5605 +#endif
5606 +
5607 #include <asm/processor.h>
5608
5609 /*
5610 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5611 index a11c6f9..be5e164 100644
5612 --- a/arch/mips/kernel/process.c
5613 +++ b/arch/mips/kernel/process.c
5614 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5615 out:
5616 return pc;
5617 }
5618 -
5619 -/*
5620 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5621 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5622 - */
5623 -unsigned long arch_align_stack(unsigned long sp)
5624 -{
5625 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5626 - sp -= get_random_int() & ~PAGE_MASK;
5627 -
5628 - return sp & ALMASK;
5629 -}
5630 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5631 index 4812c6d..2069554 100644
5632 --- a/arch/mips/kernel/ptrace.c
5633 +++ b/arch/mips/kernel/ptrace.c
5634 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5635 return arch;
5636 }
5637
5638 +#ifdef CONFIG_GRKERNSEC_SETXID
5639 +extern void gr_delayed_cred_worker(void);
5640 +#endif
5641 +
5642 /*
5643 * Notification of system call entry/exit
5644 * - triggered by current->work.syscall_trace
5645 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5646 /* do the secure computing check first */
5647 secure_computing_strict(regs->regs[2]);
5648
5649 +#ifdef CONFIG_GRKERNSEC_SETXID
5650 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5651 + gr_delayed_cred_worker();
5652 +#endif
5653 +
5654 if (!(current->ptrace & PT_PTRACED))
5655 goto out;
5656
5657 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5658 index d20a4bc..7096ae5 100644
5659 --- a/arch/mips/kernel/scall32-o32.S
5660 +++ b/arch/mips/kernel/scall32-o32.S
5661 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5662
5663 stack_done:
5664 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5665 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5666 + li t1, _TIF_SYSCALL_WORK
5667 and t0, t1
5668 bnez t0, syscall_trace_entry # -> yes
5669
5670 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5671 index b64f642..0fe6eab 100644
5672 --- a/arch/mips/kernel/scall64-64.S
5673 +++ b/arch/mips/kernel/scall64-64.S
5674 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5675
5676 sd a3, PT_R26(sp) # save a3 for syscall restarting
5677
5678 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5679 + li t1, _TIF_SYSCALL_WORK
5680 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5681 and t0, t1, t0
5682 bnez t0, syscall_trace_entry
5683 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5684 index c29ac19..c592d05 100644
5685 --- a/arch/mips/kernel/scall64-n32.S
5686 +++ b/arch/mips/kernel/scall64-n32.S
5687 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5688
5689 sd a3, PT_R26(sp) # save a3 for syscall restarting
5690
5691 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5692 + li t1, _TIF_SYSCALL_WORK
5693 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5694 and t0, t1, t0
5695 bnez t0, n32_syscall_trace_entry
5696 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5697 index cf3e75e..72e93fe 100644
5698 --- a/arch/mips/kernel/scall64-o32.S
5699 +++ b/arch/mips/kernel/scall64-o32.S
5700 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5701 PTR 4b, bad_stack
5702 .previous
5703
5704 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5705 + li t1, _TIF_SYSCALL_WORK
5706 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5707 and t0, t1, t0
5708 bnez t0, trace_a_syscall
5709 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5710 index ddcec1e..c7f983e 100644
5711 --- a/arch/mips/mm/fault.c
5712 +++ b/arch/mips/mm/fault.c
5713 @@ -27,6 +27,23 @@
5714 #include <asm/highmem.h> /* For VMALLOC_END */
5715 #include <linux/kdebug.h>
5716
5717 +#ifdef CONFIG_PAX_PAGEEXEC
5718 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5719 +{
5720 + unsigned long i;
5721 +
5722 + printk(KERN_ERR "PAX: bytes at PC: ");
5723 + for (i = 0; i < 5; i++) {
5724 + unsigned int c;
5725 + if (get_user(c, (unsigned int *)pc+i))
5726 + printk(KERN_CONT "???????? ");
5727 + else
5728 + printk(KERN_CONT "%08x ", c);
5729 + }
5730 + printk("\n");
5731 +}
5732 +#endif
5733 +
5734 /*
5735 * This routine handles page faults. It determines the address,
5736 * and the problem, and then passes it off to one of the appropriate
5737 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5738 index 7e5fe27..479a219 100644
5739 --- a/arch/mips/mm/mmap.c
5740 +++ b/arch/mips/mm/mmap.c
5741 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5742 struct vm_area_struct *vma;
5743 unsigned long addr = addr0;
5744 int do_color_align;
5745 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5746 struct vm_unmapped_area_info info;
5747
5748 if (unlikely(len > TASK_SIZE))
5749 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5750 do_color_align = 1;
5751
5752 /* requesting a specific address */
5753 +
5754 +#ifdef CONFIG_PAX_RANDMMAP
5755 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5756 +#endif
5757 +
5758 if (addr) {
5759 if (do_color_align)
5760 addr = COLOUR_ALIGN(addr, pgoff);
5761 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5762 addr = PAGE_ALIGN(addr);
5763
5764 vma = find_vma(mm, addr);
5765 - if (TASK_SIZE - len >= addr &&
5766 - (!vma || addr + len <= vma->vm_start))
5767 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5768 return addr;
5769 }
5770
5771 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5772 {
5773 unsigned long random_factor = 0UL;
5774
5775 +#ifdef CONFIG_PAX_RANDMMAP
5776 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5777 +#endif
5778 +
5779 if (current->flags & PF_RANDOMIZE) {
5780 random_factor = get_random_int();
5781 random_factor = random_factor << PAGE_SHIFT;
5782 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5783
5784 if (mmap_is_legacy()) {
5785 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5786 +
5787 +#ifdef CONFIG_PAX_RANDMMAP
5788 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5789 + mm->mmap_base += mm->delta_mmap;
5790 +#endif
5791 +
5792 mm->get_unmapped_area = arch_get_unmapped_area;
5793 mm->unmap_area = arch_unmap_area;
5794 } else {
5795 mm->mmap_base = mmap_base(random_factor);
5796 +
5797 +#ifdef CONFIG_PAX_RANDMMAP
5798 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5799 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5800 +#endif
5801 +
5802 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5803 mm->unmap_area = arch_unmap_area_topdown;
5804 }
5805 }
5806
5807 -static inline unsigned long brk_rnd(void)
5808 -{
5809 - unsigned long rnd = get_random_int();
5810 -
5811 - rnd = rnd << PAGE_SHIFT;
5812 - /* 8MB for 32bit, 256MB for 64bit */
5813 - if (TASK_IS_32BIT_ADDR)
5814 - rnd = rnd & 0x7ffffful;
5815 - else
5816 - rnd = rnd & 0xffffffful;
5817 -
5818 - return rnd;
5819 -}
5820 -
5821 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5822 -{
5823 - unsigned long base = mm->brk;
5824 - unsigned long ret;
5825 -
5826 - ret = PAGE_ALIGN(base + brk_rnd());
5827 -
5828 - if (ret < mm->brk)
5829 - return mm->brk;
5830 -
5831 - return ret;
5832 -}
5833 -
5834 int __virt_addr_valid(const volatile void *kaddr)
5835 {
5836 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5837 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5838 index 967d144..db12197 100644
5839 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5840 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5841 @@ -11,12 +11,14 @@
5842 #ifndef _ASM_PROC_CACHE_H
5843 #define _ASM_PROC_CACHE_H
5844
5845 +#include <linux/const.h>
5846 +
5847 /* L1 cache */
5848
5849 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5850 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5851 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5852 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5853 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5854 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5855
5856 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5857 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5858 index bcb5df2..84fabd2 100644
5859 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5860 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5861 @@ -16,13 +16,15 @@
5862 #ifndef _ASM_PROC_CACHE_H
5863 #define _ASM_PROC_CACHE_H
5864
5865 +#include <linux/const.h>
5866 +
5867 /*
5868 * L1 cache
5869 */
5870 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5871 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5872 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5873 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5874 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5875 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5876
5877 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5878 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5879 index 4ce7a01..449202a 100644
5880 --- a/arch/openrisc/include/asm/cache.h
5881 +++ b/arch/openrisc/include/asm/cache.h
5882 @@ -19,11 +19,13 @@
5883 #ifndef __ASM_OPENRISC_CACHE_H
5884 #define __ASM_OPENRISC_CACHE_H
5885
5886 +#include <linux/const.h>
5887 +
5888 /* FIXME: How can we replace these with values from the CPU...
5889 * they shouldn't be hard-coded!
5890 */
5891
5892 -#define L1_CACHE_BYTES 16
5893 #define L1_CACHE_SHIFT 4
5894 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5895
5896 #endif /* __ASM_OPENRISC_CACHE_H */
5897 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5898 index af9cf30..2aae9b2 100644
5899 --- a/arch/parisc/include/asm/atomic.h
5900 +++ b/arch/parisc/include/asm/atomic.h
5901 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5902
5903 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5904
5905 +#define atomic64_read_unchecked(v) atomic64_read(v)
5906 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5907 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5908 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5909 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5910 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5911 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5912 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5913 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5914 +
5915 #endif /* !CONFIG_64BIT */
5916
5917
5918 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5919 index 47f11c7..3420df2 100644
5920 --- a/arch/parisc/include/asm/cache.h
5921 +++ b/arch/parisc/include/asm/cache.h
5922 @@ -5,6 +5,7 @@
5923 #ifndef __ARCH_PARISC_CACHE_H
5924 #define __ARCH_PARISC_CACHE_H
5925
5926 +#include <linux/const.h>
5927
5928 /*
5929 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5930 @@ -15,13 +16,13 @@
5931 * just ruin performance.
5932 */
5933 #ifdef CONFIG_PA20
5934 -#define L1_CACHE_BYTES 64
5935 #define L1_CACHE_SHIFT 6
5936 #else
5937 -#define L1_CACHE_BYTES 32
5938 #define L1_CACHE_SHIFT 5
5939 #endif
5940
5941 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5942 +
5943 #ifndef __ASSEMBLY__
5944
5945 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5946 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5947 index 19f6cb1..6c78cf2 100644
5948 --- a/arch/parisc/include/asm/elf.h
5949 +++ b/arch/parisc/include/asm/elf.h
5950 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5951
5952 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5953
5954 +#ifdef CONFIG_PAX_ASLR
5955 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5956 +
5957 +#define PAX_DELTA_MMAP_LEN 16
5958 +#define PAX_DELTA_STACK_LEN 16
5959 +#endif
5960 +
5961 /* This yields a mask that user programs can use to figure out what
5962 instruction set this CPU supports. This could be done in user space,
5963 but it's not easy, and we've already done it here. */
5964 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5965 index fc987a1..6e068ef 100644
5966 --- a/arch/parisc/include/asm/pgalloc.h
5967 +++ b/arch/parisc/include/asm/pgalloc.h
5968 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5969 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5970 }
5971
5972 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5973 +{
5974 + pgd_populate(mm, pgd, pmd);
5975 +}
5976 +
5977 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5978 {
5979 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5980 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5981 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5982 #define pmd_free(mm, x) do { } while (0)
5983 #define pgd_populate(mm, pmd, pte) BUG()
5984 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5985
5986 #endif
5987
5988 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5989 index 7df49fa..a3eb445 100644
5990 --- a/arch/parisc/include/asm/pgtable.h
5991 +++ b/arch/parisc/include/asm/pgtable.h
5992 @@ -16,6 +16,8 @@
5993 #include <asm/processor.h>
5994 #include <asm/cache.h>
5995
5996 +extern spinlock_t pa_dbit_lock;
5997 +
5998 /*
5999 * kern_addr_valid(ADDR) tests if ADDR is pointing to valid kernel
6000 * memory. For the return value to be meaningful, ADDR must be >=
6001 @@ -44,8 +46,11 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6002
6003 #define set_pte_at(mm, addr, ptep, pteval) \
6004 do { \
6005 + unsigned long flags; \
6006 + spin_lock_irqsave(&pa_dbit_lock, flags); \
6007 set_pte(ptep, pteval); \
6008 purge_tlb_entries(mm, addr); \
6009 + spin_unlock_irqrestore(&pa_dbit_lock, flags); \
6010 } while (0)
6011
6012 #endif /* !__ASSEMBLY__ */
6013 @@ -218,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6014 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6015 #define PAGE_COPY PAGE_EXECREAD
6016 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6017 +
6018 +#ifdef CONFIG_PAX_PAGEEXEC
6019 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6020 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6021 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6022 +#else
6023 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6024 +# define PAGE_COPY_NOEXEC PAGE_COPY
6025 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
6026 +#endif
6027 +
6028 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
6029 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
6030 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
6031 @@ -435,48 +451,46 @@ extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *);
6032
6033 static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
6034 {
6035 -#ifdef CONFIG_SMP
6036 + pte_t pte;
6037 + unsigned long flags;
6038 +
6039 if (!pte_young(*ptep))
6040 return 0;
6041 - return test_and_clear_bit(xlate_pabit(_PAGE_ACCESSED_BIT), &pte_val(*ptep));
6042 -#else
6043 - pte_t pte = *ptep;
6044 - if (!pte_young(pte))
6045 +
6046 + spin_lock_irqsave(&pa_dbit_lock, flags);
6047 + pte = *ptep;
6048 + if (!pte_young(pte)) {
6049 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6050 return 0;
6051 - set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
6052 + }
6053 + set_pte(ptep, pte_mkold(pte));
6054 + purge_tlb_entries(vma->vm_mm, addr);
6055 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6056 return 1;
6057 -#endif
6058 }
6059
6060 -extern spinlock_t pa_dbit_lock;
6061 -
6062 struct mm_struct;
6063 static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
6064 {
6065 pte_t old_pte;
6066 + unsigned long flags;
6067
6068 - spin_lock(&pa_dbit_lock);
6069 + spin_lock_irqsave(&pa_dbit_lock, flags);
6070 old_pte = *ptep;
6071 pte_clear(mm,addr,ptep);
6072 - spin_unlock(&pa_dbit_lock);
6073 + purge_tlb_entries(mm, addr);
6074 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6075
6076 return old_pte;
6077 }
6078
6079 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
6080 {
6081 -#ifdef CONFIG_SMP
6082 - unsigned long new, old;
6083 -
6084 - do {
6085 - old = pte_val(*ptep);
6086 - new = pte_val(pte_wrprotect(__pte (old)));
6087 - } while (cmpxchg((unsigned long *) ptep, old, new) != old);
6088 + unsigned long flags;
6089 + spin_lock_irqsave(&pa_dbit_lock, flags);
6090 + set_pte(ptep, pte_wrprotect(*ptep));
6091 purge_tlb_entries(mm, addr);
6092 -#else
6093 - pte_t old_pte = *ptep;
6094 - set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
6095 -#endif
6096 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6097 }
6098
6099 #define pte_same(A,B) (pte_val(A) == pte_val(B))
6100 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
6101 index 4ba2c93..f5e3974 100644
6102 --- a/arch/parisc/include/asm/uaccess.h
6103 +++ b/arch/parisc/include/asm/uaccess.h
6104 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
6105 const void __user *from,
6106 unsigned long n)
6107 {
6108 - int sz = __compiletime_object_size(to);
6109 + size_t sz = __compiletime_object_size(to);
6110 int ret = -EFAULT;
6111
6112 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
6113 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
6114 ret = __copy_from_user(to, from, n);
6115 else
6116 copy_from_user_overflow();
6117 diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
6118 index b89a85a..a9891fa 100644
6119 --- a/arch/parisc/kernel/cache.c
6120 +++ b/arch/parisc/kernel/cache.c
6121 @@ -426,14 +426,11 @@ void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
6122 /* Note: purge_tlb_entries can be called at startup with
6123 no context. */
6124
6125 - /* Disable preemption while we play with %sr1. */
6126 - preempt_disable();
6127 + purge_tlb_start(flags);
6128 mtsp(mm->context, 1);
6129 - purge_tlb_start(flags);
6130 pdtlb(addr);
6131 pitlb(addr);
6132 purge_tlb_end(flags);
6133 - preempt_enable();
6134 }
6135 EXPORT_SYMBOL(purge_tlb_entries);
6136
6137 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
6138 index 2a625fb..9908930 100644
6139 --- a/arch/parisc/kernel/module.c
6140 +++ b/arch/parisc/kernel/module.c
6141 @@ -98,16 +98,38 @@
6142
6143 /* three functions to determine where in the module core
6144 * or init pieces the location is */
6145 +static inline int in_init_rx(struct module *me, void *loc)
6146 +{
6147 + return (loc >= me->module_init_rx &&
6148 + loc < (me->module_init_rx + me->init_size_rx));
6149 +}
6150 +
6151 +static inline int in_init_rw(struct module *me, void *loc)
6152 +{
6153 + return (loc >= me->module_init_rw &&
6154 + loc < (me->module_init_rw + me->init_size_rw));
6155 +}
6156 +
6157 static inline int in_init(struct module *me, void *loc)
6158 {
6159 - return (loc >= me->module_init &&
6160 - loc <= (me->module_init + me->init_size));
6161 + return in_init_rx(me, loc) || in_init_rw(me, loc);
6162 +}
6163 +
6164 +static inline int in_core_rx(struct module *me, void *loc)
6165 +{
6166 + return (loc >= me->module_core_rx &&
6167 + loc < (me->module_core_rx + me->core_size_rx));
6168 +}
6169 +
6170 +static inline int in_core_rw(struct module *me, void *loc)
6171 +{
6172 + return (loc >= me->module_core_rw &&
6173 + loc < (me->module_core_rw + me->core_size_rw));
6174 }
6175
6176 static inline int in_core(struct module *me, void *loc)
6177 {
6178 - return (loc >= me->module_core &&
6179 - loc <= (me->module_core + me->core_size));
6180 + return in_core_rx(me, loc) || in_core_rw(me, loc);
6181 }
6182
6183 static inline int in_local(struct module *me, void *loc)
6184 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
6185 }
6186
6187 /* align things a bit */
6188 - me->core_size = ALIGN(me->core_size, 16);
6189 - me->arch.got_offset = me->core_size;
6190 - me->core_size += gots * sizeof(struct got_entry);
6191 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6192 + me->arch.got_offset = me->core_size_rw;
6193 + me->core_size_rw += gots * sizeof(struct got_entry);
6194
6195 - me->core_size = ALIGN(me->core_size, 16);
6196 - me->arch.fdesc_offset = me->core_size;
6197 - me->core_size += fdescs * sizeof(Elf_Fdesc);
6198 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6199 + me->arch.fdesc_offset = me->core_size_rw;
6200 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
6201
6202 me->arch.got_max = gots;
6203 me->arch.fdesc_max = fdescs;
6204 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6205
6206 BUG_ON(value == 0);
6207
6208 - got = me->module_core + me->arch.got_offset;
6209 + got = me->module_core_rw + me->arch.got_offset;
6210 for (i = 0; got[i].addr; i++)
6211 if (got[i].addr == value)
6212 goto out;
6213 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6214 #ifdef CONFIG_64BIT
6215 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6216 {
6217 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
6218 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
6219
6220 if (!value) {
6221 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
6222 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6223
6224 /* Create new one */
6225 fdesc->addr = value;
6226 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6227 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6228 return (Elf_Addr)fdesc;
6229 }
6230 #endif /* CONFIG_64BIT */
6231 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
6232
6233 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
6234 end = table + sechdrs[me->arch.unwind_section].sh_size;
6235 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6236 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6237
6238 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
6239 me->arch.unwind_section, table, end, gp);
6240 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
6241 index f76c108..92bad82 100644
6242 --- a/arch/parisc/kernel/sys_parisc.c
6243 +++ b/arch/parisc/kernel/sys_parisc.c
6244 @@ -33,9 +33,11 @@
6245 #include <linux/utsname.h>
6246 #include <linux/personality.h>
6247
6248 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6249 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
6250 + unsigned long flags)
6251 {
6252 struct vm_area_struct *vma;
6253 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6254
6255 addr = PAGE_ALIGN(addr);
6256
6257 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6258 /* At this point: (!vma || addr < vma->vm_end). */
6259 if (TASK_SIZE - len < addr)
6260 return -ENOMEM;
6261 - if (!vma || addr + len <= vma->vm_start)
6262 + if (check_heap_stack_gap(vma, addr, len, offset))
6263 return addr;
6264 addr = vma->vm_end;
6265 }
6266 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
6267 return offset & 0x3FF000;
6268 }
6269
6270 -static unsigned long get_shared_area(struct address_space *mapping,
6271 - unsigned long addr, unsigned long len, unsigned long pgoff)
6272 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
6273 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
6274 {
6275 struct vm_area_struct *vma;
6276 int offset = mapping ? get_offset(mapping) : 0;
6277 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6278
6279 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
6280
6281 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6282 /* At this point: (!vma || addr < vma->vm_end). */
6283 if (TASK_SIZE - len < addr)
6284 return -ENOMEM;
6285 - if (!vma || addr + len <= vma->vm_start)
6286 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
6287 return addr;
6288 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
6289 if (addr < vma->vm_end) /* handle wraparound */
6290 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6291 if (flags & MAP_FIXED)
6292 return addr;
6293 if (!addr)
6294 - addr = TASK_UNMAPPED_BASE;
6295 + addr = current->mm->mmap_base;
6296
6297 if (filp) {
6298 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6299 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6300 } else if(flags & MAP_SHARED) {
6301 - addr = get_shared_area(NULL, addr, len, pgoff);
6302 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6303 } else {
6304 - addr = get_unshared_area(addr, len);
6305 + addr = get_unshared_area(filp, addr, len, flags);
6306 }
6307 return addr;
6308 }
6309 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6310 index 45ba99f..8e22c33 100644
6311 --- a/arch/parisc/kernel/traps.c
6312 +++ b/arch/parisc/kernel/traps.c
6313 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6314
6315 down_read(&current->mm->mmap_sem);
6316 vma = find_vma(current->mm,regs->iaoq[0]);
6317 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6318 - && (vma->vm_flags & VM_EXEC)) {
6319 -
6320 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6321 fault_address = regs->iaoq[0];
6322 fault_space = regs->iasq[0];
6323
6324 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6325 index 18162ce..94de376 100644
6326 --- a/arch/parisc/mm/fault.c
6327 +++ b/arch/parisc/mm/fault.c
6328 @@ -15,6 +15,7 @@
6329 #include <linux/sched.h>
6330 #include <linux/interrupt.h>
6331 #include <linux/module.h>
6332 +#include <linux/unistd.h>
6333
6334 #include <asm/uaccess.h>
6335 #include <asm/traps.h>
6336 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6337 static unsigned long
6338 parisc_acctyp(unsigned long code, unsigned int inst)
6339 {
6340 - if (code == 6 || code == 16)
6341 + if (code == 6 || code == 7 || code == 16)
6342 return VM_EXEC;
6343
6344 switch (inst & 0xf0000000) {
6345 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6346 }
6347 #endif
6348
6349 +#ifdef CONFIG_PAX_PAGEEXEC
6350 +/*
6351 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6352 + *
6353 + * returns 1 when task should be killed
6354 + * 2 when rt_sigreturn trampoline was detected
6355 + * 3 when unpatched PLT trampoline was detected
6356 + */
6357 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6358 +{
6359 +
6360 +#ifdef CONFIG_PAX_EMUPLT
6361 + int err;
6362 +
6363 + do { /* PaX: unpatched PLT emulation */
6364 + unsigned int bl, depwi;
6365 +
6366 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6367 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6368 +
6369 + if (err)
6370 + break;
6371 +
6372 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6373 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6374 +
6375 + err = get_user(ldw, (unsigned int *)addr);
6376 + err |= get_user(bv, (unsigned int *)(addr+4));
6377 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6378 +
6379 + if (err)
6380 + break;
6381 +
6382 + if (ldw == 0x0E801096U &&
6383 + bv == 0xEAC0C000U &&
6384 + ldw2 == 0x0E881095U)
6385 + {
6386 + unsigned int resolver, map;
6387 +
6388 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6389 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6390 + if (err)
6391 + break;
6392 +
6393 + regs->gr[20] = instruction_pointer(regs)+8;
6394 + regs->gr[21] = map;
6395 + regs->gr[22] = resolver;
6396 + regs->iaoq[0] = resolver | 3UL;
6397 + regs->iaoq[1] = regs->iaoq[0] + 4;
6398 + return 3;
6399 + }
6400 + }
6401 + } while (0);
6402 +#endif
6403 +
6404 +#ifdef CONFIG_PAX_EMUTRAMP
6405 +
6406 +#ifndef CONFIG_PAX_EMUSIGRT
6407 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6408 + return 1;
6409 +#endif
6410 +
6411 + do { /* PaX: rt_sigreturn emulation */
6412 + unsigned int ldi1, ldi2, bel, nop;
6413 +
6414 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6415 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6416 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6417 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6418 +
6419 + if (err)
6420 + break;
6421 +
6422 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6423 + ldi2 == 0x3414015AU &&
6424 + bel == 0xE4008200U &&
6425 + nop == 0x08000240U)
6426 + {
6427 + regs->gr[25] = (ldi1 & 2) >> 1;
6428 + regs->gr[20] = __NR_rt_sigreturn;
6429 + regs->gr[31] = regs->iaoq[1] + 16;
6430 + regs->sr[0] = regs->iasq[1];
6431 + regs->iaoq[0] = 0x100UL;
6432 + regs->iaoq[1] = regs->iaoq[0] + 4;
6433 + regs->iasq[0] = regs->sr[2];
6434 + regs->iasq[1] = regs->sr[2];
6435 + return 2;
6436 + }
6437 + } while (0);
6438 +#endif
6439 +
6440 + return 1;
6441 +}
6442 +
6443 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6444 +{
6445 + unsigned long i;
6446 +
6447 + printk(KERN_ERR "PAX: bytes at PC: ");
6448 + for (i = 0; i < 5; i++) {
6449 + unsigned int c;
6450 + if (get_user(c, (unsigned int *)pc+i))
6451 + printk(KERN_CONT "???????? ");
6452 + else
6453 + printk(KERN_CONT "%08x ", c);
6454 + }
6455 + printk("\n");
6456 +}
6457 +#endif
6458 +
6459 int fixup_exception(struct pt_regs *regs)
6460 {
6461 const struct exception_table_entry *fix;
6462 @@ -192,8 +303,33 @@ good_area:
6463
6464 acc_type = parisc_acctyp(code,regs->iir);
6465
6466 - if ((vma->vm_flags & acc_type) != acc_type)
6467 + if ((vma->vm_flags & acc_type) != acc_type) {
6468 +
6469 +#ifdef CONFIG_PAX_PAGEEXEC
6470 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6471 + (address & ~3UL) == instruction_pointer(regs))
6472 + {
6473 + up_read(&mm->mmap_sem);
6474 + switch (pax_handle_fetch_fault(regs)) {
6475 +
6476 +#ifdef CONFIG_PAX_EMUPLT
6477 + case 3:
6478 + return;
6479 +#endif
6480 +
6481 +#ifdef CONFIG_PAX_EMUTRAMP
6482 + case 2:
6483 + return;
6484 +#endif
6485 +
6486 + }
6487 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6488 + do_group_exit(SIGKILL);
6489 + }
6490 +#endif
6491 +
6492 goto bad_area;
6493 + }
6494
6495 /*
6496 * If for any reason at all we couldn't handle the fault, make
6497 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6498 index e3b1d41..8e81edf 100644
6499 --- a/arch/powerpc/include/asm/atomic.h
6500 +++ b/arch/powerpc/include/asm/atomic.h
6501 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6502 return t1;
6503 }
6504
6505 +#define atomic64_read_unchecked(v) atomic64_read(v)
6506 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6507 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6508 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6509 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6510 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6511 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6512 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6513 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6514 +
6515 #endif /* __powerpc64__ */
6516
6517 #endif /* __KERNEL__ */
6518 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6519 index 9e495c9..b6878e5 100644
6520 --- a/arch/powerpc/include/asm/cache.h
6521 +++ b/arch/powerpc/include/asm/cache.h
6522 @@ -3,6 +3,7 @@
6523
6524 #ifdef __KERNEL__
6525
6526 +#include <linux/const.h>
6527
6528 /* bytes per L1 cache line */
6529 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6530 @@ -22,7 +23,7 @@
6531 #define L1_CACHE_SHIFT 7
6532 #endif
6533
6534 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6535 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6536
6537 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6538
6539 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6540 index 6abf0a1..459d0f1 100644
6541 --- a/arch/powerpc/include/asm/elf.h
6542 +++ b/arch/powerpc/include/asm/elf.h
6543 @@ -28,8 +28,19 @@
6544 the loader. We need to make sure that it is out of the way of the program
6545 that it will "exec", and that there is sufficient room for the brk. */
6546
6547 -extern unsigned long randomize_et_dyn(unsigned long base);
6548 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6549 +#define ELF_ET_DYN_BASE (0x20000000)
6550 +
6551 +#ifdef CONFIG_PAX_ASLR
6552 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6553 +
6554 +#ifdef __powerpc64__
6555 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6556 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6557 +#else
6558 +#define PAX_DELTA_MMAP_LEN 15
6559 +#define PAX_DELTA_STACK_LEN 15
6560 +#endif
6561 +#endif
6562
6563 /*
6564 * Our registers are always unsigned longs, whether we're a 32 bit
6565 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6566 (0x7ff >> (PAGE_SHIFT - 12)) : \
6567 (0x3ffff >> (PAGE_SHIFT - 12)))
6568
6569 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6570 -#define arch_randomize_brk arch_randomize_brk
6571 -
6572 -
6573 #ifdef CONFIG_SPU_BASE
6574 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6575 #define NT_SPU 1
6576 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6577 index 8196e9c..d83a9f3 100644
6578 --- a/arch/powerpc/include/asm/exec.h
6579 +++ b/arch/powerpc/include/asm/exec.h
6580 @@ -4,6 +4,6 @@
6581 #ifndef _ASM_POWERPC_EXEC_H
6582 #define _ASM_POWERPC_EXEC_H
6583
6584 -extern unsigned long arch_align_stack(unsigned long sp);
6585 +#define arch_align_stack(x) ((x) & ~0xfUL)
6586
6587 #endif /* _ASM_POWERPC_EXEC_H */
6588 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6589 index 5acabbd..7ea14fa 100644
6590 --- a/arch/powerpc/include/asm/kmap_types.h
6591 +++ b/arch/powerpc/include/asm/kmap_types.h
6592 @@ -10,7 +10,7 @@
6593 * 2 of the License, or (at your option) any later version.
6594 */
6595
6596 -#define KM_TYPE_NR 16
6597 +#define KM_TYPE_NR 17
6598
6599 #endif /* __KERNEL__ */
6600 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6601 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6602 index 8565c25..2865190 100644
6603 --- a/arch/powerpc/include/asm/mman.h
6604 +++ b/arch/powerpc/include/asm/mman.h
6605 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6606 }
6607 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6608
6609 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6610 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6611 {
6612 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6613 }
6614 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6615 index f072e97..b436dee 100644
6616 --- a/arch/powerpc/include/asm/page.h
6617 +++ b/arch/powerpc/include/asm/page.h
6618 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6619 * and needs to be executable. This means the whole heap ends
6620 * up being executable.
6621 */
6622 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6623 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6624 +#define VM_DATA_DEFAULT_FLAGS32 \
6625 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6626 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6627
6628 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6629 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6630 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6631 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6632 #endif
6633
6634 +#define ktla_ktva(addr) (addr)
6635 +#define ktva_ktla(addr) (addr)
6636 +
6637 /*
6638 * Use the top bit of the higher-level page table entries to indicate whether
6639 * the entries we point to contain hugepages. This works because we know that
6640 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6641 index cd915d6..c10cee8 100644
6642 --- a/arch/powerpc/include/asm/page_64.h
6643 +++ b/arch/powerpc/include/asm/page_64.h
6644 @@ -154,15 +154,18 @@ do { \
6645 * stack by default, so in the absence of a PT_GNU_STACK program header
6646 * we turn execute permission off.
6647 */
6648 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6649 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6650 +#define VM_STACK_DEFAULT_FLAGS32 \
6651 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6652 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6653
6654 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6655 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6656
6657 +#ifndef CONFIG_PAX_PAGEEXEC
6658 #define VM_STACK_DEFAULT_FLAGS \
6659 (is_32bit_task() ? \
6660 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6661 +#endif
6662
6663 #include <asm-generic/getorder.h>
6664
6665 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6666 index 292725c..f87ae14 100644
6667 --- a/arch/powerpc/include/asm/pgalloc-64.h
6668 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6669 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6670 #ifndef CONFIG_PPC_64K_PAGES
6671
6672 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6673 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6674
6675 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6676 {
6677 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6678 pud_set(pud, (unsigned long)pmd);
6679 }
6680
6681 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6682 +{
6683 + pud_populate(mm, pud, pmd);
6684 +}
6685 +
6686 #define pmd_populate(mm, pmd, pte_page) \
6687 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6688 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6689 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6690 #else /* CONFIG_PPC_64K_PAGES */
6691
6692 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6693 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6694
6695 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6696 pte_t *pte)
6697 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6698 index a9cbd3b..3b67efa 100644
6699 --- a/arch/powerpc/include/asm/pgtable.h
6700 +++ b/arch/powerpc/include/asm/pgtable.h
6701 @@ -2,6 +2,7 @@
6702 #define _ASM_POWERPC_PGTABLE_H
6703 #ifdef __KERNEL__
6704
6705 +#include <linux/const.h>
6706 #ifndef __ASSEMBLY__
6707 #include <asm/processor.h> /* For TASK_SIZE */
6708 #include <asm/mmu.h>
6709 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6710 index 4aad413..85d86bf 100644
6711 --- a/arch/powerpc/include/asm/pte-hash32.h
6712 +++ b/arch/powerpc/include/asm/pte-hash32.h
6713 @@ -21,6 +21,7 @@
6714 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6715 #define _PAGE_USER 0x004 /* usermode access allowed */
6716 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6717 +#define _PAGE_EXEC _PAGE_GUARDED
6718 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6719 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6720 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6721 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6722 index 3d5c9dc..62f8414 100644
6723 --- a/arch/powerpc/include/asm/reg.h
6724 +++ b/arch/powerpc/include/asm/reg.h
6725 @@ -215,6 +215,7 @@
6726 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6727 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6728 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6729 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6730 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6731 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6732 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6733 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6734 index 195ce2a..ab5c614 100644
6735 --- a/arch/powerpc/include/asm/smp.h
6736 +++ b/arch/powerpc/include/asm/smp.h
6737 @@ -50,7 +50,7 @@ struct smp_ops_t {
6738 int (*cpu_disable)(void);
6739 void (*cpu_die)(unsigned int nr);
6740 int (*cpu_bootable)(unsigned int nr);
6741 -};
6742 +} __no_const;
6743
6744 extern void smp_send_debugger_break(void);
6745 extern void start_secondary_resume(void);
6746 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6747 index 406b7b9..af63426 100644
6748 --- a/arch/powerpc/include/asm/thread_info.h
6749 +++ b/arch/powerpc/include/asm/thread_info.h
6750 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6751 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6752 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6753 #define TIF_SINGLESTEP 8 /* singlestepping active */
6754 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6755 #define TIF_SECCOMP 10 /* secure computing */
6756 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6757 #define TIF_NOERROR 12 /* Force successful syscall return */
6758 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6759 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6760 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6761 for stack store? */
6762 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6763 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6764 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6765
6766 /* as above, but as bit values */
6767 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6768 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6769 #define _TIF_UPROBE (1<<TIF_UPROBE)
6770 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6771 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6772 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6773 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6774 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6775 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6776 + _TIF_GRSEC_SETXID)
6777
6778 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6779 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6780 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6781 index 4db4959..aba5c41 100644
6782 --- a/arch/powerpc/include/asm/uaccess.h
6783 +++ b/arch/powerpc/include/asm/uaccess.h
6784 @@ -318,52 +318,6 @@ do { \
6785 extern unsigned long __copy_tofrom_user(void __user *to,
6786 const void __user *from, unsigned long size);
6787
6788 -#ifndef __powerpc64__
6789 -
6790 -static inline unsigned long copy_from_user(void *to,
6791 - const void __user *from, unsigned long n)
6792 -{
6793 - unsigned long over;
6794 -
6795 - if (access_ok(VERIFY_READ, from, n))
6796 - return __copy_tofrom_user((__force void __user *)to, from, n);
6797 - if ((unsigned long)from < TASK_SIZE) {
6798 - over = (unsigned long)from + n - TASK_SIZE;
6799 - return __copy_tofrom_user((__force void __user *)to, from,
6800 - n - over) + over;
6801 - }
6802 - return n;
6803 -}
6804 -
6805 -static inline unsigned long copy_to_user(void __user *to,
6806 - const void *from, unsigned long n)
6807 -{
6808 - unsigned long over;
6809 -
6810 - if (access_ok(VERIFY_WRITE, to, n))
6811 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6812 - if ((unsigned long)to < TASK_SIZE) {
6813 - over = (unsigned long)to + n - TASK_SIZE;
6814 - return __copy_tofrom_user(to, (__force void __user *)from,
6815 - n - over) + over;
6816 - }
6817 - return n;
6818 -}
6819 -
6820 -#else /* __powerpc64__ */
6821 -
6822 -#define __copy_in_user(to, from, size) \
6823 - __copy_tofrom_user((to), (from), (size))
6824 -
6825 -extern unsigned long copy_from_user(void *to, const void __user *from,
6826 - unsigned long n);
6827 -extern unsigned long copy_to_user(void __user *to, const void *from,
6828 - unsigned long n);
6829 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6830 - unsigned long n);
6831 -
6832 -#endif /* __powerpc64__ */
6833 -
6834 static inline unsigned long __copy_from_user_inatomic(void *to,
6835 const void __user *from, unsigned long n)
6836 {
6837 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6838 if (ret == 0)
6839 return 0;
6840 }
6841 +
6842 + if (!__builtin_constant_p(n))
6843 + check_object_size(to, n, false);
6844 +
6845 return __copy_tofrom_user((__force void __user *)to, from, n);
6846 }
6847
6848 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6849 if (ret == 0)
6850 return 0;
6851 }
6852 +
6853 + if (!__builtin_constant_p(n))
6854 + check_object_size(from, n, true);
6855 +
6856 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6857 }
6858
6859 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6860 return __copy_to_user_inatomic(to, from, size);
6861 }
6862
6863 +#ifndef __powerpc64__
6864 +
6865 +static inline unsigned long __must_check copy_from_user(void *to,
6866 + const void __user *from, unsigned long n)
6867 +{
6868 + unsigned long over;
6869 +
6870 + if ((long)n < 0)
6871 + return n;
6872 +
6873 + if (access_ok(VERIFY_READ, from, n)) {
6874 + if (!__builtin_constant_p(n))
6875 + check_object_size(to, n, false);
6876 + return __copy_tofrom_user((__force void __user *)to, from, n);
6877 + }
6878 + if ((unsigned long)from < TASK_SIZE) {
6879 + over = (unsigned long)from + n - TASK_SIZE;
6880 + if (!__builtin_constant_p(n - over))
6881 + check_object_size(to, n - over, false);
6882 + return __copy_tofrom_user((__force void __user *)to, from,
6883 + n - over) + over;
6884 + }
6885 + return n;
6886 +}
6887 +
6888 +static inline unsigned long __must_check copy_to_user(void __user *to,
6889 + const void *from, unsigned long n)
6890 +{
6891 + unsigned long over;
6892 +
6893 + if ((long)n < 0)
6894 + return n;
6895 +
6896 + if (access_ok(VERIFY_WRITE, to, n)) {
6897 + if (!__builtin_constant_p(n))
6898 + check_object_size(from, n, true);
6899 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6900 + }
6901 + if ((unsigned long)to < TASK_SIZE) {
6902 + over = (unsigned long)to + n - TASK_SIZE;
6903 + if (!__builtin_constant_p(n))
6904 + check_object_size(from, n - over, true);
6905 + return __copy_tofrom_user(to, (__force void __user *)from,
6906 + n - over) + over;
6907 + }
6908 + return n;
6909 +}
6910 +
6911 +#else /* __powerpc64__ */
6912 +
6913 +#define __copy_in_user(to, from, size) \
6914 + __copy_tofrom_user((to), (from), (size))
6915 +
6916 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6917 +{
6918 + if ((long)n < 0 || n > INT_MAX)
6919 + return n;
6920 +
6921 + if (!__builtin_constant_p(n))
6922 + check_object_size(to, n, false);
6923 +
6924 + if (likely(access_ok(VERIFY_READ, from, n)))
6925 + n = __copy_from_user(to, from, n);
6926 + else
6927 + memset(to, 0, n);
6928 + return n;
6929 +}
6930 +
6931 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6932 +{
6933 + if ((long)n < 0 || n > INT_MAX)
6934 + return n;
6935 +
6936 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6937 + if (!__builtin_constant_p(n))
6938 + check_object_size(from, n, true);
6939 + n = __copy_to_user(to, from, n);
6940 + }
6941 + return n;
6942 +}
6943 +
6944 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6945 + unsigned long n);
6946 +
6947 +#endif /* __powerpc64__ */
6948 +
6949 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6950
6951 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6952 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6953 index 4684e33..acc4d19e 100644
6954 --- a/arch/powerpc/kernel/exceptions-64e.S
6955 +++ b/arch/powerpc/kernel/exceptions-64e.S
6956 @@ -715,6 +715,7 @@ storage_fault_common:
6957 std r14,_DAR(r1)
6958 std r15,_DSISR(r1)
6959 addi r3,r1,STACK_FRAME_OVERHEAD
6960 + bl .save_nvgprs
6961 mr r4,r14
6962 mr r5,r15
6963 ld r14,PACA_EXGEN+EX_R14(r13)
6964 @@ -723,8 +724,7 @@ storage_fault_common:
6965 cmpdi r3,0
6966 bne- 1f
6967 b .ret_from_except_lite
6968 -1: bl .save_nvgprs
6969 - mr r5,r3
6970 +1: mr r5,r3
6971 addi r3,r1,STACK_FRAME_OVERHEAD
6972 ld r4,_DAR(r1)
6973 bl .bad_page_fault
6974 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6975 index 3684cbd..bc89eab 100644
6976 --- a/arch/powerpc/kernel/exceptions-64s.S
6977 +++ b/arch/powerpc/kernel/exceptions-64s.S
6978 @@ -1206,10 +1206,10 @@ handle_page_fault:
6979 11: ld r4,_DAR(r1)
6980 ld r5,_DSISR(r1)
6981 addi r3,r1,STACK_FRAME_OVERHEAD
6982 + bl .save_nvgprs
6983 bl .do_page_fault
6984 cmpdi r3,0
6985 beq+ 12f
6986 - bl .save_nvgprs
6987 mr r5,r3
6988 addi r3,r1,STACK_FRAME_OVERHEAD
6989 lwz r4,_DAR(r1)
6990 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6991 index 2e3200c..72095ce 100644
6992 --- a/arch/powerpc/kernel/module_32.c
6993 +++ b/arch/powerpc/kernel/module_32.c
6994 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6995 me->arch.core_plt_section = i;
6996 }
6997 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6998 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6999 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7000 return -ENOEXEC;
7001 }
7002
7003 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7004
7005 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7006 /* Init, or core PLT? */
7007 - if (location >= mod->module_core
7008 - && location < mod->module_core + mod->core_size)
7009 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7010 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7011 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7012 - else
7013 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7014 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7015 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7016 + else {
7017 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7018 + return ~0UL;
7019 + }
7020
7021 /* Find this entry, or if that fails, the next avail. entry */
7022 while (entry->jump[0]) {
7023 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7024 index 8143067..21ae55b 100644
7025 --- a/arch/powerpc/kernel/process.c
7026 +++ b/arch/powerpc/kernel/process.c
7027 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
7028 * Lookup NIP late so we have the best change of getting the
7029 * above info out without failing
7030 */
7031 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7032 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7033 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7034 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7035 #endif
7036 show_stack(current, (unsigned long *) regs->gpr[1]);
7037 if (!user_mode(regs))
7038 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7039 newsp = stack[0];
7040 ip = stack[STACK_FRAME_LR_SAVE];
7041 if (!firstframe || ip != lr) {
7042 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
7043 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
7044 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7045 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
7046 - printk(" (%pS)",
7047 + printk(" (%pA)",
7048 (void *)current->ret_stack[curr_frame].ret);
7049 curr_frame--;
7050 }
7051 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7052 struct pt_regs *regs = (struct pt_regs *)
7053 (sp + STACK_FRAME_OVERHEAD);
7054 lr = regs->link;
7055 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
7056 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
7057 regs->trap, (void *)regs->nip, (void *)lr);
7058 firstframe = 1;
7059 }
7060 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
7061 mtspr(SPRN_CTRLT, ctrl);
7062 }
7063 #endif /* CONFIG_PPC64 */
7064 -
7065 -unsigned long arch_align_stack(unsigned long sp)
7066 -{
7067 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7068 - sp -= get_random_int() & ~PAGE_MASK;
7069 - return sp & ~0xf;
7070 -}
7071 -
7072 -static inline unsigned long brk_rnd(void)
7073 -{
7074 - unsigned long rnd = 0;
7075 -
7076 - /* 8MB for 32bit, 1GB for 64bit */
7077 - if (is_32bit_task())
7078 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7079 - else
7080 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7081 -
7082 - return rnd << PAGE_SHIFT;
7083 -}
7084 -
7085 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7086 -{
7087 - unsigned long base = mm->brk;
7088 - unsigned long ret;
7089 -
7090 -#ifdef CONFIG_PPC_STD_MMU_64
7091 - /*
7092 - * If we are using 1TB segments and we are allowed to randomise
7093 - * the heap, we can put it above 1TB so it is backed by a 1TB
7094 - * segment. Otherwise the heap will be in the bottom 1TB
7095 - * which always uses 256MB segments and this may result in a
7096 - * performance penalty.
7097 - */
7098 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7099 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7100 -#endif
7101 -
7102 - ret = PAGE_ALIGN(base + brk_rnd());
7103 -
7104 - if (ret < mm->brk)
7105 - return mm->brk;
7106 -
7107 - return ret;
7108 -}
7109 -
7110 -unsigned long randomize_et_dyn(unsigned long base)
7111 -{
7112 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7113 -
7114 - if (ret < base)
7115 - return base;
7116 -
7117 - return ret;
7118 -}
7119 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
7120 index c497000..8fde506 100644
7121 --- a/arch/powerpc/kernel/ptrace.c
7122 +++ b/arch/powerpc/kernel/ptrace.c
7123 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
7124 return ret;
7125 }
7126
7127 +#ifdef CONFIG_GRKERNSEC_SETXID
7128 +extern void gr_delayed_cred_worker(void);
7129 +#endif
7130 +
7131 /*
7132 * We must return the syscall number to actually look up in the table.
7133 * This can be -1L to skip running any syscall at all.
7134 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
7135
7136 secure_computing_strict(regs->gpr[0]);
7137
7138 +#ifdef CONFIG_GRKERNSEC_SETXID
7139 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7140 + gr_delayed_cred_worker();
7141 +#endif
7142 +
7143 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
7144 tracehook_report_syscall_entry(regs))
7145 /*
7146 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
7147 {
7148 int step;
7149
7150 +#ifdef CONFIG_GRKERNSEC_SETXID
7151 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7152 + gr_delayed_cred_worker();
7153 +#endif
7154 +
7155 audit_syscall_exit(regs);
7156
7157 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7158 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
7159 index 804e323..79181c1 100644
7160 --- a/arch/powerpc/kernel/signal_32.c
7161 +++ b/arch/powerpc/kernel/signal_32.c
7162 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
7163 /* Save user registers on the stack */
7164 frame = &rt_sf->uc.uc_mcontext;
7165 addr = frame;
7166 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
7167 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7168 if (save_user_regs(regs, frame, 0, 1))
7169 goto badframe;
7170 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
7171 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
7172 index 1ca045d..139c3f7 100644
7173 --- a/arch/powerpc/kernel/signal_64.c
7174 +++ b/arch/powerpc/kernel/signal_64.c
7175 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
7176 current->thread.fpscr.val = 0;
7177
7178 /* Set up to return from userspace. */
7179 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
7180 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7181 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
7182 } else {
7183 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
7184 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
7185 index 3ce1f86..c30e629 100644
7186 --- a/arch/powerpc/kernel/sysfs.c
7187 +++ b/arch/powerpc/kernel/sysfs.c
7188 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
7189 return NOTIFY_OK;
7190 }
7191
7192 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
7193 +static struct notifier_block sysfs_cpu_nb = {
7194 .notifier_call = sysfs_cpu_notify,
7195 };
7196
7197 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
7198 index 3251840..3f7c77a 100644
7199 --- a/arch/powerpc/kernel/traps.c
7200 +++ b/arch/powerpc/kernel/traps.c
7201 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
7202 return flags;
7203 }
7204
7205 +extern void gr_handle_kernel_exploit(void);
7206 +
7207 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7208 int signr)
7209 {
7210 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7211 panic("Fatal exception in interrupt");
7212 if (panic_on_oops)
7213 panic("Fatal exception");
7214 +
7215 + gr_handle_kernel_exploit();
7216 +
7217 do_exit(signr);
7218 }
7219
7220 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
7221 index 1b2076f..835e4be 100644
7222 --- a/arch/powerpc/kernel/vdso.c
7223 +++ b/arch/powerpc/kernel/vdso.c
7224 @@ -34,6 +34,7 @@
7225 #include <asm/firmware.h>
7226 #include <asm/vdso.h>
7227 #include <asm/vdso_datapage.h>
7228 +#include <asm/mman.h>
7229
7230 #include "setup.h"
7231
7232 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7233 vdso_base = VDSO32_MBASE;
7234 #endif
7235
7236 - current->mm->context.vdso_base = 0;
7237 + current->mm->context.vdso_base = ~0UL;
7238
7239 /* vDSO has a problem and was disabled, just don't "enable" it for the
7240 * process
7241 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7242 vdso_base = get_unmapped_area(NULL, vdso_base,
7243 (vdso_pages << PAGE_SHIFT) +
7244 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
7245 - 0, 0);
7246 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
7247 if (IS_ERR_VALUE(vdso_base)) {
7248 rc = vdso_base;
7249 goto fail_mmapsem;
7250 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
7251 index 5eea6f3..5d10396 100644
7252 --- a/arch/powerpc/lib/usercopy_64.c
7253 +++ b/arch/powerpc/lib/usercopy_64.c
7254 @@ -9,22 +9,6 @@
7255 #include <linux/module.h>
7256 #include <asm/uaccess.h>
7257
7258 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
7259 -{
7260 - if (likely(access_ok(VERIFY_READ, from, n)))
7261 - n = __copy_from_user(to, from, n);
7262 - else
7263 - memset(to, 0, n);
7264 - return n;
7265 -}
7266 -
7267 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
7268 -{
7269 - if (likely(access_ok(VERIFY_WRITE, to, n)))
7270 - n = __copy_to_user(to, from, n);
7271 - return n;
7272 -}
7273 -
7274 unsigned long copy_in_user(void __user *to, const void __user *from,
7275 unsigned long n)
7276 {
7277 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7278 return n;
7279 }
7280
7281 -EXPORT_SYMBOL(copy_from_user);
7282 -EXPORT_SYMBOL(copy_to_user);
7283 EXPORT_SYMBOL(copy_in_user);
7284
7285 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7286 index 3a8489a..6a63b3b 100644
7287 --- a/arch/powerpc/mm/fault.c
7288 +++ b/arch/powerpc/mm/fault.c
7289 @@ -32,6 +32,10 @@
7290 #include <linux/perf_event.h>
7291 #include <linux/magic.h>
7292 #include <linux/ratelimit.h>
7293 +#include <linux/slab.h>
7294 +#include <linux/pagemap.h>
7295 +#include <linux/compiler.h>
7296 +#include <linux/unistd.h>
7297
7298 #include <asm/firmware.h>
7299 #include <asm/page.h>
7300 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7301 }
7302 #endif
7303
7304 +#ifdef CONFIG_PAX_PAGEEXEC
7305 +/*
7306 + * PaX: decide what to do with offenders (regs->nip = fault address)
7307 + *
7308 + * returns 1 when task should be killed
7309 + */
7310 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7311 +{
7312 + return 1;
7313 +}
7314 +
7315 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7316 +{
7317 + unsigned long i;
7318 +
7319 + printk(KERN_ERR "PAX: bytes at PC: ");
7320 + for (i = 0; i < 5; i++) {
7321 + unsigned int c;
7322 + if (get_user(c, (unsigned int __user *)pc+i))
7323 + printk(KERN_CONT "???????? ");
7324 + else
7325 + printk(KERN_CONT "%08x ", c);
7326 + }
7327 + printk("\n");
7328 +}
7329 +#endif
7330 +
7331 /*
7332 * Check whether the instruction at regs->nip is a store using
7333 * an update addressing form which will update r1.
7334 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7335 * indicate errors in DSISR but can validly be set in SRR1.
7336 */
7337 if (trap == 0x400)
7338 - error_code &= 0x48200000;
7339 + error_code &= 0x58200000;
7340 else
7341 is_write = error_code & DSISR_ISSTORE;
7342 #else
7343 @@ -364,7 +395,7 @@ good_area:
7344 * "undefined". Of those that can be set, this is the only
7345 * one which seems bad.
7346 */
7347 - if (error_code & 0x10000000)
7348 + if (error_code & DSISR_GUARDED)
7349 /* Guarded storage error. */
7350 goto bad_area;
7351 #endif /* CONFIG_8xx */
7352 @@ -379,7 +410,7 @@ good_area:
7353 * processors use the same I/D cache coherency mechanism
7354 * as embedded.
7355 */
7356 - if (error_code & DSISR_PROTFAULT)
7357 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7358 goto bad_area;
7359 #endif /* CONFIG_PPC_STD_MMU */
7360
7361 @@ -462,6 +493,23 @@ bad_area:
7362 bad_area_nosemaphore:
7363 /* User mode accesses cause a SIGSEGV */
7364 if (user_mode(regs)) {
7365 +
7366 +#ifdef CONFIG_PAX_PAGEEXEC
7367 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7368 +#ifdef CONFIG_PPC_STD_MMU
7369 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7370 +#else
7371 + if (is_exec && regs->nip == address) {
7372 +#endif
7373 + switch (pax_handle_fetch_fault(regs)) {
7374 + }
7375 +
7376 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7377 + do_group_exit(SIGKILL);
7378 + }
7379 + }
7380 +#endif
7381 +
7382 _exception(SIGSEGV, regs, code, address);
7383 return 0;
7384 }
7385 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7386 index 67a42ed..cd463e0 100644
7387 --- a/arch/powerpc/mm/mmap_64.c
7388 +++ b/arch/powerpc/mm/mmap_64.c
7389 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7390 {
7391 unsigned long rnd = 0;
7392
7393 +#ifdef CONFIG_PAX_RANDMMAP
7394 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7395 +#endif
7396 +
7397 if (current->flags & PF_RANDOMIZE) {
7398 /* 8MB for 32bit, 1GB for 64bit */
7399 if (is_32bit_task())
7400 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7401 */
7402 if (mmap_is_legacy()) {
7403 mm->mmap_base = TASK_UNMAPPED_BASE;
7404 +
7405 +#ifdef CONFIG_PAX_RANDMMAP
7406 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7407 + mm->mmap_base += mm->delta_mmap;
7408 +#endif
7409 +
7410 mm->get_unmapped_area = arch_get_unmapped_area;
7411 mm->unmap_area = arch_unmap_area;
7412 } else {
7413 mm->mmap_base = mmap_base();
7414 +
7415 +#ifdef CONFIG_PAX_RANDMMAP
7416 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7417 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7418 +#endif
7419 +
7420 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7421 mm->unmap_area = arch_unmap_area_topdown;
7422 }
7423 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7424 index e779642..e5bb889 100644
7425 --- a/arch/powerpc/mm/mmu_context_nohash.c
7426 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7427 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7428 return NOTIFY_OK;
7429 }
7430
7431 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7432 +static struct notifier_block mmu_context_cpu_nb = {
7433 .notifier_call = mmu_context_cpu_notify,
7434 };
7435
7436 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7437 index bba87ca..c346a33 100644
7438 --- a/arch/powerpc/mm/numa.c
7439 +++ b/arch/powerpc/mm/numa.c
7440 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7441 return ret;
7442 }
7443
7444 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7445 +static struct notifier_block ppc64_numa_nb = {
7446 .notifier_call = cpu_numa_callback,
7447 .priority = 1 /* Must run before sched domains notifier. */
7448 };
7449 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7450 index cf9dada..241529f 100644
7451 --- a/arch/powerpc/mm/slice.c
7452 +++ b/arch/powerpc/mm/slice.c
7453 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7454 if ((mm->task_size - len) < addr)
7455 return 0;
7456 vma = find_vma(mm, addr);
7457 - return (!vma || (addr + len) <= vma->vm_start);
7458 + return check_heap_stack_gap(vma, addr, len, 0);
7459 }
7460
7461 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7462 @@ -272,7 +272,7 @@ full_search:
7463 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7464 continue;
7465 }
7466 - if (!vma || addr + len <= vma->vm_start) {
7467 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7468 /*
7469 * Remember the place where we stopped the search:
7470 */
7471 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7472 }
7473 }
7474
7475 - addr = mm->mmap_base;
7476 - while (addr > len) {
7477 + if (mm->mmap_base < len)
7478 + addr = -ENOMEM;
7479 + else
7480 + addr = mm->mmap_base - len;
7481 +
7482 + while (!IS_ERR_VALUE(addr)) {
7483 /* Go down by chunk size */
7484 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7485 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7486
7487 /* Check for hit with different page size */
7488 mask = slice_range_to_mask(addr, len);
7489 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7490 * return with success:
7491 */
7492 vma = find_vma(mm, addr);
7493 - if (!vma || (addr + len) <= vma->vm_start) {
7494 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7495 /* remember the address as a hint for next time */
7496 if (use_cache)
7497 mm->free_area_cache = addr;
7498 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7499 mm->cached_hole_size = vma->vm_start - addr;
7500
7501 /* try just below the current vma->vm_start */
7502 - addr = vma->vm_start;
7503 + addr = skip_heap_stack_gap(vma, len, 0);
7504 }
7505
7506 /*
7507 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7508 if (fixed && addr > (mm->task_size - len))
7509 return -EINVAL;
7510
7511 +#ifdef CONFIG_PAX_RANDMMAP
7512 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7513 + addr = 0;
7514 +#endif
7515 +
7516 /* If hint, make sure it matches our alignment restrictions */
7517 if (!fixed && addr) {
7518 addr = _ALIGN_UP(addr, 1ul << pshift);
7519 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7520 index 0cfece4..2f1a0e5 100644
7521 --- a/arch/powerpc/platforms/cell/spufs/file.c
7522 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7523 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7524 return VM_FAULT_NOPAGE;
7525 }
7526
7527 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7528 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7529 unsigned long address,
7530 - void *buf, int len, int write)
7531 + void *buf, size_t len, int write)
7532 {
7533 struct spu_context *ctx = vma->vm_file->private_data;
7534 unsigned long offset = address - vma->vm_start;
7535 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7536 index bdb738a..49c9f95 100644
7537 --- a/arch/powerpc/platforms/powermac/smp.c
7538 +++ b/arch/powerpc/platforms/powermac/smp.c
7539 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7540 return NOTIFY_OK;
7541 }
7542
7543 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7544 +static struct notifier_block smp_core99_cpu_nb = {
7545 .notifier_call = smp_core99_cpu_notify,
7546 };
7547 #endif /* CONFIG_HOTPLUG_CPU */
7548 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7549 index c797832..ce575c8 100644
7550 --- a/arch/s390/include/asm/atomic.h
7551 +++ b/arch/s390/include/asm/atomic.h
7552 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7553 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7554 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7555
7556 +#define atomic64_read_unchecked(v) atomic64_read(v)
7557 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7558 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7559 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7560 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7561 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7562 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7563 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7564 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7565 +
7566 #define smp_mb__before_atomic_dec() smp_mb()
7567 #define smp_mb__after_atomic_dec() smp_mb()
7568 #define smp_mb__before_atomic_inc() smp_mb()
7569 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7570 index 4d7ccac..d03d0ad 100644
7571 --- a/arch/s390/include/asm/cache.h
7572 +++ b/arch/s390/include/asm/cache.h
7573 @@ -9,8 +9,10 @@
7574 #ifndef __ARCH_S390_CACHE_H
7575 #define __ARCH_S390_CACHE_H
7576
7577 -#define L1_CACHE_BYTES 256
7578 +#include <linux/const.h>
7579 +
7580 #define L1_CACHE_SHIFT 8
7581 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7582 #define NET_SKB_PAD 32
7583
7584 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7585 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7586 index 178ff96..8c93bd1 100644
7587 --- a/arch/s390/include/asm/elf.h
7588 +++ b/arch/s390/include/asm/elf.h
7589 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7590 the loader. We need to make sure that it is out of the way of the program
7591 that it will "exec", and that there is sufficient room for the brk. */
7592
7593 -extern unsigned long randomize_et_dyn(unsigned long base);
7594 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7595 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7596 +
7597 +#ifdef CONFIG_PAX_ASLR
7598 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7599 +
7600 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7601 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7602 +#endif
7603
7604 /* This yields a mask that user programs can use to figure out what
7605 instruction set this CPU supports. */
7606 @@ -210,9 +216,6 @@ struct linux_binprm;
7607 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7608 int arch_setup_additional_pages(struct linux_binprm *, int);
7609
7610 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7611 -#define arch_randomize_brk arch_randomize_brk
7612 -
7613 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7614
7615 #endif
7616 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7617 index c4a93d6..4d2a9b4 100644
7618 --- a/arch/s390/include/asm/exec.h
7619 +++ b/arch/s390/include/asm/exec.h
7620 @@ -7,6 +7,6 @@
7621 #ifndef __ASM_EXEC_H
7622 #define __ASM_EXEC_H
7623
7624 -extern unsigned long arch_align_stack(unsigned long sp);
7625 +#define arch_align_stack(x) ((x) & ~0xfUL)
7626
7627 #endif /* __ASM_EXEC_H */
7628 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7629 index 34268df..ea97318 100644
7630 --- a/arch/s390/include/asm/uaccess.h
7631 +++ b/arch/s390/include/asm/uaccess.h
7632 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7633 copy_to_user(void __user *to, const void *from, unsigned long n)
7634 {
7635 might_fault();
7636 +
7637 + if ((long)n < 0)
7638 + return n;
7639 +
7640 if (access_ok(VERIFY_WRITE, to, n))
7641 n = __copy_to_user(to, from, n);
7642 return n;
7643 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7644 static inline unsigned long __must_check
7645 __copy_from_user(void *to, const void __user *from, unsigned long n)
7646 {
7647 + if ((long)n < 0)
7648 + return n;
7649 +
7650 if (__builtin_constant_p(n) && (n <= 256))
7651 return uaccess.copy_from_user_small(n, from, to);
7652 else
7653 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7654 static inline unsigned long __must_check
7655 copy_from_user(void *to, const void __user *from, unsigned long n)
7656 {
7657 - unsigned int sz = __compiletime_object_size(to);
7658 + size_t sz = __compiletime_object_size(to);
7659
7660 might_fault();
7661 - if (unlikely(sz != -1 && sz < n)) {
7662 +
7663 + if ((long)n < 0)
7664 + return n;
7665 +
7666 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7667 copy_from_user_overflow();
7668 return n;
7669 }
7670 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7671 index 4610dea..cf0af21 100644
7672 --- a/arch/s390/kernel/module.c
7673 +++ b/arch/s390/kernel/module.c
7674 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7675
7676 /* Increase core size by size of got & plt and set start
7677 offsets for got and plt. */
7678 - me->core_size = ALIGN(me->core_size, 4);
7679 - me->arch.got_offset = me->core_size;
7680 - me->core_size += me->arch.got_size;
7681 - me->arch.plt_offset = me->core_size;
7682 - me->core_size += me->arch.plt_size;
7683 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7684 + me->arch.got_offset = me->core_size_rw;
7685 + me->core_size_rw += me->arch.got_size;
7686 + me->arch.plt_offset = me->core_size_rx;
7687 + me->core_size_rx += me->arch.plt_size;
7688 return 0;
7689 }
7690
7691 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7692 if (info->got_initialized == 0) {
7693 Elf_Addr *gotent;
7694
7695 - gotent = me->module_core + me->arch.got_offset +
7696 + gotent = me->module_core_rw + me->arch.got_offset +
7697 info->got_offset;
7698 *gotent = val;
7699 info->got_initialized = 1;
7700 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7701 else if (r_type == R_390_GOTENT ||
7702 r_type == R_390_GOTPLTENT)
7703 *(unsigned int *) loc =
7704 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7705 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7706 else if (r_type == R_390_GOT64 ||
7707 r_type == R_390_GOTPLT64)
7708 *(unsigned long *) loc = val;
7709 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7710 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7711 if (info->plt_initialized == 0) {
7712 unsigned int *ip;
7713 - ip = me->module_core + me->arch.plt_offset +
7714 + ip = me->module_core_rx + me->arch.plt_offset +
7715 info->plt_offset;
7716 #ifndef CONFIG_64BIT
7717 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7718 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7719 val - loc + 0xffffUL < 0x1ffffeUL) ||
7720 (r_type == R_390_PLT32DBL &&
7721 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7722 - val = (Elf_Addr) me->module_core +
7723 + val = (Elf_Addr) me->module_core_rx +
7724 me->arch.plt_offset +
7725 info->plt_offset;
7726 val += rela->r_addend - loc;
7727 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7728 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7729 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7730 val = val + rela->r_addend -
7731 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7732 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7733 if (r_type == R_390_GOTOFF16)
7734 *(unsigned short *) loc = val;
7735 else if (r_type == R_390_GOTOFF32)
7736 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7737 break;
7738 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7739 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7740 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7741 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7742 rela->r_addend - loc;
7743 if (r_type == R_390_GOTPC)
7744 *(unsigned int *) loc = val;
7745 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7746 index 536d645..4a5bd9e 100644
7747 --- a/arch/s390/kernel/process.c
7748 +++ b/arch/s390/kernel/process.c
7749 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7750 }
7751 return 0;
7752 }
7753 -
7754 -unsigned long arch_align_stack(unsigned long sp)
7755 -{
7756 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7757 - sp -= get_random_int() & ~PAGE_MASK;
7758 - return sp & ~0xf;
7759 -}
7760 -
7761 -static inline unsigned long brk_rnd(void)
7762 -{
7763 - /* 8MB for 32bit, 1GB for 64bit */
7764 - if (is_32bit_task())
7765 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7766 - else
7767 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7768 -}
7769 -
7770 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7771 -{
7772 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7773 -
7774 - if (ret < mm->brk)
7775 - return mm->brk;
7776 - return ret;
7777 -}
7778 -
7779 -unsigned long randomize_et_dyn(unsigned long base)
7780 -{
7781 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7782 -
7783 - if (!(current->flags & PF_RANDOMIZE))
7784 - return base;
7785 - if (ret < base)
7786 - return base;
7787 - return ret;
7788 -}
7789 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7790 index c59a5ef..3fae59c 100644
7791 --- a/arch/s390/mm/mmap.c
7792 +++ b/arch/s390/mm/mmap.c
7793 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7794 */
7795 if (mmap_is_legacy()) {
7796 mm->mmap_base = TASK_UNMAPPED_BASE;
7797 +
7798 +#ifdef CONFIG_PAX_RANDMMAP
7799 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7800 + mm->mmap_base += mm->delta_mmap;
7801 +#endif
7802 +
7803 mm->get_unmapped_area = arch_get_unmapped_area;
7804 mm->unmap_area = arch_unmap_area;
7805 } else {
7806 mm->mmap_base = mmap_base();
7807 +
7808 +#ifdef CONFIG_PAX_RANDMMAP
7809 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7810 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7811 +#endif
7812 +
7813 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7814 mm->unmap_area = arch_unmap_area_topdown;
7815 }
7816 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7817 */
7818 if (mmap_is_legacy()) {
7819 mm->mmap_base = TASK_UNMAPPED_BASE;
7820 +
7821 +#ifdef CONFIG_PAX_RANDMMAP
7822 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7823 + mm->mmap_base += mm->delta_mmap;
7824 +#endif
7825 +
7826 mm->get_unmapped_area = s390_get_unmapped_area;
7827 mm->unmap_area = arch_unmap_area;
7828 } else {
7829 mm->mmap_base = mmap_base();
7830 +
7831 +#ifdef CONFIG_PAX_RANDMMAP
7832 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7833 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7834 +#endif
7835 +
7836 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7837 mm->unmap_area = arch_unmap_area_topdown;
7838 }
7839 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7840 index ae3d59f..f65f075 100644
7841 --- a/arch/score/include/asm/cache.h
7842 +++ b/arch/score/include/asm/cache.h
7843 @@ -1,7 +1,9 @@
7844 #ifndef _ASM_SCORE_CACHE_H
7845 #define _ASM_SCORE_CACHE_H
7846
7847 +#include <linux/const.h>
7848 +
7849 #define L1_CACHE_SHIFT 4
7850 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7851 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7852
7853 #endif /* _ASM_SCORE_CACHE_H */
7854 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7855 index f9f3cd5..58ff438 100644
7856 --- a/arch/score/include/asm/exec.h
7857 +++ b/arch/score/include/asm/exec.h
7858 @@ -1,6 +1,6 @@
7859 #ifndef _ASM_SCORE_EXEC_H
7860 #define _ASM_SCORE_EXEC_H
7861
7862 -extern unsigned long arch_align_stack(unsigned long sp);
7863 +#define arch_align_stack(x) (x)
7864
7865 #endif /* _ASM_SCORE_EXEC_H */
7866 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7867 index 7956846..5f37677 100644
7868 --- a/arch/score/kernel/process.c
7869 +++ b/arch/score/kernel/process.c
7870 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7871
7872 return task_pt_regs(task)->cp0_epc;
7873 }
7874 -
7875 -unsigned long arch_align_stack(unsigned long sp)
7876 -{
7877 - return sp;
7878 -}
7879 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7880 index ef9e555..331bd29 100644
7881 --- a/arch/sh/include/asm/cache.h
7882 +++ b/arch/sh/include/asm/cache.h
7883 @@ -9,10 +9,11 @@
7884 #define __ASM_SH_CACHE_H
7885 #ifdef __KERNEL__
7886
7887 +#include <linux/const.h>
7888 #include <linux/init.h>
7889 #include <cpu/cache.h>
7890
7891 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7892 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7893
7894 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7895
7896 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7897 index 03f2b55..b027032 100644
7898 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7899 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7900 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7901 return NOTIFY_OK;
7902 }
7903
7904 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7905 +static struct notifier_block shx3_cpu_notifier = {
7906 .notifier_call = shx3_cpu_callback,
7907 };
7908
7909 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7910 index 6777177..cb5e44f 100644
7911 --- a/arch/sh/mm/mmap.c
7912 +++ b/arch/sh/mm/mmap.c
7913 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7914 struct mm_struct *mm = current->mm;
7915 struct vm_area_struct *vma;
7916 int do_colour_align;
7917 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7918 struct vm_unmapped_area_info info;
7919
7920 if (flags & MAP_FIXED) {
7921 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7922 if (filp || (flags & MAP_SHARED))
7923 do_colour_align = 1;
7924
7925 +#ifdef CONFIG_PAX_RANDMMAP
7926 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7927 +#endif
7928 +
7929 if (addr) {
7930 if (do_colour_align)
7931 addr = COLOUR_ALIGN(addr, pgoff);
7932 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7933 addr = PAGE_ALIGN(addr);
7934
7935 vma = find_vma(mm, addr);
7936 - if (TASK_SIZE - len >= addr &&
7937 - (!vma || addr + len <= vma->vm_start))
7938 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7939 return addr;
7940 }
7941
7942 info.flags = 0;
7943 info.length = len;
7944 - info.low_limit = TASK_UNMAPPED_BASE;
7945 + info.low_limit = mm->mmap_base;
7946 info.high_limit = TASK_SIZE;
7947 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7948 info.align_offset = pgoff << PAGE_SHIFT;
7949 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7950 struct mm_struct *mm = current->mm;
7951 unsigned long addr = addr0;
7952 int do_colour_align;
7953 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7954 struct vm_unmapped_area_info info;
7955
7956 if (flags & MAP_FIXED) {
7957 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7958 if (filp || (flags & MAP_SHARED))
7959 do_colour_align = 1;
7960
7961 +#ifdef CONFIG_PAX_RANDMMAP
7962 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7963 +#endif
7964 +
7965 /* requesting a specific address */
7966 if (addr) {
7967 if (do_colour_align)
7968 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7969 addr = PAGE_ALIGN(addr);
7970
7971 vma = find_vma(mm, addr);
7972 - if (TASK_SIZE - len >= addr &&
7973 - (!vma || addr + len <= vma->vm_start))
7974 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7975 return addr;
7976 }
7977
7978 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7979 VM_BUG_ON(addr != -ENOMEM);
7980 info.flags = 0;
7981 info.low_limit = TASK_UNMAPPED_BASE;
7982 +
7983 +#ifdef CONFIG_PAX_RANDMMAP
7984 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7985 + info.low_limit += mm->delta_mmap;
7986 +#endif
7987 +
7988 info.high_limit = TASK_SIZE;
7989 addr = vm_unmapped_area(&info);
7990 }
7991 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7992 index be56a24..443328f 100644
7993 --- a/arch/sparc/include/asm/atomic_64.h
7994 +++ b/arch/sparc/include/asm/atomic_64.h
7995 @@ -14,18 +14,40 @@
7996 #define ATOMIC64_INIT(i) { (i) }
7997
7998 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7999 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8000 +{
8001 + return v->counter;
8002 +}
8003 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8004 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8005 +{
8006 + return v->counter;
8007 +}
8008
8009 #define atomic_set(v, i) (((v)->counter) = i)
8010 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8011 +{
8012 + v->counter = i;
8013 +}
8014 #define atomic64_set(v, i) (((v)->counter) = i)
8015 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8016 +{
8017 + v->counter = i;
8018 +}
8019
8020 extern void atomic_add(int, atomic_t *);
8021 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8022 extern void atomic64_add(long, atomic64_t *);
8023 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8024 extern void atomic_sub(int, atomic_t *);
8025 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8026 extern void atomic64_sub(long, atomic64_t *);
8027 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8028
8029 extern int atomic_add_ret(int, atomic_t *);
8030 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8031 extern long atomic64_add_ret(long, atomic64_t *);
8032 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8033 extern int atomic_sub_ret(int, atomic_t *);
8034 extern long atomic64_sub_ret(long, atomic64_t *);
8035
8036 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8037 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8038
8039 #define atomic_inc_return(v) atomic_add_ret(1, v)
8040 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8041 +{
8042 + return atomic_add_ret_unchecked(1, v);
8043 +}
8044 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8045 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8046 +{
8047 + return atomic64_add_ret_unchecked(1, v);
8048 +}
8049
8050 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8051 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8052
8053 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8054 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8055 +{
8056 + return atomic_add_ret_unchecked(i, v);
8057 +}
8058 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8059 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8060 +{
8061 + return atomic64_add_ret_unchecked(i, v);
8062 +}
8063
8064 /*
8065 * atomic_inc_and_test - increment and test
8066 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8067 * other cases.
8068 */
8069 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8070 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8071 +{
8072 + return atomic_inc_return_unchecked(v) == 0;
8073 +}
8074 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8075
8076 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8077 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8078 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8079
8080 #define atomic_inc(v) atomic_add(1, v)
8081 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8082 +{
8083 + atomic_add_unchecked(1, v);
8084 +}
8085 #define atomic64_inc(v) atomic64_add(1, v)
8086 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8087 +{
8088 + atomic64_add_unchecked(1, v);
8089 +}
8090
8091 #define atomic_dec(v) atomic_sub(1, v)
8092 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8093 +{
8094 + atomic_sub_unchecked(1, v);
8095 +}
8096 #define atomic64_dec(v) atomic64_sub(1, v)
8097 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8098 +{
8099 + atomic64_sub_unchecked(1, v);
8100 +}
8101
8102 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8103 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8104
8105 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8106 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8107 +{
8108 + return cmpxchg(&v->counter, old, new);
8109 +}
8110 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8111 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8112 +{
8113 + return xchg(&v->counter, new);
8114 +}
8115
8116 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8117 {
8118 - int c, old;
8119 + int c, old, new;
8120 c = atomic_read(v);
8121 for (;;) {
8122 - if (unlikely(c == (u)))
8123 + if (unlikely(c == u))
8124 break;
8125 - old = atomic_cmpxchg((v), c, c + (a));
8126 +
8127 + asm volatile("addcc %2, %0, %0\n"
8128 +
8129 +#ifdef CONFIG_PAX_REFCOUNT
8130 + "tvs %%icc, 6\n"
8131 +#endif
8132 +
8133 + : "=r" (new)
8134 + : "0" (c), "ir" (a)
8135 + : "cc");
8136 +
8137 + old = atomic_cmpxchg(v, c, new);
8138 if (likely(old == c))
8139 break;
8140 c = old;
8141 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8142 #define atomic64_cmpxchg(v, o, n) \
8143 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8144 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8145 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8146 +{
8147 + return xchg(&v->counter, new);
8148 +}
8149
8150 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8151 {
8152 - long c, old;
8153 + long c, old, new;
8154 c = atomic64_read(v);
8155 for (;;) {
8156 - if (unlikely(c == (u)))
8157 + if (unlikely(c == u))
8158 break;
8159 - old = atomic64_cmpxchg((v), c, c + (a));
8160 +
8161 + asm volatile("addcc %2, %0, %0\n"
8162 +
8163 +#ifdef CONFIG_PAX_REFCOUNT
8164 + "tvs %%xcc, 6\n"
8165 +#endif
8166 +
8167 + : "=r" (new)
8168 + : "0" (c), "ir" (a)
8169 + : "cc");
8170 +
8171 + old = atomic64_cmpxchg(v, c, new);
8172 if (likely(old == c))
8173 break;
8174 c = old;
8175 }
8176 - return c != (u);
8177 + return c != u;
8178 }
8179
8180 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8181 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8182 index 5bb6991..5c2132e 100644
8183 --- a/arch/sparc/include/asm/cache.h
8184 +++ b/arch/sparc/include/asm/cache.h
8185 @@ -7,10 +7,12 @@
8186 #ifndef _SPARC_CACHE_H
8187 #define _SPARC_CACHE_H
8188
8189 +#include <linux/const.h>
8190 +
8191 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8192
8193 #define L1_CACHE_SHIFT 5
8194 -#define L1_CACHE_BYTES 32
8195 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8196
8197 #ifdef CONFIG_SPARC32
8198 #define SMP_CACHE_BYTES_SHIFT 5
8199 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8200 index ac74a2c..a9e58af 100644
8201 --- a/arch/sparc/include/asm/elf_32.h
8202 +++ b/arch/sparc/include/asm/elf_32.h
8203 @@ -114,6 +114,13 @@ typedef struct {
8204
8205 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8206
8207 +#ifdef CONFIG_PAX_ASLR
8208 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8209 +
8210 +#define PAX_DELTA_MMAP_LEN 16
8211 +#define PAX_DELTA_STACK_LEN 16
8212 +#endif
8213 +
8214 /* This yields a mask that user programs can use to figure out what
8215 instruction set this cpu supports. This can NOT be done in userspace
8216 on Sparc. */
8217 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
8218 index 370ca1e..d4f4a98 100644
8219 --- a/arch/sparc/include/asm/elf_64.h
8220 +++ b/arch/sparc/include/asm/elf_64.h
8221 @@ -189,6 +189,13 @@ typedef struct {
8222 #define ELF_ET_DYN_BASE 0x0000010000000000UL
8223 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
8224
8225 +#ifdef CONFIG_PAX_ASLR
8226 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
8227 +
8228 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
8229 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
8230 +#endif
8231 +
8232 extern unsigned long sparc64_elf_hwcap;
8233 #define ELF_HWCAP sparc64_elf_hwcap
8234
8235 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
8236 index 9b1c36d..209298b 100644
8237 --- a/arch/sparc/include/asm/pgalloc_32.h
8238 +++ b/arch/sparc/include/asm/pgalloc_32.h
8239 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
8240 }
8241
8242 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
8243 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
8244
8245 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
8246 unsigned long address)
8247 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
8248 index bcfe063..b333142 100644
8249 --- a/arch/sparc/include/asm/pgalloc_64.h
8250 +++ b/arch/sparc/include/asm/pgalloc_64.h
8251 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8252 }
8253
8254 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
8255 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
8256
8257 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
8258 {
8259 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
8260 index 6fc1348..390c50a 100644
8261 --- a/arch/sparc/include/asm/pgtable_32.h
8262 +++ b/arch/sparc/include/asm/pgtable_32.h
8263 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
8264 #define PAGE_SHARED SRMMU_PAGE_SHARED
8265 #define PAGE_COPY SRMMU_PAGE_COPY
8266 #define PAGE_READONLY SRMMU_PAGE_RDONLY
8267 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
8268 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
8269 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
8270 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
8271
8272 /* Top-level page directory - dummy used by init-mm.
8273 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
8274
8275 /* xwr */
8276 #define __P000 PAGE_NONE
8277 -#define __P001 PAGE_READONLY
8278 -#define __P010 PAGE_COPY
8279 -#define __P011 PAGE_COPY
8280 +#define __P001 PAGE_READONLY_NOEXEC
8281 +#define __P010 PAGE_COPY_NOEXEC
8282 +#define __P011 PAGE_COPY_NOEXEC
8283 #define __P100 PAGE_READONLY
8284 #define __P101 PAGE_READONLY
8285 #define __P110 PAGE_COPY
8286 #define __P111 PAGE_COPY
8287
8288 #define __S000 PAGE_NONE
8289 -#define __S001 PAGE_READONLY
8290 -#define __S010 PAGE_SHARED
8291 -#define __S011 PAGE_SHARED
8292 +#define __S001 PAGE_READONLY_NOEXEC
8293 +#define __S010 PAGE_SHARED_NOEXEC
8294 +#define __S011 PAGE_SHARED_NOEXEC
8295 #define __S100 PAGE_READONLY
8296 #define __S101 PAGE_READONLY
8297 #define __S110 PAGE_SHARED
8298 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
8299 index 79da178..c2eede8 100644
8300 --- a/arch/sparc/include/asm/pgtsrmmu.h
8301 +++ b/arch/sparc/include/asm/pgtsrmmu.h
8302 @@ -115,6 +115,11 @@
8303 SRMMU_EXEC | SRMMU_REF)
8304 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
8305 SRMMU_EXEC | SRMMU_REF)
8306 +
8307 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8308 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8309 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8310 +
8311 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8312 SRMMU_DIRTY | SRMMU_REF)
8313
8314 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8315 index 9689176..63c18ea 100644
8316 --- a/arch/sparc/include/asm/spinlock_64.h
8317 +++ b/arch/sparc/include/asm/spinlock_64.h
8318 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8319
8320 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8321
8322 -static void inline arch_read_lock(arch_rwlock_t *lock)
8323 +static inline void arch_read_lock(arch_rwlock_t *lock)
8324 {
8325 unsigned long tmp1, tmp2;
8326
8327 __asm__ __volatile__ (
8328 "1: ldsw [%2], %0\n"
8329 " brlz,pn %0, 2f\n"
8330 -"4: add %0, 1, %1\n"
8331 +"4: addcc %0, 1, %1\n"
8332 +
8333 +#ifdef CONFIG_PAX_REFCOUNT
8334 +" tvs %%icc, 6\n"
8335 +#endif
8336 +
8337 " cas [%2], %0, %1\n"
8338 " cmp %0, %1\n"
8339 " bne,pn %%icc, 1b\n"
8340 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8341 " .previous"
8342 : "=&r" (tmp1), "=&r" (tmp2)
8343 : "r" (lock)
8344 - : "memory");
8345 + : "memory", "cc");
8346 }
8347
8348 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8349 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8350 {
8351 int tmp1, tmp2;
8352
8353 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8354 "1: ldsw [%2], %0\n"
8355 " brlz,a,pn %0, 2f\n"
8356 " mov 0, %0\n"
8357 -" add %0, 1, %1\n"
8358 +" addcc %0, 1, %1\n"
8359 +
8360 +#ifdef CONFIG_PAX_REFCOUNT
8361 +" tvs %%icc, 6\n"
8362 +#endif
8363 +
8364 " cas [%2], %0, %1\n"
8365 " cmp %0, %1\n"
8366 " bne,pn %%icc, 1b\n"
8367 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8368 return tmp1;
8369 }
8370
8371 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8372 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8373 {
8374 unsigned long tmp1, tmp2;
8375
8376 __asm__ __volatile__(
8377 "1: lduw [%2], %0\n"
8378 -" sub %0, 1, %1\n"
8379 +" subcc %0, 1, %1\n"
8380 +
8381 +#ifdef CONFIG_PAX_REFCOUNT
8382 +" tvs %%icc, 6\n"
8383 +#endif
8384 +
8385 " cas [%2], %0, %1\n"
8386 " cmp %0, %1\n"
8387 " bne,pn %%xcc, 1b\n"
8388 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8389 : "memory");
8390 }
8391
8392 -static void inline arch_write_lock(arch_rwlock_t *lock)
8393 +static inline void arch_write_lock(arch_rwlock_t *lock)
8394 {
8395 unsigned long mask, tmp1, tmp2;
8396
8397 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8398 : "memory");
8399 }
8400
8401 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8402 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8403 {
8404 __asm__ __volatile__(
8405 " stw %%g0, [%0]"
8406 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8407 : "memory");
8408 }
8409
8410 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8411 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8412 {
8413 unsigned long mask, tmp1, tmp2, result;
8414
8415 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8416 index 25849ae..924c54b 100644
8417 --- a/arch/sparc/include/asm/thread_info_32.h
8418 +++ b/arch/sparc/include/asm/thread_info_32.h
8419 @@ -49,6 +49,8 @@ struct thread_info {
8420 unsigned long w_saved;
8421
8422 struct restart_block restart_block;
8423 +
8424 + unsigned long lowest_stack;
8425 };
8426
8427 /*
8428 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8429 index 269bd92..e46a9b8 100644
8430 --- a/arch/sparc/include/asm/thread_info_64.h
8431 +++ b/arch/sparc/include/asm/thread_info_64.h
8432 @@ -63,6 +63,8 @@ struct thread_info {
8433 struct pt_regs *kern_una_regs;
8434 unsigned int kern_una_insn;
8435
8436 + unsigned long lowest_stack;
8437 +
8438 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8439 };
8440
8441 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8442 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8443 /* flag bit 6 is available */
8444 #define TIF_32BIT 7 /* 32-bit binary */
8445 -/* flag bit 8 is available */
8446 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8447 #define TIF_SECCOMP 9 /* secure computing */
8448 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8449 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8450 +
8451 /* NOTE: Thread flags >= 12 should be ones we have no interest
8452 * in using in assembly, else we can't use the mask as
8453 * an immediate value in instructions such as andcc.
8454 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8455 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8456 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8457 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8458 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8459
8460 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8461 _TIF_DO_NOTIFY_RESUME_MASK | \
8462 _TIF_NEED_RESCHED)
8463 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8464
8465 +#define _TIF_WORK_SYSCALL \
8466 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8467 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8468 +
8469 +
8470 /*
8471 * Thread-synchronous status.
8472 *
8473 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8474 index 0167d26..767bb0c 100644
8475 --- a/arch/sparc/include/asm/uaccess.h
8476 +++ b/arch/sparc/include/asm/uaccess.h
8477 @@ -1,5 +1,6 @@
8478 #ifndef ___ASM_SPARC_UACCESS_H
8479 #define ___ASM_SPARC_UACCESS_H
8480 +
8481 #if defined(__sparc__) && defined(__arch64__)
8482 #include <asm/uaccess_64.h>
8483 #else
8484 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8485 index 53a28dd..50c38c3 100644
8486 --- a/arch/sparc/include/asm/uaccess_32.h
8487 +++ b/arch/sparc/include/asm/uaccess_32.h
8488 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8489
8490 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8491 {
8492 - if (n && __access_ok((unsigned long) to, n))
8493 + if ((long)n < 0)
8494 + return n;
8495 +
8496 + if (n && __access_ok((unsigned long) to, n)) {
8497 + if (!__builtin_constant_p(n))
8498 + check_object_size(from, n, true);
8499 return __copy_user(to, (__force void __user *) from, n);
8500 - else
8501 + } else
8502 return n;
8503 }
8504
8505 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8506 {
8507 + if ((long)n < 0)
8508 + return n;
8509 +
8510 + if (!__builtin_constant_p(n))
8511 + check_object_size(from, n, true);
8512 +
8513 return __copy_user(to, (__force void __user *) from, n);
8514 }
8515
8516 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8517 {
8518 - if (n && __access_ok((unsigned long) from, n))
8519 + if ((long)n < 0)
8520 + return n;
8521 +
8522 + if (n && __access_ok((unsigned long) from, n)) {
8523 + if (!__builtin_constant_p(n))
8524 + check_object_size(to, n, false);
8525 return __copy_user((__force void __user *) to, from, n);
8526 - else
8527 + } else
8528 return n;
8529 }
8530
8531 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8532 {
8533 + if ((long)n < 0)
8534 + return n;
8535 +
8536 return __copy_user((__force void __user *) to, from, n);
8537 }
8538
8539 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8540 index e562d3c..191f176 100644
8541 --- a/arch/sparc/include/asm/uaccess_64.h
8542 +++ b/arch/sparc/include/asm/uaccess_64.h
8543 @@ -10,6 +10,7 @@
8544 #include <linux/compiler.h>
8545 #include <linux/string.h>
8546 #include <linux/thread_info.h>
8547 +#include <linux/kernel.h>
8548 #include <asm/asi.h>
8549 #include <asm/spitfire.h>
8550 #include <asm-generic/uaccess-unaligned.h>
8551 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8552 static inline unsigned long __must_check
8553 copy_from_user(void *to, const void __user *from, unsigned long size)
8554 {
8555 - unsigned long ret = ___copy_from_user(to, from, size);
8556 + unsigned long ret;
8557
8558 + if ((long)size < 0 || size > INT_MAX)
8559 + return size;
8560 +
8561 + if (!__builtin_constant_p(size))
8562 + check_object_size(to, size, false);
8563 +
8564 + ret = ___copy_from_user(to, from, size);
8565 if (unlikely(ret))
8566 ret = copy_from_user_fixup(to, from, size);
8567
8568 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8569 static inline unsigned long __must_check
8570 copy_to_user(void __user *to, const void *from, unsigned long size)
8571 {
8572 - unsigned long ret = ___copy_to_user(to, from, size);
8573 + unsigned long ret;
8574
8575 + if ((long)size < 0 || size > INT_MAX)
8576 + return size;
8577 +
8578 + if (!__builtin_constant_p(size))
8579 + check_object_size(from, size, true);
8580 +
8581 + ret = ___copy_to_user(to, from, size);
8582 if (unlikely(ret))
8583 ret = copy_to_user_fixup(to, from, size);
8584 return ret;
8585 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8586 index 6cf591b..b49e65a 100644
8587 --- a/arch/sparc/kernel/Makefile
8588 +++ b/arch/sparc/kernel/Makefile
8589 @@ -3,7 +3,7 @@
8590 #
8591
8592 asflags-y := -ansi
8593 -ccflags-y := -Werror
8594 +#ccflags-y := -Werror
8595
8596 extra-y := head_$(BITS).o
8597
8598 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8599 index be8e862..5b50b12 100644
8600 --- a/arch/sparc/kernel/process_32.c
8601 +++ b/arch/sparc/kernel/process_32.c
8602 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8603
8604 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8605 r->psr, r->pc, r->npc, r->y, print_tainted());
8606 - printk("PC: <%pS>\n", (void *) r->pc);
8607 + printk("PC: <%pA>\n", (void *) r->pc);
8608 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8609 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8610 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8611 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8612 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8613 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8614 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8615 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8616
8617 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8618 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8619 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8620 rw = (struct reg_window32 *) fp;
8621 pc = rw->ins[7];
8622 printk("[%08lx : ", pc);
8623 - printk("%pS ] ", (void *) pc);
8624 + printk("%pA ] ", (void *) pc);
8625 fp = rw->ins[6];
8626 } while (++count < 16);
8627 printk("\n");
8628 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8629 index cdb80b2..5ca141d 100644
8630 --- a/arch/sparc/kernel/process_64.c
8631 +++ b/arch/sparc/kernel/process_64.c
8632 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8633 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8634 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8635 if (regs->tstate & TSTATE_PRIV)
8636 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8637 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8638 }
8639
8640 void show_regs(struct pt_regs *regs)
8641 {
8642 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8643 regs->tpc, regs->tnpc, regs->y, print_tainted());
8644 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8645 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8646 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8647 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8648 regs->u_regs[3]);
8649 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8650 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8651 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8652 regs->u_regs[15]);
8653 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8654 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8655 show_regwindow(regs);
8656 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8657 }
8658 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8659 ((tp && tp->task) ? tp->task->pid : -1));
8660
8661 if (gp->tstate & TSTATE_PRIV) {
8662 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8663 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8664 (void *) gp->tpc,
8665 (void *) gp->o7,
8666 (void *) gp->i7,
8667 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8668 index 1303021..c2a6321 100644
8669 --- a/arch/sparc/kernel/prom_common.c
8670 +++ b/arch/sparc/kernel/prom_common.c
8671 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8672
8673 unsigned int prom_early_allocated __initdata;
8674
8675 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8676 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8677 .nextprop = prom_common_nextprop,
8678 .getproplen = prom_getproplen,
8679 .getproperty = prom_getproperty,
8680 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8681 index 7ff45e4..a58f271 100644
8682 --- a/arch/sparc/kernel/ptrace_64.c
8683 +++ b/arch/sparc/kernel/ptrace_64.c
8684 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8685 return ret;
8686 }
8687
8688 +#ifdef CONFIG_GRKERNSEC_SETXID
8689 +extern void gr_delayed_cred_worker(void);
8690 +#endif
8691 +
8692 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8693 {
8694 int ret = 0;
8695 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8696 /* do the secure computing check first */
8697 secure_computing_strict(regs->u_regs[UREG_G1]);
8698
8699 +#ifdef CONFIG_GRKERNSEC_SETXID
8700 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8701 + gr_delayed_cred_worker();
8702 +#endif
8703 +
8704 if (test_thread_flag(TIF_SYSCALL_TRACE))
8705 ret = tracehook_report_syscall_entry(regs);
8706
8707 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8708
8709 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8710 {
8711 +#ifdef CONFIG_GRKERNSEC_SETXID
8712 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8713 + gr_delayed_cred_worker();
8714 +#endif
8715 +
8716 audit_syscall_exit(regs);
8717
8718 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8719 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8720 index 2da0bdc..79128d2 100644
8721 --- a/arch/sparc/kernel/sys_sparc_32.c
8722 +++ b/arch/sparc/kernel/sys_sparc_32.c
8723 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8724 if (len > TASK_SIZE - PAGE_SIZE)
8725 return -ENOMEM;
8726 if (!addr)
8727 - addr = TASK_UNMAPPED_BASE;
8728 + addr = current->mm->mmap_base;
8729
8730 info.flags = 0;
8731 info.length = len;
8732 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8733 index 708bc29..f0129cb 100644
8734 --- a/arch/sparc/kernel/sys_sparc_64.c
8735 +++ b/arch/sparc/kernel/sys_sparc_64.c
8736 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8737 struct vm_area_struct * vma;
8738 unsigned long task_size = TASK_SIZE;
8739 int do_color_align;
8740 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8741 struct vm_unmapped_area_info info;
8742
8743 if (flags & MAP_FIXED) {
8744 /* We do not accept a shared mapping if it would violate
8745 * cache aliasing constraints.
8746 */
8747 - if ((flags & MAP_SHARED) &&
8748 + if ((filp || (flags & MAP_SHARED)) &&
8749 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8750 return -EINVAL;
8751 return addr;
8752 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8753 if (filp || (flags & MAP_SHARED))
8754 do_color_align = 1;
8755
8756 +#ifdef CONFIG_PAX_RANDMMAP
8757 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8758 +#endif
8759 +
8760 if (addr) {
8761 if (do_color_align)
8762 addr = COLOR_ALIGN(addr, pgoff);
8763 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8764 addr = PAGE_ALIGN(addr);
8765
8766 vma = find_vma(mm, addr);
8767 - if (task_size - len >= addr &&
8768 - (!vma || addr + len <= vma->vm_start))
8769 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8770 return addr;
8771 }
8772
8773 info.flags = 0;
8774 info.length = len;
8775 - info.low_limit = TASK_UNMAPPED_BASE;
8776 + info.low_limit = mm->mmap_base;
8777 info.high_limit = min(task_size, VA_EXCLUDE_START);
8778 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8779 info.align_offset = pgoff << PAGE_SHIFT;
8780 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8781 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8782 VM_BUG_ON(addr != -ENOMEM);
8783 info.low_limit = VA_EXCLUDE_END;
8784 +
8785 +#ifdef CONFIG_PAX_RANDMMAP
8786 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8787 + info.low_limit += mm->delta_mmap;
8788 +#endif
8789 +
8790 info.high_limit = task_size;
8791 addr = vm_unmapped_area(&info);
8792 }
8793 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8794 unsigned long task_size = STACK_TOP32;
8795 unsigned long addr = addr0;
8796 int do_color_align;
8797 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8798 struct vm_unmapped_area_info info;
8799
8800 /* This should only ever run for 32-bit processes. */
8801 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8802 /* We do not accept a shared mapping if it would violate
8803 * cache aliasing constraints.
8804 */
8805 - if ((flags & MAP_SHARED) &&
8806 + if ((filp || (flags & MAP_SHARED)) &&
8807 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8808 return -EINVAL;
8809 return addr;
8810 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8811 if (filp || (flags & MAP_SHARED))
8812 do_color_align = 1;
8813
8814 +#ifdef CONFIG_PAX_RANDMMAP
8815 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8816 +#endif
8817 +
8818 /* requesting a specific address */
8819 if (addr) {
8820 if (do_color_align)
8821 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8822 addr = PAGE_ALIGN(addr);
8823
8824 vma = find_vma(mm, addr);
8825 - if (task_size - len >= addr &&
8826 - (!vma || addr + len <= vma->vm_start))
8827 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8828 return addr;
8829 }
8830
8831 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8832 VM_BUG_ON(addr != -ENOMEM);
8833 info.flags = 0;
8834 info.low_limit = TASK_UNMAPPED_BASE;
8835 +
8836 +#ifdef CONFIG_PAX_RANDMMAP
8837 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8838 + info.low_limit += mm->delta_mmap;
8839 +#endif
8840 +
8841 info.high_limit = STACK_TOP32;
8842 addr = vm_unmapped_area(&info);
8843 }
8844 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
8845 {
8846 unsigned long rnd = 0UL;
8847
8848 +#ifdef CONFIG_PAX_RANDMMAP
8849 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8850 +#endif
8851 +
8852 if (current->flags & PF_RANDOMIZE) {
8853 unsigned long val = get_random_int();
8854 if (test_thread_flag(TIF_32BIT))
8855 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8856 gap == RLIM_INFINITY ||
8857 sysctl_legacy_va_layout) {
8858 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8859 +
8860 +#ifdef CONFIG_PAX_RANDMMAP
8861 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8862 + mm->mmap_base += mm->delta_mmap;
8863 +#endif
8864 +
8865 mm->get_unmapped_area = arch_get_unmapped_area;
8866 mm->unmap_area = arch_unmap_area;
8867 } else {
8868 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8869 gap = (task_size / 6 * 5);
8870
8871 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8872 +
8873 +#ifdef CONFIG_PAX_RANDMMAP
8874 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8875 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8876 +#endif
8877 +
8878 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8879 mm->unmap_area = arch_unmap_area_topdown;
8880 }
8881 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8882 index e0fed77..604a7e5 100644
8883 --- a/arch/sparc/kernel/syscalls.S
8884 +++ b/arch/sparc/kernel/syscalls.S
8885 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
8886 #endif
8887 .align 32
8888 1: ldx [%g6 + TI_FLAGS], %l5
8889 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8890 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8891 be,pt %icc, rtrap
8892 nop
8893 call syscall_trace_leave
8894 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
8895
8896 srl %i5, 0, %o5 ! IEU1
8897 srl %i2, 0, %o2 ! IEU0 Group
8898 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8899 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8900 bne,pn %icc, linux_syscall_trace32 ! CTI
8901 mov %i0, %l5 ! IEU1
8902 call %l7 ! CTI Group brk forced
8903 @@ -213,7 +213,7 @@ linux_sparc_syscall:
8904
8905 mov %i3, %o3 ! IEU1
8906 mov %i4, %o4 ! IEU0 Group
8907 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8908 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8909 bne,pn %icc, linux_syscall_trace ! CTI Group
8910 mov %i0, %l5 ! IEU0
8911 2: call %l7 ! CTI Group brk forced
8912 @@ -229,7 +229,7 @@ ret_sys_call:
8913
8914 cmp %o0, -ERESTART_RESTARTBLOCK
8915 bgeu,pn %xcc, 1f
8916 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8917 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8918 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8919
8920 2:
8921 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8922 index 654e8aa..45f431b 100644
8923 --- a/arch/sparc/kernel/sysfs.c
8924 +++ b/arch/sparc/kernel/sysfs.c
8925 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8926 return NOTIFY_OK;
8927 }
8928
8929 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8930 +static struct notifier_block sysfs_cpu_nb = {
8931 .notifier_call = sysfs_cpu_notify,
8932 };
8933
8934 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8935 index a5785ea..405c5f7 100644
8936 --- a/arch/sparc/kernel/traps_32.c
8937 +++ b/arch/sparc/kernel/traps_32.c
8938 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8939 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8940 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8941
8942 +extern void gr_handle_kernel_exploit(void);
8943 +
8944 void die_if_kernel(char *str, struct pt_regs *regs)
8945 {
8946 static int die_counter;
8947 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8948 count++ < 30 &&
8949 (((unsigned long) rw) >= PAGE_OFFSET) &&
8950 !(((unsigned long) rw) & 0x7)) {
8951 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8952 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8953 (void *) rw->ins[7]);
8954 rw = (struct reg_window32 *)rw->ins[6];
8955 }
8956 }
8957 printk("Instruction DUMP:");
8958 instruction_dump ((unsigned long *) regs->pc);
8959 - if(regs->psr & PSR_PS)
8960 + if(regs->psr & PSR_PS) {
8961 + gr_handle_kernel_exploit();
8962 do_exit(SIGKILL);
8963 + }
8964 do_exit(SIGSEGV);
8965 }
8966
8967 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8968 index e7ecf15..6520e65 100644
8969 --- a/arch/sparc/kernel/traps_64.c
8970 +++ b/arch/sparc/kernel/traps_64.c
8971 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8972 i + 1,
8973 p->trapstack[i].tstate, p->trapstack[i].tpc,
8974 p->trapstack[i].tnpc, p->trapstack[i].tt);
8975 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8976 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8977 }
8978 }
8979
8980 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8981
8982 lvl -= 0x100;
8983 if (regs->tstate & TSTATE_PRIV) {
8984 +
8985 +#ifdef CONFIG_PAX_REFCOUNT
8986 + if (lvl == 6)
8987 + pax_report_refcount_overflow(regs);
8988 +#endif
8989 +
8990 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8991 die_if_kernel(buffer, regs);
8992 }
8993 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8994 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8995 {
8996 char buffer[32];
8997 -
8998 +
8999 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9000 0, lvl, SIGTRAP) == NOTIFY_STOP)
9001 return;
9002
9003 +#ifdef CONFIG_PAX_REFCOUNT
9004 + if (lvl == 6)
9005 + pax_report_refcount_overflow(regs);
9006 +#endif
9007 +
9008 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9009
9010 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9011 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9012 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9013 printk("%s" "ERROR(%d): ",
9014 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9015 - printk("TPC<%pS>\n", (void *) regs->tpc);
9016 + printk("TPC<%pA>\n", (void *) regs->tpc);
9017 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9018 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9019 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9020 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9021 smp_processor_id(),
9022 (type & 0x1) ? 'I' : 'D',
9023 regs->tpc);
9024 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9025 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9026 panic("Irrecoverable Cheetah+ parity error.");
9027 }
9028
9029 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9030 smp_processor_id(),
9031 (type & 0x1) ? 'I' : 'D',
9032 regs->tpc);
9033 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9034 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9035 }
9036
9037 struct sun4v_error_entry {
9038 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
9039
9040 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
9041 regs->tpc, tl);
9042 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
9043 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
9044 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9045 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
9046 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
9047 (void *) regs->u_regs[UREG_I7]);
9048 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
9049 "pte[%lx] error[%lx]\n",
9050 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
9051
9052 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
9053 regs->tpc, tl);
9054 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
9055 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
9056 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9057 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
9058 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
9059 (void *) regs->u_regs[UREG_I7]);
9060 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
9061 "pte[%lx] error[%lx]\n",
9062 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9063 fp = (unsigned long)sf->fp + STACK_BIAS;
9064 }
9065
9066 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9067 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9068 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9069 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
9070 int index = tsk->curr_ret_stack;
9071 if (tsk->ret_stack && index >= graph) {
9072 pc = tsk->ret_stack[index - graph].ret;
9073 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9074 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9075 graph++;
9076 }
9077 }
9078 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9079 return (struct reg_window *) (fp + STACK_BIAS);
9080 }
9081
9082 +extern void gr_handle_kernel_exploit(void);
9083 +
9084 void die_if_kernel(char *str, struct pt_regs *regs)
9085 {
9086 static int die_counter;
9087 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9088 while (rw &&
9089 count++ < 30 &&
9090 kstack_valid(tp, (unsigned long) rw)) {
9091 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9092 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9093 (void *) rw->ins[7]);
9094
9095 rw = kernel_stack_up(rw);
9096 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9097 }
9098 user_instruction_dump ((unsigned int __user *) regs->tpc);
9099 }
9100 - if (regs->tstate & TSTATE_PRIV)
9101 + if (regs->tstate & TSTATE_PRIV) {
9102 + gr_handle_kernel_exploit();
9103 do_exit(SIGKILL);
9104 + }
9105 do_exit(SIGSEGV);
9106 }
9107 EXPORT_SYMBOL(die_if_kernel);
9108 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
9109 index 8201c25e..072a2a7 100644
9110 --- a/arch/sparc/kernel/unaligned_64.c
9111 +++ b/arch/sparc/kernel/unaligned_64.c
9112 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
9113 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
9114
9115 if (__ratelimit(&ratelimit)) {
9116 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
9117 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
9118 regs->tpc, (void *) regs->tpc);
9119 }
9120 }
9121 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
9122 index eb1624b..f9f4ddb 100644
9123 --- a/arch/sparc/kernel/us3_cpufreq.c
9124 +++ b/arch/sparc/kernel/us3_cpufreq.c
9125 @@ -18,14 +18,12 @@
9126 #include <asm/head.h>
9127 #include <asm/timer.h>
9128
9129 -static struct cpufreq_driver *cpufreq_us3_driver;
9130 -
9131 struct us3_freq_percpu_info {
9132 struct cpufreq_frequency_table table[4];
9133 };
9134
9135 /* Indexed by cpu number. */
9136 -static struct us3_freq_percpu_info *us3_freq_table;
9137 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
9138
9139 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
9140 * in the Safari config register.
9141 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
9142
9143 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
9144 {
9145 - if (cpufreq_us3_driver)
9146 - us3_set_cpu_divider_index(policy->cpu, 0);
9147 + us3_set_cpu_divider_index(policy->cpu, 0);
9148
9149 return 0;
9150 }
9151
9152 +static int __init us3_freq_init(void);
9153 +static void __exit us3_freq_exit(void);
9154 +
9155 +static struct cpufreq_driver cpufreq_us3_driver = {
9156 + .init = us3_freq_cpu_init,
9157 + .verify = us3_freq_verify,
9158 + .target = us3_freq_target,
9159 + .get = us3_freq_get,
9160 + .exit = us3_freq_cpu_exit,
9161 + .owner = THIS_MODULE,
9162 + .name = "UltraSPARC-III",
9163 +
9164 +};
9165 +
9166 static int __init us3_freq_init(void)
9167 {
9168 unsigned long manuf, impl, ver;
9169 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
9170 (impl == CHEETAH_IMPL ||
9171 impl == CHEETAH_PLUS_IMPL ||
9172 impl == JAGUAR_IMPL ||
9173 - impl == PANTHER_IMPL)) {
9174 - struct cpufreq_driver *driver;
9175 -
9176 - ret = -ENOMEM;
9177 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
9178 - if (!driver)
9179 - goto err_out;
9180 -
9181 - us3_freq_table = kzalloc(
9182 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
9183 - GFP_KERNEL);
9184 - if (!us3_freq_table)
9185 - goto err_out;
9186 -
9187 - driver->init = us3_freq_cpu_init;
9188 - driver->verify = us3_freq_verify;
9189 - driver->target = us3_freq_target;
9190 - driver->get = us3_freq_get;
9191 - driver->exit = us3_freq_cpu_exit;
9192 - driver->owner = THIS_MODULE,
9193 - strcpy(driver->name, "UltraSPARC-III");
9194 -
9195 - cpufreq_us3_driver = driver;
9196 - ret = cpufreq_register_driver(driver);
9197 - if (ret)
9198 - goto err_out;
9199 -
9200 - return 0;
9201 -
9202 -err_out:
9203 - if (driver) {
9204 - kfree(driver);
9205 - cpufreq_us3_driver = NULL;
9206 - }
9207 - kfree(us3_freq_table);
9208 - us3_freq_table = NULL;
9209 - return ret;
9210 - }
9211 + impl == PANTHER_IMPL))
9212 + return cpufreq_register_driver(cpufreq_us3_driver);
9213
9214 return -ENODEV;
9215 }
9216
9217 static void __exit us3_freq_exit(void)
9218 {
9219 - if (cpufreq_us3_driver) {
9220 - cpufreq_unregister_driver(cpufreq_us3_driver);
9221 - kfree(cpufreq_us3_driver);
9222 - cpufreq_us3_driver = NULL;
9223 - kfree(us3_freq_table);
9224 - us3_freq_table = NULL;
9225 - }
9226 + cpufreq_unregister_driver(cpufreq_us3_driver);
9227 }
9228
9229 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
9230 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
9231 index 8410065f2..4fd4ca22 100644
9232 --- a/arch/sparc/lib/Makefile
9233 +++ b/arch/sparc/lib/Makefile
9234 @@ -2,7 +2,7 @@
9235 #
9236
9237 asflags-y := -ansi -DST_DIV0=0x02
9238 -ccflags-y := -Werror
9239 +#ccflags-y := -Werror
9240
9241 lib-$(CONFIG_SPARC32) += ashrdi3.o
9242 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9243 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
9244 index 85c233d..68500e0 100644
9245 --- a/arch/sparc/lib/atomic_64.S
9246 +++ b/arch/sparc/lib/atomic_64.S
9247 @@ -17,7 +17,12 @@
9248 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9249 BACKOFF_SETUP(%o2)
9250 1: lduw [%o1], %g1
9251 - add %g1, %o0, %g7
9252 + addcc %g1, %o0, %g7
9253 +
9254 +#ifdef CONFIG_PAX_REFCOUNT
9255 + tvs %icc, 6
9256 +#endif
9257 +
9258 cas [%o1], %g1, %g7
9259 cmp %g1, %g7
9260 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9261 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9262 2: BACKOFF_SPIN(%o2, %o3, 1b)
9263 ENDPROC(atomic_add)
9264
9265 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9266 + BACKOFF_SETUP(%o2)
9267 +1: lduw [%o1], %g1
9268 + add %g1, %o0, %g7
9269 + cas [%o1], %g1, %g7
9270 + cmp %g1, %g7
9271 + bne,pn %icc, 2f
9272 + nop
9273 + retl
9274 + nop
9275 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9276 +ENDPROC(atomic_add_unchecked)
9277 +
9278 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9279 BACKOFF_SETUP(%o2)
9280 1: lduw [%o1], %g1
9281 - sub %g1, %o0, %g7
9282 + subcc %g1, %o0, %g7
9283 +
9284 +#ifdef CONFIG_PAX_REFCOUNT
9285 + tvs %icc, 6
9286 +#endif
9287 +
9288 cas [%o1], %g1, %g7
9289 cmp %g1, %g7
9290 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9291 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9292 2: BACKOFF_SPIN(%o2, %o3, 1b)
9293 ENDPROC(atomic_sub)
9294
9295 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9296 + BACKOFF_SETUP(%o2)
9297 +1: lduw [%o1], %g1
9298 + sub %g1, %o0, %g7
9299 + cas [%o1], %g1, %g7
9300 + cmp %g1, %g7
9301 + bne,pn %icc, 2f
9302 + nop
9303 + retl
9304 + nop
9305 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9306 +ENDPROC(atomic_sub_unchecked)
9307 +
9308 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9309 BACKOFF_SETUP(%o2)
9310 1: lduw [%o1], %g1
9311 - add %g1, %o0, %g7
9312 + addcc %g1, %o0, %g7
9313 +
9314 +#ifdef CONFIG_PAX_REFCOUNT
9315 + tvs %icc, 6
9316 +#endif
9317 +
9318 cas [%o1], %g1, %g7
9319 cmp %g1, %g7
9320 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9321 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9322 2: BACKOFF_SPIN(%o2, %o3, 1b)
9323 ENDPROC(atomic_add_ret)
9324
9325 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9326 + BACKOFF_SETUP(%o2)
9327 +1: lduw [%o1], %g1
9328 + addcc %g1, %o0, %g7
9329 + cas [%o1], %g1, %g7
9330 + cmp %g1, %g7
9331 + bne,pn %icc, 2f
9332 + add %g7, %o0, %g7
9333 + sra %g7, 0, %o0
9334 + retl
9335 + nop
9336 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9337 +ENDPROC(atomic_add_ret_unchecked)
9338 +
9339 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9340 BACKOFF_SETUP(%o2)
9341 1: lduw [%o1], %g1
9342 - sub %g1, %o0, %g7
9343 + subcc %g1, %o0, %g7
9344 +
9345 +#ifdef CONFIG_PAX_REFCOUNT
9346 + tvs %icc, 6
9347 +#endif
9348 +
9349 cas [%o1], %g1, %g7
9350 cmp %g1, %g7
9351 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9352 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9353 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9354 BACKOFF_SETUP(%o2)
9355 1: ldx [%o1], %g1
9356 - add %g1, %o0, %g7
9357 + addcc %g1, %o0, %g7
9358 +
9359 +#ifdef CONFIG_PAX_REFCOUNT
9360 + tvs %xcc, 6
9361 +#endif
9362 +
9363 casx [%o1], %g1, %g7
9364 cmp %g1, %g7
9365 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9366 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9367 2: BACKOFF_SPIN(%o2, %o3, 1b)
9368 ENDPROC(atomic64_add)
9369
9370 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9371 + BACKOFF_SETUP(%o2)
9372 +1: ldx [%o1], %g1
9373 + addcc %g1, %o0, %g7
9374 + casx [%o1], %g1, %g7
9375 + cmp %g1, %g7
9376 + bne,pn %xcc, 2f
9377 + nop
9378 + retl
9379 + nop
9380 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9381 +ENDPROC(atomic64_add_unchecked)
9382 +
9383 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9384 BACKOFF_SETUP(%o2)
9385 1: ldx [%o1], %g1
9386 - sub %g1, %o0, %g7
9387 + subcc %g1, %o0, %g7
9388 +
9389 +#ifdef CONFIG_PAX_REFCOUNT
9390 + tvs %xcc, 6
9391 +#endif
9392 +
9393 casx [%o1], %g1, %g7
9394 cmp %g1, %g7
9395 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9396 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9397 2: BACKOFF_SPIN(%o2, %o3, 1b)
9398 ENDPROC(atomic64_sub)
9399
9400 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9401 + BACKOFF_SETUP(%o2)
9402 +1: ldx [%o1], %g1
9403 + subcc %g1, %o0, %g7
9404 + casx [%o1], %g1, %g7
9405 + cmp %g1, %g7
9406 + bne,pn %xcc, 2f
9407 + nop
9408 + retl
9409 + nop
9410 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9411 +ENDPROC(atomic64_sub_unchecked)
9412 +
9413 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9414 BACKOFF_SETUP(%o2)
9415 1: ldx [%o1], %g1
9416 - add %g1, %o0, %g7
9417 + addcc %g1, %o0, %g7
9418 +
9419 +#ifdef CONFIG_PAX_REFCOUNT
9420 + tvs %xcc, 6
9421 +#endif
9422 +
9423 casx [%o1], %g1, %g7
9424 cmp %g1, %g7
9425 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9426 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9427 2: BACKOFF_SPIN(%o2, %o3, 1b)
9428 ENDPROC(atomic64_add_ret)
9429
9430 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9431 + BACKOFF_SETUP(%o2)
9432 +1: ldx [%o1], %g1
9433 + addcc %g1, %o0, %g7
9434 + casx [%o1], %g1, %g7
9435 + cmp %g1, %g7
9436 + bne,pn %xcc, 2f
9437 + add %g7, %o0, %g7
9438 + mov %g7, %o0
9439 + retl
9440 + nop
9441 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9442 +ENDPROC(atomic64_add_ret_unchecked)
9443 +
9444 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9445 BACKOFF_SETUP(%o2)
9446 1: ldx [%o1], %g1
9447 - sub %g1, %o0, %g7
9448 + subcc %g1, %o0, %g7
9449 +
9450 +#ifdef CONFIG_PAX_REFCOUNT
9451 + tvs %xcc, 6
9452 +#endif
9453 +
9454 casx [%o1], %g1, %g7
9455 cmp %g1, %g7
9456 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9457 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9458 index 0c4e35e..745d3e4 100644
9459 --- a/arch/sparc/lib/ksyms.c
9460 +++ b/arch/sparc/lib/ksyms.c
9461 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9462
9463 /* Atomic counter implementation. */
9464 EXPORT_SYMBOL(atomic_add);
9465 +EXPORT_SYMBOL(atomic_add_unchecked);
9466 EXPORT_SYMBOL(atomic_add_ret);
9467 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9468 EXPORT_SYMBOL(atomic_sub);
9469 +EXPORT_SYMBOL(atomic_sub_unchecked);
9470 EXPORT_SYMBOL(atomic_sub_ret);
9471 EXPORT_SYMBOL(atomic64_add);
9472 +EXPORT_SYMBOL(atomic64_add_unchecked);
9473 EXPORT_SYMBOL(atomic64_add_ret);
9474 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9475 EXPORT_SYMBOL(atomic64_sub);
9476 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9477 EXPORT_SYMBOL(atomic64_sub_ret);
9478 EXPORT_SYMBOL(atomic64_dec_if_positive);
9479
9480 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9481 index 30c3ecc..736f015 100644
9482 --- a/arch/sparc/mm/Makefile
9483 +++ b/arch/sparc/mm/Makefile
9484 @@ -2,7 +2,7 @@
9485 #
9486
9487 asflags-y := -ansi
9488 -ccflags-y := -Werror
9489 +#ccflags-y := -Werror
9490
9491 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9492 obj-y += fault_$(BITS).o
9493 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9494 index e98bfda..ea8d221 100644
9495 --- a/arch/sparc/mm/fault_32.c
9496 +++ b/arch/sparc/mm/fault_32.c
9497 @@ -21,6 +21,9 @@
9498 #include <linux/perf_event.h>
9499 #include <linux/interrupt.h>
9500 #include <linux/kdebug.h>
9501 +#include <linux/slab.h>
9502 +#include <linux/pagemap.h>
9503 +#include <linux/compiler.h>
9504
9505 #include <asm/page.h>
9506 #include <asm/pgtable.h>
9507 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9508 return safe_compute_effective_address(regs, insn);
9509 }
9510
9511 +#ifdef CONFIG_PAX_PAGEEXEC
9512 +#ifdef CONFIG_PAX_DLRESOLVE
9513 +static void pax_emuplt_close(struct vm_area_struct *vma)
9514 +{
9515 + vma->vm_mm->call_dl_resolve = 0UL;
9516 +}
9517 +
9518 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9519 +{
9520 + unsigned int *kaddr;
9521 +
9522 + vmf->page = alloc_page(GFP_HIGHUSER);
9523 + if (!vmf->page)
9524 + return VM_FAULT_OOM;
9525 +
9526 + kaddr = kmap(vmf->page);
9527 + memset(kaddr, 0, PAGE_SIZE);
9528 + kaddr[0] = 0x9DE3BFA8U; /* save */
9529 + flush_dcache_page(vmf->page);
9530 + kunmap(vmf->page);
9531 + return VM_FAULT_MAJOR;
9532 +}
9533 +
9534 +static const struct vm_operations_struct pax_vm_ops = {
9535 + .close = pax_emuplt_close,
9536 + .fault = pax_emuplt_fault
9537 +};
9538 +
9539 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9540 +{
9541 + int ret;
9542 +
9543 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9544 + vma->vm_mm = current->mm;
9545 + vma->vm_start = addr;
9546 + vma->vm_end = addr + PAGE_SIZE;
9547 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9548 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9549 + vma->vm_ops = &pax_vm_ops;
9550 +
9551 + ret = insert_vm_struct(current->mm, vma);
9552 + if (ret)
9553 + return ret;
9554 +
9555 + ++current->mm->total_vm;
9556 + return 0;
9557 +}
9558 +#endif
9559 +
9560 +/*
9561 + * PaX: decide what to do with offenders (regs->pc = fault address)
9562 + *
9563 + * returns 1 when task should be killed
9564 + * 2 when patched PLT trampoline was detected
9565 + * 3 when unpatched PLT trampoline was detected
9566 + */
9567 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9568 +{
9569 +
9570 +#ifdef CONFIG_PAX_EMUPLT
9571 + int err;
9572 +
9573 + do { /* PaX: patched PLT emulation #1 */
9574 + unsigned int sethi1, sethi2, jmpl;
9575 +
9576 + err = get_user(sethi1, (unsigned int *)regs->pc);
9577 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9578 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9579 +
9580 + if (err)
9581 + break;
9582 +
9583 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9584 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9585 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9586 + {
9587 + unsigned int addr;
9588 +
9589 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9590 + addr = regs->u_regs[UREG_G1];
9591 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9592 + regs->pc = addr;
9593 + regs->npc = addr+4;
9594 + return 2;
9595 + }
9596 + } while (0);
9597 +
9598 + do { /* PaX: patched PLT emulation #2 */
9599 + unsigned int ba;
9600 +
9601 + err = get_user(ba, (unsigned int *)regs->pc);
9602 +
9603 + if (err)
9604 + break;
9605 +
9606 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9607 + unsigned int addr;
9608 +
9609 + if ((ba & 0xFFC00000U) == 0x30800000U)
9610 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9611 + else
9612 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9613 + regs->pc = addr;
9614 + regs->npc = addr+4;
9615 + return 2;
9616 + }
9617 + } while (0);
9618 +
9619 + do { /* PaX: patched PLT emulation #3 */
9620 + unsigned int sethi, bajmpl, nop;
9621 +
9622 + err = get_user(sethi, (unsigned int *)regs->pc);
9623 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9624 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9625 +
9626 + if (err)
9627 + break;
9628 +
9629 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9630 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9631 + nop == 0x01000000U)
9632 + {
9633 + unsigned int addr;
9634 +
9635 + addr = (sethi & 0x003FFFFFU) << 10;
9636 + regs->u_regs[UREG_G1] = addr;
9637 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9638 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9639 + else
9640 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9641 + regs->pc = addr;
9642 + regs->npc = addr+4;
9643 + return 2;
9644 + }
9645 + } while (0);
9646 +
9647 + do { /* PaX: unpatched PLT emulation step 1 */
9648 + unsigned int sethi, ba, nop;
9649 +
9650 + err = get_user(sethi, (unsigned int *)regs->pc);
9651 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9652 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9653 +
9654 + if (err)
9655 + break;
9656 +
9657 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9658 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9659 + nop == 0x01000000U)
9660 + {
9661 + unsigned int addr, save, call;
9662 +
9663 + if ((ba & 0xFFC00000U) == 0x30800000U)
9664 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9665 + else
9666 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9667 +
9668 + err = get_user(save, (unsigned int *)addr);
9669 + err |= get_user(call, (unsigned int *)(addr+4));
9670 + err |= get_user(nop, (unsigned int *)(addr+8));
9671 + if (err)
9672 + break;
9673 +
9674 +#ifdef CONFIG_PAX_DLRESOLVE
9675 + if (save == 0x9DE3BFA8U &&
9676 + (call & 0xC0000000U) == 0x40000000U &&
9677 + nop == 0x01000000U)
9678 + {
9679 + struct vm_area_struct *vma;
9680 + unsigned long call_dl_resolve;
9681 +
9682 + down_read(&current->mm->mmap_sem);
9683 + call_dl_resolve = current->mm->call_dl_resolve;
9684 + up_read(&current->mm->mmap_sem);
9685 + if (likely(call_dl_resolve))
9686 + goto emulate;
9687 +
9688 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9689 +
9690 + down_write(&current->mm->mmap_sem);
9691 + if (current->mm->call_dl_resolve) {
9692 + call_dl_resolve = current->mm->call_dl_resolve;
9693 + up_write(&current->mm->mmap_sem);
9694 + if (vma)
9695 + kmem_cache_free(vm_area_cachep, vma);
9696 + goto emulate;
9697 + }
9698 +
9699 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9700 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9701 + up_write(&current->mm->mmap_sem);
9702 + if (vma)
9703 + kmem_cache_free(vm_area_cachep, vma);
9704 + return 1;
9705 + }
9706 +
9707 + if (pax_insert_vma(vma, call_dl_resolve)) {
9708 + up_write(&current->mm->mmap_sem);
9709 + kmem_cache_free(vm_area_cachep, vma);
9710 + return 1;
9711 + }
9712 +
9713 + current->mm->call_dl_resolve = call_dl_resolve;
9714 + up_write(&current->mm->mmap_sem);
9715 +
9716 +emulate:
9717 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9718 + regs->pc = call_dl_resolve;
9719 + regs->npc = addr+4;
9720 + return 3;
9721 + }
9722 +#endif
9723 +
9724 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9725 + if ((save & 0xFFC00000U) == 0x05000000U &&
9726 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9727 + nop == 0x01000000U)
9728 + {
9729 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9730 + regs->u_regs[UREG_G2] = addr + 4;
9731 + addr = (save & 0x003FFFFFU) << 10;
9732 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9733 + regs->pc = addr;
9734 + regs->npc = addr+4;
9735 + return 3;
9736 + }
9737 + }
9738 + } while (0);
9739 +
9740 + do { /* PaX: unpatched PLT emulation step 2 */
9741 + unsigned int save, call, nop;
9742 +
9743 + err = get_user(save, (unsigned int *)(regs->pc-4));
9744 + err |= get_user(call, (unsigned int *)regs->pc);
9745 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9746 + if (err)
9747 + break;
9748 +
9749 + if (save == 0x9DE3BFA8U &&
9750 + (call & 0xC0000000U) == 0x40000000U &&
9751 + nop == 0x01000000U)
9752 + {
9753 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9754 +
9755 + regs->u_regs[UREG_RETPC] = regs->pc;
9756 + regs->pc = dl_resolve;
9757 + regs->npc = dl_resolve+4;
9758 + return 3;
9759 + }
9760 + } while (0);
9761 +#endif
9762 +
9763 + return 1;
9764 +}
9765 +
9766 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9767 +{
9768 + unsigned long i;
9769 +
9770 + printk(KERN_ERR "PAX: bytes at PC: ");
9771 + for (i = 0; i < 8; i++) {
9772 + unsigned int c;
9773 + if (get_user(c, (unsigned int *)pc+i))
9774 + printk(KERN_CONT "???????? ");
9775 + else
9776 + printk(KERN_CONT "%08x ", c);
9777 + }
9778 + printk("\n");
9779 +}
9780 +#endif
9781 +
9782 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9783 int text_fault)
9784 {
9785 @@ -230,6 +504,24 @@ good_area:
9786 if (!(vma->vm_flags & VM_WRITE))
9787 goto bad_area;
9788 } else {
9789 +
9790 +#ifdef CONFIG_PAX_PAGEEXEC
9791 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9792 + up_read(&mm->mmap_sem);
9793 + switch (pax_handle_fetch_fault(regs)) {
9794 +
9795 +#ifdef CONFIG_PAX_EMUPLT
9796 + case 2:
9797 + case 3:
9798 + return;
9799 +#endif
9800 +
9801 + }
9802 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9803 + do_group_exit(SIGKILL);
9804 + }
9805 +#endif
9806 +
9807 /* Allow reads even for write-only mappings */
9808 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9809 goto bad_area;
9810 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9811 index 5062ff3..e0b75f3 100644
9812 --- a/arch/sparc/mm/fault_64.c
9813 +++ b/arch/sparc/mm/fault_64.c
9814 @@ -21,6 +21,9 @@
9815 #include <linux/kprobes.h>
9816 #include <linux/kdebug.h>
9817 #include <linux/percpu.h>
9818 +#include <linux/slab.h>
9819 +#include <linux/pagemap.h>
9820 +#include <linux/compiler.h>
9821
9822 #include <asm/page.h>
9823 #include <asm/pgtable.h>
9824 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9825 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9826 regs->tpc);
9827 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9828 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9829 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9830 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9831 dump_stack();
9832 unhandled_fault(regs->tpc, current, regs);
9833 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9834 show_regs(regs);
9835 }
9836
9837 +#ifdef CONFIG_PAX_PAGEEXEC
9838 +#ifdef CONFIG_PAX_DLRESOLVE
9839 +static void pax_emuplt_close(struct vm_area_struct *vma)
9840 +{
9841 + vma->vm_mm->call_dl_resolve = 0UL;
9842 +}
9843 +
9844 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9845 +{
9846 + unsigned int *kaddr;
9847 +
9848 + vmf->page = alloc_page(GFP_HIGHUSER);
9849 + if (!vmf->page)
9850 + return VM_FAULT_OOM;
9851 +
9852 + kaddr = kmap(vmf->page);
9853 + memset(kaddr, 0, PAGE_SIZE);
9854 + kaddr[0] = 0x9DE3BFA8U; /* save */
9855 + flush_dcache_page(vmf->page);
9856 + kunmap(vmf->page);
9857 + return VM_FAULT_MAJOR;
9858 +}
9859 +
9860 +static const struct vm_operations_struct pax_vm_ops = {
9861 + .close = pax_emuplt_close,
9862 + .fault = pax_emuplt_fault
9863 +};
9864 +
9865 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9866 +{
9867 + int ret;
9868 +
9869 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9870 + vma->vm_mm = current->mm;
9871 + vma->vm_start = addr;
9872 + vma->vm_end = addr + PAGE_SIZE;
9873 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9874 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9875 + vma->vm_ops = &pax_vm_ops;
9876 +
9877 + ret = insert_vm_struct(current->mm, vma);
9878 + if (ret)
9879 + return ret;
9880 +
9881 + ++current->mm->total_vm;
9882 + return 0;
9883 +}
9884 +#endif
9885 +
9886 +/*
9887 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9888 + *
9889 + * returns 1 when task should be killed
9890 + * 2 when patched PLT trampoline was detected
9891 + * 3 when unpatched PLT trampoline was detected
9892 + */
9893 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9894 +{
9895 +
9896 +#ifdef CONFIG_PAX_EMUPLT
9897 + int err;
9898 +
9899 + do { /* PaX: patched PLT emulation #1 */
9900 + unsigned int sethi1, sethi2, jmpl;
9901 +
9902 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9903 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9904 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9905 +
9906 + if (err)
9907 + break;
9908 +
9909 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9910 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9911 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9912 + {
9913 + unsigned long addr;
9914 +
9915 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9916 + addr = regs->u_regs[UREG_G1];
9917 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9918 +
9919 + if (test_thread_flag(TIF_32BIT))
9920 + addr &= 0xFFFFFFFFUL;
9921 +
9922 + regs->tpc = addr;
9923 + regs->tnpc = addr+4;
9924 + return 2;
9925 + }
9926 + } while (0);
9927 +
9928 + do { /* PaX: patched PLT emulation #2 */
9929 + unsigned int ba;
9930 +
9931 + err = get_user(ba, (unsigned int *)regs->tpc);
9932 +
9933 + if (err)
9934 + break;
9935 +
9936 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9937 + unsigned long addr;
9938 +
9939 + if ((ba & 0xFFC00000U) == 0x30800000U)
9940 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9941 + else
9942 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9943 +
9944 + if (test_thread_flag(TIF_32BIT))
9945 + addr &= 0xFFFFFFFFUL;
9946 +
9947 + regs->tpc = addr;
9948 + regs->tnpc = addr+4;
9949 + return 2;
9950 + }
9951 + } while (0);
9952 +
9953 + do { /* PaX: patched PLT emulation #3 */
9954 + unsigned int sethi, bajmpl, nop;
9955 +
9956 + err = get_user(sethi, (unsigned int *)regs->tpc);
9957 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9958 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9959 +
9960 + if (err)
9961 + break;
9962 +
9963 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9964 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9965 + nop == 0x01000000U)
9966 + {
9967 + unsigned long addr;
9968 +
9969 + addr = (sethi & 0x003FFFFFU) << 10;
9970 + regs->u_regs[UREG_G1] = addr;
9971 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9972 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9973 + else
9974 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9975 +
9976 + if (test_thread_flag(TIF_32BIT))
9977 + addr &= 0xFFFFFFFFUL;
9978 +
9979 + regs->tpc = addr;
9980 + regs->tnpc = addr+4;
9981 + return 2;
9982 + }
9983 + } while (0);
9984 +
9985 + do { /* PaX: patched PLT emulation #4 */
9986 + unsigned int sethi, mov1, call, mov2;
9987 +
9988 + err = get_user(sethi, (unsigned int *)regs->tpc);
9989 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9990 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9991 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9992 +
9993 + if (err)
9994 + break;
9995 +
9996 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9997 + mov1 == 0x8210000FU &&
9998 + (call & 0xC0000000U) == 0x40000000U &&
9999 + mov2 == 0x9E100001U)
10000 + {
10001 + unsigned long addr;
10002 +
10003 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10004 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10005 +
10006 + if (test_thread_flag(TIF_32BIT))
10007 + addr &= 0xFFFFFFFFUL;
10008 +
10009 + regs->tpc = addr;
10010 + regs->tnpc = addr+4;
10011 + return 2;
10012 + }
10013 + } while (0);
10014 +
10015 + do { /* PaX: patched PLT emulation #5 */
10016 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10017 +
10018 + err = get_user(sethi, (unsigned int *)regs->tpc);
10019 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10020 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10021 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10022 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10023 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10024 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10025 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10026 +
10027 + if (err)
10028 + break;
10029 +
10030 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10031 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10032 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10033 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10034 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10035 + sllx == 0x83287020U &&
10036 + jmpl == 0x81C04005U &&
10037 + nop == 0x01000000U)
10038 + {
10039 + unsigned long addr;
10040 +
10041 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10042 + regs->u_regs[UREG_G1] <<= 32;
10043 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10044 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10045 + regs->tpc = addr;
10046 + regs->tnpc = addr+4;
10047 + return 2;
10048 + }
10049 + } while (0);
10050 +
10051 + do { /* PaX: patched PLT emulation #6 */
10052 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10053 +
10054 + err = get_user(sethi, (unsigned int *)regs->tpc);
10055 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10056 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10057 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10058 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10059 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10060 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10061 +
10062 + if (err)
10063 + break;
10064 +
10065 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10066 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10067 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10068 + sllx == 0x83287020U &&
10069 + (or & 0xFFFFE000U) == 0x8A116000U &&
10070 + jmpl == 0x81C04005U &&
10071 + nop == 0x01000000U)
10072 + {
10073 + unsigned long addr;
10074 +
10075 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10076 + regs->u_regs[UREG_G1] <<= 32;
10077 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10078 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10079 + regs->tpc = addr;
10080 + regs->tnpc = addr+4;
10081 + return 2;
10082 + }
10083 + } while (0);
10084 +
10085 + do { /* PaX: unpatched PLT emulation step 1 */
10086 + unsigned int sethi, ba, nop;
10087 +
10088 + err = get_user(sethi, (unsigned int *)regs->tpc);
10089 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10090 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10091 +
10092 + if (err)
10093 + break;
10094 +
10095 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10096 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10097 + nop == 0x01000000U)
10098 + {
10099 + unsigned long addr;
10100 + unsigned int save, call;
10101 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10102 +
10103 + if ((ba & 0xFFC00000U) == 0x30800000U)
10104 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10105 + else
10106 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10107 +
10108 + if (test_thread_flag(TIF_32BIT))
10109 + addr &= 0xFFFFFFFFUL;
10110 +
10111 + err = get_user(save, (unsigned int *)addr);
10112 + err |= get_user(call, (unsigned int *)(addr+4));
10113 + err |= get_user(nop, (unsigned int *)(addr+8));
10114 + if (err)
10115 + break;
10116 +
10117 +#ifdef CONFIG_PAX_DLRESOLVE
10118 + if (save == 0x9DE3BFA8U &&
10119 + (call & 0xC0000000U) == 0x40000000U &&
10120 + nop == 0x01000000U)
10121 + {
10122 + struct vm_area_struct *vma;
10123 + unsigned long call_dl_resolve;
10124 +
10125 + down_read(&current->mm->mmap_sem);
10126 + call_dl_resolve = current->mm->call_dl_resolve;
10127 + up_read(&current->mm->mmap_sem);
10128 + if (likely(call_dl_resolve))
10129 + goto emulate;
10130 +
10131 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10132 +
10133 + down_write(&current->mm->mmap_sem);
10134 + if (current->mm->call_dl_resolve) {
10135 + call_dl_resolve = current->mm->call_dl_resolve;
10136 + up_write(&current->mm->mmap_sem);
10137 + if (vma)
10138 + kmem_cache_free(vm_area_cachep, vma);
10139 + goto emulate;
10140 + }
10141 +
10142 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10143 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10144 + up_write(&current->mm->mmap_sem);
10145 + if (vma)
10146 + kmem_cache_free(vm_area_cachep, vma);
10147 + return 1;
10148 + }
10149 +
10150 + if (pax_insert_vma(vma, call_dl_resolve)) {
10151 + up_write(&current->mm->mmap_sem);
10152 + kmem_cache_free(vm_area_cachep, vma);
10153 + return 1;
10154 + }
10155 +
10156 + current->mm->call_dl_resolve = call_dl_resolve;
10157 + up_write(&current->mm->mmap_sem);
10158 +
10159 +emulate:
10160 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10161 + regs->tpc = call_dl_resolve;
10162 + regs->tnpc = addr+4;
10163 + return 3;
10164 + }
10165 +#endif
10166 +
10167 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10168 + if ((save & 0xFFC00000U) == 0x05000000U &&
10169 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10170 + nop == 0x01000000U)
10171 + {
10172 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10173 + regs->u_regs[UREG_G2] = addr + 4;
10174 + addr = (save & 0x003FFFFFU) << 10;
10175 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10176 +
10177 + if (test_thread_flag(TIF_32BIT))
10178 + addr &= 0xFFFFFFFFUL;
10179 +
10180 + regs->tpc = addr;
10181 + regs->tnpc = addr+4;
10182 + return 3;
10183 + }
10184 +
10185 + /* PaX: 64-bit PLT stub */
10186 + err = get_user(sethi1, (unsigned int *)addr);
10187 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10188 + err |= get_user(or1, (unsigned int *)(addr+8));
10189 + err |= get_user(or2, (unsigned int *)(addr+12));
10190 + err |= get_user(sllx, (unsigned int *)(addr+16));
10191 + err |= get_user(add, (unsigned int *)(addr+20));
10192 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10193 + err |= get_user(nop, (unsigned int *)(addr+28));
10194 + if (err)
10195 + break;
10196 +
10197 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10198 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10199 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10200 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10201 + sllx == 0x89293020U &&
10202 + add == 0x8A010005U &&
10203 + jmpl == 0x89C14000U &&
10204 + nop == 0x01000000U)
10205 + {
10206 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10207 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10208 + regs->u_regs[UREG_G4] <<= 32;
10209 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10210 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
10211 + regs->u_regs[UREG_G4] = addr + 24;
10212 + addr = regs->u_regs[UREG_G5];
10213 + regs->tpc = addr;
10214 + regs->tnpc = addr+4;
10215 + return 3;
10216 + }
10217 + }
10218 + } while (0);
10219 +
10220 +#ifdef CONFIG_PAX_DLRESOLVE
10221 + do { /* PaX: unpatched PLT emulation step 2 */
10222 + unsigned int save, call, nop;
10223 +
10224 + err = get_user(save, (unsigned int *)(regs->tpc-4));
10225 + err |= get_user(call, (unsigned int *)regs->tpc);
10226 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
10227 + if (err)
10228 + break;
10229 +
10230 + if (save == 0x9DE3BFA8U &&
10231 + (call & 0xC0000000U) == 0x40000000U &&
10232 + nop == 0x01000000U)
10233 + {
10234 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10235 +
10236 + if (test_thread_flag(TIF_32BIT))
10237 + dl_resolve &= 0xFFFFFFFFUL;
10238 +
10239 + regs->u_regs[UREG_RETPC] = regs->tpc;
10240 + regs->tpc = dl_resolve;
10241 + regs->tnpc = dl_resolve+4;
10242 + return 3;
10243 + }
10244 + } while (0);
10245 +#endif
10246 +
10247 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
10248 + unsigned int sethi, ba, nop;
10249 +
10250 + err = get_user(sethi, (unsigned int *)regs->tpc);
10251 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10252 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10253 +
10254 + if (err)
10255 + break;
10256 +
10257 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10258 + (ba & 0xFFF00000U) == 0x30600000U &&
10259 + nop == 0x01000000U)
10260 + {
10261 + unsigned long addr;
10262 +
10263 + addr = (sethi & 0x003FFFFFU) << 10;
10264 + regs->u_regs[UREG_G1] = addr;
10265 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10266 +
10267 + if (test_thread_flag(TIF_32BIT))
10268 + addr &= 0xFFFFFFFFUL;
10269 +
10270 + regs->tpc = addr;
10271 + regs->tnpc = addr+4;
10272 + return 2;
10273 + }
10274 + } while (0);
10275 +
10276 +#endif
10277 +
10278 + return 1;
10279 +}
10280 +
10281 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10282 +{
10283 + unsigned long i;
10284 +
10285 + printk(KERN_ERR "PAX: bytes at PC: ");
10286 + for (i = 0; i < 8; i++) {
10287 + unsigned int c;
10288 + if (get_user(c, (unsigned int *)pc+i))
10289 + printk(KERN_CONT "???????? ");
10290 + else
10291 + printk(KERN_CONT "%08x ", c);
10292 + }
10293 + printk("\n");
10294 +}
10295 +#endif
10296 +
10297 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
10298 {
10299 struct mm_struct *mm = current->mm;
10300 @@ -341,6 +804,29 @@ retry:
10301 if (!vma)
10302 goto bad_area;
10303
10304 +#ifdef CONFIG_PAX_PAGEEXEC
10305 + /* PaX: detect ITLB misses on non-exec pages */
10306 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
10307 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
10308 + {
10309 + if (address != regs->tpc)
10310 + goto good_area;
10311 +
10312 + up_read(&mm->mmap_sem);
10313 + switch (pax_handle_fetch_fault(regs)) {
10314 +
10315 +#ifdef CONFIG_PAX_EMUPLT
10316 + case 2:
10317 + case 3:
10318 + return;
10319 +#endif
10320 +
10321 + }
10322 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
10323 + do_group_exit(SIGKILL);
10324 + }
10325 +#endif
10326 +
10327 /* Pure DTLB misses do not tell us whether the fault causing
10328 * load/store/atomic was a write or not, it only says that there
10329 * was no match. So in such a case we (carefully) read the
10330 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10331 index d2b5944..bd813f2 100644
10332 --- a/arch/sparc/mm/hugetlbpage.c
10333 +++ b/arch/sparc/mm/hugetlbpage.c
10334 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10335
10336 info.flags = 0;
10337 info.length = len;
10338 - info.low_limit = TASK_UNMAPPED_BASE;
10339 + info.low_limit = mm->mmap_base;
10340 info.high_limit = min(task_size, VA_EXCLUDE_START);
10341 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10342 info.align_offset = 0;
10343 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10344 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10345 VM_BUG_ON(addr != -ENOMEM);
10346 info.low_limit = VA_EXCLUDE_END;
10347 +
10348 +#ifdef CONFIG_PAX_RANDMMAP
10349 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10350 + info.low_limit += mm->delta_mmap;
10351 +#endif
10352 +
10353 info.high_limit = task_size;
10354 addr = vm_unmapped_area(&info);
10355 }
10356 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10357 VM_BUG_ON(addr != -ENOMEM);
10358 info.flags = 0;
10359 info.low_limit = TASK_UNMAPPED_BASE;
10360 +
10361 +#ifdef CONFIG_PAX_RANDMMAP
10362 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10363 + info.low_limit += mm->delta_mmap;
10364 +#endif
10365 +
10366 info.high_limit = STACK_TOP32;
10367 addr = vm_unmapped_area(&info);
10368 }
10369 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10370 struct mm_struct *mm = current->mm;
10371 struct vm_area_struct *vma;
10372 unsigned long task_size = TASK_SIZE;
10373 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10374
10375 if (test_thread_flag(TIF_32BIT))
10376 task_size = STACK_TOP32;
10377 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10378 return addr;
10379 }
10380
10381 +#ifdef CONFIG_PAX_RANDMMAP
10382 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10383 +#endif
10384 +
10385 if (addr) {
10386 addr = ALIGN(addr, HPAGE_SIZE);
10387 vma = find_vma(mm, addr);
10388 - if (task_size - len >= addr &&
10389 - (!vma || addr + len <= vma->vm_start))
10390 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10391 return addr;
10392 }
10393 if (mm->get_unmapped_area == arch_get_unmapped_area)
10394 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10395 index f4500c6..889656c 100644
10396 --- a/arch/tile/include/asm/atomic_64.h
10397 +++ b/arch/tile/include/asm/atomic_64.h
10398 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10399
10400 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10401
10402 +#define atomic64_read_unchecked(v) atomic64_read(v)
10403 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10404 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10405 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10406 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10407 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10408 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10409 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10410 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10411 +
10412 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10413 #define smp_mb__before_atomic_dec() smp_mb()
10414 #define smp_mb__after_atomic_dec() smp_mb()
10415 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10416 index a9a5299..0fce79e 100644
10417 --- a/arch/tile/include/asm/cache.h
10418 +++ b/arch/tile/include/asm/cache.h
10419 @@ -15,11 +15,12 @@
10420 #ifndef _ASM_TILE_CACHE_H
10421 #define _ASM_TILE_CACHE_H
10422
10423 +#include <linux/const.h>
10424 #include <arch/chip.h>
10425
10426 /* bytes per L1 data cache line */
10427 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10428 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10429 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10430
10431 /* bytes per L2 cache line */
10432 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10433 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10434 index 9ab078a..d6635c2 100644
10435 --- a/arch/tile/include/asm/uaccess.h
10436 +++ b/arch/tile/include/asm/uaccess.h
10437 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10438 const void __user *from,
10439 unsigned long n)
10440 {
10441 - int sz = __compiletime_object_size(to);
10442 + size_t sz = __compiletime_object_size(to);
10443
10444 - if (likely(sz == -1 || sz >= n))
10445 + if (likely(sz == (size_t)-1 || sz >= n))
10446 n = _copy_from_user(to, from, n);
10447 else
10448 copy_from_user_overflow();
10449 diff --git a/arch/um/Makefile b/arch/um/Makefile
10450 index 133f7de..1d6f2f1 100644
10451 --- a/arch/um/Makefile
10452 +++ b/arch/um/Makefile
10453 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10454 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10455 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10456
10457 +ifdef CONSTIFY_PLUGIN
10458 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10459 +endif
10460 +
10461 #This will adjust *FLAGS accordingly to the platform.
10462 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10463
10464 diff --git a/arch/um/defconfig b/arch/um/defconfig
10465 index 08107a7..ab22afe 100644
10466 --- a/arch/um/defconfig
10467 +++ b/arch/um/defconfig
10468 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10469 CONFIG_X86_L1_CACHE_SHIFT=5
10470 CONFIG_X86_XADD=y
10471 CONFIG_X86_PPRO_FENCE=y
10472 -CONFIG_X86_WP_WORKS_OK=y
10473 CONFIG_X86_INVLPG=y
10474 CONFIG_X86_BSWAP=y
10475 CONFIG_X86_POPAD_OK=y
10476 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10477 index 19e1bdd..3665b77 100644
10478 --- a/arch/um/include/asm/cache.h
10479 +++ b/arch/um/include/asm/cache.h
10480 @@ -1,6 +1,7 @@
10481 #ifndef __UM_CACHE_H
10482 #define __UM_CACHE_H
10483
10484 +#include <linux/const.h>
10485
10486 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10487 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10488 @@ -12,6 +13,6 @@
10489 # define L1_CACHE_SHIFT 5
10490 #endif
10491
10492 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10493 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10494
10495 #endif
10496 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10497 index 2e0a6b1..a64d0f5 100644
10498 --- a/arch/um/include/asm/kmap_types.h
10499 +++ b/arch/um/include/asm/kmap_types.h
10500 @@ -8,6 +8,6 @@
10501
10502 /* No more #include "asm/arch/kmap_types.h" ! */
10503
10504 -#define KM_TYPE_NR 14
10505 +#define KM_TYPE_NR 15
10506
10507 #endif
10508 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10509 index 5ff53d9..5850cdf 100644
10510 --- a/arch/um/include/asm/page.h
10511 +++ b/arch/um/include/asm/page.h
10512 @@ -14,6 +14,9 @@
10513 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10514 #define PAGE_MASK (~(PAGE_SIZE-1))
10515
10516 +#define ktla_ktva(addr) (addr)
10517 +#define ktva_ktla(addr) (addr)
10518 +
10519 #ifndef __ASSEMBLY__
10520
10521 struct page;
10522 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10523 index 0032f92..cd151e0 100644
10524 --- a/arch/um/include/asm/pgtable-3level.h
10525 +++ b/arch/um/include/asm/pgtable-3level.h
10526 @@ -58,6 +58,7 @@
10527 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10528 #define pud_populate(mm, pud, pmd) \
10529 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10530 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10531
10532 #ifdef CONFIG_64BIT
10533 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10534 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10535 index b462b13..e7a19aa 100644
10536 --- a/arch/um/kernel/process.c
10537 +++ b/arch/um/kernel/process.c
10538 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10539 return 2;
10540 }
10541
10542 -/*
10543 - * Only x86 and x86_64 have an arch_align_stack().
10544 - * All other arches have "#define arch_align_stack(x) (x)"
10545 - * in their asm/system.h
10546 - * As this is included in UML from asm-um/system-generic.h,
10547 - * we can use it to behave as the subarch does.
10548 - */
10549 -#ifndef arch_align_stack
10550 -unsigned long arch_align_stack(unsigned long sp)
10551 -{
10552 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10553 - sp -= get_random_int() % 8192;
10554 - return sp & ~0xf;
10555 -}
10556 -#endif
10557 -
10558 unsigned long get_wchan(struct task_struct *p)
10559 {
10560 unsigned long stack_page, sp, ip;
10561 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10562 index ad8f795..2c7eec6 100644
10563 --- a/arch/unicore32/include/asm/cache.h
10564 +++ b/arch/unicore32/include/asm/cache.h
10565 @@ -12,8 +12,10 @@
10566 #ifndef __UNICORE_CACHE_H__
10567 #define __UNICORE_CACHE_H__
10568
10569 -#define L1_CACHE_SHIFT (5)
10570 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10571 +#include <linux/const.h>
10572 +
10573 +#define L1_CACHE_SHIFT 5
10574 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10575
10576 /*
10577 * Memory returned by kmalloc() may be used for DMA, so we must make
10578 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10579 index 0694d09..58ea1a1 100644
10580 --- a/arch/x86/Kconfig
10581 +++ b/arch/x86/Kconfig
10582 @@ -238,7 +238,7 @@ config X86_HT
10583
10584 config X86_32_LAZY_GS
10585 def_bool y
10586 - depends on X86_32 && !CC_STACKPROTECTOR
10587 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10588
10589 config ARCH_HWEIGHT_CFLAGS
10590 string
10591 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
10592
10593 config X86_MSR
10594 tristate "/dev/cpu/*/msr - Model-specific register support"
10595 + depends on !GRKERNSEC_KMEM
10596 ---help---
10597 This device gives privileged processes access to the x86
10598 Model-Specific Registers (MSRs). It is a character device with
10599 @@ -1054,7 +1055,7 @@ choice
10600
10601 config NOHIGHMEM
10602 bool "off"
10603 - depends on !X86_NUMAQ
10604 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10605 ---help---
10606 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10607 However, the address space of 32-bit x86 processors is only 4
10608 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
10609
10610 config HIGHMEM4G
10611 bool "4GB"
10612 - depends on !X86_NUMAQ
10613 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10614 ---help---
10615 Select this if you have a 32-bit processor and between 1 and 4
10616 gigabytes of physical RAM.
10617 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
10618 hex
10619 default 0xB0000000 if VMSPLIT_3G_OPT
10620 default 0x80000000 if VMSPLIT_2G
10621 - default 0x78000000 if VMSPLIT_2G_OPT
10622 + default 0x70000000 if VMSPLIT_2G_OPT
10623 default 0x40000000 if VMSPLIT_1G
10624 default 0xC0000000
10625 depends on X86_32
10626 @@ -1542,6 +1543,7 @@ config SECCOMP
10627
10628 config CC_STACKPROTECTOR
10629 bool "Enable -fstack-protector buffer overflow detection"
10630 + depends on X86_64 || !PAX_MEMORY_UDEREF
10631 ---help---
10632 This option turns on the -fstack-protector GCC feature. This
10633 feature puts, at the beginning of functions, a canary value on
10634 @@ -1662,6 +1664,8 @@ config X86_NEED_RELOCS
10635 config PHYSICAL_ALIGN
10636 hex "Alignment value to which kernel should be aligned" if X86_32
10637 default "0x1000000"
10638 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10639 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10640 range 0x2000 0x1000000
10641 ---help---
10642 This value puts the alignment restrictions on physical address
10643 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
10644 If unsure, say N.
10645
10646 config COMPAT_VDSO
10647 - def_bool y
10648 + def_bool n
10649 prompt "Compat VDSO support"
10650 depends on X86_32 || IA32_EMULATION
10651 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10652 ---help---
10653 Map the 32-bit VDSO to the predictable old-style address too.
10654
10655 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10656 index c026cca..14657ae 100644
10657 --- a/arch/x86/Kconfig.cpu
10658 +++ b/arch/x86/Kconfig.cpu
10659 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10660
10661 config X86_F00F_BUG
10662 def_bool y
10663 - depends on M586MMX || M586TSC || M586 || M486
10664 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10665
10666 config X86_INVD_BUG
10667 def_bool y
10668 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10669
10670 config X86_ALIGNMENT_16
10671 def_bool y
10672 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10673 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10674
10675 config X86_INTEL_USERCOPY
10676 def_bool y
10677 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10678 # generates cmov.
10679 config X86_CMOV
10680 def_bool y
10681 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10682 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10683
10684 config X86_MINIMUM_CPU_FAMILY
10685 int
10686 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10687 index b322f12..652d0d9 100644
10688 --- a/arch/x86/Kconfig.debug
10689 +++ b/arch/x86/Kconfig.debug
10690 @@ -84,7 +84,7 @@ config X86_PTDUMP
10691 config DEBUG_RODATA
10692 bool "Write protect kernel read-only data structures"
10693 default y
10694 - depends on DEBUG_KERNEL
10695 + depends on DEBUG_KERNEL && BROKEN
10696 ---help---
10697 Mark the kernel read-only data as write-protected in the pagetables,
10698 in order to catch accidental (and incorrect) writes to such const
10699 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10700
10701 config DEBUG_SET_MODULE_RONX
10702 bool "Set loadable kernel module data as NX and text as RO"
10703 - depends on MODULES
10704 + depends on MODULES && BROKEN
10705 ---help---
10706 This option helps catch unintended modifications to loadable
10707 kernel module's text and read-only data. It also prevents execution
10708 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10709
10710 config DEBUG_STRICT_USER_COPY_CHECKS
10711 bool "Strict copy size checks"
10712 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10713 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10714 ---help---
10715 Enabling this option turns a certain set of sanity checks for user
10716 copy operations into compile time failures.
10717 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10718 index e71fc42..7829607 100644
10719 --- a/arch/x86/Makefile
10720 +++ b/arch/x86/Makefile
10721 @@ -50,6 +50,7 @@ else
10722 UTS_MACHINE := x86_64
10723 CHECKFLAGS += -D__x86_64__ -m64
10724
10725 + biarch := $(call cc-option,-m64)
10726 KBUILD_AFLAGS += -m64
10727 KBUILD_CFLAGS += -m64
10728
10729 @@ -230,3 +231,12 @@ define archhelp
10730 echo ' FDARGS="..." arguments for the booted kernel'
10731 echo ' FDINITRD=file initrd for the booted kernel'
10732 endef
10733 +
10734 +define OLD_LD
10735 +
10736 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10737 +*** Please upgrade your binutils to 2.18 or newer
10738 +endef
10739 +
10740 +archprepare:
10741 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10742 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10743 index 379814b..add62ce 100644
10744 --- a/arch/x86/boot/Makefile
10745 +++ b/arch/x86/boot/Makefile
10746 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10747 $(call cc-option, -fno-stack-protector) \
10748 $(call cc-option, -mpreferred-stack-boundary=2)
10749 KBUILD_CFLAGS += $(call cc-option, -m32)
10750 +ifdef CONSTIFY_PLUGIN
10751 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10752 +endif
10753 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10754 GCOV_PROFILE := n
10755
10756 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10757 index 878e4b9..20537ab 100644
10758 --- a/arch/x86/boot/bitops.h
10759 +++ b/arch/x86/boot/bitops.h
10760 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10761 u8 v;
10762 const u32 *p = (const u32 *)addr;
10763
10764 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10765 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10766 return v;
10767 }
10768
10769 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10770
10771 static inline void set_bit(int nr, void *addr)
10772 {
10773 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10774 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10775 }
10776
10777 #endif /* BOOT_BITOPS_H */
10778 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10779 index 18997e5..83d9c67 100644
10780 --- a/arch/x86/boot/boot.h
10781 +++ b/arch/x86/boot/boot.h
10782 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10783 static inline u16 ds(void)
10784 {
10785 u16 seg;
10786 - asm("movw %%ds,%0" : "=rm" (seg));
10787 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10788 return seg;
10789 }
10790
10791 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10792 static inline int memcmp(const void *s1, const void *s2, size_t len)
10793 {
10794 u8 diff;
10795 - asm("repe; cmpsb; setnz %0"
10796 + asm volatile("repe; cmpsb; setnz %0"
10797 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10798 return diff;
10799 }
10800 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10801 index 5ef205c..342191d 100644
10802 --- a/arch/x86/boot/compressed/Makefile
10803 +++ b/arch/x86/boot/compressed/Makefile
10804 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10805 KBUILD_CFLAGS += $(cflags-y)
10806 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10807 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10808 +ifdef CONSTIFY_PLUGIN
10809 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10810 +endif
10811
10812 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10813 GCOV_PROFILE := n
10814 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10815 index c205035..5853587 100644
10816 --- a/arch/x86/boot/compressed/eboot.c
10817 +++ b/arch/x86/boot/compressed/eboot.c
10818 @@ -150,7 +150,6 @@ again:
10819 *addr = max_addr;
10820 }
10821
10822 -free_pool:
10823 efi_call_phys1(sys_table->boottime->free_pool, map);
10824
10825 fail:
10826 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10827 if (i == map_size / desc_size)
10828 status = EFI_NOT_FOUND;
10829
10830 -free_pool:
10831 efi_call_phys1(sys_table->boottime->free_pool, map);
10832 fail:
10833 return status;
10834 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10835 index 1e3184f..0d11e2e 100644
10836 --- a/arch/x86/boot/compressed/head_32.S
10837 +++ b/arch/x86/boot/compressed/head_32.S
10838 @@ -118,7 +118,7 @@ preferred_addr:
10839 notl %eax
10840 andl %eax, %ebx
10841 #else
10842 - movl $LOAD_PHYSICAL_ADDR, %ebx
10843 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10844 #endif
10845
10846 /* Target address to relocate to for decompression */
10847 @@ -204,7 +204,7 @@ relocated:
10848 * and where it was actually loaded.
10849 */
10850 movl %ebp, %ebx
10851 - subl $LOAD_PHYSICAL_ADDR, %ebx
10852 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10853 jz 2f /* Nothing to be done if loaded at compiled addr. */
10854 /*
10855 * Process relocations.
10856 @@ -212,8 +212,7 @@ relocated:
10857
10858 1: subl $4, %edi
10859 movl (%edi), %ecx
10860 - testl %ecx, %ecx
10861 - jz 2f
10862 + jecxz 2f
10863 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10864 jmp 1b
10865 2:
10866 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10867 index f5d1aaa..cce11dc 100644
10868 --- a/arch/x86/boot/compressed/head_64.S
10869 +++ b/arch/x86/boot/compressed/head_64.S
10870 @@ -91,7 +91,7 @@ ENTRY(startup_32)
10871 notl %eax
10872 andl %eax, %ebx
10873 #else
10874 - movl $LOAD_PHYSICAL_ADDR, %ebx
10875 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10876 #endif
10877
10878 /* Target address to relocate to for decompression */
10879 @@ -273,7 +273,7 @@ preferred_addr:
10880 notq %rax
10881 andq %rax, %rbp
10882 #else
10883 - movq $LOAD_PHYSICAL_ADDR, %rbp
10884 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10885 #endif
10886
10887 /* Target address to relocate to for decompression */
10888 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10889 index 88f7ff6..ed695dd 100644
10890 --- a/arch/x86/boot/compressed/misc.c
10891 +++ b/arch/x86/boot/compressed/misc.c
10892 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10893 case PT_LOAD:
10894 #ifdef CONFIG_RELOCATABLE
10895 dest = output;
10896 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10897 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10898 #else
10899 dest = (void *)(phdr->p_paddr);
10900 #endif
10901 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10902 error("Destination address too large");
10903 #endif
10904 #ifndef CONFIG_RELOCATABLE
10905 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10906 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10907 error("Wrong destination address");
10908 #endif
10909
10910 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10911 index 4d3ff03..e4972ff 100644
10912 --- a/arch/x86/boot/cpucheck.c
10913 +++ b/arch/x86/boot/cpucheck.c
10914 @@ -74,7 +74,7 @@ static int has_fpu(void)
10915 u16 fcw = -1, fsw = -1;
10916 u32 cr0;
10917
10918 - asm("movl %%cr0,%0" : "=r" (cr0));
10919 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10920 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10921 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10922 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10923 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10924 {
10925 u32 f0, f1;
10926
10927 - asm("pushfl ; "
10928 + asm volatile("pushfl ; "
10929 "pushfl ; "
10930 "popl %0 ; "
10931 "movl %0,%1 ; "
10932 @@ -115,7 +115,7 @@ static void get_flags(void)
10933 set_bit(X86_FEATURE_FPU, cpu.flags);
10934
10935 if (has_eflag(X86_EFLAGS_ID)) {
10936 - asm("cpuid"
10937 + asm volatile("cpuid"
10938 : "=a" (max_intel_level),
10939 "=b" (cpu_vendor[0]),
10940 "=d" (cpu_vendor[1]),
10941 @@ -124,7 +124,7 @@ static void get_flags(void)
10942
10943 if (max_intel_level >= 0x00000001 &&
10944 max_intel_level <= 0x0000ffff) {
10945 - asm("cpuid"
10946 + asm volatile("cpuid"
10947 : "=a" (tfms),
10948 "=c" (cpu.flags[4]),
10949 "=d" (cpu.flags[0])
10950 @@ -136,7 +136,7 @@ static void get_flags(void)
10951 cpu.model += ((tfms >> 16) & 0xf) << 4;
10952 }
10953
10954 - asm("cpuid"
10955 + asm volatile("cpuid"
10956 : "=a" (max_amd_level)
10957 : "a" (0x80000000)
10958 : "ebx", "ecx", "edx");
10959 @@ -144,7 +144,7 @@ static void get_flags(void)
10960 if (max_amd_level >= 0x80000001 &&
10961 max_amd_level <= 0x8000ffff) {
10962 u32 eax = 0x80000001;
10963 - asm("cpuid"
10964 + asm volatile("cpuid"
10965 : "+a" (eax),
10966 "=c" (cpu.flags[6]),
10967 "=d" (cpu.flags[1])
10968 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10969 u32 ecx = MSR_K7_HWCR;
10970 u32 eax, edx;
10971
10972 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10973 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10974 eax &= ~(1 << 15);
10975 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10976 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10977
10978 get_flags(); /* Make sure it really did something */
10979 err = check_flags();
10980 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10981 u32 ecx = MSR_VIA_FCR;
10982 u32 eax, edx;
10983
10984 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10985 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10986 eax |= (1<<1)|(1<<7);
10987 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10988 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10989
10990 set_bit(X86_FEATURE_CX8, cpu.flags);
10991 err = check_flags();
10992 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10993 u32 eax, edx;
10994 u32 level = 1;
10995
10996 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10997 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10998 - asm("cpuid"
10999 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11000 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11001 + asm volatile("cpuid"
11002 : "+a" (level), "=d" (cpu.flags[0])
11003 : : "ecx", "ebx");
11004 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11005 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11006
11007 err = check_flags();
11008 }
11009 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
11010 index 944ce59..87ee37a 100644
11011 --- a/arch/x86/boot/header.S
11012 +++ b/arch/x86/boot/header.S
11013 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
11014 # single linked list of
11015 # struct setup_data
11016
11017 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
11018 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
11019
11020 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
11021 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
11022 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
11023 +#else
11024 #define VO_INIT_SIZE (VO__end - VO__text)
11025 +#endif
11026 #if ZO_INIT_SIZE > VO_INIT_SIZE
11027 #define INIT_SIZE ZO_INIT_SIZE
11028 #else
11029 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
11030 index db75d07..8e6d0af 100644
11031 --- a/arch/x86/boot/memory.c
11032 +++ b/arch/x86/boot/memory.c
11033 @@ -19,7 +19,7 @@
11034
11035 static int detect_memory_e820(void)
11036 {
11037 - int count = 0;
11038 + unsigned int count = 0;
11039 struct biosregs ireg, oreg;
11040 struct e820entry *desc = boot_params.e820_map;
11041 static struct e820entry buf; /* static so it is zeroed */
11042 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
11043 index 11e8c6e..fdbb1ed 100644
11044 --- a/arch/x86/boot/video-vesa.c
11045 +++ b/arch/x86/boot/video-vesa.c
11046 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
11047
11048 boot_params.screen_info.vesapm_seg = oreg.es;
11049 boot_params.screen_info.vesapm_off = oreg.di;
11050 + boot_params.screen_info.vesapm_size = oreg.cx;
11051 }
11052
11053 /*
11054 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
11055 index 43eda28..5ab5fdb 100644
11056 --- a/arch/x86/boot/video.c
11057 +++ b/arch/x86/boot/video.c
11058 @@ -96,7 +96,7 @@ static void store_mode_params(void)
11059 static unsigned int get_entry(void)
11060 {
11061 char entry_buf[4];
11062 - int i, len = 0;
11063 + unsigned int i, len = 0;
11064 int key;
11065 unsigned int v;
11066
11067 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
11068 index 5b577d5..3c1fed4 100644
11069 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
11070 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
11071 @@ -8,6 +8,8 @@
11072 * including this sentence is retained in full.
11073 */
11074
11075 +#include <asm/alternative-asm.h>
11076 +
11077 .extern crypto_ft_tab
11078 .extern crypto_it_tab
11079 .extern crypto_fl_tab
11080 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
11081 je B192; \
11082 leaq 32(r9),r9;
11083
11084 +#define ret pax_force_retaddr 0, 1; ret
11085 +
11086 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
11087 movq r1,r2; \
11088 movq r3,r4; \
11089 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
11090 index 3470624..201259d 100644
11091 --- a/arch/x86/crypto/aesni-intel_asm.S
11092 +++ b/arch/x86/crypto/aesni-intel_asm.S
11093 @@ -31,6 +31,7 @@
11094
11095 #include <linux/linkage.h>
11096 #include <asm/inst.h>
11097 +#include <asm/alternative-asm.h>
11098
11099 #ifdef __x86_64__
11100 .data
11101 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
11102 pop %r14
11103 pop %r13
11104 pop %r12
11105 + pax_force_retaddr 0, 1
11106 ret
11107 +ENDPROC(aesni_gcm_dec)
11108
11109
11110 /*****************************************************************************
11111 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
11112 pop %r14
11113 pop %r13
11114 pop %r12
11115 + pax_force_retaddr 0, 1
11116 ret
11117 +ENDPROC(aesni_gcm_enc)
11118
11119 #endif
11120
11121 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
11122 pxor %xmm1, %xmm0
11123 movaps %xmm0, (TKEYP)
11124 add $0x10, TKEYP
11125 + pax_force_retaddr_bts
11126 ret
11127
11128 .align 4
11129 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
11130 shufps $0b01001110, %xmm2, %xmm1
11131 movaps %xmm1, 0x10(TKEYP)
11132 add $0x20, TKEYP
11133 + pax_force_retaddr_bts
11134 ret
11135
11136 .align 4
11137 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
11138
11139 movaps %xmm0, (TKEYP)
11140 add $0x10, TKEYP
11141 + pax_force_retaddr_bts
11142 ret
11143
11144 .align 4
11145 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
11146 pxor %xmm1, %xmm2
11147 movaps %xmm2, (TKEYP)
11148 add $0x10, TKEYP
11149 + pax_force_retaddr_bts
11150 ret
11151
11152 /*
11153 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
11154 #ifndef __x86_64__
11155 popl KEYP
11156 #endif
11157 + pax_force_retaddr 0, 1
11158 ret
11159 +ENDPROC(aesni_set_key)
11160
11161 /*
11162 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
11163 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
11164 popl KLEN
11165 popl KEYP
11166 #endif
11167 + pax_force_retaddr 0, 1
11168 ret
11169 +ENDPROC(aesni_enc)
11170
11171 /*
11172 * _aesni_enc1: internal ABI
11173 @@ -1959,6 +1972,7 @@ _aesni_enc1:
11174 AESENC KEY STATE
11175 movaps 0x70(TKEYP), KEY
11176 AESENCLAST KEY STATE
11177 + pax_force_retaddr_bts
11178 ret
11179
11180 /*
11181 @@ -2067,6 +2081,7 @@ _aesni_enc4:
11182 AESENCLAST KEY STATE2
11183 AESENCLAST KEY STATE3
11184 AESENCLAST KEY STATE4
11185 + pax_force_retaddr_bts
11186 ret
11187
11188 /*
11189 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
11190 popl KLEN
11191 popl KEYP
11192 #endif
11193 + pax_force_retaddr 0, 1
11194 ret
11195 +ENDPROC(aesni_dec)
11196
11197 /*
11198 * _aesni_dec1: internal ABI
11199 @@ -2146,6 +2163,7 @@ _aesni_dec1:
11200 AESDEC KEY STATE
11201 movaps 0x70(TKEYP), KEY
11202 AESDECLAST KEY STATE
11203 + pax_force_retaddr_bts
11204 ret
11205
11206 /*
11207 @@ -2254,6 +2272,7 @@ _aesni_dec4:
11208 AESDECLAST KEY STATE2
11209 AESDECLAST KEY STATE3
11210 AESDECLAST KEY STATE4
11211 + pax_force_retaddr_bts
11212 ret
11213
11214 /*
11215 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
11216 popl KEYP
11217 popl LEN
11218 #endif
11219 + pax_force_retaddr 0, 1
11220 ret
11221 +ENDPROC(aesni_ecb_enc)
11222
11223 /*
11224 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11225 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
11226 popl KEYP
11227 popl LEN
11228 #endif
11229 + pax_force_retaddr 0, 1
11230 ret
11231 +ENDPROC(aesni_ecb_dec)
11232
11233 /*
11234 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11235 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
11236 popl LEN
11237 popl IVP
11238 #endif
11239 + pax_force_retaddr 0, 1
11240 ret
11241 +ENDPROC(aesni_cbc_enc)
11242
11243 /*
11244 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11245 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
11246 popl LEN
11247 popl IVP
11248 #endif
11249 + pax_force_retaddr 0, 1
11250 ret
11251 +ENDPROC(aesni_cbc_dec)
11252
11253 #ifdef __x86_64__
11254 .align 16
11255 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
11256 mov $1, TCTR_LOW
11257 MOVQ_R64_XMM TCTR_LOW INC
11258 MOVQ_R64_XMM CTR TCTR_LOW
11259 + pax_force_retaddr_bts
11260 ret
11261
11262 /*
11263 @@ -2554,6 +2582,7 @@ _aesni_inc:
11264 .Linc_low:
11265 movaps CTR, IV
11266 PSHUFB_XMM BSWAP_MASK IV
11267 + pax_force_retaddr_bts
11268 ret
11269
11270 /*
11271 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
11272 .Lctr_enc_ret:
11273 movups IV, (IVP)
11274 .Lctr_enc_just_ret:
11275 + pax_force_retaddr 0, 1
11276 ret
11277 +ENDPROC(aesni_ctr_enc)
11278 #endif
11279 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11280 index 391d245..67f35c2 100644
11281 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11282 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11283 @@ -20,6 +20,8 @@
11284 *
11285 */
11286
11287 +#include <asm/alternative-asm.h>
11288 +
11289 .file "blowfish-x86_64-asm.S"
11290 .text
11291
11292 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
11293 jnz __enc_xor;
11294
11295 write_block();
11296 + pax_force_retaddr 0, 1
11297 ret;
11298 __enc_xor:
11299 xor_block();
11300 + pax_force_retaddr 0, 1
11301 ret;
11302
11303 .align 8
11304 @@ -188,6 +192,7 @@ blowfish_dec_blk:
11305
11306 movq %r11, %rbp;
11307
11308 + pax_force_retaddr 0, 1
11309 ret;
11310
11311 /**********************************************************************
11312 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
11313
11314 popq %rbx;
11315 popq %rbp;
11316 + pax_force_retaddr 0, 1
11317 ret;
11318
11319 __enc_xor4:
11320 @@ -349,6 +355,7 @@ __enc_xor4:
11321
11322 popq %rbx;
11323 popq %rbp;
11324 + pax_force_retaddr 0, 1
11325 ret;
11326
11327 .align 8
11328 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
11329 popq %rbx;
11330 popq %rbp;
11331
11332 + pax_force_retaddr 0, 1
11333 ret;
11334
11335 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11336 index 0b33743..7a56206 100644
11337 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11338 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11339 @@ -20,6 +20,8 @@
11340 *
11341 */
11342
11343 +#include <asm/alternative-asm.h>
11344 +
11345 .file "camellia-x86_64-asm_64.S"
11346 .text
11347
11348 @@ -229,12 +231,14 @@ __enc_done:
11349 enc_outunpack(mov, RT1);
11350
11351 movq RRBP, %rbp;
11352 + pax_force_retaddr 0, 1
11353 ret;
11354
11355 __enc_xor:
11356 enc_outunpack(xor, RT1);
11357
11358 movq RRBP, %rbp;
11359 + pax_force_retaddr 0, 1
11360 ret;
11361
11362 .global camellia_dec_blk;
11363 @@ -275,6 +279,7 @@ __dec_rounds16:
11364 dec_outunpack();
11365
11366 movq RRBP, %rbp;
11367 + pax_force_retaddr 0, 1
11368 ret;
11369
11370 /**********************************************************************
11371 @@ -468,6 +473,7 @@ __enc2_done:
11372
11373 movq RRBP, %rbp;
11374 popq %rbx;
11375 + pax_force_retaddr 0, 1
11376 ret;
11377
11378 __enc2_xor:
11379 @@ -475,6 +481,7 @@ __enc2_xor:
11380
11381 movq RRBP, %rbp;
11382 popq %rbx;
11383 + pax_force_retaddr 0, 1
11384 ret;
11385
11386 .global camellia_dec_blk_2way;
11387 @@ -517,4 +524,5 @@ __dec2_rounds16:
11388
11389 movq RRBP, %rbp;
11390 movq RXOR, %rbx;
11391 + pax_force_retaddr 0, 1
11392 ret;
11393 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11394 index 15b00ac..2071784 100644
11395 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11396 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11397 @@ -23,6 +23,8 @@
11398 *
11399 */
11400
11401 +#include <asm/alternative-asm.h>
11402 +
11403 .file "cast5-avx-x86_64-asm_64.S"
11404
11405 .extern cast_s1
11406 @@ -281,6 +283,7 @@ __skip_enc:
11407 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11408 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11409
11410 + pax_force_retaddr 0, 1
11411 ret;
11412
11413 .align 16
11414 @@ -353,6 +356,7 @@ __dec_tail:
11415 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11416 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11417
11418 + pax_force_retaddr 0, 1
11419 ret;
11420
11421 __skip_dec:
11422 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
11423 vmovdqu RR4, (6*4*4)(%r11);
11424 vmovdqu RL4, (7*4*4)(%r11);
11425
11426 + pax_force_retaddr
11427 ret;
11428
11429 .align 16
11430 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
11431 vmovdqu RR4, (6*4*4)(%r11);
11432 vmovdqu RL4, (7*4*4)(%r11);
11433
11434 + pax_force_retaddr
11435 ret;
11436
11437 .align 16
11438 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
11439
11440 popq %r12;
11441
11442 + pax_force_retaddr
11443 ret;
11444
11445 .align 16
11446 @@ -555,4 +562,5 @@ cast5_ctr_16way:
11447
11448 popq %r12;
11449
11450 + pax_force_retaddr
11451 ret;
11452 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11453 index 2569d0d..637c289 100644
11454 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11455 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11456 @@ -23,6 +23,8 @@
11457 *
11458 */
11459
11460 +#include <asm/alternative-asm.h>
11461 +
11462 #include "glue_helper-asm-avx.S"
11463
11464 .file "cast6-avx-x86_64-asm_64.S"
11465 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
11466 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11467 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11468
11469 + pax_force_retaddr 0, 1
11470 ret;
11471
11472 .align 8
11473 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
11474 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11475 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11476
11477 + pax_force_retaddr 0, 1
11478 ret;
11479
11480 .align 8
11481 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
11482
11483 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11484
11485 + pax_force_retaddr
11486 ret;
11487
11488 .align 8
11489 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
11490
11491 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11492
11493 + pax_force_retaddr
11494 ret;
11495
11496 .align 8
11497 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
11498
11499 popq %r12;
11500
11501 + pax_force_retaddr
11502 ret;
11503
11504 .align 8
11505 @@ -436,4 +443,5 @@ cast6_ctr_8way:
11506
11507 popq %r12;
11508
11509 + pax_force_retaddr
11510 ret;
11511 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11512 index 6214a9b..1f4fc9a 100644
11513 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11514 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11515 @@ -1,3 +1,5 @@
11516 +#include <asm/alternative-asm.h>
11517 +
11518 # enter ECRYPT_encrypt_bytes
11519 .text
11520 .p2align 5
11521 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
11522 add %r11,%rsp
11523 mov %rdi,%rax
11524 mov %rsi,%rdx
11525 + pax_force_retaddr 0, 1
11526 ret
11527 # bytesatleast65:
11528 ._bytesatleast65:
11529 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
11530 add %r11,%rsp
11531 mov %rdi,%rax
11532 mov %rsi,%rdx
11533 + pax_force_retaddr
11534 ret
11535 # enter ECRYPT_ivsetup
11536 .text
11537 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
11538 add %r11,%rsp
11539 mov %rdi,%rax
11540 mov %rsi,%rdx
11541 + pax_force_retaddr
11542 ret
11543 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11544 index 02b0e9f..cf4cf5c 100644
11545 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11546 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11547 @@ -24,6 +24,8 @@
11548 *
11549 */
11550
11551 +#include <asm/alternative-asm.h>
11552 +
11553 #include "glue_helper-asm-avx.S"
11554
11555 .file "serpent-avx-x86_64-asm_64.S"
11556 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
11557 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11558 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11559
11560 + pax_force_retaddr
11561 ret;
11562
11563 .align 8
11564 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
11565 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11566 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11567
11568 + pax_force_retaddr
11569 ret;
11570
11571 .align 8
11572 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
11573
11574 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11575
11576 + pax_force_retaddr
11577 ret;
11578
11579 .align 8
11580 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
11581
11582 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11583
11584 + pax_force_retaddr
11585 ret;
11586
11587 .align 8
11588 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
11589
11590 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11591
11592 + pax_force_retaddr
11593 ret;
11594
11595 .align 8
11596 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
11597
11598 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11599
11600 + pax_force_retaddr
11601 ret;
11602 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11603 index 3ee1ff0..cbc568b 100644
11604 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11605 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11606 @@ -24,6 +24,8 @@
11607 *
11608 */
11609
11610 +#include <asm/alternative-asm.h>
11611 +
11612 .file "serpent-sse2-x86_64-asm_64.S"
11613 .text
11614
11615 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
11616 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11617 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11618
11619 + pax_force_retaddr
11620 ret;
11621
11622 __enc_xor8:
11623 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11624 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11625
11626 + pax_force_retaddr
11627 ret;
11628
11629 .align 8
11630 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
11631 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11632 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11633
11634 + pax_force_retaddr
11635 ret;
11636 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11637 index 49d6987..df66bd4 100644
11638 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11639 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11640 @@ -28,6 +28,8 @@
11641 * (at your option) any later version.
11642 */
11643
11644 +#include <asm/alternative-asm.h>
11645 +
11646 #define CTX %rdi // arg1
11647 #define BUF %rsi // arg2
11648 #define CNT %rdx // arg3
11649 @@ -104,6 +106,7 @@
11650 pop %r12
11651 pop %rbp
11652 pop %rbx
11653 + pax_force_retaddr 0, 1
11654 ret
11655
11656 .size \name, .-\name
11657 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11658 index ebac16b..8092eb9 100644
11659 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11660 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11661 @@ -23,6 +23,8 @@
11662 *
11663 */
11664
11665 +#include <asm/alternative-asm.h>
11666 +
11667 #include "glue_helper-asm-avx.S"
11668
11669 .file "twofish-avx-x86_64-asm_64.S"
11670 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
11671 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11672 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11673
11674 + pax_force_retaddr 0, 1
11675 ret;
11676
11677 .align 8
11678 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
11679 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11680 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11681
11682 + pax_force_retaddr 0, 1
11683 ret;
11684
11685 .align 8
11686 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
11687
11688 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11689
11690 + pax_force_retaddr 0, 1
11691 ret;
11692
11693 .align 8
11694 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
11695
11696 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11697
11698 + pax_force_retaddr 0, 1
11699 ret;
11700
11701 .align 8
11702 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
11703
11704 popq %r12;
11705
11706 + pax_force_retaddr 0, 1
11707 ret;
11708
11709 .align 8
11710 @@ -420,4 +427,5 @@ twofish_ctr_8way:
11711
11712 popq %r12;
11713
11714 + pax_force_retaddr 0, 1
11715 ret;
11716 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11717 index 5b012a2..36d5364 100644
11718 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11719 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11720 @@ -20,6 +20,8 @@
11721 *
11722 */
11723
11724 +#include <asm/alternative-asm.h>
11725 +
11726 .file "twofish-x86_64-asm-3way.S"
11727 .text
11728
11729 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
11730 popq %r13;
11731 popq %r14;
11732 popq %r15;
11733 + pax_force_retaddr 0, 1
11734 ret;
11735
11736 __enc_xor3:
11737 @@ -271,6 +274,7 @@ __enc_xor3:
11738 popq %r13;
11739 popq %r14;
11740 popq %r15;
11741 + pax_force_retaddr 0, 1
11742 ret;
11743
11744 .global twofish_dec_blk_3way
11745 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
11746 popq %r13;
11747 popq %r14;
11748 popq %r15;
11749 + pax_force_retaddr 0, 1
11750 ret;
11751
11752 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11753 index 7bcf3fc..f53832f 100644
11754 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11755 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11756 @@ -21,6 +21,7 @@
11757 .text
11758
11759 #include <asm/asm-offsets.h>
11760 +#include <asm/alternative-asm.h>
11761
11762 #define a_offset 0
11763 #define b_offset 4
11764 @@ -268,6 +269,7 @@ twofish_enc_blk:
11765
11766 popq R1
11767 movq $1,%rax
11768 + pax_force_retaddr 0, 1
11769 ret
11770
11771 twofish_dec_blk:
11772 @@ -319,4 +321,5 @@ twofish_dec_blk:
11773
11774 popq R1
11775 movq $1,%rax
11776 + pax_force_retaddr 0, 1
11777 ret
11778 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11779 index a703af1..f5b9c36 100644
11780 --- a/arch/x86/ia32/ia32_aout.c
11781 +++ b/arch/x86/ia32/ia32_aout.c
11782 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11783 unsigned long dump_start, dump_size;
11784 struct user32 dump;
11785
11786 + memset(&dump, 0, sizeof(dump));
11787 +
11788 fs = get_fs();
11789 set_fs(KERNEL_DS);
11790 has_dumped = 1;
11791 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11792 index a1daf4a..f8c4537 100644
11793 --- a/arch/x86/ia32/ia32_signal.c
11794 +++ b/arch/x86/ia32/ia32_signal.c
11795 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
11796 sp -= frame_size;
11797 /* Align the stack pointer according to the i386 ABI,
11798 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11799 - sp = ((sp + 4) & -16ul) - 4;
11800 + sp = ((sp - 12) & -16ul) - 4;
11801 return (void __user *) sp;
11802 }
11803
11804 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
11805 * These are actually not used anymore, but left because some
11806 * gdb versions depend on them as a marker.
11807 */
11808 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11809 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11810 } put_user_catch(err);
11811
11812 if (err)
11813 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11814 0xb8,
11815 __NR_ia32_rt_sigreturn,
11816 0x80cd,
11817 - 0,
11818 + 0
11819 };
11820
11821 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
11822 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11823
11824 if (ka->sa.sa_flags & SA_RESTORER)
11825 restorer = ka->sa.sa_restorer;
11826 + else if (current->mm->context.vdso)
11827 + /* Return stub is in 32bit vsyscall page */
11828 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11829 else
11830 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11831 - rt_sigreturn);
11832 + restorer = &frame->retcode;
11833 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11834
11835 /*
11836 * Not actually used anymore, but left because some gdb
11837 * versions need it.
11838 */
11839 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11840 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11841 } put_user_catch(err);
11842
11843 err |= copy_siginfo_to_user32(&frame->info, info);
11844 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11845 index 142c4ce..19b683f 100644
11846 --- a/arch/x86/ia32/ia32entry.S
11847 +++ b/arch/x86/ia32/ia32entry.S
11848 @@ -15,8 +15,10 @@
11849 #include <asm/irqflags.h>
11850 #include <asm/asm.h>
11851 #include <asm/smap.h>
11852 +#include <asm/pgtable.h>
11853 #include <linux/linkage.h>
11854 #include <linux/err.h>
11855 +#include <asm/alternative-asm.h>
11856
11857 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11858 #include <linux/elf-em.h>
11859 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11860 ENDPROC(native_irq_enable_sysexit)
11861 #endif
11862
11863 + .macro pax_enter_kernel_user
11864 + pax_set_fptr_mask
11865 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11866 + call pax_enter_kernel_user
11867 +#endif
11868 + .endm
11869 +
11870 + .macro pax_exit_kernel_user
11871 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11872 + call pax_exit_kernel_user
11873 +#endif
11874 +#ifdef CONFIG_PAX_RANDKSTACK
11875 + pushq %rax
11876 + pushq %r11
11877 + call pax_randomize_kstack
11878 + popq %r11
11879 + popq %rax
11880 +#endif
11881 + .endm
11882 +
11883 +.macro pax_erase_kstack
11884 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11885 + call pax_erase_kstack
11886 +#endif
11887 +.endm
11888 +
11889 /*
11890 * 32bit SYSENTER instruction entry.
11891 *
11892 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11893 CFI_REGISTER rsp,rbp
11894 SWAPGS_UNSAFE_STACK
11895 movq PER_CPU_VAR(kernel_stack), %rsp
11896 - addq $(KERNEL_STACK_OFFSET),%rsp
11897 - /*
11898 - * No need to follow this irqs on/off section: the syscall
11899 - * disabled irqs, here we enable it straight after entry:
11900 - */
11901 - ENABLE_INTERRUPTS(CLBR_NONE)
11902 movl %ebp,%ebp /* zero extension */
11903 pushq_cfi $__USER32_DS
11904 /*CFI_REL_OFFSET ss,0*/
11905 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11906 CFI_REL_OFFSET rsp,0
11907 pushfq_cfi
11908 /*CFI_REL_OFFSET rflags,0*/
11909 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11910 - CFI_REGISTER rip,r10
11911 + orl $X86_EFLAGS_IF,(%rsp)
11912 + GET_THREAD_INFO(%r11)
11913 + movl TI_sysenter_return(%r11), %r11d
11914 + CFI_REGISTER rip,r11
11915 pushq_cfi $__USER32_CS
11916 /*CFI_REL_OFFSET cs,0*/
11917 movl %eax, %eax
11918 - pushq_cfi %r10
11919 + pushq_cfi %r11
11920 CFI_REL_OFFSET rip,0
11921 pushq_cfi %rax
11922 cld
11923 SAVE_ARGS 0,1,0
11924 + pax_enter_kernel_user
11925 +
11926 +#ifdef CONFIG_PAX_RANDKSTACK
11927 + pax_erase_kstack
11928 +#endif
11929 +
11930 + /*
11931 + * No need to follow this irqs on/off section: the syscall
11932 + * disabled irqs, here we enable it straight after entry:
11933 + */
11934 + ENABLE_INTERRUPTS(CLBR_NONE)
11935 /* no need to do an access_ok check here because rbp has been
11936 32bit zero extended */
11937 +
11938 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11939 + mov $PAX_USER_SHADOW_BASE,%r11
11940 + add %r11,%rbp
11941 +#endif
11942 +
11943 ASM_STAC
11944 1: movl (%rbp),%ebp
11945 _ASM_EXTABLE(1b,ia32_badarg)
11946 ASM_CLAC
11947 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11948 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11949 + GET_THREAD_INFO(%r11)
11950 + orl $TS_COMPAT,TI_status(%r11)
11951 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11952 CFI_REMEMBER_STATE
11953 jnz sysenter_tracesys
11954 cmpq $(IA32_NR_syscalls-1),%rax
11955 @@ -162,12 +204,15 @@ sysenter_do_call:
11956 sysenter_dispatch:
11957 call *ia32_sys_call_table(,%rax,8)
11958 movq %rax,RAX-ARGOFFSET(%rsp)
11959 + GET_THREAD_INFO(%r11)
11960 DISABLE_INTERRUPTS(CLBR_NONE)
11961 TRACE_IRQS_OFF
11962 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11963 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11964 jnz sysexit_audit
11965 sysexit_from_sys_call:
11966 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11967 + pax_exit_kernel_user
11968 + pax_erase_kstack
11969 + andl $~TS_COMPAT,TI_status(%r11)
11970 /* clear IF, that popfq doesn't enable interrupts early */
11971 andl $~0x200,EFLAGS-R11(%rsp)
11972 movl RIP-R11(%rsp),%edx /* User %eip */
11973 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11974 movl %eax,%esi /* 2nd arg: syscall number */
11975 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11976 call __audit_syscall_entry
11977 +
11978 + pax_erase_kstack
11979 +
11980 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11981 cmpq $(IA32_NR_syscalls-1),%rax
11982 ja ia32_badsys
11983 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11984 .endm
11985
11986 .macro auditsys_exit exit
11987 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11988 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11989 jnz ia32_ret_from_sys_call
11990 TRACE_IRQS_ON
11991 ENABLE_INTERRUPTS(CLBR_NONE)
11992 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11993 1: setbe %al /* 1 if error, 0 if not */
11994 movzbl %al,%edi /* zero-extend that into %edi */
11995 call __audit_syscall_exit
11996 + GET_THREAD_INFO(%r11)
11997 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11998 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11999 DISABLE_INTERRUPTS(CLBR_NONE)
12000 TRACE_IRQS_OFF
12001 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12002 + testl %edi,TI_flags(%r11)
12003 jz \exit
12004 CLEAR_RREGS -ARGOFFSET
12005 jmp int_with_check
12006 @@ -237,7 +286,7 @@ sysexit_audit:
12007
12008 sysenter_tracesys:
12009 #ifdef CONFIG_AUDITSYSCALL
12010 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12011 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12012 jz sysenter_auditsys
12013 #endif
12014 SAVE_REST
12015 @@ -249,6 +298,9 @@ sysenter_tracesys:
12016 RESTORE_REST
12017 cmpq $(IA32_NR_syscalls-1),%rax
12018 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
12019 +
12020 + pax_erase_kstack
12021 +
12022 jmp sysenter_do_call
12023 CFI_ENDPROC
12024 ENDPROC(ia32_sysenter_target)
12025 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
12026 ENTRY(ia32_cstar_target)
12027 CFI_STARTPROC32 simple
12028 CFI_SIGNAL_FRAME
12029 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
12030 + CFI_DEF_CFA rsp,0
12031 CFI_REGISTER rip,rcx
12032 /*CFI_REGISTER rflags,r11*/
12033 SWAPGS_UNSAFE_STACK
12034 movl %esp,%r8d
12035 CFI_REGISTER rsp,r8
12036 movq PER_CPU_VAR(kernel_stack),%rsp
12037 + SAVE_ARGS 8*6,0,0
12038 + pax_enter_kernel_user
12039 +
12040 +#ifdef CONFIG_PAX_RANDKSTACK
12041 + pax_erase_kstack
12042 +#endif
12043 +
12044 /*
12045 * No need to follow this irqs on/off section: the syscall
12046 * disabled irqs and here we enable it straight after entry:
12047 */
12048 ENABLE_INTERRUPTS(CLBR_NONE)
12049 - SAVE_ARGS 8,0,0
12050 movl %eax,%eax /* zero extension */
12051 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
12052 movq %rcx,RIP-ARGOFFSET(%rsp)
12053 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
12054 /* no need to do an access_ok check here because r8 has been
12055 32bit zero extended */
12056 /* hardware stack frame is complete now */
12057 +
12058 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12059 + mov $PAX_USER_SHADOW_BASE,%r11
12060 + add %r11,%r8
12061 +#endif
12062 +
12063 ASM_STAC
12064 1: movl (%r8),%r9d
12065 _ASM_EXTABLE(1b,ia32_badarg)
12066 ASM_CLAC
12067 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12068 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12069 + GET_THREAD_INFO(%r11)
12070 + orl $TS_COMPAT,TI_status(%r11)
12071 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12072 CFI_REMEMBER_STATE
12073 jnz cstar_tracesys
12074 cmpq $IA32_NR_syscalls-1,%rax
12075 @@ -319,12 +384,15 @@ cstar_do_call:
12076 cstar_dispatch:
12077 call *ia32_sys_call_table(,%rax,8)
12078 movq %rax,RAX-ARGOFFSET(%rsp)
12079 + GET_THREAD_INFO(%r11)
12080 DISABLE_INTERRUPTS(CLBR_NONE)
12081 TRACE_IRQS_OFF
12082 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12083 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12084 jnz sysretl_audit
12085 sysretl_from_sys_call:
12086 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12087 + pax_exit_kernel_user
12088 + pax_erase_kstack
12089 + andl $~TS_COMPAT,TI_status(%r11)
12090 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
12091 movl RIP-ARGOFFSET(%rsp),%ecx
12092 CFI_REGISTER rip,rcx
12093 @@ -352,7 +420,7 @@ sysretl_audit:
12094
12095 cstar_tracesys:
12096 #ifdef CONFIG_AUDITSYSCALL
12097 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12098 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12099 jz cstar_auditsys
12100 #endif
12101 xchgl %r9d,%ebp
12102 @@ -366,6 +434,9 @@ cstar_tracesys:
12103 xchgl %ebp,%r9d
12104 cmpq $(IA32_NR_syscalls-1),%rax
12105 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
12106 +
12107 + pax_erase_kstack
12108 +
12109 jmp cstar_do_call
12110 END(ia32_cstar_target)
12111
12112 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
12113 CFI_REL_OFFSET rip,RIP-RIP
12114 PARAVIRT_ADJUST_EXCEPTION_FRAME
12115 SWAPGS
12116 - /*
12117 - * No need to follow this irqs on/off section: the syscall
12118 - * disabled irqs and here we enable it straight after entry:
12119 - */
12120 - ENABLE_INTERRUPTS(CLBR_NONE)
12121 movl %eax,%eax
12122 pushq_cfi %rax
12123 cld
12124 /* note the registers are not zero extended to the sf.
12125 this could be a problem. */
12126 SAVE_ARGS 0,1,0
12127 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12128 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12129 + pax_enter_kernel_user
12130 +
12131 +#ifdef CONFIG_PAX_RANDKSTACK
12132 + pax_erase_kstack
12133 +#endif
12134 +
12135 + /*
12136 + * No need to follow this irqs on/off section: the syscall
12137 + * disabled irqs and here we enable it straight after entry:
12138 + */
12139 + ENABLE_INTERRUPTS(CLBR_NONE)
12140 + GET_THREAD_INFO(%r11)
12141 + orl $TS_COMPAT,TI_status(%r11)
12142 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12143 jnz ia32_tracesys
12144 cmpq $(IA32_NR_syscalls-1),%rax
12145 ja ia32_badsys
12146 @@ -442,6 +520,9 @@ ia32_tracesys:
12147 RESTORE_REST
12148 cmpq $(IA32_NR_syscalls-1),%rax
12149 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
12150 +
12151 + pax_erase_kstack
12152 +
12153 jmp ia32_do_call
12154 END(ia32_syscall)
12155
12156 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
12157 index d0b689b..6811ddc 100644
12158 --- a/arch/x86/ia32/sys_ia32.c
12159 +++ b/arch/x86/ia32/sys_ia32.c
12160 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
12161 */
12162 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
12163 {
12164 - typeof(ubuf->st_uid) uid = 0;
12165 - typeof(ubuf->st_gid) gid = 0;
12166 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
12167 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
12168 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
12169 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
12170 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
12171 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12172 mm_segment_t old_fs = get_fs();
12173
12174 set_fs(KERNEL_DS);
12175 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
12176 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
12177 set_fs(old_fs);
12178 if (put_compat_timespec(&t, interval))
12179 return -EFAULT;
12180 @@ -313,13 +313,13 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12181 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
12182 compat_size_t sigsetsize)
12183 {
12184 - sigset_t s;
12185 + sigset_t s = { };
12186 compat_sigset_t s32;
12187 int ret;
12188 mm_segment_t old_fs = get_fs();
12189
12190 set_fs(KERNEL_DS);
12191 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
12192 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
12193 set_fs(old_fs);
12194 if (!ret) {
12195 switch (_NSIG_WORDS) {
12196 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
12197 if (copy_siginfo_from_user32(&info, uinfo))
12198 return -EFAULT;
12199 set_fs(KERNEL_DS);
12200 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
12201 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
12202 set_fs(old_fs);
12203 return ret;
12204 }
12205 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
12206 return -EFAULT;
12207
12208 set_fs(KERNEL_DS);
12209 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
12210 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
12211 count);
12212 set_fs(old_fs);
12213
12214 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
12215 index 372231c..a5aa1a1 100644
12216 --- a/arch/x86/include/asm/alternative-asm.h
12217 +++ b/arch/x86/include/asm/alternative-asm.h
12218 @@ -18,6 +18,45 @@
12219 .endm
12220 #endif
12221
12222 +#ifdef KERNEXEC_PLUGIN
12223 + .macro pax_force_retaddr_bts rip=0
12224 + btsq $63,\rip(%rsp)
12225 + .endm
12226 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
12227 + .macro pax_force_retaddr rip=0, reload=0
12228 + btsq $63,\rip(%rsp)
12229 + .endm
12230 + .macro pax_force_fptr ptr
12231 + btsq $63,\ptr
12232 + .endm
12233 + .macro pax_set_fptr_mask
12234 + .endm
12235 +#endif
12236 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
12237 + .macro pax_force_retaddr rip=0, reload=0
12238 + .if \reload
12239 + pax_set_fptr_mask
12240 + .endif
12241 + orq %r10,\rip(%rsp)
12242 + .endm
12243 + .macro pax_force_fptr ptr
12244 + orq %r10,\ptr
12245 + .endm
12246 + .macro pax_set_fptr_mask
12247 + movabs $0x8000000000000000,%r10
12248 + .endm
12249 +#endif
12250 +#else
12251 + .macro pax_force_retaddr rip=0, reload=0
12252 + .endm
12253 + .macro pax_force_fptr ptr
12254 + .endm
12255 + .macro pax_force_retaddr_bts rip=0
12256 + .endm
12257 + .macro pax_set_fptr_mask
12258 + .endm
12259 +#endif
12260 +
12261 .macro altinstruction_entry orig alt feature orig_len alt_len
12262 .long \orig - .
12263 .long \alt - .
12264 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
12265 index 58ed6d9..f1cbe58 100644
12266 --- a/arch/x86/include/asm/alternative.h
12267 +++ b/arch/x86/include/asm/alternative.h
12268 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12269 ".pushsection .discard,\"aw\",@progbits\n" \
12270 DISCARD_ENTRY(1) \
12271 ".popsection\n" \
12272 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12273 + ".pushsection .altinstr_replacement, \"a\"\n" \
12274 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
12275 ".popsection"
12276
12277 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12278 DISCARD_ENTRY(1) \
12279 DISCARD_ENTRY(2) \
12280 ".popsection\n" \
12281 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12282 + ".pushsection .altinstr_replacement, \"a\"\n" \
12283 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
12284 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
12285 ".popsection"
12286 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
12287 index 3388034..050f0b9 100644
12288 --- a/arch/x86/include/asm/apic.h
12289 +++ b/arch/x86/include/asm/apic.h
12290 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
12291
12292 #ifdef CONFIG_X86_LOCAL_APIC
12293
12294 -extern unsigned int apic_verbosity;
12295 +extern int apic_verbosity;
12296 extern int local_apic_timer_c2_ok;
12297
12298 extern int disable_apic;
12299 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
12300 index 20370c6..a2eb9b0 100644
12301 --- a/arch/x86/include/asm/apm.h
12302 +++ b/arch/x86/include/asm/apm.h
12303 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12304 __asm__ __volatile__(APM_DO_ZERO_SEGS
12305 "pushl %%edi\n\t"
12306 "pushl %%ebp\n\t"
12307 - "lcall *%%cs:apm_bios_entry\n\t"
12308 + "lcall *%%ss:apm_bios_entry\n\t"
12309 "setc %%al\n\t"
12310 "popl %%ebp\n\t"
12311 "popl %%edi\n\t"
12312 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12313 __asm__ __volatile__(APM_DO_ZERO_SEGS
12314 "pushl %%edi\n\t"
12315 "pushl %%ebp\n\t"
12316 - "lcall *%%cs:apm_bios_entry\n\t"
12317 + "lcall *%%ss:apm_bios_entry\n\t"
12318 "setc %%bl\n\t"
12319 "popl %%ebp\n\t"
12320 "popl %%edi\n\t"
12321 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12322 index 722aa3b..3a0bb27 100644
12323 --- a/arch/x86/include/asm/atomic.h
12324 +++ b/arch/x86/include/asm/atomic.h
12325 @@ -22,7 +22,18 @@
12326 */
12327 static inline int atomic_read(const atomic_t *v)
12328 {
12329 - return (*(volatile int *)&(v)->counter);
12330 + return (*(volatile const int *)&(v)->counter);
12331 +}
12332 +
12333 +/**
12334 + * atomic_read_unchecked - read atomic variable
12335 + * @v: pointer of type atomic_unchecked_t
12336 + *
12337 + * Atomically reads the value of @v.
12338 + */
12339 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12340 +{
12341 + return (*(volatile const int *)&(v)->counter);
12342 }
12343
12344 /**
12345 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12346 }
12347
12348 /**
12349 + * atomic_set_unchecked - set atomic variable
12350 + * @v: pointer of type atomic_unchecked_t
12351 + * @i: required value
12352 + *
12353 + * Atomically sets the value of @v to @i.
12354 + */
12355 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12356 +{
12357 + v->counter = i;
12358 +}
12359 +
12360 +/**
12361 * atomic_add - add integer to atomic variable
12362 * @i: integer value to add
12363 * @v: pointer of type atomic_t
12364 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12365 */
12366 static inline void atomic_add(int i, atomic_t *v)
12367 {
12368 - asm volatile(LOCK_PREFIX "addl %1,%0"
12369 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12370 +
12371 +#ifdef CONFIG_PAX_REFCOUNT
12372 + "jno 0f\n"
12373 + LOCK_PREFIX "subl %1,%0\n"
12374 + "int $4\n0:\n"
12375 + _ASM_EXTABLE(0b, 0b)
12376 +#endif
12377 +
12378 + : "+m" (v->counter)
12379 + : "ir" (i));
12380 +}
12381 +
12382 +/**
12383 + * atomic_add_unchecked - add integer to atomic variable
12384 + * @i: integer value to add
12385 + * @v: pointer of type atomic_unchecked_t
12386 + *
12387 + * Atomically adds @i to @v.
12388 + */
12389 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12390 +{
12391 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12392 : "+m" (v->counter)
12393 : "ir" (i));
12394 }
12395 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12396 */
12397 static inline void atomic_sub(int i, atomic_t *v)
12398 {
12399 - asm volatile(LOCK_PREFIX "subl %1,%0"
12400 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12401 +
12402 +#ifdef CONFIG_PAX_REFCOUNT
12403 + "jno 0f\n"
12404 + LOCK_PREFIX "addl %1,%0\n"
12405 + "int $4\n0:\n"
12406 + _ASM_EXTABLE(0b, 0b)
12407 +#endif
12408 +
12409 + : "+m" (v->counter)
12410 + : "ir" (i));
12411 +}
12412 +
12413 +/**
12414 + * atomic_sub_unchecked - subtract integer from atomic variable
12415 + * @i: integer value to subtract
12416 + * @v: pointer of type atomic_unchecked_t
12417 + *
12418 + * Atomically subtracts @i from @v.
12419 + */
12420 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12421 +{
12422 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12423 : "+m" (v->counter)
12424 : "ir" (i));
12425 }
12426 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12427 {
12428 unsigned char c;
12429
12430 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12431 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12432 +
12433 +#ifdef CONFIG_PAX_REFCOUNT
12434 + "jno 0f\n"
12435 + LOCK_PREFIX "addl %2,%0\n"
12436 + "int $4\n0:\n"
12437 + _ASM_EXTABLE(0b, 0b)
12438 +#endif
12439 +
12440 + "sete %1\n"
12441 : "+m" (v->counter), "=qm" (c)
12442 : "ir" (i) : "memory");
12443 return c;
12444 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12445 */
12446 static inline void atomic_inc(atomic_t *v)
12447 {
12448 - asm volatile(LOCK_PREFIX "incl %0"
12449 + asm volatile(LOCK_PREFIX "incl %0\n"
12450 +
12451 +#ifdef CONFIG_PAX_REFCOUNT
12452 + "jno 0f\n"
12453 + LOCK_PREFIX "decl %0\n"
12454 + "int $4\n0:\n"
12455 + _ASM_EXTABLE(0b, 0b)
12456 +#endif
12457 +
12458 + : "+m" (v->counter));
12459 +}
12460 +
12461 +/**
12462 + * atomic_inc_unchecked - increment atomic variable
12463 + * @v: pointer of type atomic_unchecked_t
12464 + *
12465 + * Atomically increments @v by 1.
12466 + */
12467 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12468 +{
12469 + asm volatile(LOCK_PREFIX "incl %0\n"
12470 : "+m" (v->counter));
12471 }
12472
12473 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12474 */
12475 static inline void atomic_dec(atomic_t *v)
12476 {
12477 - asm volatile(LOCK_PREFIX "decl %0"
12478 + asm volatile(LOCK_PREFIX "decl %0\n"
12479 +
12480 +#ifdef CONFIG_PAX_REFCOUNT
12481 + "jno 0f\n"
12482 + LOCK_PREFIX "incl %0\n"
12483 + "int $4\n0:\n"
12484 + _ASM_EXTABLE(0b, 0b)
12485 +#endif
12486 +
12487 + : "+m" (v->counter));
12488 +}
12489 +
12490 +/**
12491 + * atomic_dec_unchecked - decrement atomic variable
12492 + * @v: pointer of type atomic_unchecked_t
12493 + *
12494 + * Atomically decrements @v by 1.
12495 + */
12496 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12497 +{
12498 + asm volatile(LOCK_PREFIX "decl %0\n"
12499 : "+m" (v->counter));
12500 }
12501
12502 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12503 {
12504 unsigned char c;
12505
12506 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12507 + asm volatile(LOCK_PREFIX "decl %0\n"
12508 +
12509 +#ifdef CONFIG_PAX_REFCOUNT
12510 + "jno 0f\n"
12511 + LOCK_PREFIX "incl %0\n"
12512 + "int $4\n0:\n"
12513 + _ASM_EXTABLE(0b, 0b)
12514 +#endif
12515 +
12516 + "sete %1\n"
12517 : "+m" (v->counter), "=qm" (c)
12518 : : "memory");
12519 return c != 0;
12520 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12521 {
12522 unsigned char c;
12523
12524 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12525 + asm volatile(LOCK_PREFIX "incl %0\n"
12526 +
12527 +#ifdef CONFIG_PAX_REFCOUNT
12528 + "jno 0f\n"
12529 + LOCK_PREFIX "decl %0\n"
12530 + "int $4\n0:\n"
12531 + _ASM_EXTABLE(0b, 0b)
12532 +#endif
12533 +
12534 + "sete %1\n"
12535 + : "+m" (v->counter), "=qm" (c)
12536 + : : "memory");
12537 + return c != 0;
12538 +}
12539 +
12540 +/**
12541 + * atomic_inc_and_test_unchecked - increment and test
12542 + * @v: pointer of type atomic_unchecked_t
12543 + *
12544 + * Atomically increments @v by 1
12545 + * and returns true if the result is zero, or false for all
12546 + * other cases.
12547 + */
12548 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12549 +{
12550 + unsigned char c;
12551 +
12552 + asm volatile(LOCK_PREFIX "incl %0\n"
12553 + "sete %1\n"
12554 : "+m" (v->counter), "=qm" (c)
12555 : : "memory");
12556 return c != 0;
12557 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12558 {
12559 unsigned char c;
12560
12561 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12562 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12563 +
12564 +#ifdef CONFIG_PAX_REFCOUNT
12565 + "jno 0f\n"
12566 + LOCK_PREFIX "subl %2,%0\n"
12567 + "int $4\n0:\n"
12568 + _ASM_EXTABLE(0b, 0b)
12569 +#endif
12570 +
12571 + "sets %1\n"
12572 : "+m" (v->counter), "=qm" (c)
12573 : "ir" (i) : "memory");
12574 return c;
12575 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12576 */
12577 static inline int atomic_add_return(int i, atomic_t *v)
12578 {
12579 + return i + xadd_check_overflow(&v->counter, i);
12580 +}
12581 +
12582 +/**
12583 + * atomic_add_return_unchecked - add integer and return
12584 + * @i: integer value to add
12585 + * @v: pointer of type atomic_unchecked_t
12586 + *
12587 + * Atomically adds @i to @v and returns @i + @v
12588 + */
12589 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12590 +{
12591 return i + xadd(&v->counter, i);
12592 }
12593
12594 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12595 }
12596
12597 #define atomic_inc_return(v) (atomic_add_return(1, v))
12598 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12599 +{
12600 + return atomic_add_return_unchecked(1, v);
12601 +}
12602 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12603
12604 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12605 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12606 return cmpxchg(&v->counter, old, new);
12607 }
12608
12609 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12610 +{
12611 + return cmpxchg(&v->counter, old, new);
12612 +}
12613 +
12614 static inline int atomic_xchg(atomic_t *v, int new)
12615 {
12616 return xchg(&v->counter, new);
12617 }
12618
12619 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12620 +{
12621 + return xchg(&v->counter, new);
12622 +}
12623 +
12624 /**
12625 * __atomic_add_unless - add unless the number is already a given value
12626 * @v: pointer of type atomic_t
12627 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12628 */
12629 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12630 {
12631 - int c, old;
12632 + int c, old, new;
12633 c = atomic_read(v);
12634 for (;;) {
12635 - if (unlikely(c == (u)))
12636 + if (unlikely(c == u))
12637 break;
12638 - old = atomic_cmpxchg((v), c, c + (a));
12639 +
12640 + asm volatile("addl %2,%0\n"
12641 +
12642 +#ifdef CONFIG_PAX_REFCOUNT
12643 + "jno 0f\n"
12644 + "subl %2,%0\n"
12645 + "int $4\n0:\n"
12646 + _ASM_EXTABLE(0b, 0b)
12647 +#endif
12648 +
12649 + : "=r" (new)
12650 + : "0" (c), "ir" (a));
12651 +
12652 + old = atomic_cmpxchg(v, c, new);
12653 if (likely(old == c))
12654 break;
12655 c = old;
12656 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12657 }
12658
12659 /**
12660 + * atomic_inc_not_zero_hint - increment if not null
12661 + * @v: pointer of type atomic_t
12662 + * @hint: probable value of the atomic before the increment
12663 + *
12664 + * This version of atomic_inc_not_zero() gives a hint of probable
12665 + * value of the atomic. This helps processor to not read the memory
12666 + * before doing the atomic read/modify/write cycle, lowering
12667 + * number of bus transactions on some arches.
12668 + *
12669 + * Returns: 0 if increment was not done, 1 otherwise.
12670 + */
12671 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12672 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12673 +{
12674 + int val, c = hint, new;
12675 +
12676 + /* sanity test, should be removed by compiler if hint is a constant */
12677 + if (!hint)
12678 + return __atomic_add_unless(v, 1, 0);
12679 +
12680 + do {
12681 + asm volatile("incl %0\n"
12682 +
12683 +#ifdef CONFIG_PAX_REFCOUNT
12684 + "jno 0f\n"
12685 + "decl %0\n"
12686 + "int $4\n0:\n"
12687 + _ASM_EXTABLE(0b, 0b)
12688 +#endif
12689 +
12690 + : "=r" (new)
12691 + : "0" (c));
12692 +
12693 + val = atomic_cmpxchg(v, c, new);
12694 + if (val == c)
12695 + return 1;
12696 + c = val;
12697 + } while (c);
12698 +
12699 + return 0;
12700 +}
12701 +
12702 +/**
12703 * atomic_inc_short - increment of a short integer
12704 * @v: pointer to type int
12705 *
12706 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12707 #endif
12708
12709 /* These are x86-specific, used by some header files */
12710 -#define atomic_clear_mask(mask, addr) \
12711 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12712 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12713 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12714 +{
12715 + asm volatile(LOCK_PREFIX "andl %1,%0"
12716 + : "+m" (v->counter)
12717 + : "r" (~(mask))
12718 + : "memory");
12719 +}
12720
12721 -#define atomic_set_mask(mask, addr) \
12722 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12723 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12724 - : "memory")
12725 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12726 +{
12727 + asm volatile(LOCK_PREFIX "andl %1,%0"
12728 + : "+m" (v->counter)
12729 + : "r" (~(mask))
12730 + : "memory");
12731 +}
12732 +
12733 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12734 +{
12735 + asm volatile(LOCK_PREFIX "orl %1,%0"
12736 + : "+m" (v->counter)
12737 + : "r" (mask)
12738 + : "memory");
12739 +}
12740 +
12741 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12742 +{
12743 + asm volatile(LOCK_PREFIX "orl %1,%0"
12744 + : "+m" (v->counter)
12745 + : "r" (mask)
12746 + : "memory");
12747 +}
12748
12749 /* Atomic operations are already serializing on x86 */
12750 #define smp_mb__before_atomic_dec() barrier()
12751 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12752 index b154de7..aadebd8 100644
12753 --- a/arch/x86/include/asm/atomic64_32.h
12754 +++ b/arch/x86/include/asm/atomic64_32.h
12755 @@ -12,6 +12,14 @@ typedef struct {
12756 u64 __aligned(8) counter;
12757 } atomic64_t;
12758
12759 +#ifdef CONFIG_PAX_REFCOUNT
12760 +typedef struct {
12761 + u64 __aligned(8) counter;
12762 +} atomic64_unchecked_t;
12763 +#else
12764 +typedef atomic64_t atomic64_unchecked_t;
12765 +#endif
12766 +
12767 #define ATOMIC64_INIT(val) { (val) }
12768
12769 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12770 @@ -37,21 +45,31 @@ typedef struct {
12771 ATOMIC64_DECL_ONE(sym##_386)
12772
12773 ATOMIC64_DECL_ONE(add_386);
12774 +ATOMIC64_DECL_ONE(add_unchecked_386);
12775 ATOMIC64_DECL_ONE(sub_386);
12776 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12777 ATOMIC64_DECL_ONE(inc_386);
12778 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12779 ATOMIC64_DECL_ONE(dec_386);
12780 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12781 #endif
12782
12783 #define alternative_atomic64(f, out, in...) \
12784 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12785
12786 ATOMIC64_DECL(read);
12787 +ATOMIC64_DECL(read_unchecked);
12788 ATOMIC64_DECL(set);
12789 +ATOMIC64_DECL(set_unchecked);
12790 ATOMIC64_DECL(xchg);
12791 ATOMIC64_DECL(add_return);
12792 +ATOMIC64_DECL(add_return_unchecked);
12793 ATOMIC64_DECL(sub_return);
12794 +ATOMIC64_DECL(sub_return_unchecked);
12795 ATOMIC64_DECL(inc_return);
12796 +ATOMIC64_DECL(inc_return_unchecked);
12797 ATOMIC64_DECL(dec_return);
12798 +ATOMIC64_DECL(dec_return_unchecked);
12799 ATOMIC64_DECL(dec_if_positive);
12800 ATOMIC64_DECL(inc_not_zero);
12801 ATOMIC64_DECL(add_unless);
12802 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12803 }
12804
12805 /**
12806 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12807 + * @p: pointer to type atomic64_unchecked_t
12808 + * @o: expected value
12809 + * @n: new value
12810 + *
12811 + * Atomically sets @v to @n if it was equal to @o and returns
12812 + * the old value.
12813 + */
12814 +
12815 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12816 +{
12817 + return cmpxchg64(&v->counter, o, n);
12818 +}
12819 +
12820 +/**
12821 * atomic64_xchg - xchg atomic64 variable
12822 * @v: pointer to type atomic64_t
12823 * @n: value to assign
12824 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12825 }
12826
12827 /**
12828 + * atomic64_set_unchecked - set atomic64 variable
12829 + * @v: pointer to type atomic64_unchecked_t
12830 + * @n: value to assign
12831 + *
12832 + * Atomically sets the value of @v to @n.
12833 + */
12834 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12835 +{
12836 + unsigned high = (unsigned)(i >> 32);
12837 + unsigned low = (unsigned)i;
12838 + alternative_atomic64(set, /* no output */,
12839 + "S" (v), "b" (low), "c" (high)
12840 + : "eax", "edx", "memory");
12841 +}
12842 +
12843 +/**
12844 * atomic64_read - read atomic64 variable
12845 * @v: pointer to type atomic64_t
12846 *
12847 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12848 }
12849
12850 /**
12851 + * atomic64_read_unchecked - read atomic64 variable
12852 + * @v: pointer to type atomic64_unchecked_t
12853 + *
12854 + * Atomically reads the value of @v and returns it.
12855 + */
12856 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12857 +{
12858 + long long r;
12859 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12860 + return r;
12861 + }
12862 +
12863 +/**
12864 * atomic64_add_return - add and return
12865 * @i: integer value to add
12866 * @v: pointer to type atomic64_t
12867 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12868 return i;
12869 }
12870
12871 +/**
12872 + * atomic64_add_return_unchecked - add and return
12873 + * @i: integer value to add
12874 + * @v: pointer to type atomic64_unchecked_t
12875 + *
12876 + * Atomically adds @i to @v and returns @i + *@v
12877 + */
12878 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12879 +{
12880 + alternative_atomic64(add_return_unchecked,
12881 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12882 + ASM_NO_INPUT_CLOBBER("memory"));
12883 + return i;
12884 +}
12885 +
12886 /*
12887 * Other variants with different arithmetic operators:
12888 */
12889 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12890 return a;
12891 }
12892
12893 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12894 +{
12895 + long long a;
12896 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12897 + "S" (v) : "memory", "ecx");
12898 + return a;
12899 +}
12900 +
12901 static inline long long atomic64_dec_return(atomic64_t *v)
12902 {
12903 long long a;
12904 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12905 }
12906
12907 /**
12908 + * atomic64_add_unchecked - add integer to atomic64 variable
12909 + * @i: integer value to add
12910 + * @v: pointer to type atomic64_unchecked_t
12911 + *
12912 + * Atomically adds @i to @v.
12913 + */
12914 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12915 +{
12916 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12917 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12918 + ASM_NO_INPUT_CLOBBER("memory"));
12919 + return i;
12920 +}
12921 +
12922 +/**
12923 * atomic64_sub - subtract the atomic64 variable
12924 * @i: integer value to subtract
12925 * @v: pointer to type atomic64_t
12926 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12927 index 0e1cbfc..5623683 100644
12928 --- a/arch/x86/include/asm/atomic64_64.h
12929 +++ b/arch/x86/include/asm/atomic64_64.h
12930 @@ -18,7 +18,19 @@
12931 */
12932 static inline long atomic64_read(const atomic64_t *v)
12933 {
12934 - return (*(volatile long *)&(v)->counter);
12935 + return (*(volatile const long *)&(v)->counter);
12936 +}
12937 +
12938 +/**
12939 + * atomic64_read_unchecked - read atomic64 variable
12940 + * @v: pointer of type atomic64_unchecked_t
12941 + *
12942 + * Atomically reads the value of @v.
12943 + * Doesn't imply a read memory barrier.
12944 + */
12945 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12946 +{
12947 + return (*(volatile const long *)&(v)->counter);
12948 }
12949
12950 /**
12951 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12952 }
12953
12954 /**
12955 + * atomic64_set_unchecked - set atomic64 variable
12956 + * @v: pointer to type atomic64_unchecked_t
12957 + * @i: required value
12958 + *
12959 + * Atomically sets the value of @v to @i.
12960 + */
12961 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12962 +{
12963 + v->counter = i;
12964 +}
12965 +
12966 +/**
12967 * atomic64_add - add integer to atomic64 variable
12968 * @i: integer value to add
12969 * @v: pointer to type atomic64_t
12970 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12971 */
12972 static inline void atomic64_add(long i, atomic64_t *v)
12973 {
12974 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12975 +
12976 +#ifdef CONFIG_PAX_REFCOUNT
12977 + "jno 0f\n"
12978 + LOCK_PREFIX "subq %1,%0\n"
12979 + "int $4\n0:\n"
12980 + _ASM_EXTABLE(0b, 0b)
12981 +#endif
12982 +
12983 + : "=m" (v->counter)
12984 + : "er" (i), "m" (v->counter));
12985 +}
12986 +
12987 +/**
12988 + * atomic64_add_unchecked - add integer to atomic64 variable
12989 + * @i: integer value to add
12990 + * @v: pointer to type atomic64_unchecked_t
12991 + *
12992 + * Atomically adds @i to @v.
12993 + */
12994 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12995 +{
12996 asm volatile(LOCK_PREFIX "addq %1,%0"
12997 : "=m" (v->counter)
12998 : "er" (i), "m" (v->counter));
12999 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
13000 */
13001 static inline void atomic64_sub(long i, atomic64_t *v)
13002 {
13003 - asm volatile(LOCK_PREFIX "subq %1,%0"
13004 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13005 +
13006 +#ifdef CONFIG_PAX_REFCOUNT
13007 + "jno 0f\n"
13008 + LOCK_PREFIX "addq %1,%0\n"
13009 + "int $4\n0:\n"
13010 + _ASM_EXTABLE(0b, 0b)
13011 +#endif
13012 +
13013 + : "=m" (v->counter)
13014 + : "er" (i), "m" (v->counter));
13015 +}
13016 +
13017 +/**
13018 + * atomic64_sub_unchecked - subtract the atomic64 variable
13019 + * @i: integer value to subtract
13020 + * @v: pointer to type atomic64_unchecked_t
13021 + *
13022 + * Atomically subtracts @i from @v.
13023 + */
13024 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
13025 +{
13026 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13027 : "=m" (v->counter)
13028 : "er" (i), "m" (v->counter));
13029 }
13030 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13031 {
13032 unsigned char c;
13033
13034 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
13035 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
13036 +
13037 +#ifdef CONFIG_PAX_REFCOUNT
13038 + "jno 0f\n"
13039 + LOCK_PREFIX "addq %2,%0\n"
13040 + "int $4\n0:\n"
13041 + _ASM_EXTABLE(0b, 0b)
13042 +#endif
13043 +
13044 + "sete %1\n"
13045 : "=m" (v->counter), "=qm" (c)
13046 : "er" (i), "m" (v->counter) : "memory");
13047 return c;
13048 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13049 */
13050 static inline void atomic64_inc(atomic64_t *v)
13051 {
13052 + asm volatile(LOCK_PREFIX "incq %0\n"
13053 +
13054 +#ifdef CONFIG_PAX_REFCOUNT
13055 + "jno 0f\n"
13056 + LOCK_PREFIX "decq %0\n"
13057 + "int $4\n0:\n"
13058 + _ASM_EXTABLE(0b, 0b)
13059 +#endif
13060 +
13061 + : "=m" (v->counter)
13062 + : "m" (v->counter));
13063 +}
13064 +
13065 +/**
13066 + * atomic64_inc_unchecked - increment atomic64 variable
13067 + * @v: pointer to type atomic64_unchecked_t
13068 + *
13069 + * Atomically increments @v by 1.
13070 + */
13071 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
13072 +{
13073 asm volatile(LOCK_PREFIX "incq %0"
13074 : "=m" (v->counter)
13075 : "m" (v->counter));
13076 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
13077 */
13078 static inline void atomic64_dec(atomic64_t *v)
13079 {
13080 - asm volatile(LOCK_PREFIX "decq %0"
13081 + asm volatile(LOCK_PREFIX "decq %0\n"
13082 +
13083 +#ifdef CONFIG_PAX_REFCOUNT
13084 + "jno 0f\n"
13085 + LOCK_PREFIX "incq %0\n"
13086 + "int $4\n0:\n"
13087 + _ASM_EXTABLE(0b, 0b)
13088 +#endif
13089 +
13090 + : "=m" (v->counter)
13091 + : "m" (v->counter));
13092 +}
13093 +
13094 +/**
13095 + * atomic64_dec_unchecked - decrement atomic64 variable
13096 + * @v: pointer to type atomic64_t
13097 + *
13098 + * Atomically decrements @v by 1.
13099 + */
13100 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
13101 +{
13102 + asm volatile(LOCK_PREFIX "decq %0\n"
13103 : "=m" (v->counter)
13104 : "m" (v->counter));
13105 }
13106 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
13107 {
13108 unsigned char c;
13109
13110 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
13111 + asm volatile(LOCK_PREFIX "decq %0\n"
13112 +
13113 +#ifdef CONFIG_PAX_REFCOUNT
13114 + "jno 0f\n"
13115 + LOCK_PREFIX "incq %0\n"
13116 + "int $4\n0:\n"
13117 + _ASM_EXTABLE(0b, 0b)
13118 +#endif
13119 +
13120 + "sete %1\n"
13121 : "=m" (v->counter), "=qm" (c)
13122 : "m" (v->counter) : "memory");
13123 return c != 0;
13124 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
13125 {
13126 unsigned char c;
13127
13128 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
13129 + asm volatile(LOCK_PREFIX "incq %0\n"
13130 +
13131 +#ifdef CONFIG_PAX_REFCOUNT
13132 + "jno 0f\n"
13133 + LOCK_PREFIX "decq %0\n"
13134 + "int $4\n0:\n"
13135 + _ASM_EXTABLE(0b, 0b)
13136 +#endif
13137 +
13138 + "sete %1\n"
13139 : "=m" (v->counter), "=qm" (c)
13140 : "m" (v->counter) : "memory");
13141 return c != 0;
13142 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13143 {
13144 unsigned char c;
13145
13146 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
13147 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
13148 +
13149 +#ifdef CONFIG_PAX_REFCOUNT
13150 + "jno 0f\n"
13151 + LOCK_PREFIX "subq %2,%0\n"
13152 + "int $4\n0:\n"
13153 + _ASM_EXTABLE(0b, 0b)
13154 +#endif
13155 +
13156 + "sets %1\n"
13157 : "=m" (v->counter), "=qm" (c)
13158 : "er" (i), "m" (v->counter) : "memory");
13159 return c;
13160 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13161 */
13162 static inline long atomic64_add_return(long i, atomic64_t *v)
13163 {
13164 + return i + xadd_check_overflow(&v->counter, i);
13165 +}
13166 +
13167 +/**
13168 + * atomic64_add_return_unchecked - add and return
13169 + * @i: integer value to add
13170 + * @v: pointer to type atomic64_unchecked_t
13171 + *
13172 + * Atomically adds @i to @v and returns @i + @v
13173 + */
13174 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
13175 +{
13176 return i + xadd(&v->counter, i);
13177 }
13178
13179 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
13180 }
13181
13182 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
13183 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13184 +{
13185 + return atomic64_add_return_unchecked(1, v);
13186 +}
13187 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
13188
13189 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13190 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13191 return cmpxchg(&v->counter, old, new);
13192 }
13193
13194 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
13195 +{
13196 + return cmpxchg(&v->counter, old, new);
13197 +}
13198 +
13199 static inline long atomic64_xchg(atomic64_t *v, long new)
13200 {
13201 return xchg(&v->counter, new);
13202 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
13203 */
13204 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
13205 {
13206 - long c, old;
13207 + long c, old, new;
13208 c = atomic64_read(v);
13209 for (;;) {
13210 - if (unlikely(c == (u)))
13211 + if (unlikely(c == u))
13212 break;
13213 - old = atomic64_cmpxchg((v), c, c + (a));
13214 +
13215 + asm volatile("add %2,%0\n"
13216 +
13217 +#ifdef CONFIG_PAX_REFCOUNT
13218 + "jno 0f\n"
13219 + "sub %2,%0\n"
13220 + "int $4\n0:\n"
13221 + _ASM_EXTABLE(0b, 0b)
13222 +#endif
13223 +
13224 + : "=r" (new)
13225 + : "0" (c), "ir" (a));
13226 +
13227 + old = atomic64_cmpxchg(v, c, new);
13228 if (likely(old == c))
13229 break;
13230 c = old;
13231 }
13232 - return c != (u);
13233 + return c != u;
13234 }
13235
13236 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
13237 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
13238 index 6dfd019..28e188d 100644
13239 --- a/arch/x86/include/asm/bitops.h
13240 +++ b/arch/x86/include/asm/bitops.h
13241 @@ -40,7 +40,7 @@
13242 * a mask operation on a byte.
13243 */
13244 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
13245 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
13246 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
13247 #define CONST_MASK(nr) (1 << ((nr) & 7))
13248
13249 /**
13250 @@ -486,7 +486,7 @@ static inline int fls(int x)
13251 * at position 64.
13252 */
13253 #ifdef CONFIG_X86_64
13254 -static __always_inline int fls64(__u64 x)
13255 +static __always_inline long fls64(__u64 x)
13256 {
13257 int bitpos = -1;
13258 /*
13259 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
13260 index 4fa687a..60f2d39 100644
13261 --- a/arch/x86/include/asm/boot.h
13262 +++ b/arch/x86/include/asm/boot.h
13263 @@ -6,10 +6,15 @@
13264 #include <uapi/asm/boot.h>
13265
13266 /* Physical address where kernel should be loaded. */
13267 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13268 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13269 + (CONFIG_PHYSICAL_ALIGN - 1)) \
13270 & ~(CONFIG_PHYSICAL_ALIGN - 1))
13271
13272 +#ifndef __ASSEMBLY__
13273 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
13274 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
13275 +#endif
13276 +
13277 /* Minimum kernel alignment, as a power of two */
13278 #ifdef CONFIG_X86_64
13279 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13280 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
13281 index 48f99f1..d78ebf9 100644
13282 --- a/arch/x86/include/asm/cache.h
13283 +++ b/arch/x86/include/asm/cache.h
13284 @@ -5,12 +5,13 @@
13285
13286 /* L1 cache line size */
13287 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
13288 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
13289 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
13290
13291 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
13292 +#define __read_only __attribute__((__section__(".data..read_only")))
13293
13294 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13295 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
13296 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
13297
13298 #ifdef CONFIG_X86_VSMP
13299 #ifdef CONFIG_SMP
13300 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
13301 index 9863ee3..4a1f8e1 100644
13302 --- a/arch/x86/include/asm/cacheflush.h
13303 +++ b/arch/x86/include/asm/cacheflush.h
13304 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13305 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13306
13307 if (pg_flags == _PGMT_DEFAULT)
13308 - return -1;
13309 + return ~0UL;
13310 else if (pg_flags == _PGMT_WC)
13311 return _PAGE_CACHE_WC;
13312 else if (pg_flags == _PGMT_UC_MINUS)
13313 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13314 index 46fc474..b02b0f9 100644
13315 --- a/arch/x86/include/asm/checksum_32.h
13316 +++ b/arch/x86/include/asm/checksum_32.h
13317 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13318 int len, __wsum sum,
13319 int *src_err_ptr, int *dst_err_ptr);
13320
13321 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13322 + int len, __wsum sum,
13323 + int *src_err_ptr, int *dst_err_ptr);
13324 +
13325 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13326 + int len, __wsum sum,
13327 + int *src_err_ptr, int *dst_err_ptr);
13328 +
13329 /*
13330 * Note: when you get a NULL pointer exception here this means someone
13331 * passed in an incorrect kernel address to one of these functions.
13332 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13333 int *err_ptr)
13334 {
13335 might_sleep();
13336 - return csum_partial_copy_generic((__force void *)src, dst,
13337 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13338 len, sum, err_ptr, NULL);
13339 }
13340
13341 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13342 {
13343 might_sleep();
13344 if (access_ok(VERIFY_WRITE, dst, len))
13345 - return csum_partial_copy_generic(src, (__force void *)dst,
13346 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13347 len, sum, NULL, err_ptr);
13348
13349 if (len)
13350 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13351 index 8d871ea..c1a0dc9 100644
13352 --- a/arch/x86/include/asm/cmpxchg.h
13353 +++ b/arch/x86/include/asm/cmpxchg.h
13354 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13355 __compiletime_error("Bad argument size for cmpxchg");
13356 extern void __xadd_wrong_size(void)
13357 __compiletime_error("Bad argument size for xadd");
13358 +extern void __xadd_check_overflow_wrong_size(void)
13359 + __compiletime_error("Bad argument size for xadd_check_overflow");
13360 extern void __add_wrong_size(void)
13361 __compiletime_error("Bad argument size for add");
13362 +extern void __add_check_overflow_wrong_size(void)
13363 + __compiletime_error("Bad argument size for add_check_overflow");
13364
13365 /*
13366 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13367 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13368 __ret; \
13369 })
13370
13371 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13372 + ({ \
13373 + __typeof__ (*(ptr)) __ret = (arg); \
13374 + switch (sizeof(*(ptr))) { \
13375 + case __X86_CASE_L: \
13376 + asm volatile (lock #op "l %0, %1\n" \
13377 + "jno 0f\n" \
13378 + "mov %0,%1\n" \
13379 + "int $4\n0:\n" \
13380 + _ASM_EXTABLE(0b, 0b) \
13381 + : "+r" (__ret), "+m" (*(ptr)) \
13382 + : : "memory", "cc"); \
13383 + break; \
13384 + case __X86_CASE_Q: \
13385 + asm volatile (lock #op "q %q0, %1\n" \
13386 + "jno 0f\n" \
13387 + "mov %0,%1\n" \
13388 + "int $4\n0:\n" \
13389 + _ASM_EXTABLE(0b, 0b) \
13390 + : "+r" (__ret), "+m" (*(ptr)) \
13391 + : : "memory", "cc"); \
13392 + break; \
13393 + default: \
13394 + __ ## op ## _check_overflow_wrong_size(); \
13395 + } \
13396 + __ret; \
13397 + })
13398 +
13399 /*
13400 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13401 * Since this is generally used to protect other memory information, we
13402 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13403 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13404 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13405
13406 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13407 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13408 +
13409 #define __add(ptr, inc, lock) \
13410 ({ \
13411 __typeof__ (*(ptr)) __ret = (inc); \
13412 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13413 index 59c6c40..5e0b22c 100644
13414 --- a/arch/x86/include/asm/compat.h
13415 +++ b/arch/x86/include/asm/compat.h
13416 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13417 typedef u32 compat_uint_t;
13418 typedef u32 compat_ulong_t;
13419 typedef u64 __attribute__((aligned(4))) compat_u64;
13420 -typedef u32 compat_uptr_t;
13421 +typedef u32 __user compat_uptr_t;
13422
13423 struct compat_timespec {
13424 compat_time_t tv_sec;
13425 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13426 index 2d9075e..b75a844 100644
13427 --- a/arch/x86/include/asm/cpufeature.h
13428 +++ b/arch/x86/include/asm/cpufeature.h
13429 @@ -206,7 +206,7 @@
13430 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13431 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13432 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13433 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13434 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13435 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13436 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13437 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13438 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13439 ".section .discard,\"aw\",@progbits\n"
13440 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13441 ".previous\n"
13442 - ".section .altinstr_replacement,\"ax\"\n"
13443 + ".section .altinstr_replacement,\"a\"\n"
13444 "3: movb $1,%0\n"
13445 "4:\n"
13446 ".previous\n"
13447 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13448 index 8bf1c06..b6ae785 100644
13449 --- a/arch/x86/include/asm/desc.h
13450 +++ b/arch/x86/include/asm/desc.h
13451 @@ -4,6 +4,7 @@
13452 #include <asm/desc_defs.h>
13453 #include <asm/ldt.h>
13454 #include <asm/mmu.h>
13455 +#include <asm/pgtable.h>
13456
13457 #include <linux/smp.h>
13458 #include <linux/percpu.h>
13459 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13460
13461 desc->type = (info->read_exec_only ^ 1) << 1;
13462 desc->type |= info->contents << 2;
13463 + desc->type |= info->seg_not_present ^ 1;
13464
13465 desc->s = 1;
13466 desc->dpl = 0x3;
13467 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13468 }
13469
13470 extern struct desc_ptr idt_descr;
13471 -extern gate_desc idt_table[];
13472 extern struct desc_ptr nmi_idt_descr;
13473 -extern gate_desc nmi_idt_table[];
13474 -
13475 -struct gdt_page {
13476 - struct desc_struct gdt[GDT_ENTRIES];
13477 -} __attribute__((aligned(PAGE_SIZE)));
13478 -
13479 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13480 +extern gate_desc idt_table[256];
13481 +extern gate_desc nmi_idt_table[256];
13482
13483 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13484 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13485 {
13486 - return per_cpu(gdt_page, cpu).gdt;
13487 + return cpu_gdt_table[cpu];
13488 }
13489
13490 #ifdef CONFIG_X86_64
13491 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13492 unsigned long base, unsigned dpl, unsigned flags,
13493 unsigned short seg)
13494 {
13495 - gate->a = (seg << 16) | (base & 0xffff);
13496 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13497 + gate->gate.offset_low = base;
13498 + gate->gate.seg = seg;
13499 + gate->gate.reserved = 0;
13500 + gate->gate.type = type;
13501 + gate->gate.s = 0;
13502 + gate->gate.dpl = dpl;
13503 + gate->gate.p = 1;
13504 + gate->gate.offset_high = base >> 16;
13505 }
13506
13507 #endif
13508 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13509
13510 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13511 {
13512 + pax_open_kernel();
13513 memcpy(&idt[entry], gate, sizeof(*gate));
13514 + pax_close_kernel();
13515 }
13516
13517 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13518 {
13519 + pax_open_kernel();
13520 memcpy(&ldt[entry], desc, 8);
13521 + pax_close_kernel();
13522 }
13523
13524 static inline void
13525 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13526 default: size = sizeof(*gdt); break;
13527 }
13528
13529 + pax_open_kernel();
13530 memcpy(&gdt[entry], desc, size);
13531 + pax_close_kernel();
13532 }
13533
13534 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13535 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13536
13537 static inline void native_load_tr_desc(void)
13538 {
13539 + pax_open_kernel();
13540 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13541 + pax_close_kernel();
13542 }
13543
13544 static inline void native_load_gdt(const struct desc_ptr *dtr)
13545 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13546 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13547 unsigned int i;
13548
13549 + pax_open_kernel();
13550 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13551 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13552 + pax_close_kernel();
13553 }
13554
13555 #define _LDT_empty(info) \
13556 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13557 preempt_enable();
13558 }
13559
13560 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13561 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13562 {
13563 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13564 }
13565 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13566 }
13567
13568 #ifdef CONFIG_X86_64
13569 -static inline void set_nmi_gate(int gate, void *addr)
13570 +static inline void set_nmi_gate(int gate, const void *addr)
13571 {
13572 gate_desc s;
13573
13574 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13575 }
13576 #endif
13577
13578 -static inline void _set_gate(int gate, unsigned type, void *addr,
13579 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13580 unsigned dpl, unsigned ist, unsigned seg)
13581 {
13582 gate_desc s;
13583 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13584 * Pentium F0 0F bugfix can have resulted in the mapped
13585 * IDT being write-protected.
13586 */
13587 -static inline void set_intr_gate(unsigned int n, void *addr)
13588 +static inline void set_intr_gate(unsigned int n, const void *addr)
13589 {
13590 BUG_ON((unsigned)n > 0xFF);
13591 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13592 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13593 /*
13594 * This routine sets up an interrupt gate at directory privilege level 3.
13595 */
13596 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13597 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13598 {
13599 BUG_ON((unsigned)n > 0xFF);
13600 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13601 }
13602
13603 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13604 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13605 {
13606 BUG_ON((unsigned)n > 0xFF);
13607 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13608 }
13609
13610 -static inline void set_trap_gate(unsigned int n, void *addr)
13611 +static inline void set_trap_gate(unsigned int n, const void *addr)
13612 {
13613 BUG_ON((unsigned)n > 0xFF);
13614 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13615 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13616 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13617 {
13618 BUG_ON((unsigned)n > 0xFF);
13619 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13620 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13621 }
13622
13623 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13624 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13625 {
13626 BUG_ON((unsigned)n > 0xFF);
13627 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13628 }
13629
13630 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13631 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13632 {
13633 BUG_ON((unsigned)n > 0xFF);
13634 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13635 }
13636
13637 +#ifdef CONFIG_X86_32
13638 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13639 +{
13640 + struct desc_struct d;
13641 +
13642 + if (likely(limit))
13643 + limit = (limit - 1UL) >> PAGE_SHIFT;
13644 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13645 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13646 +}
13647 +#endif
13648 +
13649 #endif /* _ASM_X86_DESC_H */
13650 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13651 index 278441f..b95a174 100644
13652 --- a/arch/x86/include/asm/desc_defs.h
13653 +++ b/arch/x86/include/asm/desc_defs.h
13654 @@ -31,6 +31,12 @@ struct desc_struct {
13655 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13656 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13657 };
13658 + struct {
13659 + u16 offset_low;
13660 + u16 seg;
13661 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13662 + unsigned offset_high: 16;
13663 + } gate;
13664 };
13665 } __attribute__((packed));
13666
13667 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13668 index ced283a..ffe04cc 100644
13669 --- a/arch/x86/include/asm/div64.h
13670 +++ b/arch/x86/include/asm/div64.h
13671 @@ -39,7 +39,7 @@
13672 __mod; \
13673 })
13674
13675 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13676 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13677 {
13678 union {
13679 u64 v64;
13680 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13681 index 9c999c1..3860cb8 100644
13682 --- a/arch/x86/include/asm/elf.h
13683 +++ b/arch/x86/include/asm/elf.h
13684 @@ -243,7 +243,25 @@ extern int force_personality32;
13685 the loader. We need to make sure that it is out of the way of the program
13686 that it will "exec", and that there is sufficient room for the brk. */
13687
13688 +#ifdef CONFIG_PAX_SEGMEXEC
13689 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13690 +#else
13691 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13692 +#endif
13693 +
13694 +#ifdef CONFIG_PAX_ASLR
13695 +#ifdef CONFIG_X86_32
13696 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13697 +
13698 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13699 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13700 +#else
13701 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13702 +
13703 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13704 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13705 +#endif
13706 +#endif
13707
13708 /* This yields a mask that user programs can use to figure out what
13709 instruction set this CPU supports. This could be done in user space,
13710 @@ -296,16 +314,12 @@ do { \
13711
13712 #define ARCH_DLINFO \
13713 do { \
13714 - if (vdso_enabled) \
13715 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13716 - (unsigned long)current->mm->context.vdso); \
13717 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13718 } while (0)
13719
13720 #define ARCH_DLINFO_X32 \
13721 do { \
13722 - if (vdso_enabled) \
13723 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13724 - (unsigned long)current->mm->context.vdso); \
13725 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13726 } while (0)
13727
13728 #define AT_SYSINFO 32
13729 @@ -320,7 +334,7 @@ else \
13730
13731 #endif /* !CONFIG_X86_32 */
13732
13733 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13734 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13735
13736 #define VDSO_ENTRY \
13737 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13738 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13739 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13740 #define compat_arch_setup_additional_pages syscall32_setup_pages
13741
13742 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13743 -#define arch_randomize_brk arch_randomize_brk
13744 -
13745 /*
13746 * True on X86_32 or when emulating IA32 on X86_64
13747 */
13748 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13749 index 75ce3f4..882e801 100644
13750 --- a/arch/x86/include/asm/emergency-restart.h
13751 +++ b/arch/x86/include/asm/emergency-restart.h
13752 @@ -13,6 +13,6 @@ enum reboot_type {
13753
13754 extern enum reboot_type reboot_type;
13755
13756 -extern void machine_emergency_restart(void);
13757 +extern void machine_emergency_restart(void) __noreturn;
13758
13759 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13760 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13761 index 41ab26e..a88c9e6 100644
13762 --- a/arch/x86/include/asm/fpu-internal.h
13763 +++ b/arch/x86/include/asm/fpu-internal.h
13764 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13765 ({ \
13766 int err; \
13767 asm volatile(ASM_STAC "\n" \
13768 - "1:" #insn "\n\t" \
13769 + "1:" \
13770 + __copyuser_seg \
13771 + #insn "\n\t" \
13772 "2: " ASM_CLAC "\n" \
13773 ".section .fixup,\"ax\"\n" \
13774 "3: movl $-1,%[err]\n" \
13775 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13776 "emms\n\t" /* clear stack tags */
13777 "fildl %P[addr]", /* set F?P to defined value */
13778 X86_FEATURE_FXSAVE_LEAK,
13779 - [addr] "m" (tsk->thread.fpu.has_fpu));
13780 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13781
13782 return fpu_restore_checking(&tsk->thread.fpu);
13783 }
13784 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13785 index be27ba1..8f13ff9 100644
13786 --- a/arch/x86/include/asm/futex.h
13787 +++ b/arch/x86/include/asm/futex.h
13788 @@ -12,6 +12,7 @@
13789 #include <asm/smap.h>
13790
13791 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13792 + typecheck(u32 __user *, uaddr); \
13793 asm volatile("\t" ASM_STAC "\n" \
13794 "1:\t" insn "\n" \
13795 "2:\t" ASM_CLAC "\n" \
13796 @@ -20,15 +21,16 @@
13797 "\tjmp\t2b\n" \
13798 "\t.previous\n" \
13799 _ASM_EXTABLE(1b, 3b) \
13800 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13801 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13802 : "i" (-EFAULT), "0" (oparg), "1" (0))
13803
13804 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13805 + typecheck(u32 __user *, uaddr); \
13806 asm volatile("\t" ASM_STAC "\n" \
13807 "1:\tmovl %2, %0\n" \
13808 "\tmovl\t%0, %3\n" \
13809 "\t" insn "\n" \
13810 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13811 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13812 "\tjnz\t1b\n" \
13813 "3:\t" ASM_CLAC "\n" \
13814 "\t.section .fixup,\"ax\"\n" \
13815 @@ -38,7 +40,7 @@
13816 _ASM_EXTABLE(1b, 4b) \
13817 _ASM_EXTABLE(2b, 4b) \
13818 : "=&a" (oldval), "=&r" (ret), \
13819 - "+m" (*uaddr), "=&r" (tem) \
13820 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13821 : "r" (oparg), "i" (-EFAULT), "1" (0))
13822
13823 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13824 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13825
13826 switch (op) {
13827 case FUTEX_OP_SET:
13828 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13829 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13830 break;
13831 case FUTEX_OP_ADD:
13832 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13833 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13834 uaddr, oparg);
13835 break;
13836 case FUTEX_OP_OR:
13837 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13838 return -EFAULT;
13839
13840 asm volatile("\t" ASM_STAC "\n"
13841 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13842 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13843 "2:\t" ASM_CLAC "\n"
13844 "\t.section .fixup, \"ax\"\n"
13845 "3:\tmov %3, %0\n"
13846 "\tjmp 2b\n"
13847 "\t.previous\n"
13848 _ASM_EXTABLE(1b, 3b)
13849 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13850 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13851 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13852 : "memory"
13853 );
13854 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13855 index eb92a6e..b98b2f4 100644
13856 --- a/arch/x86/include/asm/hw_irq.h
13857 +++ b/arch/x86/include/asm/hw_irq.h
13858 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
13859 extern void enable_IO_APIC(void);
13860
13861 /* Statistics */
13862 -extern atomic_t irq_err_count;
13863 -extern atomic_t irq_mis_count;
13864 +extern atomic_unchecked_t irq_err_count;
13865 +extern atomic_unchecked_t irq_mis_count;
13866
13867 /* EISA */
13868 extern void eisa_set_level_irq(unsigned int irq);
13869 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13870 index a203659..9889f1c 100644
13871 --- a/arch/x86/include/asm/i8259.h
13872 +++ b/arch/x86/include/asm/i8259.h
13873 @@ -62,7 +62,7 @@ struct legacy_pic {
13874 void (*init)(int auto_eoi);
13875 int (*irq_pending)(unsigned int irq);
13876 void (*make_irq)(unsigned int irq);
13877 -};
13878 +} __do_const;
13879
13880 extern struct legacy_pic *legacy_pic;
13881 extern struct legacy_pic null_legacy_pic;
13882 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13883 index d8e8eef..1765f78 100644
13884 --- a/arch/x86/include/asm/io.h
13885 +++ b/arch/x86/include/asm/io.h
13886 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13887 "m" (*(volatile type __force *)addr) barrier); }
13888
13889 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13890 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13891 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13892 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13893 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13894
13895 build_mmio_read(__readb, "b", unsigned char, "=q", )
13896 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13897 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13898 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13899 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13900
13901 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13902 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13903 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13904 return ioremap_nocache(offset, size);
13905 }
13906
13907 -extern void iounmap(volatile void __iomem *addr);
13908 +extern void iounmap(const volatile void __iomem *addr);
13909
13910 extern void set_iounmap_nonlazy(void);
13911
13912 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13913
13914 #include <linux/vmalloc.h>
13915
13916 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13917 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13918 +{
13919 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13920 +}
13921 +
13922 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13923 +{
13924 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13925 +}
13926 +
13927 /*
13928 * Convert a virtual cached pointer to an uncached pointer
13929 */
13930 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13931 index bba3cf8..06bc8da 100644
13932 --- a/arch/x86/include/asm/irqflags.h
13933 +++ b/arch/x86/include/asm/irqflags.h
13934 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13935 sti; \
13936 sysexit
13937
13938 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13939 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13940 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13941 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13942 +
13943 #else
13944 #define INTERRUPT_RETURN iret
13945 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13946 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13947 index d3ddd17..c9fb0cc 100644
13948 --- a/arch/x86/include/asm/kprobes.h
13949 +++ b/arch/x86/include/asm/kprobes.h
13950 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13951 #define RELATIVEJUMP_SIZE 5
13952 #define RELATIVECALL_OPCODE 0xe8
13953 #define RELATIVE_ADDR_SIZE 4
13954 -#define MAX_STACK_SIZE 64
13955 -#define MIN_STACK_SIZE(ADDR) \
13956 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13957 - THREAD_SIZE - (unsigned long)(ADDR))) \
13958 - ? (MAX_STACK_SIZE) \
13959 - : (((unsigned long)current_thread_info()) + \
13960 - THREAD_SIZE - (unsigned long)(ADDR)))
13961 +#define MAX_STACK_SIZE 64UL
13962 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13963
13964 #define flush_insn_slot(p) do { } while (0)
13965
13966 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13967 index 2d89e39..baee879 100644
13968 --- a/arch/x86/include/asm/local.h
13969 +++ b/arch/x86/include/asm/local.h
13970 @@ -10,33 +10,97 @@ typedef struct {
13971 atomic_long_t a;
13972 } local_t;
13973
13974 +typedef struct {
13975 + atomic_long_unchecked_t a;
13976 +} local_unchecked_t;
13977 +
13978 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13979
13980 #define local_read(l) atomic_long_read(&(l)->a)
13981 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13982 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13983 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13984
13985 static inline void local_inc(local_t *l)
13986 {
13987 - asm volatile(_ASM_INC "%0"
13988 + asm volatile(_ASM_INC "%0\n"
13989 +
13990 +#ifdef CONFIG_PAX_REFCOUNT
13991 + "jno 0f\n"
13992 + _ASM_DEC "%0\n"
13993 + "int $4\n0:\n"
13994 + _ASM_EXTABLE(0b, 0b)
13995 +#endif
13996 +
13997 + : "+m" (l->a.counter));
13998 +}
13999 +
14000 +static inline void local_inc_unchecked(local_unchecked_t *l)
14001 +{
14002 + asm volatile(_ASM_INC "%0\n"
14003 : "+m" (l->a.counter));
14004 }
14005
14006 static inline void local_dec(local_t *l)
14007 {
14008 - asm volatile(_ASM_DEC "%0"
14009 + asm volatile(_ASM_DEC "%0\n"
14010 +
14011 +#ifdef CONFIG_PAX_REFCOUNT
14012 + "jno 0f\n"
14013 + _ASM_INC "%0\n"
14014 + "int $4\n0:\n"
14015 + _ASM_EXTABLE(0b, 0b)
14016 +#endif
14017 +
14018 + : "+m" (l->a.counter));
14019 +}
14020 +
14021 +static inline void local_dec_unchecked(local_unchecked_t *l)
14022 +{
14023 + asm volatile(_ASM_DEC "%0\n"
14024 : "+m" (l->a.counter));
14025 }
14026
14027 static inline void local_add(long i, local_t *l)
14028 {
14029 - asm volatile(_ASM_ADD "%1,%0"
14030 + asm volatile(_ASM_ADD "%1,%0\n"
14031 +
14032 +#ifdef CONFIG_PAX_REFCOUNT
14033 + "jno 0f\n"
14034 + _ASM_SUB "%1,%0\n"
14035 + "int $4\n0:\n"
14036 + _ASM_EXTABLE(0b, 0b)
14037 +#endif
14038 +
14039 + : "+m" (l->a.counter)
14040 + : "ir" (i));
14041 +}
14042 +
14043 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
14044 +{
14045 + asm volatile(_ASM_ADD "%1,%0\n"
14046 : "+m" (l->a.counter)
14047 : "ir" (i));
14048 }
14049
14050 static inline void local_sub(long i, local_t *l)
14051 {
14052 - asm volatile(_ASM_SUB "%1,%0"
14053 + asm volatile(_ASM_SUB "%1,%0\n"
14054 +
14055 +#ifdef CONFIG_PAX_REFCOUNT
14056 + "jno 0f\n"
14057 + _ASM_ADD "%1,%0\n"
14058 + "int $4\n0:\n"
14059 + _ASM_EXTABLE(0b, 0b)
14060 +#endif
14061 +
14062 + : "+m" (l->a.counter)
14063 + : "ir" (i));
14064 +}
14065 +
14066 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
14067 +{
14068 + asm volatile(_ASM_SUB "%1,%0\n"
14069 : "+m" (l->a.counter)
14070 : "ir" (i));
14071 }
14072 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
14073 {
14074 unsigned char c;
14075
14076 - asm volatile(_ASM_SUB "%2,%0; sete %1"
14077 + asm volatile(_ASM_SUB "%2,%0\n"
14078 +
14079 +#ifdef CONFIG_PAX_REFCOUNT
14080 + "jno 0f\n"
14081 + _ASM_ADD "%2,%0\n"
14082 + "int $4\n0:\n"
14083 + _ASM_EXTABLE(0b, 0b)
14084 +#endif
14085 +
14086 + "sete %1\n"
14087 : "+m" (l->a.counter), "=qm" (c)
14088 : "ir" (i) : "memory");
14089 return c;
14090 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
14091 {
14092 unsigned char c;
14093
14094 - asm volatile(_ASM_DEC "%0; sete %1"
14095 + asm volatile(_ASM_DEC "%0\n"
14096 +
14097 +#ifdef CONFIG_PAX_REFCOUNT
14098 + "jno 0f\n"
14099 + _ASM_INC "%0\n"
14100 + "int $4\n0:\n"
14101 + _ASM_EXTABLE(0b, 0b)
14102 +#endif
14103 +
14104 + "sete %1\n"
14105 : "+m" (l->a.counter), "=qm" (c)
14106 : : "memory");
14107 return c != 0;
14108 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
14109 {
14110 unsigned char c;
14111
14112 - asm volatile(_ASM_INC "%0; sete %1"
14113 + asm volatile(_ASM_INC "%0\n"
14114 +
14115 +#ifdef CONFIG_PAX_REFCOUNT
14116 + "jno 0f\n"
14117 + _ASM_DEC "%0\n"
14118 + "int $4\n0:\n"
14119 + _ASM_EXTABLE(0b, 0b)
14120 +#endif
14121 +
14122 + "sete %1\n"
14123 : "+m" (l->a.counter), "=qm" (c)
14124 : : "memory");
14125 return c != 0;
14126 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
14127 {
14128 unsigned char c;
14129
14130 - asm volatile(_ASM_ADD "%2,%0; sets %1"
14131 + asm volatile(_ASM_ADD "%2,%0\n"
14132 +
14133 +#ifdef CONFIG_PAX_REFCOUNT
14134 + "jno 0f\n"
14135 + _ASM_SUB "%2,%0\n"
14136 + "int $4\n0:\n"
14137 + _ASM_EXTABLE(0b, 0b)
14138 +#endif
14139 +
14140 + "sets %1\n"
14141 : "+m" (l->a.counter), "=qm" (c)
14142 : "ir" (i) : "memory");
14143 return c;
14144 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
14145 static inline long local_add_return(long i, local_t *l)
14146 {
14147 long __i = i;
14148 + asm volatile(_ASM_XADD "%0, %1\n"
14149 +
14150 +#ifdef CONFIG_PAX_REFCOUNT
14151 + "jno 0f\n"
14152 + _ASM_MOV "%0,%1\n"
14153 + "int $4\n0:\n"
14154 + _ASM_EXTABLE(0b, 0b)
14155 +#endif
14156 +
14157 + : "+r" (i), "+m" (l->a.counter)
14158 + : : "memory");
14159 + return i + __i;
14160 +}
14161 +
14162 +/**
14163 + * local_add_return_unchecked - add and return
14164 + * @i: integer value to add
14165 + * @l: pointer to type local_unchecked_t
14166 + *
14167 + * Atomically adds @i to @l and returns @i + @l
14168 + */
14169 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
14170 +{
14171 + long __i = i;
14172 asm volatile(_ASM_XADD "%0, %1;"
14173 : "+r" (i), "+m" (l->a.counter)
14174 : : "memory");
14175 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
14176
14177 #define local_cmpxchg(l, o, n) \
14178 (cmpxchg_local(&((l)->a.counter), (o), (n)))
14179 +#define local_cmpxchg_unchecked(l, o, n) \
14180 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
14181 /* Always has a lock prefix */
14182 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
14183
14184 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
14185 new file mode 100644
14186 index 0000000..2bfd3ba
14187 --- /dev/null
14188 +++ b/arch/x86/include/asm/mman.h
14189 @@ -0,0 +1,15 @@
14190 +#ifndef _X86_MMAN_H
14191 +#define _X86_MMAN_H
14192 +
14193 +#include <uapi/asm/mman.h>
14194 +
14195 +#ifdef __KERNEL__
14196 +#ifndef __ASSEMBLY__
14197 +#ifdef CONFIG_X86_32
14198 +#define arch_mmap_check i386_mmap_check
14199 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
14200 +#endif
14201 +#endif
14202 +#endif
14203 +
14204 +#endif /* X86_MMAN_H */
14205 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
14206 index 5f55e69..e20bfb1 100644
14207 --- a/arch/x86/include/asm/mmu.h
14208 +++ b/arch/x86/include/asm/mmu.h
14209 @@ -9,7 +9,7 @@
14210 * we put the segment information here.
14211 */
14212 typedef struct {
14213 - void *ldt;
14214 + struct desc_struct *ldt;
14215 int size;
14216
14217 #ifdef CONFIG_X86_64
14218 @@ -18,7 +18,19 @@ typedef struct {
14219 #endif
14220
14221 struct mutex lock;
14222 - void *vdso;
14223 + unsigned long vdso;
14224 +
14225 +#ifdef CONFIG_X86_32
14226 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
14227 + unsigned long user_cs_base;
14228 + unsigned long user_cs_limit;
14229 +
14230 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14231 + cpumask_t cpu_user_cs_mask;
14232 +#endif
14233 +
14234 +#endif
14235 +#endif
14236 } mm_context_t;
14237
14238 #ifdef CONFIG_SMP
14239 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
14240 index cdbf367..adb37ac 100644
14241 --- a/arch/x86/include/asm/mmu_context.h
14242 +++ b/arch/x86/include/asm/mmu_context.h
14243 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
14244
14245 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14246 {
14247 +
14248 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14249 + unsigned int i;
14250 + pgd_t *pgd;
14251 +
14252 + pax_open_kernel();
14253 + pgd = get_cpu_pgd(smp_processor_id());
14254 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
14255 + set_pgd_batched(pgd+i, native_make_pgd(0));
14256 + pax_close_kernel();
14257 +#endif
14258 +
14259 #ifdef CONFIG_SMP
14260 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
14261 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
14262 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14263 struct task_struct *tsk)
14264 {
14265 unsigned cpu = smp_processor_id();
14266 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14267 + int tlbstate = TLBSTATE_OK;
14268 +#endif
14269
14270 if (likely(prev != next)) {
14271 #ifdef CONFIG_SMP
14272 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14273 + tlbstate = this_cpu_read(cpu_tlbstate.state);
14274 +#endif
14275 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14276 this_cpu_write(cpu_tlbstate.active_mm, next);
14277 #endif
14278 cpumask_set_cpu(cpu, mm_cpumask(next));
14279
14280 /* Re-load page tables */
14281 +#ifdef CONFIG_PAX_PER_CPU_PGD
14282 + pax_open_kernel();
14283 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14284 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14285 + pax_close_kernel();
14286 + load_cr3(get_cpu_pgd(cpu));
14287 +#else
14288 load_cr3(next->pgd);
14289 +#endif
14290
14291 /* stop flush ipis for the previous mm */
14292 cpumask_clear_cpu(cpu, mm_cpumask(prev));
14293 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14294 */
14295 if (unlikely(prev->context.ldt != next->context.ldt))
14296 load_LDT_nolock(&next->context);
14297 - }
14298 +
14299 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14300 + if (!(__supported_pte_mask & _PAGE_NX)) {
14301 + smp_mb__before_clear_bit();
14302 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
14303 + smp_mb__after_clear_bit();
14304 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14305 + }
14306 +#endif
14307 +
14308 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14309 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
14310 + prev->context.user_cs_limit != next->context.user_cs_limit))
14311 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14312 #ifdef CONFIG_SMP
14313 + else if (unlikely(tlbstate != TLBSTATE_OK))
14314 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14315 +#endif
14316 +#endif
14317 +
14318 + }
14319 else {
14320 +
14321 +#ifdef CONFIG_PAX_PER_CPU_PGD
14322 + pax_open_kernel();
14323 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14324 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14325 + pax_close_kernel();
14326 + load_cr3(get_cpu_pgd(cpu));
14327 +#endif
14328 +
14329 +#ifdef CONFIG_SMP
14330 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14331 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14332
14333 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14334 * tlb flush IPI delivery. We must reload CR3
14335 * to make sure to use no freed page tables.
14336 */
14337 +
14338 +#ifndef CONFIG_PAX_PER_CPU_PGD
14339 load_cr3(next->pgd);
14340 +#endif
14341 +
14342 load_LDT_nolock(&next->context);
14343 +
14344 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14345 + if (!(__supported_pte_mask & _PAGE_NX))
14346 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14347 +#endif
14348 +
14349 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14350 +#ifdef CONFIG_PAX_PAGEEXEC
14351 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14352 +#endif
14353 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14354 +#endif
14355 +
14356 }
14357 +#endif
14358 }
14359 -#endif
14360 }
14361
14362 #define activate_mm(prev, next) \
14363 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14364 index e3b7819..b257c64 100644
14365 --- a/arch/x86/include/asm/module.h
14366 +++ b/arch/x86/include/asm/module.h
14367 @@ -5,6 +5,7 @@
14368
14369 #ifdef CONFIG_X86_64
14370 /* X86_64 does not define MODULE_PROC_FAMILY */
14371 +#define MODULE_PROC_FAMILY ""
14372 #elif defined CONFIG_M486
14373 #define MODULE_PROC_FAMILY "486 "
14374 #elif defined CONFIG_M586
14375 @@ -57,8 +58,20 @@
14376 #error unknown processor family
14377 #endif
14378
14379 -#ifdef CONFIG_X86_32
14380 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14381 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14382 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14383 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14384 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14385 +#else
14386 +#define MODULE_PAX_KERNEXEC ""
14387 #endif
14388
14389 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14390 +#define MODULE_PAX_UDEREF "UDEREF "
14391 +#else
14392 +#define MODULE_PAX_UDEREF ""
14393 +#endif
14394 +
14395 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14396 +
14397 #endif /* _ASM_X86_MODULE_H */
14398 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14399 index c0fa356..07a498a 100644
14400 --- a/arch/x86/include/asm/nmi.h
14401 +++ b/arch/x86/include/asm/nmi.h
14402 @@ -42,11 +42,11 @@ struct nmiaction {
14403 nmi_handler_t handler;
14404 unsigned long flags;
14405 const char *name;
14406 -};
14407 +} __do_const;
14408
14409 #define register_nmi_handler(t, fn, fg, n, init...) \
14410 ({ \
14411 - static struct nmiaction init fn##_na = { \
14412 + static const struct nmiaction init fn##_na = { \
14413 .handler = (fn), \
14414 .name = (n), \
14415 .flags = (fg), \
14416 @@ -54,7 +54,7 @@ struct nmiaction {
14417 __register_nmi_handler((t), &fn##_na); \
14418 })
14419
14420 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14421 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14422
14423 void unregister_nmi_handler(unsigned int, const char *);
14424
14425 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
14426 index 320f7bb..e89f8f8 100644
14427 --- a/arch/x86/include/asm/page_64_types.h
14428 +++ b/arch/x86/include/asm/page_64_types.h
14429 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
14430
14431 /* duplicated to the one in bootmem.h */
14432 extern unsigned long max_pfn;
14433 -extern unsigned long phys_base;
14434 +extern const unsigned long phys_base;
14435
14436 extern unsigned long __phys_addr(unsigned long);
14437 #define __phys_reloc_hide(x) (x)
14438 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14439 index 7361e47..16dc226 100644
14440 --- a/arch/x86/include/asm/paravirt.h
14441 +++ b/arch/x86/include/asm/paravirt.h
14442 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14443 return (pmd_t) { ret };
14444 }
14445
14446 -static inline pmdval_t pmd_val(pmd_t pmd)
14447 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14448 {
14449 pmdval_t ret;
14450
14451 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14452 val);
14453 }
14454
14455 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14456 +{
14457 + pgdval_t val = native_pgd_val(pgd);
14458 +
14459 + if (sizeof(pgdval_t) > sizeof(long))
14460 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14461 + val, (u64)val >> 32);
14462 + else
14463 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14464 + val);
14465 +}
14466 +
14467 static inline void pgd_clear(pgd_t *pgdp)
14468 {
14469 set_pgd(pgdp, __pgd(0));
14470 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14471 pv_mmu_ops.set_fixmap(idx, phys, flags);
14472 }
14473
14474 +#ifdef CONFIG_PAX_KERNEXEC
14475 +static inline unsigned long pax_open_kernel(void)
14476 +{
14477 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14478 +}
14479 +
14480 +static inline unsigned long pax_close_kernel(void)
14481 +{
14482 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14483 +}
14484 +#else
14485 +static inline unsigned long pax_open_kernel(void) { return 0; }
14486 +static inline unsigned long pax_close_kernel(void) { return 0; }
14487 +#endif
14488 +
14489 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14490
14491 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14492 @@ -930,7 +957,7 @@ extern void default_banner(void);
14493
14494 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14495 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14496 -#define PARA_INDIRECT(addr) *%cs:addr
14497 +#define PARA_INDIRECT(addr) *%ss:addr
14498 #endif
14499
14500 #define INTERRUPT_RETURN \
14501 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
14502 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14503 CLBR_NONE, \
14504 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14505 +
14506 +#define GET_CR0_INTO_RDI \
14507 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14508 + mov %rax,%rdi
14509 +
14510 +#define SET_RDI_INTO_CR0 \
14511 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14512 +
14513 +#define GET_CR3_INTO_RDI \
14514 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14515 + mov %rax,%rdi
14516 +
14517 +#define SET_RDI_INTO_CR3 \
14518 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14519 +
14520 #endif /* CONFIG_X86_32 */
14521
14522 #endif /* __ASSEMBLY__ */
14523 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14524 index b3b0ec1..b1cd3eb 100644
14525 --- a/arch/x86/include/asm/paravirt_types.h
14526 +++ b/arch/x86/include/asm/paravirt_types.h
14527 @@ -84,7 +84,7 @@ struct pv_init_ops {
14528 */
14529 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14530 unsigned long addr, unsigned len);
14531 -};
14532 +} __no_const;
14533
14534
14535 struct pv_lazy_ops {
14536 @@ -98,7 +98,7 @@ struct pv_time_ops {
14537 unsigned long long (*sched_clock)(void);
14538 unsigned long long (*steal_clock)(int cpu);
14539 unsigned long (*get_tsc_khz)(void);
14540 -};
14541 +} __no_const;
14542
14543 struct pv_cpu_ops {
14544 /* hooks for various privileged instructions */
14545 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14546
14547 void (*start_context_switch)(struct task_struct *prev);
14548 void (*end_context_switch)(struct task_struct *next);
14549 -};
14550 +} __no_const;
14551
14552 struct pv_irq_ops {
14553 /*
14554 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14555 unsigned long start_eip,
14556 unsigned long start_esp);
14557 #endif
14558 -};
14559 +} __no_const;
14560
14561 struct pv_mmu_ops {
14562 unsigned long (*read_cr2)(void);
14563 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14564 struct paravirt_callee_save make_pud;
14565
14566 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14567 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14568 #endif /* PAGETABLE_LEVELS == 4 */
14569 #endif /* PAGETABLE_LEVELS >= 3 */
14570
14571 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14572 an mfn. We can tell which is which from the index. */
14573 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14574 phys_addr_t phys, pgprot_t flags);
14575 +
14576 +#ifdef CONFIG_PAX_KERNEXEC
14577 + unsigned long (*pax_open_kernel)(void);
14578 + unsigned long (*pax_close_kernel)(void);
14579 +#endif
14580 +
14581 };
14582
14583 struct arch_spinlock;
14584 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14585 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14586 int (*spin_trylock)(struct arch_spinlock *lock);
14587 void (*spin_unlock)(struct arch_spinlock *lock);
14588 -};
14589 +} __no_const;
14590
14591 /* This contains all the paravirt structures: we get a convenient
14592 * number for each function using the offset which we use to indicate
14593 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14594 index b4389a4..7024269 100644
14595 --- a/arch/x86/include/asm/pgalloc.h
14596 +++ b/arch/x86/include/asm/pgalloc.h
14597 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14598 pmd_t *pmd, pte_t *pte)
14599 {
14600 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14601 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14602 +}
14603 +
14604 +static inline void pmd_populate_user(struct mm_struct *mm,
14605 + pmd_t *pmd, pte_t *pte)
14606 +{
14607 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14608 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14609 }
14610
14611 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14612
14613 #ifdef CONFIG_X86_PAE
14614 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14615 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14616 +{
14617 + pud_populate(mm, pudp, pmd);
14618 +}
14619 #else /* !CONFIG_X86_PAE */
14620 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14621 {
14622 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14623 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14624 }
14625 +
14626 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14627 +{
14628 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14629 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14630 +}
14631 #endif /* CONFIG_X86_PAE */
14632
14633 #if PAGETABLE_LEVELS > 3
14634 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14635 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14636 }
14637
14638 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14639 +{
14640 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14641 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14642 +}
14643 +
14644 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14645 {
14646 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14647 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14648 index f2b489c..4f7e2e5 100644
14649 --- a/arch/x86/include/asm/pgtable-2level.h
14650 +++ b/arch/x86/include/asm/pgtable-2level.h
14651 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14652
14653 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14654 {
14655 + pax_open_kernel();
14656 *pmdp = pmd;
14657 + pax_close_kernel();
14658 }
14659
14660 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14661 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14662 index 4cc9f2b..5fd9226 100644
14663 --- a/arch/x86/include/asm/pgtable-3level.h
14664 +++ b/arch/x86/include/asm/pgtable-3level.h
14665 @@ -92,12 +92,16 @@ 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 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14671 + pax_close_kernel();
14672 }
14673
14674 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14675 {
14676 + pax_open_kernel();
14677 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14678 + pax_close_kernel();
14679 }
14680
14681 /*
14682 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14683 index 1c1a955..50f828c 100644
14684 --- a/arch/x86/include/asm/pgtable.h
14685 +++ b/arch/x86/include/asm/pgtable.h
14686 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14687
14688 #ifndef __PAGETABLE_PUD_FOLDED
14689 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14690 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14691 #define pgd_clear(pgd) native_pgd_clear(pgd)
14692 #endif
14693
14694 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14695
14696 #define arch_end_context_switch(prev) do {} while(0)
14697
14698 +#define pax_open_kernel() native_pax_open_kernel()
14699 +#define pax_close_kernel() native_pax_close_kernel()
14700 #endif /* CONFIG_PARAVIRT */
14701
14702 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14703 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14704 +
14705 +#ifdef CONFIG_PAX_KERNEXEC
14706 +static inline unsigned long native_pax_open_kernel(void)
14707 +{
14708 + unsigned long cr0;
14709 +
14710 + preempt_disable();
14711 + barrier();
14712 + cr0 = read_cr0() ^ X86_CR0_WP;
14713 + BUG_ON(cr0 & X86_CR0_WP);
14714 + write_cr0(cr0);
14715 + return cr0 ^ X86_CR0_WP;
14716 +}
14717 +
14718 +static inline unsigned long native_pax_close_kernel(void)
14719 +{
14720 + unsigned long cr0;
14721 +
14722 + cr0 = read_cr0() ^ X86_CR0_WP;
14723 + BUG_ON(!(cr0 & X86_CR0_WP));
14724 + write_cr0(cr0);
14725 + barrier();
14726 + preempt_enable_no_resched();
14727 + return cr0 ^ X86_CR0_WP;
14728 +}
14729 +#else
14730 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14731 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14732 +#endif
14733 +
14734 /*
14735 * The following only work if pte_present() is true.
14736 * Undefined behaviour if not..
14737 */
14738 +static inline int pte_user(pte_t pte)
14739 +{
14740 + return pte_val(pte) & _PAGE_USER;
14741 +}
14742 +
14743 static inline int pte_dirty(pte_t pte)
14744 {
14745 return pte_flags(pte) & _PAGE_DIRTY;
14746 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14747 return pte_clear_flags(pte, _PAGE_RW);
14748 }
14749
14750 +static inline pte_t pte_mkread(pte_t pte)
14751 +{
14752 + return __pte(pte_val(pte) | _PAGE_USER);
14753 +}
14754 +
14755 static inline pte_t pte_mkexec(pte_t pte)
14756 {
14757 - return pte_clear_flags(pte, _PAGE_NX);
14758 +#ifdef CONFIG_X86_PAE
14759 + if (__supported_pte_mask & _PAGE_NX)
14760 + return pte_clear_flags(pte, _PAGE_NX);
14761 + else
14762 +#endif
14763 + return pte_set_flags(pte, _PAGE_USER);
14764 +}
14765 +
14766 +static inline pte_t pte_exprotect(pte_t pte)
14767 +{
14768 +#ifdef CONFIG_X86_PAE
14769 + if (__supported_pte_mask & _PAGE_NX)
14770 + return pte_set_flags(pte, _PAGE_NX);
14771 + else
14772 +#endif
14773 + return pte_clear_flags(pte, _PAGE_USER);
14774 }
14775
14776 static inline pte_t pte_mkdirty(pte_t pte)
14777 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14778 #endif
14779
14780 #ifndef __ASSEMBLY__
14781 +
14782 +#ifdef CONFIG_PAX_PER_CPU_PGD
14783 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14784 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14785 +{
14786 + return cpu_pgd[cpu];
14787 +}
14788 +#endif
14789 +
14790 #include <linux/mm_types.h>
14791
14792 static inline int pte_none(pte_t pte)
14793 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14794
14795 static inline int pgd_bad(pgd_t pgd)
14796 {
14797 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14798 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14799 }
14800
14801 static inline int pgd_none(pgd_t pgd)
14802 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
14803 * pgd_offset() returns a (pgd_t *)
14804 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14805 */
14806 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14807 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14808 +
14809 +#ifdef CONFIG_PAX_PER_CPU_PGD
14810 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14811 +#endif
14812 +
14813 /*
14814 * a shortcut which implies the use of the kernel's pgd, instead
14815 * of a process's
14816 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
14817 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14818 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14819
14820 +#ifdef CONFIG_X86_32
14821 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14822 +#else
14823 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14824 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14825 +
14826 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14827 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
14828 +#else
14829 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
14830 +#endif
14831 +
14832 +#endif
14833 +
14834 #ifndef __ASSEMBLY__
14835
14836 extern int direct_gbpages;
14837 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14838 * dst and src can be on the same page, but the range must not overlap,
14839 * and must not cross a page boundary.
14840 */
14841 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14842 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14843 {
14844 - memcpy(dst, src, count * sizeof(pgd_t));
14845 + pax_open_kernel();
14846 + while (count--)
14847 + *dst++ = *src++;
14848 + pax_close_kernel();
14849 }
14850
14851 +#ifdef CONFIG_PAX_PER_CPU_PGD
14852 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14853 +#endif
14854 +
14855 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14856 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14857 +#else
14858 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14859 +#endif
14860
14861 #include <asm-generic/pgtable.h>
14862 #endif /* __ASSEMBLY__ */
14863 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14864 index 8faa215..a8a17ea 100644
14865 --- a/arch/x86/include/asm/pgtable_32.h
14866 +++ b/arch/x86/include/asm/pgtable_32.h
14867 @@ -25,9 +25,6 @@
14868 struct mm_struct;
14869 struct vm_area_struct;
14870
14871 -extern pgd_t swapper_pg_dir[1024];
14872 -extern pgd_t initial_page_table[1024];
14873 -
14874 static inline void pgtable_cache_init(void) { }
14875 static inline void check_pgt_cache(void) { }
14876 void paging_init(void);
14877 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14878 # include <asm/pgtable-2level.h>
14879 #endif
14880
14881 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14882 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14883 +#ifdef CONFIG_X86_PAE
14884 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14885 +#endif
14886 +
14887 #if defined(CONFIG_HIGHPTE)
14888 #define pte_offset_map(dir, address) \
14889 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14890 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14891 /* Clear a kernel PTE and flush it from the TLB */
14892 #define kpte_clear_flush(ptep, vaddr) \
14893 do { \
14894 + pax_open_kernel(); \
14895 pte_clear(&init_mm, (vaddr), (ptep)); \
14896 + pax_close_kernel(); \
14897 __flush_tlb_one((vaddr)); \
14898 } while (0)
14899
14900 @@ -75,6 +80,9 @@ do { \
14901
14902 #endif /* !__ASSEMBLY__ */
14903
14904 +#define HAVE_ARCH_UNMAPPED_AREA
14905 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14906 +
14907 /*
14908 * kern_addr_valid() is (1) for FLATMEM and (0) for
14909 * SPARSEMEM and DISCONTIGMEM
14910 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14911 index ed5903b..c7fe163 100644
14912 --- a/arch/x86/include/asm/pgtable_32_types.h
14913 +++ b/arch/x86/include/asm/pgtable_32_types.h
14914 @@ -8,7 +8,7 @@
14915 */
14916 #ifdef CONFIG_X86_PAE
14917 # include <asm/pgtable-3level_types.h>
14918 -# define PMD_SIZE (1UL << PMD_SHIFT)
14919 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14920 # define PMD_MASK (~(PMD_SIZE - 1))
14921 #else
14922 # include <asm/pgtable-2level_types.h>
14923 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14924 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14925 #endif
14926
14927 +#ifdef CONFIG_PAX_KERNEXEC
14928 +#ifndef __ASSEMBLY__
14929 +extern unsigned char MODULES_EXEC_VADDR[];
14930 +extern unsigned char MODULES_EXEC_END[];
14931 +#endif
14932 +#include <asm/boot.h>
14933 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14934 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14935 +#else
14936 +#define ktla_ktva(addr) (addr)
14937 +#define ktva_ktla(addr) (addr)
14938 +#endif
14939 +
14940 #define MODULES_VADDR VMALLOC_START
14941 #define MODULES_END VMALLOC_END
14942 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14943 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14944 index 47356f9..deb94a2 100644
14945 --- a/arch/x86/include/asm/pgtable_64.h
14946 +++ b/arch/x86/include/asm/pgtable_64.h
14947 @@ -16,10 +16,14 @@
14948
14949 extern pud_t level3_kernel_pgt[512];
14950 extern pud_t level3_ident_pgt[512];
14951 +extern pud_t level3_vmalloc_start_pgt[512];
14952 +extern pud_t level3_vmalloc_end_pgt[512];
14953 +extern pud_t level3_vmemmap_pgt[512];
14954 +extern pud_t level2_vmemmap_pgt[512];
14955 extern pmd_t level2_kernel_pgt[512];
14956 extern pmd_t level2_fixmap_pgt[512];
14957 -extern pmd_t level2_ident_pgt[512];
14958 -extern pgd_t init_level4_pgt[];
14959 +extern pmd_t level2_ident_pgt[512*2];
14960 +extern pgd_t init_level4_pgt[512];
14961
14962 #define swapper_pg_dir init_level4_pgt
14963
14964 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14965
14966 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14967 {
14968 + pax_open_kernel();
14969 *pmdp = pmd;
14970 + pax_close_kernel();
14971 }
14972
14973 static inline void native_pmd_clear(pmd_t *pmd)
14974 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14975
14976 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14977 {
14978 + pax_open_kernel();
14979 *pudp = pud;
14980 + pax_close_kernel();
14981 }
14982
14983 static inline void native_pud_clear(pud_t *pud)
14984 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14985
14986 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14987 {
14988 + pax_open_kernel();
14989 + *pgdp = pgd;
14990 + pax_close_kernel();
14991 +}
14992 +
14993 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14994 +{
14995 *pgdp = pgd;
14996 }
14997
14998 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14999 index 766ea16..5b96cb3 100644
15000 --- a/arch/x86/include/asm/pgtable_64_types.h
15001 +++ b/arch/x86/include/asm/pgtable_64_types.h
15002 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
15003 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
15004 #define MODULES_END _AC(0xffffffffff000000, UL)
15005 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
15006 +#define MODULES_EXEC_VADDR MODULES_VADDR
15007 +#define MODULES_EXEC_END MODULES_END
15008 +
15009 +#define ktla_ktva(addr) (addr)
15010 +#define ktva_ktla(addr) (addr)
15011
15012 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
15013 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
15014 index 3c32db8..1ddccf5 100644
15015 --- a/arch/x86/include/asm/pgtable_types.h
15016 +++ b/arch/x86/include/asm/pgtable_types.h
15017 @@ -16,13 +16,12 @@
15018 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
15019 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
15020 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
15021 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
15022 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
15023 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
15024 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
15025 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
15026 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
15027 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
15028 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
15029 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
15030 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
15031 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
15032
15033 /* If _PAGE_BIT_PRESENT is clear, we use these: */
15034 @@ -40,7 +39,6 @@
15035 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
15036 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
15037 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
15038 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
15039 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
15040 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
15041 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
15042 @@ -57,8 +55,10 @@
15043
15044 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
15045 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
15046 -#else
15047 +#elif defined(CONFIG_KMEMCHECK)
15048 #define _PAGE_NX (_AT(pteval_t, 0))
15049 +#else
15050 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
15051 #endif
15052
15053 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
15054 @@ -116,6 +116,9 @@
15055 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
15056 _PAGE_ACCESSED)
15057
15058 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
15059 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
15060 +
15061 #define __PAGE_KERNEL_EXEC \
15062 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
15063 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
15064 @@ -126,7 +129,7 @@
15065 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
15066 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
15067 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
15068 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
15069 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
15070 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
15071 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
15072 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
15073 @@ -188,8 +191,8 @@
15074 * bits are combined, this will alow user to access the high address mapped
15075 * VDSO in the presence of CONFIG_COMPAT_VDSO
15076 */
15077 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
15078 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
15079 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15080 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15081 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
15082 #endif
15083
15084 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
15085 {
15086 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
15087 }
15088 +#endif
15089
15090 +#if PAGETABLE_LEVELS == 3
15091 +#include <asm-generic/pgtable-nopud.h>
15092 +#endif
15093 +
15094 +#if PAGETABLE_LEVELS == 2
15095 +#include <asm-generic/pgtable-nopmd.h>
15096 +#endif
15097 +
15098 +#ifndef __ASSEMBLY__
15099 #if PAGETABLE_LEVELS > 3
15100 typedef struct { pudval_t pud; } pud_t;
15101
15102 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
15103 return pud.pud;
15104 }
15105 #else
15106 -#include <asm-generic/pgtable-nopud.h>
15107 -
15108 static inline pudval_t native_pud_val(pud_t pud)
15109 {
15110 return native_pgd_val(pud.pgd);
15111 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
15112 return pmd.pmd;
15113 }
15114 #else
15115 -#include <asm-generic/pgtable-nopmd.h>
15116 -
15117 static inline pmdval_t native_pmd_val(pmd_t pmd)
15118 {
15119 return native_pgd_val(pmd.pud.pgd);
15120 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
15121
15122 extern pteval_t __supported_pte_mask;
15123 extern void set_nx(void);
15124 -extern int nx_enabled;
15125
15126 #define pgprot_writecombine pgprot_writecombine
15127 extern pgprot_t pgprot_writecombine(pgprot_t prot);
15128 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
15129 index 888184b..a07ac89 100644
15130 --- a/arch/x86/include/asm/processor.h
15131 +++ b/arch/x86/include/asm/processor.h
15132 @@ -287,7 +287,7 @@ struct tss_struct {
15133
15134 } ____cacheline_aligned;
15135
15136 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
15137 +extern struct tss_struct init_tss[NR_CPUS];
15138
15139 /*
15140 * Save the original ist values for checking stack pointers during debugging
15141 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
15142 */
15143 #define TASK_SIZE PAGE_OFFSET
15144 #define TASK_SIZE_MAX TASK_SIZE
15145 +
15146 +#ifdef CONFIG_PAX_SEGMEXEC
15147 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
15148 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
15149 +#else
15150 #define STACK_TOP TASK_SIZE
15151 -#define STACK_TOP_MAX STACK_TOP
15152 +#endif
15153 +
15154 +#define STACK_TOP_MAX TASK_SIZE
15155
15156 #define INIT_THREAD { \
15157 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15158 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15159 .vm86_info = NULL, \
15160 .sysenter_cs = __KERNEL_CS, \
15161 .io_bitmap_ptr = NULL, \
15162 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
15163 */
15164 #define INIT_TSS { \
15165 .x86_tss = { \
15166 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15167 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15168 .ss0 = __KERNEL_DS, \
15169 .ss1 = __KERNEL_CS, \
15170 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
15171 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
15172 extern unsigned long thread_saved_pc(struct task_struct *tsk);
15173
15174 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
15175 -#define KSTK_TOP(info) \
15176 -({ \
15177 - unsigned long *__ptr = (unsigned long *)(info); \
15178 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
15179 -})
15180 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
15181
15182 /*
15183 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
15184 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15185 #define task_pt_regs(task) \
15186 ({ \
15187 struct pt_regs *__regs__; \
15188 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
15189 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
15190 __regs__ - 1; \
15191 })
15192
15193 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15194 /*
15195 * User space process size. 47bits minus one guard page.
15196 */
15197 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
15198 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
15199
15200 /* This decides where the kernel will search for a free chunk of vm
15201 * space during mmap's.
15202 */
15203 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
15204 - 0xc0000000 : 0xFFFFe000)
15205 + 0xc0000000 : 0xFFFFf000)
15206
15207 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
15208 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
15209 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15210 #define STACK_TOP_MAX TASK_SIZE_MAX
15211
15212 #define INIT_THREAD { \
15213 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15214 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15215 }
15216
15217 #define INIT_TSS { \
15218 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15219 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15220 }
15221
15222 /*
15223 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
15224 */
15225 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
15226
15227 +#ifdef CONFIG_PAX_SEGMEXEC
15228 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
15229 +#endif
15230 +
15231 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
15232
15233 /* Get/set a process' ability to use the timestamp counter instruction */
15234 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
15235 #define cpu_has_amd_erratum(x) (false)
15236 #endif /* CONFIG_CPU_SUP_AMD */
15237
15238 -extern unsigned long arch_align_stack(unsigned long sp);
15239 +#define arch_align_stack(x) ((x) & ~0xfUL)
15240 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
15241
15242 void default_idle(void);
15243 bool set_pm_idle_to_default(void);
15244
15245 -void stop_this_cpu(void *dummy);
15246 +void stop_this_cpu(void *dummy) __noreturn;
15247
15248 #endif /* _ASM_X86_PROCESSOR_H */
15249 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
15250 index 942a086..6c26446 100644
15251 --- a/arch/x86/include/asm/ptrace.h
15252 +++ b/arch/x86/include/asm/ptrace.h
15253 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
15254 }
15255
15256 /*
15257 - * user_mode_vm(regs) determines whether a register set came from user mode.
15258 + * user_mode(regs) determines whether a register set came from user mode.
15259 * This is true if V8086 mode was enabled OR if the register set was from
15260 * protected mode with RPL-3 CS value. This tricky test checks that with
15261 * one comparison. Many places in the kernel can bypass this full check
15262 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
15263 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
15264 + * be used.
15265 */
15266 -static inline int user_mode(struct pt_regs *regs)
15267 +static inline int user_mode_novm(struct pt_regs *regs)
15268 {
15269 #ifdef CONFIG_X86_32
15270 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15271 #else
15272 - return !!(regs->cs & 3);
15273 + return !!(regs->cs & SEGMENT_RPL_MASK);
15274 #endif
15275 }
15276
15277 -static inline int user_mode_vm(struct pt_regs *regs)
15278 +static inline int user_mode(struct pt_regs *regs)
15279 {
15280 #ifdef CONFIG_X86_32
15281 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15282 USER_RPL;
15283 #else
15284 - return user_mode(regs);
15285 + return user_mode_novm(regs);
15286 #endif
15287 }
15288
15289 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15290 #ifdef CONFIG_X86_64
15291 static inline bool user_64bit_mode(struct pt_regs *regs)
15292 {
15293 + unsigned long cs = regs->cs & 0xffff;
15294 #ifndef CONFIG_PARAVIRT
15295 /*
15296 * On non-paravirt systems, this is the only long mode CPL 3
15297 * selector. We do not allow long mode selectors in the LDT.
15298 */
15299 - return regs->cs == __USER_CS;
15300 + return cs == __USER_CS;
15301 #else
15302 /* Headers are too twisted for this to go in paravirt.h. */
15303 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15304 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15305 #endif
15306 }
15307
15308 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15309 * Traps from the kernel do not save sp and ss.
15310 * Use the helper function to retrieve sp.
15311 */
15312 - if (offset == offsetof(struct pt_regs, sp) &&
15313 - regs->cs == __KERNEL_CS)
15314 - return kernel_stack_pointer(regs);
15315 + if (offset == offsetof(struct pt_regs, sp)) {
15316 + unsigned long cs = regs->cs & 0xffff;
15317 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15318 + return kernel_stack_pointer(regs);
15319 + }
15320 #endif
15321 return *(unsigned long *)((unsigned long)regs + offset);
15322 }
15323 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15324 index fe1ec5b..dc5c3fe 100644
15325 --- a/arch/x86/include/asm/realmode.h
15326 +++ b/arch/x86/include/asm/realmode.h
15327 @@ -22,16 +22,14 @@ struct real_mode_header {
15328 #endif
15329 /* APM/BIOS reboot */
15330 u32 machine_real_restart_asm;
15331 -#ifdef CONFIG_X86_64
15332 u32 machine_real_restart_seg;
15333 -#endif
15334 };
15335
15336 /* This must match data at trampoline_32/64.S */
15337 struct trampoline_header {
15338 #ifdef CONFIG_X86_32
15339 u32 start;
15340 - u16 gdt_pad;
15341 + u16 boot_cs;
15342 u16 gdt_limit;
15343 u32 gdt_base;
15344 #else
15345 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15346 index a82c4f1..ac45053 100644
15347 --- a/arch/x86/include/asm/reboot.h
15348 +++ b/arch/x86/include/asm/reboot.h
15349 @@ -6,13 +6,13 @@
15350 struct pt_regs;
15351
15352 struct machine_ops {
15353 - void (*restart)(char *cmd);
15354 - void (*halt)(void);
15355 - void (*power_off)(void);
15356 + void (* __noreturn restart)(char *cmd);
15357 + void (* __noreturn halt)(void);
15358 + void (* __noreturn power_off)(void);
15359 void (*shutdown)(void);
15360 void (*crash_shutdown)(struct pt_regs *);
15361 - void (*emergency_restart)(void);
15362 -};
15363 + void (* __noreturn emergency_restart)(void);
15364 +} __no_const;
15365
15366 extern struct machine_ops machine_ops;
15367
15368 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15369 index 2dbe4a7..ce1db00 100644
15370 --- a/arch/x86/include/asm/rwsem.h
15371 +++ b/arch/x86/include/asm/rwsem.h
15372 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15373 {
15374 asm volatile("# beginning down_read\n\t"
15375 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15376 +
15377 +#ifdef CONFIG_PAX_REFCOUNT
15378 + "jno 0f\n"
15379 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15380 + "int $4\n0:\n"
15381 + _ASM_EXTABLE(0b, 0b)
15382 +#endif
15383 +
15384 /* adds 0x00000001 */
15385 " jns 1f\n"
15386 " call call_rwsem_down_read_failed\n"
15387 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15388 "1:\n\t"
15389 " mov %1,%2\n\t"
15390 " add %3,%2\n\t"
15391 +
15392 +#ifdef CONFIG_PAX_REFCOUNT
15393 + "jno 0f\n"
15394 + "sub %3,%2\n"
15395 + "int $4\n0:\n"
15396 + _ASM_EXTABLE(0b, 0b)
15397 +#endif
15398 +
15399 " jle 2f\n\t"
15400 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15401 " jnz 1b\n\t"
15402 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15403 long tmp;
15404 asm volatile("# beginning down_write\n\t"
15405 LOCK_PREFIX " xadd %1,(%2)\n\t"
15406 +
15407 +#ifdef CONFIG_PAX_REFCOUNT
15408 + "jno 0f\n"
15409 + "mov %1,(%2)\n"
15410 + "int $4\n0:\n"
15411 + _ASM_EXTABLE(0b, 0b)
15412 +#endif
15413 +
15414 /* adds 0xffff0001, returns the old value */
15415 " test %1,%1\n\t"
15416 /* was the count 0 before? */
15417 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15418 long tmp;
15419 asm volatile("# beginning __up_read\n\t"
15420 LOCK_PREFIX " xadd %1,(%2)\n\t"
15421 +
15422 +#ifdef CONFIG_PAX_REFCOUNT
15423 + "jno 0f\n"
15424 + "mov %1,(%2)\n"
15425 + "int $4\n0:\n"
15426 + _ASM_EXTABLE(0b, 0b)
15427 +#endif
15428 +
15429 /* subtracts 1, returns the old value */
15430 " jns 1f\n\t"
15431 " call call_rwsem_wake\n" /* expects old value in %edx */
15432 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15433 long tmp;
15434 asm volatile("# beginning __up_write\n\t"
15435 LOCK_PREFIX " xadd %1,(%2)\n\t"
15436 +
15437 +#ifdef CONFIG_PAX_REFCOUNT
15438 + "jno 0f\n"
15439 + "mov %1,(%2)\n"
15440 + "int $4\n0:\n"
15441 + _ASM_EXTABLE(0b, 0b)
15442 +#endif
15443 +
15444 /* subtracts 0xffff0001, returns the old value */
15445 " jns 1f\n\t"
15446 " call call_rwsem_wake\n" /* expects old value in %edx */
15447 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15448 {
15449 asm volatile("# beginning __downgrade_write\n\t"
15450 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15451 +
15452 +#ifdef CONFIG_PAX_REFCOUNT
15453 + "jno 0f\n"
15454 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15455 + "int $4\n0:\n"
15456 + _ASM_EXTABLE(0b, 0b)
15457 +#endif
15458 +
15459 /*
15460 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15461 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15462 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15463 */
15464 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15465 {
15466 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15467 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15468 +
15469 +#ifdef CONFIG_PAX_REFCOUNT
15470 + "jno 0f\n"
15471 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15472 + "int $4\n0:\n"
15473 + _ASM_EXTABLE(0b, 0b)
15474 +#endif
15475 +
15476 : "+m" (sem->count)
15477 : "er" (delta));
15478 }
15479 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15480 */
15481 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15482 {
15483 - return delta + xadd(&sem->count, delta);
15484 + return delta + xadd_check_overflow(&sem->count, delta);
15485 }
15486
15487 #endif /* __KERNEL__ */
15488 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15489 index c48a950..c6d7468 100644
15490 --- a/arch/x86/include/asm/segment.h
15491 +++ b/arch/x86/include/asm/segment.h
15492 @@ -64,10 +64,15 @@
15493 * 26 - ESPFIX small SS
15494 * 27 - per-cpu [ offset to per-cpu data area ]
15495 * 28 - stack_canary-20 [ for stack protector ]
15496 - * 29 - unused
15497 - * 30 - unused
15498 + * 29 - PCI BIOS CS
15499 + * 30 - PCI BIOS DS
15500 * 31 - TSS for double fault handler
15501 */
15502 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15503 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15504 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15505 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15506 +
15507 #define GDT_ENTRY_TLS_MIN 6
15508 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15509
15510 @@ -79,6 +84,8 @@
15511
15512 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15513
15514 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15515 +
15516 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15517
15518 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15519 @@ -104,6 +111,12 @@
15520 #define __KERNEL_STACK_CANARY 0
15521 #endif
15522
15523 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15524 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15525 +
15526 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15527 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15528 +
15529 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15530
15531 /*
15532 @@ -141,7 +154,7 @@
15533 */
15534
15535 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15536 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15537 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15538
15539
15540 #else
15541 @@ -165,6 +178,8 @@
15542 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15543 #define __USER32_DS __USER_DS
15544
15545 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15546 +
15547 #define GDT_ENTRY_TSS 8 /* needs two entries */
15548 #define GDT_ENTRY_LDT 10 /* needs two entries */
15549 #define GDT_ENTRY_TLS_MIN 12
15550 @@ -185,6 +200,7 @@
15551 #endif
15552
15553 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15554 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15555 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15556 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15557 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15558 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15559 {
15560 unsigned long __limit;
15561 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15562 - return __limit + 1;
15563 + return __limit;
15564 }
15565
15566 #endif /* !__ASSEMBLY__ */
15567 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15568 index b073aae..39f9bdd 100644
15569 --- a/arch/x86/include/asm/smp.h
15570 +++ b/arch/x86/include/asm/smp.h
15571 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15572 /* cpus sharing the last level cache: */
15573 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15574 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15575 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15576 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15577
15578 static inline struct cpumask *cpu_sibling_mask(int cpu)
15579 {
15580 @@ -79,7 +79,7 @@ struct smp_ops {
15581
15582 void (*send_call_func_ipi)(const struct cpumask *mask);
15583 void (*send_call_func_single_ipi)(int cpu);
15584 -};
15585 +} __no_const;
15586
15587 /* Globals due to paravirt */
15588 extern void set_cpu_sibling_map(int cpu);
15589 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15590 extern int safe_smp_processor_id(void);
15591
15592 #elif defined(CONFIG_X86_64_SMP)
15593 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15594 -
15595 -#define stack_smp_processor_id() \
15596 -({ \
15597 - struct thread_info *ti; \
15598 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15599 - ti->cpu; \
15600 -})
15601 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15602 +#define stack_smp_processor_id() raw_smp_processor_id()
15603 #define safe_smp_processor_id() smp_processor_id()
15604
15605 #endif
15606 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15607 index 33692ea..350a534 100644
15608 --- a/arch/x86/include/asm/spinlock.h
15609 +++ b/arch/x86/include/asm/spinlock.h
15610 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15611 static inline void arch_read_lock(arch_rwlock_t *rw)
15612 {
15613 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15614 +
15615 +#ifdef CONFIG_PAX_REFCOUNT
15616 + "jno 0f\n"
15617 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15618 + "int $4\n0:\n"
15619 + _ASM_EXTABLE(0b, 0b)
15620 +#endif
15621 +
15622 "jns 1f\n"
15623 "call __read_lock_failed\n\t"
15624 "1:\n"
15625 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15626 static inline void arch_write_lock(arch_rwlock_t *rw)
15627 {
15628 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15629 +
15630 +#ifdef CONFIG_PAX_REFCOUNT
15631 + "jno 0f\n"
15632 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15633 + "int $4\n0:\n"
15634 + _ASM_EXTABLE(0b, 0b)
15635 +#endif
15636 +
15637 "jz 1f\n"
15638 "call __write_lock_failed\n\t"
15639 "1:\n"
15640 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15641
15642 static inline void arch_read_unlock(arch_rwlock_t *rw)
15643 {
15644 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15645 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15646 +
15647 +#ifdef CONFIG_PAX_REFCOUNT
15648 + "jno 0f\n"
15649 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15650 + "int $4\n0:\n"
15651 + _ASM_EXTABLE(0b, 0b)
15652 +#endif
15653 +
15654 :"+m" (rw->lock) : : "memory");
15655 }
15656
15657 static inline void arch_write_unlock(arch_rwlock_t *rw)
15658 {
15659 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15660 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15661 +
15662 +#ifdef CONFIG_PAX_REFCOUNT
15663 + "jno 0f\n"
15664 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15665 + "int $4\n0:\n"
15666 + _ASM_EXTABLE(0b, 0b)
15667 +#endif
15668 +
15669 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15670 }
15671
15672 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15673 index 6a99859..03cb807 100644
15674 --- a/arch/x86/include/asm/stackprotector.h
15675 +++ b/arch/x86/include/asm/stackprotector.h
15676 @@ -47,7 +47,7 @@
15677 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15678 */
15679 #define GDT_STACK_CANARY_INIT \
15680 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15681 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15682
15683 /*
15684 * Initialize the stackprotector canary value.
15685 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15686
15687 static inline void load_stack_canary_segment(void)
15688 {
15689 -#ifdef CONFIG_X86_32
15690 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15691 asm volatile ("mov %0, %%gs" : : "r" (0));
15692 #endif
15693 }
15694 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15695 index 70bbe39..4ae2bd4 100644
15696 --- a/arch/x86/include/asm/stacktrace.h
15697 +++ b/arch/x86/include/asm/stacktrace.h
15698 @@ -11,28 +11,20 @@
15699
15700 extern int kstack_depth_to_print;
15701
15702 -struct thread_info;
15703 +struct task_struct;
15704 struct stacktrace_ops;
15705
15706 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15707 - unsigned long *stack,
15708 - unsigned long bp,
15709 - const struct stacktrace_ops *ops,
15710 - void *data,
15711 - unsigned long *end,
15712 - int *graph);
15713 +typedef unsigned long walk_stack_t(struct task_struct *task,
15714 + void *stack_start,
15715 + unsigned long *stack,
15716 + unsigned long bp,
15717 + const struct stacktrace_ops *ops,
15718 + void *data,
15719 + unsigned long *end,
15720 + int *graph);
15721
15722 -extern unsigned long
15723 -print_context_stack(struct thread_info *tinfo,
15724 - unsigned long *stack, unsigned long bp,
15725 - const struct stacktrace_ops *ops, void *data,
15726 - unsigned long *end, int *graph);
15727 -
15728 -extern unsigned long
15729 -print_context_stack_bp(struct thread_info *tinfo,
15730 - unsigned long *stack, unsigned long bp,
15731 - const struct stacktrace_ops *ops, void *data,
15732 - unsigned long *end, int *graph);
15733 +extern walk_stack_t print_context_stack;
15734 +extern walk_stack_t print_context_stack_bp;
15735
15736 /* Generic stack tracer with callbacks */
15737
15738 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15739 void (*address)(void *data, unsigned long address, int reliable);
15740 /* On negative return stop dumping */
15741 int (*stack)(void *data, char *name);
15742 - walk_stack_t walk_stack;
15743 + walk_stack_t *walk_stack;
15744 };
15745
15746 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15747 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15748 index 4ec45b3..a4f0a8a 100644
15749 --- a/arch/x86/include/asm/switch_to.h
15750 +++ b/arch/x86/include/asm/switch_to.h
15751 @@ -108,7 +108,7 @@ do { \
15752 "call __switch_to\n\t" \
15753 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15754 __switch_canary \
15755 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15756 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15757 "movq %%rax,%%rdi\n\t" \
15758 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15759 "jnz ret_from_fork\n\t" \
15760 @@ -119,7 +119,7 @@ do { \
15761 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15762 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15763 [_tif_fork] "i" (_TIF_FORK), \
15764 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15765 + [thread_info] "m" (current_tinfo), \
15766 [current_task] "m" (current_task) \
15767 __switch_canary_iparam \
15768 : "memory", "cc" __EXTRA_CLOBBER)
15769 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15770 index 2d946e6..e453ec4 100644
15771 --- a/arch/x86/include/asm/thread_info.h
15772 +++ b/arch/x86/include/asm/thread_info.h
15773 @@ -10,6 +10,7 @@
15774 #include <linux/compiler.h>
15775 #include <asm/page.h>
15776 #include <asm/types.h>
15777 +#include <asm/percpu.h>
15778
15779 /*
15780 * low level task data that entry.S needs immediate access to
15781 @@ -24,7 +25,6 @@ struct exec_domain;
15782 #include <linux/atomic.h>
15783
15784 struct thread_info {
15785 - struct task_struct *task; /* main task structure */
15786 struct exec_domain *exec_domain; /* execution domain */
15787 __u32 flags; /* low level flags */
15788 __u32 status; /* thread synchronous flags */
15789 @@ -34,19 +34,13 @@ struct thread_info {
15790 mm_segment_t addr_limit;
15791 struct restart_block restart_block;
15792 void __user *sysenter_return;
15793 -#ifdef CONFIG_X86_32
15794 - unsigned long previous_esp; /* ESP of the previous stack in
15795 - case of nested (IRQ) stacks
15796 - */
15797 - __u8 supervisor_stack[0];
15798 -#endif
15799 + unsigned long lowest_stack;
15800 unsigned int sig_on_uaccess_error:1;
15801 unsigned int uaccess_err:1; /* uaccess failed */
15802 };
15803
15804 -#define INIT_THREAD_INFO(tsk) \
15805 +#define INIT_THREAD_INFO \
15806 { \
15807 - .task = &tsk, \
15808 .exec_domain = &default_exec_domain, \
15809 .flags = 0, \
15810 .cpu = 0, \
15811 @@ -57,7 +51,7 @@ struct thread_info {
15812 }, \
15813 }
15814
15815 -#define init_thread_info (init_thread_union.thread_info)
15816 +#define init_thread_info (init_thread_union.stack)
15817 #define init_stack (init_thread_union.stack)
15818
15819 #else /* !__ASSEMBLY__ */
15820 @@ -98,6 +92,7 @@ struct thread_info {
15821 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15822 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15823 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15824 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15825
15826 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15827 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15828 @@ -122,17 +117,18 @@ struct thread_info {
15829 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15830 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15831 #define _TIF_X32 (1 << TIF_X32)
15832 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15833
15834 /* work to do in syscall_trace_enter() */
15835 #define _TIF_WORK_SYSCALL_ENTRY \
15836 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15837 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15838 - _TIF_NOHZ)
15839 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15840
15841 /* work to do in syscall_trace_leave() */
15842 #define _TIF_WORK_SYSCALL_EXIT \
15843 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15844 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15845 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15846
15847 /* work to do on interrupt/exception return */
15848 #define _TIF_WORK_MASK \
15849 @@ -143,7 +139,7 @@ struct thread_info {
15850 /* work to do on any return to user space */
15851 #define _TIF_ALLWORK_MASK \
15852 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15853 - _TIF_NOHZ)
15854 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15855
15856 /* Only used for 64 bit */
15857 #define _TIF_DO_NOTIFY_MASK \
15858 @@ -159,45 +155,40 @@ struct thread_info {
15859
15860 #define PREEMPT_ACTIVE 0x10000000
15861
15862 -#ifdef CONFIG_X86_32
15863 -
15864 -#define STACK_WARN (THREAD_SIZE/8)
15865 -/*
15866 - * macros/functions for gaining access to the thread information structure
15867 - *
15868 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15869 - */
15870 -#ifndef __ASSEMBLY__
15871 -
15872 -
15873 -/* how to get the current stack pointer from C */
15874 -register unsigned long current_stack_pointer asm("esp") __used;
15875 -
15876 -/* how to get the thread information struct from C */
15877 -static inline struct thread_info *current_thread_info(void)
15878 -{
15879 - return (struct thread_info *)
15880 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15881 -}
15882 -
15883 -#else /* !__ASSEMBLY__ */
15884 -
15885 +#ifdef __ASSEMBLY__
15886 /* how to get the thread information struct from ASM */
15887 #define GET_THREAD_INFO(reg) \
15888 - movl $-THREAD_SIZE, reg; \
15889 - andl %esp, reg
15890 + mov PER_CPU_VAR(current_tinfo), reg
15891
15892 /* use this one if reg already contains %esp */
15893 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15894 - andl $-THREAD_SIZE, reg
15895 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15896 +#else
15897 +/* how to get the thread information struct from C */
15898 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15899 +
15900 +static __always_inline struct thread_info *current_thread_info(void)
15901 +{
15902 + return this_cpu_read_stable(current_tinfo);
15903 +}
15904 +#endif
15905 +
15906 +#ifdef CONFIG_X86_32
15907 +
15908 +#define STACK_WARN (THREAD_SIZE/8)
15909 +/*
15910 + * macros/functions for gaining access to the thread information structure
15911 + *
15912 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15913 + */
15914 +#ifndef __ASSEMBLY__
15915 +
15916 +/* how to get the current stack pointer from C */
15917 +register unsigned long current_stack_pointer asm("esp") __used;
15918
15919 #endif
15920
15921 #else /* X86_32 */
15922
15923 -#include <asm/percpu.h>
15924 -#define KERNEL_STACK_OFFSET (5*8)
15925 -
15926 /*
15927 * macros/functions for gaining access to the thread information structure
15928 * preempt_count needs to be 1 initially, until the scheduler is functional.
15929 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
15930 #ifndef __ASSEMBLY__
15931 DECLARE_PER_CPU(unsigned long, kernel_stack);
15932
15933 -static inline struct thread_info *current_thread_info(void)
15934 -{
15935 - struct thread_info *ti;
15936 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15937 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15938 - return ti;
15939 -}
15940 -
15941 -#else /* !__ASSEMBLY__ */
15942 -
15943 -/* how to get the thread information struct from ASM */
15944 -#define GET_THREAD_INFO(reg) \
15945 - movq PER_CPU_VAR(kernel_stack),reg ; \
15946 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15947 -
15948 -/*
15949 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15950 - * a certain register (to be used in assembler memory operands).
15951 - */
15952 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15953 -
15954 +/* how to get the current stack pointer from C */
15955 +register unsigned long current_stack_pointer asm("rsp") __used;
15956 #endif
15957
15958 #endif /* !X86_32 */
15959 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
15960 extern void arch_task_cache_init(void);
15961 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15962 extern void arch_release_task_struct(struct task_struct *tsk);
15963 +
15964 +#define __HAVE_THREAD_FUNCTIONS
15965 +#define task_thread_info(task) (&(task)->tinfo)
15966 +#define task_stack_page(task) ((task)->stack)
15967 +#define setup_thread_stack(p, org) do {} while (0)
15968 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15969 +
15970 #endif
15971 #endif /* _ASM_X86_THREAD_INFO_H */
15972 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15973 index 1709801..0a60f2f 100644
15974 --- a/arch/x86/include/asm/uaccess.h
15975 +++ b/arch/x86/include/asm/uaccess.h
15976 @@ -7,6 +7,7 @@
15977 #include <linux/compiler.h>
15978 #include <linux/thread_info.h>
15979 #include <linux/string.h>
15980 +#include <linux/sched.h>
15981 #include <asm/asm.h>
15982 #include <asm/page.h>
15983 #include <asm/smap.h>
15984 @@ -29,7 +30,12 @@
15985
15986 #define get_ds() (KERNEL_DS)
15987 #define get_fs() (current_thread_info()->addr_limit)
15988 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15989 +void __set_fs(mm_segment_t x);
15990 +void set_fs(mm_segment_t x);
15991 +#else
15992 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15993 +#endif
15994
15995 #define segment_eq(a, b) ((a).seg == (b).seg)
15996
15997 @@ -77,8 +83,33 @@
15998 * checks that the pointer is in the user space range - after calling
15999 * this function, memory access functions may still return -EFAULT.
16000 */
16001 -#define access_ok(type, addr, size) \
16002 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
16003 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
16004 +#define access_ok(type, addr, size) \
16005 +({ \
16006 + long __size = size; \
16007 + unsigned long __addr = (unsigned long)addr; \
16008 + unsigned long __addr_ao = __addr & PAGE_MASK; \
16009 + unsigned long __end_ao = __addr + __size - 1; \
16010 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
16011 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
16012 + while(__addr_ao <= __end_ao) { \
16013 + char __c_ao; \
16014 + __addr_ao += PAGE_SIZE; \
16015 + if (__size > PAGE_SIZE) \
16016 + cond_resched(); \
16017 + if (__get_user(__c_ao, (char __user *)__addr)) \
16018 + break; \
16019 + if (type != VERIFY_WRITE) { \
16020 + __addr = __addr_ao; \
16021 + continue; \
16022 + } \
16023 + if (__put_user(__c_ao, (char __user *)__addr)) \
16024 + break; \
16025 + __addr = __addr_ao; \
16026 + } \
16027 + } \
16028 + __ret_ao; \
16029 +})
16030
16031 /*
16032 * The exception table consists of pairs of addresses relative to the
16033 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
16034 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
16035 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
16036
16037 -
16038 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
16039 +#define __copyuser_seg "gs;"
16040 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
16041 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
16042 +#else
16043 +#define __copyuser_seg
16044 +#define __COPYUSER_SET_ES
16045 +#define __COPYUSER_RESTORE_ES
16046 +#endif
16047
16048 #ifdef CONFIG_X86_32
16049 #define __put_user_asm_u64(x, addr, err, errret) \
16050 asm volatile(ASM_STAC "\n" \
16051 - "1: movl %%eax,0(%2)\n" \
16052 - "2: movl %%edx,4(%2)\n" \
16053 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
16054 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
16055 "3: " ASM_CLAC "\n" \
16056 ".section .fixup,\"ax\"\n" \
16057 "4: movl %3,%0\n" \
16058 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
16059
16060 #define __put_user_asm_ex_u64(x, addr) \
16061 asm volatile(ASM_STAC "\n" \
16062 - "1: movl %%eax,0(%1)\n" \
16063 - "2: movl %%edx,4(%1)\n" \
16064 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
16065 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
16066 "3: " ASM_CLAC "\n" \
16067 _ASM_EXTABLE_EX(1b, 2b) \
16068 _ASM_EXTABLE_EX(2b, 3b) \
16069 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
16070 __typeof__(*(ptr)) __pu_val; \
16071 __chk_user_ptr(ptr); \
16072 might_fault(); \
16073 - __pu_val = x; \
16074 + __pu_val = (x); \
16075 switch (sizeof(*(ptr))) { \
16076 case 1: \
16077 __put_user_x(1, __pu_val, ptr, __ret_pu); \
16078 @@ -358,7 +397,7 @@ do { \
16079
16080 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16081 asm volatile(ASM_STAC "\n" \
16082 - "1: mov"itype" %2,%"rtype"1\n" \
16083 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
16084 "2: " ASM_CLAC "\n" \
16085 ".section .fixup,\"ax\"\n" \
16086 "3: mov %3,%0\n" \
16087 @@ -366,7 +405,7 @@ do { \
16088 " jmp 2b\n" \
16089 ".previous\n" \
16090 _ASM_EXTABLE(1b, 3b) \
16091 - : "=r" (err), ltype(x) \
16092 + : "=r" (err), ltype (x) \
16093 : "m" (__m(addr)), "i" (errret), "0" (err))
16094
16095 #define __get_user_size_ex(x, ptr, size) \
16096 @@ -391,7 +430,7 @@ do { \
16097 } while (0)
16098
16099 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
16100 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
16101 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
16102 "2:\n" \
16103 _ASM_EXTABLE_EX(1b, 2b) \
16104 : ltype(x) : "m" (__m(addr)))
16105 @@ -408,13 +447,24 @@ do { \
16106 int __gu_err; \
16107 unsigned long __gu_val; \
16108 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
16109 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
16110 + (x) = (__typeof__(*(ptr)))__gu_val; \
16111 __gu_err; \
16112 })
16113
16114 /* FIXME: this hack is definitely wrong -AK */
16115 struct __large_struct { unsigned long buf[100]; };
16116 -#define __m(x) (*(struct __large_struct __user *)(x))
16117 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16118 +#define ____m(x) \
16119 +({ \
16120 + unsigned long ____x = (unsigned long)(x); \
16121 + if (____x < PAX_USER_SHADOW_BASE) \
16122 + ____x += PAX_USER_SHADOW_BASE; \
16123 + (void __user *)____x; \
16124 +})
16125 +#else
16126 +#define ____m(x) (x)
16127 +#endif
16128 +#define __m(x) (*(struct __large_struct __user *)____m(x))
16129
16130 /*
16131 * Tell gcc we read from memory instead of writing: this is because
16132 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
16133 */
16134 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16135 asm volatile(ASM_STAC "\n" \
16136 - "1: mov"itype" %"rtype"1,%2\n" \
16137 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
16138 "2: " ASM_CLAC "\n" \
16139 ".section .fixup,\"ax\"\n" \
16140 "3: mov %3,%0\n" \
16141 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
16142 ".previous\n" \
16143 _ASM_EXTABLE(1b, 3b) \
16144 : "=r"(err) \
16145 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
16146 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
16147
16148 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
16149 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
16150 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
16151 "2:\n" \
16152 _ASM_EXTABLE_EX(1b, 2b) \
16153 : : ltype(x), "m" (__m(addr)))
16154 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
16155 * On error, the variable @x is set to zero.
16156 */
16157
16158 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16159 +#define __get_user(x, ptr) get_user((x), (ptr))
16160 +#else
16161 #define __get_user(x, ptr) \
16162 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
16163 +#endif
16164
16165 /**
16166 * __put_user: - Write a simple value into user space, with less checking.
16167 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
16168 * Returns zero on success, or -EFAULT on error.
16169 */
16170
16171 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16172 +#define __put_user(x, ptr) put_user((x), (ptr))
16173 +#else
16174 #define __put_user(x, ptr) \
16175 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
16176 +#endif
16177
16178 #define __get_user_unaligned __get_user
16179 #define __put_user_unaligned __put_user
16180 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
16181 #define get_user_ex(x, ptr) do { \
16182 unsigned long __gue_val; \
16183 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
16184 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
16185 + (x) = (__typeof__(*(ptr)))__gue_val; \
16186 } while (0)
16187
16188 #define put_user_try uaccess_try
16189 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
16190 extern __must_check long strlen_user(const char __user *str);
16191 extern __must_check long strnlen_user(const char __user *str, long n);
16192
16193 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
16194 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
16195 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16196 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16197
16198 /*
16199 * movsl can be slow when source and dest are not both 8-byte aligned
16200 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
16201 index 7f760a9..04b1c65 100644
16202 --- a/arch/x86/include/asm/uaccess_32.h
16203 +++ b/arch/x86/include/asm/uaccess_32.h
16204 @@ -11,15 +11,15 @@
16205 #include <asm/page.h>
16206
16207 unsigned long __must_check __copy_to_user_ll
16208 - (void __user *to, const void *from, unsigned long n);
16209 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
16210 unsigned long __must_check __copy_from_user_ll
16211 - (void *to, const void __user *from, unsigned long n);
16212 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16213 unsigned long __must_check __copy_from_user_ll_nozero
16214 - (void *to, const void __user *from, unsigned long n);
16215 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16216 unsigned long __must_check __copy_from_user_ll_nocache
16217 - (void *to, const void __user *from, unsigned long n);
16218 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16219 unsigned long __must_check __copy_from_user_ll_nocache_nozero
16220 - (void *to, const void __user *from, unsigned long n);
16221 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16222
16223 /**
16224 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
16225 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
16226 static __always_inline unsigned long __must_check
16227 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
16228 {
16229 + if ((long)n < 0)
16230 + return n;
16231 +
16232 + check_object_size(from, n, true);
16233 +
16234 if (__builtin_constant_p(n)) {
16235 unsigned long ret;
16236
16237 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
16238 __copy_to_user(void __user *to, const void *from, unsigned long n)
16239 {
16240 might_fault();
16241 +
16242 return __copy_to_user_inatomic(to, from, n);
16243 }
16244
16245 static __always_inline unsigned long
16246 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
16247 {
16248 + if ((long)n < 0)
16249 + return n;
16250 +
16251 /* Avoid zeroing the tail if the copy fails..
16252 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
16253 * but as the zeroing behaviour is only significant when n is not
16254 @@ -137,6 +146,12 @@ static __always_inline unsigned long
16255 __copy_from_user(void *to, const void __user *from, unsigned long n)
16256 {
16257 might_fault();
16258 +
16259 + if ((long)n < 0)
16260 + return n;
16261 +
16262 + check_object_size(to, n, false);
16263 +
16264 if (__builtin_constant_p(n)) {
16265 unsigned long ret;
16266
16267 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16268 const void __user *from, unsigned long n)
16269 {
16270 might_fault();
16271 +
16272 + if ((long)n < 0)
16273 + return n;
16274 +
16275 if (__builtin_constant_p(n)) {
16276 unsigned long ret;
16277
16278 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16279 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16280 unsigned long n)
16281 {
16282 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16283 + if ((long)n < 0)
16284 + return n;
16285 +
16286 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16287 }
16288
16289 -unsigned long __must_check copy_to_user(void __user *to,
16290 - const void *from, unsigned long n);
16291 -unsigned long __must_check _copy_from_user(void *to,
16292 - const void __user *from,
16293 - unsigned long n);
16294 -
16295 +extern void copy_to_user_overflow(void)
16296 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16297 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16298 +#else
16299 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16300 +#endif
16301 +;
16302
16303 extern void copy_from_user_overflow(void)
16304 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16305 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16306 #endif
16307 ;
16308
16309 -static inline unsigned long __must_check copy_from_user(void *to,
16310 - const void __user *from,
16311 - unsigned long n)
16312 +/**
16313 + * copy_to_user: - Copy a block of data into user space.
16314 + * @to: Destination address, in user space.
16315 + * @from: Source address, in kernel space.
16316 + * @n: Number of bytes to copy.
16317 + *
16318 + * Context: User context only. This function may sleep.
16319 + *
16320 + * Copy data from kernel space to user space.
16321 + *
16322 + * Returns number of bytes that could not be copied.
16323 + * On success, this will be zero.
16324 + */
16325 +static inline unsigned long __must_check
16326 +copy_to_user(void __user *to, const void *from, unsigned long n)
16327 {
16328 - int sz = __compiletime_object_size(to);
16329 + size_t sz = __compiletime_object_size(from);
16330
16331 - if (likely(sz == -1 || sz >= n))
16332 - n = _copy_from_user(to, from, n);
16333 - else
16334 + if (unlikely(sz != (size_t)-1 && sz < n))
16335 + copy_to_user_overflow();
16336 + else if (access_ok(VERIFY_WRITE, to, n))
16337 + n = __copy_to_user(to, from, n);
16338 + return n;
16339 +}
16340 +
16341 +/**
16342 + * copy_from_user: - Copy a block of data from user space.
16343 + * @to: Destination address, in kernel space.
16344 + * @from: Source address, in user space.
16345 + * @n: Number of bytes to copy.
16346 + *
16347 + * Context: User context only. This function may sleep.
16348 + *
16349 + * Copy data from user space to kernel space.
16350 + *
16351 + * Returns number of bytes that could not be copied.
16352 + * On success, this will be zero.
16353 + *
16354 + * If some data could not be copied, this function will pad the copied
16355 + * data to the requested size using zero bytes.
16356 + */
16357 +static inline unsigned long __must_check
16358 +copy_from_user(void *to, const void __user *from, unsigned long n)
16359 +{
16360 + size_t sz = __compiletime_object_size(to);
16361 +
16362 + check_object_size(to, n, false);
16363 +
16364 + if (unlikely(sz != (size_t)-1 && sz < n))
16365 copy_from_user_overflow();
16366 -
16367 + else if (access_ok(VERIFY_READ, from, n))
16368 + n = __copy_from_user(to, from, n);
16369 + else if ((long)n > 0)
16370 + memset(to, 0, n);
16371 return n;
16372 }
16373
16374 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16375 index 142810c..1f2a0a7 100644
16376 --- a/arch/x86/include/asm/uaccess_64.h
16377 +++ b/arch/x86/include/asm/uaccess_64.h
16378 @@ -10,6 +10,9 @@
16379 #include <asm/alternative.h>
16380 #include <asm/cpufeature.h>
16381 #include <asm/page.h>
16382 +#include <asm/pgtable.h>
16383 +
16384 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16385
16386 /*
16387 * Copy To/From Userspace
16388 @@ -17,13 +20,13 @@
16389
16390 /* Handles exceptions in both to and from, but doesn't do access_ok */
16391 __must_check unsigned long
16392 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16393 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16394 __must_check unsigned long
16395 -copy_user_generic_string(void *to, const void *from, unsigned len);
16396 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16397 __must_check unsigned long
16398 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16399 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16400
16401 -static __always_inline __must_check unsigned long
16402 +static __always_inline __must_check __size_overflow(3) unsigned long
16403 copy_user_generic(void *to, const void *from, unsigned len)
16404 {
16405 unsigned ret;
16406 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16407 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16408 "=d" (len)),
16409 "1" (to), "2" (from), "3" (len)
16410 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16411 + : "memory", "rcx", "r8", "r9", "r11");
16412 return ret;
16413 }
16414
16415 +static __always_inline __must_check unsigned long
16416 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16417 +static __always_inline __must_check unsigned long
16418 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16419 __must_check unsigned long
16420 -_copy_to_user(void __user *to, const void *from, unsigned len);
16421 -__must_check unsigned long
16422 -_copy_from_user(void *to, const void __user *from, unsigned len);
16423 -__must_check unsigned long
16424 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16425 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16426 +
16427 +extern void copy_to_user_overflow(void)
16428 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16429 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16430 +#else
16431 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16432 +#endif
16433 +;
16434 +
16435 +extern void copy_from_user_overflow(void)
16436 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16437 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16438 +#else
16439 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16440 +#endif
16441 +;
16442
16443 static inline unsigned long __must_check copy_from_user(void *to,
16444 const void __user *from,
16445 unsigned long n)
16446 {
16447 - int sz = __compiletime_object_size(to);
16448 -
16449 might_fault();
16450 - if (likely(sz == -1 || sz >= n))
16451 - n = _copy_from_user(to, from, n);
16452 -#ifdef CONFIG_DEBUG_VM
16453 - else
16454 - WARN(1, "Buffer overflow detected!\n");
16455 -#endif
16456 +
16457 + check_object_size(to, n, false);
16458 +
16459 + if (access_ok(VERIFY_READ, from, n))
16460 + n = __copy_from_user(to, from, n);
16461 + else if (n < INT_MAX)
16462 + memset(to, 0, n);
16463 return n;
16464 }
16465
16466 static __always_inline __must_check
16467 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16468 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16469 {
16470 might_fault();
16471
16472 - return _copy_to_user(dst, src, size);
16473 + if (access_ok(VERIFY_WRITE, dst, size))
16474 + size = __copy_to_user(dst, src, size);
16475 + return size;
16476 }
16477
16478 static __always_inline __must_check
16479 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16480 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16481 {
16482 - int ret = 0;
16483 + size_t sz = __compiletime_object_size(dst);
16484 + unsigned ret = 0;
16485
16486 might_fault();
16487 +
16488 + if (size > INT_MAX)
16489 + return size;
16490 +
16491 + check_object_size(dst, size, false);
16492 +
16493 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16494 + if (!__access_ok(VERIFY_READ, src, size))
16495 + return size;
16496 +#endif
16497 +
16498 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16499 + copy_from_user_overflow();
16500 + return size;
16501 + }
16502 +
16503 if (!__builtin_constant_p(size))
16504 - return copy_user_generic(dst, (__force void *)src, size);
16505 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16506 switch (size) {
16507 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16508 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16509 ret, "b", "b", "=q", 1);
16510 return ret;
16511 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16512 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16513 ret, "w", "w", "=r", 2);
16514 return ret;
16515 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16516 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16517 ret, "l", "k", "=r", 4);
16518 return ret;
16519 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16520 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16521 ret, "q", "", "=r", 8);
16522 return ret;
16523 case 10:
16524 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16525 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16526 ret, "q", "", "=r", 10);
16527 if (unlikely(ret))
16528 return ret;
16529 __get_user_asm(*(u16 *)(8 + (char *)dst),
16530 - (u16 __user *)(8 + (char __user *)src),
16531 + (const u16 __user *)(8 + (const char __user *)src),
16532 ret, "w", "w", "=r", 2);
16533 return ret;
16534 case 16:
16535 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16536 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16537 ret, "q", "", "=r", 16);
16538 if (unlikely(ret))
16539 return ret;
16540 __get_user_asm(*(u64 *)(8 + (char *)dst),
16541 - (u64 __user *)(8 + (char __user *)src),
16542 + (const u64 __user *)(8 + (const char __user *)src),
16543 ret, "q", "", "=r", 8);
16544 return ret;
16545 default:
16546 - return copy_user_generic(dst, (__force void *)src, size);
16547 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16548 }
16549 }
16550
16551 static __always_inline __must_check
16552 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16553 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16554 {
16555 - int ret = 0;
16556 + size_t sz = __compiletime_object_size(src);
16557 + unsigned ret = 0;
16558
16559 might_fault();
16560 +
16561 + if (size > INT_MAX)
16562 + return size;
16563 +
16564 + check_object_size(src, size, true);
16565 +
16566 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16567 + if (!__access_ok(VERIFY_WRITE, dst, size))
16568 + return size;
16569 +#endif
16570 +
16571 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16572 + copy_to_user_overflow();
16573 + return size;
16574 + }
16575 +
16576 if (!__builtin_constant_p(size))
16577 - return copy_user_generic((__force void *)dst, src, size);
16578 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16579 switch (size) {
16580 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16581 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16582 ret, "b", "b", "iq", 1);
16583 return ret;
16584 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16585 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16586 ret, "w", "w", "ir", 2);
16587 return ret;
16588 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16589 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16590 ret, "l", "k", "ir", 4);
16591 return ret;
16592 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16593 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16594 ret, "q", "", "er", 8);
16595 return ret;
16596 case 10:
16597 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16598 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16599 ret, "q", "", "er", 10);
16600 if (unlikely(ret))
16601 return ret;
16602 asm("":::"memory");
16603 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16604 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16605 ret, "w", "w", "ir", 2);
16606 return ret;
16607 case 16:
16608 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16609 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16610 ret, "q", "", "er", 16);
16611 if (unlikely(ret))
16612 return ret;
16613 asm("":::"memory");
16614 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16615 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16616 ret, "q", "", "er", 8);
16617 return ret;
16618 default:
16619 - return copy_user_generic((__force void *)dst, src, size);
16620 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16621 }
16622 }
16623
16624 static __always_inline __must_check
16625 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16626 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16627 {
16628 - int ret = 0;
16629 + unsigned ret = 0;
16630
16631 might_fault();
16632 +
16633 + if (size > INT_MAX)
16634 + return size;
16635 +
16636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16637 + if (!__access_ok(VERIFY_READ, src, size))
16638 + return size;
16639 + if (!__access_ok(VERIFY_WRITE, dst, size))
16640 + return size;
16641 +#endif
16642 +
16643 if (!__builtin_constant_p(size))
16644 - return copy_user_generic((__force void *)dst,
16645 - (__force void *)src, size);
16646 + return copy_user_generic((__force_kernel void *)____m(dst),
16647 + (__force_kernel const void *)____m(src), size);
16648 switch (size) {
16649 case 1: {
16650 u8 tmp;
16651 - __get_user_asm(tmp, (u8 __user *)src,
16652 + __get_user_asm(tmp, (const u8 __user *)src,
16653 ret, "b", "b", "=q", 1);
16654 if (likely(!ret))
16655 __put_user_asm(tmp, (u8 __user *)dst,
16656 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16657 }
16658 case 2: {
16659 u16 tmp;
16660 - __get_user_asm(tmp, (u16 __user *)src,
16661 + __get_user_asm(tmp, (const u16 __user *)src,
16662 ret, "w", "w", "=r", 2);
16663 if (likely(!ret))
16664 __put_user_asm(tmp, (u16 __user *)dst,
16665 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16666
16667 case 4: {
16668 u32 tmp;
16669 - __get_user_asm(tmp, (u32 __user *)src,
16670 + __get_user_asm(tmp, (const u32 __user *)src,
16671 ret, "l", "k", "=r", 4);
16672 if (likely(!ret))
16673 __put_user_asm(tmp, (u32 __user *)dst,
16674 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16675 }
16676 case 8: {
16677 u64 tmp;
16678 - __get_user_asm(tmp, (u64 __user *)src,
16679 + __get_user_asm(tmp, (const u64 __user *)src,
16680 ret, "q", "", "=r", 8);
16681 if (likely(!ret))
16682 __put_user_asm(tmp, (u64 __user *)dst,
16683 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16684 return ret;
16685 }
16686 default:
16687 - return copy_user_generic((__force void *)dst,
16688 - (__force void *)src, size);
16689 + return copy_user_generic((__force_kernel void *)____m(dst),
16690 + (__force_kernel const void *)____m(src), size);
16691 }
16692 }
16693
16694 static __must_check __always_inline int
16695 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16696 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16697 {
16698 - return copy_user_generic(dst, (__force const void *)src, size);
16699 + if (size > INT_MAX)
16700 + return size;
16701 +
16702 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16703 + if (!__access_ok(VERIFY_READ, src, size))
16704 + return size;
16705 +#endif
16706 +
16707 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16708 }
16709
16710 -static __must_check __always_inline int
16711 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16712 +static __must_check __always_inline unsigned long
16713 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16714 {
16715 - return copy_user_generic((__force void *)dst, src, size);
16716 + if (size > INT_MAX)
16717 + return size;
16718 +
16719 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16720 + if (!__access_ok(VERIFY_WRITE, dst, size))
16721 + return size;
16722 +#endif
16723 +
16724 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16725 }
16726
16727 -extern long __copy_user_nocache(void *dst, const void __user *src,
16728 - unsigned size, int zerorest);
16729 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16730 + unsigned long size, int zerorest) __size_overflow(3);
16731
16732 -static inline int
16733 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16734 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16735 {
16736 might_sleep();
16737 +
16738 + if (size > INT_MAX)
16739 + return size;
16740 +
16741 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16742 + if (!__access_ok(VERIFY_READ, src, size))
16743 + return size;
16744 +#endif
16745 +
16746 return __copy_user_nocache(dst, src, size, 1);
16747 }
16748
16749 -static inline int
16750 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16751 - unsigned size)
16752 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16753 + unsigned long size)
16754 {
16755 + if (size > INT_MAX)
16756 + return size;
16757 +
16758 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16759 + if (!__access_ok(VERIFY_READ, src, size))
16760 + return size;
16761 +#endif
16762 +
16763 return __copy_user_nocache(dst, src, size, 0);
16764 }
16765
16766 -unsigned long
16767 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16768 +extern unsigned long
16769 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16770
16771 #endif /* _ASM_X86_UACCESS_64_H */
16772 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16773 index 5b238981..77fdd78 100644
16774 --- a/arch/x86/include/asm/word-at-a-time.h
16775 +++ b/arch/x86/include/asm/word-at-a-time.h
16776 @@ -11,7 +11,7 @@
16777 * and shift, for example.
16778 */
16779 struct word_at_a_time {
16780 - const unsigned long one_bits, high_bits;
16781 + unsigned long one_bits, high_bits;
16782 };
16783
16784 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16785 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16786 index 5769349..a3d3e2a 100644
16787 --- a/arch/x86/include/asm/x86_init.h
16788 +++ b/arch/x86/include/asm/x86_init.h
16789 @@ -141,7 +141,7 @@ struct x86_init_ops {
16790 struct x86_init_timers timers;
16791 struct x86_init_iommu iommu;
16792 struct x86_init_pci pci;
16793 -};
16794 +} __no_const;
16795
16796 /**
16797 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16798 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16799 void (*setup_percpu_clockev)(void);
16800 void (*early_percpu_clock_init)(void);
16801 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16802 -};
16803 +} __no_const;
16804
16805 /**
16806 * struct x86_platform_ops - platform specific runtime functions
16807 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16808 void (*save_sched_clock_state)(void);
16809 void (*restore_sched_clock_state)(void);
16810 void (*apic_post_init)(void);
16811 -};
16812 +} __no_const;
16813
16814 struct pci_dev;
16815
16816 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16817 void (*teardown_msi_irq)(unsigned int irq);
16818 void (*teardown_msi_irqs)(struct pci_dev *dev);
16819 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16820 -};
16821 +} __no_const;
16822
16823 struct x86_io_apic_ops {
16824 void (*init) (void);
16825 unsigned int (*read) (unsigned int apic, unsigned int reg);
16826 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16827 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16828 -};
16829 +} __no_const;
16830
16831 extern struct x86_init_ops x86_init;
16832 extern struct x86_cpuinit_ops x86_cpuinit;
16833 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16834 index 0415cda..b43d877 100644
16835 --- a/arch/x86/include/asm/xsave.h
16836 +++ b/arch/x86/include/asm/xsave.h
16837 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16838 return -EFAULT;
16839
16840 __asm__ __volatile__(ASM_STAC "\n"
16841 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16842 + "1:"
16843 + __copyuser_seg
16844 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16845 "2: " ASM_CLAC "\n"
16846 ".section .fixup,\"ax\"\n"
16847 "3: movl $-1,%[err]\n"
16848 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16849 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16850 {
16851 int err;
16852 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16853 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16854 u32 lmask = mask;
16855 u32 hmask = mask >> 32;
16856
16857 __asm__ __volatile__(ASM_STAC "\n"
16858 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16859 + "1:"
16860 + __copyuser_seg
16861 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16862 "2: " ASM_CLAC "\n"
16863 ".section .fixup,\"ax\"\n"
16864 "3: movl $-1,%[err]\n"
16865 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16866 index bbae024..e1528f9 100644
16867 --- a/arch/x86/include/uapi/asm/e820.h
16868 +++ b/arch/x86/include/uapi/asm/e820.h
16869 @@ -63,7 +63,7 @@ struct e820map {
16870 #define ISA_START_ADDRESS 0xa0000
16871 #define ISA_END_ADDRESS 0x100000
16872
16873 -#define BIOS_BEGIN 0x000a0000
16874 +#define BIOS_BEGIN 0x000c0000
16875 #define BIOS_END 0x00100000
16876
16877 #define BIOS_ROM_BASE 0xffe00000
16878 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16879 index 34e923a..0c6bb6e 100644
16880 --- a/arch/x86/kernel/Makefile
16881 +++ b/arch/x86/kernel/Makefile
16882 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16883 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16884 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16885 obj-y += probe_roms.o
16886 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16887 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16888 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16889 obj-y += syscall_$(BITS).o
16890 obj-$(CONFIG_X86_64) += vsyscall_64.o
16891 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16892 index bacf4b0..4ede72e 100644
16893 --- a/arch/x86/kernel/acpi/boot.c
16894 +++ b/arch/x86/kernel/acpi/boot.c
16895 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16896 * If your system is blacklisted here, but you find that acpi=force
16897 * works for you, please contact linux-acpi@vger.kernel.org
16898 */
16899 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16900 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16901 /*
16902 * Boxes that need ACPI disabled
16903 */
16904 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16905 };
16906
16907 /* second table for DMI checks that should run after early-quirks */
16908 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16909 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16910 /*
16911 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16912 * which includes some code which overrides all temperature
16913 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16914 index d5e0d71..6533e08 100644
16915 --- a/arch/x86/kernel/acpi/sleep.c
16916 +++ b/arch/x86/kernel/acpi/sleep.c
16917 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16918 #else /* CONFIG_64BIT */
16919 #ifdef CONFIG_SMP
16920 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16921 +
16922 + pax_open_kernel();
16923 early_gdt_descr.address =
16924 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16925 + pax_close_kernel();
16926 +
16927 initial_gs = per_cpu_offset(smp_processor_id());
16928 #endif
16929 initial_code = (unsigned long)wakeup_long64;
16930 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16931 index 13ab720..95d5442 100644
16932 --- a/arch/x86/kernel/acpi/wakeup_32.S
16933 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16934 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16935 # and restore the stack ... but you need gdt for this to work
16936 movl saved_context_esp, %esp
16937
16938 - movl %cs:saved_magic, %eax
16939 - cmpl $0x12345678, %eax
16940 + cmpl $0x12345678, saved_magic
16941 jne bogus_magic
16942
16943 # jump to place where we left off
16944 - movl saved_eip, %eax
16945 - jmp *%eax
16946 + jmp *(saved_eip)
16947
16948 bogus_magic:
16949 jmp bogus_magic
16950 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16951 index ef5ccca..bd83949 100644
16952 --- a/arch/x86/kernel/alternative.c
16953 +++ b/arch/x86/kernel/alternative.c
16954 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16955 */
16956 for (a = start; a < end; a++) {
16957 instr = (u8 *)&a->instr_offset + a->instr_offset;
16958 +
16959 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16960 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16961 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16962 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16963 +#endif
16964 +
16965 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16966 BUG_ON(a->replacementlen > a->instrlen);
16967 BUG_ON(a->instrlen > sizeof(insnbuf));
16968 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16969 for (poff = start; poff < end; poff++) {
16970 u8 *ptr = (u8 *)poff + *poff;
16971
16972 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16973 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16974 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16975 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16976 +#endif
16977 +
16978 if (!*poff || ptr < text || ptr >= text_end)
16979 continue;
16980 /* turn DS segment override prefix into lock prefix */
16981 - if (*ptr == 0x3e)
16982 + if (*ktla_ktva(ptr) == 0x3e)
16983 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16984 }
16985 mutex_unlock(&text_mutex);
16986 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16987 for (poff = start; poff < end; poff++) {
16988 u8 *ptr = (u8 *)poff + *poff;
16989
16990 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16991 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16992 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16993 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16994 +#endif
16995 +
16996 if (!*poff || ptr < text || ptr >= text_end)
16997 continue;
16998 /* turn lock prefix into DS segment override prefix */
16999 - if (*ptr == 0xf0)
17000 + if (*ktla_ktva(ptr) == 0xf0)
17001 text_poke(ptr, ((unsigned char []){0x3E}), 1);
17002 }
17003 mutex_unlock(&text_mutex);
17004 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
17005
17006 BUG_ON(p->len > MAX_PATCH_LEN);
17007 /* prep the buffer with the original instructions */
17008 - memcpy(insnbuf, p->instr, p->len);
17009 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
17010 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
17011 (unsigned long)p->instr, p->len);
17012
17013 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
17014 if (!uniproc_patched || num_possible_cpus() == 1)
17015 free_init_pages("SMP alternatives",
17016 (unsigned long)__smp_locks,
17017 - (unsigned long)__smp_locks_end);
17018 + PAGE_ALIGN((unsigned long)__smp_locks_end));
17019 #endif
17020
17021 apply_paravirt(__parainstructions, __parainstructions_end);
17022 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
17023 * instructions. And on the local CPU you need to be protected again NMI or MCE
17024 * handlers seeing an inconsistent instruction while you patch.
17025 */
17026 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
17027 +void *__kprobes text_poke_early(void *addr, const void *opcode,
17028 size_t len)
17029 {
17030 unsigned long flags;
17031 local_irq_save(flags);
17032 - memcpy(addr, opcode, len);
17033 +
17034 + pax_open_kernel();
17035 + memcpy(ktla_ktva(addr), opcode, len);
17036 sync_core();
17037 + pax_close_kernel();
17038 +
17039 local_irq_restore(flags);
17040 /* Could also do a CLFLUSH here to speed up CPU recovery; but
17041 that causes hangs on some VIA CPUs. */
17042 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
17043 */
17044 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
17045 {
17046 - unsigned long flags;
17047 - char *vaddr;
17048 + unsigned char *vaddr = ktla_ktva(addr);
17049 struct page *pages[2];
17050 - int i;
17051 + size_t i;
17052
17053 if (!core_kernel_text((unsigned long)addr)) {
17054 - pages[0] = vmalloc_to_page(addr);
17055 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
17056 + pages[0] = vmalloc_to_page(vaddr);
17057 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
17058 } else {
17059 - pages[0] = virt_to_page(addr);
17060 + pages[0] = virt_to_page(vaddr);
17061 WARN_ON(!PageReserved(pages[0]));
17062 - pages[1] = virt_to_page(addr + PAGE_SIZE);
17063 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
17064 }
17065 BUG_ON(!pages[0]);
17066 - local_irq_save(flags);
17067 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
17068 - if (pages[1])
17069 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
17070 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
17071 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
17072 - clear_fixmap(FIX_TEXT_POKE0);
17073 - if (pages[1])
17074 - clear_fixmap(FIX_TEXT_POKE1);
17075 - local_flush_tlb();
17076 - sync_core();
17077 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
17078 - that causes hangs on some VIA CPUs. */
17079 + text_poke_early(addr, opcode, len);
17080 for (i = 0; i < len; i++)
17081 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
17082 - local_irq_restore(flags);
17083 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
17084 return addr;
17085 }
17086
17087 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
17088 index cbf5121..812b537 100644
17089 --- a/arch/x86/kernel/apic/apic.c
17090 +++ b/arch/x86/kernel/apic/apic.c
17091 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
17092 /*
17093 * Debug level, exported for io_apic.c
17094 */
17095 -unsigned int apic_verbosity;
17096 +int apic_verbosity;
17097
17098 int pic_mode;
17099
17100 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
17101 apic_write(APIC_ESR, 0);
17102 v1 = apic_read(APIC_ESR);
17103 ack_APIC_irq();
17104 - atomic_inc(&irq_err_count);
17105 + atomic_inc_unchecked(&irq_err_count);
17106
17107 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
17108 smp_processor_id(), v0 , v1);
17109 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
17110 index 00c77cf..2dc6a2d 100644
17111 --- a/arch/x86/kernel/apic/apic_flat_64.c
17112 +++ b/arch/x86/kernel/apic/apic_flat_64.c
17113 @@ -157,7 +157,7 @@ static int flat_probe(void)
17114 return 1;
17115 }
17116
17117 -static struct apic apic_flat = {
17118 +static struct apic apic_flat __read_only = {
17119 .name = "flat",
17120 .probe = flat_probe,
17121 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
17122 @@ -271,7 +271,7 @@ static int physflat_probe(void)
17123 return 0;
17124 }
17125
17126 -static struct apic apic_physflat = {
17127 +static struct apic apic_physflat __read_only = {
17128
17129 .name = "physical flat",
17130 .probe = physflat_probe,
17131 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
17132 index e145f28..2752888 100644
17133 --- a/arch/x86/kernel/apic/apic_noop.c
17134 +++ b/arch/x86/kernel/apic/apic_noop.c
17135 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
17136 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
17137 }
17138
17139 -struct apic apic_noop = {
17140 +struct apic apic_noop __read_only = {
17141 .name = "noop",
17142 .probe = noop_probe,
17143 .acpi_madt_oem_check = NULL,
17144 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
17145 index d50e364..543bee3 100644
17146 --- a/arch/x86/kernel/apic/bigsmp_32.c
17147 +++ b/arch/x86/kernel/apic/bigsmp_32.c
17148 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
17149 return dmi_bigsmp;
17150 }
17151
17152 -static struct apic apic_bigsmp = {
17153 +static struct apic apic_bigsmp __read_only = {
17154
17155 .name = "bigsmp",
17156 .probe = probe_bigsmp,
17157 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
17158 index 0874799..a7a7892 100644
17159 --- a/arch/x86/kernel/apic/es7000_32.c
17160 +++ b/arch/x86/kernel/apic/es7000_32.c
17161 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
17162 return ret && es7000_apic_is_cluster();
17163 }
17164
17165 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
17166 -static struct apic __refdata apic_es7000_cluster = {
17167 +static struct apic apic_es7000_cluster __read_only = {
17168
17169 .name = "es7000",
17170 .probe = probe_es7000,
17171 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
17172 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
17173 };
17174
17175 -static struct apic __refdata apic_es7000 = {
17176 +static struct apic apic_es7000 __read_only = {
17177
17178 .name = "es7000",
17179 .probe = probe_es7000,
17180 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
17181 index b739d39..aebc14c 100644
17182 --- a/arch/x86/kernel/apic/io_apic.c
17183 +++ b/arch/x86/kernel/apic/io_apic.c
17184 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
17185 }
17186 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
17187
17188 -void lock_vector_lock(void)
17189 +void lock_vector_lock(void) __acquires(vector_lock)
17190 {
17191 /* Used to the online set of cpus does not change
17192 * during assign_irq_vector.
17193 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
17194 raw_spin_lock(&vector_lock);
17195 }
17196
17197 -void unlock_vector_lock(void)
17198 +void unlock_vector_lock(void) __releases(vector_lock)
17199 {
17200 raw_spin_unlock(&vector_lock);
17201 }
17202 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
17203 ack_APIC_irq();
17204 }
17205
17206 -atomic_t irq_mis_count;
17207 +atomic_unchecked_t irq_mis_count;
17208
17209 #ifdef CONFIG_GENERIC_PENDING_IRQ
17210 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
17211 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
17212 * at the cpu.
17213 */
17214 if (!(v & (1 << (i & 0x1f)))) {
17215 - atomic_inc(&irq_mis_count);
17216 + atomic_inc_unchecked(&irq_mis_count);
17217
17218 eoi_ioapic_irq(irq, cfg);
17219 }
17220 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
17221
17222 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
17223 {
17224 - chip->irq_print_chip = ir_print_prefix;
17225 - chip->irq_ack = ir_ack_apic_edge;
17226 - chip->irq_eoi = ir_ack_apic_level;
17227 + pax_open_kernel();
17228 + *(void **)&chip->irq_print_chip = ir_print_prefix;
17229 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
17230 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
17231
17232 - chip->irq_set_affinity = set_remapped_irq_affinity;
17233 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
17234 + pax_close_kernel();
17235 }
17236 #endif /* CONFIG_IRQ_REMAP */
17237
17238 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
17239 index d661ee9..791fd33 100644
17240 --- a/arch/x86/kernel/apic/numaq_32.c
17241 +++ b/arch/x86/kernel/apic/numaq_32.c
17242 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
17243 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
17244 }
17245
17246 -/* Use __refdata to keep false positive warning calm. */
17247 -static struct apic __refdata apic_numaq = {
17248 +static struct apic apic_numaq __read_only = {
17249
17250 .name = "NUMAQ",
17251 .probe = probe_numaq,
17252 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
17253 index eb35ef9..f184a21 100644
17254 --- a/arch/x86/kernel/apic/probe_32.c
17255 +++ b/arch/x86/kernel/apic/probe_32.c
17256 @@ -72,7 +72,7 @@ static int probe_default(void)
17257 return 1;
17258 }
17259
17260 -static struct apic apic_default = {
17261 +static struct apic apic_default __read_only = {
17262
17263 .name = "default",
17264 .probe = probe_default,
17265 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
17266 index 77c95c0..434f8a4 100644
17267 --- a/arch/x86/kernel/apic/summit_32.c
17268 +++ b/arch/x86/kernel/apic/summit_32.c
17269 @@ -486,7 +486,7 @@ void setup_summit(void)
17270 }
17271 #endif
17272
17273 -static struct apic apic_summit = {
17274 +static struct apic apic_summit __read_only = {
17275
17276 .name = "summit",
17277 .probe = probe_summit,
17278 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
17279 index c88baa4..757aee1 100644
17280 --- a/arch/x86/kernel/apic/x2apic_cluster.c
17281 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17282 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17283 return notifier_from_errno(err);
17284 }
17285
17286 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17287 +static struct notifier_block x2apic_cpu_notifier = {
17288 .notifier_call = update_clusterinfo,
17289 };
17290
17291 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17292 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17293 }
17294
17295 -static struct apic apic_x2apic_cluster = {
17296 +static struct apic apic_x2apic_cluster __read_only = {
17297
17298 .name = "cluster x2apic",
17299 .probe = x2apic_cluster_probe,
17300 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17301 index 562a76d..a003c0f 100644
17302 --- a/arch/x86/kernel/apic/x2apic_phys.c
17303 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17304 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17305 return apic == &apic_x2apic_phys;
17306 }
17307
17308 -static struct apic apic_x2apic_phys = {
17309 +static struct apic apic_x2apic_phys __read_only = {
17310
17311 .name = "physical x2apic",
17312 .probe = x2apic_phys_probe,
17313 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17314 index 8cfade9..b9d04fc 100644
17315 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17316 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17317 @@ -333,7 +333,7 @@ static int uv_probe(void)
17318 return apic == &apic_x2apic_uv_x;
17319 }
17320
17321 -static struct apic __refdata apic_x2apic_uv_x = {
17322 +static struct apic apic_x2apic_uv_x __read_only = {
17323
17324 .name = "UV large system",
17325 .probe = uv_probe,
17326 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17327 index d65464e..1035d31 100644
17328 --- a/arch/x86/kernel/apm_32.c
17329 +++ b/arch/x86/kernel/apm_32.c
17330 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
17331 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17332 * even though they are called in protected mode.
17333 */
17334 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17335 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17336 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17337
17338 static const char driver_version[] = "1.16ac"; /* no spaces */
17339 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
17340 BUG_ON(cpu != 0);
17341 gdt = get_cpu_gdt_table(cpu);
17342 save_desc_40 = gdt[0x40 / 8];
17343 +
17344 + pax_open_kernel();
17345 gdt[0x40 / 8] = bad_bios_desc;
17346 + pax_close_kernel();
17347
17348 apm_irq_save(flags);
17349 APM_DO_SAVE_SEGS;
17350 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
17351 &call->esi);
17352 APM_DO_RESTORE_SEGS;
17353 apm_irq_restore(flags);
17354 +
17355 + pax_open_kernel();
17356 gdt[0x40 / 8] = save_desc_40;
17357 + pax_close_kernel();
17358 +
17359 put_cpu();
17360
17361 return call->eax & 0xff;
17362 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
17363 BUG_ON(cpu != 0);
17364 gdt = get_cpu_gdt_table(cpu);
17365 save_desc_40 = gdt[0x40 / 8];
17366 +
17367 + pax_open_kernel();
17368 gdt[0x40 / 8] = bad_bios_desc;
17369 + pax_close_kernel();
17370
17371 apm_irq_save(flags);
17372 APM_DO_SAVE_SEGS;
17373 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
17374 &call->eax);
17375 APM_DO_RESTORE_SEGS;
17376 apm_irq_restore(flags);
17377 +
17378 + pax_open_kernel();
17379 gdt[0x40 / 8] = save_desc_40;
17380 + pax_close_kernel();
17381 +
17382 put_cpu();
17383 return error;
17384 }
17385 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
17386 * code to that CPU.
17387 */
17388 gdt = get_cpu_gdt_table(0);
17389 +
17390 + pax_open_kernel();
17391 set_desc_base(&gdt[APM_CS >> 3],
17392 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17393 set_desc_base(&gdt[APM_CS_16 >> 3],
17394 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17395 set_desc_base(&gdt[APM_DS >> 3],
17396 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17397 + pax_close_kernel();
17398
17399 proc_create("apm", 0, NULL, &apm_file_ops);
17400
17401 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17402 index 2861082..6d4718e 100644
17403 --- a/arch/x86/kernel/asm-offsets.c
17404 +++ b/arch/x86/kernel/asm-offsets.c
17405 @@ -33,6 +33,8 @@ void common(void) {
17406 OFFSET(TI_status, thread_info, status);
17407 OFFSET(TI_addr_limit, thread_info, addr_limit);
17408 OFFSET(TI_preempt_count, thread_info, preempt_count);
17409 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17410 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17411
17412 BLANK();
17413 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17414 @@ -53,8 +55,26 @@ void common(void) {
17415 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17416 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17417 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17418 +
17419 +#ifdef CONFIG_PAX_KERNEXEC
17420 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17421 #endif
17422
17423 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17424 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17425 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17426 +#ifdef CONFIG_X86_64
17427 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17428 +#endif
17429 +#endif
17430 +
17431 +#endif
17432 +
17433 + BLANK();
17434 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17435 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17436 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17437 +
17438 #ifdef CONFIG_XEN
17439 BLANK();
17440 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17441 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17442 index 1b4754f..fbb4227 100644
17443 --- a/arch/x86/kernel/asm-offsets_64.c
17444 +++ b/arch/x86/kernel/asm-offsets_64.c
17445 @@ -76,6 +76,7 @@ int main(void)
17446 BLANK();
17447 #undef ENTRY
17448
17449 + DEFINE(TSS_size, sizeof(struct tss_struct));
17450 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17451 BLANK();
17452
17453 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17454 index a0e067d..9c7db16 100644
17455 --- a/arch/x86/kernel/cpu/Makefile
17456 +++ b/arch/x86/kernel/cpu/Makefile
17457 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17458 CFLAGS_REMOVE_perf_event.o = -pg
17459 endif
17460
17461 -# Make sure load_percpu_segment has no stackprotector
17462 -nostackp := $(call cc-option, -fno-stack-protector)
17463 -CFLAGS_common.o := $(nostackp)
17464 -
17465 obj-y := intel_cacheinfo.o scattered.o topology.o
17466 obj-y += proc.o capflags.o powerflags.o common.o
17467 obj-y += vmware.o hypervisor.o mshyperv.o
17468 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17469 index 15239ff..e23e04e 100644
17470 --- a/arch/x86/kernel/cpu/amd.c
17471 +++ b/arch/x86/kernel/cpu/amd.c
17472 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17473 unsigned int size)
17474 {
17475 /* AMD errata T13 (order #21922) */
17476 - if ((c->x86 == 6)) {
17477 + if (c->x86 == 6) {
17478 /* Duron Rev A0 */
17479 if (c->x86_model == 3 && c->x86_mask == 0)
17480 size = 64;
17481 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17482 index 9c3ab43..51e6366 100644
17483 --- a/arch/x86/kernel/cpu/common.c
17484 +++ b/arch/x86/kernel/cpu/common.c
17485 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17486
17487 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17488
17489 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17490 -#ifdef CONFIG_X86_64
17491 - /*
17492 - * We need valid kernel segments for data and code in long mode too
17493 - * IRET will check the segment types kkeil 2000/10/28
17494 - * Also sysret mandates a special GDT layout
17495 - *
17496 - * TLS descriptors are currently at a different place compared to i386.
17497 - * Hopefully nobody expects them at a fixed place (Wine?)
17498 - */
17499 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17500 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17501 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17502 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17503 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17504 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17505 -#else
17506 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17507 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17508 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17509 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17510 - /*
17511 - * Segments used for calling PnP BIOS have byte granularity.
17512 - * They code segments and data segments have fixed 64k limits,
17513 - * the transfer segment sizes are set at run time.
17514 - */
17515 - /* 32-bit code */
17516 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17517 - /* 16-bit code */
17518 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17519 - /* 16-bit data */
17520 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17521 - /* 16-bit data */
17522 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17523 - /* 16-bit data */
17524 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17525 - /*
17526 - * The APM segments have byte granularity and their bases
17527 - * are set at run time. All have 64k limits.
17528 - */
17529 - /* 32-bit code */
17530 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17531 - /* 16-bit code */
17532 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17533 - /* data */
17534 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17535 -
17536 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17537 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17538 - GDT_STACK_CANARY_INIT
17539 -#endif
17540 -} };
17541 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17542 -
17543 static int __init x86_xsave_setup(char *s)
17544 {
17545 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17546 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17547 {
17548 struct desc_ptr gdt_descr;
17549
17550 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17551 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17552 gdt_descr.size = GDT_SIZE - 1;
17553 load_gdt(&gdt_descr);
17554 /* Reload the per-cpu base */
17555 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17556 /* Filter out anything that depends on CPUID levels we don't have */
17557 filter_cpuid_features(c, true);
17558
17559 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17560 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17561 +#endif
17562 +
17563 /* If the model name is still unset, do table lookup. */
17564 if (!c->x86_model_id[0]) {
17565 const char *p;
17566 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17567 }
17568 __setup("clearcpuid=", setup_disablecpuid);
17569
17570 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17571 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17572 +
17573 #ifdef CONFIG_X86_64
17574 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17575 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17576 - (unsigned long) nmi_idt_table };
17577 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17578
17579 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17580 irq_stack_union) __aligned(PAGE_SIZE);
17581 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17582 EXPORT_PER_CPU_SYMBOL(current_task);
17583
17584 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17585 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17586 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17587 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17588
17589 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17590 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17591 int i;
17592
17593 cpu = stack_smp_processor_id();
17594 - t = &per_cpu(init_tss, cpu);
17595 + t = init_tss + cpu;
17596 oist = &per_cpu(orig_ist, cpu);
17597
17598 #ifdef CONFIG_NUMA
17599 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17600 switch_to_new_gdt(cpu);
17601 loadsegment(fs, 0);
17602
17603 - load_idt((const struct desc_ptr *)&idt_descr);
17604 + load_idt(&idt_descr);
17605
17606 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17607 syscall_init();
17608 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17609 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17610 barrier();
17611
17612 - x86_configure_nx();
17613 enable_x2apic();
17614
17615 /*
17616 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17617 {
17618 int cpu = smp_processor_id();
17619 struct task_struct *curr = current;
17620 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17621 + struct tss_struct *t = init_tss + cpu;
17622 struct thread_struct *thread = &curr->thread;
17623
17624 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17625 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17626 index fcaabd0..7b55a26 100644
17627 --- a/arch/x86/kernel/cpu/intel.c
17628 +++ b/arch/x86/kernel/cpu/intel.c
17629 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17630 * Update the IDT descriptor and reload the IDT so that
17631 * it uses the read-only mapped virtual address.
17632 */
17633 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17634 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17635 load_idt(&idt_descr);
17636 }
17637 #endif
17638 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17639 index 84c1309..39b7224 100644
17640 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17641 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17642 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17643 };
17644
17645 #ifdef CONFIG_AMD_NB
17646 +static struct attribute *default_attrs_amd_nb[] = {
17647 + &type.attr,
17648 + &level.attr,
17649 + &coherency_line_size.attr,
17650 + &physical_line_partition.attr,
17651 + &ways_of_associativity.attr,
17652 + &number_of_sets.attr,
17653 + &size.attr,
17654 + &shared_cpu_map.attr,
17655 + &shared_cpu_list.attr,
17656 + NULL,
17657 + NULL,
17658 + NULL,
17659 + NULL
17660 +};
17661 +
17662 static struct attribute ** __cpuinit amd_l3_attrs(void)
17663 {
17664 static struct attribute **attrs;
17665 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17666
17667 n = ARRAY_SIZE(default_attrs);
17668
17669 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17670 - n += 2;
17671 -
17672 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17673 - n += 1;
17674 -
17675 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17676 - if (attrs == NULL)
17677 - return attrs = default_attrs;
17678 -
17679 - for (n = 0; default_attrs[n]; n++)
17680 - attrs[n] = default_attrs[n];
17681 + attrs = default_attrs_amd_nb;
17682
17683 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17684 attrs[n++] = &cache_disable_0.attr;
17685 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17686 .default_attrs = default_attrs,
17687 };
17688
17689 +#ifdef CONFIG_AMD_NB
17690 +static struct kobj_type ktype_cache_amd_nb = {
17691 + .sysfs_ops = &sysfs_ops,
17692 + .default_attrs = default_attrs_amd_nb,
17693 +};
17694 +#endif
17695 +
17696 static struct kobj_type ktype_percpu_entry = {
17697 .sysfs_ops = &sysfs_ops,
17698 };
17699 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17700 return retval;
17701 }
17702
17703 +#ifdef CONFIG_AMD_NB
17704 + amd_l3_attrs();
17705 +#endif
17706 +
17707 for (i = 0; i < num_cache_leaves; i++) {
17708 + struct kobj_type *ktype;
17709 +
17710 this_object = INDEX_KOBJECT_PTR(cpu, i);
17711 this_object->cpu = cpu;
17712 this_object->index = i;
17713
17714 this_leaf = CPUID4_INFO_IDX(cpu, i);
17715
17716 - ktype_cache.default_attrs = default_attrs;
17717 + ktype = &ktype_cache;
17718 #ifdef CONFIG_AMD_NB
17719 if (this_leaf->base.nb)
17720 - ktype_cache.default_attrs = amd_l3_attrs();
17721 + ktype = &ktype_cache_amd_nb;
17722 #endif
17723 retval = kobject_init_and_add(&(this_object->kobj),
17724 - &ktype_cache,
17725 + ktype,
17726 per_cpu(ici_cache_kobject, cpu),
17727 "index%1lu", i);
17728 if (unlikely(retval)) {
17729 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17730 return NOTIFY_OK;
17731 }
17732
17733 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17734 +static struct notifier_block cacheinfo_cpu_notifier = {
17735 .notifier_call = cacheinfo_cpu_callback,
17736 };
17737
17738 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17739 index 80dbda8..be16652 100644
17740 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17741 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17742 @@ -45,6 +45,7 @@
17743 #include <asm/processor.h>
17744 #include <asm/mce.h>
17745 #include <asm/msr.h>
17746 +#include <asm/local.h>
17747
17748 #include "mce-internal.h"
17749
17750 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17751 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17752 m->cs, m->ip);
17753
17754 - if (m->cs == __KERNEL_CS)
17755 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17756 print_symbol("{%s}", m->ip);
17757 pr_cont("\n");
17758 }
17759 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17760
17761 #define PANIC_TIMEOUT 5 /* 5 seconds */
17762
17763 -static atomic_t mce_paniced;
17764 +static atomic_unchecked_t mce_paniced;
17765
17766 static int fake_panic;
17767 -static atomic_t mce_fake_paniced;
17768 +static atomic_unchecked_t mce_fake_paniced;
17769
17770 /* Panic in progress. Enable interrupts and wait for final IPI */
17771 static void wait_for_panic(void)
17772 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17773 /*
17774 * Make sure only one CPU runs in machine check panic
17775 */
17776 - if (atomic_inc_return(&mce_paniced) > 1)
17777 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17778 wait_for_panic();
17779 barrier();
17780
17781 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17782 console_verbose();
17783 } else {
17784 /* Don't log too much for fake panic */
17785 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17786 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17787 return;
17788 }
17789 /* First print corrected ones that are still unlogged */
17790 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17791 * might have been modified by someone else.
17792 */
17793 rmb();
17794 - if (atomic_read(&mce_paniced))
17795 + if (atomic_read_unchecked(&mce_paniced))
17796 wait_for_panic();
17797 if (!mca_cfg.monarch_timeout)
17798 goto out;
17799 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17800 }
17801
17802 /* Call the installed machine check handler for this CPU setup. */
17803 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17804 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17805 unexpected_machine_check;
17806
17807 /*
17808 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17809 return;
17810 }
17811
17812 + pax_open_kernel();
17813 machine_check_vector = do_machine_check;
17814 + pax_close_kernel();
17815
17816 __mcheck_cpu_init_generic();
17817 __mcheck_cpu_init_vendor(c);
17818 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17819 */
17820
17821 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17822 -static int mce_chrdev_open_count; /* #times opened */
17823 +static local_t mce_chrdev_open_count; /* #times opened */
17824 static int mce_chrdev_open_exclu; /* already open exclusive? */
17825
17826 static int mce_chrdev_open(struct inode *inode, struct file *file)
17827 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17828 spin_lock(&mce_chrdev_state_lock);
17829
17830 if (mce_chrdev_open_exclu ||
17831 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17832 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17833 spin_unlock(&mce_chrdev_state_lock);
17834
17835 return -EBUSY;
17836 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17837
17838 if (file->f_flags & O_EXCL)
17839 mce_chrdev_open_exclu = 1;
17840 - mce_chrdev_open_count++;
17841 + local_inc(&mce_chrdev_open_count);
17842
17843 spin_unlock(&mce_chrdev_state_lock);
17844
17845 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17846 {
17847 spin_lock(&mce_chrdev_state_lock);
17848
17849 - mce_chrdev_open_count--;
17850 + local_dec(&mce_chrdev_open_count);
17851 mce_chrdev_open_exclu = 0;
17852
17853 spin_unlock(&mce_chrdev_state_lock);
17854 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17855 return NOTIFY_OK;
17856 }
17857
17858 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17859 +static struct notifier_block mce_cpu_notifier = {
17860 .notifier_call = mce_cpu_callback,
17861 };
17862
17863 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17864
17865 for (i = 0; i < mca_cfg.banks; i++) {
17866 struct mce_bank *b = &mce_banks[i];
17867 - struct device_attribute *a = &b->attr;
17868 + device_attribute_no_const *a = &b->attr;
17869
17870 sysfs_attr_init(&a->attr);
17871 a->attr.name = b->attrname;
17872 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17873 static void mce_reset(void)
17874 {
17875 cpu_missing = 0;
17876 - atomic_set(&mce_fake_paniced, 0);
17877 + atomic_set_unchecked(&mce_fake_paniced, 0);
17878 atomic_set(&mce_executing, 0);
17879 atomic_set(&mce_callin, 0);
17880 atomic_set(&global_nwo, 0);
17881 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17882 index 2d5454c..51987eb 100644
17883 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17884 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17885 @@ -11,6 +11,7 @@
17886 #include <asm/processor.h>
17887 #include <asm/mce.h>
17888 #include <asm/msr.h>
17889 +#include <asm/pgtable.h>
17890
17891 /* By default disabled */
17892 int mce_p5_enabled __read_mostly;
17893 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17894 if (!cpu_has(c, X86_FEATURE_MCE))
17895 return;
17896
17897 + pax_open_kernel();
17898 machine_check_vector = pentium_machine_check;
17899 + pax_close_kernel();
17900 /* Make sure the vector pointer is visible before we enable MCEs: */
17901 wmb();
17902
17903 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17904 index 47a1870..8c019a7 100644
17905 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17906 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17907 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17908 return notifier_from_errno(err);
17909 }
17910
17911 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17912 +static struct notifier_block thermal_throttle_cpu_notifier =
17913 {
17914 .notifier_call = thermal_throttle_cpu_callback,
17915 };
17916 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17917 index 2d7998f..17c9de1 100644
17918 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17919 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17920 @@ -10,6 +10,7 @@
17921 #include <asm/processor.h>
17922 #include <asm/mce.h>
17923 #include <asm/msr.h>
17924 +#include <asm/pgtable.h>
17925
17926 /* Machine check handler for WinChip C6: */
17927 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17928 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17929 {
17930 u32 lo, hi;
17931
17932 + pax_open_kernel();
17933 machine_check_vector = winchip_machine_check;
17934 + pax_close_kernel();
17935 /* Make sure the vector pointer is visible before we enable MCEs: */
17936 wmb();
17937
17938 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17939 index 726bf96..81f0526 100644
17940 --- a/arch/x86/kernel/cpu/mtrr/main.c
17941 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17942 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17943 u64 size_or_mask, size_and_mask;
17944 static bool mtrr_aps_delayed_init;
17945
17946 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17947 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17948
17949 const struct mtrr_ops *mtrr_if;
17950
17951 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17952 index df5e41f..816c719 100644
17953 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17954 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17955 @@ -25,7 +25,7 @@ struct mtrr_ops {
17956 int (*validate_add_page)(unsigned long base, unsigned long size,
17957 unsigned int type);
17958 int (*have_wrcomb)(void);
17959 -};
17960 +} __do_const;
17961
17962 extern int generic_get_free_region(unsigned long base, unsigned long size,
17963 int replace_reg);
17964 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17965 index 6774c17..72c1b22 100644
17966 --- a/arch/x86/kernel/cpu/perf_event.c
17967 +++ b/arch/x86/kernel/cpu/perf_event.c
17968 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17969 pr_info("no hardware sampling interrupt available.\n");
17970 }
17971
17972 -static struct attribute_group x86_pmu_format_group = {
17973 +static attribute_group_no_const x86_pmu_format_group = {
17974 .name = "format",
17975 .attrs = NULL,
17976 };
17977 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17978 struct perf_pmu_events_attr {
17979 struct device_attribute attr;
17980 u64 id;
17981 -};
17982 +} __do_const;
17983
17984 /*
17985 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17986 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17987 NULL,
17988 };
17989
17990 -static struct attribute_group x86_pmu_events_group = {
17991 +static attribute_group_no_const x86_pmu_events_group = {
17992 .name = "events",
17993 .attrs = events_attr,
17994 };
17995 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17996 if (idx > GDT_ENTRIES)
17997 return 0;
17998
17999 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
18000 + desc = get_cpu_gdt_table(smp_processor_id());
18001 }
18002
18003 return get_desc_base(desc + idx);
18004 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
18005 break;
18006
18007 perf_callchain_store(entry, frame.return_address);
18008 - fp = frame.next_frame;
18009 + fp = (const void __force_user *)frame.next_frame;
18010 }
18011 }
18012
18013 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
18014 index 70602f8..9d9edb7 100644
18015 --- a/arch/x86/kernel/cpu/perf_event_intel.c
18016 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
18017 @@ -1964,10 +1964,10 @@ __init int intel_pmu_init(void)
18018 * v2 and above have a perf capabilities MSR
18019 */
18020 if (version > 1) {
18021 - u64 capabilities;
18022 + u64 capabilities = x86_pmu.intel_cap.capabilities;
18023
18024 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
18025 - x86_pmu.intel_cap.capabilities = capabilities;
18026 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
18027 + x86_pmu.intel_cap.capabilities = capabilities;
18028 }
18029
18030 intel_ds_init();
18031 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18032 index b43200d..d235b3e 100644
18033 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18034 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18035 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
18036 static int __init uncore_type_init(struct intel_uncore_type *type)
18037 {
18038 struct intel_uncore_pmu *pmus;
18039 - struct attribute_group *events_group;
18040 + attribute_group_no_const *attr_group;
18041 struct attribute **attrs;
18042 int i, j;
18043
18044 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
18045 while (type->event_descs[i].attr.attr.name)
18046 i++;
18047
18048 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
18049 - sizeof(*events_group), GFP_KERNEL);
18050 - if (!events_group)
18051 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
18052 + sizeof(*attr_group), GFP_KERNEL);
18053 + if (!attr_group)
18054 goto fail;
18055
18056 - attrs = (struct attribute **)(events_group + 1);
18057 - events_group->name = "events";
18058 - events_group->attrs = attrs;
18059 + attrs = (struct attribute **)(attr_group + 1);
18060 + attr_group->name = "events";
18061 + attr_group->attrs = attrs;
18062
18063 for (j = 0; j < i; j++)
18064 attrs[j] = &type->event_descs[j].attr.attr;
18065
18066 - type->events_group = events_group;
18067 + type->events_group = attr_group;
18068 }
18069
18070 type->pmu_group = &uncore_pmu_attr_group;
18071 @@ -2826,7 +2826,7 @@ static int
18072 return NOTIFY_OK;
18073 }
18074
18075 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
18076 +static struct notifier_block uncore_cpu_nb = {
18077 .notifier_call = uncore_cpu_notifier,
18078 /*
18079 * to migrate uncore events, our notifier should be executed
18080 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18081 index e68a455..975a932 100644
18082 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18083 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18084 @@ -428,7 +428,7 @@ struct intel_uncore_box {
18085 struct uncore_event_desc {
18086 struct kobj_attribute attr;
18087 const char *config;
18088 -};
18089 +} __do_const;
18090
18091 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
18092 { \
18093 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
18094 index 60c7891..9e911d3 100644
18095 --- a/arch/x86/kernel/cpuid.c
18096 +++ b/arch/x86/kernel/cpuid.c
18097 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
18098 return notifier_from_errno(err);
18099 }
18100
18101 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
18102 +static struct notifier_block cpuid_class_cpu_notifier =
18103 {
18104 .notifier_call = cpuid_class_cpu_callback,
18105 };
18106 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
18107 index 74467fe..18793d5 100644
18108 --- a/arch/x86/kernel/crash.c
18109 +++ b/arch/x86/kernel/crash.c
18110 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
18111 {
18112 #ifdef CONFIG_X86_32
18113 struct pt_regs fixed_regs;
18114 -#endif
18115
18116 -#ifdef CONFIG_X86_32
18117 - if (!user_mode_vm(regs)) {
18118 + if (!user_mode(regs)) {
18119 crash_fixup_ss_esp(&fixed_regs, regs);
18120 regs = &fixed_regs;
18121 }
18122 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
18123 index 37250fe..bf2ec74 100644
18124 --- a/arch/x86/kernel/doublefault_32.c
18125 +++ b/arch/x86/kernel/doublefault_32.c
18126 @@ -11,7 +11,7 @@
18127
18128 #define DOUBLEFAULT_STACKSIZE (1024)
18129 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
18130 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
18131 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
18132
18133 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
18134
18135 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
18136 unsigned long gdt, tss;
18137
18138 store_gdt(&gdt_desc);
18139 - gdt = gdt_desc.address;
18140 + gdt = (unsigned long)gdt_desc.address;
18141
18142 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
18143
18144 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
18145 /* 0x2 bit is always set */
18146 .flags = X86_EFLAGS_SF | 0x2,
18147 .sp = STACK_START,
18148 - .es = __USER_DS,
18149 + .es = __KERNEL_DS,
18150 .cs = __KERNEL_CS,
18151 .ss = __KERNEL_DS,
18152 - .ds = __USER_DS,
18153 + .ds = __KERNEL_DS,
18154 .fs = __KERNEL_PERCPU,
18155
18156 .__cr3 = __pa_nodebug(swapper_pg_dir),
18157 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
18158 index ae42418b..787c16b 100644
18159 --- a/arch/x86/kernel/dumpstack.c
18160 +++ b/arch/x86/kernel/dumpstack.c
18161 @@ -2,6 +2,9 @@
18162 * Copyright (C) 1991, 1992 Linus Torvalds
18163 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
18164 */
18165 +#ifdef CONFIG_GRKERNSEC_HIDESYM
18166 +#define __INCLUDED_BY_HIDESYM 1
18167 +#endif
18168 #include <linux/kallsyms.h>
18169 #include <linux/kprobes.h>
18170 #include <linux/uaccess.h>
18171 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
18172 static void
18173 print_ftrace_graph_addr(unsigned long addr, void *data,
18174 const struct stacktrace_ops *ops,
18175 - struct thread_info *tinfo, int *graph)
18176 + struct task_struct *task, int *graph)
18177 {
18178 - struct task_struct *task;
18179 unsigned long ret_addr;
18180 int index;
18181
18182 if (addr != (unsigned long)return_to_handler)
18183 return;
18184
18185 - task = tinfo->task;
18186 index = task->curr_ret_stack;
18187
18188 if (!task->ret_stack || index < *graph)
18189 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18190 static inline void
18191 print_ftrace_graph_addr(unsigned long addr, void *data,
18192 const struct stacktrace_ops *ops,
18193 - struct thread_info *tinfo, int *graph)
18194 + struct task_struct *task, int *graph)
18195 { }
18196 #endif
18197
18198 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18199 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
18200 */
18201
18202 -static inline int valid_stack_ptr(struct thread_info *tinfo,
18203 - void *p, unsigned int size, void *end)
18204 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
18205 {
18206 - void *t = tinfo;
18207 if (end) {
18208 if (p < end && p >= (end-THREAD_SIZE))
18209 return 1;
18210 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
18211 }
18212
18213 unsigned long
18214 -print_context_stack(struct thread_info *tinfo,
18215 +print_context_stack(struct task_struct *task, void *stack_start,
18216 unsigned long *stack, unsigned long bp,
18217 const struct stacktrace_ops *ops, void *data,
18218 unsigned long *end, int *graph)
18219 {
18220 struct stack_frame *frame = (struct stack_frame *)bp;
18221
18222 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
18223 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
18224 unsigned long addr;
18225
18226 addr = *stack;
18227 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
18228 } else {
18229 ops->address(data, addr, 0);
18230 }
18231 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18232 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18233 }
18234 stack++;
18235 }
18236 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
18237 EXPORT_SYMBOL_GPL(print_context_stack);
18238
18239 unsigned long
18240 -print_context_stack_bp(struct thread_info *tinfo,
18241 +print_context_stack_bp(struct task_struct *task, void *stack_start,
18242 unsigned long *stack, unsigned long bp,
18243 const struct stacktrace_ops *ops, void *data,
18244 unsigned long *end, int *graph)
18245 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18246 struct stack_frame *frame = (struct stack_frame *)bp;
18247 unsigned long *ret_addr = &frame->return_address;
18248
18249 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
18250 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
18251 unsigned long addr = *ret_addr;
18252
18253 if (!__kernel_text_address(addr))
18254 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18255 ops->address(data, addr, 1);
18256 frame = frame->next_frame;
18257 ret_addr = &frame->return_address;
18258 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18259 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18260 }
18261
18262 return (unsigned long)frame;
18263 @@ -189,7 +188,7 @@ void dump_stack(void)
18264
18265 bp = stack_frame(current, NULL);
18266 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
18267 - current->pid, current->comm, print_tainted(),
18268 + task_pid_nr(current), current->comm, print_tainted(),
18269 init_utsname()->release,
18270 (int)strcspn(init_utsname()->version, " "),
18271 init_utsname()->version);
18272 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
18273 }
18274 EXPORT_SYMBOL_GPL(oops_begin);
18275
18276 +extern void gr_handle_kernel_exploit(void);
18277 +
18278 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18279 {
18280 if (regs && kexec_should_crash(current))
18281 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18282 panic("Fatal exception in interrupt");
18283 if (panic_on_oops)
18284 panic("Fatal exception");
18285 - do_exit(signr);
18286 +
18287 + gr_handle_kernel_exploit();
18288 +
18289 + do_group_exit(signr);
18290 }
18291
18292 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18293 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18294 print_modules();
18295 show_regs(regs);
18296 #ifdef CONFIG_X86_32
18297 - if (user_mode_vm(regs)) {
18298 + if (user_mode(regs)) {
18299 sp = regs->sp;
18300 ss = regs->ss & 0xffff;
18301 } else {
18302 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18303 unsigned long flags = oops_begin();
18304 int sig = SIGSEGV;
18305
18306 - if (!user_mode_vm(regs))
18307 + if (!user_mode(regs))
18308 report_bug(regs->ip, regs);
18309
18310 if (__die(str, regs, err))
18311 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18312 index 1038a41..db2c12b 100644
18313 --- a/arch/x86/kernel/dumpstack_32.c
18314 +++ b/arch/x86/kernel/dumpstack_32.c
18315 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18316 bp = stack_frame(task, regs);
18317
18318 for (;;) {
18319 - struct thread_info *context;
18320 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18321
18322 - context = (struct thread_info *)
18323 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18324 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18325 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18326
18327 - stack = (unsigned long *)context->previous_esp;
18328 - if (!stack)
18329 + if (stack_start == task_stack_page(task))
18330 break;
18331 + stack = *(unsigned long **)stack_start;
18332 if (ops->stack(data, "IRQ") < 0)
18333 break;
18334 touch_nmi_watchdog();
18335 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18336 {
18337 int i;
18338
18339 - __show_regs(regs, !user_mode_vm(regs));
18340 + __show_regs(regs, !user_mode(regs));
18341
18342 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18343 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18344 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18345 * When in-kernel, we also print out the stack and code at the
18346 * time of the fault..
18347 */
18348 - if (!user_mode_vm(regs)) {
18349 + if (!user_mode(regs)) {
18350 unsigned int code_prologue = code_bytes * 43 / 64;
18351 unsigned int code_len = code_bytes;
18352 unsigned char c;
18353 u8 *ip;
18354 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18355
18356 pr_emerg("Stack:\n");
18357 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18358
18359 pr_emerg("Code:");
18360
18361 - ip = (u8 *)regs->ip - code_prologue;
18362 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18363 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18364 /* try starting at IP */
18365 - ip = (u8 *)regs->ip;
18366 + ip = (u8 *)regs->ip + cs_base;
18367 code_len = code_len - code_prologue + 1;
18368 }
18369 for (i = 0; i < code_len; i++, ip++) {
18370 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18371 pr_cont(" Bad EIP value.");
18372 break;
18373 }
18374 - if (ip == (u8 *)regs->ip)
18375 + if (ip == (u8 *)regs->ip + cs_base)
18376 pr_cont(" <%02x>", c);
18377 else
18378 pr_cont(" %02x", c);
18379 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18380 {
18381 unsigned short ud2;
18382
18383 + ip = ktla_ktva(ip);
18384 if (ip < PAGE_OFFSET)
18385 return 0;
18386 if (probe_kernel_address((unsigned short *)ip, ud2))
18387 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18388
18389 return ud2 == 0x0b0f;
18390 }
18391 +
18392 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18393 +void pax_check_alloca(unsigned long size)
18394 +{
18395 + unsigned long sp = (unsigned long)&sp, stack_left;
18396 +
18397 + /* all kernel stacks are of the same size */
18398 + stack_left = sp & (THREAD_SIZE - 1);
18399 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18400 +}
18401 +EXPORT_SYMBOL(pax_check_alloca);
18402 +#endif
18403 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18404 index b653675..51cc8c0 100644
18405 --- a/arch/x86/kernel/dumpstack_64.c
18406 +++ b/arch/x86/kernel/dumpstack_64.c
18407 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18408 unsigned long *irq_stack_end =
18409 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18410 unsigned used = 0;
18411 - struct thread_info *tinfo;
18412 int graph = 0;
18413 unsigned long dummy;
18414 + void *stack_start;
18415
18416 if (!task)
18417 task = current;
18418 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18419 * current stack address. If the stacks consist of nested
18420 * exceptions
18421 */
18422 - tinfo = task_thread_info(task);
18423 for (;;) {
18424 char *id;
18425 unsigned long *estack_end;
18426 +
18427 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18428 &used, &id);
18429
18430 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18431 if (ops->stack(data, id) < 0)
18432 break;
18433
18434 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18435 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18436 data, estack_end, &graph);
18437 ops->stack(data, "<EOE>");
18438 /*
18439 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18440 * second-to-last pointer (index -2 to end) in the
18441 * exception stack:
18442 */
18443 + if ((u16)estack_end[-1] != __KERNEL_DS)
18444 + goto out;
18445 stack = (unsigned long *) estack_end[-2];
18446 continue;
18447 }
18448 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18449 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18450 if (ops->stack(data, "IRQ") < 0)
18451 break;
18452 - bp = ops->walk_stack(tinfo, stack, bp,
18453 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18454 ops, data, irq_stack_end, &graph);
18455 /*
18456 * We link to the next stack (which would be
18457 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18458 /*
18459 * This handles the process stack:
18460 */
18461 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18462 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18463 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18464 +out:
18465 put_cpu();
18466 }
18467 EXPORT_SYMBOL(dump_trace);
18468 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18469 {
18470 int i;
18471 unsigned long sp;
18472 - const int cpu = smp_processor_id();
18473 + const int cpu = raw_smp_processor_id();
18474 struct task_struct *cur = current;
18475
18476 sp = regs->sp;
18477 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18478
18479 return ud2 == 0x0b0f;
18480 }
18481 +
18482 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18483 +void pax_check_alloca(unsigned long size)
18484 +{
18485 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18486 + unsigned cpu, used;
18487 + char *id;
18488 +
18489 + /* check the process stack first */
18490 + stack_start = (unsigned long)task_stack_page(current);
18491 + stack_end = stack_start + THREAD_SIZE;
18492 + if (likely(stack_start <= sp && sp < stack_end)) {
18493 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18494 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18495 + return;
18496 + }
18497 +
18498 + cpu = get_cpu();
18499 +
18500 + /* check the irq stacks */
18501 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18502 + stack_start = stack_end - IRQ_STACK_SIZE;
18503 + if (stack_start <= sp && sp < stack_end) {
18504 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18505 + put_cpu();
18506 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18507 + return;
18508 + }
18509 +
18510 + /* check the exception stacks */
18511 + used = 0;
18512 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18513 + stack_start = stack_end - EXCEPTION_STKSZ;
18514 + if (stack_end && stack_start <= sp && sp < stack_end) {
18515 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18516 + put_cpu();
18517 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18518 + return;
18519 + }
18520 +
18521 + put_cpu();
18522 +
18523 + /* unknown stack */
18524 + BUG();
18525 +}
18526 +EXPORT_SYMBOL(pax_check_alloca);
18527 +#endif
18528 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18529 index 9b9f18b..9fcaa04 100644
18530 --- a/arch/x86/kernel/early_printk.c
18531 +++ b/arch/x86/kernel/early_printk.c
18532 @@ -7,6 +7,7 @@
18533 #include <linux/pci_regs.h>
18534 #include <linux/pci_ids.h>
18535 #include <linux/errno.h>
18536 +#include <linux/sched.h>
18537 #include <asm/io.h>
18538 #include <asm/processor.h>
18539 #include <asm/fcntl.h>
18540 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18541 index 6ed91d9..6cc365b 100644
18542 --- a/arch/x86/kernel/entry_32.S
18543 +++ b/arch/x86/kernel/entry_32.S
18544 @@ -177,13 +177,153 @@
18545 /*CFI_REL_OFFSET gs, PT_GS*/
18546 .endm
18547 .macro SET_KERNEL_GS reg
18548 +
18549 +#ifdef CONFIG_CC_STACKPROTECTOR
18550 movl $(__KERNEL_STACK_CANARY), \reg
18551 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18552 + movl $(__USER_DS), \reg
18553 +#else
18554 + xorl \reg, \reg
18555 +#endif
18556 +
18557 movl \reg, %gs
18558 .endm
18559
18560 #endif /* CONFIG_X86_32_LAZY_GS */
18561
18562 -.macro SAVE_ALL
18563 +.macro pax_enter_kernel
18564 +#ifdef CONFIG_PAX_KERNEXEC
18565 + call pax_enter_kernel
18566 +#endif
18567 +.endm
18568 +
18569 +.macro pax_exit_kernel
18570 +#ifdef CONFIG_PAX_KERNEXEC
18571 + call pax_exit_kernel
18572 +#endif
18573 +.endm
18574 +
18575 +#ifdef CONFIG_PAX_KERNEXEC
18576 +ENTRY(pax_enter_kernel)
18577 +#ifdef CONFIG_PARAVIRT
18578 + pushl %eax
18579 + pushl %ecx
18580 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18581 + mov %eax, %esi
18582 +#else
18583 + mov %cr0, %esi
18584 +#endif
18585 + bts $16, %esi
18586 + jnc 1f
18587 + mov %cs, %esi
18588 + cmp $__KERNEL_CS, %esi
18589 + jz 3f
18590 + ljmp $__KERNEL_CS, $3f
18591 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18592 +2:
18593 +#ifdef CONFIG_PARAVIRT
18594 + mov %esi, %eax
18595 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18596 +#else
18597 + mov %esi, %cr0
18598 +#endif
18599 +3:
18600 +#ifdef CONFIG_PARAVIRT
18601 + popl %ecx
18602 + popl %eax
18603 +#endif
18604 + ret
18605 +ENDPROC(pax_enter_kernel)
18606 +
18607 +ENTRY(pax_exit_kernel)
18608 +#ifdef CONFIG_PARAVIRT
18609 + pushl %eax
18610 + pushl %ecx
18611 +#endif
18612 + mov %cs, %esi
18613 + cmp $__KERNEXEC_KERNEL_CS, %esi
18614 + jnz 2f
18615 +#ifdef CONFIG_PARAVIRT
18616 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18617 + mov %eax, %esi
18618 +#else
18619 + mov %cr0, %esi
18620 +#endif
18621 + btr $16, %esi
18622 + ljmp $__KERNEL_CS, $1f
18623 +1:
18624 +#ifdef CONFIG_PARAVIRT
18625 + mov %esi, %eax
18626 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18627 +#else
18628 + mov %esi, %cr0
18629 +#endif
18630 +2:
18631 +#ifdef CONFIG_PARAVIRT
18632 + popl %ecx
18633 + popl %eax
18634 +#endif
18635 + ret
18636 +ENDPROC(pax_exit_kernel)
18637 +#endif
18638 +
18639 +.macro pax_erase_kstack
18640 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18641 + call pax_erase_kstack
18642 +#endif
18643 +.endm
18644 +
18645 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18646 +/*
18647 + * ebp: thread_info
18648 + */
18649 +ENTRY(pax_erase_kstack)
18650 + pushl %edi
18651 + pushl %ecx
18652 + pushl %eax
18653 +
18654 + mov TI_lowest_stack(%ebp), %edi
18655 + mov $-0xBEEF, %eax
18656 + std
18657 +
18658 +1: mov %edi, %ecx
18659 + and $THREAD_SIZE_asm - 1, %ecx
18660 + shr $2, %ecx
18661 + repne scasl
18662 + jecxz 2f
18663 +
18664 + cmp $2*16, %ecx
18665 + jc 2f
18666 +
18667 + mov $2*16, %ecx
18668 + repe scasl
18669 + jecxz 2f
18670 + jne 1b
18671 +
18672 +2: cld
18673 + mov %esp, %ecx
18674 + sub %edi, %ecx
18675 +
18676 + cmp $THREAD_SIZE_asm, %ecx
18677 + jb 3f
18678 + ud2
18679 +3:
18680 +
18681 + shr $2, %ecx
18682 + rep stosl
18683 +
18684 + mov TI_task_thread_sp0(%ebp), %edi
18685 + sub $128, %edi
18686 + mov %edi, TI_lowest_stack(%ebp)
18687 +
18688 + popl %eax
18689 + popl %ecx
18690 + popl %edi
18691 + ret
18692 +ENDPROC(pax_erase_kstack)
18693 +#endif
18694 +
18695 +.macro __SAVE_ALL _DS
18696 cld
18697 PUSH_GS
18698 pushl_cfi %fs
18699 @@ -206,7 +346,7 @@
18700 CFI_REL_OFFSET ecx, 0
18701 pushl_cfi %ebx
18702 CFI_REL_OFFSET ebx, 0
18703 - movl $(__USER_DS), %edx
18704 + movl $\_DS, %edx
18705 movl %edx, %ds
18706 movl %edx, %es
18707 movl $(__KERNEL_PERCPU), %edx
18708 @@ -214,6 +354,15 @@
18709 SET_KERNEL_GS %edx
18710 .endm
18711
18712 +.macro SAVE_ALL
18713 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18714 + __SAVE_ALL __KERNEL_DS
18715 + pax_enter_kernel
18716 +#else
18717 + __SAVE_ALL __USER_DS
18718 +#endif
18719 +.endm
18720 +
18721 .macro RESTORE_INT_REGS
18722 popl_cfi %ebx
18723 CFI_RESTORE ebx
18724 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18725 popfl_cfi
18726 jmp syscall_exit
18727 CFI_ENDPROC
18728 -END(ret_from_fork)
18729 +ENDPROC(ret_from_fork)
18730
18731 ENTRY(ret_from_kernel_thread)
18732 CFI_STARTPROC
18733 @@ -344,7 +493,15 @@ ret_from_intr:
18734 andl $SEGMENT_RPL_MASK, %eax
18735 #endif
18736 cmpl $USER_RPL, %eax
18737 +
18738 +#ifdef CONFIG_PAX_KERNEXEC
18739 + jae resume_userspace
18740 +
18741 + pax_exit_kernel
18742 + jmp resume_kernel
18743 +#else
18744 jb resume_kernel # not returning to v8086 or userspace
18745 +#endif
18746
18747 ENTRY(resume_userspace)
18748 LOCKDEP_SYS_EXIT
18749 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18750 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18751 # int/exception return?
18752 jne work_pending
18753 - jmp restore_all
18754 -END(ret_from_exception)
18755 + jmp restore_all_pax
18756 +ENDPROC(ret_from_exception)
18757
18758 #ifdef CONFIG_PREEMPT
18759 ENTRY(resume_kernel)
18760 @@ -372,7 +529,7 @@ need_resched:
18761 jz restore_all
18762 call preempt_schedule_irq
18763 jmp need_resched
18764 -END(resume_kernel)
18765 +ENDPROC(resume_kernel)
18766 #endif
18767 CFI_ENDPROC
18768 /*
18769 @@ -406,30 +563,45 @@ sysenter_past_esp:
18770 /*CFI_REL_OFFSET cs, 0*/
18771 /*
18772 * Push current_thread_info()->sysenter_return to the stack.
18773 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18774 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18775 */
18776 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18777 + pushl_cfi $0
18778 CFI_REL_OFFSET eip, 0
18779
18780 pushl_cfi %eax
18781 SAVE_ALL
18782 + GET_THREAD_INFO(%ebp)
18783 + movl TI_sysenter_return(%ebp),%ebp
18784 + movl %ebp,PT_EIP(%esp)
18785 ENABLE_INTERRUPTS(CLBR_NONE)
18786
18787 /*
18788 * Load the potential sixth argument from user stack.
18789 * Careful about security.
18790 */
18791 + movl PT_OLDESP(%esp),%ebp
18792 +
18793 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18794 + mov PT_OLDSS(%esp),%ds
18795 +1: movl %ds:(%ebp),%ebp
18796 + push %ss
18797 + pop %ds
18798 +#else
18799 cmpl $__PAGE_OFFSET-3,%ebp
18800 jae syscall_fault
18801 ASM_STAC
18802 1: movl (%ebp),%ebp
18803 ASM_CLAC
18804 +#endif
18805 +
18806 movl %ebp,PT_EBP(%esp)
18807 _ASM_EXTABLE(1b,syscall_fault)
18808
18809 GET_THREAD_INFO(%ebp)
18810
18811 +#ifdef CONFIG_PAX_RANDKSTACK
18812 + pax_erase_kstack
18813 +#endif
18814 +
18815 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18816 jnz sysenter_audit
18817 sysenter_do_call:
18818 @@ -444,12 +616,24 @@ sysenter_do_call:
18819 testl $_TIF_ALLWORK_MASK, %ecx
18820 jne sysexit_audit
18821 sysenter_exit:
18822 +
18823 +#ifdef CONFIG_PAX_RANDKSTACK
18824 + pushl_cfi %eax
18825 + movl %esp, %eax
18826 + call pax_randomize_kstack
18827 + popl_cfi %eax
18828 +#endif
18829 +
18830 + pax_erase_kstack
18831 +
18832 /* if something modifies registers it must also disable sysexit */
18833 movl PT_EIP(%esp), %edx
18834 movl PT_OLDESP(%esp), %ecx
18835 xorl %ebp,%ebp
18836 TRACE_IRQS_ON
18837 1: mov PT_FS(%esp), %fs
18838 +2: mov PT_DS(%esp), %ds
18839 +3: mov PT_ES(%esp), %es
18840 PTGS_TO_GS
18841 ENABLE_INTERRUPTS_SYSEXIT
18842
18843 @@ -466,6 +650,9 @@ sysenter_audit:
18844 movl %eax,%edx /* 2nd arg: syscall number */
18845 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18846 call __audit_syscall_entry
18847 +
18848 + pax_erase_kstack
18849 +
18850 pushl_cfi %ebx
18851 movl PT_EAX(%esp),%eax /* reload syscall number */
18852 jmp sysenter_do_call
18853 @@ -491,10 +678,16 @@ sysexit_audit:
18854
18855 CFI_ENDPROC
18856 .pushsection .fixup,"ax"
18857 -2: movl $0,PT_FS(%esp)
18858 +4: movl $0,PT_FS(%esp)
18859 + jmp 1b
18860 +5: movl $0,PT_DS(%esp)
18861 + jmp 1b
18862 +6: movl $0,PT_ES(%esp)
18863 jmp 1b
18864 .popsection
18865 - _ASM_EXTABLE(1b,2b)
18866 + _ASM_EXTABLE(1b,4b)
18867 + _ASM_EXTABLE(2b,5b)
18868 + _ASM_EXTABLE(3b,6b)
18869 PTGS_TO_GS_EX
18870 ENDPROC(ia32_sysenter_target)
18871
18872 @@ -509,6 +702,11 @@ ENTRY(system_call)
18873 pushl_cfi %eax # save orig_eax
18874 SAVE_ALL
18875 GET_THREAD_INFO(%ebp)
18876 +
18877 +#ifdef CONFIG_PAX_RANDKSTACK
18878 + pax_erase_kstack
18879 +#endif
18880 +
18881 # system call tracing in operation / emulation
18882 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18883 jnz syscall_trace_entry
18884 @@ -527,6 +725,15 @@ syscall_exit:
18885 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18886 jne syscall_exit_work
18887
18888 +restore_all_pax:
18889 +
18890 +#ifdef CONFIG_PAX_RANDKSTACK
18891 + movl %esp, %eax
18892 + call pax_randomize_kstack
18893 +#endif
18894 +
18895 + pax_erase_kstack
18896 +
18897 restore_all:
18898 TRACE_IRQS_IRET
18899 restore_all_notrace:
18900 @@ -583,14 +790,34 @@ ldt_ss:
18901 * compensating for the offset by changing to the ESPFIX segment with
18902 * a base address that matches for the difference.
18903 */
18904 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18905 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18906 mov %esp, %edx /* load kernel esp */
18907 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18908 mov %dx, %ax /* eax: new kernel esp */
18909 sub %eax, %edx /* offset (low word is 0) */
18910 +#ifdef CONFIG_SMP
18911 + movl PER_CPU_VAR(cpu_number), %ebx
18912 + shll $PAGE_SHIFT_asm, %ebx
18913 + addl $cpu_gdt_table, %ebx
18914 +#else
18915 + movl $cpu_gdt_table, %ebx
18916 +#endif
18917 shr $16, %edx
18918 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18919 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18920 +
18921 +#ifdef CONFIG_PAX_KERNEXEC
18922 + mov %cr0, %esi
18923 + btr $16, %esi
18924 + mov %esi, %cr0
18925 +#endif
18926 +
18927 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18928 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18929 +
18930 +#ifdef CONFIG_PAX_KERNEXEC
18931 + bts $16, %esi
18932 + mov %esi, %cr0
18933 +#endif
18934 +
18935 pushl_cfi $__ESPFIX_SS
18936 pushl_cfi %eax /* new kernel esp */
18937 /* Disable interrupts, but do not irqtrace this section: we
18938 @@ -619,20 +846,18 @@ work_resched:
18939 movl TI_flags(%ebp), %ecx
18940 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18941 # than syscall tracing?
18942 - jz restore_all
18943 + jz restore_all_pax
18944 testb $_TIF_NEED_RESCHED, %cl
18945 jnz work_resched
18946
18947 work_notifysig: # deal with pending signals and
18948 # notify-resume requests
18949 + movl %esp, %eax
18950 #ifdef CONFIG_VM86
18951 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18952 - movl %esp, %eax
18953 jne work_notifysig_v86 # returning to kernel-space or
18954 # vm86-space
18955 1:
18956 -#else
18957 - movl %esp, %eax
18958 #endif
18959 TRACE_IRQS_ON
18960 ENABLE_INTERRUPTS(CLBR_NONE)
18961 @@ -653,7 +878,7 @@ work_notifysig_v86:
18962 movl %eax, %esp
18963 jmp 1b
18964 #endif
18965 -END(work_pending)
18966 +ENDPROC(work_pending)
18967
18968 # perform syscall exit tracing
18969 ALIGN
18970 @@ -661,11 +886,14 @@ syscall_trace_entry:
18971 movl $-ENOSYS,PT_EAX(%esp)
18972 movl %esp, %eax
18973 call syscall_trace_enter
18974 +
18975 + pax_erase_kstack
18976 +
18977 /* What it returned is what we'll actually use. */
18978 cmpl $(NR_syscalls), %eax
18979 jnae syscall_call
18980 jmp syscall_exit
18981 -END(syscall_trace_entry)
18982 +ENDPROC(syscall_trace_entry)
18983
18984 # perform syscall exit tracing
18985 ALIGN
18986 @@ -678,21 +906,25 @@ syscall_exit_work:
18987 movl %esp, %eax
18988 call syscall_trace_leave
18989 jmp resume_userspace
18990 -END(syscall_exit_work)
18991 +ENDPROC(syscall_exit_work)
18992 CFI_ENDPROC
18993
18994 RING0_INT_FRAME # can't unwind into user space anyway
18995 syscall_fault:
18996 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18997 + push %ss
18998 + pop %ds
18999 +#endif
19000 ASM_CLAC
19001 GET_THREAD_INFO(%ebp)
19002 movl $-EFAULT,PT_EAX(%esp)
19003 jmp resume_userspace
19004 -END(syscall_fault)
19005 +ENDPROC(syscall_fault)
19006
19007 syscall_badsys:
19008 movl $-ENOSYS,PT_EAX(%esp)
19009 jmp resume_userspace
19010 -END(syscall_badsys)
19011 +ENDPROC(syscall_badsys)
19012 CFI_ENDPROC
19013 /*
19014 * End of kprobes section
19015 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
19016 * normal stack and adjusts ESP with the matching offset.
19017 */
19018 /* fixup the stack */
19019 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
19020 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
19021 +#ifdef CONFIG_SMP
19022 + movl PER_CPU_VAR(cpu_number), %ebx
19023 + shll $PAGE_SHIFT_asm, %ebx
19024 + addl $cpu_gdt_table, %ebx
19025 +#else
19026 + movl $cpu_gdt_table, %ebx
19027 +#endif
19028 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
19029 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
19030 shl $16, %eax
19031 addl %esp, %eax /* the adjusted stack pointer */
19032 pushl_cfi $__KERNEL_DS
19033 @@ -807,7 +1046,7 @@ vector=vector+1
19034 .endr
19035 2: jmp common_interrupt
19036 .endr
19037 -END(irq_entries_start)
19038 +ENDPROC(irq_entries_start)
19039
19040 .previous
19041 END(interrupt)
19042 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
19043 pushl_cfi $do_coprocessor_error
19044 jmp error_code
19045 CFI_ENDPROC
19046 -END(coprocessor_error)
19047 +ENDPROC(coprocessor_error)
19048
19049 ENTRY(simd_coprocessor_error)
19050 RING0_INT_FRAME
19051 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
19052 #endif
19053 jmp error_code
19054 CFI_ENDPROC
19055 -END(simd_coprocessor_error)
19056 +ENDPROC(simd_coprocessor_error)
19057
19058 ENTRY(device_not_available)
19059 RING0_INT_FRAME
19060 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
19061 pushl_cfi $do_device_not_available
19062 jmp error_code
19063 CFI_ENDPROC
19064 -END(device_not_available)
19065 +ENDPROC(device_not_available)
19066
19067 #ifdef CONFIG_PARAVIRT
19068 ENTRY(native_iret)
19069 iret
19070 _ASM_EXTABLE(native_iret, iret_exc)
19071 -END(native_iret)
19072 +ENDPROC(native_iret)
19073
19074 ENTRY(native_irq_enable_sysexit)
19075 sti
19076 sysexit
19077 -END(native_irq_enable_sysexit)
19078 +ENDPROC(native_irq_enable_sysexit)
19079 #endif
19080
19081 ENTRY(overflow)
19082 @@ -910,7 +1149,7 @@ ENTRY(overflow)
19083 pushl_cfi $do_overflow
19084 jmp error_code
19085 CFI_ENDPROC
19086 -END(overflow)
19087 +ENDPROC(overflow)
19088
19089 ENTRY(bounds)
19090 RING0_INT_FRAME
19091 @@ -919,7 +1158,7 @@ ENTRY(bounds)
19092 pushl_cfi $do_bounds
19093 jmp error_code
19094 CFI_ENDPROC
19095 -END(bounds)
19096 +ENDPROC(bounds)
19097
19098 ENTRY(invalid_op)
19099 RING0_INT_FRAME
19100 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
19101 pushl_cfi $do_invalid_op
19102 jmp error_code
19103 CFI_ENDPROC
19104 -END(invalid_op)
19105 +ENDPROC(invalid_op)
19106
19107 ENTRY(coprocessor_segment_overrun)
19108 RING0_INT_FRAME
19109 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
19110 pushl_cfi $do_coprocessor_segment_overrun
19111 jmp error_code
19112 CFI_ENDPROC
19113 -END(coprocessor_segment_overrun)
19114 +ENDPROC(coprocessor_segment_overrun)
19115
19116 ENTRY(invalid_TSS)
19117 RING0_EC_FRAME
19118 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
19119 pushl_cfi $do_invalid_TSS
19120 jmp error_code
19121 CFI_ENDPROC
19122 -END(invalid_TSS)
19123 +ENDPROC(invalid_TSS)
19124
19125 ENTRY(segment_not_present)
19126 RING0_EC_FRAME
19127 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
19128 pushl_cfi $do_segment_not_present
19129 jmp error_code
19130 CFI_ENDPROC
19131 -END(segment_not_present)
19132 +ENDPROC(segment_not_present)
19133
19134 ENTRY(stack_segment)
19135 RING0_EC_FRAME
19136 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
19137 pushl_cfi $do_stack_segment
19138 jmp error_code
19139 CFI_ENDPROC
19140 -END(stack_segment)
19141 +ENDPROC(stack_segment)
19142
19143 ENTRY(alignment_check)
19144 RING0_EC_FRAME
19145 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
19146 pushl_cfi $do_alignment_check
19147 jmp error_code
19148 CFI_ENDPROC
19149 -END(alignment_check)
19150 +ENDPROC(alignment_check)
19151
19152 ENTRY(divide_error)
19153 RING0_INT_FRAME
19154 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
19155 pushl_cfi $do_divide_error
19156 jmp error_code
19157 CFI_ENDPROC
19158 -END(divide_error)
19159 +ENDPROC(divide_error)
19160
19161 #ifdef CONFIG_X86_MCE
19162 ENTRY(machine_check)
19163 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
19164 pushl_cfi machine_check_vector
19165 jmp error_code
19166 CFI_ENDPROC
19167 -END(machine_check)
19168 +ENDPROC(machine_check)
19169 #endif
19170
19171 ENTRY(spurious_interrupt_bug)
19172 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
19173 pushl_cfi $do_spurious_interrupt_bug
19174 jmp error_code
19175 CFI_ENDPROC
19176 -END(spurious_interrupt_bug)
19177 +ENDPROC(spurious_interrupt_bug)
19178 /*
19179 * End of kprobes section
19180 */
19181 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
19182
19183 ENTRY(mcount)
19184 ret
19185 -END(mcount)
19186 +ENDPROC(mcount)
19187
19188 ENTRY(ftrace_caller)
19189 cmpl $0, function_trace_stop
19190 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
19191 .globl ftrace_stub
19192 ftrace_stub:
19193 ret
19194 -END(ftrace_caller)
19195 +ENDPROC(ftrace_caller)
19196
19197 ENTRY(ftrace_regs_caller)
19198 pushf /* push flags before compare (in cs location) */
19199 @@ -1235,7 +1474,7 @@ trace:
19200 popl %ecx
19201 popl %eax
19202 jmp ftrace_stub
19203 -END(mcount)
19204 +ENDPROC(mcount)
19205 #endif /* CONFIG_DYNAMIC_FTRACE */
19206 #endif /* CONFIG_FUNCTION_TRACER */
19207
19208 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
19209 popl %ecx
19210 popl %eax
19211 ret
19212 -END(ftrace_graph_caller)
19213 +ENDPROC(ftrace_graph_caller)
19214
19215 .globl return_to_handler
19216 return_to_handler:
19217 @@ -1309,15 +1548,18 @@ error_code:
19218 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
19219 REG_TO_PTGS %ecx
19220 SET_KERNEL_GS %ecx
19221 - movl $(__USER_DS), %ecx
19222 + movl $(__KERNEL_DS), %ecx
19223 movl %ecx, %ds
19224 movl %ecx, %es
19225 +
19226 + pax_enter_kernel
19227 +
19228 TRACE_IRQS_OFF
19229 movl %esp,%eax # pt_regs pointer
19230 call *%edi
19231 jmp ret_from_exception
19232 CFI_ENDPROC
19233 -END(page_fault)
19234 +ENDPROC(page_fault)
19235
19236 /*
19237 * Debug traps and NMI can happen at the one SYSENTER instruction
19238 @@ -1360,7 +1602,7 @@ debug_stack_correct:
19239 call do_debug
19240 jmp ret_from_exception
19241 CFI_ENDPROC
19242 -END(debug)
19243 +ENDPROC(debug)
19244
19245 /*
19246 * NMI is doubly nasty. It can happen _while_ we're handling
19247 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
19248 xorl %edx,%edx # zero error code
19249 movl %esp,%eax # pt_regs pointer
19250 call do_nmi
19251 +
19252 + pax_exit_kernel
19253 +
19254 jmp restore_all_notrace
19255 CFI_ENDPROC
19256
19257 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
19258 FIXUP_ESPFIX_STACK # %eax == %esp
19259 xorl %edx,%edx # zero error code
19260 call do_nmi
19261 +
19262 + pax_exit_kernel
19263 +
19264 RESTORE_REGS
19265 lss 12+4(%esp), %esp # back to espfix stack
19266 CFI_ADJUST_CFA_OFFSET -24
19267 jmp irq_return
19268 CFI_ENDPROC
19269 -END(nmi)
19270 +ENDPROC(nmi)
19271
19272 ENTRY(int3)
19273 RING0_INT_FRAME
19274 @@ -1452,14 +1700,14 @@ ENTRY(int3)
19275 call do_int3
19276 jmp ret_from_exception
19277 CFI_ENDPROC
19278 -END(int3)
19279 +ENDPROC(int3)
19280
19281 ENTRY(general_protection)
19282 RING0_EC_FRAME
19283 pushl_cfi $do_general_protection
19284 jmp error_code
19285 CFI_ENDPROC
19286 -END(general_protection)
19287 +ENDPROC(general_protection)
19288
19289 #ifdef CONFIG_KVM_GUEST
19290 ENTRY(async_page_fault)
19291 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
19292 pushl_cfi $do_async_page_fault
19293 jmp error_code
19294 CFI_ENDPROC
19295 -END(async_page_fault)
19296 +ENDPROC(async_page_fault)
19297 #endif
19298
19299 /*
19300 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19301 index cb3c591..0617fa7 100644
19302 --- a/arch/x86/kernel/entry_64.S
19303 +++ b/arch/x86/kernel/entry_64.S
19304 @@ -59,6 +59,8 @@
19305 #include <asm/context_tracking.h>
19306 #include <asm/smap.h>
19307 #include <linux/err.h>
19308 +#include <asm/pgtable.h>
19309 +#include <asm/alternative-asm.h>
19310
19311 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19312 #include <linux/elf-em.h>
19313 @@ -80,8 +82,9 @@
19314 #ifdef CONFIG_DYNAMIC_FTRACE
19315
19316 ENTRY(function_hook)
19317 + pax_force_retaddr
19318 retq
19319 -END(function_hook)
19320 +ENDPROC(function_hook)
19321
19322 /* skip is set if stack has been adjusted */
19323 .macro ftrace_caller_setup skip=0
19324 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19325 #endif
19326
19327 GLOBAL(ftrace_stub)
19328 + pax_force_retaddr
19329 retq
19330 -END(ftrace_caller)
19331 +ENDPROC(ftrace_caller)
19332
19333 ENTRY(ftrace_regs_caller)
19334 /* Save the current flags before compare (in SS location)*/
19335 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19336 popfq
19337 jmp ftrace_stub
19338
19339 -END(ftrace_regs_caller)
19340 +ENDPROC(ftrace_regs_caller)
19341
19342
19343 #else /* ! CONFIG_DYNAMIC_FTRACE */
19344 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19345 #endif
19346
19347 GLOBAL(ftrace_stub)
19348 + pax_force_retaddr
19349 retq
19350
19351 trace:
19352 @@ -225,12 +230,13 @@ trace:
19353 #endif
19354 subq $MCOUNT_INSN_SIZE, %rdi
19355
19356 + pax_force_fptr ftrace_trace_function
19357 call *ftrace_trace_function
19358
19359 MCOUNT_RESTORE_FRAME
19360
19361 jmp ftrace_stub
19362 -END(function_hook)
19363 +ENDPROC(function_hook)
19364 #endif /* CONFIG_DYNAMIC_FTRACE */
19365 #endif /* CONFIG_FUNCTION_TRACER */
19366
19367 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19368
19369 MCOUNT_RESTORE_FRAME
19370
19371 + pax_force_retaddr
19372 retq
19373 -END(ftrace_graph_caller)
19374 +ENDPROC(ftrace_graph_caller)
19375
19376 GLOBAL(return_to_handler)
19377 subq $24, %rsp
19378 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19379 movq 8(%rsp), %rdx
19380 movq (%rsp), %rax
19381 addq $24, %rsp
19382 + pax_force_fptr %rdi
19383 jmp *%rdi
19384 +ENDPROC(return_to_handler)
19385 #endif
19386
19387
19388 @@ -284,6 +293,282 @@ ENTRY(native_usergs_sysret64)
19389 ENDPROC(native_usergs_sysret64)
19390 #endif /* CONFIG_PARAVIRT */
19391
19392 + .macro ljmpq sel, off
19393 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19394 + .byte 0x48; ljmp *1234f(%rip)
19395 + .pushsection .rodata
19396 + .align 16
19397 + 1234: .quad \off; .word \sel
19398 + .popsection
19399 +#else
19400 + pushq $\sel
19401 + pushq $\off
19402 + lretq
19403 +#endif
19404 + .endm
19405 +
19406 + .macro pax_enter_kernel
19407 + pax_set_fptr_mask
19408 +#ifdef CONFIG_PAX_KERNEXEC
19409 + call pax_enter_kernel
19410 +#endif
19411 + .endm
19412 +
19413 + .macro pax_exit_kernel
19414 +#ifdef CONFIG_PAX_KERNEXEC
19415 + call pax_exit_kernel
19416 +#endif
19417 + .endm
19418 +
19419 +#ifdef CONFIG_PAX_KERNEXEC
19420 +ENTRY(pax_enter_kernel)
19421 + pushq %rdi
19422 +
19423 +#ifdef CONFIG_PARAVIRT
19424 + PV_SAVE_REGS(CLBR_RDI)
19425 +#endif
19426 +
19427 + GET_CR0_INTO_RDI
19428 + bts $16,%rdi
19429 + jnc 3f
19430 + mov %cs,%edi
19431 + cmp $__KERNEL_CS,%edi
19432 + jnz 2f
19433 +1:
19434 +
19435 +#ifdef CONFIG_PARAVIRT
19436 + PV_RESTORE_REGS(CLBR_RDI)
19437 +#endif
19438 +
19439 + popq %rdi
19440 + pax_force_retaddr
19441 + retq
19442 +
19443 +2: ljmpq __KERNEL_CS,1b
19444 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19445 +4: SET_RDI_INTO_CR0
19446 + jmp 1b
19447 +ENDPROC(pax_enter_kernel)
19448 +
19449 +ENTRY(pax_exit_kernel)
19450 + pushq %rdi
19451 +
19452 +#ifdef CONFIG_PARAVIRT
19453 + PV_SAVE_REGS(CLBR_RDI)
19454 +#endif
19455 +
19456 + mov %cs,%rdi
19457 + cmp $__KERNEXEC_KERNEL_CS,%edi
19458 + jz 2f
19459 + GET_CR0_INTO_RDI
19460 + bts $16,%rdi
19461 + jnc 4f
19462 +1:
19463 +
19464 +#ifdef CONFIG_PARAVIRT
19465 + PV_RESTORE_REGS(CLBR_RDI);
19466 +#endif
19467 +
19468 + popq %rdi
19469 + pax_force_retaddr
19470 + retq
19471 +
19472 +2: GET_CR0_INTO_RDI
19473 + btr $16,%rdi
19474 + jnc 4f
19475 + ljmpq __KERNEL_CS,3f
19476 +3: SET_RDI_INTO_CR0
19477 + jmp 1b
19478 +4: ud2
19479 + jmp 4b
19480 +ENDPROC(pax_exit_kernel)
19481 +#endif
19482 +
19483 + .macro pax_enter_kernel_user
19484 + pax_set_fptr_mask
19485 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19486 + call pax_enter_kernel_user
19487 +#endif
19488 + .endm
19489 +
19490 + .macro pax_exit_kernel_user
19491 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19492 + call pax_exit_kernel_user
19493 +#endif
19494 +#ifdef CONFIG_PAX_RANDKSTACK
19495 + pushq %rax
19496 + call pax_randomize_kstack
19497 + popq %rax
19498 +#endif
19499 + .endm
19500 +
19501 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19502 +ENTRY(pax_enter_kernel_user)
19503 + pushq %rdi
19504 + pushq %rbx
19505 +
19506 +#ifdef CONFIG_PARAVIRT
19507 + PV_SAVE_REGS(CLBR_RDI)
19508 +#endif
19509 +
19510 + GET_CR3_INTO_RDI
19511 + mov %rdi,%rbx
19512 + add $__START_KERNEL_map,%rbx
19513 + sub phys_base(%rip),%rbx
19514 +
19515 +#ifdef CONFIG_PARAVIRT
19516 + pushq %rdi
19517 + cmpl $0, pv_info+PARAVIRT_enabled
19518 + jz 1f
19519 + i = 0
19520 + .rept USER_PGD_PTRS
19521 + mov i*8(%rbx),%rsi
19522 + mov $0,%sil
19523 + lea i*8(%rbx),%rdi
19524 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19525 + i = i + 1
19526 + .endr
19527 + jmp 2f
19528 +1:
19529 +#endif
19530 +
19531 + i = 0
19532 + .rept USER_PGD_PTRS
19533 + movb $0,i*8(%rbx)
19534 + i = i + 1
19535 + .endr
19536 +
19537 +#ifdef CONFIG_PARAVIRT
19538 +2: popq %rdi
19539 +#endif
19540 + SET_RDI_INTO_CR3
19541 +
19542 +#ifdef CONFIG_PAX_KERNEXEC
19543 + GET_CR0_INTO_RDI
19544 + bts $16,%rdi
19545 + SET_RDI_INTO_CR0
19546 +#endif
19547 +
19548 +#ifdef CONFIG_PARAVIRT
19549 + PV_RESTORE_REGS(CLBR_RDI)
19550 +#endif
19551 +
19552 + popq %rbx
19553 + popq %rdi
19554 + pax_force_retaddr
19555 + retq
19556 +ENDPROC(pax_enter_kernel_user)
19557 +
19558 +ENTRY(pax_exit_kernel_user)
19559 + push %rdi
19560 +
19561 +#ifdef CONFIG_PARAVIRT
19562 + pushq %rbx
19563 + PV_SAVE_REGS(CLBR_RDI)
19564 +#endif
19565 +
19566 +#ifdef CONFIG_PAX_KERNEXEC
19567 + GET_CR0_INTO_RDI
19568 + btr $16,%rdi
19569 + jnc 3f
19570 + SET_RDI_INTO_CR0
19571 +#endif
19572 +
19573 + GET_CR3_INTO_RDI
19574 + add $__START_KERNEL_map,%rdi
19575 + sub phys_base(%rip),%rdi
19576 +
19577 +#ifdef CONFIG_PARAVIRT
19578 + cmpl $0, pv_info+PARAVIRT_enabled
19579 + jz 1f
19580 + mov %rdi,%rbx
19581 + i = 0
19582 + .rept USER_PGD_PTRS
19583 + mov i*8(%rbx),%rsi
19584 + mov $0x67,%sil
19585 + lea i*8(%rbx),%rdi
19586 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19587 + i = i + 1
19588 + .endr
19589 + jmp 2f
19590 +1:
19591 +#endif
19592 +
19593 + i = 0
19594 + .rept USER_PGD_PTRS
19595 + movb $0x67,i*8(%rdi)
19596 + i = i + 1
19597 + .endr
19598 +
19599 +#ifdef CONFIG_PARAVIRT
19600 +2: PV_RESTORE_REGS(CLBR_RDI)
19601 + popq %rbx
19602 +#endif
19603 +
19604 + popq %rdi
19605 + pax_force_retaddr
19606 + retq
19607 +3: ud2
19608 + jmp 3b
19609 +ENDPROC(pax_exit_kernel_user)
19610 +#endif
19611 +
19612 +.macro pax_erase_kstack
19613 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19614 + call pax_erase_kstack
19615 +#endif
19616 +.endm
19617 +
19618 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19619 +ENTRY(pax_erase_kstack)
19620 + pushq %rdi
19621 + pushq %rcx
19622 + pushq %rax
19623 + pushq %r11
19624 +
19625 + GET_THREAD_INFO(%r11)
19626 + mov TI_lowest_stack(%r11), %rdi
19627 + mov $-0xBEEF, %rax
19628 + std
19629 +
19630 +1: mov %edi, %ecx
19631 + and $THREAD_SIZE_asm - 1, %ecx
19632 + shr $3, %ecx
19633 + repne scasq
19634 + jecxz 2f
19635 +
19636 + cmp $2*8, %ecx
19637 + jc 2f
19638 +
19639 + mov $2*8, %ecx
19640 + repe scasq
19641 + jecxz 2f
19642 + jne 1b
19643 +
19644 +2: cld
19645 + mov %esp, %ecx
19646 + sub %edi, %ecx
19647 +
19648 + cmp $THREAD_SIZE_asm, %rcx
19649 + jb 3f
19650 + ud2
19651 +3:
19652 +
19653 + shr $3, %ecx
19654 + rep stosq
19655 +
19656 + mov TI_task_thread_sp0(%r11), %rdi
19657 + sub $256, %rdi
19658 + mov %rdi, TI_lowest_stack(%r11)
19659 +
19660 + popq %r11
19661 + popq %rax
19662 + popq %rcx
19663 + popq %rdi
19664 + pax_force_retaddr
19665 + ret
19666 +ENDPROC(pax_erase_kstack)
19667 +#endif
19668
19669 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19670 #ifdef CONFIG_TRACE_IRQFLAGS
19671 @@ -375,8 +660,8 @@ ENDPROC(native_usergs_sysret64)
19672 .endm
19673
19674 .macro UNFAKE_STACK_FRAME
19675 - addq $8*6, %rsp
19676 - CFI_ADJUST_CFA_OFFSET -(6*8)
19677 + addq $8*6 + ARG_SKIP, %rsp
19678 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19679 .endm
19680
19681 /*
19682 @@ -463,7 +748,7 @@ ENDPROC(native_usergs_sysret64)
19683 movq %rsp, %rsi
19684
19685 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19686 - testl $3, CS-RBP(%rsi)
19687 + testb $3, CS-RBP(%rsi)
19688 je 1f
19689 SWAPGS
19690 /*
19691 @@ -498,9 +783,10 @@ ENTRY(save_rest)
19692 movq_cfi r15, R15+16
19693 movq %r11, 8(%rsp) /* return address */
19694 FIXUP_TOP_OF_STACK %r11, 16
19695 + pax_force_retaddr
19696 ret
19697 CFI_ENDPROC
19698 -END(save_rest)
19699 +ENDPROC(save_rest)
19700
19701 /* save complete stack frame */
19702 .pushsection .kprobes.text, "ax"
19703 @@ -529,9 +815,10 @@ ENTRY(save_paranoid)
19704 js 1f /* negative -> in kernel */
19705 SWAPGS
19706 xorl %ebx,%ebx
19707 -1: ret
19708 +1: pax_force_retaddr_bts
19709 + ret
19710 CFI_ENDPROC
19711 -END(save_paranoid)
19712 +ENDPROC(save_paranoid)
19713 .popsection
19714
19715 /*
19716 @@ -553,7 +840,7 @@ ENTRY(ret_from_fork)
19717
19718 RESTORE_REST
19719
19720 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19721 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19722 jz 1f
19723
19724 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19725 @@ -571,7 +858,7 @@ ENTRY(ret_from_fork)
19726 RESTORE_REST
19727 jmp int_ret_from_sys_call
19728 CFI_ENDPROC
19729 -END(ret_from_fork)
19730 +ENDPROC(ret_from_fork)
19731
19732 /*
19733 * System call entry. Up to 6 arguments in registers are supported.
19734 @@ -608,7 +895,7 @@ END(ret_from_fork)
19735 ENTRY(system_call)
19736 CFI_STARTPROC simple
19737 CFI_SIGNAL_FRAME
19738 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19739 + CFI_DEF_CFA rsp,0
19740 CFI_REGISTER rip,rcx
19741 /*CFI_REGISTER rflags,r11*/
19742 SWAPGS_UNSAFE_STACK
19743 @@ -621,16 +908,23 @@ GLOBAL(system_call_after_swapgs)
19744
19745 movq %rsp,PER_CPU_VAR(old_rsp)
19746 movq PER_CPU_VAR(kernel_stack),%rsp
19747 + SAVE_ARGS 8*6,0
19748 + pax_enter_kernel_user
19749 +
19750 +#ifdef CONFIG_PAX_RANDKSTACK
19751 + pax_erase_kstack
19752 +#endif
19753 +
19754 /*
19755 * No need to follow this irqs off/on section - it's straight
19756 * and short:
19757 */
19758 ENABLE_INTERRUPTS(CLBR_NONE)
19759 - SAVE_ARGS 8,0
19760 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19761 movq %rcx,RIP-ARGOFFSET(%rsp)
19762 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19763 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19764 + GET_THREAD_INFO(%rcx)
19765 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19766 jnz tracesys
19767 system_call_fastpath:
19768 #if __SYSCALL_MASK == ~0
19769 @@ -640,7 +934,7 @@ system_call_fastpath:
19770 cmpl $__NR_syscall_max,%eax
19771 #endif
19772 ja badsys
19773 - movq %r10,%rcx
19774 + movq R10-ARGOFFSET(%rsp),%rcx
19775 call *sys_call_table(,%rax,8) # XXX: rip relative
19776 movq %rax,RAX-ARGOFFSET(%rsp)
19777 /*
19778 @@ -654,10 +948,13 @@ sysret_check:
19779 LOCKDEP_SYS_EXIT
19780 DISABLE_INTERRUPTS(CLBR_NONE)
19781 TRACE_IRQS_OFF
19782 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19783 + GET_THREAD_INFO(%rcx)
19784 + movl TI_flags(%rcx),%edx
19785 andl %edi,%edx
19786 jnz sysret_careful
19787 CFI_REMEMBER_STATE
19788 + pax_exit_kernel_user
19789 + pax_erase_kstack
19790 /*
19791 * sysretq will re-enable interrupts:
19792 */
19793 @@ -709,14 +1006,18 @@ badsys:
19794 * jump back to the normal fast path.
19795 */
19796 auditsys:
19797 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19798 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19799 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19800 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19801 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19802 movq %rax,%rsi /* 2nd arg: syscall number */
19803 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19804 call __audit_syscall_entry
19805 +
19806 + pax_erase_kstack
19807 +
19808 LOAD_ARGS 0 /* reload call-clobbered registers */
19809 + pax_set_fptr_mask
19810 jmp system_call_fastpath
19811
19812 /*
19813 @@ -737,7 +1038,7 @@ sysret_audit:
19814 /* Do syscall tracing */
19815 tracesys:
19816 #ifdef CONFIG_AUDITSYSCALL
19817 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19818 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19819 jz auditsys
19820 #endif
19821 SAVE_REST
19822 @@ -745,12 +1046,16 @@ tracesys:
19823 FIXUP_TOP_OF_STACK %rdi
19824 movq %rsp,%rdi
19825 call syscall_trace_enter
19826 +
19827 + pax_erase_kstack
19828 +
19829 /*
19830 * Reload arg registers from stack in case ptrace changed them.
19831 * We don't reload %rax because syscall_trace_enter() returned
19832 * the value it wants us to use in the table lookup.
19833 */
19834 LOAD_ARGS ARGOFFSET, 1
19835 + pax_set_fptr_mask
19836 RESTORE_REST
19837 #if __SYSCALL_MASK == ~0
19838 cmpq $__NR_syscall_max,%rax
19839 @@ -759,7 +1064,7 @@ tracesys:
19840 cmpl $__NR_syscall_max,%eax
19841 #endif
19842 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19843 - movq %r10,%rcx /* fixup for C */
19844 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19845 call *sys_call_table(,%rax,8)
19846 movq %rax,RAX-ARGOFFSET(%rsp)
19847 /* Use IRET because user could have changed frame */
19848 @@ -780,7 +1085,9 @@ GLOBAL(int_with_check)
19849 andl %edi,%edx
19850 jnz int_careful
19851 andl $~TS_COMPAT,TI_status(%rcx)
19852 - jmp retint_swapgs
19853 + pax_exit_kernel_user
19854 + pax_erase_kstack
19855 + jmp retint_swapgs_pax
19856
19857 /* Either reschedule or signal or syscall exit tracking needed. */
19858 /* First do a reschedule test. */
19859 @@ -826,7 +1133,7 @@ int_restore_rest:
19860 TRACE_IRQS_OFF
19861 jmp int_with_check
19862 CFI_ENDPROC
19863 -END(system_call)
19864 +ENDPROC(system_call)
19865
19866 /*
19867 * Certain special system calls that need to save a complete full stack frame.
19868 @@ -842,7 +1149,7 @@ ENTRY(\label)
19869 call \func
19870 jmp ptregscall_common
19871 CFI_ENDPROC
19872 -END(\label)
19873 +ENDPROC(\label)
19874 .endm
19875
19876 .macro FORK_LIKE func
19877 @@ -856,9 +1163,10 @@ ENTRY(stub_\func)
19878 DEFAULT_FRAME 0 8 /* offset 8: return address */
19879 call sys_\func
19880 RESTORE_TOP_OF_STACK %r11, 8
19881 + pax_force_retaddr
19882 ret $REST_SKIP /* pop extended registers */
19883 CFI_ENDPROC
19884 -END(stub_\func)
19885 +ENDPROC(stub_\func)
19886 .endm
19887
19888 FORK_LIKE clone
19889 @@ -875,9 +1183,10 @@ ENTRY(ptregscall_common)
19890 movq_cfi_restore R12+8, r12
19891 movq_cfi_restore RBP+8, rbp
19892 movq_cfi_restore RBX+8, rbx
19893 + pax_force_retaddr
19894 ret $REST_SKIP /* pop extended registers */
19895 CFI_ENDPROC
19896 -END(ptregscall_common)
19897 +ENDPROC(ptregscall_common)
19898
19899 ENTRY(stub_execve)
19900 CFI_STARTPROC
19901 @@ -891,7 +1200,7 @@ ENTRY(stub_execve)
19902 RESTORE_REST
19903 jmp int_ret_from_sys_call
19904 CFI_ENDPROC
19905 -END(stub_execve)
19906 +ENDPROC(stub_execve)
19907
19908 /*
19909 * sigreturn is special because it needs to restore all registers on return.
19910 @@ -909,7 +1218,7 @@ ENTRY(stub_rt_sigreturn)
19911 RESTORE_REST
19912 jmp int_ret_from_sys_call
19913 CFI_ENDPROC
19914 -END(stub_rt_sigreturn)
19915 +ENDPROC(stub_rt_sigreturn)
19916
19917 #ifdef CONFIG_X86_X32_ABI
19918 ENTRY(stub_x32_rt_sigreturn)
19919 @@ -975,7 +1284,7 @@ vector=vector+1
19920 2: jmp common_interrupt
19921 .endr
19922 CFI_ENDPROC
19923 -END(irq_entries_start)
19924 +ENDPROC(irq_entries_start)
19925
19926 .previous
19927 END(interrupt)
19928 @@ -995,6 +1304,16 @@ END(interrupt)
19929 subq $ORIG_RAX-RBP, %rsp
19930 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19931 SAVE_ARGS_IRQ
19932 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19933 + testb $3, CS(%rdi)
19934 + jnz 1f
19935 + pax_enter_kernel
19936 + jmp 2f
19937 +1: pax_enter_kernel_user
19938 +2:
19939 +#else
19940 + pax_enter_kernel
19941 +#endif
19942 call \func
19943 .endm
19944
19945 @@ -1027,7 +1346,7 @@ ret_from_intr:
19946
19947 exit_intr:
19948 GET_THREAD_INFO(%rcx)
19949 - testl $3,CS-ARGOFFSET(%rsp)
19950 + testb $3,CS-ARGOFFSET(%rsp)
19951 je retint_kernel
19952
19953 /* Interrupt came from user space */
19954 @@ -1049,12 +1368,16 @@ retint_swapgs: /* return to user-space */
19955 * The iretq could re-enable interrupts:
19956 */
19957 DISABLE_INTERRUPTS(CLBR_ANY)
19958 + pax_exit_kernel_user
19959 +retint_swapgs_pax:
19960 TRACE_IRQS_IRETQ
19961 SWAPGS
19962 jmp restore_args
19963
19964 retint_restore_args: /* return to kernel space */
19965 DISABLE_INTERRUPTS(CLBR_ANY)
19966 + pax_exit_kernel
19967 + pax_force_retaddr (RIP-ARGOFFSET)
19968 /*
19969 * The iretq could re-enable interrupts:
19970 */
19971 @@ -1137,7 +1460,7 @@ ENTRY(retint_kernel)
19972 #endif
19973
19974 CFI_ENDPROC
19975 -END(common_interrupt)
19976 +ENDPROC(common_interrupt)
19977 /*
19978 * End of kprobes section
19979 */
19980 @@ -1155,7 +1478,7 @@ ENTRY(\sym)
19981 interrupt \do_sym
19982 jmp ret_from_intr
19983 CFI_ENDPROC
19984 -END(\sym)
19985 +ENDPROC(\sym)
19986 .endm
19987
19988 #ifdef CONFIG_SMP
19989 @@ -1211,12 +1534,22 @@ ENTRY(\sym)
19990 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19991 call error_entry
19992 DEFAULT_FRAME 0
19993 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19994 + testb $3, CS(%rsp)
19995 + jnz 1f
19996 + pax_enter_kernel
19997 + jmp 2f
19998 +1: pax_enter_kernel_user
19999 +2:
20000 +#else
20001 + pax_enter_kernel
20002 +#endif
20003 movq %rsp,%rdi /* pt_regs pointer */
20004 xorl %esi,%esi /* no error code */
20005 call \do_sym
20006 jmp error_exit /* %ebx: no swapgs flag */
20007 CFI_ENDPROC
20008 -END(\sym)
20009 +ENDPROC(\sym)
20010 .endm
20011
20012 .macro paranoidzeroentry sym do_sym
20013 @@ -1229,15 +1562,25 @@ ENTRY(\sym)
20014 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20015 call save_paranoid
20016 TRACE_IRQS_OFF
20017 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20018 + testb $3, CS(%rsp)
20019 + jnz 1f
20020 + pax_enter_kernel
20021 + jmp 2f
20022 +1: pax_enter_kernel_user
20023 +2:
20024 +#else
20025 + pax_enter_kernel
20026 +#endif
20027 movq %rsp,%rdi /* pt_regs pointer */
20028 xorl %esi,%esi /* no error code */
20029 call \do_sym
20030 jmp paranoid_exit /* %ebx: no swapgs flag */
20031 CFI_ENDPROC
20032 -END(\sym)
20033 +ENDPROC(\sym)
20034 .endm
20035
20036 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
20037 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
20038 .macro paranoidzeroentry_ist sym do_sym ist
20039 ENTRY(\sym)
20040 INTR_FRAME
20041 @@ -1248,14 +1591,30 @@ ENTRY(\sym)
20042 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20043 call save_paranoid
20044 TRACE_IRQS_OFF_DEBUG
20045 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20046 + testb $3, CS(%rsp)
20047 + jnz 1f
20048 + pax_enter_kernel
20049 + jmp 2f
20050 +1: pax_enter_kernel_user
20051 +2:
20052 +#else
20053 + pax_enter_kernel
20054 +#endif
20055 movq %rsp,%rdi /* pt_regs pointer */
20056 xorl %esi,%esi /* no error code */
20057 +#ifdef CONFIG_SMP
20058 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
20059 + lea init_tss(%r12), %r12
20060 +#else
20061 + lea init_tss(%rip), %r12
20062 +#endif
20063 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20064 call \do_sym
20065 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20066 jmp paranoid_exit /* %ebx: no swapgs flag */
20067 CFI_ENDPROC
20068 -END(\sym)
20069 +ENDPROC(\sym)
20070 .endm
20071
20072 .macro errorentry sym do_sym
20073 @@ -1267,13 +1626,23 @@ ENTRY(\sym)
20074 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20075 call error_entry
20076 DEFAULT_FRAME 0
20077 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20078 + testb $3, CS(%rsp)
20079 + jnz 1f
20080 + pax_enter_kernel
20081 + jmp 2f
20082 +1: pax_enter_kernel_user
20083 +2:
20084 +#else
20085 + pax_enter_kernel
20086 +#endif
20087 movq %rsp,%rdi /* pt_regs pointer */
20088 movq ORIG_RAX(%rsp),%rsi /* get error code */
20089 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20090 call \do_sym
20091 jmp error_exit /* %ebx: no swapgs flag */
20092 CFI_ENDPROC
20093 -END(\sym)
20094 +ENDPROC(\sym)
20095 .endm
20096
20097 /* error code is on the stack already */
20098 @@ -1287,13 +1656,23 @@ ENTRY(\sym)
20099 call save_paranoid
20100 DEFAULT_FRAME 0
20101 TRACE_IRQS_OFF
20102 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20103 + testb $3, CS(%rsp)
20104 + jnz 1f
20105 + pax_enter_kernel
20106 + jmp 2f
20107 +1: pax_enter_kernel_user
20108 +2:
20109 +#else
20110 + pax_enter_kernel
20111 +#endif
20112 movq %rsp,%rdi /* pt_regs pointer */
20113 movq ORIG_RAX(%rsp),%rsi /* get error code */
20114 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20115 call \do_sym
20116 jmp paranoid_exit /* %ebx: no swapgs flag */
20117 CFI_ENDPROC
20118 -END(\sym)
20119 +ENDPROC(\sym)
20120 .endm
20121
20122 zeroentry divide_error do_divide_error
20123 @@ -1323,9 +1702,10 @@ gs_change:
20124 2: mfence /* workaround */
20125 SWAPGS
20126 popfq_cfi
20127 + pax_force_retaddr
20128 ret
20129 CFI_ENDPROC
20130 -END(native_load_gs_index)
20131 +ENDPROC(native_load_gs_index)
20132
20133 _ASM_EXTABLE(gs_change,bad_gs)
20134 .section .fixup,"ax"
20135 @@ -1353,9 +1733,10 @@ ENTRY(call_softirq)
20136 CFI_DEF_CFA_REGISTER rsp
20137 CFI_ADJUST_CFA_OFFSET -8
20138 decl PER_CPU_VAR(irq_count)
20139 + pax_force_retaddr
20140 ret
20141 CFI_ENDPROC
20142 -END(call_softirq)
20143 +ENDPROC(call_softirq)
20144
20145 #ifdef CONFIG_XEN
20146 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
20147 @@ -1393,7 +1774,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
20148 decl PER_CPU_VAR(irq_count)
20149 jmp error_exit
20150 CFI_ENDPROC
20151 -END(xen_do_hypervisor_callback)
20152 +ENDPROC(xen_do_hypervisor_callback)
20153
20154 /*
20155 * Hypervisor uses this for application faults while it executes.
20156 @@ -1452,7 +1833,7 @@ ENTRY(xen_failsafe_callback)
20157 SAVE_ALL
20158 jmp error_exit
20159 CFI_ENDPROC
20160 -END(xen_failsafe_callback)
20161 +ENDPROC(xen_failsafe_callback)
20162
20163 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
20164 xen_hvm_callback_vector xen_evtchn_do_upcall
20165 @@ -1501,16 +1882,31 @@ ENTRY(paranoid_exit)
20166 TRACE_IRQS_OFF_DEBUG
20167 testl %ebx,%ebx /* swapgs needed? */
20168 jnz paranoid_restore
20169 - testl $3,CS(%rsp)
20170 + testb $3,CS(%rsp)
20171 jnz paranoid_userspace
20172 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20173 + pax_exit_kernel
20174 + TRACE_IRQS_IRETQ 0
20175 + SWAPGS_UNSAFE_STACK
20176 + RESTORE_ALL 8
20177 + pax_force_retaddr_bts
20178 + jmp irq_return
20179 +#endif
20180 paranoid_swapgs:
20181 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20182 + pax_exit_kernel_user
20183 +#else
20184 + pax_exit_kernel
20185 +#endif
20186 TRACE_IRQS_IRETQ 0
20187 SWAPGS_UNSAFE_STACK
20188 RESTORE_ALL 8
20189 jmp irq_return
20190 paranoid_restore:
20191 + pax_exit_kernel
20192 TRACE_IRQS_IRETQ_DEBUG 0
20193 RESTORE_ALL 8
20194 + pax_force_retaddr_bts
20195 jmp irq_return
20196 paranoid_userspace:
20197 GET_THREAD_INFO(%rcx)
20198 @@ -1539,7 +1935,7 @@ paranoid_schedule:
20199 TRACE_IRQS_OFF
20200 jmp paranoid_userspace
20201 CFI_ENDPROC
20202 -END(paranoid_exit)
20203 +ENDPROC(paranoid_exit)
20204
20205 /*
20206 * Exception entry point. This expects an error code/orig_rax on the stack.
20207 @@ -1566,12 +1962,13 @@ ENTRY(error_entry)
20208 movq_cfi r14, R14+8
20209 movq_cfi r15, R15+8
20210 xorl %ebx,%ebx
20211 - testl $3,CS+8(%rsp)
20212 + testb $3,CS+8(%rsp)
20213 je error_kernelspace
20214 error_swapgs:
20215 SWAPGS
20216 error_sti:
20217 TRACE_IRQS_OFF
20218 + pax_force_retaddr_bts
20219 ret
20220
20221 /*
20222 @@ -1598,7 +1995,7 @@ bstep_iret:
20223 movq %rcx,RIP+8(%rsp)
20224 jmp error_swapgs
20225 CFI_ENDPROC
20226 -END(error_entry)
20227 +ENDPROC(error_entry)
20228
20229
20230 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
20231 @@ -1618,7 +2015,7 @@ ENTRY(error_exit)
20232 jnz retint_careful
20233 jmp retint_swapgs
20234 CFI_ENDPROC
20235 -END(error_exit)
20236 +ENDPROC(error_exit)
20237
20238 /*
20239 * Test if a given stack is an NMI stack or not.
20240 @@ -1676,9 +2073,11 @@ ENTRY(nmi)
20241 * If %cs was not the kernel segment, then the NMI triggered in user
20242 * space, which means it is definitely not nested.
20243 */
20244 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20245 + je 1f
20246 cmpl $__KERNEL_CS, 16(%rsp)
20247 jne first_nmi
20248 -
20249 +1:
20250 /*
20251 * Check the special variable on the stack to see if NMIs are
20252 * executing.
20253 @@ -1712,8 +2111,7 @@ nested_nmi:
20254
20255 1:
20256 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
20257 - leaq -1*8(%rsp), %rdx
20258 - movq %rdx, %rsp
20259 + subq $8, %rsp
20260 CFI_ADJUST_CFA_OFFSET 1*8
20261 leaq -10*8(%rsp), %rdx
20262 pushq_cfi $__KERNEL_DS
20263 @@ -1731,6 +2129,7 @@ nested_nmi_out:
20264 CFI_RESTORE rdx
20265
20266 /* No need to check faults here */
20267 + pax_force_retaddr_bts
20268 INTERRUPT_RETURN
20269
20270 CFI_RESTORE_STATE
20271 @@ -1847,6 +2246,17 @@ end_repeat_nmi:
20272 */
20273 movq %cr2, %r12
20274
20275 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20276 + testb $3, CS(%rsp)
20277 + jnz 1f
20278 + pax_enter_kernel
20279 + jmp 2f
20280 +1: pax_enter_kernel_user
20281 +2:
20282 +#else
20283 + pax_enter_kernel
20284 +#endif
20285 +
20286 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20287 movq %rsp,%rdi
20288 movq $-1,%rsi
20289 @@ -1862,23 +2272,34 @@ end_repeat_nmi:
20290 testl %ebx,%ebx /* swapgs needed? */
20291 jnz nmi_restore
20292 nmi_swapgs:
20293 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20294 + pax_exit_kernel_user
20295 +#else
20296 + pax_exit_kernel
20297 +#endif
20298 SWAPGS_UNSAFE_STACK
20299 + RESTORE_ALL 6*8
20300 + /* Clear the NMI executing stack variable */
20301 + movq $0, 5*8(%rsp)
20302 + jmp irq_return
20303 nmi_restore:
20304 + pax_exit_kernel
20305 /* Pop the extra iret frame at once */
20306 RESTORE_ALL 6*8
20307 + pax_force_retaddr_bts
20308
20309 /* Clear the NMI executing stack variable */
20310 movq $0, 5*8(%rsp)
20311 jmp irq_return
20312 CFI_ENDPROC
20313 -END(nmi)
20314 +ENDPROC(nmi)
20315
20316 ENTRY(ignore_sysret)
20317 CFI_STARTPROC
20318 mov $-ENOSYS,%eax
20319 sysret
20320 CFI_ENDPROC
20321 -END(ignore_sysret)
20322 +ENDPROC(ignore_sysret)
20323
20324 /*
20325 * End of kprobes section
20326 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20327 index 1d41402..af9a46a 100644
20328 --- a/arch/x86/kernel/ftrace.c
20329 +++ b/arch/x86/kernel/ftrace.c
20330 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20331 {
20332 unsigned char replaced[MCOUNT_INSN_SIZE];
20333
20334 + ip = ktla_ktva(ip);
20335 +
20336 /*
20337 * Note: Due to modules and __init, code can
20338 * disappear and change, we need to protect against faulting
20339 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20340 unsigned char old[MCOUNT_INSN_SIZE], *new;
20341 int ret;
20342
20343 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20344 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20345 new = ftrace_call_replace(ip, (unsigned long)func);
20346
20347 /* See comment above by declaration of modifying_ftrace_code */
20348 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20349 /* Also update the regs callback function */
20350 if (!ret) {
20351 ip = (unsigned long)(&ftrace_regs_call);
20352 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20353 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20354 new = ftrace_call_replace(ip, (unsigned long)func);
20355 ret = ftrace_modify_code(ip, old, new);
20356 }
20357 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20358 * kernel identity mapping to modify code.
20359 */
20360 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20361 - ip = (unsigned long)__va(__pa(ip));
20362 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
20363
20364 return probe_kernel_write((void *)ip, val, size);
20365 }
20366 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20367 unsigned char replaced[MCOUNT_INSN_SIZE];
20368 unsigned char brk = BREAKPOINT_INSTRUCTION;
20369
20370 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20371 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20372 return -EFAULT;
20373
20374 /* Make sure it is what we expect it to be */
20375 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20376 return ret;
20377
20378 fail_update:
20379 - probe_kernel_write((void *)ip, &old_code[0], 1);
20380 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20381 goto out;
20382 }
20383
20384 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20385 {
20386 unsigned char code[MCOUNT_INSN_SIZE];
20387
20388 + ip = ktla_ktva(ip);
20389 +
20390 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20391 return -EFAULT;
20392
20393 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
20394 index c18f59d..9c0c9f6 100644
20395 --- a/arch/x86/kernel/head32.c
20396 +++ b/arch/x86/kernel/head32.c
20397 @@ -18,6 +18,7 @@
20398 #include <asm/io_apic.h>
20399 #include <asm/bios_ebda.h>
20400 #include <asm/tlbflush.h>
20401 +#include <asm/boot.h>
20402
20403 static void __init i386_default_early_setup(void)
20404 {
20405 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
20406
20407 void __init i386_start_kernel(void)
20408 {
20409 - memblock_reserve(__pa_symbol(&_text),
20410 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
20411 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
20412
20413 #ifdef CONFIG_BLK_DEV_INITRD
20414 /* Reserve INITRD */
20415 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20416 index c8932c7..d56b622 100644
20417 --- a/arch/x86/kernel/head_32.S
20418 +++ b/arch/x86/kernel/head_32.S
20419 @@ -26,6 +26,12 @@
20420 /* Physical address */
20421 #define pa(X) ((X) - __PAGE_OFFSET)
20422
20423 +#ifdef CONFIG_PAX_KERNEXEC
20424 +#define ta(X) (X)
20425 +#else
20426 +#define ta(X) ((X) - __PAGE_OFFSET)
20427 +#endif
20428 +
20429 /*
20430 * References to members of the new_cpu_data structure.
20431 */
20432 @@ -55,11 +61,7 @@
20433 * and small than max_low_pfn, otherwise will waste some page table entries
20434 */
20435
20436 -#if PTRS_PER_PMD > 1
20437 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20438 -#else
20439 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20440 -#endif
20441 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20442
20443 /* Number of possible pages in the lowmem region */
20444 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20445 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20446 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20447
20448 /*
20449 + * Real beginning of normal "text" segment
20450 + */
20451 +ENTRY(stext)
20452 +ENTRY(_stext)
20453 +
20454 +/*
20455 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20456 * %esi points to the real-mode code as a 32-bit pointer.
20457 * CS and DS must be 4 GB flat segments, but we don't depend on
20458 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20459 * can.
20460 */
20461 __HEAD
20462 +
20463 +#ifdef CONFIG_PAX_KERNEXEC
20464 + jmp startup_32
20465 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20466 +.fill PAGE_SIZE-5,1,0xcc
20467 +#endif
20468 +
20469 ENTRY(startup_32)
20470 movl pa(stack_start),%ecx
20471
20472 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20473 2:
20474 leal -__PAGE_OFFSET(%ecx),%esp
20475
20476 +#ifdef CONFIG_SMP
20477 + movl $pa(cpu_gdt_table),%edi
20478 + movl $__per_cpu_load,%eax
20479 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20480 + rorl $16,%eax
20481 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20482 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20483 + movl $__per_cpu_end - 1,%eax
20484 + subl $__per_cpu_start,%eax
20485 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20486 +#endif
20487 +
20488 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20489 + movl $NR_CPUS,%ecx
20490 + movl $pa(cpu_gdt_table),%edi
20491 +1:
20492 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20493 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20494 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20495 + addl $PAGE_SIZE_asm,%edi
20496 + loop 1b
20497 +#endif
20498 +
20499 +#ifdef CONFIG_PAX_KERNEXEC
20500 + movl $pa(boot_gdt),%edi
20501 + movl $__LOAD_PHYSICAL_ADDR,%eax
20502 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20503 + rorl $16,%eax
20504 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20505 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20506 + rorl $16,%eax
20507 +
20508 + ljmp $(__BOOT_CS),$1f
20509 +1:
20510 +
20511 + movl $NR_CPUS,%ecx
20512 + movl $pa(cpu_gdt_table),%edi
20513 + addl $__PAGE_OFFSET,%eax
20514 +1:
20515 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20516 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20517 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20518 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20519 + rorl $16,%eax
20520 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20521 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20522 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20523 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20524 + rorl $16,%eax
20525 + addl $PAGE_SIZE_asm,%edi
20526 + loop 1b
20527 +#endif
20528 +
20529 /*
20530 * Clear BSS first so that there are no surprises...
20531 */
20532 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20533 movl %eax, pa(max_pfn_mapped)
20534
20535 /* Do early initialization of the fixmap area */
20536 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20537 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20538 +#ifdef CONFIG_COMPAT_VDSO
20539 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20540 +#else
20541 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20542 +#endif
20543 #else /* Not PAE */
20544
20545 page_pde_offset = (__PAGE_OFFSET >> 20);
20546 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20547 movl %eax, pa(max_pfn_mapped)
20548
20549 /* Do early initialization of the fixmap area */
20550 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20551 - movl %eax,pa(initial_page_table+0xffc)
20552 +#ifdef CONFIG_COMPAT_VDSO
20553 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20554 +#else
20555 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20556 +#endif
20557 #endif
20558
20559 #ifdef CONFIG_PARAVIRT
20560 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20561 cmpl $num_subarch_entries, %eax
20562 jae bad_subarch
20563
20564 - movl pa(subarch_entries)(,%eax,4), %eax
20565 - subl $__PAGE_OFFSET, %eax
20566 - jmp *%eax
20567 + jmp *pa(subarch_entries)(,%eax,4)
20568
20569 bad_subarch:
20570 WEAK(lguest_entry)
20571 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20572 __INITDATA
20573
20574 subarch_entries:
20575 - .long default_entry /* normal x86/PC */
20576 - .long lguest_entry /* lguest hypervisor */
20577 - .long xen_entry /* Xen hypervisor */
20578 - .long default_entry /* Moorestown MID */
20579 + .long ta(default_entry) /* normal x86/PC */
20580 + .long ta(lguest_entry) /* lguest hypervisor */
20581 + .long ta(xen_entry) /* Xen hypervisor */
20582 + .long ta(default_entry) /* Moorestown MID */
20583 num_subarch_entries = (. - subarch_entries) / 4
20584 .previous
20585 #else
20586 @@ -335,6 +407,7 @@ default_entry:
20587 movl pa(mmu_cr4_features),%eax
20588 movl %eax,%cr4
20589
20590 +#ifdef CONFIG_X86_PAE
20591 testb $X86_CR4_PAE, %al # check if PAE is enabled
20592 jz 6f
20593
20594 @@ -363,6 +436,9 @@ default_entry:
20595 /* Make changes effective */
20596 wrmsr
20597
20598 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20599 +#endif
20600 +
20601 6:
20602
20603 /*
20604 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20605 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20606 movl %eax,%ss # after changing gdt.
20607
20608 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20609 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20610 movl %eax,%ds
20611 movl %eax,%es
20612
20613 movl $(__KERNEL_PERCPU), %eax
20614 movl %eax,%fs # set this cpu's percpu
20615
20616 +#ifdef CONFIG_CC_STACKPROTECTOR
20617 movl $(__KERNEL_STACK_CANARY),%eax
20618 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20619 + movl $(__USER_DS),%eax
20620 +#else
20621 + xorl %eax,%eax
20622 +#endif
20623 movl %eax,%gs
20624
20625 xorl %eax,%eax # Clear LDT
20626 @@ -544,8 +626,11 @@ setup_once:
20627 * relocation. Manually set base address in stack canary
20628 * segment descriptor.
20629 */
20630 - movl $gdt_page,%eax
20631 + movl $cpu_gdt_table,%eax
20632 movl $stack_canary,%ecx
20633 +#ifdef CONFIG_SMP
20634 + addl $__per_cpu_load,%ecx
20635 +#endif
20636 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20637 shrl $16, %ecx
20638 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20639 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20640 /* This is global to keep gas from relaxing the jumps */
20641 ENTRY(early_idt_handler)
20642 cld
20643 - cmpl $2,%ss:early_recursion_flag
20644 + cmpl $1,%ss:early_recursion_flag
20645 je hlt_loop
20646 incl %ss:early_recursion_flag
20647
20648 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20649 pushl (20+6*4)(%esp) /* trapno */
20650 pushl $fault_msg
20651 call printk
20652 -#endif
20653 call dump_stack
20654 +#endif
20655 hlt_loop:
20656 hlt
20657 jmp hlt_loop
20658 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20659 /* This is the default interrupt "handler" :-) */
20660 ALIGN
20661 ignore_int:
20662 - cld
20663 #ifdef CONFIG_PRINTK
20664 + cmpl $2,%ss:early_recursion_flag
20665 + je hlt_loop
20666 + incl %ss:early_recursion_flag
20667 + cld
20668 pushl %eax
20669 pushl %ecx
20670 pushl %edx
20671 @@ -644,9 +732,6 @@ ignore_int:
20672 movl $(__KERNEL_DS),%eax
20673 movl %eax,%ds
20674 movl %eax,%es
20675 - cmpl $2,early_recursion_flag
20676 - je hlt_loop
20677 - incl early_recursion_flag
20678 pushl 16(%esp)
20679 pushl 24(%esp)
20680 pushl 32(%esp)
20681 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20682 /*
20683 * BSS section
20684 */
20685 -__PAGE_ALIGNED_BSS
20686 - .align PAGE_SIZE
20687 #ifdef CONFIG_X86_PAE
20688 +.section .initial_pg_pmd,"a",@progbits
20689 initial_pg_pmd:
20690 .fill 1024*KPMDS,4,0
20691 #else
20692 +.section .initial_page_table,"a",@progbits
20693 ENTRY(initial_page_table)
20694 .fill 1024,4,0
20695 #endif
20696 +.section .initial_pg_fixmap,"a",@progbits
20697 initial_pg_fixmap:
20698 .fill 1024,4,0
20699 +.section .empty_zero_page,"a",@progbits
20700 ENTRY(empty_zero_page)
20701 .fill 4096,1,0
20702 +.section .swapper_pg_dir,"a",@progbits
20703 ENTRY(swapper_pg_dir)
20704 +#ifdef CONFIG_X86_PAE
20705 + .fill 4,8,0
20706 +#else
20707 .fill 1024,4,0
20708 +#endif
20709 +
20710 +/*
20711 + * The IDT has to be page-aligned to simplify the Pentium
20712 + * F0 0F bug workaround.. We have a special link segment
20713 + * for this.
20714 + */
20715 +.section .idt,"a",@progbits
20716 +ENTRY(idt_table)
20717 + .fill 256,8,0
20718
20719 /*
20720 * This starts the data section.
20721 */
20722 #ifdef CONFIG_X86_PAE
20723 -__PAGE_ALIGNED_DATA
20724 - /* Page-aligned for the benefit of paravirt? */
20725 - .align PAGE_SIZE
20726 +.section .initial_page_table,"a",@progbits
20727 ENTRY(initial_page_table)
20728 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20729 # if KPMDS == 3
20730 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20731 # error "Kernel PMDs should be 1, 2 or 3"
20732 # endif
20733 .align PAGE_SIZE /* needs to be page-sized too */
20734 +
20735 +#ifdef CONFIG_PAX_PER_CPU_PGD
20736 +ENTRY(cpu_pgd)
20737 + .rept NR_CPUS
20738 + .fill 4,8,0
20739 + .endr
20740 +#endif
20741 +
20742 #endif
20743
20744 .data
20745 .balign 4
20746 ENTRY(stack_start)
20747 - .long init_thread_union+THREAD_SIZE
20748 + .long init_thread_union+THREAD_SIZE-8
20749
20750 __INITRODATA
20751 int_msg:
20752 @@ -754,7 +861,7 @@ fault_msg:
20753 * segment size, and 32-bit linear address value:
20754 */
20755
20756 - .data
20757 +.section .rodata,"a",@progbits
20758 .globl boot_gdt_descr
20759 .globl idt_descr
20760
20761 @@ -763,7 +870,7 @@ fault_msg:
20762 .word 0 # 32 bit align gdt_desc.address
20763 boot_gdt_descr:
20764 .word __BOOT_DS+7
20765 - .long boot_gdt - __PAGE_OFFSET
20766 + .long pa(boot_gdt)
20767
20768 .word 0 # 32-bit align idt_desc.address
20769 idt_descr:
20770 @@ -774,7 +881,7 @@ idt_descr:
20771 .word 0 # 32 bit align gdt_desc.address
20772 ENTRY(early_gdt_descr)
20773 .word GDT_ENTRIES*8-1
20774 - .long gdt_page /* Overwritten for secondary CPUs */
20775 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20776
20777 /*
20778 * The boot_gdt must mirror the equivalent in setup.S and is
20779 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20780 .align L1_CACHE_BYTES
20781 ENTRY(boot_gdt)
20782 .fill GDT_ENTRY_BOOT_CS,8,0
20783 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20784 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20785 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20786 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20787 +
20788 + .align PAGE_SIZE_asm
20789 +ENTRY(cpu_gdt_table)
20790 + .rept NR_CPUS
20791 + .quad 0x0000000000000000 /* NULL descriptor */
20792 + .quad 0x0000000000000000 /* 0x0b reserved */
20793 + .quad 0x0000000000000000 /* 0x13 reserved */
20794 + .quad 0x0000000000000000 /* 0x1b reserved */
20795 +
20796 +#ifdef CONFIG_PAX_KERNEXEC
20797 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20798 +#else
20799 + .quad 0x0000000000000000 /* 0x20 unused */
20800 +#endif
20801 +
20802 + .quad 0x0000000000000000 /* 0x28 unused */
20803 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20804 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20805 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20806 + .quad 0x0000000000000000 /* 0x4b reserved */
20807 + .quad 0x0000000000000000 /* 0x53 reserved */
20808 + .quad 0x0000000000000000 /* 0x5b reserved */
20809 +
20810 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20811 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20812 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20813 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20814 +
20815 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20816 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20817 +
20818 + /*
20819 + * Segments used for calling PnP BIOS have byte granularity.
20820 + * The code segments and data segments have fixed 64k limits,
20821 + * the transfer segment sizes are set at run time.
20822 + */
20823 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20824 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20825 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20826 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20827 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20828 +
20829 + /*
20830 + * The APM segments have byte granularity and their bases
20831 + * are set at run time. All have 64k limits.
20832 + */
20833 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20834 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20835 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20836 +
20837 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20838 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20839 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20840 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20841 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20842 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20843 +
20844 + /* Be sure this is zeroed to avoid false validations in Xen */
20845 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20846 + .endr
20847 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20848 index 980053c..74d3b44 100644
20849 --- a/arch/x86/kernel/head_64.S
20850 +++ b/arch/x86/kernel/head_64.S
20851 @@ -20,6 +20,8 @@
20852 #include <asm/processor-flags.h>
20853 #include <asm/percpu.h>
20854 #include <asm/nops.h>
20855 +#include <asm/cpufeature.h>
20856 +#include <asm/alternative-asm.h>
20857
20858 #ifdef CONFIG_PARAVIRT
20859 #include <asm/asm-offsets.h>
20860 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20861 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20862 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20863 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20864 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20865 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20866 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20867 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20868 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20869 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20870
20871 .text
20872 __HEAD
20873 @@ -88,35 +96,23 @@ startup_64:
20874 */
20875 addq %rbp, init_level4_pgt + 0(%rip)
20876 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20877 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20878 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20879 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20880 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20881
20882 addq %rbp, level3_ident_pgt + 0(%rip)
20883 +#ifndef CONFIG_XEN
20884 + addq %rbp, level3_ident_pgt + 8(%rip)
20885 +#endif
20886
20887 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20888 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20889 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20890 +
20891 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20892 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20893
20894 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20895 -
20896 - /* Add an Identity mapping if I am above 1G */
20897 - leaq _text(%rip), %rdi
20898 - andq $PMD_PAGE_MASK, %rdi
20899 -
20900 - movq %rdi, %rax
20901 - shrq $PUD_SHIFT, %rax
20902 - andq $(PTRS_PER_PUD - 1), %rax
20903 - jz ident_complete
20904 -
20905 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20906 - leaq level3_ident_pgt(%rip), %rbx
20907 - movq %rdx, 0(%rbx, %rax, 8)
20908 -
20909 - movq %rdi, %rax
20910 - shrq $PMD_SHIFT, %rax
20911 - andq $(PTRS_PER_PMD - 1), %rax
20912 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20913 - leaq level2_spare_pgt(%rip), %rbx
20914 - movq %rdx, 0(%rbx, %rax, 8)
20915 -ident_complete:
20916 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20917
20918 /*
20919 * Fixup the kernel text+data virtual addresses. Note that
20920 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20921 * after the boot processor executes this code.
20922 */
20923
20924 - /* Enable PAE mode and PGE */
20925 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20926 + /* Enable PAE mode and PSE/PGE */
20927 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20928 movq %rax, %cr4
20929
20930 /* Setup early boot stage 4 level pagetables. */
20931 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20932 movl $MSR_EFER, %ecx
20933 rdmsr
20934 btsl $_EFER_SCE, %eax /* Enable System Call */
20935 - btl $20,%edi /* No Execute supported? */
20936 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20937 jnc 1f
20938 btsl $_EFER_NX, %eax
20939 + leaq init_level4_pgt(%rip), %rdi
20940 +#ifndef CONFIG_EFI
20941 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20942 +#endif
20943 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20944 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20945 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20946 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20947 1: wrmsr /* Make changes effective */
20948
20949 /* Setup cr0 */
20950 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20951 * jump. In addition we need to ensure %cs is set so we make this
20952 * a far return.
20953 */
20954 + pax_set_fptr_mask
20955 movq initial_code(%rip),%rax
20956 pushq $0 # fake return address to stop unwinder
20957 pushq $__KERNEL_CS # set correct cs
20958 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
20959 bad_address:
20960 jmp bad_address
20961
20962 - .section ".init.text","ax"
20963 + __INIT
20964 .globl early_idt_handlers
20965 early_idt_handlers:
20966 # 104(%rsp) %rflags
20967 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
20968 call dump_stack
20969 #ifdef CONFIG_KALLSYMS
20970 leaq early_idt_ripmsg(%rip),%rdi
20971 - movq 40(%rsp),%rsi # %rip again
20972 + movq 88(%rsp),%rsi # %rip again
20973 call __print_symbol
20974 #endif
20975 #endif /* EARLY_PRINTK */
20976 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
20977 addq $16,%rsp # drop vector number and error code
20978 decl early_recursion_flag(%rip)
20979 INTERRUPT_RETURN
20980 + .previous
20981
20982 + __INITDATA
20983 .balign 4
20984 early_recursion_flag:
20985 .long 0
20986 + .previous
20987
20988 + .section .rodata,"a",@progbits
20989 #ifdef CONFIG_EARLY_PRINTK
20990 early_idt_msg:
20991 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20992 @@ -376,6 +385,7 @@ early_idt_ripmsg:
20993 #endif /* CONFIG_EARLY_PRINTK */
20994 .previous
20995
20996 + .section .rodata,"a",@progbits
20997 #define NEXT_PAGE(name) \
20998 .balign PAGE_SIZE; \
20999 ENTRY(name)
21000 @@ -388,7 +398,6 @@ ENTRY(name)
21001 i = i + 1 ; \
21002 .endr
21003
21004 - .data
21005 /*
21006 * This default setting generates an ident mapping at address 0x100000
21007 * and a mapping for the kernel that precisely maps virtual address
21008 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
21009 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21010 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
21011 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21012 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
21013 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
21014 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
21015 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
21016 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
21017 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
21018 .org init_level4_pgt + L4_START_KERNEL*8, 0
21019 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
21020 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
21021
21022 +#ifdef CONFIG_PAX_PER_CPU_PGD
21023 +NEXT_PAGE(cpu_pgd)
21024 + .rept NR_CPUS
21025 + .fill 512,8,0
21026 + .endr
21027 +#endif
21028 +
21029 NEXT_PAGE(level3_ident_pgt)
21030 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21031 +#ifdef CONFIG_XEN
21032 .fill 511,8,0
21033 +#else
21034 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
21035 + .fill 510,8,0
21036 +#endif
21037 +
21038 +NEXT_PAGE(level3_vmalloc_start_pgt)
21039 + .fill 512,8,0
21040 +
21041 +NEXT_PAGE(level3_vmalloc_end_pgt)
21042 + .fill 512,8,0
21043 +
21044 +NEXT_PAGE(level3_vmemmap_pgt)
21045 + .fill L3_VMEMMAP_START,8,0
21046 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
21047
21048 NEXT_PAGE(level3_kernel_pgt)
21049 .fill L3_START_KERNEL,8,0
21050 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
21051 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
21052 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21053
21054 +NEXT_PAGE(level2_vmemmap_pgt)
21055 + .fill 512,8,0
21056 +
21057 NEXT_PAGE(level2_fixmap_pgt)
21058 - .fill 506,8,0
21059 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21060 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
21061 - .fill 5,8,0
21062 + .fill 507,8,0
21063 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
21064 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
21065 + .fill 4,8,0
21066
21067 -NEXT_PAGE(level1_fixmap_pgt)
21068 +NEXT_PAGE(level1_vsyscall_pgt)
21069 .fill 512,8,0
21070
21071 -NEXT_PAGE(level2_ident_pgt)
21072 - /* Since I easily can, map the first 1G.
21073 + /* Since I easily can, map the first 2G.
21074 * Don't set NX because code runs from these pages.
21075 */
21076 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
21077 +NEXT_PAGE(level2_ident_pgt)
21078 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
21079
21080 NEXT_PAGE(level2_kernel_pgt)
21081 /*
21082 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
21083 * If you want to increase this then increase MODULES_VADDR
21084 * too.)
21085 */
21086 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
21087 - KERNEL_IMAGE_SIZE/PMD_SIZE)
21088 -
21089 -NEXT_PAGE(level2_spare_pgt)
21090 - .fill 512, 8, 0
21091 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
21092
21093 #undef PMDS
21094 #undef NEXT_PAGE
21095
21096 - .data
21097 + .align PAGE_SIZE
21098 +ENTRY(cpu_gdt_table)
21099 + .rept NR_CPUS
21100 + .quad 0x0000000000000000 /* NULL descriptor */
21101 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
21102 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
21103 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
21104 + .quad 0x00cffb000000ffff /* __USER32_CS */
21105 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
21106 + .quad 0x00affb000000ffff /* __USER_CS */
21107 +
21108 +#ifdef CONFIG_PAX_KERNEXEC
21109 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
21110 +#else
21111 + .quad 0x0 /* unused */
21112 +#endif
21113 +
21114 + .quad 0,0 /* TSS */
21115 + .quad 0,0 /* LDT */
21116 + .quad 0,0,0 /* three TLS descriptors */
21117 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
21118 + /* asm/segment.h:GDT_ENTRIES must match this */
21119 +
21120 + /* zero the remaining page */
21121 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
21122 + .endr
21123 +
21124 .align 16
21125 .globl early_gdt_descr
21126 early_gdt_descr:
21127 .word GDT_ENTRIES*8-1
21128 early_gdt_descr_base:
21129 - .quad INIT_PER_CPU_VAR(gdt_page)
21130 + .quad cpu_gdt_table
21131
21132 ENTRY(phys_base)
21133 /* This must match the first entry in level2_kernel_pgt */
21134 .quad 0x0000000000000000
21135
21136 #include "../../x86/xen/xen-head.S"
21137 -
21138 - .section .bss, "aw", @nobits
21139 +
21140 + .section .rodata,"a",@progbits
21141 .align L1_CACHE_BYTES
21142 ENTRY(idt_table)
21143 - .skip IDT_ENTRIES * 16
21144 + .fill 512,8,0
21145
21146 .align L1_CACHE_BYTES
21147 ENTRY(nmi_idt_table)
21148 - .skip IDT_ENTRIES * 16
21149 + .fill 512,8,0
21150
21151 __PAGE_ALIGNED_BSS
21152 .align PAGE_SIZE
21153 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
21154 index 9c3bd4a..e1d9b35 100644
21155 --- a/arch/x86/kernel/i386_ksyms_32.c
21156 +++ b/arch/x86/kernel/i386_ksyms_32.c
21157 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
21158 EXPORT_SYMBOL(cmpxchg8b_emu);
21159 #endif
21160
21161 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
21162 +
21163 /* Networking helper routines. */
21164 EXPORT_SYMBOL(csum_partial_copy_generic);
21165 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
21166 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
21167
21168 EXPORT_SYMBOL(__get_user_1);
21169 EXPORT_SYMBOL(__get_user_2);
21170 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
21171
21172 EXPORT_SYMBOL(csum_partial);
21173 EXPORT_SYMBOL(empty_zero_page);
21174 +
21175 +#ifdef CONFIG_PAX_KERNEXEC
21176 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
21177 +#endif
21178 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
21179 index 245a71d..89d9ce4 100644
21180 --- a/arch/x86/kernel/i387.c
21181 +++ b/arch/x86/kernel/i387.c
21182 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
21183 static inline bool interrupted_user_mode(void)
21184 {
21185 struct pt_regs *regs = get_irq_regs();
21186 - return regs && user_mode_vm(regs);
21187 + return regs && user_mode(regs);
21188 }
21189
21190 /*
21191 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
21192 index 9a5c460..84868423 100644
21193 --- a/arch/x86/kernel/i8259.c
21194 +++ b/arch/x86/kernel/i8259.c
21195 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
21196 static void make_8259A_irq(unsigned int irq)
21197 {
21198 disable_irq_nosync(irq);
21199 - io_apic_irqs &= ~(1<<irq);
21200 + io_apic_irqs &= ~(1UL<<irq);
21201 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
21202 i8259A_chip.name);
21203 enable_irq(irq);
21204 @@ -209,7 +209,7 @@ spurious_8259A_irq:
21205 "spurious 8259A interrupt: IRQ%d.\n", irq);
21206 spurious_irq_mask |= irqmask;
21207 }
21208 - atomic_inc(&irq_err_count);
21209 + atomic_inc_unchecked(&irq_err_count);
21210 /*
21211 * Theoretically we do not have to handle this IRQ,
21212 * but in Linux this does not cause problems and is
21213 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
21214 /* (slave's support for AEOI in flat mode is to be investigated) */
21215 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
21216
21217 + pax_open_kernel();
21218 if (auto_eoi)
21219 /*
21220 * In AEOI mode we just have to mask the interrupt
21221 * when acking.
21222 */
21223 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
21224 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
21225 else
21226 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21227 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21228 + pax_close_kernel();
21229
21230 udelay(100); /* wait for 8259A to initialize */
21231
21232 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
21233 index a979b5b..1d6db75 100644
21234 --- a/arch/x86/kernel/io_delay.c
21235 +++ b/arch/x86/kernel/io_delay.c
21236 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
21237 * Quirk table for systems that misbehave (lock up, etc.) if port
21238 * 0x80 is used:
21239 */
21240 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
21241 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
21242 {
21243 .callback = dmi_io_delay_0xed_port,
21244 .ident = "Compaq Presario V6000",
21245 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
21246 index 8c96897..be66bfa 100644
21247 --- a/arch/x86/kernel/ioport.c
21248 +++ b/arch/x86/kernel/ioport.c
21249 @@ -6,6 +6,7 @@
21250 #include <linux/sched.h>
21251 #include <linux/kernel.h>
21252 #include <linux/capability.h>
21253 +#include <linux/security.h>
21254 #include <linux/errno.h>
21255 #include <linux/types.h>
21256 #include <linux/ioport.h>
21257 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21258
21259 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
21260 return -EINVAL;
21261 +#ifdef CONFIG_GRKERNSEC_IO
21262 + if (turn_on && grsec_disable_privio) {
21263 + gr_handle_ioperm();
21264 + return -EPERM;
21265 + }
21266 +#endif
21267 if (turn_on && !capable(CAP_SYS_RAWIO))
21268 return -EPERM;
21269
21270 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21271 * because the ->io_bitmap_max value must match the bitmap
21272 * contents:
21273 */
21274 - tss = &per_cpu(init_tss, get_cpu());
21275 + tss = init_tss + get_cpu();
21276
21277 if (turn_on)
21278 bitmap_clear(t->io_bitmap_ptr, from, num);
21279 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
21280 return -EINVAL;
21281 /* Trying to gain more privileges? */
21282 if (level > old) {
21283 +#ifdef CONFIG_GRKERNSEC_IO
21284 + if (grsec_disable_privio) {
21285 + gr_handle_iopl();
21286 + return -EPERM;
21287 + }
21288 +#endif
21289 if (!capable(CAP_SYS_RAWIO))
21290 return -EPERM;
21291 }
21292 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21293 index e4595f1..ee3bfb8 100644
21294 --- a/arch/x86/kernel/irq.c
21295 +++ b/arch/x86/kernel/irq.c
21296 @@ -18,7 +18,7 @@
21297 #include <asm/mce.h>
21298 #include <asm/hw_irq.h>
21299
21300 -atomic_t irq_err_count;
21301 +atomic_unchecked_t irq_err_count;
21302
21303 /* Function pointer for generic interrupt vector handling */
21304 void (*x86_platform_ipi_callback)(void) = NULL;
21305 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21306 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21307 seq_printf(p, " Machine check polls\n");
21308 #endif
21309 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21310 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21311 #if defined(CONFIG_X86_IO_APIC)
21312 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21313 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21314 #endif
21315 return 0;
21316 }
21317 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21318
21319 u64 arch_irq_stat(void)
21320 {
21321 - u64 sum = atomic_read(&irq_err_count);
21322 + u64 sum = atomic_read_unchecked(&irq_err_count);
21323
21324 #ifdef CONFIG_X86_IO_APIC
21325 - sum += atomic_read(&irq_mis_count);
21326 + sum += atomic_read_unchecked(&irq_mis_count);
21327 #endif
21328 return sum;
21329 }
21330 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21331 index 344faf8..355f60d 100644
21332 --- a/arch/x86/kernel/irq_32.c
21333 +++ b/arch/x86/kernel/irq_32.c
21334 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21335 __asm__ __volatile__("andl %%esp,%0" :
21336 "=r" (sp) : "0" (THREAD_SIZE - 1));
21337
21338 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21339 + return sp < STACK_WARN;
21340 }
21341
21342 static void print_stack_overflow(void)
21343 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21344 * per-CPU IRQ handling contexts (thread information and stack)
21345 */
21346 union irq_ctx {
21347 - struct thread_info tinfo;
21348 - u32 stack[THREAD_SIZE/sizeof(u32)];
21349 + unsigned long previous_esp;
21350 + u32 stack[THREAD_SIZE/sizeof(u32)];
21351 } __attribute__((aligned(THREAD_SIZE)));
21352
21353 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21354 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21355 static inline int
21356 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21357 {
21358 - union irq_ctx *curctx, *irqctx;
21359 + union irq_ctx *irqctx;
21360 u32 *isp, arg1, arg2;
21361
21362 - curctx = (union irq_ctx *) current_thread_info();
21363 irqctx = __this_cpu_read(hardirq_ctx);
21364
21365 /*
21366 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21367 * handler) we can't do that and just have to keep using the
21368 * current stack (which is the irq stack already after all)
21369 */
21370 - if (unlikely(curctx == irqctx))
21371 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21372 return 0;
21373
21374 /* build the stack frame on the IRQ stack */
21375 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21376 - irqctx->tinfo.task = curctx->tinfo.task;
21377 - irqctx->tinfo.previous_esp = current_stack_pointer;
21378 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21379 + irqctx->previous_esp = current_stack_pointer;
21380
21381 - /* Copy the preempt_count so that the [soft]irq checks work. */
21382 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21383 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21384 + __set_fs(MAKE_MM_SEG(0));
21385 +#endif
21386
21387 if (unlikely(overflow))
21388 call_on_stack(print_stack_overflow, isp);
21389 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21390 : "0" (irq), "1" (desc), "2" (isp),
21391 "D" (desc->handle_irq)
21392 : "memory", "cc", "ecx");
21393 +
21394 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21395 + __set_fs(current_thread_info()->addr_limit);
21396 +#endif
21397 +
21398 return 1;
21399 }
21400
21401 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21402 */
21403 void __cpuinit irq_ctx_init(int cpu)
21404 {
21405 - union irq_ctx *irqctx;
21406 -
21407 if (per_cpu(hardirq_ctx, cpu))
21408 return;
21409
21410 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21411 - THREADINFO_GFP,
21412 - THREAD_SIZE_ORDER));
21413 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21414 - irqctx->tinfo.cpu = cpu;
21415 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21416 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21417 -
21418 - per_cpu(hardirq_ctx, cpu) = irqctx;
21419 -
21420 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21421 - THREADINFO_GFP,
21422 - THREAD_SIZE_ORDER));
21423 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21424 - irqctx->tinfo.cpu = cpu;
21425 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21426 -
21427 - per_cpu(softirq_ctx, cpu) = irqctx;
21428 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21429 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21430 +
21431 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21432 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21433
21434 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21435 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21436 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21437 asmlinkage void do_softirq(void)
21438 {
21439 unsigned long flags;
21440 - struct thread_info *curctx;
21441 union irq_ctx *irqctx;
21442 u32 *isp;
21443
21444 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21445 local_irq_save(flags);
21446
21447 if (local_softirq_pending()) {
21448 - curctx = current_thread_info();
21449 irqctx = __this_cpu_read(softirq_ctx);
21450 - irqctx->tinfo.task = curctx->task;
21451 - irqctx->tinfo.previous_esp = current_stack_pointer;
21452 + irqctx->previous_esp = current_stack_pointer;
21453
21454 /* build the stack frame on the softirq stack */
21455 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21456 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21457 +
21458 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21459 + __set_fs(MAKE_MM_SEG(0));
21460 +#endif
21461
21462 call_on_stack(__do_softirq, isp);
21463 +
21464 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21465 + __set_fs(current_thread_info()->addr_limit);
21466 +#endif
21467 +
21468 /*
21469 * Shouldn't happen, we returned above if in_interrupt():
21470 */
21471 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21472 if (unlikely(!desc))
21473 return false;
21474
21475 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21476 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21477 if (unlikely(overflow))
21478 print_stack_overflow();
21479 desc->handle_irq(irq, desc);
21480 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21481 index d04d3ec..ea4b374 100644
21482 --- a/arch/x86/kernel/irq_64.c
21483 +++ b/arch/x86/kernel/irq_64.c
21484 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21485 u64 estack_top, estack_bottom;
21486 u64 curbase = (u64)task_stack_page(current);
21487
21488 - if (user_mode_vm(regs))
21489 + if (user_mode(regs))
21490 return;
21491
21492 if (regs->sp >= curbase + sizeof(struct thread_info) +
21493 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21494 index dc1404b..bbc43e7 100644
21495 --- a/arch/x86/kernel/kdebugfs.c
21496 +++ b/arch/x86/kernel/kdebugfs.c
21497 @@ -27,7 +27,7 @@ struct setup_data_node {
21498 u32 len;
21499 };
21500
21501 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21502 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21503 size_t count, loff_t *ppos)
21504 {
21505 struct setup_data_node *node = file->private_data;
21506 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21507 index 836f832..a8bda67 100644
21508 --- a/arch/x86/kernel/kgdb.c
21509 +++ b/arch/x86/kernel/kgdb.c
21510 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21511 #ifdef CONFIG_X86_32
21512 switch (regno) {
21513 case GDB_SS:
21514 - if (!user_mode_vm(regs))
21515 + if (!user_mode(regs))
21516 *(unsigned long *)mem = __KERNEL_DS;
21517 break;
21518 case GDB_SP:
21519 - if (!user_mode_vm(regs))
21520 + if (!user_mode(regs))
21521 *(unsigned long *)mem = kernel_stack_pointer(regs);
21522 break;
21523 case GDB_GS:
21524 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21525 bp->attr.bp_addr = breakinfo[breakno].addr;
21526 bp->attr.bp_len = breakinfo[breakno].len;
21527 bp->attr.bp_type = breakinfo[breakno].type;
21528 - info->address = breakinfo[breakno].addr;
21529 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21530 + info->address = ktla_ktva(breakinfo[breakno].addr);
21531 + else
21532 + info->address = breakinfo[breakno].addr;
21533 info->len = breakinfo[breakno].len;
21534 info->type = breakinfo[breakno].type;
21535 val = arch_install_hw_breakpoint(bp);
21536 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21537 case 'k':
21538 /* clear the trace bit */
21539 linux_regs->flags &= ~X86_EFLAGS_TF;
21540 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21541 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21542
21543 /* set the trace bit if we're stepping */
21544 if (remcomInBuffer[0] == 's') {
21545 linux_regs->flags |= X86_EFLAGS_TF;
21546 - atomic_set(&kgdb_cpu_doing_single_step,
21547 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21548 raw_smp_processor_id());
21549 }
21550
21551 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21552
21553 switch (cmd) {
21554 case DIE_DEBUG:
21555 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21556 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21557 if (user_mode(regs))
21558 return single_step_cont(regs, args);
21559 break;
21560 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21561 #endif /* CONFIG_DEBUG_RODATA */
21562
21563 bpt->type = BP_BREAKPOINT;
21564 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21565 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21566 BREAK_INSTR_SIZE);
21567 if (err)
21568 return err;
21569 - err = probe_kernel_write((char *)bpt->bpt_addr,
21570 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21571 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21572 #ifdef CONFIG_DEBUG_RODATA
21573 if (!err)
21574 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21575 return -EBUSY;
21576 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21577 BREAK_INSTR_SIZE);
21578 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21579 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21580 if (err)
21581 return err;
21582 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21583 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21584 if (mutex_is_locked(&text_mutex))
21585 goto knl_write;
21586 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21587 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21588 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21589 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21590 goto knl_write;
21591 return err;
21592 knl_write:
21593 #endif /* CONFIG_DEBUG_RODATA */
21594 - return probe_kernel_write((char *)bpt->bpt_addr,
21595 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21596 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21597 }
21598
21599 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21600 index c5e410e..ed5a7f0 100644
21601 --- a/arch/x86/kernel/kprobes-opt.c
21602 +++ b/arch/x86/kernel/kprobes-opt.c
21603 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21604 * Verify if the address gap is in 2GB range, because this uses
21605 * a relative jump.
21606 */
21607 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21608 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21609 if (abs(rel) > 0x7fffffff)
21610 return -ERANGE;
21611
21612 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21613 op->optinsn.size = ret;
21614
21615 /* Copy arch-dep-instance from template */
21616 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21617 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21618
21619 /* Set probe information */
21620 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21621
21622 /* Set probe function call */
21623 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21624 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21625
21626 /* Set returning jmp instruction at the tail of out-of-line buffer */
21627 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21628 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21629 (u8 *)op->kp.addr + op->optinsn.size);
21630
21631 flush_icache_range((unsigned long) buf,
21632 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21633 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21634
21635 /* Backup instructions which will be replaced by jump address */
21636 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21637 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21638 RELATIVE_ADDR_SIZE);
21639
21640 insn_buf[0] = RELATIVEJUMP_OPCODE;
21641 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21642 /* This kprobe is really able to run optimized path. */
21643 op = container_of(p, struct optimized_kprobe, kp);
21644 /* Detour through copied instructions */
21645 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21646 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21647 if (!reenter)
21648 reset_current_kprobe();
21649 preempt_enable_no_resched();
21650 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21651 index 57916c0..9e0b9d0 100644
21652 --- a/arch/x86/kernel/kprobes.c
21653 +++ b/arch/x86/kernel/kprobes.c
21654 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21655 s32 raddr;
21656 } __attribute__((packed)) *insn;
21657
21658 - insn = (struct __arch_relative_insn *)from;
21659 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21660 +
21661 + pax_open_kernel();
21662 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21663 insn->op = op;
21664 + pax_close_kernel();
21665 }
21666
21667 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21668 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21669 kprobe_opcode_t opcode;
21670 kprobe_opcode_t *orig_opcodes = opcodes;
21671
21672 - if (search_exception_tables((unsigned long)opcodes))
21673 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21674 return 0; /* Page fault may occur on this address. */
21675
21676 retry:
21677 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21678 * for the first byte, we can recover the original instruction
21679 * from it and kp->opcode.
21680 */
21681 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21682 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21683 buf[0] = kp->opcode;
21684 - return (unsigned long)buf;
21685 + return ktva_ktla((unsigned long)buf);
21686 }
21687
21688 /*
21689 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21690 /* Another subsystem puts a breakpoint, failed to recover */
21691 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21692 return 0;
21693 + pax_open_kernel();
21694 memcpy(dest, insn.kaddr, insn.length);
21695 + pax_close_kernel();
21696
21697 #ifdef CONFIG_X86_64
21698 if (insn_rip_relative(&insn)) {
21699 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21700 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21701 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21702 disp = (u8 *) dest + insn_offset_displacement(&insn);
21703 + pax_open_kernel();
21704 *(s32 *) disp = (s32) newdisp;
21705 + pax_close_kernel();
21706 }
21707 #endif
21708 return insn.length;
21709 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21710 * nor set current_kprobe, because it doesn't use single
21711 * stepping.
21712 */
21713 - regs->ip = (unsigned long)p->ainsn.insn;
21714 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21715 preempt_enable_no_resched();
21716 return;
21717 }
21718 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21719 regs->flags &= ~X86_EFLAGS_IF;
21720 /* single step inline if the instruction is an int3 */
21721 if (p->opcode == BREAKPOINT_INSTRUCTION)
21722 - regs->ip = (unsigned long)p->addr;
21723 + regs->ip = ktla_ktva((unsigned long)p->addr);
21724 else
21725 - regs->ip = (unsigned long)p->ainsn.insn;
21726 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21727 }
21728
21729 /*
21730 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21731 setup_singlestep(p, regs, kcb, 0);
21732 return 1;
21733 }
21734 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21735 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21736 /*
21737 * The breakpoint instruction was removed right
21738 * after we hit it. Another cpu has removed
21739 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21740 " movq %rax, 152(%rsp)\n"
21741 RESTORE_REGS_STRING
21742 " popfq\n"
21743 +#ifdef KERNEXEC_PLUGIN
21744 + " btsq $63,(%rsp)\n"
21745 +#endif
21746 #else
21747 " pushf\n"
21748 SAVE_REGS_STRING
21749 @@ -788,7 +798,7 @@ static void __kprobes
21750 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21751 {
21752 unsigned long *tos = stack_addr(regs);
21753 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21754 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21755 unsigned long orig_ip = (unsigned long)p->addr;
21756 kprobe_opcode_t *insn = p->ainsn.insn;
21757
21758 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21759 struct die_args *args = data;
21760 int ret = NOTIFY_DONE;
21761
21762 - if (args->regs && user_mode_vm(args->regs))
21763 + if (args->regs && user_mode(args->regs))
21764 return ret;
21765
21766 switch (val) {
21767 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21768 index 9c2bd8b..bb1131c 100644
21769 --- a/arch/x86/kernel/kvm.c
21770 +++ b/arch/x86/kernel/kvm.c
21771 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21772 return NOTIFY_OK;
21773 }
21774
21775 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21776 +static struct notifier_block kvm_cpu_notifier = {
21777 .notifier_call = kvm_cpu_notify,
21778 };
21779 #endif
21780 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21781 index ebc9873..1b9724b 100644
21782 --- a/arch/x86/kernel/ldt.c
21783 +++ b/arch/x86/kernel/ldt.c
21784 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21785 if (reload) {
21786 #ifdef CONFIG_SMP
21787 preempt_disable();
21788 - load_LDT(pc);
21789 + load_LDT_nolock(pc);
21790 if (!cpumask_equal(mm_cpumask(current->mm),
21791 cpumask_of(smp_processor_id())))
21792 smp_call_function(flush_ldt, current->mm, 1);
21793 preempt_enable();
21794 #else
21795 - load_LDT(pc);
21796 + load_LDT_nolock(pc);
21797 #endif
21798 }
21799 if (oldsize) {
21800 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21801 return err;
21802
21803 for (i = 0; i < old->size; i++)
21804 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21805 + write_ldt_entry(new->ldt, i, old->ldt + i);
21806 return 0;
21807 }
21808
21809 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21810 retval = copy_ldt(&mm->context, &old_mm->context);
21811 mutex_unlock(&old_mm->context.lock);
21812 }
21813 +
21814 + if (tsk == current) {
21815 + mm->context.vdso = 0;
21816 +
21817 +#ifdef CONFIG_X86_32
21818 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21819 + mm->context.user_cs_base = 0UL;
21820 + mm->context.user_cs_limit = ~0UL;
21821 +
21822 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21823 + cpus_clear(mm->context.cpu_user_cs_mask);
21824 +#endif
21825 +
21826 +#endif
21827 +#endif
21828 +
21829 + }
21830 +
21831 return retval;
21832 }
21833
21834 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21835 }
21836 }
21837
21838 +#ifdef CONFIG_PAX_SEGMEXEC
21839 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21840 + error = -EINVAL;
21841 + goto out_unlock;
21842 + }
21843 +#endif
21844 +
21845 fill_ldt(&ldt, &ldt_info);
21846 if (oldmode)
21847 ldt.avl = 0;
21848 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21849 index 5b19e4d..6476a76 100644
21850 --- a/arch/x86/kernel/machine_kexec_32.c
21851 +++ b/arch/x86/kernel/machine_kexec_32.c
21852 @@ -26,7 +26,7 @@
21853 #include <asm/cacheflush.h>
21854 #include <asm/debugreg.h>
21855
21856 -static void set_idt(void *newidt, __u16 limit)
21857 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21858 {
21859 struct desc_ptr curidt;
21860
21861 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21862 }
21863
21864
21865 -static void set_gdt(void *newgdt, __u16 limit)
21866 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21867 {
21868 struct desc_ptr curgdt;
21869
21870 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21871 }
21872
21873 control_page = page_address(image->control_code_page);
21874 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21875 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21876
21877 relocate_kernel_ptr = control_page;
21878 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21879 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21880 index 3a04b22..1d2eb09 100644
21881 --- a/arch/x86/kernel/microcode_core.c
21882 +++ b/arch/x86/kernel/microcode_core.c
21883 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21884 return NOTIFY_OK;
21885 }
21886
21887 -static struct notifier_block __refdata mc_cpu_notifier = {
21888 +static struct notifier_block mc_cpu_notifier = {
21889 .notifier_call = mc_cpu_callback,
21890 };
21891
21892 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21893 index 3544aed..01ddc1c 100644
21894 --- a/arch/x86/kernel/microcode_intel.c
21895 +++ b/arch/x86/kernel/microcode_intel.c
21896 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21897
21898 static int get_ucode_user(void *to, const void *from, size_t n)
21899 {
21900 - return copy_from_user(to, from, n);
21901 + return copy_from_user(to, (const void __force_user *)from, n);
21902 }
21903
21904 static enum ucode_state
21905 request_microcode_user(int cpu, const void __user *buf, size_t size)
21906 {
21907 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21908 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21909 }
21910
21911 static void microcode_fini_cpu(int cpu)
21912 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21913 index 216a4d7..228255a 100644
21914 --- a/arch/x86/kernel/module.c
21915 +++ b/arch/x86/kernel/module.c
21916 @@ -43,15 +43,60 @@ do { \
21917 } while (0)
21918 #endif
21919
21920 -void *module_alloc(unsigned long size)
21921 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21922 {
21923 - if (PAGE_ALIGN(size) > MODULES_LEN)
21924 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21925 return NULL;
21926 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21927 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21928 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21929 -1, __builtin_return_address(0));
21930 }
21931
21932 +void *module_alloc(unsigned long size)
21933 +{
21934 +
21935 +#ifdef CONFIG_PAX_KERNEXEC
21936 + return __module_alloc(size, PAGE_KERNEL);
21937 +#else
21938 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21939 +#endif
21940 +
21941 +}
21942 +
21943 +#ifdef CONFIG_PAX_KERNEXEC
21944 +#ifdef CONFIG_X86_32
21945 +void *module_alloc_exec(unsigned long size)
21946 +{
21947 + struct vm_struct *area;
21948 +
21949 + if (size == 0)
21950 + return NULL;
21951 +
21952 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21953 + return area ? area->addr : NULL;
21954 +}
21955 +EXPORT_SYMBOL(module_alloc_exec);
21956 +
21957 +void module_free_exec(struct module *mod, void *module_region)
21958 +{
21959 + vunmap(module_region);
21960 +}
21961 +EXPORT_SYMBOL(module_free_exec);
21962 +#else
21963 +void module_free_exec(struct module *mod, void *module_region)
21964 +{
21965 + module_free(mod, module_region);
21966 +}
21967 +EXPORT_SYMBOL(module_free_exec);
21968 +
21969 +void *module_alloc_exec(unsigned long size)
21970 +{
21971 + return __module_alloc(size, PAGE_KERNEL_RX);
21972 +}
21973 +EXPORT_SYMBOL(module_alloc_exec);
21974 +#endif
21975 +#endif
21976 +
21977 #ifdef CONFIG_X86_32
21978 int apply_relocate(Elf32_Shdr *sechdrs,
21979 const char *strtab,
21980 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21981 unsigned int i;
21982 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21983 Elf32_Sym *sym;
21984 - uint32_t *location;
21985 + uint32_t *plocation, location;
21986
21987 DEBUGP("Applying relocate section %u to %u\n",
21988 relsec, sechdrs[relsec].sh_info);
21989 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21990 /* This is where to make the change */
21991 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21992 - + rel[i].r_offset;
21993 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21994 + location = (uint32_t)plocation;
21995 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21996 + plocation = ktla_ktva((void *)plocation);
21997 /* This is the symbol it is referring to. Note that all
21998 undefined symbols have been resolved. */
21999 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
22000 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
22001 switch (ELF32_R_TYPE(rel[i].r_info)) {
22002 case R_386_32:
22003 /* We add the value into the location given */
22004 - *location += sym->st_value;
22005 + pax_open_kernel();
22006 + *plocation += sym->st_value;
22007 + pax_close_kernel();
22008 break;
22009 case R_386_PC32:
22010 /* Add the value, subtract its position */
22011 - *location += sym->st_value - (uint32_t)location;
22012 + pax_open_kernel();
22013 + *plocation += sym->st_value - location;
22014 + pax_close_kernel();
22015 break;
22016 default:
22017 pr_err("%s: Unknown relocation: %u\n",
22018 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
22019 case R_X86_64_NONE:
22020 break;
22021 case R_X86_64_64:
22022 + pax_open_kernel();
22023 *(u64 *)loc = val;
22024 + pax_close_kernel();
22025 break;
22026 case R_X86_64_32:
22027 + pax_open_kernel();
22028 *(u32 *)loc = val;
22029 + pax_close_kernel();
22030 if (val != *(u32 *)loc)
22031 goto overflow;
22032 break;
22033 case R_X86_64_32S:
22034 + pax_open_kernel();
22035 *(s32 *)loc = val;
22036 + pax_close_kernel();
22037 if ((s64)val != *(s32 *)loc)
22038 goto overflow;
22039 break;
22040 case R_X86_64_PC32:
22041 val -= (u64)loc;
22042 + pax_open_kernel();
22043 *(u32 *)loc = val;
22044 + pax_close_kernel();
22045 +
22046 #if 0
22047 if ((s64)val != *(s32 *)loc)
22048 goto overflow;
22049 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
22050 index 4929502..686c291 100644
22051 --- a/arch/x86/kernel/msr.c
22052 +++ b/arch/x86/kernel/msr.c
22053 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
22054 return notifier_from_errno(err);
22055 }
22056
22057 -static struct notifier_block __refdata msr_class_cpu_notifier = {
22058 +static struct notifier_block msr_class_cpu_notifier = {
22059 .notifier_call = msr_class_cpu_callback,
22060 };
22061
22062 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
22063 index f84f5c5..f404e81 100644
22064 --- a/arch/x86/kernel/nmi.c
22065 +++ b/arch/x86/kernel/nmi.c
22066 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
22067 return handled;
22068 }
22069
22070 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22071 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
22072 {
22073 struct nmi_desc *desc = nmi_to_desc(type);
22074 unsigned long flags;
22075 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22076 * event confuses some handlers (kdump uses this flag)
22077 */
22078 if (action->flags & NMI_FLAG_FIRST)
22079 - list_add_rcu(&action->list, &desc->head);
22080 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
22081 else
22082 - list_add_tail_rcu(&action->list, &desc->head);
22083 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
22084
22085 spin_unlock_irqrestore(&desc->lock, flags);
22086 return 0;
22087 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
22088 if (!strcmp(n->name, name)) {
22089 WARN(in_nmi(),
22090 "Trying to free NMI (%s) from NMI context!\n", n->name);
22091 - list_del_rcu(&n->list);
22092 + pax_list_del_rcu((struct list_head *)&n->list);
22093 break;
22094 }
22095 }
22096 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
22097 dotraplinkage notrace __kprobes void
22098 do_nmi(struct pt_regs *regs, long error_code)
22099 {
22100 +
22101 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
22102 + if (!user_mode(regs)) {
22103 + unsigned long cs = regs->cs & 0xFFFF;
22104 + unsigned long ip = ktva_ktla(regs->ip);
22105 +
22106 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
22107 + regs->ip = ip;
22108 + }
22109 +#endif
22110 +
22111 nmi_nesting_preprocess(regs);
22112
22113 nmi_enter();
22114 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
22115 index 6d9582e..f746287 100644
22116 --- a/arch/x86/kernel/nmi_selftest.c
22117 +++ b/arch/x86/kernel/nmi_selftest.c
22118 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
22119 {
22120 /* trap all the unknown NMIs we may generate */
22121 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
22122 - __initdata);
22123 + __initconst);
22124 }
22125
22126 static void __init cleanup_nmi_testsuite(void)
22127 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
22128 unsigned long timeout;
22129
22130 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
22131 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
22132 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
22133 nmi_fail = FAILURE;
22134 return;
22135 }
22136 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
22137 index 676b8c7..870ba04 100644
22138 --- a/arch/x86/kernel/paravirt-spinlocks.c
22139 +++ b/arch/x86/kernel/paravirt-spinlocks.c
22140 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
22141 arch_spin_lock(lock);
22142 }
22143
22144 -struct pv_lock_ops pv_lock_ops = {
22145 +struct pv_lock_ops pv_lock_ops __read_only = {
22146 #ifdef CONFIG_SMP
22147 .spin_is_locked = __ticket_spin_is_locked,
22148 .spin_is_contended = __ticket_spin_is_contended,
22149 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
22150 index 8bfb335..c1463c6 100644
22151 --- a/arch/x86/kernel/paravirt.c
22152 +++ b/arch/x86/kernel/paravirt.c
22153 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
22154 {
22155 return x;
22156 }
22157 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22158 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
22159 +#endif
22160
22161 void __init default_banner(void)
22162 {
22163 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
22164 if (opfunc == NULL)
22165 /* If there's no function, patch it with a ud2a (BUG) */
22166 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
22167 - else if (opfunc == _paravirt_nop)
22168 + else if (opfunc == (void *)_paravirt_nop)
22169 /* If the operation is a nop, then nop the callsite */
22170 ret = paravirt_patch_nop();
22171
22172 /* identity functions just return their single argument */
22173 - else if (opfunc == _paravirt_ident_32)
22174 + else if (opfunc == (void *)_paravirt_ident_32)
22175 ret = paravirt_patch_ident_32(insnbuf, len);
22176 - else if (opfunc == _paravirt_ident_64)
22177 + else if (opfunc == (void *)_paravirt_ident_64)
22178 ret = paravirt_patch_ident_64(insnbuf, len);
22179 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22180 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
22181 + ret = paravirt_patch_ident_64(insnbuf, len);
22182 +#endif
22183
22184 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
22185 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
22186 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
22187 if (insn_len > len || start == NULL)
22188 insn_len = len;
22189 else
22190 - memcpy(insnbuf, start, insn_len);
22191 + memcpy(insnbuf, ktla_ktva(start), insn_len);
22192
22193 return insn_len;
22194 }
22195 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
22196 return this_cpu_read(paravirt_lazy_mode);
22197 }
22198
22199 -struct pv_info pv_info = {
22200 +struct pv_info pv_info __read_only = {
22201 .name = "bare hardware",
22202 .paravirt_enabled = 0,
22203 .kernel_rpl = 0,
22204 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
22205 #endif
22206 };
22207
22208 -struct pv_init_ops pv_init_ops = {
22209 +struct pv_init_ops pv_init_ops __read_only = {
22210 .patch = native_patch,
22211 };
22212
22213 -struct pv_time_ops pv_time_ops = {
22214 +struct pv_time_ops pv_time_ops __read_only = {
22215 .sched_clock = native_sched_clock,
22216 .steal_clock = native_steal_clock,
22217 };
22218
22219 -struct pv_irq_ops pv_irq_ops = {
22220 +struct pv_irq_ops pv_irq_ops __read_only = {
22221 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
22222 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
22223 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
22224 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
22225 #endif
22226 };
22227
22228 -struct pv_cpu_ops pv_cpu_ops = {
22229 +struct pv_cpu_ops pv_cpu_ops __read_only = {
22230 .cpuid = native_cpuid,
22231 .get_debugreg = native_get_debugreg,
22232 .set_debugreg = native_set_debugreg,
22233 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
22234 .end_context_switch = paravirt_nop,
22235 };
22236
22237 -struct pv_apic_ops pv_apic_ops = {
22238 +struct pv_apic_ops pv_apic_ops __read_only= {
22239 #ifdef CONFIG_X86_LOCAL_APIC
22240 .startup_ipi_hook = paravirt_nop,
22241 #endif
22242 };
22243
22244 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
22245 +#ifdef CONFIG_X86_32
22246 +#ifdef CONFIG_X86_PAE
22247 +/* 64-bit pagetable entries */
22248 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
22249 +#else
22250 /* 32-bit pagetable entries */
22251 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
22252 +#endif
22253 #else
22254 /* 64-bit pagetable entries */
22255 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22256 #endif
22257
22258 -struct pv_mmu_ops pv_mmu_ops = {
22259 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22260
22261 .read_cr2 = native_read_cr2,
22262 .write_cr2 = native_write_cr2,
22263 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22264 .make_pud = PTE_IDENT,
22265
22266 .set_pgd = native_set_pgd,
22267 + .set_pgd_batched = native_set_pgd_batched,
22268 #endif
22269 #endif /* PAGETABLE_LEVELS >= 3 */
22270
22271 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22272 },
22273
22274 .set_fixmap = native_set_fixmap,
22275 +
22276 +#ifdef CONFIG_PAX_KERNEXEC
22277 + .pax_open_kernel = native_pax_open_kernel,
22278 + .pax_close_kernel = native_pax_close_kernel,
22279 +#endif
22280 +
22281 };
22282
22283 EXPORT_SYMBOL_GPL(pv_time_ops);
22284 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
22285 index 299d493..2ccb0ee 100644
22286 --- a/arch/x86/kernel/pci-calgary_64.c
22287 +++ b/arch/x86/kernel/pci-calgary_64.c
22288 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
22289 tce_space = be64_to_cpu(readq(target));
22290 tce_space = tce_space & TAR_SW_BITS;
22291
22292 - tce_space = tce_space & (~specified_table_size);
22293 + tce_space = tce_space & (~(unsigned long)specified_table_size);
22294 info->tce_space = (u64 *)__va(tce_space);
22295 }
22296 }
22297 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22298 index 35ccf75..7a15747 100644
22299 --- a/arch/x86/kernel/pci-iommu_table.c
22300 +++ b/arch/x86/kernel/pci-iommu_table.c
22301 @@ -2,7 +2,7 @@
22302 #include <asm/iommu_table.h>
22303 #include <linux/string.h>
22304 #include <linux/kallsyms.h>
22305 -
22306 +#include <linux/sched.h>
22307
22308 #define DEBUG 1
22309
22310 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22311 index 6c483ba..d10ce2f 100644
22312 --- a/arch/x86/kernel/pci-swiotlb.c
22313 +++ b/arch/x86/kernel/pci-swiotlb.c
22314 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22315 void *vaddr, dma_addr_t dma_addr,
22316 struct dma_attrs *attrs)
22317 {
22318 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22319 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22320 }
22321
22322 static struct dma_map_ops swiotlb_dma_ops = {
22323 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22324 index 2ed787f..f70c9f6 100644
22325 --- a/arch/x86/kernel/process.c
22326 +++ b/arch/x86/kernel/process.c
22327 @@ -36,7 +36,8 @@
22328 * section. Since TSS's are completely CPU-local, we want them
22329 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22330 */
22331 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22332 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22333 +EXPORT_SYMBOL(init_tss);
22334
22335 #ifdef CONFIG_X86_64
22336 static DEFINE_PER_CPU(unsigned char, is_idle);
22337 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22338 task_xstate_cachep =
22339 kmem_cache_create("task_xstate", xstate_size,
22340 __alignof__(union thread_xstate),
22341 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22342 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22343 }
22344
22345 /*
22346 @@ -105,7 +106,7 @@ void exit_thread(void)
22347 unsigned long *bp = t->io_bitmap_ptr;
22348
22349 if (bp) {
22350 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22351 + struct tss_struct *tss = init_tss + get_cpu();
22352
22353 t->io_bitmap_ptr = NULL;
22354 clear_thread_flag(TIF_IO_BITMAP);
22355 @@ -136,7 +137,7 @@ void show_regs_common(void)
22356 board = dmi_get_system_info(DMI_BOARD_NAME);
22357
22358 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22359 - current->pid, current->comm, print_tainted(),
22360 + task_pid_nr(current), current->comm, print_tainted(),
22361 init_utsname()->release,
22362 (int)strcspn(init_utsname()->version, " "),
22363 init_utsname()->version,
22364 @@ -149,6 +150,9 @@ void flush_thread(void)
22365 {
22366 struct task_struct *tsk = current;
22367
22368 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22369 + loadsegment(gs, 0);
22370 +#endif
22371 flush_ptrace_hw_breakpoint(tsk);
22372 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22373 drop_init_fpu(tsk);
22374 @@ -301,7 +305,7 @@ static void __exit_idle(void)
22375 void exit_idle(void)
22376 {
22377 /* idle loop has pid 0 */
22378 - if (current->pid)
22379 + if (task_pid_nr(current))
22380 return;
22381 __exit_idle();
22382 }
22383 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
22384
22385 return ret;
22386 }
22387 -void stop_this_cpu(void *dummy)
22388 +__noreturn void stop_this_cpu(void *dummy)
22389 {
22390 local_irq_disable();
22391 /*
22392 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
22393 }
22394 early_param("idle", idle_setup);
22395
22396 -unsigned long arch_align_stack(unsigned long sp)
22397 +#ifdef CONFIG_PAX_RANDKSTACK
22398 +void pax_randomize_kstack(struct pt_regs *regs)
22399 {
22400 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22401 - sp -= get_random_int() % 8192;
22402 - return sp & ~0xf;
22403 -}
22404 + struct thread_struct *thread = &current->thread;
22405 + unsigned long time;
22406
22407 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22408 -{
22409 - unsigned long range_end = mm->brk + 0x02000000;
22410 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22411 -}
22412 + if (!randomize_va_space)
22413 + return;
22414 +
22415 + if (v8086_mode(regs))
22416 + return;
22417
22418 + rdtscl(time);
22419 +
22420 + /* P4 seems to return a 0 LSB, ignore it */
22421 +#ifdef CONFIG_MPENTIUM4
22422 + time &= 0x3EUL;
22423 + time <<= 2;
22424 +#elif defined(CONFIG_X86_64)
22425 + time &= 0xFUL;
22426 + time <<= 4;
22427 +#else
22428 + time &= 0x1FUL;
22429 + time <<= 3;
22430 +#endif
22431 +
22432 + thread->sp0 ^= time;
22433 + load_sp0(init_tss + smp_processor_id(), thread);
22434 +
22435 +#ifdef CONFIG_X86_64
22436 + this_cpu_write(kernel_stack, thread->sp0);
22437 +#endif
22438 +}
22439 +#endif
22440 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22441 index b5a8905..d9cacac 100644
22442 --- a/arch/x86/kernel/process_32.c
22443 +++ b/arch/x86/kernel/process_32.c
22444 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22445 unsigned long thread_saved_pc(struct task_struct *tsk)
22446 {
22447 return ((unsigned long *)tsk->thread.sp)[3];
22448 +//XXX return tsk->thread.eip;
22449 }
22450
22451 void __show_regs(struct pt_regs *regs, int all)
22452 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22453 unsigned long sp;
22454 unsigned short ss, gs;
22455
22456 - if (user_mode_vm(regs)) {
22457 + if (user_mode(regs)) {
22458 sp = regs->sp;
22459 ss = regs->ss & 0xffff;
22460 - gs = get_user_gs(regs);
22461 } else {
22462 sp = kernel_stack_pointer(regs);
22463 savesegment(ss, ss);
22464 - savesegment(gs, gs);
22465 }
22466 + gs = get_user_gs(regs);
22467
22468 show_regs_common();
22469
22470 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22471 (u16)regs->cs, regs->ip, regs->flags,
22472 - smp_processor_id());
22473 + raw_smp_processor_id());
22474 print_symbol("EIP is at %s\n", regs->ip);
22475
22476 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22477 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22478 int copy_thread(unsigned long clone_flags, unsigned long sp,
22479 unsigned long arg, struct task_struct *p)
22480 {
22481 - struct pt_regs *childregs = task_pt_regs(p);
22482 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22483 struct task_struct *tsk;
22484 int err;
22485
22486 p->thread.sp = (unsigned long) childregs;
22487 p->thread.sp0 = (unsigned long) (childregs+1);
22488 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22489
22490 if (unlikely(p->flags & PF_KTHREAD)) {
22491 /* kernel thread */
22492 memset(childregs, 0, sizeof(struct pt_regs));
22493 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22494 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22495 - childregs->ds = __USER_DS;
22496 - childregs->es = __USER_DS;
22497 + savesegment(gs, childregs->gs);
22498 + childregs->ds = __KERNEL_DS;
22499 + childregs->es = __KERNEL_DS;
22500 childregs->fs = __KERNEL_PERCPU;
22501 childregs->bx = sp; /* function */
22502 childregs->bp = arg;
22503 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22504 struct thread_struct *prev = &prev_p->thread,
22505 *next = &next_p->thread;
22506 int cpu = smp_processor_id();
22507 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22508 + struct tss_struct *tss = init_tss + cpu;
22509 fpu_switch_t fpu;
22510
22511 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22512 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22513 */
22514 lazy_save_gs(prev->gs);
22515
22516 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22517 + __set_fs(task_thread_info(next_p)->addr_limit);
22518 +#endif
22519 +
22520 /*
22521 * Load the per-thread Thread-Local Storage descriptor.
22522 */
22523 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22524 */
22525 arch_end_context_switch(next_p);
22526
22527 + this_cpu_write(current_task, next_p);
22528 + this_cpu_write(current_tinfo, &next_p->tinfo);
22529 +
22530 /*
22531 * Restore %gs if needed (which is common)
22532 */
22533 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22534
22535 switch_fpu_finish(next_p, fpu);
22536
22537 - this_cpu_write(current_task, next_p);
22538 -
22539 return prev_p;
22540 }
22541
22542 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22543 } while (count++ < 16);
22544 return 0;
22545 }
22546 -
22547 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22548 index 6e68a61..955a9a5 100644
22549 --- a/arch/x86/kernel/process_64.c
22550 +++ b/arch/x86/kernel/process_64.c
22551 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22552 struct pt_regs *childregs;
22553 struct task_struct *me = current;
22554
22555 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22556 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22557 childregs = task_pt_regs(p);
22558 p->thread.sp = (unsigned long) childregs;
22559 p->thread.usersp = me->thread.usersp;
22560 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22561 set_tsk_thread_flag(p, TIF_FORK);
22562 p->fpu_counter = 0;
22563 p->thread.io_bitmap_ptr = NULL;
22564 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22565 struct thread_struct *prev = &prev_p->thread;
22566 struct thread_struct *next = &next_p->thread;
22567 int cpu = smp_processor_id();
22568 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22569 + struct tss_struct *tss = init_tss + cpu;
22570 unsigned fsindex, gsindex;
22571 fpu_switch_t fpu;
22572
22573 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22574 prev->usersp = this_cpu_read(old_rsp);
22575 this_cpu_write(old_rsp, next->usersp);
22576 this_cpu_write(current_task, next_p);
22577 + this_cpu_write(current_tinfo, &next_p->tinfo);
22578
22579 - this_cpu_write(kernel_stack,
22580 - (unsigned long)task_stack_page(next_p) +
22581 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22582 + this_cpu_write(kernel_stack, next->sp0);
22583
22584 /*
22585 * Now maybe reload the debug registers and handle I/O bitmaps
22586 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22587 if (!p || p == current || p->state == TASK_RUNNING)
22588 return 0;
22589 stack = (unsigned long)task_stack_page(p);
22590 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22591 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22592 return 0;
22593 fp = *(u64 *)(p->thread.sp);
22594 do {
22595 - if (fp < (unsigned long)stack ||
22596 - fp >= (unsigned long)stack+THREAD_SIZE)
22597 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22598 return 0;
22599 ip = *(u64 *)(fp+8);
22600 if (!in_sched_functions(ip))
22601 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22602 index b629bbe..0fa615a 100644
22603 --- a/arch/x86/kernel/ptrace.c
22604 +++ b/arch/x86/kernel/ptrace.c
22605 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22606 {
22607 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22608 unsigned long sp = (unsigned long)&regs->sp;
22609 - struct thread_info *tinfo;
22610
22611 - if (context == (sp & ~(THREAD_SIZE - 1)))
22612 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22613 return sp;
22614
22615 - tinfo = (struct thread_info *)context;
22616 - if (tinfo->previous_esp)
22617 - return tinfo->previous_esp;
22618 + sp = *(unsigned long *)context;
22619 + if (sp)
22620 + return sp;
22621
22622 return (unsigned long)regs;
22623 }
22624 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22625 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22626 {
22627 int i;
22628 - int dr7 = 0;
22629 + unsigned long dr7 = 0;
22630 struct arch_hw_breakpoint *info;
22631
22632 for (i = 0; i < HBP_NUM; i++) {
22633 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22634 unsigned long addr, unsigned long data)
22635 {
22636 int ret;
22637 - unsigned long __user *datap = (unsigned long __user *)data;
22638 + unsigned long __user *datap = (__force unsigned long __user *)data;
22639
22640 switch (request) {
22641 /* read the word at location addr in the USER area. */
22642 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22643 if ((int) addr < 0)
22644 return -EIO;
22645 ret = do_get_thread_area(child, addr,
22646 - (struct user_desc __user *)data);
22647 + (__force struct user_desc __user *) data);
22648 break;
22649
22650 case PTRACE_SET_THREAD_AREA:
22651 if ((int) addr < 0)
22652 return -EIO;
22653 ret = do_set_thread_area(child, addr,
22654 - (struct user_desc __user *)data, 0);
22655 + (__force struct user_desc __user *) data, 0);
22656 break;
22657 #endif
22658
22659 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22660
22661 #ifdef CONFIG_X86_64
22662
22663 -static struct user_regset x86_64_regsets[] __read_mostly = {
22664 +static user_regset_no_const x86_64_regsets[] __read_only = {
22665 [REGSET_GENERAL] = {
22666 .core_note_type = NT_PRSTATUS,
22667 .n = sizeof(struct user_regs_struct) / sizeof(long),
22668 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22669 #endif /* CONFIG_X86_64 */
22670
22671 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22672 -static struct user_regset x86_32_regsets[] __read_mostly = {
22673 +static user_regset_no_const x86_32_regsets[] __read_only = {
22674 [REGSET_GENERAL] = {
22675 .core_note_type = NT_PRSTATUS,
22676 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22677 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22678 */
22679 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22680
22681 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22682 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22683 {
22684 #ifdef CONFIG_X86_64
22685 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22686 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22687 memset(info, 0, sizeof(*info));
22688 info->si_signo = SIGTRAP;
22689 info->si_code = si_code;
22690 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22691 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22692 }
22693
22694 void user_single_step_siginfo(struct task_struct *tsk,
22695 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22696 # define IS_IA32 0
22697 #endif
22698
22699 +#ifdef CONFIG_GRKERNSEC_SETXID
22700 +extern void gr_delayed_cred_worker(void);
22701 +#endif
22702 +
22703 /*
22704 * We must return the syscall number to actually look up in the table.
22705 * This can be -1L to skip running any syscall at all.
22706 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22707
22708 user_exit();
22709
22710 +#ifdef CONFIG_GRKERNSEC_SETXID
22711 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22712 + gr_delayed_cred_worker();
22713 +#endif
22714 +
22715 /*
22716 * If we stepped into a sysenter/syscall insn, it trapped in
22717 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22718 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22719 */
22720 user_exit();
22721
22722 +#ifdef CONFIG_GRKERNSEC_SETXID
22723 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22724 + gr_delayed_cred_worker();
22725 +#endif
22726 +
22727 audit_syscall_exit(regs);
22728
22729 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22730 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22731 index 2cb9470..ff1fd80 100644
22732 --- a/arch/x86/kernel/pvclock.c
22733 +++ b/arch/x86/kernel/pvclock.c
22734 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22735 return pv_tsc_khz;
22736 }
22737
22738 -static atomic64_t last_value = ATOMIC64_INIT(0);
22739 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22740
22741 void pvclock_resume(void)
22742 {
22743 - atomic64_set(&last_value, 0);
22744 + atomic64_set_unchecked(&last_value, 0);
22745 }
22746
22747 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22748 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22749 * updating at the same time, and one of them could be slightly behind,
22750 * making the assumption that last_value always go forward fail to hold.
22751 */
22752 - last = atomic64_read(&last_value);
22753 + last = atomic64_read_unchecked(&last_value);
22754 do {
22755 if (ret < last)
22756 return last;
22757 - last = atomic64_cmpxchg(&last_value, last, ret);
22758 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22759 } while (unlikely(last != ret));
22760
22761 return ret;
22762 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22763 index 76fa1e9..abf09ea 100644
22764 --- a/arch/x86/kernel/reboot.c
22765 +++ b/arch/x86/kernel/reboot.c
22766 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22767 EXPORT_SYMBOL(pm_power_off);
22768
22769 static const struct desc_ptr no_idt = {};
22770 -static int reboot_mode;
22771 +static unsigned short reboot_mode;
22772 enum reboot_type reboot_type = BOOT_ACPI;
22773 int reboot_force;
22774
22775 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22776
22777 void __noreturn machine_real_restart(unsigned int type)
22778 {
22779 +
22780 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22781 + struct desc_struct *gdt;
22782 +#endif
22783 +
22784 local_irq_disable();
22785
22786 /*
22787 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22788
22789 /* Jump to the identity-mapped low memory code */
22790 #ifdef CONFIG_X86_32
22791 - asm volatile("jmpl *%0" : :
22792 +
22793 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22794 + gdt = get_cpu_gdt_table(smp_processor_id());
22795 + pax_open_kernel();
22796 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22797 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22798 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22799 + loadsegment(ds, __KERNEL_DS);
22800 + loadsegment(es, __KERNEL_DS);
22801 + loadsegment(ss, __KERNEL_DS);
22802 +#endif
22803 +#ifdef CONFIG_PAX_KERNEXEC
22804 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22805 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22806 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22807 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22808 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22809 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22810 +#endif
22811 + pax_close_kernel();
22812 +#endif
22813 +
22814 + asm volatile("ljmpl *%0" : :
22815 "rm" (real_mode_header->machine_real_restart_asm),
22816 "a" (type));
22817 #else
22818 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22819 * try to force a triple fault and then cycle between hitting the keyboard
22820 * controller and doing that
22821 */
22822 -static void native_machine_emergency_restart(void)
22823 +static void __noreturn native_machine_emergency_restart(void)
22824 {
22825 int i;
22826 int attempt = 0;
22827 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22828 #endif
22829 }
22830
22831 -static void __machine_emergency_restart(int emergency)
22832 +static void __noreturn __machine_emergency_restart(int emergency)
22833 {
22834 reboot_emergency = emergency;
22835 machine_ops.emergency_restart();
22836 }
22837
22838 -static void native_machine_restart(char *__unused)
22839 +static void __noreturn native_machine_restart(char *__unused)
22840 {
22841 pr_notice("machine restart\n");
22842
22843 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22844 __machine_emergency_restart(0);
22845 }
22846
22847 -static void native_machine_halt(void)
22848 +static void __noreturn native_machine_halt(void)
22849 {
22850 /* Stop other cpus and apics */
22851 machine_shutdown();
22852 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22853 stop_this_cpu(NULL);
22854 }
22855
22856 -static void native_machine_power_off(void)
22857 +static void __noreturn native_machine_power_off(void)
22858 {
22859 if (pm_power_off) {
22860 if (!reboot_force)
22861 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22862 }
22863 /* A fallback in case there is no PM info available */
22864 tboot_shutdown(TB_SHUTDOWN_HALT);
22865 + unreachable();
22866 }
22867
22868 -struct machine_ops machine_ops = {
22869 +struct machine_ops machine_ops __read_only = {
22870 .power_off = native_machine_power_off,
22871 .shutdown = native_machine_shutdown,
22872 .emergency_restart = native_machine_emergency_restart,
22873 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22874 index 7a6f3b3..bed145d7 100644
22875 --- a/arch/x86/kernel/relocate_kernel_64.S
22876 +++ b/arch/x86/kernel/relocate_kernel_64.S
22877 @@ -11,6 +11,7 @@
22878 #include <asm/kexec.h>
22879 #include <asm/processor-flags.h>
22880 #include <asm/pgtable_types.h>
22881 +#include <asm/alternative-asm.h>
22882
22883 /*
22884 * Must be relocatable PIC code callable as a C function
22885 @@ -160,13 +161,14 @@ identity_mapped:
22886 xorq %rbp, %rbp
22887 xorq %r8, %r8
22888 xorq %r9, %r9
22889 - xorq %r10, %r9
22890 + xorq %r10, %r10
22891 xorq %r11, %r11
22892 xorq %r12, %r12
22893 xorq %r13, %r13
22894 xorq %r14, %r14
22895 xorq %r15, %r15
22896
22897 + pax_force_retaddr 0, 1
22898 ret
22899
22900 1:
22901 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22902 index 8b24289..d37b58b 100644
22903 --- a/arch/x86/kernel/setup.c
22904 +++ b/arch/x86/kernel/setup.c
22905 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22906
22907 switch (data->type) {
22908 case SETUP_E820_EXT:
22909 - parse_e820_ext(data);
22910 + parse_e820_ext((struct setup_data __force_kernel *)data);
22911 break;
22912 case SETUP_DTB:
22913 add_dtb(pa_data);
22914 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22915 * area (640->1Mb) as ram even though it is not.
22916 * take them out.
22917 */
22918 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22919 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22920
22921 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22922 }
22923 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22924
22925 if (!boot_params.hdr.root_flags)
22926 root_mountflags &= ~MS_RDONLY;
22927 - init_mm.start_code = (unsigned long) _text;
22928 - init_mm.end_code = (unsigned long) _etext;
22929 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22930 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22931 init_mm.end_data = (unsigned long) _edata;
22932 init_mm.brk = _brk_end;
22933
22934 - code_resource.start = virt_to_phys(_text);
22935 - code_resource.end = virt_to_phys(_etext)-1;
22936 - data_resource.start = virt_to_phys(_etext);
22937 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22938 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22939 + data_resource.start = virt_to_phys(_sdata);
22940 data_resource.end = virt_to_phys(_edata)-1;
22941 bss_resource.start = virt_to_phys(&__bss_start);
22942 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22943 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22944 index 5cdff03..80fa283 100644
22945 --- a/arch/x86/kernel/setup_percpu.c
22946 +++ b/arch/x86/kernel/setup_percpu.c
22947 @@ -21,19 +21,17 @@
22948 #include <asm/cpu.h>
22949 #include <asm/stackprotector.h>
22950
22951 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22952 +#ifdef CONFIG_SMP
22953 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22954 EXPORT_PER_CPU_SYMBOL(cpu_number);
22955 +#endif
22956
22957 -#ifdef CONFIG_X86_64
22958 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22959 -#else
22960 -#define BOOT_PERCPU_OFFSET 0
22961 -#endif
22962
22963 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22964 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22965
22966 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22967 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22968 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22969 };
22970 EXPORT_SYMBOL(__per_cpu_offset);
22971 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22972 {
22973 #ifdef CONFIG_NEED_MULTIPLE_NODES
22974 pg_data_t *last = NULL;
22975 - unsigned int cpu;
22976 + int cpu;
22977
22978 for_each_possible_cpu(cpu) {
22979 int node = early_cpu_to_node(cpu);
22980 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22981 {
22982 #ifdef CONFIG_X86_32
22983 struct desc_struct gdt;
22984 + unsigned long base = per_cpu_offset(cpu);
22985
22986 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22987 - 0x2 | DESCTYPE_S, 0x8);
22988 - gdt.s = 1;
22989 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22990 + 0x83 | DESCTYPE_S, 0xC);
22991 write_gdt_entry(get_cpu_gdt_table(cpu),
22992 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22993 #endif
22994 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22995 /* alrighty, percpu areas up and running */
22996 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22997 for_each_possible_cpu(cpu) {
22998 +#ifdef CONFIG_CC_STACKPROTECTOR
22999 +#ifdef CONFIG_X86_32
23000 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
23001 +#endif
23002 +#endif
23003 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
23004 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
23005 per_cpu(cpu_number, cpu) = cpu;
23006 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
23007 */
23008 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
23009 #endif
23010 +#ifdef CONFIG_CC_STACKPROTECTOR
23011 +#ifdef CONFIG_X86_32
23012 + if (!cpu)
23013 + per_cpu(stack_canary.canary, cpu) = canary;
23014 +#endif
23015 +#endif
23016 /*
23017 * Up to this point, the boot CPU has been using .init.data
23018 * area. Reload any changed state for the boot CPU.
23019 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
23020 index d6bf1f3..3ffce5a 100644
23021 --- a/arch/x86/kernel/signal.c
23022 +++ b/arch/x86/kernel/signal.c
23023 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
23024 * Align the stack pointer according to the i386 ABI,
23025 * i.e. so that on function entry ((sp + 4) & 15) == 0.
23026 */
23027 - sp = ((sp + 4) & -16ul) - 4;
23028 + sp = ((sp - 12) & -16ul) - 4;
23029 #else /* !CONFIG_X86_32 */
23030 sp = round_down(sp, 16) - 8;
23031 #endif
23032 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
23033 }
23034
23035 if (current->mm->context.vdso)
23036 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
23037 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
23038 else
23039 - restorer = &frame->retcode;
23040 + restorer = (void __user *)&frame->retcode;
23041 if (ka->sa.sa_flags & SA_RESTORER)
23042 restorer = ka->sa.sa_restorer;
23043
23044 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
23045 * reasons and because gdb uses it as a signature to notice
23046 * signal handler stack frames.
23047 */
23048 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
23049 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
23050
23051 if (err)
23052 return -EFAULT;
23053 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
23054 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
23055
23056 /* Set up to return from userspace. */
23057 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
23058 + if (current->mm->context.vdso)
23059 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
23060 + else
23061 + restorer = (void __user *)&frame->retcode;
23062 if (ka->sa.sa_flags & SA_RESTORER)
23063 restorer = ka->sa.sa_restorer;
23064 put_user_ex(restorer, &frame->pretcode);
23065 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
23066 * reasons and because gdb uses it as a signature to notice
23067 * signal handler stack frames.
23068 */
23069 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
23070 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
23071 } put_user_catch(err);
23072
23073 err |= copy_siginfo_to_user(&frame->info, info);
23074 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
23075 index 48d2b7d..90d328a 100644
23076 --- a/arch/x86/kernel/smp.c
23077 +++ b/arch/x86/kernel/smp.c
23078 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
23079
23080 __setup("nonmi_ipi", nonmi_ipi_setup);
23081
23082 -struct smp_ops smp_ops = {
23083 +struct smp_ops smp_ops __read_only = {
23084 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
23085 .smp_prepare_cpus = native_smp_prepare_cpus,
23086 .smp_cpus_done = native_smp_cpus_done,
23087 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
23088 index ed0fe38..87fc692 100644
23089 --- a/arch/x86/kernel/smpboot.c
23090 +++ b/arch/x86/kernel/smpboot.c
23091 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23092 idle->thread.sp = (unsigned long) (((struct pt_regs *)
23093 (THREAD_SIZE + task_stack_page(idle))) - 1);
23094 per_cpu(current_task, cpu) = idle;
23095 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
23096
23097 #ifdef CONFIG_X86_32
23098 /* Stack for startup_32 can be just as for start_secondary onwards */
23099 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23100 #else
23101 clear_tsk_thread_flag(idle, TIF_FORK);
23102 initial_gs = per_cpu_offset(cpu);
23103 - per_cpu(kernel_stack, cpu) =
23104 - (unsigned long)task_stack_page(idle) -
23105 - KERNEL_STACK_OFFSET + THREAD_SIZE;
23106 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
23107 #endif
23108 +
23109 + pax_open_kernel();
23110 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23111 + pax_close_kernel();
23112 +
23113 initial_code = (unsigned long)start_secondary;
23114 stack_start = idle->thread.sp;
23115
23116 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
23117 /* the FPU context is blank, nobody can own it */
23118 __cpu_disable_lazy_restore(cpu);
23119
23120 +#ifdef CONFIG_PAX_PER_CPU_PGD
23121 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
23122 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
23123 + KERNEL_PGD_PTRS);
23124 +#endif
23125 +
23126 + /* the FPU context is blank, nobody can own it */
23127 + __cpu_disable_lazy_restore(cpu);
23128 +
23129 err = do_boot_cpu(apicid, cpu, tidle);
23130 if (err) {
23131 pr_debug("do_boot_cpu failed %d\n", err);
23132 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
23133 index 9b4d51d..5d28b58 100644
23134 --- a/arch/x86/kernel/step.c
23135 +++ b/arch/x86/kernel/step.c
23136 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23137 struct desc_struct *desc;
23138 unsigned long base;
23139
23140 - seg &= ~7UL;
23141 + seg >>= 3;
23142
23143 mutex_lock(&child->mm->context.lock);
23144 - if (unlikely((seg >> 3) >= child->mm->context.size))
23145 + if (unlikely(seg >= child->mm->context.size))
23146 addr = -1L; /* bogus selector, access would fault */
23147 else {
23148 desc = child->mm->context.ldt + seg;
23149 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23150 addr += base;
23151 }
23152 mutex_unlock(&child->mm->context.lock);
23153 - }
23154 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
23155 + addr = ktla_ktva(addr);
23156
23157 return addr;
23158 }
23159 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
23160 unsigned char opcode[15];
23161 unsigned long addr = convert_ip_to_linear(child, regs);
23162
23163 + if (addr == -EINVAL)
23164 + return 0;
23165 +
23166 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
23167 for (i = 0; i < copied; i++) {
23168 switch (opcode[i]) {
23169 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
23170 new file mode 100644
23171 index 0000000..207bec6
23172 --- /dev/null
23173 +++ b/arch/x86/kernel/sys_i386_32.c
23174 @@ -0,0 +1,250 @@
23175 +/*
23176 + * This file contains various random system calls that
23177 + * have a non-standard calling sequence on the Linux/i386
23178 + * platform.
23179 + */
23180 +
23181 +#include <linux/errno.h>
23182 +#include <linux/sched.h>
23183 +#include <linux/mm.h>
23184 +#include <linux/fs.h>
23185 +#include <linux/smp.h>
23186 +#include <linux/sem.h>
23187 +#include <linux/msg.h>
23188 +#include <linux/shm.h>
23189 +#include <linux/stat.h>
23190 +#include <linux/syscalls.h>
23191 +#include <linux/mman.h>
23192 +#include <linux/file.h>
23193 +#include <linux/utsname.h>
23194 +#include <linux/ipc.h>
23195 +
23196 +#include <linux/uaccess.h>
23197 +#include <linux/unistd.h>
23198 +
23199 +#include <asm/syscalls.h>
23200 +
23201 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
23202 +{
23203 + unsigned long pax_task_size = TASK_SIZE;
23204 +
23205 +#ifdef CONFIG_PAX_SEGMEXEC
23206 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
23207 + pax_task_size = SEGMEXEC_TASK_SIZE;
23208 +#endif
23209 +
23210 + if (flags & MAP_FIXED)
23211 + if (len > pax_task_size || addr > pax_task_size - len)
23212 + return -EINVAL;
23213 +
23214 + return 0;
23215 +}
23216 +
23217 +unsigned long
23218 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23219 + unsigned long len, unsigned long pgoff, unsigned long flags)
23220 +{
23221 + struct mm_struct *mm = current->mm;
23222 + struct vm_area_struct *vma;
23223 + unsigned long start_addr, pax_task_size = TASK_SIZE;
23224 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23225 +
23226 +#ifdef CONFIG_PAX_SEGMEXEC
23227 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23228 + pax_task_size = SEGMEXEC_TASK_SIZE;
23229 +#endif
23230 +
23231 + pax_task_size -= PAGE_SIZE;
23232 +
23233 + if (len > pax_task_size)
23234 + return -ENOMEM;
23235 +
23236 + if (flags & MAP_FIXED)
23237 + return addr;
23238 +
23239 +#ifdef CONFIG_PAX_RANDMMAP
23240 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23241 +#endif
23242 +
23243 + if (addr) {
23244 + addr = PAGE_ALIGN(addr);
23245 + if (pax_task_size - len >= addr) {
23246 + vma = find_vma(mm, addr);
23247 + if (check_heap_stack_gap(vma, addr, len, offset))
23248 + return addr;
23249 + }
23250 + }
23251 + if (len > mm->cached_hole_size) {
23252 + start_addr = addr = mm->free_area_cache;
23253 + } else {
23254 + start_addr = addr = mm->mmap_base;
23255 + mm->cached_hole_size = 0;
23256 + }
23257 +
23258 +#ifdef CONFIG_PAX_PAGEEXEC
23259 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
23260 + start_addr = 0x00110000UL;
23261 +
23262 +#ifdef CONFIG_PAX_RANDMMAP
23263 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23264 + start_addr += mm->delta_mmap & 0x03FFF000UL;
23265 +#endif
23266 +
23267 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
23268 + start_addr = addr = mm->mmap_base;
23269 + else
23270 + addr = start_addr;
23271 + }
23272 +#endif
23273 +
23274 +full_search:
23275 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
23276 + /* At this point: (!vma || addr < vma->vm_end). */
23277 + if (pax_task_size - len < addr) {
23278 + /*
23279 + * Start a new search - just in case we missed
23280 + * some holes.
23281 + */
23282 + if (start_addr != mm->mmap_base) {
23283 + start_addr = addr = mm->mmap_base;
23284 + mm->cached_hole_size = 0;
23285 + goto full_search;
23286 + }
23287 + return -ENOMEM;
23288 + }
23289 + if (check_heap_stack_gap(vma, addr, len, offset))
23290 + break;
23291 + if (addr + mm->cached_hole_size < vma->vm_start)
23292 + mm->cached_hole_size = vma->vm_start - addr;
23293 + addr = vma->vm_end;
23294 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
23295 + start_addr = addr = mm->mmap_base;
23296 + mm->cached_hole_size = 0;
23297 + goto full_search;
23298 + }
23299 + }
23300 +
23301 + /*
23302 + * Remember the place where we stopped the search:
23303 + */
23304 + mm->free_area_cache = addr + len;
23305 + return addr;
23306 +}
23307 +
23308 +unsigned long
23309 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23310 + const unsigned long len, const unsigned long pgoff,
23311 + const unsigned long flags)
23312 +{
23313 + struct vm_area_struct *vma;
23314 + struct mm_struct *mm = current->mm;
23315 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
23316 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23317 +
23318 +#ifdef CONFIG_PAX_SEGMEXEC
23319 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23320 + pax_task_size = SEGMEXEC_TASK_SIZE;
23321 +#endif
23322 +
23323 + pax_task_size -= PAGE_SIZE;
23324 +
23325 + /* requested length too big for entire address space */
23326 + if (len > pax_task_size)
23327 + return -ENOMEM;
23328 +
23329 + if (flags & MAP_FIXED)
23330 + return addr;
23331 +
23332 +#ifdef CONFIG_PAX_PAGEEXEC
23333 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23334 + goto bottomup;
23335 +#endif
23336 +
23337 +#ifdef CONFIG_PAX_RANDMMAP
23338 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23339 +#endif
23340 +
23341 + /* requesting a specific address */
23342 + if (addr) {
23343 + addr = PAGE_ALIGN(addr);
23344 + if (pax_task_size - len >= addr) {
23345 + vma = find_vma(mm, addr);
23346 + if (check_heap_stack_gap(vma, addr, len, offset))
23347 + return addr;
23348 + }
23349 + }
23350 +
23351 + /* check if free_area_cache is useful for us */
23352 + if (len <= mm->cached_hole_size) {
23353 + mm->cached_hole_size = 0;
23354 + mm->free_area_cache = mm->mmap_base;
23355 + }
23356 +
23357 + /* either no address requested or can't fit in requested address hole */
23358 + addr = mm->free_area_cache;
23359 +
23360 + /* make sure it can fit in the remaining address space */
23361 + if (addr > len) {
23362 + vma = find_vma(mm, addr-len);
23363 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23364 + /* remember the address as a hint for next time */
23365 + return (mm->free_area_cache = addr-len);
23366 + }
23367 +
23368 + if (mm->mmap_base < len)
23369 + goto bottomup;
23370 +
23371 + addr = mm->mmap_base-len;
23372 +
23373 + do {
23374 + /*
23375 + * Lookup failure means no vma is above this address,
23376 + * else if new region fits below vma->vm_start,
23377 + * return with success:
23378 + */
23379 + vma = find_vma(mm, addr);
23380 + if (check_heap_stack_gap(vma, addr, len, offset))
23381 + /* remember the address as a hint for next time */
23382 + return (mm->free_area_cache = addr);
23383 +
23384 + /* remember the largest hole we saw so far */
23385 + if (addr + mm->cached_hole_size < vma->vm_start)
23386 + mm->cached_hole_size = vma->vm_start - addr;
23387 +
23388 + /* try just below the current vma->vm_start */
23389 + addr = skip_heap_stack_gap(vma, len, offset);
23390 + } while (!IS_ERR_VALUE(addr));
23391 +
23392 +bottomup:
23393 + /*
23394 + * A failed mmap() very likely causes application failure,
23395 + * so fall back to the bottom-up function here. This scenario
23396 + * can happen with large stack limits and large mmap()
23397 + * allocations.
23398 + */
23399 +
23400 +#ifdef CONFIG_PAX_SEGMEXEC
23401 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23402 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23403 + else
23404 +#endif
23405 +
23406 + mm->mmap_base = TASK_UNMAPPED_BASE;
23407 +
23408 +#ifdef CONFIG_PAX_RANDMMAP
23409 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23410 + mm->mmap_base += mm->delta_mmap;
23411 +#endif
23412 +
23413 + mm->free_area_cache = mm->mmap_base;
23414 + mm->cached_hole_size = ~0UL;
23415 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23416 + /*
23417 + * Restore the topdown base:
23418 + */
23419 + mm->mmap_base = base;
23420 + mm->free_area_cache = base;
23421 + mm->cached_hole_size = ~0UL;
23422 +
23423 + return addr;
23424 +}
23425 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23426 index 97ef74b..57a1882 100644
23427 --- a/arch/x86/kernel/sys_x86_64.c
23428 +++ b/arch/x86/kernel/sys_x86_64.c
23429 @@ -81,8 +81,8 @@ out:
23430 return error;
23431 }
23432
23433 -static void find_start_end(unsigned long flags, unsigned long *begin,
23434 - unsigned long *end)
23435 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23436 + unsigned long *begin, unsigned long *end)
23437 {
23438 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23439 unsigned long new_begin;
23440 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23441 *begin = new_begin;
23442 }
23443 } else {
23444 - *begin = TASK_UNMAPPED_BASE;
23445 + *begin = mm->mmap_base;
23446 *end = TASK_SIZE;
23447 }
23448 }
23449 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23450 struct vm_area_struct *vma;
23451 struct vm_unmapped_area_info info;
23452 unsigned long begin, end;
23453 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23454
23455 if (flags & MAP_FIXED)
23456 return addr;
23457
23458 - find_start_end(flags, &begin, &end);
23459 + find_start_end(mm, flags, &begin, &end);
23460
23461 if (len > end)
23462 return -ENOMEM;
23463
23464 +#ifdef CONFIG_PAX_RANDMMAP
23465 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23466 +#endif
23467 +
23468 if (addr) {
23469 addr = PAGE_ALIGN(addr);
23470 vma = find_vma(mm, addr);
23471 - if (end - len >= addr &&
23472 - (!vma || addr + len <= vma->vm_start))
23473 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23474 return addr;
23475 }
23476
23477 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23478 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23479 goto bottomup;
23480
23481 +#ifdef CONFIG_PAX_RANDMMAP
23482 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23483 +#endif
23484 +
23485 /* requesting a specific address */
23486 if (addr) {
23487 addr = PAGE_ALIGN(addr);
23488 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23489 index f84fe00..f41d9f1 100644
23490 --- a/arch/x86/kernel/tboot.c
23491 +++ b/arch/x86/kernel/tboot.c
23492 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23493
23494 void tboot_shutdown(u32 shutdown_type)
23495 {
23496 - void (*shutdown)(void);
23497 + void (* __noreturn shutdown)(void);
23498
23499 if (!tboot_enabled())
23500 return;
23501 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23502
23503 switch_to_tboot_pt();
23504
23505 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23506 + shutdown = (void *)tboot->shutdown_entry;
23507 shutdown();
23508
23509 /* should not reach here */
23510 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23511 return 0;
23512 }
23513
23514 -static atomic_t ap_wfs_count;
23515 +static atomic_unchecked_t ap_wfs_count;
23516
23517 static int tboot_wait_for_aps(int num_aps)
23518 {
23519 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23520 {
23521 switch (action) {
23522 case CPU_DYING:
23523 - atomic_inc(&ap_wfs_count);
23524 + atomic_inc_unchecked(&ap_wfs_count);
23525 if (num_online_cpus() == 1)
23526 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23527 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23528 return NOTIFY_BAD;
23529 break;
23530 }
23531 return NOTIFY_OK;
23532 }
23533
23534 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23535 +static struct notifier_block tboot_cpu_notifier =
23536 {
23537 .notifier_call = tboot_cpu_callback,
23538 };
23539 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23540
23541 tboot_create_trampoline();
23542
23543 - atomic_set(&ap_wfs_count, 0);
23544 + atomic_set_unchecked(&ap_wfs_count, 0);
23545 register_hotcpu_notifier(&tboot_cpu_notifier);
23546
23547 acpi_os_set_prepare_sleep(&tboot_sleep);
23548 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23549 index 24d3c91..d06b473 100644
23550 --- a/arch/x86/kernel/time.c
23551 +++ b/arch/x86/kernel/time.c
23552 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23553 {
23554 unsigned long pc = instruction_pointer(regs);
23555
23556 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23557 + if (!user_mode(regs) && in_lock_functions(pc)) {
23558 #ifdef CONFIG_FRAME_POINTER
23559 - return *(unsigned long *)(regs->bp + sizeof(long));
23560 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23561 #else
23562 unsigned long *sp =
23563 (unsigned long *)kernel_stack_pointer(regs);
23564 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23565 * or above a saved flags. Eflags has bits 22-31 zero,
23566 * kernel addresses don't.
23567 */
23568 +
23569 +#ifdef CONFIG_PAX_KERNEXEC
23570 + return ktla_ktva(sp[0]);
23571 +#else
23572 if (sp[0] >> 22)
23573 return sp[0];
23574 if (sp[1] >> 22)
23575 return sp[1];
23576 #endif
23577 +
23578 +#endif
23579 }
23580 return pc;
23581 }
23582 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23583 index 9d9d2f9..cad418a 100644
23584 --- a/arch/x86/kernel/tls.c
23585 +++ b/arch/x86/kernel/tls.c
23586 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23587 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23588 return -EINVAL;
23589
23590 +#ifdef CONFIG_PAX_SEGMEXEC
23591 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23592 + return -EINVAL;
23593 +#endif
23594 +
23595 set_tls_desc(p, idx, &info, 1);
23596
23597 return 0;
23598 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23599
23600 if (kbuf)
23601 info = kbuf;
23602 - else if (__copy_from_user(infobuf, ubuf, count))
23603 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23604 return -EFAULT;
23605 else
23606 info = infobuf;
23607 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23608 index ecffca1..95c4d13 100644
23609 --- a/arch/x86/kernel/traps.c
23610 +++ b/arch/x86/kernel/traps.c
23611 @@ -68,12 +68,6 @@
23612 #include <asm/setup.h>
23613
23614 asmlinkage int system_call(void);
23615 -
23616 -/*
23617 - * The IDT has to be page-aligned to simplify the Pentium
23618 - * F0 0F bug workaround.
23619 - */
23620 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23621 #endif
23622
23623 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23624 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23625 }
23626
23627 static int __kprobes
23628 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23629 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23630 struct pt_regs *regs, long error_code)
23631 {
23632 #ifdef CONFIG_X86_32
23633 - if (regs->flags & X86_VM_MASK) {
23634 + if (v8086_mode(regs)) {
23635 /*
23636 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23637 * On nmi (interrupt 2), do_trap should not be called.
23638 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23639 return -1;
23640 }
23641 #endif
23642 - if (!user_mode(regs)) {
23643 + if (!user_mode_novm(regs)) {
23644 if (!fixup_exception(regs)) {
23645 tsk->thread.error_code = error_code;
23646 tsk->thread.trap_nr = trapnr;
23647 +
23648 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23649 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23650 + str = "PAX: suspicious stack segment fault";
23651 +#endif
23652 +
23653 die(str, regs, error_code);
23654 }
23655 +
23656 +#ifdef CONFIG_PAX_REFCOUNT
23657 + if (trapnr == 4)
23658 + pax_report_refcount_overflow(regs);
23659 +#endif
23660 +
23661 return 0;
23662 }
23663
23664 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23665 }
23666
23667 static void __kprobes
23668 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23669 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23670 long error_code, siginfo_t *info)
23671 {
23672 struct task_struct *tsk = current;
23673 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23674 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23675 printk_ratelimit()) {
23676 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23677 - tsk->comm, tsk->pid, str,
23678 + tsk->comm, task_pid_nr(tsk), str,
23679 regs->ip, regs->sp, error_code);
23680 print_vma_addr(" in ", regs->ip);
23681 pr_cont("\n");
23682 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23683 conditional_sti(regs);
23684
23685 #ifdef CONFIG_X86_32
23686 - if (regs->flags & X86_VM_MASK) {
23687 + if (v8086_mode(regs)) {
23688 local_irq_enable();
23689 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23690 goto exit;
23691 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23692 #endif
23693
23694 tsk = current;
23695 - if (!user_mode(regs)) {
23696 + if (!user_mode_novm(regs)) {
23697 if (fixup_exception(regs))
23698 goto exit;
23699
23700 tsk->thread.error_code = error_code;
23701 tsk->thread.trap_nr = X86_TRAP_GP;
23702 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23703 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23704 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23705 +
23706 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23707 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23708 + die("PAX: suspicious general protection fault", regs, error_code);
23709 + else
23710 +#endif
23711 +
23712 die("general protection fault", regs, error_code);
23713 + }
23714 goto exit;
23715 }
23716
23717 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23718 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23719 + struct mm_struct *mm = tsk->mm;
23720 + unsigned long limit;
23721 +
23722 + down_write(&mm->mmap_sem);
23723 + limit = mm->context.user_cs_limit;
23724 + if (limit < TASK_SIZE) {
23725 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23726 + up_write(&mm->mmap_sem);
23727 + return;
23728 + }
23729 + up_write(&mm->mmap_sem);
23730 + }
23731 +#endif
23732 +
23733 tsk->thread.error_code = error_code;
23734 tsk->thread.trap_nr = X86_TRAP_GP;
23735
23736 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23737 /* It's safe to allow irq's after DR6 has been saved */
23738 preempt_conditional_sti(regs);
23739
23740 - if (regs->flags & X86_VM_MASK) {
23741 + if (v8086_mode(regs)) {
23742 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23743 X86_TRAP_DB);
23744 preempt_conditional_cli(regs);
23745 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23746 * We already checked v86 mode above, so we can check for kernel mode
23747 * by just checking the CPL of CS.
23748 */
23749 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23750 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23751 tsk->thread.debugreg6 &= ~DR_STEP;
23752 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23753 regs->flags &= ~X86_EFLAGS_TF;
23754 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23755 return;
23756 conditional_sti(regs);
23757
23758 - if (!user_mode_vm(regs))
23759 + if (!user_mode(regs))
23760 {
23761 if (!fixup_exception(regs)) {
23762 task->thread.error_code = error_code;
23763 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23764 index c71025b..b117501 100644
23765 --- a/arch/x86/kernel/uprobes.c
23766 +++ b/arch/x86/kernel/uprobes.c
23767 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23768 int ret = NOTIFY_DONE;
23769
23770 /* We are only interested in userspace traps */
23771 - if (regs && !user_mode_vm(regs))
23772 + if (regs && !user_mode(regs))
23773 return NOTIFY_DONE;
23774
23775 switch (val) {
23776 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23777 index b9242ba..50c5edd 100644
23778 --- a/arch/x86/kernel/verify_cpu.S
23779 +++ b/arch/x86/kernel/verify_cpu.S
23780 @@ -20,6 +20,7 @@
23781 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23782 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23783 * arch/x86/kernel/head_32.S: processor startup
23784 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23785 *
23786 * verify_cpu, returns the status of longmode and SSE in register %eax.
23787 * 0: Success 1: Failure
23788 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23789 index 1dfe69c..a3df6f6 100644
23790 --- a/arch/x86/kernel/vm86_32.c
23791 +++ b/arch/x86/kernel/vm86_32.c
23792 @@ -43,6 +43,7 @@
23793 #include <linux/ptrace.h>
23794 #include <linux/audit.h>
23795 #include <linux/stddef.h>
23796 +#include <linux/grsecurity.h>
23797
23798 #include <asm/uaccess.h>
23799 #include <asm/io.h>
23800 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23801 do_exit(SIGSEGV);
23802 }
23803
23804 - tss = &per_cpu(init_tss, get_cpu());
23805 + tss = init_tss + get_cpu();
23806 current->thread.sp0 = current->thread.saved_sp0;
23807 current->thread.sysenter_cs = __KERNEL_CS;
23808 load_sp0(tss, &current->thread);
23809 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23810 struct task_struct *tsk;
23811 int tmp, ret = -EPERM;
23812
23813 +#ifdef CONFIG_GRKERNSEC_VM86
23814 + if (!capable(CAP_SYS_RAWIO)) {
23815 + gr_handle_vm86();
23816 + goto out;
23817 + }
23818 +#endif
23819 +
23820 tsk = current;
23821 if (tsk->thread.saved_sp0)
23822 goto out;
23823 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23824 int tmp, ret;
23825 struct vm86plus_struct __user *v86;
23826
23827 +#ifdef CONFIG_GRKERNSEC_VM86
23828 + if (!capable(CAP_SYS_RAWIO)) {
23829 + gr_handle_vm86();
23830 + ret = -EPERM;
23831 + goto out;
23832 + }
23833 +#endif
23834 +
23835 tsk = current;
23836 switch (cmd) {
23837 case VM86_REQUEST_IRQ:
23838 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23839 tsk->thread.saved_fs = info->regs32->fs;
23840 tsk->thread.saved_gs = get_user_gs(info->regs32);
23841
23842 - tss = &per_cpu(init_tss, get_cpu());
23843 + tss = init_tss + get_cpu();
23844 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23845 if (cpu_has_sep)
23846 tsk->thread.sysenter_cs = 0;
23847 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23848 goto cannot_handle;
23849 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23850 goto cannot_handle;
23851 - intr_ptr = (unsigned long __user *) (i << 2);
23852 + intr_ptr = (__force unsigned long __user *) (i << 2);
23853 if (get_user(segoffs, intr_ptr))
23854 goto cannot_handle;
23855 if ((segoffs >> 16) == BIOSSEG)
23856 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23857 index 22a1530..8fbaaad 100644
23858 --- a/arch/x86/kernel/vmlinux.lds.S
23859 +++ b/arch/x86/kernel/vmlinux.lds.S
23860 @@ -26,6 +26,13 @@
23861 #include <asm/page_types.h>
23862 #include <asm/cache.h>
23863 #include <asm/boot.h>
23864 +#include <asm/segment.h>
23865 +
23866 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23867 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23868 +#else
23869 +#define __KERNEL_TEXT_OFFSET 0
23870 +#endif
23871
23872 #undef i386 /* in case the preprocessor is a 32bit one */
23873
23874 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23875
23876 PHDRS {
23877 text PT_LOAD FLAGS(5); /* R_E */
23878 +#ifdef CONFIG_X86_32
23879 + module PT_LOAD FLAGS(5); /* R_E */
23880 +#endif
23881 +#ifdef CONFIG_XEN
23882 + rodata PT_LOAD FLAGS(5); /* R_E */
23883 +#else
23884 + rodata PT_LOAD FLAGS(4); /* R__ */
23885 +#endif
23886 data PT_LOAD FLAGS(6); /* RW_ */
23887 -#ifdef CONFIG_X86_64
23888 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23889 #ifdef CONFIG_SMP
23890 percpu PT_LOAD FLAGS(6); /* RW_ */
23891 #endif
23892 + text.init PT_LOAD FLAGS(5); /* R_E */
23893 + text.exit PT_LOAD FLAGS(5); /* R_E */
23894 init PT_LOAD FLAGS(7); /* RWE */
23895 -#endif
23896 note PT_NOTE FLAGS(0); /* ___ */
23897 }
23898
23899 SECTIONS
23900 {
23901 #ifdef CONFIG_X86_32
23902 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23903 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23904 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23905 #else
23906 - . = __START_KERNEL;
23907 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23908 + . = __START_KERNEL;
23909 #endif
23910
23911 /* Text and read-only data */
23912 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23913 - _text = .;
23914 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23915 /* bootstrapping code */
23916 +#ifdef CONFIG_X86_32
23917 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23918 +#else
23919 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23920 +#endif
23921 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23922 + _text = .;
23923 HEAD_TEXT
23924 #ifdef CONFIG_X86_32
23925 . = ALIGN(PAGE_SIZE);
23926 @@ -108,13 +128,48 @@ SECTIONS
23927 IRQENTRY_TEXT
23928 *(.fixup)
23929 *(.gnu.warning)
23930 - /* End of text section */
23931 - _etext = .;
23932 } :text = 0x9090
23933
23934 - NOTES :text :note
23935 + . += __KERNEL_TEXT_OFFSET;
23936
23937 - EXCEPTION_TABLE(16) :text = 0x9090
23938 +#ifdef CONFIG_X86_32
23939 + . = ALIGN(PAGE_SIZE);
23940 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23941 +
23942 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23943 + MODULES_EXEC_VADDR = .;
23944 + BYTE(0)
23945 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23946 + . = ALIGN(HPAGE_SIZE) - 1;
23947 + MODULES_EXEC_END = .;
23948 +#endif
23949 +
23950 + } :module
23951 +#endif
23952 +
23953 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23954 + /* End of text section */
23955 + BYTE(0)
23956 + _etext = . - __KERNEL_TEXT_OFFSET;
23957 + }
23958 +
23959 +#ifdef CONFIG_X86_32
23960 + . = ALIGN(PAGE_SIZE);
23961 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23962 + *(.idt)
23963 + . = ALIGN(PAGE_SIZE);
23964 + *(.empty_zero_page)
23965 + *(.initial_pg_fixmap)
23966 + *(.initial_pg_pmd)
23967 + *(.initial_page_table)
23968 + *(.swapper_pg_dir)
23969 + } :rodata
23970 +#endif
23971 +
23972 + . = ALIGN(PAGE_SIZE);
23973 + NOTES :rodata :note
23974 +
23975 + EXCEPTION_TABLE(16) :rodata
23976
23977 #if defined(CONFIG_DEBUG_RODATA)
23978 /* .text should occupy whole number of pages */
23979 @@ -126,16 +181,20 @@ SECTIONS
23980
23981 /* Data */
23982 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23983 +
23984 +#ifdef CONFIG_PAX_KERNEXEC
23985 + . = ALIGN(HPAGE_SIZE);
23986 +#else
23987 + . = ALIGN(PAGE_SIZE);
23988 +#endif
23989 +
23990 /* Start of data section */
23991 _sdata = .;
23992
23993 /* init_task */
23994 INIT_TASK_DATA(THREAD_SIZE)
23995
23996 -#ifdef CONFIG_X86_32
23997 - /* 32 bit has nosave before _edata */
23998 NOSAVE_DATA
23999 -#endif
24000
24001 PAGE_ALIGNED_DATA(PAGE_SIZE)
24002
24003 @@ -176,12 +235,19 @@ SECTIONS
24004 #endif /* CONFIG_X86_64 */
24005
24006 /* Init code and data - will be freed after init */
24007 - . = ALIGN(PAGE_SIZE);
24008 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
24009 + BYTE(0)
24010 +
24011 +#ifdef CONFIG_PAX_KERNEXEC
24012 + . = ALIGN(HPAGE_SIZE);
24013 +#else
24014 + . = ALIGN(PAGE_SIZE);
24015 +#endif
24016 +
24017 __init_begin = .; /* paired with __init_end */
24018 - }
24019 + } :init.begin
24020
24021 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
24022 +#ifdef CONFIG_SMP
24023 /*
24024 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
24025 * output PHDR, so the next output section - .init.text - should
24026 @@ -190,12 +256,27 @@ SECTIONS
24027 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
24028 #endif
24029
24030 - INIT_TEXT_SECTION(PAGE_SIZE)
24031 -#ifdef CONFIG_X86_64
24032 - :init
24033 -#endif
24034 + . = ALIGN(PAGE_SIZE);
24035 + init_begin = .;
24036 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
24037 + VMLINUX_SYMBOL(_sinittext) = .;
24038 + INIT_TEXT
24039 + VMLINUX_SYMBOL(_einittext) = .;
24040 + . = ALIGN(PAGE_SIZE);
24041 + } :text.init
24042
24043 - INIT_DATA_SECTION(16)
24044 + /*
24045 + * .exit.text is discard at runtime, not link time, to deal with
24046 + * references from .altinstructions and .eh_frame
24047 + */
24048 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
24049 + EXIT_TEXT
24050 + . = ALIGN(16);
24051 + } :text.exit
24052 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
24053 +
24054 + . = ALIGN(PAGE_SIZE);
24055 + INIT_DATA_SECTION(16) :init
24056
24057 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
24058 __x86_cpu_dev_start = .;
24059 @@ -257,19 +338,12 @@ SECTIONS
24060 }
24061
24062 . = ALIGN(8);
24063 - /*
24064 - * .exit.text is discard at runtime, not link time, to deal with
24065 - * references from .altinstructions and .eh_frame
24066 - */
24067 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
24068 - EXIT_TEXT
24069 - }
24070
24071 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
24072 EXIT_DATA
24073 }
24074
24075 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
24076 +#ifndef CONFIG_SMP
24077 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
24078 #endif
24079
24080 @@ -288,16 +362,10 @@ SECTIONS
24081 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
24082 __smp_locks = .;
24083 *(.smp_locks)
24084 - . = ALIGN(PAGE_SIZE);
24085 __smp_locks_end = .;
24086 + . = ALIGN(PAGE_SIZE);
24087 }
24088
24089 -#ifdef CONFIG_X86_64
24090 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
24091 - NOSAVE_DATA
24092 - }
24093 -#endif
24094 -
24095 /* BSS */
24096 . = ALIGN(PAGE_SIZE);
24097 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
24098 @@ -313,6 +381,7 @@ SECTIONS
24099 __brk_base = .;
24100 . += 64 * 1024; /* 64k alignment slop space */
24101 *(.brk_reservation) /* areas brk users have reserved */
24102 + . = ALIGN(HPAGE_SIZE);
24103 __brk_limit = .;
24104 }
24105
24106 @@ -339,13 +408,12 @@ SECTIONS
24107 * for the boot processor.
24108 */
24109 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
24110 -INIT_PER_CPU(gdt_page);
24111 INIT_PER_CPU(irq_stack_union);
24112
24113 /*
24114 * Build-time check on the image size:
24115 */
24116 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
24117 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
24118 "kernel image bigger than KERNEL_IMAGE_SIZE");
24119
24120 #ifdef CONFIG_SMP
24121 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
24122 index 9a907a6..f83f921 100644
24123 --- a/arch/x86/kernel/vsyscall_64.c
24124 +++ b/arch/x86/kernel/vsyscall_64.c
24125 @@ -56,15 +56,13 @@
24126 DEFINE_VVAR(int, vgetcpu_mode);
24127 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
24128
24129 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
24130 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
24131
24132 static int __init vsyscall_setup(char *str)
24133 {
24134 if (str) {
24135 if (!strcmp("emulate", str))
24136 vsyscall_mode = EMULATE;
24137 - else if (!strcmp("native", str))
24138 - vsyscall_mode = NATIVE;
24139 else if (!strcmp("none", str))
24140 vsyscall_mode = NONE;
24141 else
24142 @@ -323,8 +321,7 @@ do_ret:
24143 return true;
24144
24145 sigsegv:
24146 - force_sig(SIGSEGV, current);
24147 - return true;
24148 + do_group_exit(SIGKILL);
24149 }
24150
24151 /*
24152 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
24153 extern char __vvar_page;
24154 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
24155
24156 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
24157 - vsyscall_mode == NATIVE
24158 - ? PAGE_KERNEL_VSYSCALL
24159 - : PAGE_KERNEL_VVAR);
24160 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
24161 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
24162 (unsigned long)VSYSCALL_START);
24163
24164 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
24165 index 1330dd1..d220b99 100644
24166 --- a/arch/x86/kernel/x8664_ksyms_64.c
24167 +++ b/arch/x86/kernel/x8664_ksyms_64.c
24168 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
24169 EXPORT_SYMBOL(copy_user_generic_unrolled);
24170 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
24171 EXPORT_SYMBOL(__copy_user_nocache);
24172 -EXPORT_SYMBOL(_copy_from_user);
24173 -EXPORT_SYMBOL(_copy_to_user);
24174
24175 EXPORT_SYMBOL(copy_page);
24176 EXPORT_SYMBOL(clear_page);
24177 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
24178 index 7a3d075..6cb373d 100644
24179 --- a/arch/x86/kernel/x86_init.c
24180 +++ b/arch/x86/kernel/x86_init.c
24181 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
24182 },
24183 };
24184
24185 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24186 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
24187 .early_percpu_clock_init = x86_init_noop,
24188 .setup_percpu_clockev = setup_secondary_APIC_clock,
24189 };
24190 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24191 static void default_nmi_init(void) { };
24192 static int default_i8042_detect(void) { return 1; };
24193
24194 -struct x86_platform_ops x86_platform = {
24195 +struct x86_platform_ops x86_platform __read_only = {
24196 .calibrate_tsc = native_calibrate_tsc,
24197 .get_wallclock = mach_get_cmos_time,
24198 .set_wallclock = mach_set_rtc_mmss,
24199 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
24200 };
24201
24202 EXPORT_SYMBOL_GPL(x86_platform);
24203 -struct x86_msi_ops x86_msi = {
24204 +struct x86_msi_ops x86_msi __read_only = {
24205 .setup_msi_irqs = native_setup_msi_irqs,
24206 .teardown_msi_irq = native_teardown_msi_irq,
24207 .teardown_msi_irqs = default_teardown_msi_irqs,
24208 .restore_msi_irqs = default_restore_msi_irqs,
24209 };
24210
24211 -struct x86_io_apic_ops x86_io_apic_ops = {
24212 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
24213 .init = native_io_apic_init_mappings,
24214 .read = native_io_apic_read,
24215 .write = native_io_apic_write,
24216 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
24217 index ada87a3..afea76d 100644
24218 --- a/arch/x86/kernel/xsave.c
24219 +++ b/arch/x86/kernel/xsave.c
24220 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
24221 {
24222 int err;
24223
24224 + buf = (struct xsave_struct __user *)____m(buf);
24225 if (use_xsave())
24226 err = xsave_user(buf);
24227 else if (use_fxsr())
24228 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24229 */
24230 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24231 {
24232 + buf = (void __user *)____m(buf);
24233 if (use_xsave()) {
24234 if ((unsigned long)buf % 64 || fx_only) {
24235 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24236 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24237 index a20ecb5..d0e2194 100644
24238 --- a/arch/x86/kvm/cpuid.c
24239 +++ b/arch/x86/kvm/cpuid.c
24240 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24241 struct kvm_cpuid2 *cpuid,
24242 struct kvm_cpuid_entry2 __user *entries)
24243 {
24244 - int r;
24245 + int r, i;
24246
24247 r = -E2BIG;
24248 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24249 goto out;
24250 r = -EFAULT;
24251 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24252 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24253 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24254 goto out;
24255 + for (i = 0; i < cpuid->nent; ++i) {
24256 + struct kvm_cpuid_entry2 cpuid_entry;
24257 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24258 + goto out;
24259 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24260 + }
24261 vcpu->arch.cpuid_nent = cpuid->nent;
24262 kvm_apic_set_version(vcpu);
24263 kvm_x86_ops->cpuid_update(vcpu);
24264 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24265 struct kvm_cpuid2 *cpuid,
24266 struct kvm_cpuid_entry2 __user *entries)
24267 {
24268 - int r;
24269 + int r, i;
24270
24271 r = -E2BIG;
24272 if (cpuid->nent < vcpu->arch.cpuid_nent)
24273 goto out;
24274 r = -EFAULT;
24275 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24276 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24277 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24278 goto out;
24279 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24280 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24281 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24282 + goto out;
24283 + }
24284 return 0;
24285
24286 out:
24287 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24288 index a27e763..54bfe43 100644
24289 --- a/arch/x86/kvm/emulate.c
24290 +++ b/arch/x86/kvm/emulate.c
24291 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24292
24293 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24294 do { \
24295 + unsigned long _tmp; \
24296 __asm__ __volatile__ ( \
24297 _PRE_EFLAGS("0", "4", "2") \
24298 _op _suffix " %"_x"3,%1; " \
24299 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24300 /* Raw emulation: instruction has two explicit operands. */
24301 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24302 do { \
24303 - unsigned long _tmp; \
24304 - \
24305 switch ((ctxt)->dst.bytes) { \
24306 case 2: \
24307 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24308 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24309
24310 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24311 do { \
24312 - unsigned long _tmp; \
24313 switch ((ctxt)->dst.bytes) { \
24314 case 1: \
24315 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24316 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24317 index a2f492c..899e107 100644
24318 --- a/arch/x86/kvm/lapic.c
24319 +++ b/arch/x86/kvm/lapic.c
24320 @@ -55,7 +55,7 @@
24321 #define APIC_BUS_CYCLE_NS 1
24322
24323 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24324 -#define apic_debug(fmt, arg...)
24325 +#define apic_debug(fmt, arg...) do {} while (0)
24326
24327 #define APIC_LVT_NUM 6
24328 /* 14 is the version for Xeon and Pentium 8.4.8*/
24329 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24330 index 891eb6d..e027900 100644
24331 --- a/arch/x86/kvm/paging_tmpl.h
24332 +++ b/arch/x86/kvm/paging_tmpl.h
24333 @@ -208,7 +208,7 @@ retry_walk:
24334 if (unlikely(kvm_is_error_hva(host_addr)))
24335 goto error;
24336
24337 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24338 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24339 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24340 goto error;
24341 walker->ptep_user[walker->level - 1] = ptep_user;
24342 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24343 index d29d3cd..ec9d522 100644
24344 --- a/arch/x86/kvm/svm.c
24345 +++ b/arch/x86/kvm/svm.c
24346 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24347 int cpu = raw_smp_processor_id();
24348
24349 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24350 +
24351 + pax_open_kernel();
24352 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24353 + pax_close_kernel();
24354 +
24355 load_TR_desc();
24356 }
24357
24358 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24359 #endif
24360 #endif
24361
24362 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24363 + __set_fs(current_thread_info()->addr_limit);
24364 +#endif
24365 +
24366 reload_tss(vcpu);
24367
24368 local_irq_disable();
24369 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24370 index 9120ae1..aca46d0 100644
24371 --- a/arch/x86/kvm/vmx.c
24372 +++ b/arch/x86/kvm/vmx.c
24373 @@ -1164,12 +1164,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24374 #endif
24375 }
24376
24377 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24378 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24379 {
24380 vmcs_writel(field, vmcs_readl(field) & ~mask);
24381 }
24382
24383 -static void vmcs_set_bits(unsigned long field, u32 mask)
24384 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24385 {
24386 vmcs_writel(field, vmcs_readl(field) | mask);
24387 }
24388 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
24389 struct desc_struct *descs;
24390
24391 descs = (void *)gdt->address;
24392 +
24393 + pax_open_kernel();
24394 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24395 + pax_close_kernel();
24396 +
24397 load_TR_desc();
24398 }
24399
24400 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24401 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24402 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24403
24404 +#ifdef CONFIG_PAX_PER_CPU_PGD
24405 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24406 +#endif
24407 +
24408 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24409 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24410 vmx->loaded_vmcs->cpu = cpu;
24411 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
24412 if (!cpu_has_vmx_flexpriority())
24413 flexpriority_enabled = 0;
24414
24415 - if (!cpu_has_vmx_tpr_shadow())
24416 - kvm_x86_ops->update_cr8_intercept = NULL;
24417 + if (!cpu_has_vmx_tpr_shadow()) {
24418 + pax_open_kernel();
24419 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24420 + pax_close_kernel();
24421 + }
24422
24423 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24424 kvm_disable_largepages();
24425 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
24426
24427 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24428 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24429 +
24430 +#ifndef CONFIG_PAX_PER_CPU_PGD
24431 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24432 +#endif
24433
24434 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24435 #ifdef CONFIG_X86_64
24436 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
24437 native_store_idt(&dt);
24438 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24439
24440 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24441 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24442
24443 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24444 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24445 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24446 "jmp 2f \n\t"
24447 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24448 "2: "
24449 +
24450 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24451 + "ljmp %[cs],$3f\n\t"
24452 + "3: "
24453 +#endif
24454 +
24455 /* Save guest registers, load host registers, keep flags */
24456 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24457 "pop %0 \n\t"
24458 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24459 #endif
24460 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24461 [wordsize]"i"(sizeof(ulong))
24462 +
24463 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24464 + ,[cs]"i"(__KERNEL_CS)
24465 +#endif
24466 +
24467 : "cc", "memory"
24468 #ifdef CONFIG_X86_64
24469 , "rax", "rbx", "rdi", "rsi"
24470 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24471 if (debugctlmsr)
24472 update_debugctlmsr(debugctlmsr);
24473
24474 -#ifndef CONFIG_X86_64
24475 +#ifdef CONFIG_X86_32
24476 /*
24477 * The sysexit path does not restore ds/es, so we must set them to
24478 * a reasonable value ourselves.
24479 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24480 * may be executed in interrupt context, which saves and restore segments
24481 * around it, nullifying its effect.
24482 */
24483 - loadsegment(ds, __USER_DS);
24484 - loadsegment(es, __USER_DS);
24485 + loadsegment(ds, __KERNEL_DS);
24486 + loadsegment(es, __KERNEL_DS);
24487 + loadsegment(ss, __KERNEL_DS);
24488 +
24489 +#ifdef CONFIG_PAX_KERNEXEC
24490 + loadsegment(fs, __KERNEL_PERCPU);
24491 +#endif
24492 +
24493 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24494 + __set_fs(current_thread_info()->addr_limit);
24495 +#endif
24496 +
24497 #endif
24498
24499 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24500 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24501 index 9a51121..f739a79 100644
24502 --- a/arch/x86/kvm/x86.c
24503 +++ b/arch/x86/kvm/x86.c
24504 @@ -1688,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24505 {
24506 struct kvm *kvm = vcpu->kvm;
24507 int lm = is_long_mode(vcpu);
24508 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24509 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24510 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24511 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24512 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24513 : kvm->arch.xen_hvm_config.blob_size_32;
24514 u32 page_num = data & ~PAGE_MASK;
24515 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24516 if (n < msr_list.nmsrs)
24517 goto out;
24518 r = -EFAULT;
24519 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24520 + goto out;
24521 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24522 num_msrs_to_save * sizeof(u32)))
24523 goto out;
24524 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24525 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24526 struct kvm_interrupt *irq)
24527 {
24528 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24529 + if (irq->irq >= KVM_NR_INTERRUPTS)
24530 return -EINVAL;
24531 if (irqchip_in_kernel(vcpu->kvm))
24532 return -ENXIO;
24533 @@ -5209,7 +5211,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24534 };
24535 #endif
24536
24537 -int kvm_arch_init(void *opaque)
24538 +int kvm_arch_init(const void *opaque)
24539 {
24540 int r;
24541 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24542 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24543 index 20a4fd4..d806083 100644
24544 --- a/arch/x86/lguest/boot.c
24545 +++ b/arch/x86/lguest/boot.c
24546 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24547 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24548 * Launcher to reboot us.
24549 */
24550 -static void lguest_restart(char *reason)
24551 +static __noreturn void lguest_restart(char *reason)
24552 {
24553 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24554 + BUG();
24555 }
24556
24557 /*G:050
24558 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24559 index 00933d5..3a64af9 100644
24560 --- a/arch/x86/lib/atomic64_386_32.S
24561 +++ b/arch/x86/lib/atomic64_386_32.S
24562 @@ -48,6 +48,10 @@ BEGIN(read)
24563 movl (v), %eax
24564 movl 4(v), %edx
24565 RET_ENDP
24566 +BEGIN(read_unchecked)
24567 + movl (v), %eax
24568 + movl 4(v), %edx
24569 +RET_ENDP
24570 #undef v
24571
24572 #define v %esi
24573 @@ -55,6 +59,10 @@ BEGIN(set)
24574 movl %ebx, (v)
24575 movl %ecx, 4(v)
24576 RET_ENDP
24577 +BEGIN(set_unchecked)
24578 + movl %ebx, (v)
24579 + movl %ecx, 4(v)
24580 +RET_ENDP
24581 #undef v
24582
24583 #define v %esi
24584 @@ -70,6 +78,20 @@ RET_ENDP
24585 BEGIN(add)
24586 addl %eax, (v)
24587 adcl %edx, 4(v)
24588 +
24589 +#ifdef CONFIG_PAX_REFCOUNT
24590 + jno 0f
24591 + subl %eax, (v)
24592 + sbbl %edx, 4(v)
24593 + int $4
24594 +0:
24595 + _ASM_EXTABLE(0b, 0b)
24596 +#endif
24597 +
24598 +RET_ENDP
24599 +BEGIN(add_unchecked)
24600 + addl %eax, (v)
24601 + adcl %edx, 4(v)
24602 RET_ENDP
24603 #undef v
24604
24605 @@ -77,6 +99,24 @@ RET_ENDP
24606 BEGIN(add_return)
24607 addl (v), %eax
24608 adcl 4(v), %edx
24609 +
24610 +#ifdef CONFIG_PAX_REFCOUNT
24611 + into
24612 +1234:
24613 + _ASM_EXTABLE(1234b, 2f)
24614 +#endif
24615 +
24616 + movl %eax, (v)
24617 + movl %edx, 4(v)
24618 +
24619 +#ifdef CONFIG_PAX_REFCOUNT
24620 +2:
24621 +#endif
24622 +
24623 +RET_ENDP
24624 +BEGIN(add_return_unchecked)
24625 + addl (v), %eax
24626 + adcl 4(v), %edx
24627 movl %eax, (v)
24628 movl %edx, 4(v)
24629 RET_ENDP
24630 @@ -86,6 +126,20 @@ RET_ENDP
24631 BEGIN(sub)
24632 subl %eax, (v)
24633 sbbl %edx, 4(v)
24634 +
24635 +#ifdef CONFIG_PAX_REFCOUNT
24636 + jno 0f
24637 + addl %eax, (v)
24638 + adcl %edx, 4(v)
24639 + int $4
24640 +0:
24641 + _ASM_EXTABLE(0b, 0b)
24642 +#endif
24643 +
24644 +RET_ENDP
24645 +BEGIN(sub_unchecked)
24646 + subl %eax, (v)
24647 + sbbl %edx, 4(v)
24648 RET_ENDP
24649 #undef v
24650
24651 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24652 sbbl $0, %edx
24653 addl (v), %eax
24654 adcl 4(v), %edx
24655 +
24656 +#ifdef CONFIG_PAX_REFCOUNT
24657 + into
24658 +1234:
24659 + _ASM_EXTABLE(1234b, 2f)
24660 +#endif
24661 +
24662 + movl %eax, (v)
24663 + movl %edx, 4(v)
24664 +
24665 +#ifdef CONFIG_PAX_REFCOUNT
24666 +2:
24667 +#endif
24668 +
24669 +RET_ENDP
24670 +BEGIN(sub_return_unchecked)
24671 + negl %edx
24672 + negl %eax
24673 + sbbl $0, %edx
24674 + addl (v), %eax
24675 + adcl 4(v), %edx
24676 movl %eax, (v)
24677 movl %edx, 4(v)
24678 RET_ENDP
24679 @@ -105,6 +180,20 @@ RET_ENDP
24680 BEGIN(inc)
24681 addl $1, (v)
24682 adcl $0, 4(v)
24683 +
24684 +#ifdef CONFIG_PAX_REFCOUNT
24685 + jno 0f
24686 + subl $1, (v)
24687 + sbbl $0, 4(v)
24688 + int $4
24689 +0:
24690 + _ASM_EXTABLE(0b, 0b)
24691 +#endif
24692 +
24693 +RET_ENDP
24694 +BEGIN(inc_unchecked)
24695 + addl $1, (v)
24696 + adcl $0, 4(v)
24697 RET_ENDP
24698 #undef v
24699
24700 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24701 movl 4(v), %edx
24702 addl $1, %eax
24703 adcl $0, %edx
24704 +
24705 +#ifdef CONFIG_PAX_REFCOUNT
24706 + into
24707 +1234:
24708 + _ASM_EXTABLE(1234b, 2f)
24709 +#endif
24710 +
24711 + movl %eax, (v)
24712 + movl %edx, 4(v)
24713 +
24714 +#ifdef CONFIG_PAX_REFCOUNT
24715 +2:
24716 +#endif
24717 +
24718 +RET_ENDP
24719 +BEGIN(inc_return_unchecked)
24720 + movl (v), %eax
24721 + movl 4(v), %edx
24722 + addl $1, %eax
24723 + adcl $0, %edx
24724 movl %eax, (v)
24725 movl %edx, 4(v)
24726 RET_ENDP
24727 @@ -123,6 +232,20 @@ RET_ENDP
24728 BEGIN(dec)
24729 subl $1, (v)
24730 sbbl $0, 4(v)
24731 +
24732 +#ifdef CONFIG_PAX_REFCOUNT
24733 + jno 0f
24734 + addl $1, (v)
24735 + adcl $0, 4(v)
24736 + int $4
24737 +0:
24738 + _ASM_EXTABLE(0b, 0b)
24739 +#endif
24740 +
24741 +RET_ENDP
24742 +BEGIN(dec_unchecked)
24743 + subl $1, (v)
24744 + sbbl $0, 4(v)
24745 RET_ENDP
24746 #undef v
24747
24748 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24749 movl 4(v), %edx
24750 subl $1, %eax
24751 sbbl $0, %edx
24752 +
24753 +#ifdef CONFIG_PAX_REFCOUNT
24754 + into
24755 +1234:
24756 + _ASM_EXTABLE(1234b, 2f)
24757 +#endif
24758 +
24759 + movl %eax, (v)
24760 + movl %edx, 4(v)
24761 +
24762 +#ifdef CONFIG_PAX_REFCOUNT
24763 +2:
24764 +#endif
24765 +
24766 +RET_ENDP
24767 +BEGIN(dec_return_unchecked)
24768 + movl (v), %eax
24769 + movl 4(v), %edx
24770 + subl $1, %eax
24771 + sbbl $0, %edx
24772 movl %eax, (v)
24773 movl %edx, 4(v)
24774 RET_ENDP
24775 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24776 adcl %edx, %edi
24777 addl (v), %eax
24778 adcl 4(v), %edx
24779 +
24780 +#ifdef CONFIG_PAX_REFCOUNT
24781 + into
24782 +1234:
24783 + _ASM_EXTABLE(1234b, 2f)
24784 +#endif
24785 +
24786 cmpl %eax, %ecx
24787 je 3f
24788 1:
24789 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24790 1:
24791 addl $1, %eax
24792 adcl $0, %edx
24793 +
24794 +#ifdef CONFIG_PAX_REFCOUNT
24795 + into
24796 +1234:
24797 + _ASM_EXTABLE(1234b, 2f)
24798 +#endif
24799 +
24800 movl %eax, (v)
24801 movl %edx, 4(v)
24802 movl $1, %eax
24803 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24804 movl 4(v), %edx
24805 subl $1, %eax
24806 sbbl $0, %edx
24807 +
24808 +#ifdef CONFIG_PAX_REFCOUNT
24809 + into
24810 +1234:
24811 + _ASM_EXTABLE(1234b, 1f)
24812 +#endif
24813 +
24814 js 1f
24815 movl %eax, (v)
24816 movl %edx, 4(v)
24817 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24818 index f5cc9eb..51fa319 100644
24819 --- a/arch/x86/lib/atomic64_cx8_32.S
24820 +++ b/arch/x86/lib/atomic64_cx8_32.S
24821 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24822 CFI_STARTPROC
24823
24824 read64 %ecx
24825 + pax_force_retaddr
24826 ret
24827 CFI_ENDPROC
24828 ENDPROC(atomic64_read_cx8)
24829
24830 +ENTRY(atomic64_read_unchecked_cx8)
24831 + CFI_STARTPROC
24832 +
24833 + read64 %ecx
24834 + pax_force_retaddr
24835 + ret
24836 + CFI_ENDPROC
24837 +ENDPROC(atomic64_read_unchecked_cx8)
24838 +
24839 ENTRY(atomic64_set_cx8)
24840 CFI_STARTPROC
24841
24842 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24843 cmpxchg8b (%esi)
24844 jne 1b
24845
24846 + pax_force_retaddr
24847 ret
24848 CFI_ENDPROC
24849 ENDPROC(atomic64_set_cx8)
24850
24851 +ENTRY(atomic64_set_unchecked_cx8)
24852 + CFI_STARTPROC
24853 +
24854 +1:
24855 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24856 + * are atomic on 586 and newer */
24857 + cmpxchg8b (%esi)
24858 + jne 1b
24859 +
24860 + pax_force_retaddr
24861 + ret
24862 + CFI_ENDPROC
24863 +ENDPROC(atomic64_set_unchecked_cx8)
24864 +
24865 ENTRY(atomic64_xchg_cx8)
24866 CFI_STARTPROC
24867
24868 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24869 cmpxchg8b (%esi)
24870 jne 1b
24871
24872 + pax_force_retaddr
24873 ret
24874 CFI_ENDPROC
24875 ENDPROC(atomic64_xchg_cx8)
24876
24877 -.macro addsub_return func ins insc
24878 -ENTRY(atomic64_\func\()_return_cx8)
24879 +.macro addsub_return func ins insc unchecked=""
24880 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24881 CFI_STARTPROC
24882 SAVE ebp
24883 SAVE ebx
24884 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24885 movl %edx, %ecx
24886 \ins\()l %esi, %ebx
24887 \insc\()l %edi, %ecx
24888 +
24889 +.ifb \unchecked
24890 +#ifdef CONFIG_PAX_REFCOUNT
24891 + into
24892 +2:
24893 + _ASM_EXTABLE(2b, 3f)
24894 +#endif
24895 +.endif
24896 +
24897 LOCK_PREFIX
24898 cmpxchg8b (%ebp)
24899 jne 1b
24900 -
24901 -10:
24902 movl %ebx, %eax
24903 movl %ecx, %edx
24904 +
24905 +.ifb \unchecked
24906 +#ifdef CONFIG_PAX_REFCOUNT
24907 +3:
24908 +#endif
24909 +.endif
24910 +
24911 RESTORE edi
24912 RESTORE esi
24913 RESTORE ebx
24914 RESTORE ebp
24915 + pax_force_retaddr
24916 ret
24917 CFI_ENDPROC
24918 -ENDPROC(atomic64_\func\()_return_cx8)
24919 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24920 .endm
24921
24922 addsub_return add add adc
24923 addsub_return sub sub sbb
24924 +addsub_return add add adc _unchecked
24925 +addsub_return sub sub sbb _unchecked
24926
24927 -.macro incdec_return func ins insc
24928 -ENTRY(atomic64_\func\()_return_cx8)
24929 +.macro incdec_return func ins insc unchecked=""
24930 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24931 CFI_STARTPROC
24932 SAVE ebx
24933
24934 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24935 movl %edx, %ecx
24936 \ins\()l $1, %ebx
24937 \insc\()l $0, %ecx
24938 +
24939 +.ifb \unchecked
24940 +#ifdef CONFIG_PAX_REFCOUNT
24941 + into
24942 +2:
24943 + _ASM_EXTABLE(2b, 3f)
24944 +#endif
24945 +.endif
24946 +
24947 LOCK_PREFIX
24948 cmpxchg8b (%esi)
24949 jne 1b
24950
24951 -10:
24952 movl %ebx, %eax
24953 movl %ecx, %edx
24954 +
24955 +.ifb \unchecked
24956 +#ifdef CONFIG_PAX_REFCOUNT
24957 +3:
24958 +#endif
24959 +.endif
24960 +
24961 RESTORE ebx
24962 + pax_force_retaddr
24963 ret
24964 CFI_ENDPROC
24965 -ENDPROC(atomic64_\func\()_return_cx8)
24966 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24967 .endm
24968
24969 incdec_return inc add adc
24970 incdec_return dec sub sbb
24971 +incdec_return inc add adc _unchecked
24972 +incdec_return dec sub sbb _unchecked
24973
24974 ENTRY(atomic64_dec_if_positive_cx8)
24975 CFI_STARTPROC
24976 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24977 movl %edx, %ecx
24978 subl $1, %ebx
24979 sbb $0, %ecx
24980 +
24981 +#ifdef CONFIG_PAX_REFCOUNT
24982 + into
24983 +1234:
24984 + _ASM_EXTABLE(1234b, 2f)
24985 +#endif
24986 +
24987 js 2f
24988 LOCK_PREFIX
24989 cmpxchg8b (%esi)
24990 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24991 movl %ebx, %eax
24992 movl %ecx, %edx
24993 RESTORE ebx
24994 + pax_force_retaddr
24995 ret
24996 CFI_ENDPROC
24997 ENDPROC(atomic64_dec_if_positive_cx8)
24998 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24999 movl %edx, %ecx
25000 addl %ebp, %ebx
25001 adcl %edi, %ecx
25002 +
25003 +#ifdef CONFIG_PAX_REFCOUNT
25004 + into
25005 +1234:
25006 + _ASM_EXTABLE(1234b, 3f)
25007 +#endif
25008 +
25009 LOCK_PREFIX
25010 cmpxchg8b (%esi)
25011 jne 1b
25012 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
25013 CFI_ADJUST_CFA_OFFSET -8
25014 RESTORE ebx
25015 RESTORE ebp
25016 + pax_force_retaddr
25017 ret
25018 4:
25019 cmpl %edx, 4(%esp)
25020 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
25021 xorl %ecx, %ecx
25022 addl $1, %ebx
25023 adcl %edx, %ecx
25024 +
25025 +#ifdef CONFIG_PAX_REFCOUNT
25026 + into
25027 +1234:
25028 + _ASM_EXTABLE(1234b, 3f)
25029 +#endif
25030 +
25031 LOCK_PREFIX
25032 cmpxchg8b (%esi)
25033 jne 1b
25034 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
25035 movl $1, %eax
25036 3:
25037 RESTORE ebx
25038 + pax_force_retaddr
25039 ret
25040 CFI_ENDPROC
25041 ENDPROC(atomic64_inc_not_zero_cx8)
25042 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
25043 index 2af5df3..62b1a5a 100644
25044 --- a/arch/x86/lib/checksum_32.S
25045 +++ b/arch/x86/lib/checksum_32.S
25046 @@ -29,7 +29,8 @@
25047 #include <asm/dwarf2.h>
25048 #include <asm/errno.h>
25049 #include <asm/asm.h>
25050 -
25051 +#include <asm/segment.h>
25052 +
25053 /*
25054 * computes a partial checksum, e.g. for TCP/UDP fragments
25055 */
25056 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
25057
25058 #define ARGBASE 16
25059 #define FP 12
25060 -
25061 -ENTRY(csum_partial_copy_generic)
25062 +
25063 +ENTRY(csum_partial_copy_generic_to_user)
25064 CFI_STARTPROC
25065 +
25066 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25067 + pushl_cfi %gs
25068 + popl_cfi %es
25069 + jmp csum_partial_copy_generic
25070 +#endif
25071 +
25072 +ENTRY(csum_partial_copy_generic_from_user)
25073 +
25074 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25075 + pushl_cfi %gs
25076 + popl_cfi %ds
25077 +#endif
25078 +
25079 +ENTRY(csum_partial_copy_generic)
25080 subl $4,%esp
25081 CFI_ADJUST_CFA_OFFSET 4
25082 pushl_cfi %edi
25083 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
25084 jmp 4f
25085 SRC(1: movw (%esi), %bx )
25086 addl $2, %esi
25087 -DST( movw %bx, (%edi) )
25088 +DST( movw %bx, %es:(%edi) )
25089 addl $2, %edi
25090 addw %bx, %ax
25091 adcl $0, %eax
25092 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
25093 SRC(1: movl (%esi), %ebx )
25094 SRC( movl 4(%esi), %edx )
25095 adcl %ebx, %eax
25096 -DST( movl %ebx, (%edi) )
25097 +DST( movl %ebx, %es:(%edi) )
25098 adcl %edx, %eax
25099 -DST( movl %edx, 4(%edi) )
25100 +DST( movl %edx, %es:4(%edi) )
25101
25102 SRC( movl 8(%esi), %ebx )
25103 SRC( movl 12(%esi), %edx )
25104 adcl %ebx, %eax
25105 -DST( movl %ebx, 8(%edi) )
25106 +DST( movl %ebx, %es:8(%edi) )
25107 adcl %edx, %eax
25108 -DST( movl %edx, 12(%edi) )
25109 +DST( movl %edx, %es:12(%edi) )
25110
25111 SRC( movl 16(%esi), %ebx )
25112 SRC( movl 20(%esi), %edx )
25113 adcl %ebx, %eax
25114 -DST( movl %ebx, 16(%edi) )
25115 +DST( movl %ebx, %es:16(%edi) )
25116 adcl %edx, %eax
25117 -DST( movl %edx, 20(%edi) )
25118 +DST( movl %edx, %es:20(%edi) )
25119
25120 SRC( movl 24(%esi), %ebx )
25121 SRC( movl 28(%esi), %edx )
25122 adcl %ebx, %eax
25123 -DST( movl %ebx, 24(%edi) )
25124 +DST( movl %ebx, %es:24(%edi) )
25125 adcl %edx, %eax
25126 -DST( movl %edx, 28(%edi) )
25127 +DST( movl %edx, %es:28(%edi) )
25128
25129 lea 32(%esi), %esi
25130 lea 32(%edi), %edi
25131 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
25132 shrl $2, %edx # This clears CF
25133 SRC(3: movl (%esi), %ebx )
25134 adcl %ebx, %eax
25135 -DST( movl %ebx, (%edi) )
25136 +DST( movl %ebx, %es:(%edi) )
25137 lea 4(%esi), %esi
25138 lea 4(%edi), %edi
25139 dec %edx
25140 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
25141 jb 5f
25142 SRC( movw (%esi), %cx )
25143 leal 2(%esi), %esi
25144 -DST( movw %cx, (%edi) )
25145 +DST( movw %cx, %es:(%edi) )
25146 leal 2(%edi), %edi
25147 je 6f
25148 shll $16,%ecx
25149 SRC(5: movb (%esi), %cl )
25150 -DST( movb %cl, (%edi) )
25151 +DST( movb %cl, %es:(%edi) )
25152 6: addl %ecx, %eax
25153 adcl $0, %eax
25154 7:
25155 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
25156
25157 6001:
25158 movl ARGBASE+20(%esp), %ebx # src_err_ptr
25159 - movl $-EFAULT, (%ebx)
25160 + movl $-EFAULT, %ss:(%ebx)
25161
25162 # zero the complete destination - computing the rest
25163 # is too much work
25164 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
25165
25166 6002:
25167 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25168 - movl $-EFAULT,(%ebx)
25169 + movl $-EFAULT,%ss:(%ebx)
25170 jmp 5000b
25171
25172 .previous
25173
25174 + pushl_cfi %ss
25175 + popl_cfi %ds
25176 + pushl_cfi %ss
25177 + popl_cfi %es
25178 popl_cfi %ebx
25179 CFI_RESTORE ebx
25180 popl_cfi %esi
25181 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
25182 popl_cfi %ecx # equivalent to addl $4,%esp
25183 ret
25184 CFI_ENDPROC
25185 -ENDPROC(csum_partial_copy_generic)
25186 +ENDPROC(csum_partial_copy_generic_to_user)
25187
25188 #else
25189
25190 /* Version for PentiumII/PPro */
25191
25192 #define ROUND1(x) \
25193 + nop; nop; nop; \
25194 SRC(movl x(%esi), %ebx ) ; \
25195 addl %ebx, %eax ; \
25196 - DST(movl %ebx, x(%edi) ) ;
25197 + DST(movl %ebx, %es:x(%edi)) ;
25198
25199 #define ROUND(x) \
25200 + nop; nop; nop; \
25201 SRC(movl x(%esi), %ebx ) ; \
25202 adcl %ebx, %eax ; \
25203 - DST(movl %ebx, x(%edi) ) ;
25204 + DST(movl %ebx, %es:x(%edi)) ;
25205
25206 #define ARGBASE 12
25207 -
25208 -ENTRY(csum_partial_copy_generic)
25209 +
25210 +ENTRY(csum_partial_copy_generic_to_user)
25211 CFI_STARTPROC
25212 +
25213 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25214 + pushl_cfi %gs
25215 + popl_cfi %es
25216 + jmp csum_partial_copy_generic
25217 +#endif
25218 +
25219 +ENTRY(csum_partial_copy_generic_from_user)
25220 +
25221 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25222 + pushl_cfi %gs
25223 + popl_cfi %ds
25224 +#endif
25225 +
25226 +ENTRY(csum_partial_copy_generic)
25227 pushl_cfi %ebx
25228 CFI_REL_OFFSET ebx, 0
25229 pushl_cfi %edi
25230 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25231 subl %ebx, %edi
25232 lea -1(%esi),%edx
25233 andl $-32,%edx
25234 - lea 3f(%ebx,%ebx), %ebx
25235 + lea 3f(%ebx,%ebx,2), %ebx
25236 testl %esi, %esi
25237 jmp *%ebx
25238 1: addl $64,%esi
25239 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25240 jb 5f
25241 SRC( movw (%esi), %dx )
25242 leal 2(%esi), %esi
25243 -DST( movw %dx, (%edi) )
25244 +DST( movw %dx, %es:(%edi) )
25245 leal 2(%edi), %edi
25246 je 6f
25247 shll $16,%edx
25248 5:
25249 SRC( movb (%esi), %dl )
25250 -DST( movb %dl, (%edi) )
25251 +DST( movb %dl, %es:(%edi) )
25252 6: addl %edx, %eax
25253 adcl $0, %eax
25254 7:
25255 .section .fixup, "ax"
25256 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25257 - movl $-EFAULT, (%ebx)
25258 + movl $-EFAULT, %ss:(%ebx)
25259 # zero the complete destination (computing the rest is too much work)
25260 movl ARGBASE+8(%esp),%edi # dst
25261 movl ARGBASE+12(%esp),%ecx # len
25262 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25263 rep; stosb
25264 jmp 7b
25265 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25266 - movl $-EFAULT, (%ebx)
25267 + movl $-EFAULT, %ss:(%ebx)
25268 jmp 7b
25269 .previous
25270
25271 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25272 + pushl_cfi %ss
25273 + popl_cfi %ds
25274 + pushl_cfi %ss
25275 + popl_cfi %es
25276 +#endif
25277 +
25278 popl_cfi %esi
25279 CFI_RESTORE esi
25280 popl_cfi %edi
25281 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25282 CFI_RESTORE ebx
25283 ret
25284 CFI_ENDPROC
25285 -ENDPROC(csum_partial_copy_generic)
25286 +ENDPROC(csum_partial_copy_generic_to_user)
25287
25288 #undef ROUND
25289 #undef ROUND1
25290 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25291 index f2145cf..cea889d 100644
25292 --- a/arch/x86/lib/clear_page_64.S
25293 +++ b/arch/x86/lib/clear_page_64.S
25294 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25295 movl $4096/8,%ecx
25296 xorl %eax,%eax
25297 rep stosq
25298 + pax_force_retaddr
25299 ret
25300 CFI_ENDPROC
25301 ENDPROC(clear_page_c)
25302 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25303 movl $4096,%ecx
25304 xorl %eax,%eax
25305 rep stosb
25306 + pax_force_retaddr
25307 ret
25308 CFI_ENDPROC
25309 ENDPROC(clear_page_c_e)
25310 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25311 leaq 64(%rdi),%rdi
25312 jnz .Lloop
25313 nop
25314 + pax_force_retaddr
25315 ret
25316 CFI_ENDPROC
25317 .Lclear_page_end:
25318 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25319
25320 #include <asm/cpufeature.h>
25321
25322 - .section .altinstr_replacement,"ax"
25323 + .section .altinstr_replacement,"a"
25324 1: .byte 0xeb /* jmp <disp8> */
25325 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25326 2: .byte 0xeb /* jmp <disp8> */
25327 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25328 index 1e572c5..2a162cd 100644
25329 --- a/arch/x86/lib/cmpxchg16b_emu.S
25330 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25331 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25332
25333 popf
25334 mov $1, %al
25335 + pax_force_retaddr
25336 ret
25337
25338 not_same:
25339 popf
25340 xor %al,%al
25341 + pax_force_retaddr
25342 ret
25343
25344 CFI_ENDPROC
25345 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25346 index 176cca6..1166c50 100644
25347 --- a/arch/x86/lib/copy_page_64.S
25348 +++ b/arch/x86/lib/copy_page_64.S
25349 @@ -9,6 +9,7 @@ copy_page_rep:
25350 CFI_STARTPROC
25351 movl $4096/8, %ecx
25352 rep movsq
25353 + pax_force_retaddr
25354 ret
25355 CFI_ENDPROC
25356 ENDPROC(copy_page_rep)
25357 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25358
25359 ENTRY(copy_page)
25360 CFI_STARTPROC
25361 - subq $2*8, %rsp
25362 - CFI_ADJUST_CFA_OFFSET 2*8
25363 + subq $3*8, %rsp
25364 + CFI_ADJUST_CFA_OFFSET 3*8
25365 movq %rbx, (%rsp)
25366 CFI_REL_OFFSET rbx, 0
25367 movq %r12, 1*8(%rsp)
25368 CFI_REL_OFFSET r12, 1*8
25369 + movq %r13, 2*8(%rsp)
25370 + CFI_REL_OFFSET r13, 2*8
25371
25372 movl $(4096/64)-5, %ecx
25373 .p2align 4
25374 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25375 movq 0x8*2(%rsi), %rdx
25376 movq 0x8*3(%rsi), %r8
25377 movq 0x8*4(%rsi), %r9
25378 - movq 0x8*5(%rsi), %r10
25379 + movq 0x8*5(%rsi), %r13
25380 movq 0x8*6(%rsi), %r11
25381 movq 0x8*7(%rsi), %r12
25382
25383 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25384 movq %rdx, 0x8*2(%rdi)
25385 movq %r8, 0x8*3(%rdi)
25386 movq %r9, 0x8*4(%rdi)
25387 - movq %r10, 0x8*5(%rdi)
25388 + movq %r13, 0x8*5(%rdi)
25389 movq %r11, 0x8*6(%rdi)
25390 movq %r12, 0x8*7(%rdi)
25391
25392 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25393 movq 0x8*2(%rsi), %rdx
25394 movq 0x8*3(%rsi), %r8
25395 movq 0x8*4(%rsi), %r9
25396 - movq 0x8*5(%rsi), %r10
25397 + movq 0x8*5(%rsi), %r13
25398 movq 0x8*6(%rsi), %r11
25399 movq 0x8*7(%rsi), %r12
25400
25401 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25402 movq %rdx, 0x8*2(%rdi)
25403 movq %r8, 0x8*3(%rdi)
25404 movq %r9, 0x8*4(%rdi)
25405 - movq %r10, 0x8*5(%rdi)
25406 + movq %r13, 0x8*5(%rdi)
25407 movq %r11, 0x8*6(%rdi)
25408 movq %r12, 0x8*7(%rdi)
25409
25410 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25411 CFI_RESTORE rbx
25412 movq 1*8(%rsp), %r12
25413 CFI_RESTORE r12
25414 - addq $2*8, %rsp
25415 - CFI_ADJUST_CFA_OFFSET -2*8
25416 + movq 2*8(%rsp), %r13
25417 + CFI_RESTORE r13
25418 + addq $3*8, %rsp
25419 + CFI_ADJUST_CFA_OFFSET -3*8
25420 + pax_force_retaddr
25421 ret
25422 .Lcopy_page_end:
25423 CFI_ENDPROC
25424 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25425
25426 #include <asm/cpufeature.h>
25427
25428 - .section .altinstr_replacement,"ax"
25429 + .section .altinstr_replacement,"a"
25430 1: .byte 0xeb /* jmp <disp8> */
25431 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25432 2:
25433 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25434 index a30ca15..d25fab6 100644
25435 --- a/arch/x86/lib/copy_user_64.S
25436 +++ b/arch/x86/lib/copy_user_64.S
25437 @@ -18,6 +18,7 @@
25438 #include <asm/alternative-asm.h>
25439 #include <asm/asm.h>
25440 #include <asm/smap.h>
25441 +#include <asm/pgtable.h>
25442
25443 /*
25444 * By placing feature2 after feature1 in altinstructions section, we logically
25445 @@ -31,7 +32,7 @@
25446 .byte 0xe9 /* 32bit jump */
25447 .long \orig-1f /* by default jump to orig */
25448 1:
25449 - .section .altinstr_replacement,"ax"
25450 + .section .altinstr_replacement,"a"
25451 2: .byte 0xe9 /* near jump with 32bit immediate */
25452 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25453 3: .byte 0xe9 /* near jump with 32bit immediate */
25454 @@ -70,47 +71,20 @@
25455 #endif
25456 .endm
25457
25458 -/* Standard copy_to_user with segment limit checking */
25459 -ENTRY(_copy_to_user)
25460 - CFI_STARTPROC
25461 - GET_THREAD_INFO(%rax)
25462 - movq %rdi,%rcx
25463 - addq %rdx,%rcx
25464 - jc bad_to_user
25465 - cmpq TI_addr_limit(%rax),%rcx
25466 - ja bad_to_user
25467 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25468 - copy_user_generic_unrolled,copy_user_generic_string, \
25469 - copy_user_enhanced_fast_string
25470 - CFI_ENDPROC
25471 -ENDPROC(_copy_to_user)
25472 -
25473 -/* Standard copy_from_user with segment limit checking */
25474 -ENTRY(_copy_from_user)
25475 - CFI_STARTPROC
25476 - GET_THREAD_INFO(%rax)
25477 - movq %rsi,%rcx
25478 - addq %rdx,%rcx
25479 - jc bad_from_user
25480 - cmpq TI_addr_limit(%rax),%rcx
25481 - ja bad_from_user
25482 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25483 - copy_user_generic_unrolled,copy_user_generic_string, \
25484 - copy_user_enhanced_fast_string
25485 - CFI_ENDPROC
25486 -ENDPROC(_copy_from_user)
25487 -
25488 .section .fixup,"ax"
25489 /* must zero dest */
25490 ENTRY(bad_from_user)
25491 bad_from_user:
25492 CFI_STARTPROC
25493 + testl %edx,%edx
25494 + js bad_to_user
25495 movl %edx,%ecx
25496 xorl %eax,%eax
25497 rep
25498 stosb
25499 bad_to_user:
25500 movl %edx,%eax
25501 + pax_force_retaddr
25502 ret
25503 CFI_ENDPROC
25504 ENDPROC(bad_from_user)
25505 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25506 jz 17f
25507 1: movq (%rsi),%r8
25508 2: movq 1*8(%rsi),%r9
25509 -3: movq 2*8(%rsi),%r10
25510 +3: movq 2*8(%rsi),%rax
25511 4: movq 3*8(%rsi),%r11
25512 5: movq %r8,(%rdi)
25513 6: movq %r9,1*8(%rdi)
25514 -7: movq %r10,2*8(%rdi)
25515 +7: movq %rax,2*8(%rdi)
25516 8: movq %r11,3*8(%rdi)
25517 9: movq 4*8(%rsi),%r8
25518 10: movq 5*8(%rsi),%r9
25519 -11: movq 6*8(%rsi),%r10
25520 +11: movq 6*8(%rsi),%rax
25521 12: movq 7*8(%rsi),%r11
25522 13: movq %r8,4*8(%rdi)
25523 14: movq %r9,5*8(%rdi)
25524 -15: movq %r10,6*8(%rdi)
25525 +15: movq %rax,6*8(%rdi)
25526 16: movq %r11,7*8(%rdi)
25527 leaq 64(%rsi),%rsi
25528 leaq 64(%rdi),%rdi
25529 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25530 jnz 21b
25531 23: xor %eax,%eax
25532 ASM_CLAC
25533 + pax_force_retaddr
25534 ret
25535
25536 .section .fixup,"ax"
25537 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25538 movsb
25539 4: xorl %eax,%eax
25540 ASM_CLAC
25541 + pax_force_retaddr
25542 ret
25543
25544 .section .fixup,"ax"
25545 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25546 movsb
25547 2: xorl %eax,%eax
25548 ASM_CLAC
25549 + pax_force_retaddr
25550 ret
25551
25552 .section .fixup,"ax"
25553 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25554 index 6a4f43c..f5f9e26 100644
25555 --- a/arch/x86/lib/copy_user_nocache_64.S
25556 +++ b/arch/x86/lib/copy_user_nocache_64.S
25557 @@ -8,6 +8,7 @@
25558
25559 #include <linux/linkage.h>
25560 #include <asm/dwarf2.h>
25561 +#include <asm/alternative-asm.h>
25562
25563 #define FIX_ALIGNMENT 1
25564
25565 @@ -16,6 +17,7 @@
25566 #include <asm/thread_info.h>
25567 #include <asm/asm.h>
25568 #include <asm/smap.h>
25569 +#include <asm/pgtable.h>
25570
25571 .macro ALIGN_DESTINATION
25572 #ifdef FIX_ALIGNMENT
25573 @@ -49,6 +51,15 @@
25574 */
25575 ENTRY(__copy_user_nocache)
25576 CFI_STARTPROC
25577 +
25578 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25579 + mov $PAX_USER_SHADOW_BASE,%rcx
25580 + cmp %rcx,%rsi
25581 + jae 1f
25582 + add %rcx,%rsi
25583 +1:
25584 +#endif
25585 +
25586 ASM_STAC
25587 cmpl $8,%edx
25588 jb 20f /* less then 8 bytes, go to byte copy loop */
25589 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25590 jz 17f
25591 1: movq (%rsi),%r8
25592 2: movq 1*8(%rsi),%r9
25593 -3: movq 2*8(%rsi),%r10
25594 +3: movq 2*8(%rsi),%rax
25595 4: movq 3*8(%rsi),%r11
25596 5: movnti %r8,(%rdi)
25597 6: movnti %r9,1*8(%rdi)
25598 -7: movnti %r10,2*8(%rdi)
25599 +7: movnti %rax,2*8(%rdi)
25600 8: movnti %r11,3*8(%rdi)
25601 9: movq 4*8(%rsi),%r8
25602 10: movq 5*8(%rsi),%r9
25603 -11: movq 6*8(%rsi),%r10
25604 +11: movq 6*8(%rsi),%rax
25605 12: movq 7*8(%rsi),%r11
25606 13: movnti %r8,4*8(%rdi)
25607 14: movnti %r9,5*8(%rdi)
25608 -15: movnti %r10,6*8(%rdi)
25609 +15: movnti %rax,6*8(%rdi)
25610 16: movnti %r11,7*8(%rdi)
25611 leaq 64(%rsi),%rsi
25612 leaq 64(%rdi),%rdi
25613 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25614 23: xorl %eax,%eax
25615 ASM_CLAC
25616 sfence
25617 + pax_force_retaddr
25618 ret
25619
25620 .section .fixup,"ax"
25621 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25622 index 2419d5f..953ee51 100644
25623 --- a/arch/x86/lib/csum-copy_64.S
25624 +++ b/arch/x86/lib/csum-copy_64.S
25625 @@ -9,6 +9,7 @@
25626 #include <asm/dwarf2.h>
25627 #include <asm/errno.h>
25628 #include <asm/asm.h>
25629 +#include <asm/alternative-asm.h>
25630
25631 /*
25632 * Checksum copy with exception handling.
25633 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25634 CFI_RESTORE rbp
25635 addq $7*8, %rsp
25636 CFI_ADJUST_CFA_OFFSET -7*8
25637 + pax_force_retaddr 0, 1
25638 ret
25639 CFI_RESTORE_STATE
25640
25641 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25642 index 25b7ae8..169fafc 100644
25643 --- a/arch/x86/lib/csum-wrappers_64.c
25644 +++ b/arch/x86/lib/csum-wrappers_64.c
25645 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25646 len -= 2;
25647 }
25648 }
25649 - isum = csum_partial_copy_generic((__force const void *)src,
25650 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25651 dst, len, isum, errp, NULL);
25652 if (unlikely(*errp))
25653 goto out_err;
25654 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25655 }
25656
25657 *errp = 0;
25658 - return csum_partial_copy_generic(src, (void __force *)dst,
25659 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25660 len, isum, NULL, errp);
25661 }
25662 EXPORT_SYMBOL(csum_partial_copy_to_user);
25663 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25664 index 156b9c8..b144132 100644
25665 --- a/arch/x86/lib/getuser.S
25666 +++ b/arch/x86/lib/getuser.S
25667 @@ -34,17 +34,40 @@
25668 #include <asm/thread_info.h>
25669 #include <asm/asm.h>
25670 #include <asm/smap.h>
25671 +#include <asm/segment.h>
25672 +#include <asm/pgtable.h>
25673 +#include <asm/alternative-asm.h>
25674 +
25675 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25676 +#define __copyuser_seg gs;
25677 +#else
25678 +#define __copyuser_seg
25679 +#endif
25680
25681 .text
25682 ENTRY(__get_user_1)
25683 CFI_STARTPROC
25684 +
25685 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25686 GET_THREAD_INFO(%_ASM_DX)
25687 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25688 jae bad_get_user
25689 ASM_STAC
25690 -1: movzb (%_ASM_AX),%edx
25691 +
25692 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25693 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25694 + cmp %_ASM_DX,%_ASM_AX
25695 + jae 1234f
25696 + add %_ASM_DX,%_ASM_AX
25697 +1234:
25698 +#endif
25699 +
25700 +#endif
25701 +
25702 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25703 xor %eax,%eax
25704 ASM_CLAC
25705 + pax_force_retaddr
25706 ret
25707 CFI_ENDPROC
25708 ENDPROC(__get_user_1)
25709 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25710 ENTRY(__get_user_2)
25711 CFI_STARTPROC
25712 add $1,%_ASM_AX
25713 +
25714 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25715 jc bad_get_user
25716 GET_THREAD_INFO(%_ASM_DX)
25717 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25718 jae bad_get_user
25719 ASM_STAC
25720 -2: movzwl -1(%_ASM_AX),%edx
25721 +
25722 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25723 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25724 + cmp %_ASM_DX,%_ASM_AX
25725 + jae 1234f
25726 + add %_ASM_DX,%_ASM_AX
25727 +1234:
25728 +#endif
25729 +
25730 +#endif
25731 +
25732 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25733 xor %eax,%eax
25734 ASM_CLAC
25735 + pax_force_retaddr
25736 ret
25737 CFI_ENDPROC
25738 ENDPROC(__get_user_2)
25739 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25740 ENTRY(__get_user_4)
25741 CFI_STARTPROC
25742 add $3,%_ASM_AX
25743 +
25744 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25745 jc bad_get_user
25746 GET_THREAD_INFO(%_ASM_DX)
25747 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25748 jae bad_get_user
25749 ASM_STAC
25750 -3: mov -3(%_ASM_AX),%edx
25751 +
25752 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25753 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25754 + cmp %_ASM_DX,%_ASM_AX
25755 + jae 1234f
25756 + add %_ASM_DX,%_ASM_AX
25757 +1234:
25758 +#endif
25759 +
25760 +#endif
25761 +
25762 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25763 xor %eax,%eax
25764 ASM_CLAC
25765 + pax_force_retaddr
25766 ret
25767 CFI_ENDPROC
25768 ENDPROC(__get_user_4)
25769 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25770 GET_THREAD_INFO(%_ASM_DX)
25771 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25772 jae bad_get_user
25773 +
25774 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25775 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25776 + cmp %_ASM_DX,%_ASM_AX
25777 + jae 1234f
25778 + add %_ASM_DX,%_ASM_AX
25779 +1234:
25780 +#endif
25781 +
25782 ASM_STAC
25783 4: movq -7(%_ASM_AX),%_ASM_DX
25784 xor %eax,%eax
25785 ASM_CLAC
25786 + pax_force_retaddr
25787 ret
25788 CFI_ENDPROC
25789 ENDPROC(__get_user_8)
25790 @@ -101,6 +162,7 @@ bad_get_user:
25791 xor %edx,%edx
25792 mov $(-EFAULT),%_ASM_AX
25793 ASM_CLAC
25794 + pax_force_retaddr
25795 ret
25796 CFI_ENDPROC
25797 END(bad_get_user)
25798 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25799 index 54fcffe..7be149e 100644
25800 --- a/arch/x86/lib/insn.c
25801 +++ b/arch/x86/lib/insn.c
25802 @@ -20,8 +20,10 @@
25803
25804 #ifdef __KERNEL__
25805 #include <linux/string.h>
25806 +#include <asm/pgtable_types.h>
25807 #else
25808 #include <string.h>
25809 +#define ktla_ktva(addr) addr
25810 #endif
25811 #include <asm/inat.h>
25812 #include <asm/insn.h>
25813 @@ -53,8 +55,8 @@
25814 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25815 {
25816 memset(insn, 0, sizeof(*insn));
25817 - insn->kaddr = kaddr;
25818 - insn->next_byte = kaddr;
25819 + insn->kaddr = ktla_ktva(kaddr);
25820 + insn->next_byte = ktla_ktva(kaddr);
25821 insn->x86_64 = x86_64 ? 1 : 0;
25822 insn->opnd_bytes = 4;
25823 if (x86_64)
25824 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25825 index 05a95e7..326f2fa 100644
25826 --- a/arch/x86/lib/iomap_copy_64.S
25827 +++ b/arch/x86/lib/iomap_copy_64.S
25828 @@ -17,6 +17,7 @@
25829
25830 #include <linux/linkage.h>
25831 #include <asm/dwarf2.h>
25832 +#include <asm/alternative-asm.h>
25833
25834 /*
25835 * override generic version in lib/iomap_copy.c
25836 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25837 CFI_STARTPROC
25838 movl %edx,%ecx
25839 rep movsd
25840 + pax_force_retaddr
25841 ret
25842 CFI_ENDPROC
25843 ENDPROC(__iowrite32_copy)
25844 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25845 index 1c273be..da9cc0e 100644
25846 --- a/arch/x86/lib/memcpy_64.S
25847 +++ b/arch/x86/lib/memcpy_64.S
25848 @@ -33,6 +33,7 @@
25849 rep movsq
25850 movl %edx, %ecx
25851 rep movsb
25852 + pax_force_retaddr
25853 ret
25854 .Lmemcpy_e:
25855 .previous
25856 @@ -49,6 +50,7 @@
25857 movq %rdi, %rax
25858 movq %rdx, %rcx
25859 rep movsb
25860 + pax_force_retaddr
25861 ret
25862 .Lmemcpy_e_e:
25863 .previous
25864 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25865 */
25866 movq 0*8(%rsi), %r8
25867 movq 1*8(%rsi), %r9
25868 - movq 2*8(%rsi), %r10
25869 + movq 2*8(%rsi), %rcx
25870 movq 3*8(%rsi), %r11
25871 leaq 4*8(%rsi), %rsi
25872
25873 movq %r8, 0*8(%rdi)
25874 movq %r9, 1*8(%rdi)
25875 - movq %r10, 2*8(%rdi)
25876 + movq %rcx, 2*8(%rdi)
25877 movq %r11, 3*8(%rdi)
25878 leaq 4*8(%rdi), %rdi
25879 jae .Lcopy_forward_loop
25880 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25881 subq $0x20, %rdx
25882 movq -1*8(%rsi), %r8
25883 movq -2*8(%rsi), %r9
25884 - movq -3*8(%rsi), %r10
25885 + movq -3*8(%rsi), %rcx
25886 movq -4*8(%rsi), %r11
25887 leaq -4*8(%rsi), %rsi
25888 movq %r8, -1*8(%rdi)
25889 movq %r9, -2*8(%rdi)
25890 - movq %r10, -3*8(%rdi)
25891 + movq %rcx, -3*8(%rdi)
25892 movq %r11, -4*8(%rdi)
25893 leaq -4*8(%rdi), %rdi
25894 jae .Lcopy_backward_loop
25895 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25896 */
25897 movq 0*8(%rsi), %r8
25898 movq 1*8(%rsi), %r9
25899 - movq -2*8(%rsi, %rdx), %r10
25900 + movq -2*8(%rsi, %rdx), %rcx
25901 movq -1*8(%rsi, %rdx), %r11
25902 movq %r8, 0*8(%rdi)
25903 movq %r9, 1*8(%rdi)
25904 - movq %r10, -2*8(%rdi, %rdx)
25905 + movq %rcx, -2*8(%rdi, %rdx)
25906 movq %r11, -1*8(%rdi, %rdx)
25907 + pax_force_retaddr
25908 retq
25909 .p2align 4
25910 .Lless_16bytes:
25911 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25912 movq -1*8(%rsi, %rdx), %r9
25913 movq %r8, 0*8(%rdi)
25914 movq %r9, -1*8(%rdi, %rdx)
25915 + pax_force_retaddr
25916 retq
25917 .p2align 4
25918 .Lless_8bytes:
25919 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25920 movl -4(%rsi, %rdx), %r8d
25921 movl %ecx, (%rdi)
25922 movl %r8d, -4(%rdi, %rdx)
25923 + pax_force_retaddr
25924 retq
25925 .p2align 4
25926 .Lless_3bytes:
25927 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25928 movb %cl, (%rdi)
25929
25930 .Lend:
25931 + pax_force_retaddr
25932 retq
25933 CFI_ENDPROC
25934 ENDPROC(memcpy)
25935 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25936 index ee16461..c39c199 100644
25937 --- a/arch/x86/lib/memmove_64.S
25938 +++ b/arch/x86/lib/memmove_64.S
25939 @@ -61,13 +61,13 @@ ENTRY(memmove)
25940 5:
25941 sub $0x20, %rdx
25942 movq 0*8(%rsi), %r11
25943 - movq 1*8(%rsi), %r10
25944 + movq 1*8(%rsi), %rcx
25945 movq 2*8(%rsi), %r9
25946 movq 3*8(%rsi), %r8
25947 leaq 4*8(%rsi), %rsi
25948
25949 movq %r11, 0*8(%rdi)
25950 - movq %r10, 1*8(%rdi)
25951 + movq %rcx, 1*8(%rdi)
25952 movq %r9, 2*8(%rdi)
25953 movq %r8, 3*8(%rdi)
25954 leaq 4*8(%rdi), %rdi
25955 @@ -81,10 +81,10 @@ ENTRY(memmove)
25956 4:
25957 movq %rdx, %rcx
25958 movq -8(%rsi, %rdx), %r11
25959 - lea -8(%rdi, %rdx), %r10
25960 + lea -8(%rdi, %rdx), %r9
25961 shrq $3, %rcx
25962 rep movsq
25963 - movq %r11, (%r10)
25964 + movq %r11, (%r9)
25965 jmp 13f
25966 .Lmemmove_end_forward:
25967
25968 @@ -95,14 +95,14 @@ ENTRY(memmove)
25969 7:
25970 movq %rdx, %rcx
25971 movq (%rsi), %r11
25972 - movq %rdi, %r10
25973 + movq %rdi, %r9
25974 leaq -8(%rsi, %rdx), %rsi
25975 leaq -8(%rdi, %rdx), %rdi
25976 shrq $3, %rcx
25977 std
25978 rep movsq
25979 cld
25980 - movq %r11, (%r10)
25981 + movq %r11, (%r9)
25982 jmp 13f
25983
25984 /*
25985 @@ -127,13 +127,13 @@ ENTRY(memmove)
25986 8:
25987 subq $0x20, %rdx
25988 movq -1*8(%rsi), %r11
25989 - movq -2*8(%rsi), %r10
25990 + movq -2*8(%rsi), %rcx
25991 movq -3*8(%rsi), %r9
25992 movq -4*8(%rsi), %r8
25993 leaq -4*8(%rsi), %rsi
25994
25995 movq %r11, -1*8(%rdi)
25996 - movq %r10, -2*8(%rdi)
25997 + movq %rcx, -2*8(%rdi)
25998 movq %r9, -3*8(%rdi)
25999 movq %r8, -4*8(%rdi)
26000 leaq -4*8(%rdi), %rdi
26001 @@ -151,11 +151,11 @@ ENTRY(memmove)
26002 * Move data from 16 bytes to 31 bytes.
26003 */
26004 movq 0*8(%rsi), %r11
26005 - movq 1*8(%rsi), %r10
26006 + movq 1*8(%rsi), %rcx
26007 movq -2*8(%rsi, %rdx), %r9
26008 movq -1*8(%rsi, %rdx), %r8
26009 movq %r11, 0*8(%rdi)
26010 - movq %r10, 1*8(%rdi)
26011 + movq %rcx, 1*8(%rdi)
26012 movq %r9, -2*8(%rdi, %rdx)
26013 movq %r8, -1*8(%rdi, %rdx)
26014 jmp 13f
26015 @@ -167,9 +167,9 @@ ENTRY(memmove)
26016 * Move data from 8 bytes to 15 bytes.
26017 */
26018 movq 0*8(%rsi), %r11
26019 - movq -1*8(%rsi, %rdx), %r10
26020 + movq -1*8(%rsi, %rdx), %r9
26021 movq %r11, 0*8(%rdi)
26022 - movq %r10, -1*8(%rdi, %rdx)
26023 + movq %r9, -1*8(%rdi, %rdx)
26024 jmp 13f
26025 10:
26026 cmpq $4, %rdx
26027 @@ -178,9 +178,9 @@ ENTRY(memmove)
26028 * Move data from 4 bytes to 7 bytes.
26029 */
26030 movl (%rsi), %r11d
26031 - movl -4(%rsi, %rdx), %r10d
26032 + movl -4(%rsi, %rdx), %r9d
26033 movl %r11d, (%rdi)
26034 - movl %r10d, -4(%rdi, %rdx)
26035 + movl %r9d, -4(%rdi, %rdx)
26036 jmp 13f
26037 11:
26038 cmp $2, %rdx
26039 @@ -189,9 +189,9 @@ ENTRY(memmove)
26040 * Move data from 2 bytes to 3 bytes.
26041 */
26042 movw (%rsi), %r11w
26043 - movw -2(%rsi, %rdx), %r10w
26044 + movw -2(%rsi, %rdx), %r9w
26045 movw %r11w, (%rdi)
26046 - movw %r10w, -2(%rdi, %rdx)
26047 + movw %r9w, -2(%rdi, %rdx)
26048 jmp 13f
26049 12:
26050 cmp $1, %rdx
26051 @@ -202,6 +202,7 @@ ENTRY(memmove)
26052 movb (%rsi), %r11b
26053 movb %r11b, (%rdi)
26054 13:
26055 + pax_force_retaddr
26056 retq
26057 CFI_ENDPROC
26058
26059 @@ -210,6 +211,7 @@ ENTRY(memmove)
26060 /* Forward moving data. */
26061 movq %rdx, %rcx
26062 rep movsb
26063 + pax_force_retaddr
26064 retq
26065 .Lmemmove_end_forward_efs:
26066 .previous
26067 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
26068 index 2dcb380..963660a 100644
26069 --- a/arch/x86/lib/memset_64.S
26070 +++ b/arch/x86/lib/memset_64.S
26071 @@ -30,6 +30,7 @@
26072 movl %edx,%ecx
26073 rep stosb
26074 movq %r9,%rax
26075 + pax_force_retaddr
26076 ret
26077 .Lmemset_e:
26078 .previous
26079 @@ -52,6 +53,7 @@
26080 movq %rdx,%rcx
26081 rep stosb
26082 movq %r9,%rax
26083 + pax_force_retaddr
26084 ret
26085 .Lmemset_e_e:
26086 .previous
26087 @@ -59,7 +61,7 @@
26088 ENTRY(memset)
26089 ENTRY(__memset)
26090 CFI_STARTPROC
26091 - movq %rdi,%r10
26092 + movq %rdi,%r11
26093
26094 /* expand byte value */
26095 movzbl %sil,%ecx
26096 @@ -117,7 +119,8 @@ ENTRY(__memset)
26097 jnz .Lloop_1
26098
26099 .Lende:
26100 - movq %r10,%rax
26101 + movq %r11,%rax
26102 + pax_force_retaddr
26103 ret
26104
26105 CFI_RESTORE_STATE
26106 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
26107 index c9f2d9b..e7fd2c0 100644
26108 --- a/arch/x86/lib/mmx_32.c
26109 +++ b/arch/x86/lib/mmx_32.c
26110 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26111 {
26112 void *p;
26113 int i;
26114 + unsigned long cr0;
26115
26116 if (unlikely(in_interrupt()))
26117 return __memcpy(to, from, len);
26118 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26119 kernel_fpu_begin();
26120
26121 __asm__ __volatile__ (
26122 - "1: prefetch (%0)\n" /* This set is 28 bytes */
26123 - " prefetch 64(%0)\n"
26124 - " prefetch 128(%0)\n"
26125 - " prefetch 192(%0)\n"
26126 - " prefetch 256(%0)\n"
26127 + "1: prefetch (%1)\n" /* This set is 28 bytes */
26128 + " prefetch 64(%1)\n"
26129 + " prefetch 128(%1)\n"
26130 + " prefetch 192(%1)\n"
26131 + " prefetch 256(%1)\n"
26132 "2: \n"
26133 ".section .fixup, \"ax\"\n"
26134 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26135 + "3: \n"
26136 +
26137 +#ifdef CONFIG_PAX_KERNEXEC
26138 + " movl %%cr0, %0\n"
26139 + " movl %0, %%eax\n"
26140 + " andl $0xFFFEFFFF, %%eax\n"
26141 + " movl %%eax, %%cr0\n"
26142 +#endif
26143 +
26144 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26145 +
26146 +#ifdef CONFIG_PAX_KERNEXEC
26147 + " movl %0, %%cr0\n"
26148 +#endif
26149 +
26150 " jmp 2b\n"
26151 ".previous\n"
26152 _ASM_EXTABLE(1b, 3b)
26153 - : : "r" (from));
26154 + : "=&r" (cr0) : "r" (from) : "ax");
26155
26156 for ( ; i > 5; i--) {
26157 __asm__ __volatile__ (
26158 - "1: prefetch 320(%0)\n"
26159 - "2: movq (%0), %%mm0\n"
26160 - " movq 8(%0), %%mm1\n"
26161 - " movq 16(%0), %%mm2\n"
26162 - " movq 24(%0), %%mm3\n"
26163 - " movq %%mm0, (%1)\n"
26164 - " movq %%mm1, 8(%1)\n"
26165 - " movq %%mm2, 16(%1)\n"
26166 - " movq %%mm3, 24(%1)\n"
26167 - " movq 32(%0), %%mm0\n"
26168 - " movq 40(%0), %%mm1\n"
26169 - " movq 48(%0), %%mm2\n"
26170 - " movq 56(%0), %%mm3\n"
26171 - " movq %%mm0, 32(%1)\n"
26172 - " movq %%mm1, 40(%1)\n"
26173 - " movq %%mm2, 48(%1)\n"
26174 - " movq %%mm3, 56(%1)\n"
26175 + "1: prefetch 320(%1)\n"
26176 + "2: movq (%1), %%mm0\n"
26177 + " movq 8(%1), %%mm1\n"
26178 + " movq 16(%1), %%mm2\n"
26179 + " movq 24(%1), %%mm3\n"
26180 + " movq %%mm0, (%2)\n"
26181 + " movq %%mm1, 8(%2)\n"
26182 + " movq %%mm2, 16(%2)\n"
26183 + " movq %%mm3, 24(%2)\n"
26184 + " movq 32(%1), %%mm0\n"
26185 + " movq 40(%1), %%mm1\n"
26186 + " movq 48(%1), %%mm2\n"
26187 + " movq 56(%1), %%mm3\n"
26188 + " movq %%mm0, 32(%2)\n"
26189 + " movq %%mm1, 40(%2)\n"
26190 + " movq %%mm2, 48(%2)\n"
26191 + " movq %%mm3, 56(%2)\n"
26192 ".section .fixup, \"ax\"\n"
26193 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26194 + "3:\n"
26195 +
26196 +#ifdef CONFIG_PAX_KERNEXEC
26197 + " movl %%cr0, %0\n"
26198 + " movl %0, %%eax\n"
26199 + " andl $0xFFFEFFFF, %%eax\n"
26200 + " movl %%eax, %%cr0\n"
26201 +#endif
26202 +
26203 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26204 +
26205 +#ifdef CONFIG_PAX_KERNEXEC
26206 + " movl %0, %%cr0\n"
26207 +#endif
26208 +
26209 " jmp 2b\n"
26210 ".previous\n"
26211 _ASM_EXTABLE(1b, 3b)
26212 - : : "r" (from), "r" (to) : "memory");
26213 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26214
26215 from += 64;
26216 to += 64;
26217 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26218 static void fast_copy_page(void *to, void *from)
26219 {
26220 int i;
26221 + unsigned long cr0;
26222
26223 kernel_fpu_begin();
26224
26225 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26226 * but that is for later. -AV
26227 */
26228 __asm__ __volatile__(
26229 - "1: prefetch (%0)\n"
26230 - " prefetch 64(%0)\n"
26231 - " prefetch 128(%0)\n"
26232 - " prefetch 192(%0)\n"
26233 - " prefetch 256(%0)\n"
26234 + "1: prefetch (%1)\n"
26235 + " prefetch 64(%1)\n"
26236 + " prefetch 128(%1)\n"
26237 + " prefetch 192(%1)\n"
26238 + " prefetch 256(%1)\n"
26239 "2: \n"
26240 ".section .fixup, \"ax\"\n"
26241 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26242 + "3: \n"
26243 +
26244 +#ifdef CONFIG_PAX_KERNEXEC
26245 + " movl %%cr0, %0\n"
26246 + " movl %0, %%eax\n"
26247 + " andl $0xFFFEFFFF, %%eax\n"
26248 + " movl %%eax, %%cr0\n"
26249 +#endif
26250 +
26251 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26252 +
26253 +#ifdef CONFIG_PAX_KERNEXEC
26254 + " movl %0, %%cr0\n"
26255 +#endif
26256 +
26257 " jmp 2b\n"
26258 ".previous\n"
26259 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26260 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26261
26262 for (i = 0; i < (4096-320)/64; i++) {
26263 __asm__ __volatile__ (
26264 - "1: prefetch 320(%0)\n"
26265 - "2: movq (%0), %%mm0\n"
26266 - " movntq %%mm0, (%1)\n"
26267 - " movq 8(%0), %%mm1\n"
26268 - " movntq %%mm1, 8(%1)\n"
26269 - " movq 16(%0), %%mm2\n"
26270 - " movntq %%mm2, 16(%1)\n"
26271 - " movq 24(%0), %%mm3\n"
26272 - " movntq %%mm3, 24(%1)\n"
26273 - " movq 32(%0), %%mm4\n"
26274 - " movntq %%mm4, 32(%1)\n"
26275 - " movq 40(%0), %%mm5\n"
26276 - " movntq %%mm5, 40(%1)\n"
26277 - " movq 48(%0), %%mm6\n"
26278 - " movntq %%mm6, 48(%1)\n"
26279 - " movq 56(%0), %%mm7\n"
26280 - " movntq %%mm7, 56(%1)\n"
26281 + "1: prefetch 320(%1)\n"
26282 + "2: movq (%1), %%mm0\n"
26283 + " movntq %%mm0, (%2)\n"
26284 + " movq 8(%1), %%mm1\n"
26285 + " movntq %%mm1, 8(%2)\n"
26286 + " movq 16(%1), %%mm2\n"
26287 + " movntq %%mm2, 16(%2)\n"
26288 + " movq 24(%1), %%mm3\n"
26289 + " movntq %%mm3, 24(%2)\n"
26290 + " movq 32(%1), %%mm4\n"
26291 + " movntq %%mm4, 32(%2)\n"
26292 + " movq 40(%1), %%mm5\n"
26293 + " movntq %%mm5, 40(%2)\n"
26294 + " movq 48(%1), %%mm6\n"
26295 + " movntq %%mm6, 48(%2)\n"
26296 + " movq 56(%1), %%mm7\n"
26297 + " movntq %%mm7, 56(%2)\n"
26298 ".section .fixup, \"ax\"\n"
26299 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26300 + "3:\n"
26301 +
26302 +#ifdef CONFIG_PAX_KERNEXEC
26303 + " movl %%cr0, %0\n"
26304 + " movl %0, %%eax\n"
26305 + " andl $0xFFFEFFFF, %%eax\n"
26306 + " movl %%eax, %%cr0\n"
26307 +#endif
26308 +
26309 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26310 +
26311 +#ifdef CONFIG_PAX_KERNEXEC
26312 + " movl %0, %%cr0\n"
26313 +#endif
26314 +
26315 " jmp 2b\n"
26316 ".previous\n"
26317 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26318 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26319
26320 from += 64;
26321 to += 64;
26322 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26323 static void fast_copy_page(void *to, void *from)
26324 {
26325 int i;
26326 + unsigned long cr0;
26327
26328 kernel_fpu_begin();
26329
26330 __asm__ __volatile__ (
26331 - "1: prefetch (%0)\n"
26332 - " prefetch 64(%0)\n"
26333 - " prefetch 128(%0)\n"
26334 - " prefetch 192(%0)\n"
26335 - " prefetch 256(%0)\n"
26336 + "1: prefetch (%1)\n"
26337 + " prefetch 64(%1)\n"
26338 + " prefetch 128(%1)\n"
26339 + " prefetch 192(%1)\n"
26340 + " prefetch 256(%1)\n"
26341 "2: \n"
26342 ".section .fixup, \"ax\"\n"
26343 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26344 + "3: \n"
26345 +
26346 +#ifdef CONFIG_PAX_KERNEXEC
26347 + " movl %%cr0, %0\n"
26348 + " movl %0, %%eax\n"
26349 + " andl $0xFFFEFFFF, %%eax\n"
26350 + " movl %%eax, %%cr0\n"
26351 +#endif
26352 +
26353 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26354 +
26355 +#ifdef CONFIG_PAX_KERNEXEC
26356 + " movl %0, %%cr0\n"
26357 +#endif
26358 +
26359 " jmp 2b\n"
26360 ".previous\n"
26361 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26362 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26363
26364 for (i = 0; i < 4096/64; i++) {
26365 __asm__ __volatile__ (
26366 - "1: prefetch 320(%0)\n"
26367 - "2: movq (%0), %%mm0\n"
26368 - " movq 8(%0), %%mm1\n"
26369 - " movq 16(%0), %%mm2\n"
26370 - " movq 24(%0), %%mm3\n"
26371 - " movq %%mm0, (%1)\n"
26372 - " movq %%mm1, 8(%1)\n"
26373 - " movq %%mm2, 16(%1)\n"
26374 - " movq %%mm3, 24(%1)\n"
26375 - " movq 32(%0), %%mm0\n"
26376 - " movq 40(%0), %%mm1\n"
26377 - " movq 48(%0), %%mm2\n"
26378 - " movq 56(%0), %%mm3\n"
26379 - " movq %%mm0, 32(%1)\n"
26380 - " movq %%mm1, 40(%1)\n"
26381 - " movq %%mm2, 48(%1)\n"
26382 - " movq %%mm3, 56(%1)\n"
26383 + "1: prefetch 320(%1)\n"
26384 + "2: movq (%1), %%mm0\n"
26385 + " movq 8(%1), %%mm1\n"
26386 + " movq 16(%1), %%mm2\n"
26387 + " movq 24(%1), %%mm3\n"
26388 + " movq %%mm0, (%2)\n"
26389 + " movq %%mm1, 8(%2)\n"
26390 + " movq %%mm2, 16(%2)\n"
26391 + " movq %%mm3, 24(%2)\n"
26392 + " movq 32(%1), %%mm0\n"
26393 + " movq 40(%1), %%mm1\n"
26394 + " movq 48(%1), %%mm2\n"
26395 + " movq 56(%1), %%mm3\n"
26396 + " movq %%mm0, 32(%2)\n"
26397 + " movq %%mm1, 40(%2)\n"
26398 + " movq %%mm2, 48(%2)\n"
26399 + " movq %%mm3, 56(%2)\n"
26400 ".section .fixup, \"ax\"\n"
26401 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26402 + "3:\n"
26403 +
26404 +#ifdef CONFIG_PAX_KERNEXEC
26405 + " movl %%cr0, %0\n"
26406 + " movl %0, %%eax\n"
26407 + " andl $0xFFFEFFFF, %%eax\n"
26408 + " movl %%eax, %%cr0\n"
26409 +#endif
26410 +
26411 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26412 +
26413 +#ifdef CONFIG_PAX_KERNEXEC
26414 + " movl %0, %%cr0\n"
26415 +#endif
26416 +
26417 " jmp 2b\n"
26418 ".previous\n"
26419 _ASM_EXTABLE(1b, 3b)
26420 - : : "r" (from), "r" (to) : "memory");
26421 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26422
26423 from += 64;
26424 to += 64;
26425 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26426 index f6d13ee..aca5f0b 100644
26427 --- a/arch/x86/lib/msr-reg.S
26428 +++ b/arch/x86/lib/msr-reg.S
26429 @@ -3,6 +3,7 @@
26430 #include <asm/dwarf2.h>
26431 #include <asm/asm.h>
26432 #include <asm/msr.h>
26433 +#include <asm/alternative-asm.h>
26434
26435 #ifdef CONFIG_X86_64
26436 /*
26437 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26438 CFI_STARTPROC
26439 pushq_cfi %rbx
26440 pushq_cfi %rbp
26441 - movq %rdi, %r10 /* Save pointer */
26442 + movq %rdi, %r9 /* Save pointer */
26443 xorl %r11d, %r11d /* Return value */
26444 movl (%rdi), %eax
26445 movl 4(%rdi), %ecx
26446 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26447 movl 28(%rdi), %edi
26448 CFI_REMEMBER_STATE
26449 1: \op
26450 -2: movl %eax, (%r10)
26451 +2: movl %eax, (%r9)
26452 movl %r11d, %eax /* Return value */
26453 - movl %ecx, 4(%r10)
26454 - movl %edx, 8(%r10)
26455 - movl %ebx, 12(%r10)
26456 - movl %ebp, 20(%r10)
26457 - movl %esi, 24(%r10)
26458 - movl %edi, 28(%r10)
26459 + movl %ecx, 4(%r9)
26460 + movl %edx, 8(%r9)
26461 + movl %ebx, 12(%r9)
26462 + movl %ebp, 20(%r9)
26463 + movl %esi, 24(%r9)
26464 + movl %edi, 28(%r9)
26465 popq_cfi %rbp
26466 popq_cfi %rbx
26467 + pax_force_retaddr
26468 ret
26469 3:
26470 CFI_RESTORE_STATE
26471 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26472 index fc6ba17..04471c5 100644
26473 --- a/arch/x86/lib/putuser.S
26474 +++ b/arch/x86/lib/putuser.S
26475 @@ -16,7 +16,9 @@
26476 #include <asm/errno.h>
26477 #include <asm/asm.h>
26478 #include <asm/smap.h>
26479 -
26480 +#include <asm/segment.h>
26481 +#include <asm/pgtable.h>
26482 +#include <asm/alternative-asm.h>
26483
26484 /*
26485 * __put_user_X
26486 @@ -30,57 +32,125 @@
26487 * as they get called from within inline assembly.
26488 */
26489
26490 -#define ENTER CFI_STARTPROC ; \
26491 - GET_THREAD_INFO(%_ASM_BX)
26492 -#define EXIT ASM_CLAC ; \
26493 - ret ; \
26494 +#define ENTER CFI_STARTPROC
26495 +#define EXIT ASM_CLAC ; \
26496 + pax_force_retaddr ; \
26497 + ret ; \
26498 CFI_ENDPROC
26499
26500 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26501 +#define _DEST %_ASM_CX,%_ASM_BX
26502 +#else
26503 +#define _DEST %_ASM_CX
26504 +#endif
26505 +
26506 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26507 +#define __copyuser_seg gs;
26508 +#else
26509 +#define __copyuser_seg
26510 +#endif
26511 +
26512 .text
26513 ENTRY(__put_user_1)
26514 ENTER
26515 +
26516 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26517 + GET_THREAD_INFO(%_ASM_BX)
26518 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26519 jae bad_put_user
26520 ASM_STAC
26521 -1: movb %al,(%_ASM_CX)
26522 +
26523 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26524 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26525 + cmp %_ASM_BX,%_ASM_CX
26526 + jb 1234f
26527 + xor %ebx,%ebx
26528 +1234:
26529 +#endif
26530 +
26531 +#endif
26532 +
26533 +1: __copyuser_seg movb %al,(_DEST)
26534 xor %eax,%eax
26535 EXIT
26536 ENDPROC(__put_user_1)
26537
26538 ENTRY(__put_user_2)
26539 ENTER
26540 +
26541 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26542 + GET_THREAD_INFO(%_ASM_BX)
26543 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26544 sub $1,%_ASM_BX
26545 cmp %_ASM_BX,%_ASM_CX
26546 jae bad_put_user
26547 ASM_STAC
26548 -2: movw %ax,(%_ASM_CX)
26549 +
26550 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26551 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26552 + cmp %_ASM_BX,%_ASM_CX
26553 + jb 1234f
26554 + xor %ebx,%ebx
26555 +1234:
26556 +#endif
26557 +
26558 +#endif
26559 +
26560 +2: __copyuser_seg movw %ax,(_DEST)
26561 xor %eax,%eax
26562 EXIT
26563 ENDPROC(__put_user_2)
26564
26565 ENTRY(__put_user_4)
26566 ENTER
26567 +
26568 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26569 + GET_THREAD_INFO(%_ASM_BX)
26570 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26571 sub $3,%_ASM_BX
26572 cmp %_ASM_BX,%_ASM_CX
26573 jae bad_put_user
26574 ASM_STAC
26575 -3: movl %eax,(%_ASM_CX)
26576 +
26577 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26578 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26579 + cmp %_ASM_BX,%_ASM_CX
26580 + jb 1234f
26581 + xor %ebx,%ebx
26582 +1234:
26583 +#endif
26584 +
26585 +#endif
26586 +
26587 +3: __copyuser_seg movl %eax,(_DEST)
26588 xor %eax,%eax
26589 EXIT
26590 ENDPROC(__put_user_4)
26591
26592 ENTRY(__put_user_8)
26593 ENTER
26594 +
26595 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26596 + GET_THREAD_INFO(%_ASM_BX)
26597 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26598 sub $7,%_ASM_BX
26599 cmp %_ASM_BX,%_ASM_CX
26600 jae bad_put_user
26601 ASM_STAC
26602 -4: mov %_ASM_AX,(%_ASM_CX)
26603 +
26604 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26605 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26606 + cmp %_ASM_BX,%_ASM_CX
26607 + jb 1234f
26608 + xor %ebx,%ebx
26609 +1234:
26610 +#endif
26611 +
26612 +#endif
26613 +
26614 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26615 #ifdef CONFIG_X86_32
26616 -5: movl %edx,4(%_ASM_CX)
26617 +5: __copyuser_seg movl %edx,4(_DEST)
26618 #endif
26619 xor %eax,%eax
26620 EXIT
26621 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26622 index 1cad221..de671ee 100644
26623 --- a/arch/x86/lib/rwlock.S
26624 +++ b/arch/x86/lib/rwlock.S
26625 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26626 FRAME
26627 0: LOCK_PREFIX
26628 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26629 +
26630 +#ifdef CONFIG_PAX_REFCOUNT
26631 + jno 1234f
26632 + LOCK_PREFIX
26633 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26634 + int $4
26635 +1234:
26636 + _ASM_EXTABLE(1234b, 1234b)
26637 +#endif
26638 +
26639 1: rep; nop
26640 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26641 jne 1b
26642 LOCK_PREFIX
26643 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26644 +
26645 +#ifdef CONFIG_PAX_REFCOUNT
26646 + jno 1234f
26647 + LOCK_PREFIX
26648 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26649 + int $4
26650 +1234:
26651 + _ASM_EXTABLE(1234b, 1234b)
26652 +#endif
26653 +
26654 jnz 0b
26655 ENDFRAME
26656 + pax_force_retaddr
26657 ret
26658 CFI_ENDPROC
26659 END(__write_lock_failed)
26660 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26661 FRAME
26662 0: LOCK_PREFIX
26663 READ_LOCK_SIZE(inc) (%__lock_ptr)
26664 +
26665 +#ifdef CONFIG_PAX_REFCOUNT
26666 + jno 1234f
26667 + LOCK_PREFIX
26668 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26669 + int $4
26670 +1234:
26671 + _ASM_EXTABLE(1234b, 1234b)
26672 +#endif
26673 +
26674 1: rep; nop
26675 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26676 js 1b
26677 LOCK_PREFIX
26678 READ_LOCK_SIZE(dec) (%__lock_ptr)
26679 +
26680 +#ifdef CONFIG_PAX_REFCOUNT
26681 + jno 1234f
26682 + LOCK_PREFIX
26683 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26684 + int $4
26685 +1234:
26686 + _ASM_EXTABLE(1234b, 1234b)
26687 +#endif
26688 +
26689 js 0b
26690 ENDFRAME
26691 + pax_force_retaddr
26692 ret
26693 CFI_ENDPROC
26694 END(__read_lock_failed)
26695 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26696 index 5dff5f0..cadebf4 100644
26697 --- a/arch/x86/lib/rwsem.S
26698 +++ b/arch/x86/lib/rwsem.S
26699 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26700 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26701 CFI_RESTORE __ASM_REG(dx)
26702 restore_common_regs
26703 + pax_force_retaddr
26704 ret
26705 CFI_ENDPROC
26706 ENDPROC(call_rwsem_down_read_failed)
26707 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26708 movq %rax,%rdi
26709 call rwsem_down_write_failed
26710 restore_common_regs
26711 + pax_force_retaddr
26712 ret
26713 CFI_ENDPROC
26714 ENDPROC(call_rwsem_down_write_failed)
26715 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26716 movq %rax,%rdi
26717 call rwsem_wake
26718 restore_common_regs
26719 -1: ret
26720 +1: pax_force_retaddr
26721 + ret
26722 CFI_ENDPROC
26723 ENDPROC(call_rwsem_wake)
26724
26725 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26726 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26727 CFI_RESTORE __ASM_REG(dx)
26728 restore_common_regs
26729 + pax_force_retaddr
26730 ret
26731 CFI_ENDPROC
26732 ENDPROC(call_rwsem_downgrade_wake)
26733 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26734 index a63efd6..ccecad8 100644
26735 --- a/arch/x86/lib/thunk_64.S
26736 +++ b/arch/x86/lib/thunk_64.S
26737 @@ -8,6 +8,7 @@
26738 #include <linux/linkage.h>
26739 #include <asm/dwarf2.h>
26740 #include <asm/calling.h>
26741 +#include <asm/alternative-asm.h>
26742
26743 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26744 .macro THUNK name, func, put_ret_addr_in_rdi=0
26745 @@ -41,5 +42,6 @@
26746 SAVE_ARGS
26747 restore:
26748 RESTORE_ARGS
26749 + pax_force_retaddr
26750 ret
26751 CFI_ENDPROC
26752 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26753 index f0312d7..9c39d63 100644
26754 --- a/arch/x86/lib/usercopy_32.c
26755 +++ b/arch/x86/lib/usercopy_32.c
26756 @@ -42,11 +42,13 @@ do { \
26757 int __d0; \
26758 might_fault(); \
26759 __asm__ __volatile__( \
26760 + __COPYUSER_SET_ES \
26761 ASM_STAC "\n" \
26762 "0: rep; stosl\n" \
26763 " movl %2,%0\n" \
26764 "1: rep; stosb\n" \
26765 "2: " ASM_CLAC "\n" \
26766 + __COPYUSER_RESTORE_ES \
26767 ".section .fixup,\"ax\"\n" \
26768 "3: lea 0(%2,%0,4),%0\n" \
26769 " jmp 2b\n" \
26770 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26771
26772 #ifdef CONFIG_X86_INTEL_USERCOPY
26773 static unsigned long
26774 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26775 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26776 {
26777 int d0, d1;
26778 __asm__ __volatile__(
26779 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26780 " .align 2,0x90\n"
26781 "3: movl 0(%4), %%eax\n"
26782 "4: movl 4(%4), %%edx\n"
26783 - "5: movl %%eax, 0(%3)\n"
26784 - "6: movl %%edx, 4(%3)\n"
26785 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26786 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26787 "7: movl 8(%4), %%eax\n"
26788 "8: movl 12(%4),%%edx\n"
26789 - "9: movl %%eax, 8(%3)\n"
26790 - "10: movl %%edx, 12(%3)\n"
26791 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26792 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26793 "11: movl 16(%4), %%eax\n"
26794 "12: movl 20(%4), %%edx\n"
26795 - "13: movl %%eax, 16(%3)\n"
26796 - "14: movl %%edx, 20(%3)\n"
26797 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26798 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26799 "15: movl 24(%4), %%eax\n"
26800 "16: movl 28(%4), %%edx\n"
26801 - "17: movl %%eax, 24(%3)\n"
26802 - "18: movl %%edx, 28(%3)\n"
26803 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26804 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26805 "19: movl 32(%4), %%eax\n"
26806 "20: movl 36(%4), %%edx\n"
26807 - "21: movl %%eax, 32(%3)\n"
26808 - "22: movl %%edx, 36(%3)\n"
26809 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26810 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26811 "23: movl 40(%4), %%eax\n"
26812 "24: movl 44(%4), %%edx\n"
26813 - "25: movl %%eax, 40(%3)\n"
26814 - "26: movl %%edx, 44(%3)\n"
26815 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26816 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26817 "27: movl 48(%4), %%eax\n"
26818 "28: movl 52(%4), %%edx\n"
26819 - "29: movl %%eax, 48(%3)\n"
26820 - "30: movl %%edx, 52(%3)\n"
26821 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26822 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26823 "31: movl 56(%4), %%eax\n"
26824 "32: movl 60(%4), %%edx\n"
26825 - "33: movl %%eax, 56(%3)\n"
26826 - "34: movl %%edx, 60(%3)\n"
26827 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26828 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26829 " addl $-64, %0\n"
26830 " addl $64, %4\n"
26831 " addl $64, %3\n"
26832 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26833 " shrl $2, %0\n"
26834 " andl $3, %%eax\n"
26835 " cld\n"
26836 + __COPYUSER_SET_ES
26837 "99: rep; movsl\n"
26838 "36: movl %%eax, %0\n"
26839 "37: rep; movsb\n"
26840 "100:\n"
26841 + __COPYUSER_RESTORE_ES
26842 ".section .fixup,\"ax\"\n"
26843 "101: lea 0(%%eax,%0,4),%0\n"
26844 " jmp 100b\n"
26845 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26846 }
26847
26848 static unsigned long
26849 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26850 +{
26851 + int d0, d1;
26852 + __asm__ __volatile__(
26853 + " .align 2,0x90\n"
26854 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26855 + " cmpl $67, %0\n"
26856 + " jbe 3f\n"
26857 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26858 + " .align 2,0x90\n"
26859 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26860 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26861 + "5: movl %%eax, 0(%3)\n"
26862 + "6: movl %%edx, 4(%3)\n"
26863 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26864 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26865 + "9: movl %%eax, 8(%3)\n"
26866 + "10: movl %%edx, 12(%3)\n"
26867 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26868 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26869 + "13: movl %%eax, 16(%3)\n"
26870 + "14: movl %%edx, 20(%3)\n"
26871 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26872 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26873 + "17: movl %%eax, 24(%3)\n"
26874 + "18: movl %%edx, 28(%3)\n"
26875 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26876 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26877 + "21: movl %%eax, 32(%3)\n"
26878 + "22: movl %%edx, 36(%3)\n"
26879 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26880 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26881 + "25: movl %%eax, 40(%3)\n"
26882 + "26: movl %%edx, 44(%3)\n"
26883 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26884 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26885 + "29: movl %%eax, 48(%3)\n"
26886 + "30: movl %%edx, 52(%3)\n"
26887 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26888 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26889 + "33: movl %%eax, 56(%3)\n"
26890 + "34: movl %%edx, 60(%3)\n"
26891 + " addl $-64, %0\n"
26892 + " addl $64, %4\n"
26893 + " addl $64, %3\n"
26894 + " cmpl $63, %0\n"
26895 + " ja 1b\n"
26896 + "35: movl %0, %%eax\n"
26897 + " shrl $2, %0\n"
26898 + " andl $3, %%eax\n"
26899 + " cld\n"
26900 + "99: rep; "__copyuser_seg" movsl\n"
26901 + "36: movl %%eax, %0\n"
26902 + "37: rep; "__copyuser_seg" movsb\n"
26903 + "100:\n"
26904 + ".section .fixup,\"ax\"\n"
26905 + "101: lea 0(%%eax,%0,4),%0\n"
26906 + " jmp 100b\n"
26907 + ".previous\n"
26908 + _ASM_EXTABLE(1b,100b)
26909 + _ASM_EXTABLE(2b,100b)
26910 + _ASM_EXTABLE(3b,100b)
26911 + _ASM_EXTABLE(4b,100b)
26912 + _ASM_EXTABLE(5b,100b)
26913 + _ASM_EXTABLE(6b,100b)
26914 + _ASM_EXTABLE(7b,100b)
26915 + _ASM_EXTABLE(8b,100b)
26916 + _ASM_EXTABLE(9b,100b)
26917 + _ASM_EXTABLE(10b,100b)
26918 + _ASM_EXTABLE(11b,100b)
26919 + _ASM_EXTABLE(12b,100b)
26920 + _ASM_EXTABLE(13b,100b)
26921 + _ASM_EXTABLE(14b,100b)
26922 + _ASM_EXTABLE(15b,100b)
26923 + _ASM_EXTABLE(16b,100b)
26924 + _ASM_EXTABLE(17b,100b)
26925 + _ASM_EXTABLE(18b,100b)
26926 + _ASM_EXTABLE(19b,100b)
26927 + _ASM_EXTABLE(20b,100b)
26928 + _ASM_EXTABLE(21b,100b)
26929 + _ASM_EXTABLE(22b,100b)
26930 + _ASM_EXTABLE(23b,100b)
26931 + _ASM_EXTABLE(24b,100b)
26932 + _ASM_EXTABLE(25b,100b)
26933 + _ASM_EXTABLE(26b,100b)
26934 + _ASM_EXTABLE(27b,100b)
26935 + _ASM_EXTABLE(28b,100b)
26936 + _ASM_EXTABLE(29b,100b)
26937 + _ASM_EXTABLE(30b,100b)
26938 + _ASM_EXTABLE(31b,100b)
26939 + _ASM_EXTABLE(32b,100b)
26940 + _ASM_EXTABLE(33b,100b)
26941 + _ASM_EXTABLE(34b,100b)
26942 + _ASM_EXTABLE(35b,100b)
26943 + _ASM_EXTABLE(36b,100b)
26944 + _ASM_EXTABLE(37b,100b)
26945 + _ASM_EXTABLE(99b,101b)
26946 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26947 + : "1"(to), "2"(from), "0"(size)
26948 + : "eax", "edx", "memory");
26949 + return size;
26950 +}
26951 +
26952 +static unsigned long __size_overflow(3)
26953 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26954 {
26955 int d0, d1;
26956 __asm__ __volatile__(
26957 " .align 2,0x90\n"
26958 - "0: movl 32(%4), %%eax\n"
26959 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26960 " cmpl $67, %0\n"
26961 " jbe 2f\n"
26962 - "1: movl 64(%4), %%eax\n"
26963 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26964 " .align 2,0x90\n"
26965 - "2: movl 0(%4), %%eax\n"
26966 - "21: movl 4(%4), %%edx\n"
26967 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26968 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26969 " movl %%eax, 0(%3)\n"
26970 " movl %%edx, 4(%3)\n"
26971 - "3: movl 8(%4), %%eax\n"
26972 - "31: movl 12(%4),%%edx\n"
26973 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26974 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26975 " movl %%eax, 8(%3)\n"
26976 " movl %%edx, 12(%3)\n"
26977 - "4: movl 16(%4), %%eax\n"
26978 - "41: movl 20(%4), %%edx\n"
26979 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26980 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26981 " movl %%eax, 16(%3)\n"
26982 " movl %%edx, 20(%3)\n"
26983 - "10: movl 24(%4), %%eax\n"
26984 - "51: movl 28(%4), %%edx\n"
26985 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26986 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26987 " movl %%eax, 24(%3)\n"
26988 " movl %%edx, 28(%3)\n"
26989 - "11: movl 32(%4), %%eax\n"
26990 - "61: movl 36(%4), %%edx\n"
26991 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26992 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26993 " movl %%eax, 32(%3)\n"
26994 " movl %%edx, 36(%3)\n"
26995 - "12: movl 40(%4), %%eax\n"
26996 - "71: movl 44(%4), %%edx\n"
26997 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26998 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26999 " movl %%eax, 40(%3)\n"
27000 " movl %%edx, 44(%3)\n"
27001 - "13: movl 48(%4), %%eax\n"
27002 - "81: movl 52(%4), %%edx\n"
27003 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27004 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27005 " movl %%eax, 48(%3)\n"
27006 " movl %%edx, 52(%3)\n"
27007 - "14: movl 56(%4), %%eax\n"
27008 - "91: movl 60(%4), %%edx\n"
27009 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27010 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27011 " movl %%eax, 56(%3)\n"
27012 " movl %%edx, 60(%3)\n"
27013 " addl $-64, %0\n"
27014 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27015 " shrl $2, %0\n"
27016 " andl $3, %%eax\n"
27017 " cld\n"
27018 - "6: rep; movsl\n"
27019 + "6: rep; "__copyuser_seg" movsl\n"
27020 " movl %%eax,%0\n"
27021 - "7: rep; movsb\n"
27022 + "7: rep; "__copyuser_seg" movsb\n"
27023 "8:\n"
27024 ".section .fixup,\"ax\"\n"
27025 "9: lea 0(%%eax,%0,4),%0\n"
27026 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27027 * hyoshiok@miraclelinux.com
27028 */
27029
27030 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27031 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
27032 const void __user *from, unsigned long size)
27033 {
27034 int d0, d1;
27035
27036 __asm__ __volatile__(
27037 " .align 2,0x90\n"
27038 - "0: movl 32(%4), %%eax\n"
27039 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27040 " cmpl $67, %0\n"
27041 " jbe 2f\n"
27042 - "1: movl 64(%4), %%eax\n"
27043 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27044 " .align 2,0x90\n"
27045 - "2: movl 0(%4), %%eax\n"
27046 - "21: movl 4(%4), %%edx\n"
27047 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27048 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27049 " movnti %%eax, 0(%3)\n"
27050 " movnti %%edx, 4(%3)\n"
27051 - "3: movl 8(%4), %%eax\n"
27052 - "31: movl 12(%4),%%edx\n"
27053 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27054 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27055 " movnti %%eax, 8(%3)\n"
27056 " movnti %%edx, 12(%3)\n"
27057 - "4: movl 16(%4), %%eax\n"
27058 - "41: movl 20(%4), %%edx\n"
27059 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27060 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27061 " movnti %%eax, 16(%3)\n"
27062 " movnti %%edx, 20(%3)\n"
27063 - "10: movl 24(%4), %%eax\n"
27064 - "51: movl 28(%4), %%edx\n"
27065 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27066 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27067 " movnti %%eax, 24(%3)\n"
27068 " movnti %%edx, 28(%3)\n"
27069 - "11: movl 32(%4), %%eax\n"
27070 - "61: movl 36(%4), %%edx\n"
27071 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27072 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27073 " movnti %%eax, 32(%3)\n"
27074 " movnti %%edx, 36(%3)\n"
27075 - "12: movl 40(%4), %%eax\n"
27076 - "71: movl 44(%4), %%edx\n"
27077 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27078 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27079 " movnti %%eax, 40(%3)\n"
27080 " movnti %%edx, 44(%3)\n"
27081 - "13: movl 48(%4), %%eax\n"
27082 - "81: movl 52(%4), %%edx\n"
27083 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27084 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27085 " movnti %%eax, 48(%3)\n"
27086 " movnti %%edx, 52(%3)\n"
27087 - "14: movl 56(%4), %%eax\n"
27088 - "91: movl 60(%4), %%edx\n"
27089 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27090 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27091 " movnti %%eax, 56(%3)\n"
27092 " movnti %%edx, 60(%3)\n"
27093 " addl $-64, %0\n"
27094 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27095 " shrl $2, %0\n"
27096 " andl $3, %%eax\n"
27097 " cld\n"
27098 - "6: rep; movsl\n"
27099 + "6: rep; "__copyuser_seg" movsl\n"
27100 " movl %%eax,%0\n"
27101 - "7: rep; movsb\n"
27102 + "7: rep; "__copyuser_seg" movsb\n"
27103 "8:\n"
27104 ".section .fixup,\"ax\"\n"
27105 "9: lea 0(%%eax,%0,4),%0\n"
27106 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27107 return size;
27108 }
27109
27110 -static unsigned long __copy_user_intel_nocache(void *to,
27111 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
27112 const void __user *from, unsigned long size)
27113 {
27114 int d0, d1;
27115
27116 __asm__ __volatile__(
27117 " .align 2,0x90\n"
27118 - "0: movl 32(%4), %%eax\n"
27119 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27120 " cmpl $67, %0\n"
27121 " jbe 2f\n"
27122 - "1: movl 64(%4), %%eax\n"
27123 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27124 " .align 2,0x90\n"
27125 - "2: movl 0(%4), %%eax\n"
27126 - "21: movl 4(%4), %%edx\n"
27127 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27128 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27129 " movnti %%eax, 0(%3)\n"
27130 " movnti %%edx, 4(%3)\n"
27131 - "3: movl 8(%4), %%eax\n"
27132 - "31: movl 12(%4),%%edx\n"
27133 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27134 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27135 " movnti %%eax, 8(%3)\n"
27136 " movnti %%edx, 12(%3)\n"
27137 - "4: movl 16(%4), %%eax\n"
27138 - "41: movl 20(%4), %%edx\n"
27139 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27140 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27141 " movnti %%eax, 16(%3)\n"
27142 " movnti %%edx, 20(%3)\n"
27143 - "10: movl 24(%4), %%eax\n"
27144 - "51: movl 28(%4), %%edx\n"
27145 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27146 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27147 " movnti %%eax, 24(%3)\n"
27148 " movnti %%edx, 28(%3)\n"
27149 - "11: movl 32(%4), %%eax\n"
27150 - "61: movl 36(%4), %%edx\n"
27151 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27152 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27153 " movnti %%eax, 32(%3)\n"
27154 " movnti %%edx, 36(%3)\n"
27155 - "12: movl 40(%4), %%eax\n"
27156 - "71: movl 44(%4), %%edx\n"
27157 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27158 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27159 " movnti %%eax, 40(%3)\n"
27160 " movnti %%edx, 44(%3)\n"
27161 - "13: movl 48(%4), %%eax\n"
27162 - "81: movl 52(%4), %%edx\n"
27163 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27164 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27165 " movnti %%eax, 48(%3)\n"
27166 " movnti %%edx, 52(%3)\n"
27167 - "14: movl 56(%4), %%eax\n"
27168 - "91: movl 60(%4), %%edx\n"
27169 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27170 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27171 " movnti %%eax, 56(%3)\n"
27172 " movnti %%edx, 60(%3)\n"
27173 " addl $-64, %0\n"
27174 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
27175 " shrl $2, %0\n"
27176 " andl $3, %%eax\n"
27177 " cld\n"
27178 - "6: rep; movsl\n"
27179 + "6: rep; "__copyuser_seg" movsl\n"
27180 " movl %%eax,%0\n"
27181 - "7: rep; movsb\n"
27182 + "7: rep; "__copyuser_seg" movsb\n"
27183 "8:\n"
27184 ".section .fixup,\"ax\"\n"
27185 "9: lea 0(%%eax,%0,4),%0\n"
27186 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
27187 */
27188 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
27189 unsigned long size);
27190 -unsigned long __copy_user_intel(void __user *to, const void *from,
27191 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
27192 + unsigned long size);
27193 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27194 unsigned long size);
27195 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27196 const void __user *from, unsigned long size);
27197 #endif /* CONFIG_X86_INTEL_USERCOPY */
27198
27199 /* Generic arbitrary sized copy. */
27200 -#define __copy_user(to, from, size) \
27201 +#define __copy_user(to, from, size, prefix, set, restore) \
27202 do { \
27203 int __d0, __d1, __d2; \
27204 __asm__ __volatile__( \
27205 + set \
27206 " cmp $7,%0\n" \
27207 " jbe 1f\n" \
27208 " movl %1,%0\n" \
27209 " negl %0\n" \
27210 " andl $7,%0\n" \
27211 " subl %0,%3\n" \
27212 - "4: rep; movsb\n" \
27213 + "4: rep; "prefix"movsb\n" \
27214 " movl %3,%0\n" \
27215 " shrl $2,%0\n" \
27216 " andl $3,%3\n" \
27217 " .align 2,0x90\n" \
27218 - "0: rep; movsl\n" \
27219 + "0: rep; "prefix"movsl\n" \
27220 " movl %3,%0\n" \
27221 - "1: rep; movsb\n" \
27222 + "1: rep; "prefix"movsb\n" \
27223 "2:\n" \
27224 + restore \
27225 ".section .fixup,\"ax\"\n" \
27226 "5: addl %3,%0\n" \
27227 " jmp 2b\n" \
27228 @@ -538,14 +650,14 @@ do { \
27229 " negl %0\n" \
27230 " andl $7,%0\n" \
27231 " subl %0,%3\n" \
27232 - "4: rep; movsb\n" \
27233 + "4: rep; "__copyuser_seg"movsb\n" \
27234 " movl %3,%0\n" \
27235 " shrl $2,%0\n" \
27236 " andl $3,%3\n" \
27237 " .align 2,0x90\n" \
27238 - "0: rep; movsl\n" \
27239 + "0: rep; "__copyuser_seg"movsl\n" \
27240 " movl %3,%0\n" \
27241 - "1: rep; movsb\n" \
27242 + "1: rep; "__copyuser_seg"movsb\n" \
27243 "2:\n" \
27244 ".section .fixup,\"ax\"\n" \
27245 "5: addl %3,%0\n" \
27246 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27247 {
27248 stac();
27249 if (movsl_is_ok(to, from, n))
27250 - __copy_user(to, from, n);
27251 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27252 else
27253 - n = __copy_user_intel(to, from, n);
27254 + n = __generic_copy_to_user_intel(to, from, n);
27255 clac();
27256 return n;
27257 }
27258 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27259 {
27260 stac();
27261 if (movsl_is_ok(to, from, n))
27262 - __copy_user(to, from, n);
27263 + __copy_user(to, from, n, __copyuser_seg, "", "");
27264 else
27265 - n = __copy_user_intel((void __user *)to,
27266 - (const void *)from, n);
27267 + n = __generic_copy_from_user_intel(to, from, n);
27268 clac();
27269 return n;
27270 }
27271 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27272 if (n > 64 && cpu_has_xmm2)
27273 n = __copy_user_intel_nocache(to, from, n);
27274 else
27275 - __copy_user(to, from, n);
27276 + __copy_user(to, from, n, __copyuser_seg, "", "");
27277 #else
27278 - __copy_user(to, from, n);
27279 + __copy_user(to, from, n, __copyuser_seg, "", "");
27280 #endif
27281 clac();
27282 return n;
27283 }
27284 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27285
27286 -/**
27287 - * copy_to_user: - Copy a block of data into user space.
27288 - * @to: Destination address, in user space.
27289 - * @from: Source address, in kernel space.
27290 - * @n: Number of bytes to copy.
27291 - *
27292 - * Context: User context only. This function may sleep.
27293 - *
27294 - * Copy data from kernel space to user space.
27295 - *
27296 - * Returns number of bytes that could not be copied.
27297 - * On success, this will be zero.
27298 - */
27299 -unsigned long
27300 -copy_to_user(void __user *to, const void *from, unsigned long n)
27301 -{
27302 - if (access_ok(VERIFY_WRITE, to, n))
27303 - n = __copy_to_user(to, from, n);
27304 - return n;
27305 -}
27306 -EXPORT_SYMBOL(copy_to_user);
27307 -
27308 -/**
27309 - * copy_from_user: - Copy a block of data from user space.
27310 - * @to: Destination address, in kernel space.
27311 - * @from: Source address, in user space.
27312 - * @n: Number of bytes to copy.
27313 - *
27314 - * Context: User context only. This function may sleep.
27315 - *
27316 - * Copy data from user space to kernel space.
27317 - *
27318 - * Returns number of bytes that could not be copied.
27319 - * On success, this will be zero.
27320 - *
27321 - * If some data could not be copied, this function will pad the copied
27322 - * data to the requested size using zero bytes.
27323 - */
27324 -unsigned long
27325 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27326 -{
27327 - if (access_ok(VERIFY_READ, from, n))
27328 - n = __copy_from_user(to, from, n);
27329 - else
27330 - memset(to, 0, n);
27331 - return n;
27332 -}
27333 -EXPORT_SYMBOL(_copy_from_user);
27334 -
27335 void copy_from_user_overflow(void)
27336 {
27337 WARN(1, "Buffer overflow detected!\n");
27338 }
27339 EXPORT_SYMBOL(copy_from_user_overflow);
27340 +
27341 +void copy_to_user_overflow(void)
27342 +{
27343 + WARN(1, "Buffer overflow detected!\n");
27344 +}
27345 +EXPORT_SYMBOL(copy_to_user_overflow);
27346 +
27347 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27348 +void __set_fs(mm_segment_t x)
27349 +{
27350 + switch (x.seg) {
27351 + case 0:
27352 + loadsegment(gs, 0);
27353 + break;
27354 + case TASK_SIZE_MAX:
27355 + loadsegment(gs, __USER_DS);
27356 + break;
27357 + case -1UL:
27358 + loadsegment(gs, __KERNEL_DS);
27359 + break;
27360 + default:
27361 + BUG();
27362 + }
27363 + return;
27364 +}
27365 +EXPORT_SYMBOL(__set_fs);
27366 +
27367 +void set_fs(mm_segment_t x)
27368 +{
27369 + current_thread_info()->addr_limit = x;
27370 + __set_fs(x);
27371 +}
27372 +EXPORT_SYMBOL(set_fs);
27373 +#endif
27374 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27375 index 906fea3..ee8a097 100644
27376 --- a/arch/x86/lib/usercopy_64.c
27377 +++ b/arch/x86/lib/usercopy_64.c
27378 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27379 _ASM_EXTABLE(0b,3b)
27380 _ASM_EXTABLE(1b,2b)
27381 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27382 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27383 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27384 [zero] "r" (0UL), [eight] "r" (8UL));
27385 clac();
27386 return size;
27387 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27388 }
27389 EXPORT_SYMBOL(clear_user);
27390
27391 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27392 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27393 {
27394 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27395 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27396 - }
27397 - return len;
27398 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27399 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27400 + return len;
27401 }
27402 EXPORT_SYMBOL(copy_in_user);
27403
27404 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27405 * it is not necessary to optimize tail handling.
27406 */
27407 unsigned long
27408 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27409 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27410 {
27411 char c;
27412 unsigned zero_len;
27413 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27414 clac();
27415 return len;
27416 }
27417 +
27418 +void copy_from_user_overflow(void)
27419 +{
27420 + WARN(1, "Buffer overflow detected!\n");
27421 +}
27422 +EXPORT_SYMBOL(copy_from_user_overflow);
27423 +
27424 +void copy_to_user_overflow(void)
27425 +{
27426 + WARN(1, "Buffer overflow detected!\n");
27427 +}
27428 +EXPORT_SYMBOL(copy_to_user_overflow);
27429 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27430 index 903ec1e..c4166b2 100644
27431 --- a/arch/x86/mm/extable.c
27432 +++ b/arch/x86/mm/extable.c
27433 @@ -6,12 +6,24 @@
27434 static inline unsigned long
27435 ex_insn_addr(const struct exception_table_entry *x)
27436 {
27437 - return (unsigned long)&x->insn + x->insn;
27438 + unsigned long reloc = 0;
27439 +
27440 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27441 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27442 +#endif
27443 +
27444 + return (unsigned long)&x->insn + x->insn + reloc;
27445 }
27446 static inline unsigned long
27447 ex_fixup_addr(const struct exception_table_entry *x)
27448 {
27449 - return (unsigned long)&x->fixup + x->fixup;
27450 + unsigned long reloc = 0;
27451 +
27452 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27453 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27454 +#endif
27455 +
27456 + return (unsigned long)&x->fixup + x->fixup + reloc;
27457 }
27458
27459 int fixup_exception(struct pt_regs *regs)
27460 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27461 unsigned long new_ip;
27462
27463 #ifdef CONFIG_PNPBIOS
27464 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27465 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27466 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27467 extern u32 pnp_bios_is_utter_crap;
27468 pnp_bios_is_utter_crap = 1;
27469 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27470 i += 4;
27471 p->fixup -= i;
27472 i += 4;
27473 +
27474 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27475 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27476 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27477 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27478 +#endif
27479 +
27480 }
27481 }
27482
27483 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27484 index 4f7d793..165a8be 100644
27485 --- a/arch/x86/mm/fault.c
27486 +++ b/arch/x86/mm/fault.c
27487 @@ -13,12 +13,19 @@
27488 #include <linux/perf_event.h> /* perf_sw_event */
27489 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27490 #include <linux/prefetch.h> /* prefetchw */
27491 +#include <linux/unistd.h>
27492 +#include <linux/compiler.h>
27493
27494 #include <asm/traps.h> /* dotraplinkage, ... */
27495 #include <asm/pgalloc.h> /* pgd_*(), ... */
27496 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27497 #include <asm/fixmap.h> /* VSYSCALL_START */
27498 #include <asm/context_tracking.h> /* exception_enter(), ... */
27499 +#include <asm/tlbflush.h>
27500 +
27501 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27502 +#include <asm/stacktrace.h>
27503 +#endif
27504
27505 /*
27506 * Page fault error code bits:
27507 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27508 int ret = 0;
27509
27510 /* kprobe_running() needs smp_processor_id() */
27511 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27512 + if (kprobes_built_in() && !user_mode(regs)) {
27513 preempt_disable();
27514 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27515 ret = 1;
27516 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27517 return !instr_lo || (instr_lo>>1) == 1;
27518 case 0x00:
27519 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27520 - if (probe_kernel_address(instr, opcode))
27521 + if (user_mode(regs)) {
27522 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27523 + return 0;
27524 + } else if (probe_kernel_address(instr, opcode))
27525 return 0;
27526
27527 *prefetch = (instr_lo == 0xF) &&
27528 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27529 while (instr < max_instr) {
27530 unsigned char opcode;
27531
27532 - if (probe_kernel_address(instr, opcode))
27533 + if (user_mode(regs)) {
27534 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27535 + break;
27536 + } else if (probe_kernel_address(instr, opcode))
27537 break;
27538
27539 instr++;
27540 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27541 force_sig_info(si_signo, &info, tsk);
27542 }
27543
27544 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27545 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27546 +#endif
27547 +
27548 +#ifdef CONFIG_PAX_EMUTRAMP
27549 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27550 +#endif
27551 +
27552 +#ifdef CONFIG_PAX_PAGEEXEC
27553 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27554 +{
27555 + pgd_t *pgd;
27556 + pud_t *pud;
27557 + pmd_t *pmd;
27558 +
27559 + pgd = pgd_offset(mm, address);
27560 + if (!pgd_present(*pgd))
27561 + return NULL;
27562 + pud = pud_offset(pgd, address);
27563 + if (!pud_present(*pud))
27564 + return NULL;
27565 + pmd = pmd_offset(pud, address);
27566 + if (!pmd_present(*pmd))
27567 + return NULL;
27568 + return pmd;
27569 +}
27570 +#endif
27571 +
27572 DEFINE_SPINLOCK(pgd_lock);
27573 LIST_HEAD(pgd_list);
27574
27575 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27576 for (address = VMALLOC_START & PMD_MASK;
27577 address >= TASK_SIZE && address < FIXADDR_TOP;
27578 address += PMD_SIZE) {
27579 +
27580 +#ifdef CONFIG_PAX_PER_CPU_PGD
27581 + unsigned long cpu;
27582 +#else
27583 struct page *page;
27584 +#endif
27585
27586 spin_lock(&pgd_lock);
27587 +
27588 +#ifdef CONFIG_PAX_PER_CPU_PGD
27589 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27590 + pgd_t *pgd = get_cpu_pgd(cpu);
27591 + pmd_t *ret;
27592 +#else
27593 list_for_each_entry(page, &pgd_list, lru) {
27594 + pgd_t *pgd;
27595 spinlock_t *pgt_lock;
27596 pmd_t *ret;
27597
27598 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27599 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27600
27601 spin_lock(pgt_lock);
27602 - ret = vmalloc_sync_one(page_address(page), address);
27603 + pgd = page_address(page);
27604 +#endif
27605 +
27606 + ret = vmalloc_sync_one(pgd, address);
27607 +
27608 +#ifndef CONFIG_PAX_PER_CPU_PGD
27609 spin_unlock(pgt_lock);
27610 +#endif
27611
27612 if (!ret)
27613 break;
27614 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27615 * an interrupt in the middle of a task switch..
27616 */
27617 pgd_paddr = read_cr3();
27618 +
27619 +#ifdef CONFIG_PAX_PER_CPU_PGD
27620 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27621 +#endif
27622 +
27623 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27624 if (!pmd_k)
27625 return -1;
27626 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27627 * happen within a race in page table update. In the later
27628 * case just flush:
27629 */
27630 +
27631 +#ifdef CONFIG_PAX_PER_CPU_PGD
27632 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27633 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27634 +#else
27635 pgd = pgd_offset(current->active_mm, address);
27636 +#endif
27637 +
27638 pgd_ref = pgd_offset_k(address);
27639 if (pgd_none(*pgd_ref))
27640 return -1;
27641 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27642 static int is_errata100(struct pt_regs *regs, unsigned long address)
27643 {
27644 #ifdef CONFIG_X86_64
27645 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27646 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27647 return 1;
27648 #endif
27649 return 0;
27650 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27651 }
27652
27653 static const char nx_warning[] = KERN_CRIT
27654 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27655 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27656
27657 static void
27658 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27659 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27660 if (!oops_may_print())
27661 return;
27662
27663 - if (error_code & PF_INSTR) {
27664 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27665 unsigned int level;
27666
27667 pte_t *pte = lookup_address(address, &level);
27668
27669 if (pte && pte_present(*pte) && !pte_exec(*pte))
27670 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27671 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27672 }
27673
27674 +#ifdef CONFIG_PAX_KERNEXEC
27675 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27676 + if (current->signal->curr_ip)
27677 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27678 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27679 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27680 + else
27681 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27682 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27683 + }
27684 +#endif
27685 +
27686 printk(KERN_ALERT "BUG: unable to handle kernel ");
27687 if (address < PAGE_SIZE)
27688 printk(KERN_CONT "NULL pointer dereference");
27689 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27690 return;
27691 }
27692 #endif
27693 +
27694 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27695 + if (pax_is_fetch_fault(regs, error_code, address)) {
27696 +
27697 +#ifdef CONFIG_PAX_EMUTRAMP
27698 + switch (pax_handle_fetch_fault(regs)) {
27699 + case 2:
27700 + return;
27701 + }
27702 +#endif
27703 +
27704 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27705 + do_group_exit(SIGKILL);
27706 + }
27707 +#endif
27708 +
27709 /* Kernel addresses are always protection faults: */
27710 if (address >= TASK_SIZE)
27711 error_code |= PF_PROT;
27712 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27713 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27714 printk(KERN_ERR
27715 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27716 - tsk->comm, tsk->pid, address);
27717 + tsk->comm, task_pid_nr(tsk), address);
27718 code = BUS_MCEERR_AR;
27719 }
27720 #endif
27721 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27722 return 1;
27723 }
27724
27725 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27726 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27727 +{
27728 + pte_t *pte;
27729 + pmd_t *pmd;
27730 + spinlock_t *ptl;
27731 + unsigned char pte_mask;
27732 +
27733 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27734 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27735 + return 0;
27736 +
27737 + /* PaX: it's our fault, let's handle it if we can */
27738 +
27739 + /* PaX: take a look at read faults before acquiring any locks */
27740 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27741 + /* instruction fetch attempt from a protected page in user mode */
27742 + up_read(&mm->mmap_sem);
27743 +
27744 +#ifdef CONFIG_PAX_EMUTRAMP
27745 + switch (pax_handle_fetch_fault(regs)) {
27746 + case 2:
27747 + return 1;
27748 + }
27749 +#endif
27750 +
27751 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27752 + do_group_exit(SIGKILL);
27753 + }
27754 +
27755 + pmd = pax_get_pmd(mm, address);
27756 + if (unlikely(!pmd))
27757 + return 0;
27758 +
27759 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27760 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27761 + pte_unmap_unlock(pte, ptl);
27762 + return 0;
27763 + }
27764 +
27765 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27766 + /* write attempt to a protected page in user mode */
27767 + pte_unmap_unlock(pte, ptl);
27768 + return 0;
27769 + }
27770 +
27771 +#ifdef CONFIG_SMP
27772 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27773 +#else
27774 + if (likely(address > get_limit(regs->cs)))
27775 +#endif
27776 + {
27777 + set_pte(pte, pte_mkread(*pte));
27778 + __flush_tlb_one(address);
27779 + pte_unmap_unlock(pte, ptl);
27780 + up_read(&mm->mmap_sem);
27781 + return 1;
27782 + }
27783 +
27784 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27785 +
27786 + /*
27787 + * PaX: fill DTLB with user rights and retry
27788 + */
27789 + __asm__ __volatile__ (
27790 + "orb %2,(%1)\n"
27791 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27792 +/*
27793 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27794 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27795 + * page fault when examined during a TLB load attempt. this is true not only
27796 + * for PTEs holding a non-present entry but also present entries that will
27797 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27798 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27799 + * for our target pages since their PTEs are simply not in the TLBs at all.
27800 +
27801 + * the best thing in omitting it is that we gain around 15-20% speed in the
27802 + * fast path of the page fault handler and can get rid of tracing since we
27803 + * can no longer flush unintended entries.
27804 + */
27805 + "invlpg (%0)\n"
27806 +#endif
27807 + __copyuser_seg"testb $0,(%0)\n"
27808 + "xorb %3,(%1)\n"
27809 + :
27810 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27811 + : "memory", "cc");
27812 + pte_unmap_unlock(pte, ptl);
27813 + up_read(&mm->mmap_sem);
27814 + return 1;
27815 +}
27816 +#endif
27817 +
27818 /*
27819 * Handle a spurious fault caused by a stale TLB entry.
27820 *
27821 @@ -970,6 +1162,9 @@ int show_unhandled_signals = 1;
27822 static inline int
27823 access_error(unsigned long error_code, struct vm_area_struct *vma)
27824 {
27825 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27826 + return 1;
27827 +
27828 if (error_code & PF_WRITE) {
27829 /* write, present and write, not present: */
27830 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27831 @@ -998,7 +1193,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27832 if (error_code & PF_USER)
27833 return false;
27834
27835 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27836 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27837 return false;
27838
27839 return true;
27840 @@ -1014,18 +1209,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27841 {
27842 struct vm_area_struct *vma;
27843 struct task_struct *tsk;
27844 - unsigned long address;
27845 struct mm_struct *mm;
27846 int fault;
27847 int write = error_code & PF_WRITE;
27848 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27849 (write ? FAULT_FLAG_WRITE : 0);
27850
27851 - tsk = current;
27852 - mm = tsk->mm;
27853 -
27854 /* Get the faulting address: */
27855 - address = read_cr2();
27856 + unsigned long address = read_cr2();
27857 +
27858 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27859 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27860 + if (!search_exception_tables(regs->ip)) {
27861 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27862 + bad_area_nosemaphore(regs, error_code, address);
27863 + return;
27864 + }
27865 + if (address < PAX_USER_SHADOW_BASE) {
27866 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27867 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27868 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27869 + } else
27870 + address -= PAX_USER_SHADOW_BASE;
27871 + }
27872 +#endif
27873 +
27874 + tsk = current;
27875 + mm = tsk->mm;
27876
27877 /*
27878 * Detect and handle instructions that would cause a page fault for
27879 @@ -1086,7 +1296,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27880 * User-mode registers count as a user access even for any
27881 * potential system fault or CPU buglet:
27882 */
27883 - if (user_mode_vm(regs)) {
27884 + if (user_mode(regs)) {
27885 local_irq_enable();
27886 error_code |= PF_USER;
27887 } else {
27888 @@ -1148,6 +1358,11 @@ retry:
27889 might_sleep();
27890 }
27891
27892 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27893 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27894 + return;
27895 +#endif
27896 +
27897 vma = find_vma(mm, address);
27898 if (unlikely(!vma)) {
27899 bad_area(regs, error_code, address);
27900 @@ -1159,18 +1374,24 @@ retry:
27901 bad_area(regs, error_code, address);
27902 return;
27903 }
27904 - if (error_code & PF_USER) {
27905 - /*
27906 - * Accessing the stack below %sp is always a bug.
27907 - * The large cushion allows instructions like enter
27908 - * and pusha to work. ("enter $65535, $31" pushes
27909 - * 32 pointers and then decrements %sp by 65535.)
27910 - */
27911 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27912 - bad_area(regs, error_code, address);
27913 - return;
27914 - }
27915 + /*
27916 + * Accessing the stack below %sp is always a bug.
27917 + * The large cushion allows instructions like enter
27918 + * and pusha to work. ("enter $65535, $31" pushes
27919 + * 32 pointers and then decrements %sp by 65535.)
27920 + */
27921 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27922 + bad_area(regs, error_code, address);
27923 + return;
27924 }
27925 +
27926 +#ifdef CONFIG_PAX_SEGMEXEC
27927 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27928 + bad_area(regs, error_code, address);
27929 + return;
27930 + }
27931 +#endif
27932 +
27933 if (unlikely(expand_stack(vma, address))) {
27934 bad_area(regs, error_code, address);
27935 return;
27936 @@ -1234,3 +1455,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27937 __do_page_fault(regs, error_code);
27938 exception_exit(regs);
27939 }
27940 +
27941 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27942 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27943 +{
27944 + struct mm_struct *mm = current->mm;
27945 + unsigned long ip = regs->ip;
27946 +
27947 + if (v8086_mode(regs))
27948 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27949 +
27950 +#ifdef CONFIG_PAX_PAGEEXEC
27951 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27952 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27953 + return true;
27954 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27955 + return true;
27956 + return false;
27957 + }
27958 +#endif
27959 +
27960 +#ifdef CONFIG_PAX_SEGMEXEC
27961 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27962 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27963 + return true;
27964 + return false;
27965 + }
27966 +#endif
27967 +
27968 + return false;
27969 +}
27970 +#endif
27971 +
27972 +#ifdef CONFIG_PAX_EMUTRAMP
27973 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27974 +{
27975 + int err;
27976 +
27977 + do { /* PaX: libffi trampoline emulation */
27978 + unsigned char mov, jmp;
27979 + unsigned int addr1, addr2;
27980 +
27981 +#ifdef CONFIG_X86_64
27982 + if ((regs->ip + 9) >> 32)
27983 + break;
27984 +#endif
27985 +
27986 + err = get_user(mov, (unsigned char __user *)regs->ip);
27987 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27988 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27989 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27990 +
27991 + if (err)
27992 + break;
27993 +
27994 + if (mov == 0xB8 && jmp == 0xE9) {
27995 + regs->ax = addr1;
27996 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27997 + return 2;
27998 + }
27999 + } while (0);
28000 +
28001 + do { /* PaX: gcc trampoline emulation #1 */
28002 + unsigned char mov1, mov2;
28003 + unsigned short jmp;
28004 + unsigned int addr1, addr2;
28005 +
28006 +#ifdef CONFIG_X86_64
28007 + if ((regs->ip + 11) >> 32)
28008 + break;
28009 +#endif
28010 +
28011 + err = get_user(mov1, (unsigned char __user *)regs->ip);
28012 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28013 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
28014 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28015 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
28016 +
28017 + if (err)
28018 + break;
28019 +
28020 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
28021 + regs->cx = addr1;
28022 + regs->ax = addr2;
28023 + regs->ip = addr2;
28024 + return 2;
28025 + }
28026 + } while (0);
28027 +
28028 + do { /* PaX: gcc trampoline emulation #2 */
28029 + unsigned char mov, jmp;
28030 + unsigned int addr1, addr2;
28031 +
28032 +#ifdef CONFIG_X86_64
28033 + if ((regs->ip + 9) >> 32)
28034 + break;
28035 +#endif
28036 +
28037 + err = get_user(mov, (unsigned char __user *)regs->ip);
28038 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28039 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28040 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28041 +
28042 + if (err)
28043 + break;
28044 +
28045 + if (mov == 0xB9 && jmp == 0xE9) {
28046 + regs->cx = addr1;
28047 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28048 + return 2;
28049 + }
28050 + } while (0);
28051 +
28052 + return 1; /* PaX in action */
28053 +}
28054 +
28055 +#ifdef CONFIG_X86_64
28056 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
28057 +{
28058 + int err;
28059 +
28060 + do { /* PaX: libffi trampoline emulation */
28061 + unsigned short mov1, mov2, jmp1;
28062 + unsigned char stcclc, jmp2;
28063 + unsigned long addr1, addr2;
28064 +
28065 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28066 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28067 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28068 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28069 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
28070 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
28071 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
28072 +
28073 + if (err)
28074 + break;
28075 +
28076 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28077 + regs->r11 = addr1;
28078 + regs->r10 = addr2;
28079 + if (stcclc == 0xF8)
28080 + regs->flags &= ~X86_EFLAGS_CF;
28081 + else
28082 + regs->flags |= X86_EFLAGS_CF;
28083 + regs->ip = addr1;
28084 + return 2;
28085 + }
28086 + } while (0);
28087 +
28088 + do { /* PaX: gcc trampoline emulation #1 */
28089 + unsigned short mov1, mov2, jmp1;
28090 + unsigned char jmp2;
28091 + unsigned int addr1;
28092 + unsigned long addr2;
28093 +
28094 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28095 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
28096 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
28097 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
28098 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
28099 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
28100 +
28101 + if (err)
28102 + break;
28103 +
28104 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28105 + regs->r11 = addr1;
28106 + regs->r10 = addr2;
28107 + regs->ip = addr1;
28108 + return 2;
28109 + }
28110 + } while (0);
28111 +
28112 + do { /* PaX: gcc trampoline emulation #2 */
28113 + unsigned short mov1, mov2, jmp1;
28114 + unsigned char jmp2;
28115 + unsigned long addr1, addr2;
28116 +
28117 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28118 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28119 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28120 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28121 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
28122 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
28123 +
28124 + if (err)
28125 + break;
28126 +
28127 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28128 + regs->r11 = addr1;
28129 + regs->r10 = addr2;
28130 + regs->ip = addr1;
28131 + return 2;
28132 + }
28133 + } while (0);
28134 +
28135 + return 1; /* PaX in action */
28136 +}
28137 +#endif
28138 +
28139 +/*
28140 + * PaX: decide what to do with offenders (regs->ip = fault address)
28141 + *
28142 + * returns 1 when task should be killed
28143 + * 2 when gcc trampoline was detected
28144 + */
28145 +static int pax_handle_fetch_fault(struct pt_regs *regs)
28146 +{
28147 + if (v8086_mode(regs))
28148 + return 1;
28149 +
28150 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
28151 + return 1;
28152 +
28153 +#ifdef CONFIG_X86_32
28154 + return pax_handle_fetch_fault_32(regs);
28155 +#else
28156 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
28157 + return pax_handle_fetch_fault_32(regs);
28158 + else
28159 + return pax_handle_fetch_fault_64(regs);
28160 +#endif
28161 +}
28162 +#endif
28163 +
28164 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28165 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
28166 +{
28167 + long i;
28168 +
28169 + printk(KERN_ERR "PAX: bytes at PC: ");
28170 + for (i = 0; i < 20; i++) {
28171 + unsigned char c;
28172 + if (get_user(c, (unsigned char __force_user *)pc+i))
28173 + printk(KERN_CONT "?? ");
28174 + else
28175 + printk(KERN_CONT "%02x ", c);
28176 + }
28177 + printk("\n");
28178 +
28179 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
28180 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
28181 + unsigned long c;
28182 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
28183 +#ifdef CONFIG_X86_32
28184 + printk(KERN_CONT "???????? ");
28185 +#else
28186 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
28187 + printk(KERN_CONT "???????? ???????? ");
28188 + else
28189 + printk(KERN_CONT "???????????????? ");
28190 +#endif
28191 + } else {
28192 +#ifdef CONFIG_X86_64
28193 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
28194 + printk(KERN_CONT "%08x ", (unsigned int)c);
28195 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
28196 + } else
28197 +#endif
28198 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
28199 + }
28200 + }
28201 + printk("\n");
28202 +}
28203 +#endif
28204 +
28205 +/**
28206 + * probe_kernel_write(): safely attempt to write to a location
28207 + * @dst: address to write to
28208 + * @src: pointer to the data that shall be written
28209 + * @size: size of the data chunk
28210 + *
28211 + * Safely write to address @dst from the buffer at @src. If a kernel fault
28212 + * happens, handle that and return -EFAULT.
28213 + */
28214 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
28215 +{
28216 + long ret;
28217 + mm_segment_t old_fs = get_fs();
28218 +
28219 + set_fs(KERNEL_DS);
28220 + pagefault_disable();
28221 + pax_open_kernel();
28222 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
28223 + pax_close_kernel();
28224 + pagefault_enable();
28225 + set_fs(old_fs);
28226 +
28227 + return ret ? -EFAULT : 0;
28228 +}
28229 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28230 index dd74e46..7d26398 100644
28231 --- a/arch/x86/mm/gup.c
28232 +++ b/arch/x86/mm/gup.c
28233 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28234 addr = start;
28235 len = (unsigned long) nr_pages << PAGE_SHIFT;
28236 end = start + len;
28237 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28238 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28239 (void __user *)start, len)))
28240 return 0;
28241
28242 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28243 index 6f31ee5..8ee4164 100644
28244 --- a/arch/x86/mm/highmem_32.c
28245 +++ b/arch/x86/mm/highmem_32.c
28246 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28247 idx = type + KM_TYPE_NR*smp_processor_id();
28248 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28249 BUG_ON(!pte_none(*(kmap_pte-idx)));
28250 +
28251 + pax_open_kernel();
28252 set_pte(kmap_pte-idx, mk_pte(page, prot));
28253 + pax_close_kernel();
28254 +
28255 arch_flush_lazy_mmu_mode();
28256
28257 return (void *)vaddr;
28258 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28259 index ae1aa71..56316db 100644
28260 --- a/arch/x86/mm/hugetlbpage.c
28261 +++ b/arch/x86/mm/hugetlbpage.c
28262 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28263 info.flags = 0;
28264 info.length = len;
28265 info.low_limit = TASK_UNMAPPED_BASE;
28266 +
28267 +#ifdef CONFIG_PAX_RANDMMAP
28268 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28269 + info.low_limit += current->mm->delta_mmap;
28270 +#endif
28271 +
28272 info.high_limit = TASK_SIZE;
28273 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28274 info.align_offset = 0;
28275 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28276 VM_BUG_ON(addr != -ENOMEM);
28277 info.flags = 0;
28278 info.low_limit = TASK_UNMAPPED_BASE;
28279 +
28280 +#ifdef CONFIG_PAX_RANDMMAP
28281 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28282 + info.low_limit += current->mm->delta_mmap;
28283 +#endif
28284 +
28285 info.high_limit = TASK_SIZE;
28286 addr = vm_unmapped_area(&info);
28287 }
28288 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28289 struct hstate *h = hstate_file(file);
28290 struct mm_struct *mm = current->mm;
28291 struct vm_area_struct *vma;
28292 + unsigned long pax_task_size = TASK_SIZE;
28293 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28294
28295 if (len & ~huge_page_mask(h))
28296 return -EINVAL;
28297 - if (len > TASK_SIZE)
28298 +
28299 +#ifdef CONFIG_PAX_SEGMEXEC
28300 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28301 + pax_task_size = SEGMEXEC_TASK_SIZE;
28302 +#endif
28303 +
28304 + pax_task_size -= PAGE_SIZE;
28305 +
28306 + if (len > pax_task_size)
28307 return -ENOMEM;
28308
28309 if (flags & MAP_FIXED) {
28310 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28311 return addr;
28312 }
28313
28314 +#ifdef CONFIG_PAX_RANDMMAP
28315 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28316 +#endif
28317 +
28318 if (addr) {
28319 addr = ALIGN(addr, huge_page_size(h));
28320 vma = find_vma(mm, addr);
28321 - if (TASK_SIZE - len >= addr &&
28322 - (!vma || addr + len <= vma->vm_start))
28323 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28324 return addr;
28325 }
28326 if (mm->get_unmapped_area == arch_get_unmapped_area)
28327 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28328 index d7aea41..0fc945b 100644
28329 --- a/arch/x86/mm/init.c
28330 +++ b/arch/x86/mm/init.c
28331 @@ -4,6 +4,7 @@
28332 #include <linux/swap.h>
28333 #include <linux/memblock.h>
28334 #include <linux/bootmem.h> /* for max_low_pfn */
28335 +#include <linux/tboot.h>
28336
28337 #include <asm/cacheflush.h>
28338 #include <asm/e820.h>
28339 @@ -16,6 +17,8 @@
28340 #include <asm/tlb.h>
28341 #include <asm/proto.h>
28342 #include <asm/dma.h> /* for MAX_DMA_PFN */
28343 +#include <asm/desc.h>
28344 +#include <asm/bios_ebda.h>
28345
28346 unsigned long __initdata pgt_buf_start;
28347 unsigned long __meminitdata pgt_buf_end;
28348 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
28349 {
28350 int i;
28351 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
28352 - unsigned long start = 0, good_end;
28353 + unsigned long start = 0x100000, good_end;
28354 phys_addr_t base;
28355
28356 for (i = 0; i < nr_range; i++) {
28357 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
28358 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28359 * mmio resources as well as potential bios/acpi data regions.
28360 */
28361 +
28362 +#ifdef CONFIG_GRKERNSEC_KMEM
28363 +static unsigned int ebda_start __read_only;
28364 +static unsigned int ebda_end __read_only;
28365 +#endif
28366 +
28367 int devmem_is_allowed(unsigned long pagenr)
28368 {
28369 - if (pagenr < 256)
28370 +#ifdef CONFIG_GRKERNSEC_KMEM
28371 + /* allow BDA */
28372 + if (!pagenr)
28373 return 1;
28374 + /* allow EBDA */
28375 + if (pagenr >= ebda_start && pagenr < ebda_end)
28376 + return 1;
28377 + /* if tboot is in use, allow access to its hardcoded serial log range */
28378 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28379 + return 1;
28380 +#else
28381 + if (!pagenr)
28382 + return 1;
28383 +#ifdef CONFIG_VM86
28384 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28385 + return 1;
28386 +#endif
28387 +#endif
28388 +
28389 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28390 + return 1;
28391 +#ifdef CONFIG_GRKERNSEC_KMEM
28392 + /* throw out everything else below 1MB */
28393 + if (pagenr <= 256)
28394 + return 0;
28395 +#endif
28396 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28397 return 0;
28398 if (!page_is_ram(pagenr))
28399 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28400 #endif
28401 }
28402
28403 +#ifdef CONFIG_GRKERNSEC_KMEM
28404 +static inline void gr_init_ebda(void)
28405 +{
28406 + unsigned int ebda_addr;
28407 + unsigned int ebda_size = 0;
28408 +
28409 + ebda_addr = get_bios_ebda();
28410 + if (ebda_addr) {
28411 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28412 + ebda_size <<= 10;
28413 + }
28414 + if (ebda_addr && ebda_size) {
28415 + ebda_start = ebda_addr >> PAGE_SHIFT;
28416 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28417 + } else {
28418 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28419 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28420 + }
28421 +}
28422 +#else
28423 +static inline void gr_init_ebda(void) { }
28424 +#endif
28425 +
28426 void free_initmem(void)
28427 {
28428 +#ifdef CONFIG_PAX_KERNEXEC
28429 +#ifdef CONFIG_X86_32
28430 + /* PaX: limit KERNEL_CS to actual size */
28431 + unsigned long addr, limit;
28432 + struct desc_struct d;
28433 + int cpu;
28434 +#else
28435 + pgd_t *pgd;
28436 + pud_t *pud;
28437 + pmd_t *pmd;
28438 + unsigned long addr, end;
28439 +#endif
28440 +#endif
28441 +
28442 + gr_init_ebda();
28443 +
28444 +#ifdef CONFIG_PAX_KERNEXEC
28445 +#ifdef CONFIG_X86_32
28446 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28447 + limit = (limit - 1UL) >> PAGE_SHIFT;
28448 +
28449 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28450 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28451 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28452 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28453 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28454 + }
28455 +
28456 + /* PaX: make KERNEL_CS read-only */
28457 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28458 + if (!paravirt_enabled())
28459 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28460 +/*
28461 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28462 + pgd = pgd_offset_k(addr);
28463 + pud = pud_offset(pgd, addr);
28464 + pmd = pmd_offset(pud, addr);
28465 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28466 + }
28467 +*/
28468 +#ifdef CONFIG_X86_PAE
28469 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28470 +/*
28471 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28472 + pgd = pgd_offset_k(addr);
28473 + pud = pud_offset(pgd, addr);
28474 + pmd = pmd_offset(pud, addr);
28475 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28476 + }
28477 +*/
28478 +#endif
28479 +
28480 +#ifdef CONFIG_MODULES
28481 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28482 +#endif
28483 +
28484 +#else
28485 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28486 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28487 + pgd = pgd_offset_k(addr);
28488 + pud = pud_offset(pgd, addr);
28489 + pmd = pmd_offset(pud, addr);
28490 + if (!pmd_present(*pmd))
28491 + continue;
28492 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28493 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28494 + else
28495 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28496 + }
28497 +
28498 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28499 + end = addr + KERNEL_IMAGE_SIZE;
28500 + for (; addr < end; addr += PMD_SIZE) {
28501 + pgd = pgd_offset_k(addr);
28502 + pud = pud_offset(pgd, addr);
28503 + pmd = pmd_offset(pud, addr);
28504 + if (!pmd_present(*pmd))
28505 + continue;
28506 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28507 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28508 + }
28509 +#endif
28510 +
28511 + flush_tlb_all();
28512 +#endif
28513 +
28514 free_init_pages("unused kernel memory",
28515 (unsigned long)(&__init_begin),
28516 (unsigned long)(&__init_end));
28517 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28518 index 745d66b..56bf568 100644
28519 --- a/arch/x86/mm/init_32.c
28520 +++ b/arch/x86/mm/init_32.c
28521 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28522 }
28523
28524 /*
28525 - * Creates a middle page table and puts a pointer to it in the
28526 - * given global directory entry. This only returns the gd entry
28527 - * in non-PAE compilation mode, since the middle layer is folded.
28528 - */
28529 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28530 -{
28531 - pud_t *pud;
28532 - pmd_t *pmd_table;
28533 -
28534 -#ifdef CONFIG_X86_PAE
28535 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28536 - if (after_bootmem)
28537 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28538 - else
28539 - pmd_table = (pmd_t *)alloc_low_page();
28540 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28541 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28542 - pud = pud_offset(pgd, 0);
28543 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28544 -
28545 - return pmd_table;
28546 - }
28547 -#endif
28548 - pud = pud_offset(pgd, 0);
28549 - pmd_table = pmd_offset(pud, 0);
28550 -
28551 - return pmd_table;
28552 -}
28553 -
28554 -/*
28555 * Create a page table and place a pointer to it in a middle page
28556 * directory entry:
28557 */
28558 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28559 page_table = (pte_t *)alloc_low_page();
28560
28561 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28562 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28563 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28564 +#else
28565 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28566 +#endif
28567 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28568 }
28569
28570 return pte_offset_kernel(pmd, 0);
28571 }
28572
28573 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28574 +{
28575 + pud_t *pud;
28576 + pmd_t *pmd_table;
28577 +
28578 + pud = pud_offset(pgd, 0);
28579 + pmd_table = pmd_offset(pud, 0);
28580 +
28581 + return pmd_table;
28582 +}
28583 +
28584 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28585 {
28586 int pgd_idx = pgd_index(vaddr);
28587 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28588 int pgd_idx, pmd_idx;
28589 unsigned long vaddr;
28590 pgd_t *pgd;
28591 + pud_t *pud;
28592 pmd_t *pmd;
28593 pte_t *pte = NULL;
28594
28595 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28596 pgd = pgd_base + pgd_idx;
28597
28598 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28599 - pmd = one_md_table_init(pgd);
28600 - pmd = pmd + pmd_index(vaddr);
28601 + pud = pud_offset(pgd, vaddr);
28602 + pmd = pmd_offset(pud, vaddr);
28603 +
28604 +#ifdef CONFIG_X86_PAE
28605 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28606 +#endif
28607 +
28608 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28609 pmd++, pmd_idx++) {
28610 pte = page_table_kmap_check(one_page_table_init(pmd),
28611 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28612 }
28613 }
28614
28615 -static inline int is_kernel_text(unsigned long addr)
28616 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28617 {
28618 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28619 - return 1;
28620 - return 0;
28621 + if ((start > ktla_ktva((unsigned long)_etext) ||
28622 + end <= ktla_ktva((unsigned long)_stext)) &&
28623 + (start > ktla_ktva((unsigned long)_einittext) ||
28624 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28625 +
28626 +#ifdef CONFIG_ACPI_SLEEP
28627 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28628 +#endif
28629 +
28630 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28631 + return 0;
28632 + return 1;
28633 }
28634
28635 /*
28636 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28637 unsigned long last_map_addr = end;
28638 unsigned long start_pfn, end_pfn;
28639 pgd_t *pgd_base = swapper_pg_dir;
28640 - int pgd_idx, pmd_idx, pte_ofs;
28641 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28642 unsigned long pfn;
28643 pgd_t *pgd;
28644 + pud_t *pud;
28645 pmd_t *pmd;
28646 pte_t *pte;
28647 unsigned pages_2m, pages_4k;
28648 @@ -280,8 +281,13 @@ repeat:
28649 pfn = start_pfn;
28650 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28651 pgd = pgd_base + pgd_idx;
28652 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28653 - pmd = one_md_table_init(pgd);
28654 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28655 + pud = pud_offset(pgd, 0);
28656 + pmd = pmd_offset(pud, 0);
28657 +
28658 +#ifdef CONFIG_X86_PAE
28659 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28660 +#endif
28661
28662 if (pfn >= end_pfn)
28663 continue;
28664 @@ -293,14 +299,13 @@ repeat:
28665 #endif
28666 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28667 pmd++, pmd_idx++) {
28668 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28669 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28670
28671 /*
28672 * Map with big pages if possible, otherwise
28673 * create normal page tables:
28674 */
28675 if (use_pse) {
28676 - unsigned int addr2;
28677 pgprot_t prot = PAGE_KERNEL_LARGE;
28678 /*
28679 * first pass will use the same initial
28680 @@ -310,11 +315,7 @@ repeat:
28681 __pgprot(PTE_IDENT_ATTR |
28682 _PAGE_PSE);
28683
28684 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28685 - PAGE_OFFSET + PAGE_SIZE-1;
28686 -
28687 - if (is_kernel_text(addr) ||
28688 - is_kernel_text(addr2))
28689 + if (is_kernel_text(address, address + PMD_SIZE))
28690 prot = PAGE_KERNEL_LARGE_EXEC;
28691
28692 pages_2m++;
28693 @@ -331,7 +332,7 @@ repeat:
28694 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28695 pte += pte_ofs;
28696 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28697 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28698 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28699 pgprot_t prot = PAGE_KERNEL;
28700 /*
28701 * first pass will use the same initial
28702 @@ -339,7 +340,7 @@ repeat:
28703 */
28704 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28705
28706 - if (is_kernel_text(addr))
28707 + if (is_kernel_text(address, address + PAGE_SIZE))
28708 prot = PAGE_KERNEL_EXEC;
28709
28710 pages_4k++;
28711 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28712
28713 pud = pud_offset(pgd, va);
28714 pmd = pmd_offset(pud, va);
28715 - if (!pmd_present(*pmd))
28716 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28717 break;
28718
28719 pte = pte_offset_kernel(pmd, va);
28720 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28721
28722 static void __init pagetable_init(void)
28723 {
28724 - pgd_t *pgd_base = swapper_pg_dir;
28725 -
28726 - permanent_kmaps_init(pgd_base);
28727 + permanent_kmaps_init(swapper_pg_dir);
28728 }
28729
28730 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28731 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28732 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28733
28734 /* user-defined highmem size */
28735 @@ -728,6 +727,12 @@ void __init mem_init(void)
28736
28737 pci_iommu_alloc();
28738
28739 +#ifdef CONFIG_PAX_PER_CPU_PGD
28740 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28741 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28742 + KERNEL_PGD_PTRS);
28743 +#endif
28744 +
28745 #ifdef CONFIG_FLATMEM
28746 BUG_ON(!mem_map);
28747 #endif
28748 @@ -754,7 +759,7 @@ void __init mem_init(void)
28749 reservedpages++;
28750
28751 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28752 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28753 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28754 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28755
28756 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28757 @@ -795,10 +800,10 @@ void __init mem_init(void)
28758 ((unsigned long)&__init_end -
28759 (unsigned long)&__init_begin) >> 10,
28760
28761 - (unsigned long)&_etext, (unsigned long)&_edata,
28762 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28763 + (unsigned long)&_sdata, (unsigned long)&_edata,
28764 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28765
28766 - (unsigned long)&_text, (unsigned long)&_etext,
28767 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28768 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28769
28770 /*
28771 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28772 if (!kernel_set_to_readonly)
28773 return;
28774
28775 + start = ktla_ktva(start);
28776 pr_debug("Set kernel text: %lx - %lx for read write\n",
28777 start, start+size);
28778
28779 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
28780 if (!kernel_set_to_readonly)
28781 return;
28782
28783 + start = ktla_ktva(start);
28784 pr_debug("Set kernel text: %lx - %lx for read only\n",
28785 start, start+size);
28786
28787 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28788 unsigned long start = PFN_ALIGN(_text);
28789 unsigned long size = PFN_ALIGN(_etext) - start;
28790
28791 + start = ktla_ktva(start);
28792 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28793 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28794 size >> 10);
28795 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28796 index 75c9a6a..498d677 100644
28797 --- a/arch/x86/mm/init_64.c
28798 +++ b/arch/x86/mm/init_64.c
28799 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28800 * around without checking the pgd every time.
28801 */
28802
28803 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28804 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28805 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28806
28807 int force_personality32;
28808 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28809
28810 for (address = start; address <= end; address += PGDIR_SIZE) {
28811 const pgd_t *pgd_ref = pgd_offset_k(address);
28812 +
28813 +#ifdef CONFIG_PAX_PER_CPU_PGD
28814 + unsigned long cpu;
28815 +#else
28816 struct page *page;
28817 +#endif
28818
28819 if (pgd_none(*pgd_ref))
28820 continue;
28821
28822 spin_lock(&pgd_lock);
28823 +
28824 +#ifdef CONFIG_PAX_PER_CPU_PGD
28825 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28826 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28827 +#else
28828 list_for_each_entry(page, &pgd_list, lru) {
28829 pgd_t *pgd;
28830 spinlock_t *pgt_lock;
28831 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28832 /* the pgt_lock only for Xen */
28833 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28834 spin_lock(pgt_lock);
28835 +#endif
28836
28837 if (pgd_none(*pgd))
28838 set_pgd(pgd, *pgd_ref);
28839 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28840 BUG_ON(pgd_page_vaddr(*pgd)
28841 != pgd_page_vaddr(*pgd_ref));
28842
28843 +#ifndef CONFIG_PAX_PER_CPU_PGD
28844 spin_unlock(pgt_lock);
28845 +#endif
28846 +
28847 }
28848 spin_unlock(&pgd_lock);
28849 }
28850 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28851 {
28852 if (pgd_none(*pgd)) {
28853 pud_t *pud = (pud_t *)spp_getpage();
28854 - pgd_populate(&init_mm, pgd, pud);
28855 + pgd_populate_kernel(&init_mm, pgd, pud);
28856 if (pud != pud_offset(pgd, 0))
28857 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28858 pud, pud_offset(pgd, 0));
28859 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28860 {
28861 if (pud_none(*pud)) {
28862 pmd_t *pmd = (pmd_t *) spp_getpage();
28863 - pud_populate(&init_mm, pud, pmd);
28864 + pud_populate_kernel(&init_mm, pud, pmd);
28865 if (pmd != pmd_offset(pud, 0))
28866 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28867 pmd, pmd_offset(pud, 0));
28868 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28869 pmd = fill_pmd(pud, vaddr);
28870 pte = fill_pte(pmd, vaddr);
28871
28872 + pax_open_kernel();
28873 set_pte(pte, new_pte);
28874 + pax_close_kernel();
28875
28876 /*
28877 * It's enough to flush this one mapping.
28878 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28879 pgd = pgd_offset_k((unsigned long)__va(phys));
28880 if (pgd_none(*pgd)) {
28881 pud = (pud_t *) spp_getpage();
28882 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28883 - _PAGE_USER));
28884 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28885 }
28886 pud = pud_offset(pgd, (unsigned long)__va(phys));
28887 if (pud_none(*pud)) {
28888 pmd = (pmd_t *) spp_getpage();
28889 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28890 - _PAGE_USER));
28891 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28892 }
28893 pmd = pmd_offset(pud, phys);
28894 BUG_ON(!pmd_none(*pmd));
28895 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28896 if (pfn >= pgt_buf_top)
28897 panic("alloc_low_page: ran out of memory");
28898
28899 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28900 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28901 clear_page(adr);
28902 *phys = pfn * PAGE_SIZE;
28903 return adr;
28904 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28905
28906 phys = __pa(virt);
28907 left = phys & (PAGE_SIZE - 1);
28908 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28909 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28910 adr = (void *)(((unsigned long)adr) | left);
28911
28912 return adr;
28913 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28914 unmap_low_page(pmd);
28915
28916 spin_lock(&init_mm.page_table_lock);
28917 - pud_populate(&init_mm, pud, __va(pmd_phys));
28918 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28919 spin_unlock(&init_mm.page_table_lock);
28920 }
28921 __flush_tlb_all();
28922 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28923 unmap_low_page(pud);
28924
28925 spin_lock(&init_mm.page_table_lock);
28926 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28927 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28928 spin_unlock(&init_mm.page_table_lock);
28929 pgd_changed = true;
28930 }
28931 @@ -693,6 +707,12 @@ void __init mem_init(void)
28932
28933 pci_iommu_alloc();
28934
28935 +#ifdef CONFIG_PAX_PER_CPU_PGD
28936 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28937 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28938 + KERNEL_PGD_PTRS);
28939 +#endif
28940 +
28941 /* clear_bss() already clear the empty_zero_page */
28942
28943 reservedpages = 0;
28944 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28945 static struct vm_area_struct gate_vma = {
28946 .vm_start = VSYSCALL_START,
28947 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28948 - .vm_page_prot = PAGE_READONLY_EXEC,
28949 - .vm_flags = VM_READ | VM_EXEC
28950 + .vm_page_prot = PAGE_READONLY,
28951 + .vm_flags = VM_READ
28952 };
28953
28954 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28955 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28956
28957 const char *arch_vma_name(struct vm_area_struct *vma)
28958 {
28959 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28960 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28961 return "[vdso]";
28962 if (vma == &gate_vma)
28963 return "[vsyscall]";
28964 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28965 index 7b179b4..6bd17777 100644
28966 --- a/arch/x86/mm/iomap_32.c
28967 +++ b/arch/x86/mm/iomap_32.c
28968 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28969 type = kmap_atomic_idx_push();
28970 idx = type + KM_TYPE_NR * smp_processor_id();
28971 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28972 +
28973 + pax_open_kernel();
28974 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28975 + pax_close_kernel();
28976 +
28977 arch_flush_lazy_mmu_mode();
28978
28979 return (void *)vaddr;
28980 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28981 index 78fe3f1..73b95e2 100644
28982 --- a/arch/x86/mm/ioremap.c
28983 +++ b/arch/x86/mm/ioremap.c
28984 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28985 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28986 int is_ram = page_is_ram(pfn);
28987
28988 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28989 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28990 return NULL;
28991 WARN_ON_ONCE(is_ram);
28992 }
28993 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28994 *
28995 * Caller must ensure there is only one unmapping for the same pointer.
28996 */
28997 -void iounmap(volatile void __iomem *addr)
28998 +void iounmap(const volatile void __iomem *addr)
28999 {
29000 struct vm_struct *p, *o;
29001
29002 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29003
29004 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
29005 if (page_is_ram(start >> PAGE_SHIFT))
29006 +#ifdef CONFIG_HIGHMEM
29007 + if ((start >> PAGE_SHIFT) < max_low_pfn)
29008 +#endif
29009 return __va(phys);
29010
29011 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
29012 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29013 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
29014 {
29015 if (page_is_ram(phys >> PAGE_SHIFT))
29016 +#ifdef CONFIG_HIGHMEM
29017 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
29018 +#endif
29019 return;
29020
29021 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
29022 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
29023 early_param("early_ioremap_debug", early_ioremap_debug_setup);
29024
29025 static __initdata int after_paging_init;
29026 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
29027 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
29028
29029 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
29030 {
29031 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
29032 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
29033
29034 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
29035 - memset(bm_pte, 0, sizeof(bm_pte));
29036 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
29037 + pmd_populate_user(&init_mm, pmd, bm_pte);
29038
29039 /*
29040 * The boot-ioremap range spans multiple pmds, for which
29041 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
29042 index d87dd6d..bf3fa66 100644
29043 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
29044 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
29045 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
29046 * memory (e.g. tracked pages)? For now, we need this to avoid
29047 * invoking kmemcheck for PnP BIOS calls.
29048 */
29049 - if (regs->flags & X86_VM_MASK)
29050 + if (v8086_mode(regs))
29051 return false;
29052 - if (regs->cs != __KERNEL_CS)
29053 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
29054 return false;
29055
29056 pte = kmemcheck_pte_lookup(address);
29057 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
29058 index 845df68..1d8d29f 100644
29059 --- a/arch/x86/mm/mmap.c
29060 +++ b/arch/x86/mm/mmap.c
29061 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
29062 * Leave an at least ~128 MB hole with possible stack randomization.
29063 */
29064 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
29065 -#define MAX_GAP (TASK_SIZE/6*5)
29066 +#define MAX_GAP (pax_task_size/6*5)
29067
29068 static int mmap_is_legacy(void)
29069 {
29070 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
29071 return rnd << PAGE_SHIFT;
29072 }
29073
29074 -static unsigned long mmap_base(void)
29075 +static unsigned long mmap_base(struct mm_struct *mm)
29076 {
29077 unsigned long gap = rlimit(RLIMIT_STACK);
29078 + unsigned long pax_task_size = TASK_SIZE;
29079 +
29080 +#ifdef CONFIG_PAX_SEGMEXEC
29081 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29082 + pax_task_size = SEGMEXEC_TASK_SIZE;
29083 +#endif
29084
29085 if (gap < MIN_GAP)
29086 gap = MIN_GAP;
29087 else if (gap > MAX_GAP)
29088 gap = MAX_GAP;
29089
29090 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
29091 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
29092 }
29093
29094 /*
29095 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
29096 * does, but not when emulating X86_32
29097 */
29098 -static unsigned long mmap_legacy_base(void)
29099 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
29100 {
29101 - if (mmap_is_ia32())
29102 + if (mmap_is_ia32()) {
29103 +
29104 +#ifdef CONFIG_PAX_SEGMEXEC
29105 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29106 + return SEGMEXEC_TASK_UNMAPPED_BASE;
29107 + else
29108 +#endif
29109 +
29110 return TASK_UNMAPPED_BASE;
29111 - else
29112 + } else
29113 return TASK_UNMAPPED_BASE + mmap_rnd();
29114 }
29115
29116 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
29117 void arch_pick_mmap_layout(struct mm_struct *mm)
29118 {
29119 if (mmap_is_legacy()) {
29120 - mm->mmap_base = mmap_legacy_base();
29121 + mm->mmap_base = mmap_legacy_base(mm);
29122 +
29123 +#ifdef CONFIG_PAX_RANDMMAP
29124 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29125 + mm->mmap_base += mm->delta_mmap;
29126 +#endif
29127 +
29128 mm->get_unmapped_area = arch_get_unmapped_area;
29129 mm->unmap_area = arch_unmap_area;
29130 } else {
29131 - mm->mmap_base = mmap_base();
29132 + mm->mmap_base = mmap_base(mm);
29133 +
29134 +#ifdef CONFIG_PAX_RANDMMAP
29135 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29136 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
29137 +#endif
29138 +
29139 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
29140 mm->unmap_area = arch_unmap_area_topdown;
29141 }
29142 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
29143 index dc0b727..f612039 100644
29144 --- a/arch/x86/mm/mmio-mod.c
29145 +++ b/arch/x86/mm/mmio-mod.c
29146 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
29147 break;
29148 default:
29149 {
29150 - unsigned char *ip = (unsigned char *)instptr;
29151 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
29152 my_trace->opcode = MMIO_UNKNOWN_OP;
29153 my_trace->width = 0;
29154 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
29155 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
29156 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29157 void __iomem *addr)
29158 {
29159 - static atomic_t next_id;
29160 + static atomic_unchecked_t next_id;
29161 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
29162 /* These are page-unaligned. */
29163 struct mmiotrace_map map = {
29164 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29165 .private = trace
29166 },
29167 .phys = offset,
29168 - .id = atomic_inc_return(&next_id)
29169 + .id = atomic_inc_return_unchecked(&next_id)
29170 };
29171 map.map_id = trace->id;
29172
29173 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
29174 ioremap_trace_core(offset, size, addr);
29175 }
29176
29177 -static void iounmap_trace_core(volatile void __iomem *addr)
29178 +static void iounmap_trace_core(const volatile void __iomem *addr)
29179 {
29180 struct mmiotrace_map map = {
29181 .phys = 0,
29182 @@ -328,7 +328,7 @@ not_enabled:
29183 }
29184 }
29185
29186 -void mmiotrace_iounmap(volatile void __iomem *addr)
29187 +void mmiotrace_iounmap(const volatile void __iomem *addr)
29188 {
29189 might_sleep();
29190 if (is_enabled()) /* recheck and proper locking in *_core() */
29191 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
29192 index 8504f36..5fc68f2 100644
29193 --- a/arch/x86/mm/numa.c
29194 +++ b/arch/x86/mm/numa.c
29195 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
29196 return true;
29197 }
29198
29199 -static int __init numa_register_memblks(struct numa_meminfo *mi)
29200 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
29201 {
29202 unsigned long uninitialized_var(pfn_align);
29203 int i, nid;
29204 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
29205 index b008656..773eac2 100644
29206 --- a/arch/x86/mm/pageattr-test.c
29207 +++ b/arch/x86/mm/pageattr-test.c
29208 @@ -36,7 +36,7 @@ enum {
29209
29210 static int pte_testbit(pte_t pte)
29211 {
29212 - return pte_flags(pte) & _PAGE_UNUSED1;
29213 + return pte_flags(pte) & _PAGE_CPA_TEST;
29214 }
29215
29216 struct split_state {
29217 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
29218 index a718e0d..77419bc 100644
29219 --- a/arch/x86/mm/pageattr.c
29220 +++ b/arch/x86/mm/pageattr.c
29221 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29222 */
29223 #ifdef CONFIG_PCI_BIOS
29224 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
29225 - pgprot_val(forbidden) |= _PAGE_NX;
29226 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29227 #endif
29228
29229 /*
29230 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29231 * Does not cover __inittext since that is gone later on. On
29232 * 64bit we do not enforce !NX on the low mapping
29233 */
29234 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29235 - pgprot_val(forbidden) |= _PAGE_NX;
29236 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29237 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29238
29239 +#ifdef CONFIG_DEBUG_RODATA
29240 /*
29241 * The .rodata section needs to be read-only. Using the pfn
29242 * catches all aliases.
29243 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29244 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
29245 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
29246 pgprot_val(forbidden) |= _PAGE_RW;
29247 +#endif
29248
29249 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29250 /*
29251 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29252 }
29253 #endif
29254
29255 +#ifdef CONFIG_PAX_KERNEXEC
29256 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29257 + pgprot_val(forbidden) |= _PAGE_RW;
29258 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29259 + }
29260 +#endif
29261 +
29262 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29263
29264 return prot;
29265 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
29266 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29267 {
29268 /* change init_mm */
29269 + pax_open_kernel();
29270 set_pte_atomic(kpte, pte);
29271 +
29272 #ifdef CONFIG_X86_32
29273 if (!SHARED_KERNEL_PMD) {
29274 +
29275 +#ifdef CONFIG_PAX_PER_CPU_PGD
29276 + unsigned long cpu;
29277 +#else
29278 struct page *page;
29279 +#endif
29280
29281 +#ifdef CONFIG_PAX_PER_CPU_PGD
29282 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29283 + pgd_t *pgd = get_cpu_pgd(cpu);
29284 +#else
29285 list_for_each_entry(page, &pgd_list, lru) {
29286 - pgd_t *pgd;
29287 + pgd_t *pgd = (pgd_t *)page_address(page);
29288 +#endif
29289 +
29290 pud_t *pud;
29291 pmd_t *pmd;
29292
29293 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29294 + pgd += pgd_index(address);
29295 pud = pud_offset(pgd, address);
29296 pmd = pmd_offset(pud, address);
29297 set_pte_atomic((pte_t *)pmd, pte);
29298 }
29299 }
29300 #endif
29301 + pax_close_kernel();
29302 }
29303
29304 static int
29305 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29306 index 0eb572e..92f5c1e 100644
29307 --- a/arch/x86/mm/pat.c
29308 +++ b/arch/x86/mm/pat.c
29309 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29310
29311 if (!entry) {
29312 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29313 - current->comm, current->pid, start, end - 1);
29314 + current->comm, task_pid_nr(current), start, end - 1);
29315 return -EINVAL;
29316 }
29317
29318 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29319
29320 while (cursor < to) {
29321 if (!devmem_is_allowed(pfn)) {
29322 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29323 - current->comm, from, to - 1);
29324 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29325 + current->comm, from, to - 1, cursor);
29326 return 0;
29327 }
29328 cursor += PAGE_SIZE;
29329 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29330 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29331 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29332 "for [mem %#010Lx-%#010Lx]\n",
29333 - current->comm, current->pid,
29334 + current->comm, task_pid_nr(current),
29335 cattr_name(flags),
29336 base, (unsigned long long)(base + size-1));
29337 return -EINVAL;
29338 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29339 flags = lookup_memtype(paddr);
29340 if (want_flags != flags) {
29341 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29342 - current->comm, current->pid,
29343 + current->comm, task_pid_nr(current),
29344 cattr_name(want_flags),
29345 (unsigned long long)paddr,
29346 (unsigned long long)(paddr + size - 1),
29347 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29348 free_memtype(paddr, paddr + size);
29349 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29350 " for [mem %#010Lx-%#010Lx], got %s\n",
29351 - current->comm, current->pid,
29352 + current->comm, task_pid_nr(current),
29353 cattr_name(want_flags),
29354 (unsigned long long)paddr,
29355 (unsigned long long)(paddr + size - 1),
29356 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29357 index 9f0614d..92ae64a 100644
29358 --- a/arch/x86/mm/pf_in.c
29359 +++ b/arch/x86/mm/pf_in.c
29360 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29361 int i;
29362 enum reason_type rv = OTHERS;
29363
29364 - p = (unsigned char *)ins_addr;
29365 + p = (unsigned char *)ktla_ktva(ins_addr);
29366 p += skip_prefix(p, &prf);
29367 p += get_opcode(p, &opcode);
29368
29369 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29370 struct prefix_bits prf;
29371 int i;
29372
29373 - p = (unsigned char *)ins_addr;
29374 + p = (unsigned char *)ktla_ktva(ins_addr);
29375 p += skip_prefix(p, &prf);
29376 p += get_opcode(p, &opcode);
29377
29378 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29379 struct prefix_bits prf;
29380 int i;
29381
29382 - p = (unsigned char *)ins_addr;
29383 + p = (unsigned char *)ktla_ktva(ins_addr);
29384 p += skip_prefix(p, &prf);
29385 p += get_opcode(p, &opcode);
29386
29387 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29388 struct prefix_bits prf;
29389 int i;
29390
29391 - p = (unsigned char *)ins_addr;
29392 + p = (unsigned char *)ktla_ktva(ins_addr);
29393 p += skip_prefix(p, &prf);
29394 p += get_opcode(p, &opcode);
29395 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29396 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29397 struct prefix_bits prf;
29398 int i;
29399
29400 - p = (unsigned char *)ins_addr;
29401 + p = (unsigned char *)ktla_ktva(ins_addr);
29402 p += skip_prefix(p, &prf);
29403 p += get_opcode(p, &opcode);
29404 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29405 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29406 index 395b3b4a..213e72b 100644
29407 --- a/arch/x86/mm/pgtable.c
29408 +++ b/arch/x86/mm/pgtable.c
29409 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29410 list_del(&page->lru);
29411 }
29412
29413 -#define UNSHARED_PTRS_PER_PGD \
29414 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29415 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29416 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29417
29418 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29419 +{
29420 + unsigned int count = USER_PGD_PTRS;
29421
29422 + while (count--)
29423 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29424 +}
29425 +#endif
29426 +
29427 +#ifdef CONFIG_PAX_PER_CPU_PGD
29428 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29429 +{
29430 + unsigned int count = USER_PGD_PTRS;
29431 +
29432 + while (count--) {
29433 + pgd_t pgd;
29434 +
29435 +#ifdef CONFIG_X86_64
29436 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29437 +#else
29438 + pgd = *src++;
29439 +#endif
29440 +
29441 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29442 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29443 +#endif
29444 +
29445 + *dst++ = pgd;
29446 + }
29447 +
29448 +}
29449 +#endif
29450 +
29451 +#ifdef CONFIG_X86_64
29452 +#define pxd_t pud_t
29453 +#define pyd_t pgd_t
29454 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29455 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29456 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29457 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29458 +#define PYD_SIZE PGDIR_SIZE
29459 +#else
29460 +#define pxd_t pmd_t
29461 +#define pyd_t pud_t
29462 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29463 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29464 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29465 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29466 +#define PYD_SIZE PUD_SIZE
29467 +#endif
29468 +
29469 +#ifdef CONFIG_PAX_PER_CPU_PGD
29470 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29471 +static inline void pgd_dtor(pgd_t *pgd) {}
29472 +#else
29473 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29474 {
29475 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29476 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29477 pgd_list_del(pgd);
29478 spin_unlock(&pgd_lock);
29479 }
29480 +#endif
29481
29482 /*
29483 * List of all pgd's needed for non-PAE so it can invalidate entries
29484 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29485 * -- nyc
29486 */
29487
29488 -#ifdef CONFIG_X86_PAE
29489 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29490 /*
29491 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29492 * updating the top-level pagetable entries to guarantee the
29493 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29494 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29495 * and initialize the kernel pmds here.
29496 */
29497 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29498 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29499
29500 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29501 {
29502 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29503 */
29504 flush_tlb_mm(mm);
29505 }
29506 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29507 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29508 #else /* !CONFIG_X86_PAE */
29509
29510 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29511 -#define PREALLOCATED_PMDS 0
29512 +#define PREALLOCATED_PXDS 0
29513
29514 #endif /* CONFIG_X86_PAE */
29515
29516 -static void free_pmds(pmd_t *pmds[])
29517 +static void free_pxds(pxd_t *pxds[])
29518 {
29519 int i;
29520
29521 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29522 - if (pmds[i])
29523 - free_page((unsigned long)pmds[i]);
29524 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29525 + if (pxds[i])
29526 + free_page((unsigned long)pxds[i]);
29527 }
29528
29529 -static int preallocate_pmds(pmd_t *pmds[])
29530 +static int preallocate_pxds(pxd_t *pxds[])
29531 {
29532 int i;
29533 bool failed = false;
29534
29535 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29536 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29537 - if (pmd == NULL)
29538 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29539 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29540 + if (pxd == NULL)
29541 failed = true;
29542 - pmds[i] = pmd;
29543 + pxds[i] = pxd;
29544 }
29545
29546 if (failed) {
29547 - free_pmds(pmds);
29548 + free_pxds(pxds);
29549 return -ENOMEM;
29550 }
29551
29552 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29553 * preallocate which never got a corresponding vma will need to be
29554 * freed manually.
29555 */
29556 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29557 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29558 {
29559 int i;
29560
29561 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29562 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29563 pgd_t pgd = pgdp[i];
29564
29565 if (pgd_val(pgd) != 0) {
29566 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29567 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29568
29569 - pgdp[i] = native_make_pgd(0);
29570 + set_pgd(pgdp + i, native_make_pgd(0));
29571
29572 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29573 - pmd_free(mm, pmd);
29574 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29575 + pxd_free(mm, pxd);
29576 }
29577 }
29578 }
29579
29580 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29581 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29582 {
29583 - pud_t *pud;
29584 + pyd_t *pyd;
29585 unsigned long addr;
29586 int i;
29587
29588 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29589 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29590 return;
29591
29592 - pud = pud_offset(pgd, 0);
29593 +#ifdef CONFIG_X86_64
29594 + pyd = pyd_offset(mm, 0L);
29595 +#else
29596 + pyd = pyd_offset(pgd, 0L);
29597 +#endif
29598
29599 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29600 - i++, pud++, addr += PUD_SIZE) {
29601 - pmd_t *pmd = pmds[i];
29602 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29603 + i++, pyd++, addr += PYD_SIZE) {
29604 + pxd_t *pxd = pxds[i];
29605
29606 if (i >= KERNEL_PGD_BOUNDARY)
29607 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29608 - sizeof(pmd_t) * PTRS_PER_PMD);
29609 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29610 + sizeof(pxd_t) * PTRS_PER_PMD);
29611
29612 - pud_populate(mm, pud, pmd);
29613 + pyd_populate(mm, pyd, pxd);
29614 }
29615 }
29616
29617 pgd_t *pgd_alloc(struct mm_struct *mm)
29618 {
29619 pgd_t *pgd;
29620 - pmd_t *pmds[PREALLOCATED_PMDS];
29621 + pxd_t *pxds[PREALLOCATED_PXDS];
29622
29623 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29624
29625 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29626
29627 mm->pgd = pgd;
29628
29629 - if (preallocate_pmds(pmds) != 0)
29630 + if (preallocate_pxds(pxds) != 0)
29631 goto out_free_pgd;
29632
29633 if (paravirt_pgd_alloc(mm) != 0)
29634 - goto out_free_pmds;
29635 + goto out_free_pxds;
29636
29637 /*
29638 * Make sure that pre-populating the pmds is atomic with
29639 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29640 spin_lock(&pgd_lock);
29641
29642 pgd_ctor(mm, pgd);
29643 - pgd_prepopulate_pmd(mm, pgd, pmds);
29644 + pgd_prepopulate_pxd(mm, pgd, pxds);
29645
29646 spin_unlock(&pgd_lock);
29647
29648 return pgd;
29649
29650 -out_free_pmds:
29651 - free_pmds(pmds);
29652 +out_free_pxds:
29653 + free_pxds(pxds);
29654 out_free_pgd:
29655 free_page((unsigned long)pgd);
29656 out:
29657 @@ -302,7 +363,7 @@ out:
29658
29659 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29660 {
29661 - pgd_mop_up_pmds(mm, pgd);
29662 + pgd_mop_up_pxds(mm, pgd);
29663 pgd_dtor(pgd);
29664 paravirt_pgd_free(mm, pgd);
29665 free_page((unsigned long)pgd);
29666 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29667 index a69bcb8..19068ab 100644
29668 --- a/arch/x86/mm/pgtable_32.c
29669 +++ b/arch/x86/mm/pgtable_32.c
29670 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29671 return;
29672 }
29673 pte = pte_offset_kernel(pmd, vaddr);
29674 +
29675 + pax_open_kernel();
29676 if (pte_val(pteval))
29677 set_pte_at(&init_mm, vaddr, pte, pteval);
29678 else
29679 pte_clear(&init_mm, vaddr, pte);
29680 + pax_close_kernel();
29681
29682 /*
29683 * It's enough to flush this one mapping.
29684 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29685 index d2e2735..5c6586f 100644
29686 --- a/arch/x86/mm/physaddr.c
29687 +++ b/arch/x86/mm/physaddr.c
29688 @@ -8,7 +8,7 @@
29689
29690 #ifdef CONFIG_X86_64
29691
29692 -unsigned long __phys_addr(unsigned long x)
29693 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29694 {
29695 if (x >= __START_KERNEL_map) {
29696 x -= __START_KERNEL_map;
29697 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29698 #else
29699
29700 #ifdef CONFIG_DEBUG_VIRTUAL
29701 -unsigned long __phys_addr(unsigned long x)
29702 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29703 {
29704 /* VMALLOC_* aren't constants */
29705 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29706 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29707 index 410531d..0f16030 100644
29708 --- a/arch/x86/mm/setup_nx.c
29709 +++ b/arch/x86/mm/setup_nx.c
29710 @@ -5,8 +5,10 @@
29711 #include <asm/pgtable.h>
29712 #include <asm/proto.h>
29713
29714 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29715 static int disable_nx __cpuinitdata;
29716
29717 +#ifndef CONFIG_PAX_PAGEEXEC
29718 /*
29719 * noexec = on|off
29720 *
29721 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29722 return 0;
29723 }
29724 early_param("noexec", noexec_setup);
29725 +#endif
29726 +
29727 +#endif
29728
29729 void __cpuinit x86_configure_nx(void)
29730 {
29731 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29732 if (cpu_has_nx && !disable_nx)
29733 __supported_pte_mask |= _PAGE_NX;
29734 else
29735 +#endif
29736 __supported_pte_mask &= ~_PAGE_NX;
29737 }
29738
29739 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29740 index 13a6b29..c2fff23 100644
29741 --- a/arch/x86/mm/tlb.c
29742 +++ b/arch/x86/mm/tlb.c
29743 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29744 BUG();
29745 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29746 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29747 +
29748 +#ifndef CONFIG_PAX_PER_CPU_PGD
29749 load_cr3(swapper_pg_dir);
29750 +#endif
29751 +
29752 }
29753 }
29754 EXPORT_SYMBOL_GPL(leave_mm);
29755 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29756 index 877b9a1..a8ecf42 100644
29757 --- a/arch/x86/net/bpf_jit.S
29758 +++ b/arch/x86/net/bpf_jit.S
29759 @@ -9,6 +9,7 @@
29760 */
29761 #include <linux/linkage.h>
29762 #include <asm/dwarf2.h>
29763 +#include <asm/alternative-asm.h>
29764
29765 /*
29766 * Calling convention :
29767 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29768 jle bpf_slow_path_word
29769 mov (SKBDATA,%rsi),%eax
29770 bswap %eax /* ntohl() */
29771 + pax_force_retaddr
29772 ret
29773
29774 sk_load_half:
29775 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29776 jle bpf_slow_path_half
29777 movzwl (SKBDATA,%rsi),%eax
29778 rol $8,%ax # ntohs()
29779 + pax_force_retaddr
29780 ret
29781
29782 sk_load_byte:
29783 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29784 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29785 jle bpf_slow_path_byte
29786 movzbl (SKBDATA,%rsi),%eax
29787 + pax_force_retaddr
29788 ret
29789
29790 /**
29791 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29792 movzbl (SKBDATA,%rsi),%ebx
29793 and $15,%bl
29794 shl $2,%bl
29795 + pax_force_retaddr
29796 ret
29797
29798 /* rsi contains offset and can be scratched */
29799 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29800 js bpf_error
29801 mov -12(%rbp),%eax
29802 bswap %eax
29803 + pax_force_retaddr
29804 ret
29805
29806 bpf_slow_path_half:
29807 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29808 mov -12(%rbp),%ax
29809 rol $8,%ax
29810 movzwl %ax,%eax
29811 + pax_force_retaddr
29812 ret
29813
29814 bpf_slow_path_byte:
29815 bpf_slow_path_common(1)
29816 js bpf_error
29817 movzbl -12(%rbp),%eax
29818 + pax_force_retaddr
29819 ret
29820
29821 bpf_slow_path_byte_msh:
29822 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29823 and $15,%al
29824 shl $2,%al
29825 xchg %eax,%ebx
29826 + pax_force_retaddr
29827 ret
29828
29829 #define sk_negative_common(SIZE) \
29830 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29831 sk_negative_common(4)
29832 mov (%rax), %eax
29833 bswap %eax
29834 + pax_force_retaddr
29835 ret
29836
29837 bpf_slow_path_half_neg:
29838 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29839 mov (%rax),%ax
29840 rol $8,%ax
29841 movzwl %ax,%eax
29842 + pax_force_retaddr
29843 ret
29844
29845 bpf_slow_path_byte_neg:
29846 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29847 .globl sk_load_byte_negative_offset
29848 sk_negative_common(1)
29849 movzbl (%rax), %eax
29850 + pax_force_retaddr
29851 ret
29852
29853 bpf_slow_path_byte_msh_neg:
29854 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29855 and $15,%al
29856 shl $2,%al
29857 xchg %eax,%ebx
29858 + pax_force_retaddr
29859 ret
29860
29861 bpf_error:
29862 @@ -197,4 +210,5 @@ bpf_error:
29863 xor %eax,%eax
29864 mov -8(%rbp),%rbx
29865 leaveq
29866 + pax_force_retaddr
29867 ret
29868 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29869 index d11a470..3f9adff3 100644
29870 --- a/arch/x86/net/bpf_jit_comp.c
29871 +++ b/arch/x86/net/bpf_jit_comp.c
29872 @@ -12,6 +12,7 @@
29873 #include <linux/netdevice.h>
29874 #include <linux/filter.h>
29875 #include <linux/if_vlan.h>
29876 +#include <linux/random.h>
29877
29878 /*
29879 * Conventions :
29880 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29881 return ptr + len;
29882 }
29883
29884 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29885 +#define MAX_INSTR_CODE_SIZE 96
29886 +#else
29887 +#define MAX_INSTR_CODE_SIZE 64
29888 +#endif
29889 +
29890 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29891
29892 #define EMIT1(b1) EMIT(b1, 1)
29893 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29894 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29895 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29896 +
29897 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29898 +/* original constant will appear in ecx */
29899 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29900 +do { \
29901 + /* mov ecx, randkey */ \
29902 + EMIT1(0xb9); \
29903 + EMIT(_key, 4); \
29904 + /* xor ecx, randkey ^ off */ \
29905 + EMIT2(0x81, 0xf1); \
29906 + EMIT((_key) ^ (_off), 4); \
29907 +} while (0)
29908 +
29909 +#define EMIT1_off32(b1, _off) \
29910 +do { \
29911 + switch (b1) { \
29912 + case 0x05: /* add eax, imm32 */ \
29913 + case 0x2d: /* sub eax, imm32 */ \
29914 + case 0x25: /* and eax, imm32 */ \
29915 + case 0x0d: /* or eax, imm32 */ \
29916 + case 0xb8: /* mov eax, imm32 */ \
29917 + case 0x3d: /* cmp eax, imm32 */ \
29918 + case 0xa9: /* test eax, imm32 */ \
29919 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29920 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29921 + break; \
29922 + case 0xbb: /* mov ebx, imm32 */ \
29923 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29924 + /* mov ebx, ecx */ \
29925 + EMIT2(0x89, 0xcb); \
29926 + break; \
29927 + case 0xbe: /* mov esi, imm32 */ \
29928 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29929 + /* mov esi, ecx */ \
29930 + EMIT2(0x89, 0xce); \
29931 + break; \
29932 + case 0xe9: /* jmp rel imm32 */ \
29933 + EMIT1(b1); \
29934 + EMIT(_off, 4); \
29935 + /* prevent fall-through, we're not called if off = 0 */ \
29936 + EMIT(0xcccccccc, 4); \
29937 + EMIT(0xcccccccc, 4); \
29938 + break; \
29939 + default: \
29940 + EMIT1(b1); \
29941 + EMIT(_off, 4); \
29942 + } \
29943 +} while (0)
29944 +
29945 +#define EMIT2_off32(b1, b2, _off) \
29946 +do { \
29947 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29948 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29949 + EMIT(randkey, 4); \
29950 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29951 + EMIT((_off) - randkey, 4); \
29952 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29953 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29954 + /* imul eax, ecx */ \
29955 + EMIT3(0x0f, 0xaf, 0xc1); \
29956 + } else { \
29957 + EMIT2(b1, b2); \
29958 + EMIT(_off, 4); \
29959 + } \
29960 +} while (0)
29961 +#else
29962 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29963 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29964 +#endif
29965
29966 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29967 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29968 @@ -90,6 +165,24 @@ do { \
29969 #define X86_JBE 0x76
29970 #define X86_JA 0x77
29971
29972 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29973 +#define APPEND_FLOW_VERIFY() \
29974 +do { \
29975 + /* mov ecx, randkey */ \
29976 + EMIT1(0xb9); \
29977 + EMIT(randkey, 4); \
29978 + /* cmp ecx, randkey */ \
29979 + EMIT2(0x81, 0xf9); \
29980 + EMIT(randkey, 4); \
29981 + /* jz after 8 int 3s */ \
29982 + EMIT2(0x74, 0x08); \
29983 + EMIT(0xcccccccc, 4); \
29984 + EMIT(0xcccccccc, 4); \
29985 +} while (0)
29986 +#else
29987 +#define APPEND_FLOW_VERIFY() do { } while (0)
29988 +#endif
29989 +
29990 #define EMIT_COND_JMP(op, offset) \
29991 do { \
29992 if (is_near(offset)) \
29993 @@ -97,6 +190,7 @@ do { \
29994 else { \
29995 EMIT2(0x0f, op + 0x10); \
29996 EMIT(offset, 4); /* jxx .+off32 */ \
29997 + APPEND_FLOW_VERIFY(); \
29998 } \
29999 } while (0)
30000
30001 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
30002 set_fs(old_fs);
30003 }
30004
30005 +struct bpf_jit_work {
30006 + struct work_struct work;
30007 + void *image;
30008 +};
30009 +
30010 #define CHOOSE_LOAD_FUNC(K, func) \
30011 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
30012
30013 void bpf_jit_compile(struct sk_filter *fp)
30014 {
30015 - u8 temp[64];
30016 + u8 temp[MAX_INSTR_CODE_SIZE];
30017 u8 *prog;
30018 unsigned int proglen, oldproglen = 0;
30019 int ilen, i;
30020 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
30021 unsigned int *addrs;
30022 const struct sock_filter *filter = fp->insns;
30023 int flen = fp->len;
30024 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30025 + unsigned int randkey;
30026 +#endif
30027
30028 if (!bpf_jit_enable)
30029 return;
30030 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
30031 if (addrs == NULL)
30032 return;
30033
30034 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
30035 + if (!fp->work)
30036 + goto out;
30037 +
30038 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30039 + randkey = get_random_int();
30040 +#endif
30041 +
30042 /* Before first pass, make a rough estimation of addrs[]
30043 - * each bpf instruction is translated to less than 64 bytes
30044 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
30045 */
30046 for (proglen = 0, i = 0; i < flen; i++) {
30047 - proglen += 64;
30048 + proglen += MAX_INSTR_CODE_SIZE;
30049 addrs[i] = proglen;
30050 }
30051 cleanup_addr = proglen; /* epilogue address */
30052 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
30053 case BPF_S_ALU_MUL_K: /* A *= K */
30054 if (is_imm8(K))
30055 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
30056 - else {
30057 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
30058 - EMIT(K, 4);
30059 - }
30060 + else
30061 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
30062 break;
30063 case BPF_S_ALU_DIV_X: /* A /= X; */
30064 seen |= SEEN_XREG;
30065 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
30066 break;
30067 case BPF_S_ALU_MOD_K: /* A %= K; */
30068 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
30069 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30070 + DILUTE_CONST_SEQUENCE(K, randkey);
30071 +#else
30072 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
30073 +#endif
30074 EMIT2(0xf7, 0xf1); /* div %ecx */
30075 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
30076 break;
30077 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
30078 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30079 + DILUTE_CONST_SEQUENCE(K, randkey);
30080 + // imul rax, rcx
30081 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
30082 +#else
30083 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
30084 EMIT(K, 4);
30085 +#endif
30086 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
30087 break;
30088 case BPF_S_ALU_AND_X:
30089 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
30090 if (is_imm8(K)) {
30091 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
30092 } else {
30093 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
30094 - EMIT(K, 4);
30095 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
30096 }
30097 } else {
30098 EMIT2(0x89,0xde); /* mov %ebx,%esi */
30099 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30100 break;
30101 default:
30102 /* hmm, too complex filter, give up with jit compiler */
30103 - goto out;
30104 + goto error;
30105 }
30106 ilen = prog - temp;
30107 if (image) {
30108 if (unlikely(proglen + ilen > oldproglen)) {
30109 pr_err("bpb_jit_compile fatal error\n");
30110 - kfree(addrs);
30111 - module_free(NULL, image);
30112 - return;
30113 + module_free_exec(NULL, image);
30114 + goto error;
30115 }
30116 + pax_open_kernel();
30117 memcpy(image + proglen, temp, ilen);
30118 + pax_close_kernel();
30119 }
30120 proglen += ilen;
30121 addrs[i] = proglen;
30122 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30123 break;
30124 }
30125 if (proglen == oldproglen) {
30126 - image = module_alloc(max_t(unsigned int,
30127 - proglen,
30128 - sizeof(struct work_struct)));
30129 + image = module_alloc_exec(proglen);
30130 if (!image)
30131 - goto out;
30132 + goto error;
30133 }
30134 oldproglen = proglen;
30135 }
30136 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30137 bpf_flush_icache(image, image + proglen);
30138
30139 fp->bpf_func = (void *)image;
30140 - }
30141 + } else
30142 +error:
30143 + kfree(fp->work);
30144 +
30145 out:
30146 kfree(addrs);
30147 return;
30148 @@ -707,18 +826,20 @@ out:
30149
30150 static void jit_free_defer(struct work_struct *arg)
30151 {
30152 - module_free(NULL, arg);
30153 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
30154 + kfree(arg);
30155 }
30156
30157 /* run from softirq, we must use a work_struct to call
30158 - * module_free() from process context
30159 + * module_free_exec() from process context
30160 */
30161 void bpf_jit_free(struct sk_filter *fp)
30162 {
30163 if (fp->bpf_func != sk_run_filter) {
30164 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
30165 + struct work_struct *work = &fp->work->work;
30166
30167 INIT_WORK(work, jit_free_defer);
30168 + fp->work->image = fp->bpf_func;
30169 schedule_work(work);
30170 }
30171 }
30172 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
30173 index d6aa6e8..266395a 100644
30174 --- a/arch/x86/oprofile/backtrace.c
30175 +++ b/arch/x86/oprofile/backtrace.c
30176 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
30177 struct stack_frame_ia32 *fp;
30178 unsigned long bytes;
30179
30180 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30181 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30182 if (bytes != sizeof(bufhead))
30183 return NULL;
30184
30185 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
30186 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
30187
30188 oprofile_add_trace(bufhead[0].return_address);
30189
30190 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
30191 struct stack_frame bufhead[2];
30192 unsigned long bytes;
30193
30194 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30195 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30196 if (bytes != sizeof(bufhead))
30197 return NULL;
30198
30199 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
30200 {
30201 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
30202
30203 - if (!user_mode_vm(regs)) {
30204 + if (!user_mode(regs)) {
30205 unsigned long stack = kernel_stack_pointer(regs);
30206 if (depth)
30207 dump_trace(NULL, regs, (unsigned long *)stack, 0,
30208 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
30209 index 48768df..ba9143c 100644
30210 --- a/arch/x86/oprofile/nmi_int.c
30211 +++ b/arch/x86/oprofile/nmi_int.c
30212 @@ -23,6 +23,7 @@
30213 #include <asm/nmi.h>
30214 #include <asm/msr.h>
30215 #include <asm/apic.h>
30216 +#include <asm/pgtable.h>
30217
30218 #include "op_counter.h"
30219 #include "op_x86_model.h"
30220 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30221 if (ret)
30222 return ret;
30223
30224 - if (!model->num_virt_counters)
30225 - model->num_virt_counters = model->num_counters;
30226 + if (!model->num_virt_counters) {
30227 + pax_open_kernel();
30228 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30229 + pax_close_kernel();
30230 + }
30231
30232 mux_init(ops);
30233
30234 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30235 index b2b9443..be58856 100644
30236 --- a/arch/x86/oprofile/op_model_amd.c
30237 +++ b/arch/x86/oprofile/op_model_amd.c
30238 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30239 num_counters = AMD64_NUM_COUNTERS;
30240 }
30241
30242 - op_amd_spec.num_counters = num_counters;
30243 - op_amd_spec.num_controls = num_counters;
30244 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30245 + pax_open_kernel();
30246 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30247 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30248 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30249 + pax_close_kernel();
30250
30251 return 0;
30252 }
30253 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30254 index d90528e..0127e2b 100644
30255 --- a/arch/x86/oprofile/op_model_ppro.c
30256 +++ b/arch/x86/oprofile/op_model_ppro.c
30257 @@ -19,6 +19,7 @@
30258 #include <asm/msr.h>
30259 #include <asm/apic.h>
30260 #include <asm/nmi.h>
30261 +#include <asm/pgtable.h>
30262
30263 #include "op_x86_model.h"
30264 #include "op_counter.h"
30265 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30266
30267 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30268
30269 - op_arch_perfmon_spec.num_counters = num_counters;
30270 - op_arch_perfmon_spec.num_controls = num_counters;
30271 + pax_open_kernel();
30272 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30273 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30274 + pax_close_kernel();
30275 }
30276
30277 static int arch_perfmon_init(struct oprofile_operations *ignore)
30278 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30279 index 71e8a67..6a313bb 100644
30280 --- a/arch/x86/oprofile/op_x86_model.h
30281 +++ b/arch/x86/oprofile/op_x86_model.h
30282 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30283 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30284 struct op_msrs const * const msrs);
30285 #endif
30286 -};
30287 +} __do_const;
30288
30289 struct op_counter_config;
30290
30291 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30292 index e9e6ed5..e47ae67 100644
30293 --- a/arch/x86/pci/amd_bus.c
30294 +++ b/arch/x86/pci/amd_bus.c
30295 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30296 return NOTIFY_OK;
30297 }
30298
30299 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30300 +static struct notifier_block amd_cpu_notifier = {
30301 .notifier_call = amd_cpu_notify,
30302 };
30303
30304 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30305 index 372e9b8..e775a6c 100644
30306 --- a/arch/x86/pci/irq.c
30307 +++ b/arch/x86/pci/irq.c
30308 @@ -50,7 +50,7 @@ struct irq_router {
30309 struct irq_router_handler {
30310 u16 vendor;
30311 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30312 -};
30313 +} __do_const;
30314
30315 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30316 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30317 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30318 return 0;
30319 }
30320
30321 -static __initdata struct irq_router_handler pirq_routers[] = {
30322 +static __initconst const struct irq_router_handler pirq_routers[] = {
30323 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30324 { PCI_VENDOR_ID_AL, ali_router_probe },
30325 { PCI_VENDOR_ID_ITE, ite_router_probe },
30326 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30327 static void __init pirq_find_router(struct irq_router *r)
30328 {
30329 struct irq_routing_table *rt = pirq_table;
30330 - struct irq_router_handler *h;
30331 + const struct irq_router_handler *h;
30332
30333 #ifdef CONFIG_PCI_BIOS
30334 if (!rt->signature) {
30335 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30336 return 0;
30337 }
30338
30339 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30340 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30341 {
30342 .callback = fix_broken_hp_bios_irq9,
30343 .ident = "HP Pavilion N5400 Series Laptop",
30344 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30345 index 6eb18c4..20d83de 100644
30346 --- a/arch/x86/pci/mrst.c
30347 +++ b/arch/x86/pci/mrst.c
30348 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30349 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30350 pci_mmcfg_late_init();
30351 pcibios_enable_irq = mrst_pci_irq_enable;
30352 - pci_root_ops = pci_mrst_ops;
30353 + pax_open_kernel();
30354 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30355 + pax_close_kernel();
30356 pci_soc_mode = 1;
30357 /* Continue with standard init */
30358 return 1;
30359 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30360 index c77b24a..c979855 100644
30361 --- a/arch/x86/pci/pcbios.c
30362 +++ b/arch/x86/pci/pcbios.c
30363 @@ -79,7 +79,7 @@ union bios32 {
30364 static struct {
30365 unsigned long address;
30366 unsigned short segment;
30367 -} bios32_indirect = { 0, __KERNEL_CS };
30368 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30369
30370 /*
30371 * Returns the entry point for the given service, NULL on error
30372 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30373 unsigned long length; /* %ecx */
30374 unsigned long entry; /* %edx */
30375 unsigned long flags;
30376 + struct desc_struct d, *gdt;
30377
30378 local_irq_save(flags);
30379 - __asm__("lcall *(%%edi); cld"
30380 +
30381 + gdt = get_cpu_gdt_table(smp_processor_id());
30382 +
30383 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30384 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30385 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30386 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30387 +
30388 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30389 : "=a" (return_code),
30390 "=b" (address),
30391 "=c" (length),
30392 "=d" (entry)
30393 : "0" (service),
30394 "1" (0),
30395 - "D" (&bios32_indirect));
30396 + "D" (&bios32_indirect),
30397 + "r"(__PCIBIOS_DS)
30398 + : "memory");
30399 +
30400 + pax_open_kernel();
30401 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30402 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30403 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30404 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30405 + pax_close_kernel();
30406 +
30407 local_irq_restore(flags);
30408
30409 switch (return_code) {
30410 - case 0:
30411 - return address + entry;
30412 - case 0x80: /* Not present */
30413 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30414 - return 0;
30415 - default: /* Shouldn't happen */
30416 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30417 - service, return_code);
30418 + case 0: {
30419 + int cpu;
30420 + unsigned char flags;
30421 +
30422 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30423 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30424 + printk(KERN_WARNING "bios32_service: not valid\n");
30425 return 0;
30426 + }
30427 + address = address + PAGE_OFFSET;
30428 + length += 16UL; /* some BIOSs underreport this... */
30429 + flags = 4;
30430 + if (length >= 64*1024*1024) {
30431 + length >>= PAGE_SHIFT;
30432 + flags |= 8;
30433 + }
30434 +
30435 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30436 + gdt = get_cpu_gdt_table(cpu);
30437 + pack_descriptor(&d, address, length, 0x9b, flags);
30438 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30439 + pack_descriptor(&d, address, length, 0x93, flags);
30440 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30441 + }
30442 + return entry;
30443 + }
30444 + case 0x80: /* Not present */
30445 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30446 + return 0;
30447 + default: /* Shouldn't happen */
30448 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30449 + service, return_code);
30450 + return 0;
30451 }
30452 }
30453
30454 static struct {
30455 unsigned long address;
30456 unsigned short segment;
30457 -} pci_indirect = { 0, __KERNEL_CS };
30458 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30459
30460 -static int pci_bios_present;
30461 +static int pci_bios_present __read_only;
30462
30463 static int check_pcibios(void)
30464 {
30465 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30466 unsigned long flags, pcibios_entry;
30467
30468 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30469 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30470 + pci_indirect.address = pcibios_entry;
30471
30472 local_irq_save(flags);
30473 - __asm__(
30474 - "lcall *(%%edi); cld\n\t"
30475 + __asm__("movw %w6, %%ds\n\t"
30476 + "lcall *%%ss:(%%edi); cld\n\t"
30477 + "push %%ss\n\t"
30478 + "pop %%ds\n\t"
30479 "jc 1f\n\t"
30480 "xor %%ah, %%ah\n"
30481 "1:"
30482 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30483 "=b" (ebx),
30484 "=c" (ecx)
30485 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30486 - "D" (&pci_indirect)
30487 + "D" (&pci_indirect),
30488 + "r" (__PCIBIOS_DS)
30489 : "memory");
30490 local_irq_restore(flags);
30491
30492 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30493
30494 switch (len) {
30495 case 1:
30496 - __asm__("lcall *(%%esi); cld\n\t"
30497 + __asm__("movw %w6, %%ds\n\t"
30498 + "lcall *%%ss:(%%esi); cld\n\t"
30499 + "push %%ss\n\t"
30500 + "pop %%ds\n\t"
30501 "jc 1f\n\t"
30502 "xor %%ah, %%ah\n"
30503 "1:"
30504 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30505 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30506 "b" (bx),
30507 "D" ((long)reg),
30508 - "S" (&pci_indirect));
30509 + "S" (&pci_indirect),
30510 + "r" (__PCIBIOS_DS));
30511 /*
30512 * Zero-extend the result beyond 8 bits, do not trust the
30513 * BIOS having done it:
30514 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30515 *value &= 0xff;
30516 break;
30517 case 2:
30518 - __asm__("lcall *(%%esi); cld\n\t"
30519 + __asm__("movw %w6, %%ds\n\t"
30520 + "lcall *%%ss:(%%esi); cld\n\t"
30521 + "push %%ss\n\t"
30522 + "pop %%ds\n\t"
30523 "jc 1f\n\t"
30524 "xor %%ah, %%ah\n"
30525 "1:"
30526 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30527 : "1" (PCIBIOS_READ_CONFIG_WORD),
30528 "b" (bx),
30529 "D" ((long)reg),
30530 - "S" (&pci_indirect));
30531 + "S" (&pci_indirect),
30532 + "r" (__PCIBIOS_DS));
30533 /*
30534 * Zero-extend the result beyond 16 bits, do not trust the
30535 * BIOS having done it:
30536 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30537 *value &= 0xffff;
30538 break;
30539 case 4:
30540 - __asm__("lcall *(%%esi); cld\n\t"
30541 + __asm__("movw %w6, %%ds\n\t"
30542 + "lcall *%%ss:(%%esi); cld\n\t"
30543 + "push %%ss\n\t"
30544 + "pop %%ds\n\t"
30545 "jc 1f\n\t"
30546 "xor %%ah, %%ah\n"
30547 "1:"
30548 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30549 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30550 "b" (bx),
30551 "D" ((long)reg),
30552 - "S" (&pci_indirect));
30553 + "S" (&pci_indirect),
30554 + "r" (__PCIBIOS_DS));
30555 break;
30556 }
30557
30558 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30559
30560 switch (len) {
30561 case 1:
30562 - __asm__("lcall *(%%esi); cld\n\t"
30563 + __asm__("movw %w6, %%ds\n\t"
30564 + "lcall *%%ss:(%%esi); cld\n\t"
30565 + "push %%ss\n\t"
30566 + "pop %%ds\n\t"
30567 "jc 1f\n\t"
30568 "xor %%ah, %%ah\n"
30569 "1:"
30570 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30571 "c" (value),
30572 "b" (bx),
30573 "D" ((long)reg),
30574 - "S" (&pci_indirect));
30575 + "S" (&pci_indirect),
30576 + "r" (__PCIBIOS_DS));
30577 break;
30578 case 2:
30579 - __asm__("lcall *(%%esi); cld\n\t"
30580 + __asm__("movw %w6, %%ds\n\t"
30581 + "lcall *%%ss:(%%esi); cld\n\t"
30582 + "push %%ss\n\t"
30583 + "pop %%ds\n\t"
30584 "jc 1f\n\t"
30585 "xor %%ah, %%ah\n"
30586 "1:"
30587 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30588 "c" (value),
30589 "b" (bx),
30590 "D" ((long)reg),
30591 - "S" (&pci_indirect));
30592 + "S" (&pci_indirect),
30593 + "r" (__PCIBIOS_DS));
30594 break;
30595 case 4:
30596 - __asm__("lcall *(%%esi); cld\n\t"
30597 + __asm__("movw %w6, %%ds\n\t"
30598 + "lcall *%%ss:(%%esi); cld\n\t"
30599 + "push %%ss\n\t"
30600 + "pop %%ds\n\t"
30601 "jc 1f\n\t"
30602 "xor %%ah, %%ah\n"
30603 "1:"
30604 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30605 "c" (value),
30606 "b" (bx),
30607 "D" ((long)reg),
30608 - "S" (&pci_indirect));
30609 + "S" (&pci_indirect),
30610 + "r" (__PCIBIOS_DS));
30611 break;
30612 }
30613
30614 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30615
30616 DBG("PCI: Fetching IRQ routing table... ");
30617 __asm__("push %%es\n\t"
30618 + "movw %w8, %%ds\n\t"
30619 "push %%ds\n\t"
30620 "pop %%es\n\t"
30621 - "lcall *(%%esi); cld\n\t"
30622 + "lcall *%%ss:(%%esi); cld\n\t"
30623 "pop %%es\n\t"
30624 + "push %%ss\n\t"
30625 + "pop %%ds\n"
30626 "jc 1f\n\t"
30627 "xor %%ah, %%ah\n"
30628 "1:"
30629 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30630 "1" (0),
30631 "D" ((long) &opt),
30632 "S" (&pci_indirect),
30633 - "m" (opt)
30634 + "m" (opt),
30635 + "r" (__PCIBIOS_DS)
30636 : "memory");
30637 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30638 if (ret & 0xff00)
30639 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30640 {
30641 int ret;
30642
30643 - __asm__("lcall *(%%esi); cld\n\t"
30644 + __asm__("movw %w5, %%ds\n\t"
30645 + "lcall *%%ss:(%%esi); cld\n\t"
30646 + "push %%ss\n\t"
30647 + "pop %%ds\n"
30648 "jc 1f\n\t"
30649 "xor %%ah, %%ah\n"
30650 "1:"
30651 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30652 : "0" (PCIBIOS_SET_PCI_HW_INT),
30653 "b" ((dev->bus->number << 8) | dev->devfn),
30654 "c" ((irq << 8) | (pin + 10)),
30655 - "S" (&pci_indirect));
30656 + "S" (&pci_indirect),
30657 + "r" (__PCIBIOS_DS));
30658 return !(ret & 0xff00);
30659 }
30660 EXPORT_SYMBOL(pcibios_set_irq_routing);
30661 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30662 index 40e4469..1ab536e 100644
30663 --- a/arch/x86/platform/efi/efi_32.c
30664 +++ b/arch/x86/platform/efi/efi_32.c
30665 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30666 {
30667 struct desc_ptr gdt_descr;
30668
30669 +#ifdef CONFIG_PAX_KERNEXEC
30670 + struct desc_struct d;
30671 +#endif
30672 +
30673 local_irq_save(efi_rt_eflags);
30674
30675 load_cr3(initial_page_table);
30676 __flush_tlb_all();
30677
30678 +#ifdef CONFIG_PAX_KERNEXEC
30679 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30680 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30681 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30682 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30683 +#endif
30684 +
30685 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30686 gdt_descr.size = GDT_SIZE - 1;
30687 load_gdt(&gdt_descr);
30688 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30689 {
30690 struct desc_ptr gdt_descr;
30691
30692 +#ifdef CONFIG_PAX_KERNEXEC
30693 + struct desc_struct d;
30694 +
30695 + memset(&d, 0, sizeof d);
30696 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30697 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30698 +#endif
30699 +
30700 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30701 gdt_descr.size = GDT_SIZE - 1;
30702 load_gdt(&gdt_descr);
30703 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30704 index fbe66e6..eae5e38 100644
30705 --- a/arch/x86/platform/efi/efi_stub_32.S
30706 +++ b/arch/x86/platform/efi/efi_stub_32.S
30707 @@ -6,7 +6,9 @@
30708 */
30709
30710 #include <linux/linkage.h>
30711 +#include <linux/init.h>
30712 #include <asm/page_types.h>
30713 +#include <asm/segment.h>
30714
30715 /*
30716 * efi_call_phys(void *, ...) is a function with variable parameters.
30717 @@ -20,7 +22,7 @@
30718 * service functions will comply with gcc calling convention, too.
30719 */
30720
30721 -.text
30722 +__INIT
30723 ENTRY(efi_call_phys)
30724 /*
30725 * 0. The function can only be called in Linux kernel. So CS has been
30726 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30727 * The mapping of lower virtual memory has been created in prelog and
30728 * epilog.
30729 */
30730 - movl $1f, %edx
30731 - subl $__PAGE_OFFSET, %edx
30732 - jmp *%edx
30733 +#ifdef CONFIG_PAX_KERNEXEC
30734 + movl $(__KERNEXEC_EFI_DS), %edx
30735 + mov %edx, %ds
30736 + mov %edx, %es
30737 + mov %edx, %ss
30738 + addl $2f,(1f)
30739 + ljmp *(1f)
30740 +
30741 +__INITDATA
30742 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30743 +.previous
30744 +
30745 +2:
30746 + subl $2b,(1b)
30747 +#else
30748 + jmp 1f-__PAGE_OFFSET
30749 1:
30750 +#endif
30751
30752 /*
30753 * 2. Now on the top of stack is the return
30754 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30755 * parameter 2, ..., param n. To make things easy, we save the return
30756 * address of efi_call_phys in a global variable.
30757 */
30758 - popl %edx
30759 - movl %edx, saved_return_addr
30760 - /* get the function pointer into ECX*/
30761 - popl %ecx
30762 - movl %ecx, efi_rt_function_ptr
30763 - movl $2f, %edx
30764 - subl $__PAGE_OFFSET, %edx
30765 - pushl %edx
30766 + popl (saved_return_addr)
30767 + popl (efi_rt_function_ptr)
30768
30769 /*
30770 * 3. Clear PG bit in %CR0.
30771 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30772 /*
30773 * 5. Call the physical function.
30774 */
30775 - jmp *%ecx
30776 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30777
30778 -2:
30779 /*
30780 * 6. After EFI runtime service returns, control will return to
30781 * following instruction. We'd better readjust stack pointer first.
30782 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30783 movl %cr0, %edx
30784 orl $0x80000000, %edx
30785 movl %edx, %cr0
30786 - jmp 1f
30787 -1:
30788 +
30789 /*
30790 * 8. Now restore the virtual mode from flat mode by
30791 * adding EIP with PAGE_OFFSET.
30792 */
30793 - movl $1f, %edx
30794 - jmp *%edx
30795 +#ifdef CONFIG_PAX_KERNEXEC
30796 + movl $(__KERNEL_DS), %edx
30797 + mov %edx, %ds
30798 + mov %edx, %es
30799 + mov %edx, %ss
30800 + ljmp $(__KERNEL_CS),$1f
30801 +#else
30802 + jmp 1f+__PAGE_OFFSET
30803 +#endif
30804 1:
30805
30806 /*
30807 * 9. Balance the stack. And because EAX contain the return value,
30808 * we'd better not clobber it.
30809 */
30810 - leal efi_rt_function_ptr, %edx
30811 - movl (%edx), %ecx
30812 - pushl %ecx
30813 + pushl (efi_rt_function_ptr)
30814
30815 /*
30816 - * 10. Push the saved return address onto the stack and return.
30817 + * 10. Return to the saved return address.
30818 */
30819 - leal saved_return_addr, %edx
30820 - movl (%edx), %ecx
30821 - pushl %ecx
30822 - ret
30823 + jmpl *(saved_return_addr)
30824 ENDPROC(efi_call_phys)
30825 .previous
30826
30827 -.data
30828 +__INITDATA
30829 saved_return_addr:
30830 .long 0
30831 efi_rt_function_ptr:
30832 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30833 index 4c07cca..2c8427d 100644
30834 --- a/arch/x86/platform/efi/efi_stub_64.S
30835 +++ b/arch/x86/platform/efi/efi_stub_64.S
30836 @@ -7,6 +7,7 @@
30837 */
30838
30839 #include <linux/linkage.h>
30840 +#include <asm/alternative-asm.h>
30841
30842 #define SAVE_XMM \
30843 mov %rsp, %rax; \
30844 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30845 call *%rdi
30846 addq $32, %rsp
30847 RESTORE_XMM
30848 + pax_force_retaddr 0, 1
30849 ret
30850 ENDPROC(efi_call0)
30851
30852 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30853 call *%rdi
30854 addq $32, %rsp
30855 RESTORE_XMM
30856 + pax_force_retaddr 0, 1
30857 ret
30858 ENDPROC(efi_call1)
30859
30860 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30861 call *%rdi
30862 addq $32, %rsp
30863 RESTORE_XMM
30864 + pax_force_retaddr 0, 1
30865 ret
30866 ENDPROC(efi_call2)
30867
30868 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30869 call *%rdi
30870 addq $32, %rsp
30871 RESTORE_XMM
30872 + pax_force_retaddr 0, 1
30873 ret
30874 ENDPROC(efi_call3)
30875
30876 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30877 call *%rdi
30878 addq $32, %rsp
30879 RESTORE_XMM
30880 + pax_force_retaddr 0, 1
30881 ret
30882 ENDPROC(efi_call4)
30883
30884 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30885 call *%rdi
30886 addq $48, %rsp
30887 RESTORE_XMM
30888 + pax_force_retaddr 0, 1
30889 ret
30890 ENDPROC(efi_call5)
30891
30892 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30893 call *%rdi
30894 addq $48, %rsp
30895 RESTORE_XMM
30896 + pax_force_retaddr 0, 1
30897 ret
30898 ENDPROC(efi_call6)
30899 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30900 index e31bcd8..f12dc46 100644
30901 --- a/arch/x86/platform/mrst/mrst.c
30902 +++ b/arch/x86/platform/mrst/mrst.c
30903 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30904 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30905 int sfi_mrtc_num;
30906
30907 -static void mrst_power_off(void)
30908 +static __noreturn void mrst_power_off(void)
30909 {
30910 + BUG();
30911 }
30912
30913 -static void mrst_reboot(void)
30914 +static __noreturn void mrst_reboot(void)
30915 {
30916 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30917 + BUG();
30918 }
30919
30920 /* parse all the mtimer info to a static mtimer array */
30921 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30922 index d6ee929..3637cb5 100644
30923 --- a/arch/x86/platform/olpc/olpc_dt.c
30924 +++ b/arch/x86/platform/olpc/olpc_dt.c
30925 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30926 return res;
30927 }
30928
30929 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30930 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30931 .nextprop = olpc_dt_nextprop,
30932 .getproplen = olpc_dt_getproplen,
30933 .getproperty = olpc_dt_getproperty,
30934 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30935 index 3c68768..07e82b8 100644
30936 --- a/arch/x86/power/cpu.c
30937 +++ b/arch/x86/power/cpu.c
30938 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30939 static void fix_processor_context(void)
30940 {
30941 int cpu = smp_processor_id();
30942 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30943 + struct tss_struct *t = init_tss + cpu;
30944
30945 set_tss_desc(cpu, t); /*
30946 * This just modifies memory; should not be
30947 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30948 */
30949
30950 #ifdef CONFIG_X86_64
30951 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30952 -
30953 syscall_init(); /* This sets MSR_*STAR and related */
30954 #endif
30955 load_TR_desc(); /* This does ltr */
30956 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30957 index cbca565..bae7133 100644
30958 --- a/arch/x86/realmode/init.c
30959 +++ b/arch/x86/realmode/init.c
30960 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
30961 __va(real_mode_header->trampoline_header);
30962
30963 #ifdef CONFIG_X86_32
30964 - trampoline_header->start = __pa(startup_32_smp);
30965 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
30966 +
30967 +#ifdef CONFIG_PAX_KERNEXEC
30968 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30969 +#endif
30970 +
30971 + trampoline_header->boot_cs = __BOOT_CS;
30972 trampoline_header->gdt_limit = __BOOT_DS + 7;
30973 trampoline_header->gdt_base = __pa(boot_gdt);
30974 #else
30975 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30976 index 8869287..d577672 100644
30977 --- a/arch/x86/realmode/rm/Makefile
30978 +++ b/arch/x86/realmode/rm/Makefile
30979 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30980 $(call cc-option, -fno-unit-at-a-time)) \
30981 $(call cc-option, -fno-stack-protector) \
30982 $(call cc-option, -mpreferred-stack-boundary=2)
30983 +ifdef CONSTIFY_PLUGIN
30984 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30985 +endif
30986 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30987 GCOV_PROFILE := n
30988 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30989 index a28221d..93c40f1 100644
30990 --- a/arch/x86/realmode/rm/header.S
30991 +++ b/arch/x86/realmode/rm/header.S
30992 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30993 #endif
30994 /* APM/BIOS reboot */
30995 .long pa_machine_real_restart_asm
30996 -#ifdef CONFIG_X86_64
30997 +#ifdef CONFIG_X86_32
30998 + .long __KERNEL_CS
30999 +#else
31000 .long __KERNEL32_CS
31001 #endif
31002 END(real_mode_header)
31003 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
31004 index c1b2791..f9e31c7 100644
31005 --- a/arch/x86/realmode/rm/trampoline_32.S
31006 +++ b/arch/x86/realmode/rm/trampoline_32.S
31007 @@ -25,6 +25,12 @@
31008 #include <asm/page_types.h>
31009 #include "realmode.h"
31010
31011 +#ifdef CONFIG_PAX_KERNEXEC
31012 +#define ta(X) (X)
31013 +#else
31014 +#define ta(X) (pa_ ## X)
31015 +#endif
31016 +
31017 .text
31018 .code16
31019
31020 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
31021
31022 cli # We should be safe anyway
31023
31024 - movl tr_start, %eax # where we need to go
31025 -
31026 movl $0xA5A5A5A5, trampoline_status
31027 # write marker for master knows we're running
31028
31029 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
31030 movw $1, %dx # protected mode (PE) bit
31031 lmsw %dx # into protected mode
31032
31033 - ljmpl $__BOOT_CS, $pa_startup_32
31034 + ljmpl *(trampoline_header)
31035
31036 .section ".text32","ax"
31037 .code32
31038 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
31039 .balign 8
31040 GLOBAL(trampoline_header)
31041 tr_start: .space 4
31042 - tr_gdt_pad: .space 2
31043 + tr_boot_cs: .space 2
31044 tr_gdt: .space 6
31045 END(trampoline_header)
31046
31047 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
31048 index bb360dc..3e5945f 100644
31049 --- a/arch/x86/realmode/rm/trampoline_64.S
31050 +++ b/arch/x86/realmode/rm/trampoline_64.S
31051 @@ -107,7 +107,7 @@ ENTRY(startup_32)
31052 wrmsr
31053
31054 # Enable paging and in turn activate Long Mode
31055 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
31056 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
31057 movl %eax, %cr0
31058
31059 /*
31060 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
31061 index 79d67bd..c7e1b90 100644
31062 --- a/arch/x86/tools/relocs.c
31063 +++ b/arch/x86/tools/relocs.c
31064 @@ -12,10 +12,13 @@
31065 #include <regex.h>
31066 #include <tools/le_byteshift.h>
31067
31068 +#include "../../../include/generated/autoconf.h"
31069 +
31070 static void die(char *fmt, ...);
31071
31072 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
31073 static Elf32_Ehdr ehdr;
31074 +static Elf32_Phdr *phdr;
31075 static unsigned long reloc_count, reloc_idx;
31076 static unsigned long *relocs;
31077 static unsigned long reloc16_count, reloc16_idx;
31078 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
31079 }
31080 }
31081
31082 +static void read_phdrs(FILE *fp)
31083 +{
31084 + unsigned int i;
31085 +
31086 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
31087 + if (!phdr) {
31088 + die("Unable to allocate %d program headers\n",
31089 + ehdr.e_phnum);
31090 + }
31091 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
31092 + die("Seek to %d failed: %s\n",
31093 + ehdr.e_phoff, strerror(errno));
31094 + }
31095 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
31096 + die("Cannot read ELF program headers: %s\n",
31097 + strerror(errno));
31098 + }
31099 + for(i = 0; i < ehdr.e_phnum; i++) {
31100 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
31101 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
31102 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
31103 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
31104 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
31105 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
31106 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
31107 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
31108 + }
31109 +
31110 +}
31111 +
31112 static void read_shdrs(FILE *fp)
31113 {
31114 - int i;
31115 + unsigned int i;
31116 Elf32_Shdr shdr;
31117
31118 secs = calloc(ehdr.e_shnum, sizeof(struct section));
31119 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
31120
31121 static void read_strtabs(FILE *fp)
31122 {
31123 - int i;
31124 + unsigned int i;
31125 for (i = 0; i < ehdr.e_shnum; i++) {
31126 struct section *sec = &secs[i];
31127 if (sec->shdr.sh_type != SHT_STRTAB) {
31128 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
31129
31130 static void read_symtabs(FILE *fp)
31131 {
31132 - int i,j;
31133 + unsigned int i,j;
31134 for (i = 0; i < ehdr.e_shnum; i++) {
31135 struct section *sec = &secs[i];
31136 if (sec->shdr.sh_type != SHT_SYMTAB) {
31137 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
31138 }
31139
31140
31141 -static void read_relocs(FILE *fp)
31142 +static void read_relocs(FILE *fp, int use_real_mode)
31143 {
31144 - int i,j;
31145 + unsigned int i,j;
31146 + uint32_t base;
31147 +
31148 for (i = 0; i < ehdr.e_shnum; i++) {
31149 struct section *sec = &secs[i];
31150 if (sec->shdr.sh_type != SHT_REL) {
31151 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
31152 die("Cannot read symbol table: %s\n",
31153 strerror(errno));
31154 }
31155 + base = 0;
31156 +
31157 +#ifdef CONFIG_X86_32
31158 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31159 + if (phdr[j].p_type != PT_LOAD )
31160 + continue;
31161 + 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)
31162 + continue;
31163 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31164 + break;
31165 + }
31166 +#endif
31167 +
31168 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
31169 Elf32_Rel *rel = &sec->reltab[j];
31170 - rel->r_offset = elf32_to_cpu(rel->r_offset);
31171 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
31172 rel->r_info = elf32_to_cpu(rel->r_info);
31173 }
31174 }
31175 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
31176
31177 static void print_absolute_symbols(void)
31178 {
31179 - int i;
31180 + unsigned int i;
31181 printf("Absolute symbols\n");
31182 printf(" Num: Value Size Type Bind Visibility Name\n");
31183 for (i = 0; i < ehdr.e_shnum; i++) {
31184 struct section *sec = &secs[i];
31185 char *sym_strtab;
31186 - int j;
31187 + unsigned int j;
31188
31189 if (sec->shdr.sh_type != SHT_SYMTAB) {
31190 continue;
31191 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
31192
31193 static void print_absolute_relocs(void)
31194 {
31195 - int i, printed = 0;
31196 + unsigned int i, printed = 0;
31197
31198 for (i = 0; i < ehdr.e_shnum; i++) {
31199 struct section *sec = &secs[i];
31200 struct section *sec_applies, *sec_symtab;
31201 char *sym_strtab;
31202 Elf32_Sym *sh_symtab;
31203 - int j;
31204 + unsigned int j;
31205 if (sec->shdr.sh_type != SHT_REL) {
31206 continue;
31207 }
31208 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
31209 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31210 int use_real_mode)
31211 {
31212 - int i;
31213 + unsigned int i;
31214 /* Walk through the relocations */
31215 for (i = 0; i < ehdr.e_shnum; i++) {
31216 char *sym_strtab;
31217 Elf32_Sym *sh_symtab;
31218 struct section *sec_applies, *sec_symtab;
31219 - int j;
31220 + unsigned int j;
31221 struct section *sec = &secs[i];
31222
31223 if (sec->shdr.sh_type != SHT_REL) {
31224 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31225 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
31226 r_type = ELF32_R_TYPE(rel->r_info);
31227
31228 + if (!use_real_mode) {
31229 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31230 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31231 + continue;
31232 +
31233 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
31234 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31235 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31236 + continue;
31237 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31238 + continue;
31239 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31240 + continue;
31241 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31242 + continue;
31243 +#endif
31244 + }
31245 +
31246 shn_abs = sym->st_shndx == SHN_ABS;
31247
31248 switch (r_type) {
31249 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
31250
31251 static void emit_relocs(int as_text, int use_real_mode)
31252 {
31253 - int i;
31254 + unsigned int i;
31255 /* Count how many relocations I have and allocate space for them. */
31256 reloc_count = 0;
31257 walk_relocs(count_reloc, use_real_mode);
31258 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
31259 fname, strerror(errno));
31260 }
31261 read_ehdr(fp);
31262 + read_phdrs(fp);
31263 read_shdrs(fp);
31264 read_strtabs(fp);
31265 read_symtabs(fp);
31266 - read_relocs(fp);
31267 + read_relocs(fp, use_real_mode);
31268 if (show_absolute_syms) {
31269 print_absolute_symbols();
31270 goto out;
31271 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31272 index fd14be1..e3c79c0 100644
31273 --- a/arch/x86/vdso/Makefile
31274 +++ b/arch/x86/vdso/Makefile
31275 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31276 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31277 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31278
31279 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31280 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31281 GCOV_PROFILE := n
31282
31283 #
31284 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31285 index 0faad64..39ef157 100644
31286 --- a/arch/x86/vdso/vdso32-setup.c
31287 +++ b/arch/x86/vdso/vdso32-setup.c
31288 @@ -25,6 +25,7 @@
31289 #include <asm/tlbflush.h>
31290 #include <asm/vdso.h>
31291 #include <asm/proto.h>
31292 +#include <asm/mman.h>
31293
31294 enum {
31295 VDSO_DISABLED = 0,
31296 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31297 void enable_sep_cpu(void)
31298 {
31299 int cpu = get_cpu();
31300 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31301 + struct tss_struct *tss = init_tss + cpu;
31302
31303 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31304 put_cpu();
31305 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31306 gate_vma.vm_start = FIXADDR_USER_START;
31307 gate_vma.vm_end = FIXADDR_USER_END;
31308 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31309 - gate_vma.vm_page_prot = __P101;
31310 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31311
31312 return 0;
31313 }
31314 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31315 if (compat)
31316 addr = VDSO_HIGH_BASE;
31317 else {
31318 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31319 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31320 if (IS_ERR_VALUE(addr)) {
31321 ret = addr;
31322 goto up_fail;
31323 }
31324 }
31325
31326 - current->mm->context.vdso = (void *)addr;
31327 + current->mm->context.vdso = addr;
31328
31329 if (compat_uses_vma || !compat) {
31330 /*
31331 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31332 }
31333
31334 current_thread_info()->sysenter_return =
31335 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31336 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31337
31338 up_fail:
31339 if (ret)
31340 - current->mm->context.vdso = NULL;
31341 + current->mm->context.vdso = 0;
31342
31343 up_write(&mm->mmap_sem);
31344
31345 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31346
31347 const char *arch_vma_name(struct vm_area_struct *vma)
31348 {
31349 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31350 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31351 return "[vdso]";
31352 +
31353 +#ifdef CONFIG_PAX_SEGMEXEC
31354 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31355 + return "[vdso]";
31356 +#endif
31357 +
31358 return NULL;
31359 }
31360
31361 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31362 * Check to see if the corresponding task was created in compat vdso
31363 * mode.
31364 */
31365 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31366 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31367 return &gate_vma;
31368 return NULL;
31369 }
31370 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31371 index 431e875..cbb23f3 100644
31372 --- a/arch/x86/vdso/vma.c
31373 +++ b/arch/x86/vdso/vma.c
31374 @@ -16,8 +16,6 @@
31375 #include <asm/vdso.h>
31376 #include <asm/page.h>
31377
31378 -unsigned int __read_mostly vdso_enabled = 1;
31379 -
31380 extern char vdso_start[], vdso_end[];
31381 extern unsigned short vdso_sync_cpuid;
31382
31383 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31384 * unaligned here as a result of stack start randomization.
31385 */
31386 addr = PAGE_ALIGN(addr);
31387 - addr = align_vdso_addr(addr);
31388
31389 return addr;
31390 }
31391 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31392 unsigned size)
31393 {
31394 struct mm_struct *mm = current->mm;
31395 - unsigned long addr;
31396 + unsigned long addr = 0;
31397 int ret;
31398
31399 - if (!vdso_enabled)
31400 - return 0;
31401 -
31402 down_write(&mm->mmap_sem);
31403 +
31404 +#ifdef CONFIG_PAX_RANDMMAP
31405 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31406 +#endif
31407 +
31408 addr = vdso_addr(mm->start_stack, size);
31409 + addr = align_vdso_addr(addr);
31410 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31411 if (IS_ERR_VALUE(addr)) {
31412 ret = addr;
31413 goto up_fail;
31414 }
31415
31416 - current->mm->context.vdso = (void *)addr;
31417 + mm->context.vdso = addr;
31418
31419 ret = install_special_mapping(mm, addr, size,
31420 VM_READ|VM_EXEC|
31421 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31422 pages);
31423 - if (ret) {
31424 - current->mm->context.vdso = NULL;
31425 - goto up_fail;
31426 - }
31427 + if (ret)
31428 + mm->context.vdso = 0;
31429
31430 up_fail:
31431 up_write(&mm->mmap_sem);
31432 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31433 vdsox32_size);
31434 }
31435 #endif
31436 -
31437 -static __init int vdso_setup(char *s)
31438 -{
31439 - vdso_enabled = simple_strtoul(s, NULL, 0);
31440 - return 0;
31441 -}
31442 -__setup("vdso=", vdso_setup);
31443 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31444 index 2262003..3ee61cf 100644
31445 --- a/arch/x86/xen/enlighten.c
31446 +++ b/arch/x86/xen/enlighten.c
31447 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31448
31449 struct shared_info xen_dummy_shared_info;
31450
31451 -void *xen_initial_gdt;
31452 -
31453 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31454 __read_mostly int xen_have_vector_callback;
31455 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31456 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31457 {
31458 unsigned long va = dtr->address;
31459 unsigned int size = dtr->size + 1;
31460 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31461 - unsigned long frames[pages];
31462 + unsigned long frames[65536 / PAGE_SIZE];
31463 int f;
31464
31465 /*
31466 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31467 {
31468 unsigned long va = dtr->address;
31469 unsigned int size = dtr->size + 1;
31470 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31471 - unsigned long frames[pages];
31472 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31473 int f;
31474
31475 /*
31476 @@ -554,7 +550,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31477 * 8-byte entries, or 16 4k pages..
31478 */
31479
31480 - BUG_ON(size > 65536);
31481 + BUG_ON(size > GDT_SIZE);
31482 BUG_ON(va & ~PAGE_MASK);
31483
31484 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31485 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31486 return 0;
31487 }
31488
31489 -static void set_xen_basic_apic_ops(void)
31490 +static void __init set_xen_basic_apic_ops(void)
31491 {
31492 apic->read = xen_apic_read;
31493 apic->write = xen_apic_write;
31494 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31495 #endif
31496 };
31497
31498 -static void xen_reboot(int reason)
31499 +static __noreturn void xen_reboot(int reason)
31500 {
31501 struct sched_shutdown r = { .reason = reason };
31502
31503 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31504 - BUG();
31505 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31506 + BUG();
31507 }
31508
31509 -static void xen_restart(char *msg)
31510 +static __noreturn void xen_restart(char *msg)
31511 {
31512 xen_reboot(SHUTDOWN_reboot);
31513 }
31514
31515 -static void xen_emergency_restart(void)
31516 +static __noreturn void xen_emergency_restart(void)
31517 {
31518 xen_reboot(SHUTDOWN_reboot);
31519 }
31520
31521 -static void xen_machine_halt(void)
31522 +static __noreturn void xen_machine_halt(void)
31523 {
31524 xen_reboot(SHUTDOWN_poweroff);
31525 }
31526
31527 -static void xen_machine_power_off(void)
31528 +static __noreturn void xen_machine_power_off(void)
31529 {
31530 if (pm_power_off)
31531 pm_power_off();
31532 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31533 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31534
31535 /* Work out if we support NX */
31536 - x86_configure_nx();
31537 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31538 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31539 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31540 + unsigned l, h;
31541 +
31542 + __supported_pte_mask |= _PAGE_NX;
31543 + rdmsr(MSR_EFER, l, h);
31544 + l |= EFER_NX;
31545 + wrmsr(MSR_EFER, l, h);
31546 + }
31547 +#endif
31548
31549 xen_setup_features();
31550
31551 @@ -1401,13 +1407,6 @@ asmlinkage void __init xen_start_kernel(void)
31552
31553 machine_ops = xen_machine_ops;
31554
31555 - /*
31556 - * The only reliable way to retain the initial address of the
31557 - * percpu gdt_page is to remember it here, so we can go and
31558 - * mark it RW later, when the initial percpu area is freed.
31559 - */
31560 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31561 -
31562 xen_smp_init();
31563
31564 #ifdef CONFIG_ACPI_NUMA
31565 @@ -1598,7 +1597,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31566 return NOTIFY_OK;
31567 }
31568
31569 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31570 +static struct notifier_block xen_hvm_cpu_notifier = {
31571 .notifier_call = xen_hvm_cpu_notify,
31572 };
31573
31574 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31575 index cab96b6..8c629ba 100644
31576 --- a/arch/x86/xen/mmu.c
31577 +++ b/arch/x86/xen/mmu.c
31578 @@ -1739,14 +1739,18 @@ static void *m2v(phys_addr_t maddr)
31579 }
31580
31581 /* Set the page permissions on an identity-mapped pages */
31582 -static void set_page_prot(void *addr, pgprot_t prot)
31583 +static void set_page_prot_flags(void *addr, pgprot_t prot, unsigned long flags)
31584 {
31585 unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
31586 pte_t pte = pfn_pte(pfn, prot);
31587
31588 - if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0))
31589 + if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, flags))
31590 BUG();
31591 }
31592 +static void set_page_prot(void *addr, pgprot_t prot)
31593 +{
31594 + return set_page_prot_flags(addr, prot, UVMF_NONE);
31595 +}
31596 #ifdef CONFIG_X86_32
31597 static void __init xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
31598 {
31599 @@ -1830,12 +1834,12 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
31600 unsigned long addr)
31601 {
31602 if (*pt_base == PFN_DOWN(__pa(addr))) {
31603 - set_page_prot((void *)addr, PAGE_KERNEL);
31604 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31605 clear_page((void *)addr);
31606 (*pt_base)++;
31607 }
31608 if (*pt_end == PFN_DOWN(__pa(addr))) {
31609 - set_page_prot((void *)addr, PAGE_KERNEL);
31610 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31611 clear_page((void *)addr);
31612 (*pt_end)--;
31613 }
31614 @@ -1881,6 +1885,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31615 /* L3_k[510] -> level2_kernel_pgt
31616 * L3_i[511] -> level2_fixmap_pgt */
31617 convert_pfn_mfn(level3_kernel_pgt);
31618 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31619 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31620 + convert_pfn_mfn(level3_vmemmap_pgt);
31621
31622 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31623 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31624 @@ -1910,8 +1917,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31625 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31626 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31627 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31628 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31629 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31630 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31631 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31632 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31633 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31634 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31635 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31636
31637 @@ -2097,6 +2108,7 @@ static void __init xen_post_allocator_init(void)
31638 pv_mmu_ops.set_pud = xen_set_pud;
31639 #if PAGETABLE_LEVELS == 4
31640 pv_mmu_ops.set_pgd = xen_set_pgd;
31641 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31642 #endif
31643
31644 /* This will work as long as patching hasn't happened yet
31645 @@ -2178,6 +2190,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31646 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31647 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31648 .set_pgd = xen_set_pgd_hyper,
31649 + .set_pgd_batched = xen_set_pgd_hyper,
31650
31651 .alloc_pud = xen_alloc_pmd_init,
31652 .release_pud = xen_release_pmd_init,
31653 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31654 index 34bc4ce..c34aa24 100644
31655 --- a/arch/x86/xen/smp.c
31656 +++ b/arch/x86/xen/smp.c
31657 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31658 {
31659 BUG_ON(smp_processor_id() != 0);
31660 native_smp_prepare_boot_cpu();
31661 -
31662 - /* We've switched to the "real" per-cpu gdt, so make sure the
31663 - old memory can be recycled */
31664 - make_lowmem_page_readwrite(xen_initial_gdt);
31665 -
31666 xen_filter_cpu_maps();
31667 xen_setup_vcpu_info_placement();
31668 }
31669 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31670 gdt = get_cpu_gdt_table(cpu);
31671
31672 ctxt->flags = VGCF_IN_KERNEL;
31673 - ctxt->user_regs.ds = __USER_DS;
31674 - ctxt->user_regs.es = __USER_DS;
31675 + ctxt->user_regs.ds = __KERNEL_DS;
31676 + ctxt->user_regs.es = __KERNEL_DS;
31677 ctxt->user_regs.ss = __KERNEL_DS;
31678 #ifdef CONFIG_X86_32
31679 ctxt->user_regs.fs = __KERNEL_PERCPU;
31680 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31681 + savesegment(gs, ctxt->user_regs.gs);
31682 #else
31683 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31684 #endif
31685 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31686 int rc;
31687
31688 per_cpu(current_task, cpu) = idle;
31689 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31690 #ifdef CONFIG_X86_32
31691 irq_ctx_init(cpu);
31692 #else
31693 clear_tsk_thread_flag(idle, TIF_FORK);
31694 - per_cpu(kernel_stack, cpu) =
31695 - (unsigned long)task_stack_page(idle) -
31696 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31697 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31698 #endif
31699 xen_setup_runstate_info(cpu);
31700 xen_setup_timer(cpu);
31701 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31702
31703 void __init xen_smp_init(void)
31704 {
31705 - smp_ops = xen_smp_ops;
31706 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31707 xen_fill_possible_map();
31708 xen_init_spinlocks();
31709 }
31710 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31711 index 33ca6e4..0ded929 100644
31712 --- a/arch/x86/xen/xen-asm_32.S
31713 +++ b/arch/x86/xen/xen-asm_32.S
31714 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31715 ESP_OFFSET=4 # bytes pushed onto stack
31716
31717 /*
31718 - * Store vcpu_info pointer for easy access. Do it this way to
31719 - * avoid having to reload %fs
31720 + * Store vcpu_info pointer for easy access.
31721 */
31722 #ifdef CONFIG_SMP
31723 - GET_THREAD_INFO(%eax)
31724 - movl %ss:TI_cpu(%eax), %eax
31725 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31726 - mov %ss:xen_vcpu(%eax), %eax
31727 + push %fs
31728 + mov $(__KERNEL_PERCPU), %eax
31729 + mov %eax, %fs
31730 + mov PER_CPU_VAR(xen_vcpu), %eax
31731 + pop %fs
31732 #else
31733 movl %ss:xen_vcpu, %eax
31734 #endif
31735 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31736 index 7faed58..ba4427c 100644
31737 --- a/arch/x86/xen/xen-head.S
31738 +++ b/arch/x86/xen/xen-head.S
31739 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31740 #ifdef CONFIG_X86_32
31741 mov %esi,xen_start_info
31742 mov $init_thread_union+THREAD_SIZE,%esp
31743 +#ifdef CONFIG_SMP
31744 + movl $cpu_gdt_table,%edi
31745 + movl $__per_cpu_load,%eax
31746 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31747 + rorl $16,%eax
31748 + movb %al,__KERNEL_PERCPU + 4(%edi)
31749 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31750 + movl $__per_cpu_end - 1,%eax
31751 + subl $__per_cpu_start,%eax
31752 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31753 +#endif
31754 #else
31755 mov %rsi,xen_start_info
31756 mov $init_thread_union+THREAD_SIZE,%rsp
31757 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31758 index a95b417..b6dbd0b 100644
31759 --- a/arch/x86/xen/xen-ops.h
31760 +++ b/arch/x86/xen/xen-ops.h
31761 @@ -10,8 +10,6 @@
31762 extern const char xen_hypervisor_callback[];
31763 extern const char xen_failsafe_callback[];
31764
31765 -extern void *xen_initial_gdt;
31766 -
31767 struct trap_info;
31768 void xen_copy_trap_info(struct trap_info *traps);
31769
31770 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31771 index 525bd3d..ef888b1 100644
31772 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31773 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31774 @@ -119,9 +119,9 @@
31775 ----------------------------------------------------------------------*/
31776
31777 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31778 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31779 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31780 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31781 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31782
31783 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31784 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31785 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31786 index 2f33760..835e50a 100644
31787 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31788 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31789 @@ -11,6 +11,7 @@
31790 #ifndef _XTENSA_CORE_H
31791 #define _XTENSA_CORE_H
31792
31793 +#include <linux/const.h>
31794
31795 /****************************************************************************
31796 Parameters Useful for Any Code, USER or PRIVILEGED
31797 @@ -112,9 +113,9 @@
31798 ----------------------------------------------------------------------*/
31799
31800 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31801 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31802 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31803 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31804 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31805
31806 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31807 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31808 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31809 index af00795..2bb8105 100644
31810 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31811 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31812 @@ -11,6 +11,7 @@
31813 #ifndef _XTENSA_CORE_CONFIGURATION_H
31814 #define _XTENSA_CORE_CONFIGURATION_H
31815
31816 +#include <linux/const.h>
31817
31818 /****************************************************************************
31819 Parameters Useful for Any Code, USER or PRIVILEGED
31820 @@ -118,9 +119,9 @@
31821 ----------------------------------------------------------------------*/
31822
31823 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31824 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31825 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31826 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31827 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31828
31829 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31830 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31831 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31832 index 58916af..eb9dbcf6 100644
31833 --- a/block/blk-iopoll.c
31834 +++ b/block/blk-iopoll.c
31835 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31836 }
31837 EXPORT_SYMBOL(blk_iopoll_complete);
31838
31839 -static void blk_iopoll_softirq(struct softirq_action *h)
31840 +static void blk_iopoll_softirq(void)
31841 {
31842 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31843 int rearm = 0, budget = blk_iopoll_budget;
31844 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31845 return NOTIFY_OK;
31846 }
31847
31848 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31849 +static struct notifier_block blk_iopoll_cpu_notifier = {
31850 .notifier_call = blk_iopoll_cpu_notify,
31851 };
31852
31853 diff --git a/block/blk-map.c b/block/blk-map.c
31854 index 623e1cd..ca1e109 100644
31855 --- a/block/blk-map.c
31856 +++ b/block/blk-map.c
31857 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31858 if (!len || !kbuf)
31859 return -EINVAL;
31860
31861 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31862 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31863 if (do_copy)
31864 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31865 else
31866 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31867 index 467c8de..f3628c5 100644
31868 --- a/block/blk-softirq.c
31869 +++ b/block/blk-softirq.c
31870 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31871 * Softirq action handler - move entries to local list and loop over them
31872 * while passing them to the queue registered handler.
31873 */
31874 -static void blk_done_softirq(struct softirq_action *h)
31875 +static void blk_done_softirq(void)
31876 {
31877 struct list_head *cpu_list, local_list;
31878
31879 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31880 return NOTIFY_OK;
31881 }
31882
31883 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31884 +static struct notifier_block blk_cpu_notifier = {
31885 .notifier_call = blk_cpu_notify,
31886 };
31887
31888 diff --git a/block/bsg.c b/block/bsg.c
31889 index ff64ae3..593560c 100644
31890 --- a/block/bsg.c
31891 +++ b/block/bsg.c
31892 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31893 struct sg_io_v4 *hdr, struct bsg_device *bd,
31894 fmode_t has_write_perm)
31895 {
31896 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31897 + unsigned char *cmdptr;
31898 +
31899 if (hdr->request_len > BLK_MAX_CDB) {
31900 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31901 if (!rq->cmd)
31902 return -ENOMEM;
31903 - }
31904 + cmdptr = rq->cmd;
31905 + } else
31906 + cmdptr = tmpcmd;
31907
31908 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31909 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31910 hdr->request_len))
31911 return -EFAULT;
31912
31913 + if (cmdptr != rq->cmd)
31914 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31915 +
31916 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31917 if (blk_verify_command(rq->cmd, has_write_perm))
31918 return -EPERM;
31919 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31920 index 7c668c8..db3521c 100644
31921 --- a/block/compat_ioctl.c
31922 +++ b/block/compat_ioctl.c
31923 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31924 err |= __get_user(f->spec1, &uf->spec1);
31925 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31926 err |= __get_user(name, &uf->name);
31927 - f->name = compat_ptr(name);
31928 + f->name = (void __force_kernel *)compat_ptr(name);
31929 if (err) {
31930 err = -EFAULT;
31931 goto out;
31932 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31933 index b62fb88..bdab4c4 100644
31934 --- a/block/partitions/efi.c
31935 +++ b/block/partitions/efi.c
31936 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31937 if (!gpt)
31938 return NULL;
31939
31940 + if (!le32_to_cpu(gpt->num_partition_entries))
31941 + return NULL;
31942 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31943 + if (!pte)
31944 + return NULL;
31945 +
31946 count = le32_to_cpu(gpt->num_partition_entries) *
31947 le32_to_cpu(gpt->sizeof_partition_entry);
31948 - if (!count)
31949 - return NULL;
31950 - pte = kzalloc(count, GFP_KERNEL);
31951 - if (!pte)
31952 - return NULL;
31953 -
31954 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31955 (u8 *) pte,
31956 count) < count) {
31957 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31958 index 9a87daa..fb17486 100644
31959 --- a/block/scsi_ioctl.c
31960 +++ b/block/scsi_ioctl.c
31961 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31962 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31963 struct sg_io_hdr *hdr, fmode_t mode)
31964 {
31965 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31966 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31967 + unsigned char *cmdptr;
31968 +
31969 + if (rq->cmd != rq->__cmd)
31970 + cmdptr = rq->cmd;
31971 + else
31972 + cmdptr = tmpcmd;
31973 +
31974 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31975 return -EFAULT;
31976 +
31977 + if (cmdptr != rq->cmd)
31978 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31979 +
31980 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31981 return -EPERM;
31982
31983 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31984 int err;
31985 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31986 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31987 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31988 + unsigned char *cmdptr;
31989
31990 if (!sic)
31991 return -EINVAL;
31992 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31993 */
31994 err = -EFAULT;
31995 rq->cmd_len = cmdlen;
31996 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31997 +
31998 + if (rq->cmd != rq->__cmd)
31999 + cmdptr = rq->cmd;
32000 + else
32001 + cmdptr = tmpcmd;
32002 +
32003 + if (copy_from_user(cmdptr, sic->data, cmdlen))
32004 goto error;
32005
32006 + if (rq->cmd != cmdptr)
32007 + memcpy(rq->cmd, cmdptr, cmdlen);
32008 +
32009 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
32010 goto error;
32011
32012 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
32013 index 7bdd61b..afec999 100644
32014 --- a/crypto/cryptd.c
32015 +++ b/crypto/cryptd.c
32016 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
32017
32018 struct cryptd_blkcipher_request_ctx {
32019 crypto_completion_t complete;
32020 -};
32021 +} __no_const;
32022
32023 struct cryptd_hash_ctx {
32024 struct crypto_shash *child;
32025 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
32026
32027 struct cryptd_aead_request_ctx {
32028 crypto_completion_t complete;
32029 -};
32030 +} __no_const;
32031
32032 static void cryptd_queue_worker(struct work_struct *work);
32033
32034 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
32035 index f6d9baf..dfd511f 100644
32036 --- a/crypto/crypto_user.c
32037 +++ b/crypto/crypto_user.c
32038 @@ -30,6 +30,8 @@
32039
32040 #include "internal.h"
32041
32042 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
32043 +
32044 static DEFINE_MUTEX(crypto_cfg_mutex);
32045
32046 /* The crypto netlink socket */
32047 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
32048 struct crypto_dump_info info;
32049 int err;
32050
32051 - if (!p->cru_driver_name)
32052 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32053 + return -EINVAL;
32054 +
32055 + if (!p->cru_driver_name[0])
32056 return -EINVAL;
32057
32058 alg = crypto_alg_match(p, 1);
32059 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32060 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32061 LIST_HEAD(list);
32062
32063 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32064 + return -EINVAL;
32065 +
32066 if (priority && !strlen(p->cru_driver_name))
32067 return -EINVAL;
32068
32069 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32070 struct crypto_alg *alg;
32071 struct crypto_user_alg *p = nlmsg_data(nlh);
32072
32073 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32074 + return -EINVAL;
32075 +
32076 alg = crypto_alg_match(p, 1);
32077 if (!alg)
32078 return -ENOENT;
32079 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32080 struct crypto_user_alg *p = nlmsg_data(nlh);
32081 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32082
32083 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32084 + return -EINVAL;
32085 +
32086 if (strlen(p->cru_driver_name))
32087 exact = 1;
32088
32089 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
32090 index f220d64..d359ad6 100644
32091 --- a/drivers/acpi/apei/apei-internal.h
32092 +++ b/drivers/acpi/apei/apei-internal.h
32093 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
32094 struct apei_exec_ins_type {
32095 u32 flags;
32096 apei_exec_ins_func_t run;
32097 -};
32098 +} __do_const;
32099
32100 struct apei_exec_context {
32101 u32 ip;
32102 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
32103 index e6defd8..c26a225 100644
32104 --- a/drivers/acpi/apei/cper.c
32105 +++ b/drivers/acpi/apei/cper.c
32106 @@ -38,12 +38,12 @@
32107 */
32108 u64 cper_next_record_id(void)
32109 {
32110 - static atomic64_t seq;
32111 + static atomic64_unchecked_t seq;
32112
32113 - if (!atomic64_read(&seq))
32114 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
32115 + if (!atomic64_read_unchecked(&seq))
32116 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
32117
32118 - return atomic64_inc_return(&seq);
32119 + return atomic64_inc_return_unchecked(&seq);
32120 }
32121 EXPORT_SYMBOL_GPL(cper_next_record_id);
32122
32123 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
32124 index be60399..778b33e8 100644
32125 --- a/drivers/acpi/bgrt.c
32126 +++ b/drivers/acpi/bgrt.c
32127 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
32128 return -ENODEV;
32129
32130 sysfs_bin_attr_init(&image_attr);
32131 - image_attr.private = bgrt_image;
32132 - image_attr.size = bgrt_image_size;
32133 + pax_open_kernel();
32134 + *(void **)&image_attr.private = bgrt_image;
32135 + *(size_t *)&image_attr.size = bgrt_image_size;
32136 + pax_close_kernel();
32137
32138 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
32139 if (!bgrt_kobj)
32140 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
32141 index cb96296..b81293b 100644
32142 --- a/drivers/acpi/blacklist.c
32143 +++ b/drivers/acpi/blacklist.c
32144 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
32145 u32 is_critical_error;
32146 };
32147
32148 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
32149 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
32150
32151 /*
32152 * POLICY: If *anything* doesn't work, put it on the blacklist.
32153 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
32154 return 0;
32155 }
32156
32157 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
32158 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
32159 {
32160 .callback = dmi_disable_osi_vista,
32161 .ident = "Fujitsu Siemens",
32162 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32163 index 7586544..636a2f0 100644
32164 --- a/drivers/acpi/ec_sys.c
32165 +++ b/drivers/acpi/ec_sys.c
32166 @@ -12,6 +12,7 @@
32167 #include <linux/acpi.h>
32168 #include <linux/debugfs.h>
32169 #include <linux/module.h>
32170 +#include <linux/uaccess.h>
32171 #include "internal.h"
32172
32173 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32174 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32175 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32176 */
32177 unsigned int size = EC_SPACE_SIZE;
32178 - u8 *data = (u8 *) buf;
32179 + u8 data;
32180 loff_t init_off = *off;
32181 int err = 0;
32182
32183 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32184 size = count;
32185
32186 while (size) {
32187 - err = ec_read(*off, &data[*off - init_off]);
32188 + err = ec_read(*off, &data);
32189 if (err)
32190 return err;
32191 + if (put_user(data, &buf[*off - init_off]))
32192 + return -EFAULT;
32193 *off += 1;
32194 size--;
32195 }
32196 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32197
32198 unsigned int size = count;
32199 loff_t init_off = *off;
32200 - u8 *data = (u8 *) buf;
32201 int err = 0;
32202
32203 if (*off >= EC_SPACE_SIZE)
32204 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32205 }
32206
32207 while (size) {
32208 - u8 byte_write = data[*off - init_off];
32209 + u8 byte_write;
32210 + if (get_user(byte_write, &buf[*off - init_off]))
32211 + return -EFAULT;
32212 err = ec_write(*off, byte_write);
32213 if (err)
32214 return err;
32215 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
32216 index e83311b..142b5cc 100644
32217 --- a/drivers/acpi/processor_driver.c
32218 +++ b/drivers/acpi/processor_driver.c
32219 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
32220 return 0;
32221 #endif
32222
32223 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
32224 + BUG_ON(pr->id >= nr_cpu_ids);
32225
32226 /*
32227 * Buggy BIOS check
32228 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32229 index ed9a1cc..f4a354c 100644
32230 --- a/drivers/acpi/processor_idle.c
32231 +++ b/drivers/acpi/processor_idle.c
32232 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32233 {
32234 int i, count = CPUIDLE_DRIVER_STATE_START;
32235 struct acpi_processor_cx *cx;
32236 - struct cpuidle_state *state;
32237 + cpuidle_state_no_const *state;
32238 struct cpuidle_driver *drv = &acpi_idle_driver;
32239
32240 if (!pr->flags.power_setup_done)
32241 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32242 index ea61ca9..3fdd70d 100644
32243 --- a/drivers/acpi/sysfs.c
32244 +++ b/drivers/acpi/sysfs.c
32245 @@ -420,11 +420,11 @@ static u32 num_counters;
32246 static struct attribute **all_attrs;
32247 static u32 acpi_gpe_count;
32248
32249 -static struct attribute_group interrupt_stats_attr_group = {
32250 +static attribute_group_no_const interrupt_stats_attr_group = {
32251 .name = "interrupts",
32252 };
32253
32254 -static struct kobj_attribute *counter_attrs;
32255 +static kobj_attribute_no_const *counter_attrs;
32256
32257 static void delete_gpe_attr_array(void)
32258 {
32259 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32260 index 6cd7805..07facb3 100644
32261 --- a/drivers/ata/libahci.c
32262 +++ b/drivers/ata/libahci.c
32263 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32264 }
32265 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32266
32267 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32268 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32269 struct ata_taskfile *tf, int is_cmd, u16 flags,
32270 unsigned long timeout_msec)
32271 {
32272 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32273 index 501c209..5f28b4d 100644
32274 --- a/drivers/ata/libata-core.c
32275 +++ b/drivers/ata/libata-core.c
32276 @@ -4784,7 +4784,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32277 struct ata_port *ap;
32278 unsigned int tag;
32279
32280 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32281 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32282 ap = qc->ap;
32283
32284 qc->flags = 0;
32285 @@ -4800,7 +4800,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32286 struct ata_port *ap;
32287 struct ata_link *link;
32288
32289 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32290 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32291 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32292 ap = qc->ap;
32293 link = qc->dev->link;
32294 @@ -5896,6 +5896,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32295 return;
32296
32297 spin_lock(&lock);
32298 + pax_open_kernel();
32299
32300 for (cur = ops->inherits; cur; cur = cur->inherits) {
32301 void **inherit = (void **)cur;
32302 @@ -5909,8 +5910,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32303 if (IS_ERR(*pp))
32304 *pp = NULL;
32305
32306 - ops->inherits = NULL;
32307 + *(struct ata_port_operations **)&ops->inherits = NULL;
32308
32309 + pax_close_kernel();
32310 spin_unlock(&lock);
32311 }
32312
32313 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32314 index 405022d..fb70e53 100644
32315 --- a/drivers/ata/pata_arasan_cf.c
32316 +++ b/drivers/ata/pata_arasan_cf.c
32317 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32318 /* Handle platform specific quirks */
32319 if (pdata->quirk) {
32320 if (pdata->quirk & CF_BROKEN_PIO) {
32321 - ap->ops->set_piomode = NULL;
32322 + pax_open_kernel();
32323 + *(void **)&ap->ops->set_piomode = NULL;
32324 + pax_close_kernel();
32325 ap->pio_mask = 0;
32326 }
32327 if (pdata->quirk & CF_BROKEN_MWDMA)
32328 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32329 index f9b983a..887b9d8 100644
32330 --- a/drivers/atm/adummy.c
32331 +++ b/drivers/atm/adummy.c
32332 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32333 vcc->pop(vcc, skb);
32334 else
32335 dev_kfree_skb_any(skb);
32336 - atomic_inc(&vcc->stats->tx);
32337 + atomic_inc_unchecked(&vcc->stats->tx);
32338
32339 return 0;
32340 }
32341 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32342 index 77a7480..05cde58 100644
32343 --- a/drivers/atm/ambassador.c
32344 +++ b/drivers/atm/ambassador.c
32345 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32346 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32347
32348 // VC layer stats
32349 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32350 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32351
32352 // free the descriptor
32353 kfree (tx_descr);
32354 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32355 dump_skb ("<<<", vc, skb);
32356
32357 // VC layer stats
32358 - atomic_inc(&atm_vcc->stats->rx);
32359 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32360 __net_timestamp(skb);
32361 // end of our responsibility
32362 atm_vcc->push (atm_vcc, skb);
32363 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32364 } else {
32365 PRINTK (KERN_INFO, "dropped over-size frame");
32366 // should we count this?
32367 - atomic_inc(&atm_vcc->stats->rx_drop);
32368 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32369 }
32370
32371 } else {
32372 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32373 }
32374
32375 if (check_area (skb->data, skb->len)) {
32376 - atomic_inc(&atm_vcc->stats->tx_err);
32377 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32378 return -ENOMEM; // ?
32379 }
32380
32381 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32382 index b22d71c..d6e1049 100644
32383 --- a/drivers/atm/atmtcp.c
32384 +++ b/drivers/atm/atmtcp.c
32385 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32386 if (vcc->pop) vcc->pop(vcc,skb);
32387 else dev_kfree_skb(skb);
32388 if (dev_data) return 0;
32389 - atomic_inc(&vcc->stats->tx_err);
32390 + atomic_inc_unchecked(&vcc->stats->tx_err);
32391 return -ENOLINK;
32392 }
32393 size = skb->len+sizeof(struct atmtcp_hdr);
32394 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32395 if (!new_skb) {
32396 if (vcc->pop) vcc->pop(vcc,skb);
32397 else dev_kfree_skb(skb);
32398 - atomic_inc(&vcc->stats->tx_err);
32399 + atomic_inc_unchecked(&vcc->stats->tx_err);
32400 return -ENOBUFS;
32401 }
32402 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32403 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32404 if (vcc->pop) vcc->pop(vcc,skb);
32405 else dev_kfree_skb(skb);
32406 out_vcc->push(out_vcc,new_skb);
32407 - atomic_inc(&vcc->stats->tx);
32408 - atomic_inc(&out_vcc->stats->rx);
32409 + atomic_inc_unchecked(&vcc->stats->tx);
32410 + atomic_inc_unchecked(&out_vcc->stats->rx);
32411 return 0;
32412 }
32413
32414 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32415 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32416 read_unlock(&vcc_sklist_lock);
32417 if (!out_vcc) {
32418 - atomic_inc(&vcc->stats->tx_err);
32419 + atomic_inc_unchecked(&vcc->stats->tx_err);
32420 goto done;
32421 }
32422 skb_pull(skb,sizeof(struct atmtcp_hdr));
32423 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32424 __net_timestamp(new_skb);
32425 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32426 out_vcc->push(out_vcc,new_skb);
32427 - atomic_inc(&vcc->stats->tx);
32428 - atomic_inc(&out_vcc->stats->rx);
32429 + atomic_inc_unchecked(&vcc->stats->tx);
32430 + atomic_inc_unchecked(&out_vcc->stats->rx);
32431 done:
32432 if (vcc->pop) vcc->pop(vcc,skb);
32433 else dev_kfree_skb(skb);
32434 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32435 index c1eb6fa..4c71be9 100644
32436 --- a/drivers/atm/eni.c
32437 +++ b/drivers/atm/eni.c
32438 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32439 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32440 vcc->dev->number);
32441 length = 0;
32442 - atomic_inc(&vcc->stats->rx_err);
32443 + atomic_inc_unchecked(&vcc->stats->rx_err);
32444 }
32445 else {
32446 length = ATM_CELL_SIZE-1; /* no HEC */
32447 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32448 size);
32449 }
32450 eff = length = 0;
32451 - atomic_inc(&vcc->stats->rx_err);
32452 + atomic_inc_unchecked(&vcc->stats->rx_err);
32453 }
32454 else {
32455 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32456 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32457 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32458 vcc->dev->number,vcc->vci,length,size << 2,descr);
32459 length = eff = 0;
32460 - atomic_inc(&vcc->stats->rx_err);
32461 + atomic_inc_unchecked(&vcc->stats->rx_err);
32462 }
32463 }
32464 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32465 @@ -767,7 +767,7 @@ rx_dequeued++;
32466 vcc->push(vcc,skb);
32467 pushed++;
32468 }
32469 - atomic_inc(&vcc->stats->rx);
32470 + atomic_inc_unchecked(&vcc->stats->rx);
32471 }
32472 wake_up(&eni_dev->rx_wait);
32473 }
32474 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32475 PCI_DMA_TODEVICE);
32476 if (vcc->pop) vcc->pop(vcc,skb);
32477 else dev_kfree_skb_irq(skb);
32478 - atomic_inc(&vcc->stats->tx);
32479 + atomic_inc_unchecked(&vcc->stats->tx);
32480 wake_up(&eni_dev->tx_wait);
32481 dma_complete++;
32482 }
32483 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32484 index b41c948..a002b17 100644
32485 --- a/drivers/atm/firestream.c
32486 +++ b/drivers/atm/firestream.c
32487 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32488 }
32489 }
32490
32491 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32492 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32493
32494 fs_dprintk (FS_DEBUG_TXMEM, "i");
32495 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32496 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32497 #endif
32498 skb_put (skb, qe->p1 & 0xffff);
32499 ATM_SKB(skb)->vcc = atm_vcc;
32500 - atomic_inc(&atm_vcc->stats->rx);
32501 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32502 __net_timestamp(skb);
32503 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32504 atm_vcc->push (atm_vcc, skb);
32505 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32506 kfree (pe);
32507 }
32508 if (atm_vcc)
32509 - atomic_inc(&atm_vcc->stats->rx_drop);
32510 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32511 break;
32512 case 0x1f: /* Reassembly abort: no buffers. */
32513 /* Silently increment error counter. */
32514 if (atm_vcc)
32515 - atomic_inc(&atm_vcc->stats->rx_drop);
32516 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32517 break;
32518 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32519 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32520 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32521 index 204814e..cede831 100644
32522 --- a/drivers/atm/fore200e.c
32523 +++ b/drivers/atm/fore200e.c
32524 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32525 #endif
32526 /* check error condition */
32527 if (*entry->status & STATUS_ERROR)
32528 - atomic_inc(&vcc->stats->tx_err);
32529 + atomic_inc_unchecked(&vcc->stats->tx_err);
32530 else
32531 - atomic_inc(&vcc->stats->tx);
32532 + atomic_inc_unchecked(&vcc->stats->tx);
32533 }
32534 }
32535
32536 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32537 if (skb == NULL) {
32538 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32539
32540 - atomic_inc(&vcc->stats->rx_drop);
32541 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32542 return -ENOMEM;
32543 }
32544
32545 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32546
32547 dev_kfree_skb_any(skb);
32548
32549 - atomic_inc(&vcc->stats->rx_drop);
32550 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32551 return -ENOMEM;
32552 }
32553
32554 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32555
32556 vcc->push(vcc, skb);
32557 - atomic_inc(&vcc->stats->rx);
32558 + atomic_inc_unchecked(&vcc->stats->rx);
32559
32560 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32561
32562 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32563 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32564 fore200e->atm_dev->number,
32565 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32566 - atomic_inc(&vcc->stats->rx_err);
32567 + atomic_inc_unchecked(&vcc->stats->rx_err);
32568 }
32569 }
32570
32571 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32572 goto retry_here;
32573 }
32574
32575 - atomic_inc(&vcc->stats->tx_err);
32576 + atomic_inc_unchecked(&vcc->stats->tx_err);
32577
32578 fore200e->tx_sat++;
32579 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32580 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32581 index 72b6960..cf9167a 100644
32582 --- a/drivers/atm/he.c
32583 +++ b/drivers/atm/he.c
32584 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32585
32586 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32587 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32588 - atomic_inc(&vcc->stats->rx_drop);
32589 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32590 goto return_host_buffers;
32591 }
32592
32593 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32594 RBRQ_LEN_ERR(he_dev->rbrq_head)
32595 ? "LEN_ERR" : "",
32596 vcc->vpi, vcc->vci);
32597 - atomic_inc(&vcc->stats->rx_err);
32598 + atomic_inc_unchecked(&vcc->stats->rx_err);
32599 goto return_host_buffers;
32600 }
32601
32602 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32603 vcc->push(vcc, skb);
32604 spin_lock(&he_dev->global_lock);
32605
32606 - atomic_inc(&vcc->stats->rx);
32607 + atomic_inc_unchecked(&vcc->stats->rx);
32608
32609 return_host_buffers:
32610 ++pdus_assembled;
32611 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32612 tpd->vcc->pop(tpd->vcc, tpd->skb);
32613 else
32614 dev_kfree_skb_any(tpd->skb);
32615 - atomic_inc(&tpd->vcc->stats->tx_err);
32616 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32617 }
32618 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32619 return;
32620 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32621 vcc->pop(vcc, skb);
32622 else
32623 dev_kfree_skb_any(skb);
32624 - atomic_inc(&vcc->stats->tx_err);
32625 + atomic_inc_unchecked(&vcc->stats->tx_err);
32626 return -EINVAL;
32627 }
32628
32629 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32630 vcc->pop(vcc, skb);
32631 else
32632 dev_kfree_skb_any(skb);
32633 - atomic_inc(&vcc->stats->tx_err);
32634 + atomic_inc_unchecked(&vcc->stats->tx_err);
32635 return -EINVAL;
32636 }
32637 #endif
32638 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32639 vcc->pop(vcc, skb);
32640 else
32641 dev_kfree_skb_any(skb);
32642 - atomic_inc(&vcc->stats->tx_err);
32643 + atomic_inc_unchecked(&vcc->stats->tx_err);
32644 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32645 return -ENOMEM;
32646 }
32647 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32648 vcc->pop(vcc, skb);
32649 else
32650 dev_kfree_skb_any(skb);
32651 - atomic_inc(&vcc->stats->tx_err);
32652 + atomic_inc_unchecked(&vcc->stats->tx_err);
32653 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32654 return -ENOMEM;
32655 }
32656 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32657 __enqueue_tpd(he_dev, tpd, cid);
32658 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32659
32660 - atomic_inc(&vcc->stats->tx);
32661 + atomic_inc_unchecked(&vcc->stats->tx);
32662
32663 return 0;
32664 }
32665 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32666 index 1dc0519..1aadaf7 100644
32667 --- a/drivers/atm/horizon.c
32668 +++ b/drivers/atm/horizon.c
32669 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32670 {
32671 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32672 // VC layer stats
32673 - atomic_inc(&vcc->stats->rx);
32674 + atomic_inc_unchecked(&vcc->stats->rx);
32675 __net_timestamp(skb);
32676 // end of our responsibility
32677 vcc->push (vcc, skb);
32678 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32679 dev->tx_iovec = NULL;
32680
32681 // VC layer stats
32682 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32683 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32684
32685 // free the skb
32686 hrz_kfree_skb (skb);
32687 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32688 index 272f009..a18ba55 100644
32689 --- a/drivers/atm/idt77252.c
32690 +++ b/drivers/atm/idt77252.c
32691 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32692 else
32693 dev_kfree_skb(skb);
32694
32695 - atomic_inc(&vcc->stats->tx);
32696 + atomic_inc_unchecked(&vcc->stats->tx);
32697 }
32698
32699 atomic_dec(&scq->used);
32700 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32701 if ((sb = dev_alloc_skb(64)) == NULL) {
32702 printk("%s: Can't allocate buffers for aal0.\n",
32703 card->name);
32704 - atomic_add(i, &vcc->stats->rx_drop);
32705 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32706 break;
32707 }
32708 if (!atm_charge(vcc, sb->truesize)) {
32709 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32710 card->name);
32711 - atomic_add(i - 1, &vcc->stats->rx_drop);
32712 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32713 dev_kfree_skb(sb);
32714 break;
32715 }
32716 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32717 ATM_SKB(sb)->vcc = vcc;
32718 __net_timestamp(sb);
32719 vcc->push(vcc, sb);
32720 - atomic_inc(&vcc->stats->rx);
32721 + atomic_inc_unchecked(&vcc->stats->rx);
32722
32723 cell += ATM_CELL_PAYLOAD;
32724 }
32725 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32726 "(CDC: %08x)\n",
32727 card->name, len, rpp->len, readl(SAR_REG_CDC));
32728 recycle_rx_pool_skb(card, rpp);
32729 - atomic_inc(&vcc->stats->rx_err);
32730 + atomic_inc_unchecked(&vcc->stats->rx_err);
32731 return;
32732 }
32733 if (stat & SAR_RSQE_CRC) {
32734 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32735 recycle_rx_pool_skb(card, rpp);
32736 - atomic_inc(&vcc->stats->rx_err);
32737 + atomic_inc_unchecked(&vcc->stats->rx_err);
32738 return;
32739 }
32740 if (skb_queue_len(&rpp->queue) > 1) {
32741 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32742 RXPRINTK("%s: Can't alloc RX skb.\n",
32743 card->name);
32744 recycle_rx_pool_skb(card, rpp);
32745 - atomic_inc(&vcc->stats->rx_err);
32746 + atomic_inc_unchecked(&vcc->stats->rx_err);
32747 return;
32748 }
32749 if (!atm_charge(vcc, skb->truesize)) {
32750 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32751 __net_timestamp(skb);
32752
32753 vcc->push(vcc, skb);
32754 - atomic_inc(&vcc->stats->rx);
32755 + atomic_inc_unchecked(&vcc->stats->rx);
32756
32757 return;
32758 }
32759 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32760 __net_timestamp(skb);
32761
32762 vcc->push(vcc, skb);
32763 - atomic_inc(&vcc->stats->rx);
32764 + atomic_inc_unchecked(&vcc->stats->rx);
32765
32766 if (skb->truesize > SAR_FB_SIZE_3)
32767 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32768 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32769 if (vcc->qos.aal != ATM_AAL0) {
32770 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32771 card->name, vpi, vci);
32772 - atomic_inc(&vcc->stats->rx_drop);
32773 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32774 goto drop;
32775 }
32776
32777 if ((sb = dev_alloc_skb(64)) == NULL) {
32778 printk("%s: Can't allocate buffers for AAL0.\n",
32779 card->name);
32780 - atomic_inc(&vcc->stats->rx_err);
32781 + atomic_inc_unchecked(&vcc->stats->rx_err);
32782 goto drop;
32783 }
32784
32785 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32786 ATM_SKB(sb)->vcc = vcc;
32787 __net_timestamp(sb);
32788 vcc->push(vcc, sb);
32789 - atomic_inc(&vcc->stats->rx);
32790 + atomic_inc_unchecked(&vcc->stats->rx);
32791
32792 drop:
32793 skb_pull(queue, 64);
32794 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32795
32796 if (vc == NULL) {
32797 printk("%s: NULL connection in send().\n", card->name);
32798 - atomic_inc(&vcc->stats->tx_err);
32799 + atomic_inc_unchecked(&vcc->stats->tx_err);
32800 dev_kfree_skb(skb);
32801 return -EINVAL;
32802 }
32803 if (!test_bit(VCF_TX, &vc->flags)) {
32804 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32805 - atomic_inc(&vcc->stats->tx_err);
32806 + atomic_inc_unchecked(&vcc->stats->tx_err);
32807 dev_kfree_skb(skb);
32808 return -EINVAL;
32809 }
32810 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32811 break;
32812 default:
32813 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32814 - atomic_inc(&vcc->stats->tx_err);
32815 + atomic_inc_unchecked(&vcc->stats->tx_err);
32816 dev_kfree_skb(skb);
32817 return -EINVAL;
32818 }
32819
32820 if (skb_shinfo(skb)->nr_frags != 0) {
32821 printk("%s: No scatter-gather yet.\n", card->name);
32822 - atomic_inc(&vcc->stats->tx_err);
32823 + atomic_inc_unchecked(&vcc->stats->tx_err);
32824 dev_kfree_skb(skb);
32825 return -EINVAL;
32826 }
32827 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32828
32829 err = queue_skb(card, vc, skb, oam);
32830 if (err) {
32831 - atomic_inc(&vcc->stats->tx_err);
32832 + atomic_inc_unchecked(&vcc->stats->tx_err);
32833 dev_kfree_skb(skb);
32834 return err;
32835 }
32836 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32837 skb = dev_alloc_skb(64);
32838 if (!skb) {
32839 printk("%s: Out of memory in send_oam().\n", card->name);
32840 - atomic_inc(&vcc->stats->tx_err);
32841 + atomic_inc_unchecked(&vcc->stats->tx_err);
32842 return -ENOMEM;
32843 }
32844 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32845 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32846 index 4217f29..88f547a 100644
32847 --- a/drivers/atm/iphase.c
32848 +++ b/drivers/atm/iphase.c
32849 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32850 status = (u_short) (buf_desc_ptr->desc_mode);
32851 if (status & (RX_CER | RX_PTE | RX_OFL))
32852 {
32853 - atomic_inc(&vcc->stats->rx_err);
32854 + atomic_inc_unchecked(&vcc->stats->rx_err);
32855 IF_ERR(printk("IA: bad packet, dropping it");)
32856 if (status & RX_CER) {
32857 IF_ERR(printk(" cause: packet CRC error\n");)
32858 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32859 len = dma_addr - buf_addr;
32860 if (len > iadev->rx_buf_sz) {
32861 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32862 - atomic_inc(&vcc->stats->rx_err);
32863 + atomic_inc_unchecked(&vcc->stats->rx_err);
32864 goto out_free_desc;
32865 }
32866
32867 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32868 ia_vcc = INPH_IA_VCC(vcc);
32869 if (ia_vcc == NULL)
32870 {
32871 - atomic_inc(&vcc->stats->rx_err);
32872 + atomic_inc_unchecked(&vcc->stats->rx_err);
32873 atm_return(vcc, skb->truesize);
32874 dev_kfree_skb_any(skb);
32875 goto INCR_DLE;
32876 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32877 if ((length > iadev->rx_buf_sz) || (length >
32878 (skb->len - sizeof(struct cpcs_trailer))))
32879 {
32880 - atomic_inc(&vcc->stats->rx_err);
32881 + atomic_inc_unchecked(&vcc->stats->rx_err);
32882 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32883 length, skb->len);)
32884 atm_return(vcc, skb->truesize);
32885 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32886
32887 IF_RX(printk("rx_dle_intr: skb push");)
32888 vcc->push(vcc,skb);
32889 - atomic_inc(&vcc->stats->rx);
32890 + atomic_inc_unchecked(&vcc->stats->rx);
32891 iadev->rx_pkt_cnt++;
32892 }
32893 INCR_DLE:
32894 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32895 {
32896 struct k_sonet_stats *stats;
32897 stats = &PRIV(_ia_dev[board])->sonet_stats;
32898 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32899 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32900 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32901 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32902 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32903 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32904 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32905 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32906 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32907 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32908 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32909 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32910 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32911 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32912 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32913 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32914 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32915 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32916 }
32917 ia_cmds.status = 0;
32918 break;
32919 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32920 if ((desc == 0) || (desc > iadev->num_tx_desc))
32921 {
32922 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32923 - atomic_inc(&vcc->stats->tx);
32924 + atomic_inc_unchecked(&vcc->stats->tx);
32925 if (vcc->pop)
32926 vcc->pop(vcc, skb);
32927 else
32928 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32929 ATM_DESC(skb) = vcc->vci;
32930 skb_queue_tail(&iadev->tx_dma_q, skb);
32931
32932 - atomic_inc(&vcc->stats->tx);
32933 + atomic_inc_unchecked(&vcc->stats->tx);
32934 iadev->tx_pkt_cnt++;
32935 /* Increment transaction counter */
32936 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32937
32938 #if 0
32939 /* add flow control logic */
32940 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32941 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32942 if (iavcc->vc_desc_cnt > 10) {
32943 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32944 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32945 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32946 index fa7d701..1e404c7 100644
32947 --- a/drivers/atm/lanai.c
32948 +++ b/drivers/atm/lanai.c
32949 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32950 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32951 lanai_endtx(lanai, lvcc);
32952 lanai_free_skb(lvcc->tx.atmvcc, skb);
32953 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32954 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32955 }
32956
32957 /* Try to fill the buffer - don't call unless there is backlog */
32958 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32959 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32960 __net_timestamp(skb);
32961 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32962 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32963 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32964 out:
32965 lvcc->rx.buf.ptr = end;
32966 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32967 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32968 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32969 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32970 lanai->stats.service_rxnotaal5++;
32971 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32972 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32973 return 0;
32974 }
32975 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32976 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32977 int bytes;
32978 read_unlock(&vcc_sklist_lock);
32979 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32980 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32981 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32982 lvcc->stats.x.aal5.service_trash++;
32983 bytes = (SERVICE_GET_END(s) * 16) -
32984 (((unsigned long) lvcc->rx.buf.ptr) -
32985 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32986 }
32987 if (s & SERVICE_STREAM) {
32988 read_unlock(&vcc_sklist_lock);
32989 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32990 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32991 lvcc->stats.x.aal5.service_stream++;
32992 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32993 "PDU on VCI %d!\n", lanai->number, vci);
32994 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32995 return 0;
32996 }
32997 DPRINTK("got rx crc error on vci %d\n", vci);
32998 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32999 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33000 lvcc->stats.x.aal5.service_rxcrc++;
33001 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
33002 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
33003 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
33004 index ed1d2b7..8cffc1f 100644
33005 --- a/drivers/atm/nicstar.c
33006 +++ b/drivers/atm/nicstar.c
33007 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33008 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
33009 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
33010 card->index);
33011 - atomic_inc(&vcc->stats->tx_err);
33012 + atomic_inc_unchecked(&vcc->stats->tx_err);
33013 dev_kfree_skb_any(skb);
33014 return -EINVAL;
33015 }
33016 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33017 if (!vc->tx) {
33018 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
33019 card->index);
33020 - atomic_inc(&vcc->stats->tx_err);
33021 + atomic_inc_unchecked(&vcc->stats->tx_err);
33022 dev_kfree_skb_any(skb);
33023 return -EINVAL;
33024 }
33025 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33026 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
33027 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
33028 card->index);
33029 - atomic_inc(&vcc->stats->tx_err);
33030 + atomic_inc_unchecked(&vcc->stats->tx_err);
33031 dev_kfree_skb_any(skb);
33032 return -EINVAL;
33033 }
33034
33035 if (skb_shinfo(skb)->nr_frags != 0) {
33036 printk("nicstar%d: No scatter-gather yet.\n", card->index);
33037 - atomic_inc(&vcc->stats->tx_err);
33038 + atomic_inc_unchecked(&vcc->stats->tx_err);
33039 dev_kfree_skb_any(skb);
33040 return -EINVAL;
33041 }
33042 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33043 }
33044
33045 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
33046 - atomic_inc(&vcc->stats->tx_err);
33047 + atomic_inc_unchecked(&vcc->stats->tx_err);
33048 dev_kfree_skb_any(skb);
33049 return -EIO;
33050 }
33051 - atomic_inc(&vcc->stats->tx);
33052 + atomic_inc_unchecked(&vcc->stats->tx);
33053
33054 return 0;
33055 }
33056 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33057 printk
33058 ("nicstar%d: Can't allocate buffers for aal0.\n",
33059 card->index);
33060 - atomic_add(i, &vcc->stats->rx_drop);
33061 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
33062 break;
33063 }
33064 if (!atm_charge(vcc, sb->truesize)) {
33065 RXPRINTK
33066 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
33067 card->index);
33068 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33069 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33070 dev_kfree_skb_any(sb);
33071 break;
33072 }
33073 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33074 ATM_SKB(sb)->vcc = vcc;
33075 __net_timestamp(sb);
33076 vcc->push(vcc, sb);
33077 - atomic_inc(&vcc->stats->rx);
33078 + atomic_inc_unchecked(&vcc->stats->rx);
33079 cell += ATM_CELL_PAYLOAD;
33080 }
33081
33082 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33083 if (iovb == NULL) {
33084 printk("nicstar%d: Out of iovec buffers.\n",
33085 card->index);
33086 - atomic_inc(&vcc->stats->rx_drop);
33087 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33088 recycle_rx_buf(card, skb);
33089 return;
33090 }
33091 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33092 small or large buffer itself. */
33093 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
33094 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
33095 - atomic_inc(&vcc->stats->rx_err);
33096 + atomic_inc_unchecked(&vcc->stats->rx_err);
33097 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33098 NS_MAX_IOVECS);
33099 NS_PRV_IOVCNT(iovb) = 0;
33100 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33101 ("nicstar%d: Expected a small buffer, and this is not one.\n",
33102 card->index);
33103 which_list(card, skb);
33104 - atomic_inc(&vcc->stats->rx_err);
33105 + atomic_inc_unchecked(&vcc->stats->rx_err);
33106 recycle_rx_buf(card, skb);
33107 vc->rx_iov = NULL;
33108 recycle_iov_buf(card, iovb);
33109 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33110 ("nicstar%d: Expected a large buffer, and this is not one.\n",
33111 card->index);
33112 which_list(card, skb);
33113 - atomic_inc(&vcc->stats->rx_err);
33114 + atomic_inc_unchecked(&vcc->stats->rx_err);
33115 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33116 NS_PRV_IOVCNT(iovb));
33117 vc->rx_iov = NULL;
33118 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33119 printk(" - PDU size mismatch.\n");
33120 else
33121 printk(".\n");
33122 - atomic_inc(&vcc->stats->rx_err);
33123 + atomic_inc_unchecked(&vcc->stats->rx_err);
33124 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33125 NS_PRV_IOVCNT(iovb));
33126 vc->rx_iov = NULL;
33127 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33128 /* skb points to a small buffer */
33129 if (!atm_charge(vcc, skb->truesize)) {
33130 push_rxbufs(card, skb);
33131 - atomic_inc(&vcc->stats->rx_drop);
33132 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33133 } else {
33134 skb_put(skb, len);
33135 dequeue_sm_buf(card, skb);
33136 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33137 ATM_SKB(skb)->vcc = vcc;
33138 __net_timestamp(skb);
33139 vcc->push(vcc, skb);
33140 - atomic_inc(&vcc->stats->rx);
33141 + atomic_inc_unchecked(&vcc->stats->rx);
33142 }
33143 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
33144 struct sk_buff *sb;
33145 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33146 if (len <= NS_SMBUFSIZE) {
33147 if (!atm_charge(vcc, sb->truesize)) {
33148 push_rxbufs(card, sb);
33149 - atomic_inc(&vcc->stats->rx_drop);
33150 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33151 } else {
33152 skb_put(sb, len);
33153 dequeue_sm_buf(card, sb);
33154 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33155 ATM_SKB(sb)->vcc = vcc;
33156 __net_timestamp(sb);
33157 vcc->push(vcc, sb);
33158 - atomic_inc(&vcc->stats->rx);
33159 + atomic_inc_unchecked(&vcc->stats->rx);
33160 }
33161
33162 push_rxbufs(card, skb);
33163 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33164
33165 if (!atm_charge(vcc, skb->truesize)) {
33166 push_rxbufs(card, skb);
33167 - atomic_inc(&vcc->stats->rx_drop);
33168 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33169 } else {
33170 dequeue_lg_buf(card, skb);
33171 #ifdef NS_USE_DESTRUCTORS
33172 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33173 ATM_SKB(skb)->vcc = vcc;
33174 __net_timestamp(skb);
33175 vcc->push(vcc, skb);
33176 - atomic_inc(&vcc->stats->rx);
33177 + atomic_inc_unchecked(&vcc->stats->rx);
33178 }
33179
33180 push_rxbufs(card, sb);
33181 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33182 printk
33183 ("nicstar%d: Out of huge buffers.\n",
33184 card->index);
33185 - atomic_inc(&vcc->stats->rx_drop);
33186 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33187 recycle_iovec_rx_bufs(card,
33188 (struct iovec *)
33189 iovb->data,
33190 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33191 card->hbpool.count++;
33192 } else
33193 dev_kfree_skb_any(hb);
33194 - atomic_inc(&vcc->stats->rx_drop);
33195 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33196 } else {
33197 /* Copy the small buffer to the huge buffer */
33198 sb = (struct sk_buff *)iov->iov_base;
33199 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33200 #endif /* NS_USE_DESTRUCTORS */
33201 __net_timestamp(hb);
33202 vcc->push(vcc, hb);
33203 - atomic_inc(&vcc->stats->rx);
33204 + atomic_inc_unchecked(&vcc->stats->rx);
33205 }
33206 }
33207
33208 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33209 index 0474a89..06ea4a1 100644
33210 --- a/drivers/atm/solos-pci.c
33211 +++ b/drivers/atm/solos-pci.c
33212 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33213 }
33214 atm_charge(vcc, skb->truesize);
33215 vcc->push(vcc, skb);
33216 - atomic_inc(&vcc->stats->rx);
33217 + atomic_inc_unchecked(&vcc->stats->rx);
33218 break;
33219
33220 case PKT_STATUS:
33221 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33222 vcc = SKB_CB(oldskb)->vcc;
33223
33224 if (vcc) {
33225 - atomic_inc(&vcc->stats->tx);
33226 + atomic_inc_unchecked(&vcc->stats->tx);
33227 solos_pop(vcc, oldskb);
33228 } else {
33229 dev_kfree_skb_irq(oldskb);
33230 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33231 index 0215934..ce9f5b1 100644
33232 --- a/drivers/atm/suni.c
33233 +++ b/drivers/atm/suni.c
33234 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33235
33236
33237 #define ADD_LIMITED(s,v) \
33238 - atomic_add((v),&stats->s); \
33239 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33240 + atomic_add_unchecked((v),&stats->s); \
33241 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33242
33243
33244 static void suni_hz(unsigned long from_timer)
33245 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33246 index 5120a96..e2572bd 100644
33247 --- a/drivers/atm/uPD98402.c
33248 +++ b/drivers/atm/uPD98402.c
33249 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33250 struct sonet_stats tmp;
33251 int error = 0;
33252
33253 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33254 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33255 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33256 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33257 if (zero && !error) {
33258 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33259
33260
33261 #define ADD_LIMITED(s,v) \
33262 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33263 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33264 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33265 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33266 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33267 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33268
33269
33270 static void stat_event(struct atm_dev *dev)
33271 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33272 if (reason & uPD98402_INT_PFM) stat_event(dev);
33273 if (reason & uPD98402_INT_PCO) {
33274 (void) GET(PCOCR); /* clear interrupt cause */
33275 - atomic_add(GET(HECCT),
33276 + atomic_add_unchecked(GET(HECCT),
33277 &PRIV(dev)->sonet_stats.uncorr_hcs);
33278 }
33279 if ((reason & uPD98402_INT_RFO) &&
33280 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33281 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33282 uPD98402_INT_LOS),PIMR); /* enable them */
33283 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33284 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33285 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33286 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33287 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33288 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33289 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33290 return 0;
33291 }
33292
33293 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33294 index 969c3c2..9b72956 100644
33295 --- a/drivers/atm/zatm.c
33296 +++ b/drivers/atm/zatm.c
33297 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33298 }
33299 if (!size) {
33300 dev_kfree_skb_irq(skb);
33301 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33302 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33303 continue;
33304 }
33305 if (!atm_charge(vcc,skb->truesize)) {
33306 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33307 skb->len = size;
33308 ATM_SKB(skb)->vcc = vcc;
33309 vcc->push(vcc,skb);
33310 - atomic_inc(&vcc->stats->rx);
33311 + atomic_inc_unchecked(&vcc->stats->rx);
33312 }
33313 zout(pos & 0xffff,MTA(mbx));
33314 #if 0 /* probably a stupid idea */
33315 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33316 skb_queue_head(&zatm_vcc->backlog,skb);
33317 break;
33318 }
33319 - atomic_inc(&vcc->stats->tx);
33320 + atomic_inc_unchecked(&vcc->stats->tx);
33321 wake_up(&zatm_vcc->tx_wait);
33322 }
33323
33324 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33325 index 6856303..0602d70 100644
33326 --- a/drivers/base/bus.c
33327 +++ b/drivers/base/bus.c
33328 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33329 return -EINVAL;
33330
33331 mutex_lock(&subsys->p->mutex);
33332 - list_add_tail(&sif->node, &subsys->p->interfaces);
33333 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33334 if (sif->add_dev) {
33335 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33336 while ((dev = subsys_dev_iter_next(&iter)))
33337 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33338 subsys = sif->subsys;
33339
33340 mutex_lock(&subsys->p->mutex);
33341 - list_del_init(&sif->node);
33342 + pax_list_del_init((struct list_head *)&sif->node);
33343 if (sif->remove_dev) {
33344 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33345 while ((dev = subsys_dev_iter_next(&iter)))
33346 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33347 index 17cf7ca..7e553e1 100644
33348 --- a/drivers/base/devtmpfs.c
33349 +++ b/drivers/base/devtmpfs.c
33350 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
33351 if (!thread)
33352 return 0;
33353
33354 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33355 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33356 if (err)
33357 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33358 else
33359 diff --git a/drivers/base/node.c b/drivers/base/node.c
33360 index fac124a..66bd4ab 100644
33361 --- a/drivers/base/node.c
33362 +++ b/drivers/base/node.c
33363 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33364 struct node_attr {
33365 struct device_attribute attr;
33366 enum node_states state;
33367 -};
33368 +} __do_const;
33369
33370 static ssize_t show_node_state(struct device *dev,
33371 struct device_attribute *attr, char *buf)
33372 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33373 index acc3a8d..981c236 100644
33374 --- a/drivers/base/power/domain.c
33375 +++ b/drivers/base/power/domain.c
33376 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33377 {
33378 struct cpuidle_driver *cpuidle_drv;
33379 struct gpd_cpu_data *cpu_data;
33380 - struct cpuidle_state *idle_state;
33381 + cpuidle_state_no_const *idle_state;
33382 int ret = 0;
33383
33384 if (IS_ERR_OR_NULL(genpd) || state < 0)
33385 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33386 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33387 {
33388 struct gpd_cpu_data *cpu_data;
33389 - struct cpuidle_state *idle_state;
33390 + cpuidle_state_no_const *idle_state;
33391 int ret = 0;
33392
33393 if (IS_ERR_OR_NULL(genpd))
33394 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33395 index e6ee5e8..98ad7fc 100644
33396 --- a/drivers/base/power/wakeup.c
33397 +++ b/drivers/base/power/wakeup.c
33398 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33399 * They need to be modified together atomically, so it's better to use one
33400 * atomic variable to hold them both.
33401 */
33402 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33403 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33404
33405 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33406 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33407
33408 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33409 {
33410 - unsigned int comb = atomic_read(&combined_event_count);
33411 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33412
33413 *cnt = (comb >> IN_PROGRESS_BITS);
33414 *inpr = comb & MAX_IN_PROGRESS;
33415 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33416 ws->start_prevent_time = ws->last_time;
33417
33418 /* Increment the counter of events in progress. */
33419 - cec = atomic_inc_return(&combined_event_count);
33420 + cec = atomic_inc_return_unchecked(&combined_event_count);
33421
33422 trace_wakeup_source_activate(ws->name, cec);
33423 }
33424 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33425 * Increment the counter of registered wakeup events and decrement the
33426 * couter of wakeup events in progress simultaneously.
33427 */
33428 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33429 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33430 trace_wakeup_source_deactivate(ws->name, cec);
33431
33432 split_counters(&cnt, &inpr);
33433 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33434 index e8d11b6..7b1b36f 100644
33435 --- a/drivers/base/syscore.c
33436 +++ b/drivers/base/syscore.c
33437 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33438 void register_syscore_ops(struct syscore_ops *ops)
33439 {
33440 mutex_lock(&syscore_ops_lock);
33441 - list_add_tail(&ops->node, &syscore_ops_list);
33442 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33443 mutex_unlock(&syscore_ops_lock);
33444 }
33445 EXPORT_SYMBOL_GPL(register_syscore_ops);
33446 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33447 void unregister_syscore_ops(struct syscore_ops *ops)
33448 {
33449 mutex_lock(&syscore_ops_lock);
33450 - list_del(&ops->node);
33451 + pax_list_del((struct list_head *)&ops->node);
33452 mutex_unlock(&syscore_ops_lock);
33453 }
33454 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33455 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33456 index ade58bc..867143d 100644
33457 --- a/drivers/block/cciss.c
33458 +++ b/drivers/block/cciss.c
33459 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33460 int err;
33461 u32 cp;
33462
33463 + memset(&arg64, 0, sizeof(arg64));
33464 +
33465 err = 0;
33466 err |=
33467 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33468 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33469 while (!list_empty(&h->reqQ)) {
33470 c = list_entry(h->reqQ.next, CommandList_struct, list);
33471 /* can't do anything if fifo is full */
33472 - if ((h->access.fifo_full(h))) {
33473 + if ((h->access->fifo_full(h))) {
33474 dev_warn(&h->pdev->dev, "fifo full\n");
33475 break;
33476 }
33477 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33478 h->Qdepth--;
33479
33480 /* Tell the controller execute command */
33481 - h->access.submit_command(h, c);
33482 + h->access->submit_command(h, c);
33483
33484 /* Put job onto the completed Q */
33485 addQ(&h->cmpQ, c);
33486 @@ -3441,17 +3443,17 @@ startio:
33487
33488 static inline unsigned long get_next_completion(ctlr_info_t *h)
33489 {
33490 - return h->access.command_completed(h);
33491 + return h->access->command_completed(h);
33492 }
33493
33494 static inline int interrupt_pending(ctlr_info_t *h)
33495 {
33496 - return h->access.intr_pending(h);
33497 + return h->access->intr_pending(h);
33498 }
33499
33500 static inline long interrupt_not_for_us(ctlr_info_t *h)
33501 {
33502 - return ((h->access.intr_pending(h) == 0) ||
33503 + return ((h->access->intr_pending(h) == 0) ||
33504 (h->interrupts_enabled == 0));
33505 }
33506
33507 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33508 u32 a;
33509
33510 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33511 - return h->access.command_completed(h);
33512 + return h->access->command_completed(h);
33513
33514 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33515 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33516 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33517 trans_support & CFGTBL_Trans_use_short_tags);
33518
33519 /* Change the access methods to the performant access methods */
33520 - h->access = SA5_performant_access;
33521 + h->access = &SA5_performant_access;
33522 h->transMethod = CFGTBL_Trans_Performant;
33523
33524 return;
33525 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33526 if (prod_index < 0)
33527 return -ENODEV;
33528 h->product_name = products[prod_index].product_name;
33529 - h->access = *(products[prod_index].access);
33530 + h->access = products[prod_index].access;
33531
33532 if (cciss_board_disabled(h)) {
33533 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33534 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33535 }
33536
33537 /* make sure the board interrupts are off */
33538 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33539 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33540 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33541 if (rc)
33542 goto clean2;
33543 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33544 * fake ones to scoop up any residual completions.
33545 */
33546 spin_lock_irqsave(&h->lock, flags);
33547 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33548 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33549 spin_unlock_irqrestore(&h->lock, flags);
33550 free_irq(h->intr[h->intr_mode], h);
33551 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33552 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33553 dev_info(&h->pdev->dev, "Board READY.\n");
33554 dev_info(&h->pdev->dev,
33555 "Waiting for stale completions to drain.\n");
33556 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33557 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33558 msleep(10000);
33559 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33560 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33561
33562 rc = controller_reset_failed(h->cfgtable);
33563 if (rc)
33564 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33565 cciss_scsi_setup(h);
33566
33567 /* Turn the interrupts on so we can service requests */
33568 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33569 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33570
33571 /* Get the firmware version */
33572 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33573 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33574 kfree(flush_buf);
33575 if (return_code != IO_OK)
33576 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33577 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33578 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33579 free_irq(h->intr[h->intr_mode], h);
33580 }
33581
33582 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33583 index 7fda30e..eb5dfe0 100644
33584 --- a/drivers/block/cciss.h
33585 +++ b/drivers/block/cciss.h
33586 @@ -101,7 +101,7 @@ struct ctlr_info
33587 /* information about each logical volume */
33588 drive_info_struct *drv[CISS_MAX_LUN];
33589
33590 - struct access_method access;
33591 + struct access_method *access;
33592
33593 /* queue and queue Info */
33594 struct list_head reqQ;
33595 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33596 index 3f08713..56a586a 100644
33597 --- a/drivers/block/cpqarray.c
33598 +++ b/drivers/block/cpqarray.c
33599 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33600 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33601 goto Enomem4;
33602 }
33603 - hba[i]->access.set_intr_mask(hba[i], 0);
33604 + hba[i]->access->set_intr_mask(hba[i], 0);
33605 if (request_irq(hba[i]->intr, do_ida_intr,
33606 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33607 {
33608 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33609 add_timer(&hba[i]->timer);
33610
33611 /* Enable IRQ now that spinlock and rate limit timer are set up */
33612 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33613 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33614
33615 for(j=0; j<NWD; j++) {
33616 struct gendisk *disk = ida_gendisk[i][j];
33617 @@ -694,7 +694,7 @@ DBGINFO(
33618 for(i=0; i<NR_PRODUCTS; i++) {
33619 if (board_id == products[i].board_id) {
33620 c->product_name = products[i].product_name;
33621 - c->access = *(products[i].access);
33622 + c->access = products[i].access;
33623 break;
33624 }
33625 }
33626 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33627 hba[ctlr]->intr = intr;
33628 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33629 hba[ctlr]->product_name = products[j].product_name;
33630 - hba[ctlr]->access = *(products[j].access);
33631 + hba[ctlr]->access = products[j].access;
33632 hba[ctlr]->ctlr = ctlr;
33633 hba[ctlr]->board_id = board_id;
33634 hba[ctlr]->pci_dev = NULL; /* not PCI */
33635 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33636
33637 while((c = h->reqQ) != NULL) {
33638 /* Can't do anything if we're busy */
33639 - if (h->access.fifo_full(h) == 0)
33640 + if (h->access->fifo_full(h) == 0)
33641 return;
33642
33643 /* Get the first entry from the request Q */
33644 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33645 h->Qdepth--;
33646
33647 /* Tell the controller to do our bidding */
33648 - h->access.submit_command(h, c);
33649 + h->access->submit_command(h, c);
33650
33651 /* Get onto the completion Q */
33652 addQ(&h->cmpQ, c);
33653 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33654 unsigned long flags;
33655 __u32 a,a1;
33656
33657 - istat = h->access.intr_pending(h);
33658 + istat = h->access->intr_pending(h);
33659 /* Is this interrupt for us? */
33660 if (istat == 0)
33661 return IRQ_NONE;
33662 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33663 */
33664 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33665 if (istat & FIFO_NOT_EMPTY) {
33666 - while((a = h->access.command_completed(h))) {
33667 + while((a = h->access->command_completed(h))) {
33668 a1 = a; a &= ~3;
33669 if ((c = h->cmpQ) == NULL)
33670 {
33671 @@ -1449,11 +1449,11 @@ static int sendcmd(
33672 /*
33673 * Disable interrupt
33674 */
33675 - info_p->access.set_intr_mask(info_p, 0);
33676 + info_p->access->set_intr_mask(info_p, 0);
33677 /* Make sure there is room in the command FIFO */
33678 /* Actually it should be completely empty at this time. */
33679 for (i = 200000; i > 0; i--) {
33680 - temp = info_p->access.fifo_full(info_p);
33681 + temp = info_p->access->fifo_full(info_p);
33682 if (temp != 0) {
33683 break;
33684 }
33685 @@ -1466,7 +1466,7 @@ DBG(
33686 /*
33687 * Send the cmd
33688 */
33689 - info_p->access.submit_command(info_p, c);
33690 + info_p->access->submit_command(info_p, c);
33691 complete = pollcomplete(ctlr);
33692
33693 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33694 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33695 * we check the new geometry. Then turn interrupts back on when
33696 * we're done.
33697 */
33698 - host->access.set_intr_mask(host, 0);
33699 + host->access->set_intr_mask(host, 0);
33700 getgeometry(ctlr);
33701 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33702 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33703
33704 for(i=0; i<NWD; i++) {
33705 struct gendisk *disk = ida_gendisk[ctlr][i];
33706 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33707 /* Wait (up to 2 seconds) for a command to complete */
33708
33709 for (i = 200000; i > 0; i--) {
33710 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33711 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33712 if (done == 0) {
33713 udelay(10); /* a short fixed delay */
33714 } else
33715 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33716 index be73e9d..7fbf140 100644
33717 --- a/drivers/block/cpqarray.h
33718 +++ b/drivers/block/cpqarray.h
33719 @@ -99,7 +99,7 @@ struct ctlr_info {
33720 drv_info_t drv[NWD];
33721 struct proc_dir_entry *proc;
33722
33723 - struct access_method access;
33724 + struct access_method *access;
33725
33726 cmdlist_t *reqQ;
33727 cmdlist_t *cmpQ;
33728 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33729 index 6b51afa..17e1191 100644
33730 --- a/drivers/block/drbd/drbd_int.h
33731 +++ b/drivers/block/drbd/drbd_int.h
33732 @@ -582,7 +582,7 @@ struct drbd_epoch {
33733 struct drbd_tconn *tconn;
33734 struct list_head list;
33735 unsigned int barrier_nr;
33736 - atomic_t epoch_size; /* increased on every request added. */
33737 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33738 atomic_t active; /* increased on every req. added, and dec on every finished. */
33739 unsigned long flags;
33740 };
33741 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33742 int al_tr_cycle;
33743 int al_tr_pos; /* position of the next transaction in the journal */
33744 wait_queue_head_t seq_wait;
33745 - atomic_t packet_seq;
33746 + atomic_unchecked_t packet_seq;
33747 unsigned int peer_seq;
33748 spinlock_t peer_seq_lock;
33749 unsigned int minor;
33750 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33751 char __user *uoptval;
33752 int err;
33753
33754 - uoptval = (char __user __force *)optval;
33755 + uoptval = (char __force_user *)optval;
33756
33757 set_fs(KERNEL_DS);
33758 if (level == SOL_SOCKET)
33759 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33760 index 8c13eeb..217adee 100644
33761 --- a/drivers/block/drbd/drbd_main.c
33762 +++ b/drivers/block/drbd/drbd_main.c
33763 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33764 p->sector = sector;
33765 p->block_id = block_id;
33766 p->blksize = blksize;
33767 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33768 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33769 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33770 }
33771
33772 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33773 return -EIO;
33774 p->sector = cpu_to_be64(req->i.sector);
33775 p->block_id = (unsigned long)req;
33776 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33777 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33778 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33779 if (mdev->state.conn >= C_SYNC_SOURCE &&
33780 mdev->state.conn <= C_PAUSED_SYNC_T)
33781 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33782 {
33783 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33784
33785 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33786 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33787 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33788 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33789 kfree(tconn->current_epoch);
33790
33791 idr_destroy(&tconn->volumes);
33792 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33793 index a9eccfc..f5efe87 100644
33794 --- a/drivers/block/drbd/drbd_receiver.c
33795 +++ b/drivers/block/drbd/drbd_receiver.c
33796 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33797 {
33798 int err;
33799
33800 - atomic_set(&mdev->packet_seq, 0);
33801 + atomic_set_unchecked(&mdev->packet_seq, 0);
33802 mdev->peer_seq = 0;
33803
33804 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33805 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33806 do {
33807 next_epoch = NULL;
33808
33809 - epoch_size = atomic_read(&epoch->epoch_size);
33810 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33811
33812 switch (ev & ~EV_CLEANUP) {
33813 case EV_PUT:
33814 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33815 rv = FE_DESTROYED;
33816 } else {
33817 epoch->flags = 0;
33818 - atomic_set(&epoch->epoch_size, 0);
33819 + atomic_set_unchecked(&epoch->epoch_size, 0);
33820 /* atomic_set(&epoch->active, 0); is already zero */
33821 if (rv == FE_STILL_LIVE)
33822 rv = FE_RECYCLED;
33823 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33824 conn_wait_active_ee_empty(tconn);
33825 drbd_flush(tconn);
33826
33827 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33828 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33829 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33830 if (epoch)
33831 break;
33832 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33833 }
33834
33835 epoch->flags = 0;
33836 - atomic_set(&epoch->epoch_size, 0);
33837 + atomic_set_unchecked(&epoch->epoch_size, 0);
33838 atomic_set(&epoch->active, 0);
33839
33840 spin_lock(&tconn->epoch_lock);
33841 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33842 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33843 list_add(&epoch->list, &tconn->current_epoch->list);
33844 tconn->current_epoch = epoch;
33845 tconn->epochs++;
33846 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33847
33848 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33849 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33850 - atomic_inc(&tconn->current_epoch->epoch_size);
33851 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33852 err2 = drbd_drain_block(mdev, pi->size);
33853 if (!err)
33854 err = err2;
33855 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33856
33857 spin_lock(&tconn->epoch_lock);
33858 peer_req->epoch = tconn->current_epoch;
33859 - atomic_inc(&peer_req->epoch->epoch_size);
33860 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33861 atomic_inc(&peer_req->epoch->active);
33862 spin_unlock(&tconn->epoch_lock);
33863
33864 @@ -4346,7 +4346,7 @@ struct data_cmd {
33865 int expect_payload;
33866 size_t pkt_size;
33867 int (*fn)(struct drbd_tconn *, struct packet_info *);
33868 -};
33869 +} __do_const;
33870
33871 static struct data_cmd drbd_cmd_handler[] = {
33872 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33873 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33874 if (!list_empty(&tconn->current_epoch->list))
33875 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33876 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33877 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33878 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33879 tconn->send.seen_any_write_yet = false;
33880
33881 conn_info(tconn, "Connection closed\n");
33882 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33883 struct asender_cmd {
33884 size_t pkt_size;
33885 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33886 -};
33887 +} __do_const;
33888
33889 static struct asender_cmd asender_tbl[] = {
33890 [P_PING] = { 0, got_Ping },
33891 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33892 index f74f2c0..bb668af 100644
33893 --- a/drivers/block/loop.c
33894 +++ b/drivers/block/loop.c
33895 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33896 mm_segment_t old_fs = get_fs();
33897
33898 set_fs(get_ds());
33899 - bw = file->f_op->write(file, buf, len, &pos);
33900 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33901 set_fs(old_fs);
33902 if (likely(bw == len))
33903 return 0;
33904 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33905 index 2e7de7a..ed86dc0 100644
33906 --- a/drivers/block/pktcdvd.c
33907 +++ b/drivers/block/pktcdvd.c
33908 @@ -83,7 +83,7 @@
33909
33910 #define MAX_SPEED 0xffff
33911
33912 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33913 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33914
33915 static DEFINE_MUTEX(pktcdvd_mutex);
33916 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33917 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33918 index d620b44..587561e 100644
33919 --- a/drivers/cdrom/cdrom.c
33920 +++ b/drivers/cdrom/cdrom.c
33921 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33922 ENSURE(reset, CDC_RESET);
33923 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33924 cdi->mc_flags = 0;
33925 - cdo->n_minors = 0;
33926 cdi->options = CDO_USE_FFLAGS;
33927
33928 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33929 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33930 else
33931 cdi->cdda_method = CDDA_OLD;
33932
33933 - if (!cdo->generic_packet)
33934 - cdo->generic_packet = cdrom_dummy_generic_packet;
33935 + if (!cdo->generic_packet) {
33936 + pax_open_kernel();
33937 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33938 + pax_close_kernel();
33939 + }
33940
33941 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33942 mutex_lock(&cdrom_mutex);
33943 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33944 if (cdi->exit)
33945 cdi->exit(cdi);
33946
33947 - cdi->ops->n_minors--;
33948 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33949 }
33950
33951 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33952 index d59cdcb..11afddf 100644
33953 --- a/drivers/cdrom/gdrom.c
33954 +++ b/drivers/cdrom/gdrom.c
33955 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33956 .audio_ioctl = gdrom_audio_ioctl,
33957 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33958 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33959 - .n_minors = 1,
33960 };
33961
33962 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33963 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33964 index 72bedad..8181ce1 100644
33965 --- a/drivers/char/Kconfig
33966 +++ b/drivers/char/Kconfig
33967 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33968
33969 config DEVKMEM
33970 bool "/dev/kmem virtual device support"
33971 - default y
33972 + default n
33973 + depends on !GRKERNSEC_KMEM
33974 help
33975 Say Y here if you want to support the /dev/kmem device. The
33976 /dev/kmem device is rarely used, but can be used for certain
33977 @@ -581,6 +582,7 @@ config DEVPORT
33978 bool
33979 depends on !M68K
33980 depends on ISA || PCI
33981 + depends on !GRKERNSEC_KMEM
33982 default y
33983
33984 source "drivers/s390/char/Kconfig"
33985 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33986 index 2e04433..22afc64 100644
33987 --- a/drivers/char/agp/frontend.c
33988 +++ b/drivers/char/agp/frontend.c
33989 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33990 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33991 return -EFAULT;
33992
33993 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33994 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33995 return -EFAULT;
33996
33997 client = agp_find_client_by_pid(reserve.pid);
33998 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33999 index 21cb980..f15107c 100644
34000 --- a/drivers/char/genrtc.c
34001 +++ b/drivers/char/genrtc.c
34002 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
34003 switch (cmd) {
34004
34005 case RTC_PLL_GET:
34006 + memset(&pll, 0, sizeof(pll));
34007 if (get_rtc_pll(&pll))
34008 return -EINVAL;
34009 else
34010 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
34011 index 615d262..15d5c9d 100644
34012 --- a/drivers/char/hpet.c
34013 +++ b/drivers/char/hpet.c
34014 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
34015 }
34016
34017 static int
34018 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
34019 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
34020 struct hpet_info *info)
34021 {
34022 struct hpet_timer __iomem *timer;
34023 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
34024 index 053201b0..8335cce 100644
34025 --- a/drivers/char/ipmi/ipmi_msghandler.c
34026 +++ b/drivers/char/ipmi/ipmi_msghandler.c
34027 @@ -420,7 +420,7 @@ struct ipmi_smi {
34028 struct proc_dir_entry *proc_dir;
34029 char proc_dir_name[10];
34030
34031 - atomic_t stats[IPMI_NUM_STATS];
34032 + atomic_unchecked_t stats[IPMI_NUM_STATS];
34033
34034 /*
34035 * run_to_completion duplicate of smb_info, smi_info
34036 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
34037
34038
34039 #define ipmi_inc_stat(intf, stat) \
34040 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
34041 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
34042 #define ipmi_get_stat(intf, stat) \
34043 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
34044 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
34045
34046 static int is_lan_addr(struct ipmi_addr *addr)
34047 {
34048 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
34049 INIT_LIST_HEAD(&intf->cmd_rcvrs);
34050 init_waitqueue_head(&intf->waitq);
34051 for (i = 0; i < IPMI_NUM_STATS; i++)
34052 - atomic_set(&intf->stats[i], 0);
34053 + atomic_set_unchecked(&intf->stats[i], 0);
34054
34055 intf->proc_dir = NULL;
34056
34057 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
34058 index 1c7fdcd..4899100 100644
34059 --- a/drivers/char/ipmi/ipmi_si_intf.c
34060 +++ b/drivers/char/ipmi/ipmi_si_intf.c
34061 @@ -275,7 +275,7 @@ struct smi_info {
34062 unsigned char slave_addr;
34063
34064 /* Counters and things for the proc filesystem. */
34065 - atomic_t stats[SI_NUM_STATS];
34066 + atomic_unchecked_t stats[SI_NUM_STATS];
34067
34068 struct task_struct *thread;
34069
34070 @@ -284,9 +284,9 @@ struct smi_info {
34071 };
34072
34073 #define smi_inc_stat(smi, stat) \
34074 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
34075 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
34076 #define smi_get_stat(smi, stat) \
34077 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
34078 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
34079
34080 #define SI_MAX_PARMS 4
34081
34082 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
34083 atomic_set(&new_smi->req_events, 0);
34084 new_smi->run_to_completion = 0;
34085 for (i = 0; i < SI_NUM_STATS; i++)
34086 - atomic_set(&new_smi->stats[i], 0);
34087 + atomic_set_unchecked(&new_smi->stats[i], 0);
34088
34089 new_smi->interrupt_disabled = 1;
34090 atomic_set(&new_smi->stop_operation, 0);
34091 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34092 index c6fa3bc..4ca3e42 100644
34093 --- a/drivers/char/mem.c
34094 +++ b/drivers/char/mem.c
34095 @@ -18,6 +18,7 @@
34096 #include <linux/raw.h>
34097 #include <linux/tty.h>
34098 #include <linux/capability.h>
34099 +#include <linux/security.h>
34100 #include <linux/ptrace.h>
34101 #include <linux/device.h>
34102 #include <linux/highmem.h>
34103 @@ -37,6 +38,10 @@
34104
34105 #define DEVPORT_MINOR 4
34106
34107 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34108 +extern const struct file_operations grsec_fops;
34109 +#endif
34110 +
34111 static inline unsigned long size_inside_page(unsigned long start,
34112 unsigned long size)
34113 {
34114 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34115
34116 while (cursor < to) {
34117 if (!devmem_is_allowed(pfn)) {
34118 +#ifdef CONFIG_GRKERNSEC_KMEM
34119 + gr_handle_mem_readwrite(from, to);
34120 +#else
34121 printk(KERN_INFO
34122 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34123 current->comm, from, to);
34124 +#endif
34125 return 0;
34126 }
34127 cursor += PAGE_SIZE;
34128 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34129 }
34130 return 1;
34131 }
34132 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34133 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34134 +{
34135 + return 0;
34136 +}
34137 #else
34138 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34139 {
34140 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34141
34142 while (count > 0) {
34143 unsigned long remaining;
34144 + char *temp;
34145
34146 sz = size_inside_page(p, count);
34147
34148 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34149 if (!ptr)
34150 return -EFAULT;
34151
34152 - remaining = copy_to_user(buf, ptr, sz);
34153 +#ifdef CONFIG_PAX_USERCOPY
34154 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34155 + if (!temp) {
34156 + unxlate_dev_mem_ptr(p, ptr);
34157 + return -ENOMEM;
34158 + }
34159 + memcpy(temp, ptr, sz);
34160 +#else
34161 + temp = ptr;
34162 +#endif
34163 +
34164 + remaining = copy_to_user(buf, temp, sz);
34165 +
34166 +#ifdef CONFIG_PAX_USERCOPY
34167 + kfree(temp);
34168 +#endif
34169 +
34170 unxlate_dev_mem_ptr(p, ptr);
34171 if (remaining)
34172 return -EFAULT;
34173 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34174 size_t count, loff_t *ppos)
34175 {
34176 unsigned long p = *ppos;
34177 - ssize_t low_count, read, sz;
34178 + ssize_t low_count, read, sz, err = 0;
34179 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34180 - int err = 0;
34181
34182 read = 0;
34183 if (p < (unsigned long) high_memory) {
34184 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34185 }
34186 #endif
34187 while (low_count > 0) {
34188 + char *temp;
34189 +
34190 sz = size_inside_page(p, low_count);
34191
34192 /*
34193 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34194 */
34195 kbuf = xlate_dev_kmem_ptr((char *)p);
34196
34197 - if (copy_to_user(buf, kbuf, sz))
34198 +#ifdef CONFIG_PAX_USERCOPY
34199 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34200 + if (!temp)
34201 + return -ENOMEM;
34202 + memcpy(temp, kbuf, sz);
34203 +#else
34204 + temp = kbuf;
34205 +#endif
34206 +
34207 + err = copy_to_user(buf, temp, sz);
34208 +
34209 +#ifdef CONFIG_PAX_USERCOPY
34210 + kfree(temp);
34211 +#endif
34212 +
34213 + if (err)
34214 return -EFAULT;
34215 buf += sz;
34216 p += sz;
34217 @@ -833,6 +880,9 @@ static const struct memdev {
34218 #ifdef CONFIG_CRASH_DUMP
34219 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34220 #endif
34221 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34222 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34223 +#endif
34224 };
34225
34226 static int memory_open(struct inode *inode, struct file *filp)
34227 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34228 index 9df78e2..01ba9ae 100644
34229 --- a/drivers/char/nvram.c
34230 +++ b/drivers/char/nvram.c
34231 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34232
34233 spin_unlock_irq(&rtc_lock);
34234
34235 - if (copy_to_user(buf, contents, tmp - contents))
34236 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34237 return -EFAULT;
34238
34239 *ppos = i;
34240 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34241 index b66eaa0..2619d1b 100644
34242 --- a/drivers/char/pcmcia/synclink_cs.c
34243 +++ b/drivers/char/pcmcia/synclink_cs.c
34244 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34245
34246 if (debug_level >= DEBUG_LEVEL_INFO)
34247 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34248 - __FILE__,__LINE__, info->device_name, port->count);
34249 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
34250
34251 - WARN_ON(!port->count);
34252 + WARN_ON(!atomic_read(&port->count));
34253
34254 if (tty_port_close_start(port, tty, filp) == 0)
34255 goto cleanup;
34256 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34257 cleanup:
34258 if (debug_level >= DEBUG_LEVEL_INFO)
34259 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
34260 - tty->driver->name, port->count);
34261 + tty->driver->name, atomic_read(&port->count));
34262 }
34263
34264 /* Wait until the transmitter is empty.
34265 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34266
34267 if (debug_level >= DEBUG_LEVEL_INFO)
34268 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34269 - __FILE__,__LINE__,tty->driver->name, port->count);
34270 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
34271
34272 /* If port is closing, signal caller to try again */
34273 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34274 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34275 goto cleanup;
34276 }
34277 spin_lock(&port->lock);
34278 - port->count++;
34279 + atomic_inc(&port->count);
34280 spin_unlock(&port->lock);
34281 spin_unlock_irqrestore(&info->netlock, flags);
34282
34283 - if (port->count == 1) {
34284 + if (atomic_read(&port->count) == 1) {
34285 /* 1st open on this device, init hardware */
34286 retval = startup(info, tty);
34287 if (retval < 0)
34288 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34289 unsigned short new_crctype;
34290
34291 /* return error if TTY interface open */
34292 - if (info->port.count)
34293 + if (atomic_read(&info->port.count))
34294 return -EBUSY;
34295
34296 switch (encoding)
34297 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
34298
34299 /* arbitrate between network and tty opens */
34300 spin_lock_irqsave(&info->netlock, flags);
34301 - if (info->port.count != 0 || info->netcount != 0) {
34302 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34303 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34304 spin_unlock_irqrestore(&info->netlock, flags);
34305 return -EBUSY;
34306 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34307 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
34308
34309 /* return error if TTY interface open */
34310 - if (info->port.count)
34311 + if (atomic_read(&info->port.count))
34312 return -EBUSY;
34313
34314 if (cmd != SIOCWANDEV)
34315 diff --git a/drivers/char/random.c b/drivers/char/random.c
34316 index 57d4b15..253207b 100644
34317 --- a/drivers/char/random.c
34318 +++ b/drivers/char/random.c
34319 @@ -272,8 +272,13 @@
34320 /*
34321 * Configuration information
34322 */
34323 +#ifdef CONFIG_GRKERNSEC_RANDNET
34324 +#define INPUT_POOL_WORDS 512
34325 +#define OUTPUT_POOL_WORDS 128
34326 +#else
34327 #define INPUT_POOL_WORDS 128
34328 #define OUTPUT_POOL_WORDS 32
34329 +#endif
34330 #define SEC_XFER_SIZE 512
34331 #define EXTRACT_SIZE 10
34332
34333 @@ -313,10 +318,17 @@ static struct poolinfo {
34334 int poolwords;
34335 int tap1, tap2, tap3, tap4, tap5;
34336 } poolinfo_table[] = {
34337 +#ifdef CONFIG_GRKERNSEC_RANDNET
34338 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34339 + { 512, 411, 308, 208, 104, 1 },
34340 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34341 + { 128, 103, 76, 51, 25, 1 },
34342 +#else
34343 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34344 { 128, 103, 76, 51, 25, 1 },
34345 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34346 { 32, 26, 20, 14, 7, 1 },
34347 +#endif
34348 #if 0
34349 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34350 { 2048, 1638, 1231, 819, 411, 1 },
34351 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34352 input_rotate += i ? 7 : 14;
34353 }
34354
34355 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34356 - ACCESS_ONCE(r->add_ptr) = i;
34357 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34358 + ACCESS_ONCE_RW(r->add_ptr) = i;
34359 smp_wmb();
34360
34361 if (out)
34362 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34363
34364 extract_buf(r, tmp);
34365 i = min_t(int, nbytes, EXTRACT_SIZE);
34366 - if (copy_to_user(buf, tmp, i)) {
34367 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34368 ret = -EFAULT;
34369 break;
34370 }
34371 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34372 #include <linux/sysctl.h>
34373
34374 static int min_read_thresh = 8, min_write_thresh;
34375 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34376 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34377 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34378 static char sysctl_bootid[16];
34379
34380 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
34381 static int proc_do_uuid(ctl_table *table, int write,
34382 void __user *buffer, size_t *lenp, loff_t *ppos)
34383 {
34384 - ctl_table fake_table;
34385 + ctl_table_no_const fake_table;
34386 unsigned char buf[64], tmp_uuid[16], *uuid;
34387
34388 uuid = table->data;
34389 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34390 index d780295..b29f3a8 100644
34391 --- a/drivers/char/sonypi.c
34392 +++ b/drivers/char/sonypi.c
34393 @@ -54,6 +54,7 @@
34394
34395 #include <asm/uaccess.h>
34396 #include <asm/io.h>
34397 +#include <asm/local.h>
34398
34399 #include <linux/sonypi.h>
34400
34401 @@ -490,7 +491,7 @@ static struct sonypi_device {
34402 spinlock_t fifo_lock;
34403 wait_queue_head_t fifo_proc_list;
34404 struct fasync_struct *fifo_async;
34405 - int open_count;
34406 + local_t open_count;
34407 int model;
34408 struct input_dev *input_jog_dev;
34409 struct input_dev *input_key_dev;
34410 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34411 static int sonypi_misc_release(struct inode *inode, struct file *file)
34412 {
34413 mutex_lock(&sonypi_device.lock);
34414 - sonypi_device.open_count--;
34415 + local_dec(&sonypi_device.open_count);
34416 mutex_unlock(&sonypi_device.lock);
34417 return 0;
34418 }
34419 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34420 {
34421 mutex_lock(&sonypi_device.lock);
34422 /* Flush input queue on first open */
34423 - if (!sonypi_device.open_count)
34424 + if (!local_read(&sonypi_device.open_count))
34425 kfifo_reset(&sonypi_device.fifo);
34426 - sonypi_device.open_count++;
34427 + local_inc(&sonypi_device.open_count);
34428 mutex_unlock(&sonypi_device.lock);
34429
34430 return 0;
34431 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
34432 index 93211df..c7805f7 100644
34433 --- a/drivers/char/tpm/tpm.c
34434 +++ b/drivers/char/tpm/tpm.c
34435 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
34436 chip->vendor.req_complete_val)
34437 goto out_recv;
34438
34439 - if ((status == chip->vendor.req_canceled)) {
34440 + if (status == chip->vendor.req_canceled) {
34441 dev_err(chip->dev, "Operation Canceled\n");
34442 rc = -ECANCELED;
34443 goto out;
34444 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34445 index 56051d0..11cf3b7 100644
34446 --- a/drivers/char/tpm/tpm_acpi.c
34447 +++ b/drivers/char/tpm/tpm_acpi.c
34448 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34449 virt = acpi_os_map_memory(start, len);
34450 if (!virt) {
34451 kfree(log->bios_event_log);
34452 + log->bios_event_log = NULL;
34453 printk("%s: ERROR - Unable to map memory\n", __func__);
34454 return -EIO;
34455 }
34456
34457 - memcpy_fromio(log->bios_event_log, virt, len);
34458 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34459
34460 acpi_os_unmap_memory(virt, len);
34461 return 0;
34462 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34463 index 84ddc55..1d32f1e 100644
34464 --- a/drivers/char/tpm/tpm_eventlog.c
34465 +++ b/drivers/char/tpm/tpm_eventlog.c
34466 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34467 event = addr;
34468
34469 if ((event->event_type == 0 && event->event_size == 0) ||
34470 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34471 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34472 return NULL;
34473
34474 return addr;
34475 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34476 return NULL;
34477
34478 if ((event->event_type == 0 && event->event_size == 0) ||
34479 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34480 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34481 return NULL;
34482
34483 (*pos)++;
34484 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34485 int i;
34486
34487 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34488 - seq_putc(m, data[i]);
34489 + if (!seq_putc(m, data[i]))
34490 + return -EFAULT;
34491
34492 return 0;
34493 }
34494 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34495 index a4b7aa0..2faa0bc 100644
34496 --- a/drivers/char/virtio_console.c
34497 +++ b/drivers/char/virtio_console.c
34498 @@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34499 if (to_user) {
34500 ssize_t ret;
34501
34502 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34503 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34504 if (ret)
34505 return -EFAULT;
34506 } else {
34507 @@ -784,7 +784,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34508 if (!port_has_data(port) && !port->host_connected)
34509 return 0;
34510
34511 - return fill_readbuf(port, ubuf, count, true);
34512 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34513 }
34514
34515 static int wait_port_writable(struct port *port, bool nonblock)
34516 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
34517 index 8ae1a61..9c00613 100644
34518 --- a/drivers/clocksource/arm_generic.c
34519 +++ b/drivers/clocksource/arm_generic.c
34520 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34521 return NOTIFY_OK;
34522 }
34523
34524 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34525 +static struct notifier_block arch_timer_cpu_nb = {
34526 .notifier_call = arch_timer_cpu_notify,
34527 };
34528
34529 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34530 index 7b0d49d..134fac9 100644
34531 --- a/drivers/cpufreq/acpi-cpufreq.c
34532 +++ b/drivers/cpufreq/acpi-cpufreq.c
34533 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34534 return sprintf(buf, "%u\n", boost_enabled);
34535 }
34536
34537 -static struct global_attr global_boost = __ATTR(boost, 0644,
34538 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34539 show_global_boost,
34540 store_global_boost);
34541
34542 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34543 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34544 per_cpu(acfreq_data, cpu) = data;
34545
34546 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34547 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34548 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34549 + pax_open_kernel();
34550 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34551 + pax_close_kernel();
34552 + }
34553
34554 result = acpi_processor_register_performance(data->acpi_data, cpu);
34555 if (result)
34556 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34557 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34558 break;
34559 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34560 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34561 + pax_open_kernel();
34562 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34563 + pax_close_kernel();
34564 policy->cur = get_cur_freq_on_cpu(cpu);
34565 break;
34566 default:
34567 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34568 acpi_processor_notify_smm(THIS_MODULE);
34569
34570 /* Check for APERF/MPERF support in hardware */
34571 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34572 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34573 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34574 + pax_open_kernel();
34575 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34576 + pax_close_kernel();
34577 + }
34578
34579 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34580 for (i = 0; i < perf->state_count; i++)
34581 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34582 index 1f93dbd..305cef1 100644
34583 --- a/drivers/cpufreq/cpufreq.c
34584 +++ b/drivers/cpufreq/cpufreq.c
34585 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34586 return NOTIFY_OK;
34587 }
34588
34589 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34590 +static struct notifier_block cpufreq_cpu_notifier = {
34591 .notifier_call = cpufreq_cpu_callback,
34592 };
34593
34594 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34595
34596 pr_debug("trying to register driver %s\n", driver_data->name);
34597
34598 - if (driver_data->setpolicy)
34599 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34600 + if (driver_data->setpolicy) {
34601 + pax_open_kernel();
34602 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34603 + pax_close_kernel();
34604 + }
34605
34606 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34607 if (cpufreq_driver) {
34608 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34609 index 6c5f1d3..c7e2f35e 100644
34610 --- a/drivers/cpufreq/cpufreq_governor.c
34611 +++ b/drivers/cpufreq/cpufreq_governor.c
34612 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34613 * governor, thus we are bound to jiffes/HZ
34614 */
34615 if (dbs_data->governor == GOV_CONSERVATIVE) {
34616 - struct cs_ops *ops = dbs_data->gov_ops;
34617 + const struct cs_ops *ops = dbs_data->gov_ops;
34618
34619 cpufreq_register_notifier(ops->notifier_block,
34620 CPUFREQ_TRANSITION_NOTIFIER);
34621 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34622 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34623 jiffies_to_usecs(10);
34624 } else {
34625 - struct od_ops *ops = dbs_data->gov_ops;
34626 + const struct od_ops *ops = dbs_data->gov_ops;
34627
34628 od_tuners->io_is_busy = ops->io_busy();
34629 }
34630 @@ -268,7 +268,7 @@ second_time:
34631 cs_dbs_info->enable = 1;
34632 cs_dbs_info->requested_freq = policy->cur;
34633 } else {
34634 - struct od_ops *ops = dbs_data->gov_ops;
34635 + const struct od_ops *ops = dbs_data->gov_ops;
34636 od_dbs_info->rate_mult = 1;
34637 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34638 ops->powersave_bias_init_cpu(cpu);
34639 @@ -289,7 +289,7 @@ second_time:
34640 mutex_destroy(&cpu_cdbs->timer_mutex);
34641 dbs_data->enable--;
34642 if (!dbs_data->enable) {
34643 - struct cs_ops *ops = dbs_data->gov_ops;
34644 + const struct cs_ops *ops = dbs_data->gov_ops;
34645
34646 sysfs_remove_group(cpufreq_global_kobject,
34647 dbs_data->attr_group);
34648 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34649 index f661654..6c8e638 100644
34650 --- a/drivers/cpufreq/cpufreq_governor.h
34651 +++ b/drivers/cpufreq/cpufreq_governor.h
34652 @@ -142,7 +142,7 @@ struct dbs_data {
34653 void (*gov_check_cpu)(int cpu, unsigned int load);
34654
34655 /* Governor specific ops, see below */
34656 - void *gov_ops;
34657 + const void *gov_ops;
34658 };
34659
34660 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34661 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34662 index 9d7732b..0b1a793 100644
34663 --- a/drivers/cpufreq/cpufreq_stats.c
34664 +++ b/drivers/cpufreq/cpufreq_stats.c
34665 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34666 }
34667
34668 /* priority=1 so this will get called before cpufreq_remove_dev */
34669 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34670 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34671 .notifier_call = cpufreq_stat_cpu_callback,
34672 .priority = 1,
34673 };
34674 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34675 index 827629c9..0bc6a03 100644
34676 --- a/drivers/cpufreq/p4-clockmod.c
34677 +++ b/drivers/cpufreq/p4-clockmod.c
34678 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34679 case 0x0F: /* Core Duo */
34680 case 0x16: /* Celeron Core */
34681 case 0x1C: /* Atom */
34682 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34683 + pax_open_kernel();
34684 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34685 + pax_close_kernel();
34686 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34687 case 0x0D: /* Pentium M (Dothan) */
34688 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34689 + pax_open_kernel();
34690 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34691 + pax_close_kernel();
34692 /* fall through */
34693 case 0x09: /* Pentium M (Banias) */
34694 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34695 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34696
34697 /* on P-4s, the TSC runs with constant frequency independent whether
34698 * throttling is active or not. */
34699 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34700 + pax_open_kernel();
34701 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34702 + pax_close_kernel();
34703
34704 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34705 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34706 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34707 index 3a953d5..f5993f6 100644
34708 --- a/drivers/cpufreq/speedstep-centrino.c
34709 +++ b/drivers/cpufreq/speedstep-centrino.c
34710 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34711 !cpu_has(cpu, X86_FEATURE_EST))
34712 return -ENODEV;
34713
34714 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34715 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34716 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34717 + pax_open_kernel();
34718 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34719 + pax_close_kernel();
34720 + }
34721
34722 if (policy->cpu != 0)
34723 return -ENODEV;
34724 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34725 index e1f6860..f8de20b 100644
34726 --- a/drivers/cpuidle/cpuidle.c
34727 +++ b/drivers/cpuidle/cpuidle.c
34728 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34729
34730 static void poll_idle_init(struct cpuidle_driver *drv)
34731 {
34732 - struct cpuidle_state *state = &drv->states[0];
34733 + cpuidle_state_no_const *state = &drv->states[0];
34734
34735 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34736 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34737 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34738 index ea2f8e7..70ac501 100644
34739 --- a/drivers/cpuidle/governor.c
34740 +++ b/drivers/cpuidle/governor.c
34741 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34742 mutex_lock(&cpuidle_lock);
34743 if (__cpuidle_find_governor(gov->name) == NULL) {
34744 ret = 0;
34745 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34746 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34747 if (!cpuidle_curr_governor ||
34748 cpuidle_curr_governor->rating < gov->rating)
34749 cpuidle_switch_governor(gov);
34750 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34751 new_gov = cpuidle_replace_governor(gov->rating);
34752 cpuidle_switch_governor(new_gov);
34753 }
34754 - list_del(&gov->governor_list);
34755 + pax_list_del((struct list_head *)&gov->governor_list);
34756 mutex_unlock(&cpuidle_lock);
34757 }
34758
34759 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34760 index 428754a..8bdf9cc 100644
34761 --- a/drivers/cpuidle/sysfs.c
34762 +++ b/drivers/cpuidle/sysfs.c
34763 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34764 NULL
34765 };
34766
34767 -static struct attribute_group cpuidle_attr_group = {
34768 +static attribute_group_no_const cpuidle_attr_group = {
34769 .attrs = cpuidle_default_attrs,
34770 .name = "cpuidle",
34771 };
34772 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34773 index 3b36797..289c16a 100644
34774 --- a/drivers/devfreq/devfreq.c
34775 +++ b/drivers/devfreq/devfreq.c
34776 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34777 goto err_out;
34778 }
34779
34780 - list_add(&governor->node, &devfreq_governor_list);
34781 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34782
34783 list_for_each_entry(devfreq, &devfreq_list, node) {
34784 int ret = 0;
34785 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34786 }
34787 }
34788
34789 - list_del(&governor->node);
34790 + pax_list_del((struct list_head *)&governor->node);
34791 err_out:
34792 mutex_unlock(&devfreq_list_lock);
34793
34794 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34795 index b70709b..1d8d02a 100644
34796 --- a/drivers/dma/sh/shdma.c
34797 +++ b/drivers/dma/sh/shdma.c
34798 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34799 return ret;
34800 }
34801
34802 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34803 +static struct notifier_block sh_dmae_nmi_notifier = {
34804 .notifier_call = sh_dmae_nmi_handler,
34805
34806 /* Run before NMI debug handler and KGDB */
34807 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34808 index 0ca1ca7..6e6f454 100644
34809 --- a/drivers/edac/edac_mc_sysfs.c
34810 +++ b/drivers/edac/edac_mc_sysfs.c
34811 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34812 struct dev_ch_attribute {
34813 struct device_attribute attr;
34814 int channel;
34815 -};
34816 +} __do_const;
34817
34818 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34819 struct dev_ch_attribute dev_attr_legacy_##_name = \
34820 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34821 index 0056c4d..23b54d9 100644
34822 --- a/drivers/edac/edac_pci_sysfs.c
34823 +++ b/drivers/edac/edac_pci_sysfs.c
34824 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34825 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34826 static int edac_pci_poll_msec = 1000; /* one second workq period */
34827
34828 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34829 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34830 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34831 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34832
34833 static struct kobject *edac_pci_top_main_kobj;
34834 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34835 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34836 void *value;
34837 ssize_t(*show) (void *, char *);
34838 ssize_t(*store) (void *, const char *, size_t);
34839 -};
34840 +} __do_const;
34841
34842 /* Set of show/store abstract level functions for PCI Parity object */
34843 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34844 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34845 edac_printk(KERN_CRIT, EDAC_PCI,
34846 "Signaled System Error on %s\n",
34847 pci_name(dev));
34848 - atomic_inc(&pci_nonparity_count);
34849 + atomic_inc_unchecked(&pci_nonparity_count);
34850 }
34851
34852 if (status & (PCI_STATUS_PARITY)) {
34853 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34854 "Master Data Parity Error on %s\n",
34855 pci_name(dev));
34856
34857 - atomic_inc(&pci_parity_count);
34858 + atomic_inc_unchecked(&pci_parity_count);
34859 }
34860
34861 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34862 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34863 "Detected Parity Error on %s\n",
34864 pci_name(dev));
34865
34866 - atomic_inc(&pci_parity_count);
34867 + atomic_inc_unchecked(&pci_parity_count);
34868 }
34869 }
34870
34871 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34872 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34873 "Signaled System Error on %s\n",
34874 pci_name(dev));
34875 - atomic_inc(&pci_nonparity_count);
34876 + atomic_inc_unchecked(&pci_nonparity_count);
34877 }
34878
34879 if (status & (PCI_STATUS_PARITY)) {
34880 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34881 "Master Data Parity Error on "
34882 "%s\n", pci_name(dev));
34883
34884 - atomic_inc(&pci_parity_count);
34885 + atomic_inc_unchecked(&pci_parity_count);
34886 }
34887
34888 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34889 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34890 "Detected Parity Error on %s\n",
34891 pci_name(dev));
34892
34893 - atomic_inc(&pci_parity_count);
34894 + atomic_inc_unchecked(&pci_parity_count);
34895 }
34896 }
34897 }
34898 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34899 if (!check_pci_errors)
34900 return;
34901
34902 - before_count = atomic_read(&pci_parity_count);
34903 + before_count = atomic_read_unchecked(&pci_parity_count);
34904
34905 /* scan all PCI devices looking for a Parity Error on devices and
34906 * bridges.
34907 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34908 /* Only if operator has selected panic on PCI Error */
34909 if (edac_pci_get_panic_on_pe()) {
34910 /* If the count is different 'after' from 'before' */
34911 - if (before_count != atomic_read(&pci_parity_count))
34912 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34913 panic("EDAC: PCI Parity Error");
34914 }
34915 }
34916 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34917 index 6796799..99e8377 100644
34918 --- a/drivers/edac/mce_amd.h
34919 +++ b/drivers/edac/mce_amd.h
34920 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34921 struct amd_decoder_ops {
34922 bool (*mc0_mce)(u16, u8);
34923 bool (*mc1_mce)(u16, u8);
34924 -};
34925 +} __no_const;
34926
34927 void amd_report_gart_errors(bool);
34928 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34929 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34930 index 57ea7f4..789e3c3 100644
34931 --- a/drivers/firewire/core-card.c
34932 +++ b/drivers/firewire/core-card.c
34933 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34934
34935 void fw_core_remove_card(struct fw_card *card)
34936 {
34937 - struct fw_card_driver dummy_driver = dummy_driver_template;
34938 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34939
34940 card->driver->update_phy_reg(card, 4,
34941 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34942 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34943 index f8d2287..5aaf4db 100644
34944 --- a/drivers/firewire/core-cdev.c
34945 +++ b/drivers/firewire/core-cdev.c
34946 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34947 int ret;
34948
34949 if ((request->channels == 0 && request->bandwidth == 0) ||
34950 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34951 - request->bandwidth < 0)
34952 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34953 return -EINVAL;
34954
34955 r = kmalloc(sizeof(*r), GFP_KERNEL);
34956 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34957 index af3e8aa..eb2f227 100644
34958 --- a/drivers/firewire/core-device.c
34959 +++ b/drivers/firewire/core-device.c
34960 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34961 struct config_rom_attribute {
34962 struct device_attribute attr;
34963 u32 key;
34964 -};
34965 +} __do_const;
34966
34967 static ssize_t show_immediate(struct device *dev,
34968 struct device_attribute *dattr, char *buf)
34969 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34970 index 28a94c7..58da63a 100644
34971 --- a/drivers/firewire/core-transaction.c
34972 +++ b/drivers/firewire/core-transaction.c
34973 @@ -38,6 +38,7 @@
34974 #include <linux/timer.h>
34975 #include <linux/types.h>
34976 #include <linux/workqueue.h>
34977 +#include <linux/sched.h>
34978
34979 #include <asm/byteorder.h>
34980
34981 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34982 index 515a42c..5ecf3ba 100644
34983 --- a/drivers/firewire/core.h
34984 +++ b/drivers/firewire/core.h
34985 @@ -111,6 +111,7 @@ struct fw_card_driver {
34986
34987 int (*stop_iso)(struct fw_iso_context *ctx);
34988 };
34989 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34990
34991 void fw_card_initialize(struct fw_card *card,
34992 const struct fw_card_driver *driver, struct device *device);
34993 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34994 index 94a58a0..f5eba42 100644
34995 --- a/drivers/firmware/dmi-id.c
34996 +++ b/drivers/firmware/dmi-id.c
34997 @@ -16,7 +16,7 @@
34998 struct dmi_device_attribute{
34999 struct device_attribute dev_attr;
35000 int field;
35001 -};
35002 +} __do_const;
35003 #define to_dmi_dev_attr(_dev_attr) \
35004 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35005
35006 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35007 index 4cd392d..4b629e1 100644
35008 --- a/drivers/firmware/dmi_scan.c
35009 +++ b/drivers/firmware/dmi_scan.c
35010 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
35011 }
35012 }
35013 else {
35014 - /*
35015 - * no iounmap() for that ioremap(); it would be a no-op, but
35016 - * it's so early in setup that sucker gets confused into doing
35017 - * what it shouldn't if we actually call it.
35018 - */
35019 p = dmi_ioremap(0xF0000, 0x10000);
35020 if (p == NULL)
35021 goto error;
35022 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35023 if (buf == NULL)
35024 return -1;
35025
35026 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35027 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35028
35029 iounmap(buf);
35030 return 0;
35031 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
35032 index b07cb37..2a51037 100644
35033 --- a/drivers/firmware/efivars.c
35034 +++ b/drivers/firmware/efivars.c
35035 @@ -138,7 +138,7 @@ struct efivar_attribute {
35036 };
35037
35038 static struct efivars __efivars;
35039 -static struct efivar_operations ops;
35040 +static efivar_operations_no_const ops __read_only;
35041
35042 #define PSTORE_EFI_ATTRIBUTES \
35043 (EFI_VARIABLE_NON_VOLATILE | \
35044 @@ -1834,7 +1834,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
35045 static int
35046 create_efivars_bin_attributes(struct efivars *efivars)
35047 {
35048 - struct bin_attribute *attr;
35049 + bin_attribute_no_const *attr;
35050 int error;
35051
35052 /* new_var */
35053 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35054 index 2a90ba6..07f3733 100644
35055 --- a/drivers/firmware/google/memconsole.c
35056 +++ b/drivers/firmware/google/memconsole.c
35057 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35058 if (!found_memconsole())
35059 return -ENODEV;
35060
35061 - memconsole_bin_attr.size = memconsole_length;
35062 + pax_open_kernel();
35063 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35064 + pax_close_kernel();
35065
35066 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35067
35068 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35069 index 6f2306d..af9476a 100644
35070 --- a/drivers/gpio/gpio-ich.c
35071 +++ b/drivers/gpio/gpio-ich.c
35072 @@ -69,7 +69,7 @@ struct ichx_desc {
35073 /* Some chipsets have quirks, let these use their own request/get */
35074 int (*request)(struct gpio_chip *chip, unsigned offset);
35075 int (*get)(struct gpio_chip *chip, unsigned offset);
35076 -};
35077 +} __do_const;
35078
35079 static struct {
35080 spinlock_t lock;
35081 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35082 index 9902732..64b62dd 100644
35083 --- a/drivers/gpio/gpio-vr41xx.c
35084 +++ b/drivers/gpio/gpio-vr41xx.c
35085 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35086 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35087 maskl, pendl, maskh, pendh);
35088
35089 - atomic_inc(&irq_err_count);
35090 + atomic_inc_unchecked(&irq_err_count);
35091
35092 return -EINVAL;
35093 }
35094 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35095 index 7b2d378..cc947ea 100644
35096 --- a/drivers/gpu/drm/drm_crtc_helper.c
35097 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35098 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35099 struct drm_crtc *tmp;
35100 int crtc_mask = 1;
35101
35102 - WARN(!crtc, "checking null crtc?\n");
35103 + BUG_ON(!crtc);
35104
35105 dev = crtc->dev;
35106
35107 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35108 index be174ca..7f38143 100644
35109 --- a/drivers/gpu/drm/drm_drv.c
35110 +++ b/drivers/gpu/drm/drm_drv.c
35111 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
35112 /**
35113 * Copy and IOCTL return string to user space
35114 */
35115 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35116 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35117 {
35118 int len;
35119
35120 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
35121 struct drm_file *file_priv = filp->private_data;
35122 struct drm_device *dev;
35123 struct drm_ioctl_desc *ioctl;
35124 - drm_ioctl_t *func;
35125 + drm_ioctl_no_const_t func;
35126 unsigned int nr = DRM_IOCTL_NR(cmd);
35127 int retcode = -EINVAL;
35128 char stack_kdata[128];
35129 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
35130 return -ENODEV;
35131
35132 atomic_inc(&dev->ioctl_count);
35133 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35134 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35135 ++file_priv->ioctl_count;
35136
35137 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
35138 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35139 index 32d7775..c8be5e1 100644
35140 --- a/drivers/gpu/drm/drm_fops.c
35141 +++ b/drivers/gpu/drm/drm_fops.c
35142 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35143 }
35144
35145 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35146 - atomic_set(&dev->counts[i], 0);
35147 + atomic_set_unchecked(&dev->counts[i], 0);
35148
35149 dev->sigdata.lock = NULL;
35150
35151 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35152 if (drm_device_is_unplugged(dev))
35153 return -ENODEV;
35154
35155 - if (!dev->open_count++)
35156 + if (local_inc_return(&dev->open_count) == 1)
35157 need_setup = 1;
35158 mutex_lock(&dev->struct_mutex);
35159 old_imapping = inode->i_mapping;
35160 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35161 retcode = drm_open_helper(inode, filp, dev);
35162 if (retcode)
35163 goto err_undo;
35164 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35165 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35166 if (need_setup) {
35167 retcode = drm_setup(dev);
35168 if (retcode)
35169 @@ -166,7 +166,7 @@ err_undo:
35170 iput(container_of(dev->dev_mapping, struct inode, i_data));
35171 dev->dev_mapping = old_mapping;
35172 mutex_unlock(&dev->struct_mutex);
35173 - dev->open_count--;
35174 + local_dec(&dev->open_count);
35175 return retcode;
35176 }
35177 EXPORT_SYMBOL(drm_open);
35178 @@ -440,7 +440,7 @@ int drm_release(struct inode *inode, struct file *filp)
35179
35180 mutex_lock(&drm_global_mutex);
35181
35182 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35183 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35184
35185 if (dev->driver->preclose)
35186 dev->driver->preclose(dev, file_priv);
35187 @@ -449,10 +449,10 @@ int drm_release(struct inode *inode, struct file *filp)
35188 * Begin inline drm_release
35189 */
35190
35191 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35192 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35193 task_pid_nr(current),
35194 (long)old_encode_dev(file_priv->minor->device),
35195 - dev->open_count);
35196 + local_read(&dev->open_count));
35197
35198 /* Release any auth tokens that might point to this file_priv,
35199 (do that under the drm_global_mutex) */
35200 @@ -549,8 +549,8 @@ int drm_release(struct inode *inode, struct file *filp)
35201 * End inline drm_release
35202 */
35203
35204 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35205 - if (!--dev->open_count) {
35206 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35207 + if (local_dec_and_test(&dev->open_count)) {
35208 if (atomic_read(&dev->ioctl_count)) {
35209 DRM_ERROR("Device busy: %d\n",
35210 atomic_read(&dev->ioctl_count));
35211 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35212 index f731116..629842c 100644
35213 --- a/drivers/gpu/drm/drm_global.c
35214 +++ b/drivers/gpu/drm/drm_global.c
35215 @@ -36,7 +36,7 @@
35216 struct drm_global_item {
35217 struct mutex mutex;
35218 void *object;
35219 - int refcount;
35220 + atomic_t refcount;
35221 };
35222
35223 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35224 @@ -49,7 +49,7 @@ void drm_global_init(void)
35225 struct drm_global_item *item = &glob[i];
35226 mutex_init(&item->mutex);
35227 item->object = NULL;
35228 - item->refcount = 0;
35229 + atomic_set(&item->refcount, 0);
35230 }
35231 }
35232
35233 @@ -59,7 +59,7 @@ void drm_global_release(void)
35234 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35235 struct drm_global_item *item = &glob[i];
35236 BUG_ON(item->object != NULL);
35237 - BUG_ON(item->refcount != 0);
35238 + BUG_ON(atomic_read(&item->refcount) != 0);
35239 }
35240 }
35241
35242 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35243 void *object;
35244
35245 mutex_lock(&item->mutex);
35246 - if (item->refcount == 0) {
35247 + if (atomic_read(&item->refcount) == 0) {
35248 item->object = kzalloc(ref->size, GFP_KERNEL);
35249 if (unlikely(item->object == NULL)) {
35250 ret = -ENOMEM;
35251 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35252 goto out_err;
35253
35254 }
35255 - ++item->refcount;
35256 + atomic_inc(&item->refcount);
35257 ref->object = item->object;
35258 object = item->object;
35259 mutex_unlock(&item->mutex);
35260 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35261 struct drm_global_item *item = &glob[ref->global_type];
35262
35263 mutex_lock(&item->mutex);
35264 - BUG_ON(item->refcount == 0);
35265 + BUG_ON(atomic_read(&item->refcount) == 0);
35266 BUG_ON(ref->object != item->object);
35267 - if (--item->refcount == 0) {
35268 + if (atomic_dec_and_test(&item->refcount)) {
35269 ref->release(ref);
35270 item->object = NULL;
35271 }
35272 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35273 index d4b20ce..77a8d41 100644
35274 --- a/drivers/gpu/drm/drm_info.c
35275 +++ b/drivers/gpu/drm/drm_info.c
35276 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35277 struct drm_local_map *map;
35278 struct drm_map_list *r_list;
35279
35280 - /* Hardcoded from _DRM_FRAME_BUFFER,
35281 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35282 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35283 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35284 + static const char * const types[] = {
35285 + [_DRM_FRAME_BUFFER] = "FB",
35286 + [_DRM_REGISTERS] = "REG",
35287 + [_DRM_SHM] = "SHM",
35288 + [_DRM_AGP] = "AGP",
35289 + [_DRM_SCATTER_GATHER] = "SG",
35290 + [_DRM_CONSISTENT] = "PCI",
35291 + [_DRM_GEM] = "GEM" };
35292 const char *type;
35293 int i;
35294
35295 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35296 map = r_list->map;
35297 if (!map)
35298 continue;
35299 - if (map->type < 0 || map->type > 5)
35300 + if (map->type >= ARRAY_SIZE(types))
35301 type = "??";
35302 else
35303 type = types[map->type];
35304 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35305 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35306 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35307 vma->vm_flags & VM_IO ? 'i' : '-',
35308 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35309 + 0);
35310 +#else
35311 vma->vm_pgoff);
35312 +#endif
35313
35314 #if defined(__i386__)
35315 pgprot = pgprot_val(vma->vm_page_prot);
35316 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35317 index 2f4c434..dd12cd2 100644
35318 --- a/drivers/gpu/drm/drm_ioc32.c
35319 +++ b/drivers/gpu/drm/drm_ioc32.c
35320 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35321 request = compat_alloc_user_space(nbytes);
35322 if (!access_ok(VERIFY_WRITE, request, nbytes))
35323 return -EFAULT;
35324 - list = (struct drm_buf_desc *) (request + 1);
35325 + list = (struct drm_buf_desc __user *) (request + 1);
35326
35327 if (__put_user(count, &request->count)
35328 || __put_user(list, &request->list))
35329 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35330 request = compat_alloc_user_space(nbytes);
35331 if (!access_ok(VERIFY_WRITE, request, nbytes))
35332 return -EFAULT;
35333 - list = (struct drm_buf_pub *) (request + 1);
35334 + list = (struct drm_buf_pub __user *) (request + 1);
35335
35336 if (__put_user(count, &request->count)
35337 || __put_user(list, &request->list))
35338 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35339 return 0;
35340 }
35341
35342 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35343 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35344 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35345 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35346 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35347 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35348 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35349 {
35350 unsigned int nr = DRM_IOCTL_NR(cmd);
35351 - drm_ioctl_compat_t *fn;
35352 int ret;
35353
35354 /* Assume that ioctls without an explicit compat routine will just
35355 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35356 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35357 return drm_ioctl(filp, cmd, arg);
35358
35359 - fn = drm_compat_ioctls[nr];
35360 -
35361 - if (fn != NULL)
35362 - ret = (*fn) (filp, cmd, arg);
35363 + if (drm_compat_ioctls[nr] != NULL)
35364 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35365 else
35366 ret = drm_ioctl(filp, cmd, arg);
35367
35368 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35369 index e77bd8b..1571b85 100644
35370 --- a/drivers/gpu/drm/drm_ioctl.c
35371 +++ b/drivers/gpu/drm/drm_ioctl.c
35372 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35373 stats->data[i].value =
35374 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35375 else
35376 - stats->data[i].value = atomic_read(&dev->counts[i]);
35377 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35378 stats->data[i].type = dev->types[i];
35379 }
35380
35381 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35382 index d752c96..fe08455 100644
35383 --- a/drivers/gpu/drm/drm_lock.c
35384 +++ b/drivers/gpu/drm/drm_lock.c
35385 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35386 if (drm_lock_take(&master->lock, lock->context)) {
35387 master->lock.file_priv = file_priv;
35388 master->lock.lock_time = jiffies;
35389 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35390 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35391 break; /* Got lock */
35392 }
35393
35394 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35395 return -EINVAL;
35396 }
35397
35398 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35399 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35400
35401 if (drm_lock_free(&master->lock, lock->context)) {
35402 /* FIXME: Should really bail out here. */
35403 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35404 index 200e104..59facda 100644
35405 --- a/drivers/gpu/drm/drm_stub.c
35406 +++ b/drivers/gpu/drm/drm_stub.c
35407 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
35408
35409 drm_device_set_unplugged(dev);
35410
35411 - if (dev->open_count == 0) {
35412 + if (local_read(&dev->open_count) == 0) {
35413 drm_put_dev(dev);
35414 }
35415 mutex_unlock(&drm_global_mutex);
35416 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35417 index 004ecdf..db1f6e0 100644
35418 --- a/drivers/gpu/drm/i810/i810_dma.c
35419 +++ b/drivers/gpu/drm/i810/i810_dma.c
35420 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35421 dma->buflist[vertex->idx],
35422 vertex->discard, vertex->used);
35423
35424 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35425 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35426 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35427 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35428 sarea_priv->last_enqueue = dev_priv->counter - 1;
35429 sarea_priv->last_dispatch = (int)hw_status[5];
35430
35431 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35432 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35433 mc->last_render);
35434
35435 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35436 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35437 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35438 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35439 sarea_priv->last_enqueue = dev_priv->counter - 1;
35440 sarea_priv->last_dispatch = (int)hw_status[5];
35441
35442 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35443 index 6e0acad..93c8289 100644
35444 --- a/drivers/gpu/drm/i810/i810_drv.h
35445 +++ b/drivers/gpu/drm/i810/i810_drv.h
35446 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35447 int page_flipping;
35448
35449 wait_queue_head_t irq_queue;
35450 - atomic_t irq_received;
35451 - atomic_t irq_emitted;
35452 + atomic_unchecked_t irq_received;
35453 + atomic_unchecked_t irq_emitted;
35454
35455 int front_offset;
35456 } drm_i810_private_t;
35457 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35458 index 261efc8e..27af8a5 100644
35459 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35460 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35461 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35462 I915_READ(GTIMR));
35463 }
35464 seq_printf(m, "Interrupts received: %d\n",
35465 - atomic_read(&dev_priv->irq_received));
35466 + atomic_read_unchecked(&dev_priv->irq_received));
35467 for_each_ring(ring, dev_priv, i) {
35468 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35469 seq_printf(m,
35470 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35471 index 99daa89..84ebd44 100644
35472 --- a/drivers/gpu/drm/i915/i915_dma.c
35473 +++ b/drivers/gpu/drm/i915/i915_dma.c
35474 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35475 bool can_switch;
35476
35477 spin_lock(&dev->count_lock);
35478 - can_switch = (dev->open_count == 0);
35479 + can_switch = (local_read(&dev->open_count) == 0);
35480 spin_unlock(&dev->count_lock);
35481 return can_switch;
35482 }
35483 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35484 index 7339a4b..445aaba 100644
35485 --- a/drivers/gpu/drm/i915/i915_drv.h
35486 +++ b/drivers/gpu/drm/i915/i915_drv.h
35487 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
35488 drm_dma_handle_t *status_page_dmah;
35489 struct resource mch_res;
35490
35491 - atomic_t irq_received;
35492 + atomic_unchecked_t irq_received;
35493
35494 /* protects the irq masks */
35495 spinlock_t irq_lock;
35496 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
35497 * will be page flipped away on the next vblank. When it
35498 * reaches 0, dev_priv->pending_flip_queue will be woken up.
35499 */
35500 - atomic_t pending_flip;
35501 + atomic_unchecked_t pending_flip;
35502 };
35503 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
35504
35505 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35506 struct drm_i915_private *dev_priv, unsigned port);
35507 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35508 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35509 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35510 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35511 {
35512 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35513 }
35514 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35515 index ba8805a..39d5330 100644
35516 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35517 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35518 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
35519 i915_gem_clflush_object(obj);
35520
35521 if (obj->base.pending_write_domain)
35522 - flips |= atomic_read(&obj->pending_flip);
35523 + flips |= atomic_read_unchecked(&obj->pending_flip);
35524
35525 flush_domains |= obj->base.write_domain;
35526 }
35527 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35528
35529 static int
35530 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35531 - int count)
35532 + unsigned int count)
35533 {
35534 - int i;
35535 + unsigned int i;
35536 int relocs_total = 0;
35537 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35538
35539 @@ -1202,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35540 return -ENOMEM;
35541 }
35542 ret = copy_from_user(exec2_list,
35543 - (struct drm_i915_relocation_entry __user *)
35544 + (struct drm_i915_gem_exec_object2 __user *)
35545 (uintptr_t) args->buffers_ptr,
35546 sizeof(*exec2_list) * args->buffer_count);
35547 if (ret != 0) {
35548 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35549 index 3c59584..500f2e9 100644
35550 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35551 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35552 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35553 (unsigned long)request);
35554 }
35555
35556 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35557 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35558 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35559 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35560 [DRM_I915_GETPARAM] = compat_i915_getparam,
35561 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35562 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35563 {
35564 unsigned int nr = DRM_IOCTL_NR(cmd);
35565 - drm_ioctl_compat_t *fn = NULL;
35566 int ret;
35567
35568 if (nr < DRM_COMMAND_BASE)
35569 return drm_compat_ioctl(filp, cmd, arg);
35570
35571 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35572 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35573 -
35574 - if (fn != NULL)
35575 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35576 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35577 ret = (*fn) (filp, cmd, arg);
35578 - else
35579 + } else
35580 ret = drm_ioctl(filp, cmd, arg);
35581
35582 return ret;
35583 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35584 index fe84338..a863190 100644
35585 --- a/drivers/gpu/drm/i915/i915_irq.c
35586 +++ b/drivers/gpu/drm/i915/i915_irq.c
35587 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35588 u32 pipe_stats[I915_MAX_PIPES];
35589 bool blc_event;
35590
35591 - atomic_inc(&dev_priv->irq_received);
35592 + atomic_inc_unchecked(&dev_priv->irq_received);
35593
35594 while (true) {
35595 iir = I915_READ(VLV_IIR);
35596 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35597 irqreturn_t ret = IRQ_NONE;
35598 int i;
35599
35600 - atomic_inc(&dev_priv->irq_received);
35601 + atomic_inc_unchecked(&dev_priv->irq_received);
35602
35603 /* disable master interrupt before clearing iir */
35604 de_ier = I915_READ(DEIER);
35605 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35606 int ret = IRQ_NONE;
35607 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35608
35609 - atomic_inc(&dev_priv->irq_received);
35610 + atomic_inc_unchecked(&dev_priv->irq_received);
35611
35612 /* disable master interrupt before clearing iir */
35613 de_ier = I915_READ(DEIER);
35614 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35615 {
35616 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35617
35618 - atomic_set(&dev_priv->irq_received, 0);
35619 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35620
35621 I915_WRITE(HWSTAM, 0xeffe);
35622
35623 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35624 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35625 int pipe;
35626
35627 - atomic_set(&dev_priv->irq_received, 0);
35628 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35629
35630 /* VLV magic */
35631 I915_WRITE(VLV_IMR, 0);
35632 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35633 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35634 int pipe;
35635
35636 - atomic_set(&dev_priv->irq_received, 0);
35637 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35638
35639 for_each_pipe(pipe)
35640 I915_WRITE(PIPESTAT(pipe), 0);
35641 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35642 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35643 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35644
35645 - atomic_inc(&dev_priv->irq_received);
35646 + atomic_inc_unchecked(&dev_priv->irq_received);
35647
35648 iir = I915_READ16(IIR);
35649 if (iir == 0)
35650 @@ -2244,7 +2244,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35651 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35652 int pipe;
35653
35654 - atomic_set(&dev_priv->irq_received, 0);
35655 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35656
35657 if (I915_HAS_HOTPLUG(dev)) {
35658 I915_WRITE(PORT_HOTPLUG_EN, 0);
35659 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35660 };
35661 int pipe, ret = IRQ_NONE;
35662
35663 - atomic_inc(&dev_priv->irq_received);
35664 + atomic_inc_unchecked(&dev_priv->irq_received);
35665
35666 iir = I915_READ(IIR);
35667 do {
35668 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35669 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35670 int pipe;
35671
35672 - atomic_set(&dev_priv->irq_received, 0);
35673 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35674
35675 I915_WRITE(PORT_HOTPLUG_EN, 0);
35676 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35677 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35678 int irq_received;
35679 int ret = IRQ_NONE, pipe;
35680
35681 - atomic_inc(&dev_priv->irq_received);
35682 + atomic_inc_unchecked(&dev_priv->irq_received);
35683
35684 iir = I915_READ(IIR);
35685
35686 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35687 index d3f834a..0ad1b37 100644
35688 --- a/drivers/gpu/drm/i915/intel_display.c
35689 +++ b/drivers/gpu/drm/i915/intel_display.c
35690 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35691
35692 wait_event(dev_priv->pending_flip_queue,
35693 atomic_read(&dev_priv->mm.wedged) ||
35694 - atomic_read(&obj->pending_flip) == 0);
35695 + atomic_read_unchecked(&obj->pending_flip) == 0);
35696
35697 /* Big Hammer, we also need to ensure that any pending
35698 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35699 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35700
35701 obj = work->old_fb_obj;
35702
35703 - atomic_clear_mask(1 << intel_crtc->plane,
35704 - &obj->pending_flip.counter);
35705 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35706 wake_up(&dev_priv->pending_flip_queue);
35707
35708 queue_work(dev_priv->wq, &work->work);
35709 @@ -7486,7 +7485,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35710 /* Block clients from rendering to the new back buffer until
35711 * the flip occurs and the object is no longer visible.
35712 */
35713 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35714 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35715 atomic_inc(&intel_crtc->unpin_work_count);
35716
35717 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35718 @@ -7504,7 +7503,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35719 cleanup_pending:
35720 atomic_dec(&intel_crtc->unpin_work_count);
35721 crtc->fb = old_fb;
35722 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35723 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35724 drm_gem_object_unreference(&work->old_fb_obj->base);
35725 drm_gem_object_unreference(&obj->base);
35726 mutex_unlock(&dev->struct_mutex);
35727 @@ -8846,13 +8845,13 @@ struct intel_quirk {
35728 int subsystem_vendor;
35729 int subsystem_device;
35730 void (*hook)(struct drm_device *dev);
35731 -};
35732 +} __do_const;
35733
35734 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35735 struct intel_dmi_quirk {
35736 void (*hook)(struct drm_device *dev);
35737 const struct dmi_system_id (*dmi_id_list)[];
35738 -};
35739 +} __do_const;
35740
35741 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35742 {
35743 @@ -8860,18 +8859,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35744 return 1;
35745 }
35746
35747 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35748 + {
35749 + .callback = intel_dmi_reverse_brightness,
35750 + .ident = "NCR Corporation",
35751 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35752 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35753 + },
35754 + },
35755 + { } /* terminating entry */
35756 +};
35757 +
35758 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35759 {
35760 - .dmi_id_list = &(const struct dmi_system_id[]) {
35761 - {
35762 - .callback = intel_dmi_reverse_brightness,
35763 - .ident = "NCR Corporation",
35764 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35765 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35766 - },
35767 - },
35768 - { } /* terminating entry */
35769 - },
35770 + .dmi_id_list = &intel_dmi_quirks_table,
35771 .hook = quirk_invert_brightness,
35772 },
35773 };
35774 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35775 index 54558a0..2d97005 100644
35776 --- a/drivers/gpu/drm/mga/mga_drv.h
35777 +++ b/drivers/gpu/drm/mga/mga_drv.h
35778 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35779 u32 clear_cmd;
35780 u32 maccess;
35781
35782 - atomic_t vbl_received; /**< Number of vblanks received. */
35783 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35784 wait_queue_head_t fence_queue;
35785 - atomic_t last_fence_retired;
35786 + atomic_unchecked_t last_fence_retired;
35787 u32 next_fence_to_post;
35788
35789 unsigned int fb_cpp;
35790 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35791 index 709e90d..89a1c0d 100644
35792 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35793 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35794 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35795 return 0;
35796 }
35797
35798 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35799 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35800 [DRM_MGA_INIT] = compat_mga_init,
35801 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35802 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35803 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35804 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35805 {
35806 unsigned int nr = DRM_IOCTL_NR(cmd);
35807 - drm_ioctl_compat_t *fn = NULL;
35808 int ret;
35809
35810 if (nr < DRM_COMMAND_BASE)
35811 return drm_compat_ioctl(filp, cmd, arg);
35812
35813 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35814 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35815 -
35816 - if (fn != NULL)
35817 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35818 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35819 ret = (*fn) (filp, cmd, arg);
35820 - else
35821 + } else
35822 ret = drm_ioctl(filp, cmd, arg);
35823
35824 return ret;
35825 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35826 index 598c281..60d590e 100644
35827 --- a/drivers/gpu/drm/mga/mga_irq.c
35828 +++ b/drivers/gpu/drm/mga/mga_irq.c
35829 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35830 if (crtc != 0)
35831 return 0;
35832
35833 - return atomic_read(&dev_priv->vbl_received);
35834 + return atomic_read_unchecked(&dev_priv->vbl_received);
35835 }
35836
35837
35838 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35839 /* VBLANK interrupt */
35840 if (status & MGA_VLINEPEN) {
35841 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35842 - atomic_inc(&dev_priv->vbl_received);
35843 + atomic_inc_unchecked(&dev_priv->vbl_received);
35844 drm_handle_vblank(dev, 0);
35845 handled = 1;
35846 }
35847 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35848 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35849 MGA_WRITE(MGA_PRIMEND, prim_end);
35850
35851 - atomic_inc(&dev_priv->last_fence_retired);
35852 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35853 DRM_WAKEUP(&dev_priv->fence_queue);
35854 handled = 1;
35855 }
35856 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35857 * using fences.
35858 */
35859 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35860 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35861 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35862 - *sequence) <= (1 << 23)));
35863
35864 *sequence = cur_fence;
35865 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35866 index 865eddf..62c4cc3 100644
35867 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35868 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35869 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35870 struct bit_table {
35871 const char id;
35872 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35873 -};
35874 +} __no_const;
35875
35876 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35877
35878 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35879 index aa89eb9..d45d38b 100644
35880 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35881 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35882 @@ -80,7 +80,7 @@ struct nouveau_drm {
35883 struct drm_global_reference mem_global_ref;
35884 struct ttm_bo_global_ref bo_global_ref;
35885 struct ttm_bo_device bdev;
35886 - atomic_t validate_sequence;
35887 + atomic_unchecked_t validate_sequence;
35888 int (*move)(struct nouveau_channel *,
35889 struct ttm_buffer_object *,
35890 struct ttm_mem_reg *, struct ttm_mem_reg *);
35891 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35892 index cdb83ac..27f0a16 100644
35893 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35894 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35895 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35896 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35897 struct nouveau_channel *);
35898 u32 (*read)(struct nouveau_channel *);
35899 -};
35900 +} __no_const;
35901
35902 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35903
35904 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35905 index 8bf695c..9fbc90a 100644
35906 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35907 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35908 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35909 int trycnt = 0;
35910 int ret, i;
35911
35912 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35913 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35914 retry:
35915 if (++trycnt > 100000) {
35916 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35917 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35918 index 08214bc..9208577 100644
35919 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35920 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35921 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35922 unsigned long arg)
35923 {
35924 unsigned int nr = DRM_IOCTL_NR(cmd);
35925 - drm_ioctl_compat_t *fn = NULL;
35926 + drm_ioctl_compat_t fn = NULL;
35927 int ret;
35928
35929 if (nr < DRM_COMMAND_BASE)
35930 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35931 index 25d3495..d81aaf6 100644
35932 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35933 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35934 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35935 bool can_switch;
35936
35937 spin_lock(&dev->count_lock);
35938 - can_switch = (dev->open_count == 0);
35939 + can_switch = (local_read(&dev->open_count) == 0);
35940 spin_unlock(&dev->count_lock);
35941 return can_switch;
35942 }
35943 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35944 index d4660cf..70dbe65 100644
35945 --- a/drivers/gpu/drm/r128/r128_cce.c
35946 +++ b/drivers/gpu/drm/r128/r128_cce.c
35947 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35948
35949 /* GH: Simple idle check.
35950 */
35951 - atomic_set(&dev_priv->idle_count, 0);
35952 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35953
35954 /* We don't support anything other than bus-mastering ring mode,
35955 * but the ring can be in either AGP or PCI space for the ring
35956 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35957 index 930c71b..499aded 100644
35958 --- a/drivers/gpu/drm/r128/r128_drv.h
35959 +++ b/drivers/gpu/drm/r128/r128_drv.h
35960 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35961 int is_pci;
35962 unsigned long cce_buffers_offset;
35963
35964 - atomic_t idle_count;
35965 + atomic_unchecked_t idle_count;
35966
35967 int page_flipping;
35968 int current_page;
35969 u32 crtc_offset;
35970 u32 crtc_offset_cntl;
35971
35972 - atomic_t vbl_received;
35973 + atomic_unchecked_t vbl_received;
35974
35975 u32 color_fmt;
35976 unsigned int front_offset;
35977 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35978 index a954c54..9cc595c 100644
35979 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35980 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35981 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35982 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35983 }
35984
35985 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35986 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35987 [DRM_R128_INIT] = compat_r128_init,
35988 [DRM_R128_DEPTH] = compat_r128_depth,
35989 [DRM_R128_STIPPLE] = compat_r128_stipple,
35990 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35991 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35992 {
35993 unsigned int nr = DRM_IOCTL_NR(cmd);
35994 - drm_ioctl_compat_t *fn = NULL;
35995 int ret;
35996
35997 if (nr < DRM_COMMAND_BASE)
35998 return drm_compat_ioctl(filp, cmd, arg);
35999
36000 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36001 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36002 -
36003 - if (fn != NULL)
36004 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36005 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36006 ret = (*fn) (filp, cmd, arg);
36007 - else
36008 + } else
36009 ret = drm_ioctl(filp, cmd, arg);
36010
36011 return ret;
36012 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36013 index 2ea4f09..d391371 100644
36014 --- a/drivers/gpu/drm/r128/r128_irq.c
36015 +++ b/drivers/gpu/drm/r128/r128_irq.c
36016 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36017 if (crtc != 0)
36018 return 0;
36019
36020 - return atomic_read(&dev_priv->vbl_received);
36021 + return atomic_read_unchecked(&dev_priv->vbl_received);
36022 }
36023
36024 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36025 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36026 /* VBLANK interrupt */
36027 if (status & R128_CRTC_VBLANK_INT) {
36028 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36029 - atomic_inc(&dev_priv->vbl_received);
36030 + atomic_inc_unchecked(&dev_priv->vbl_received);
36031 drm_handle_vblank(dev, 0);
36032 return IRQ_HANDLED;
36033 }
36034 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36035 index 19bb7e6..de7e2a2 100644
36036 --- a/drivers/gpu/drm/r128/r128_state.c
36037 +++ b/drivers/gpu/drm/r128/r128_state.c
36038 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36039
36040 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36041 {
36042 - if (atomic_read(&dev_priv->idle_count) == 0)
36043 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36044 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36045 else
36046 - atomic_set(&dev_priv->idle_count, 0);
36047 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36048 }
36049
36050 #endif
36051 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36052 index 5a82b6b..9e69c73 100644
36053 --- a/drivers/gpu/drm/radeon/mkregtable.c
36054 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36055 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36056 regex_t mask_rex;
36057 regmatch_t match[4];
36058 char buf[1024];
36059 - size_t end;
36060 + long end;
36061 int len;
36062 int done = 0;
36063 int r;
36064 unsigned o;
36065 struct offset *offset;
36066 char last_reg_s[10];
36067 - int last_reg;
36068 + unsigned long last_reg;
36069
36070 if (regcomp
36071 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36072 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36073 index 0d6562b..a154330 100644
36074 --- a/drivers/gpu/drm/radeon/radeon_device.c
36075 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36076 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36077 bool can_switch;
36078
36079 spin_lock(&dev->count_lock);
36080 - can_switch = (dev->open_count == 0);
36081 + can_switch = (local_read(&dev->open_count) == 0);
36082 spin_unlock(&dev->count_lock);
36083 return can_switch;
36084 }
36085 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36086 index e7fdf16..f4f6490 100644
36087 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36088 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36089 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
36090
36091 /* SW interrupt */
36092 wait_queue_head_t swi_queue;
36093 - atomic_t swi_emitted;
36094 + atomic_unchecked_t swi_emitted;
36095 int vblank_crtc;
36096 uint32_t irq_enable_reg;
36097 uint32_t r500_disp_irq_reg;
36098 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36099 index c180df8..5fd8186 100644
36100 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36101 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36102 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36103 request = compat_alloc_user_space(sizeof(*request));
36104 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36105 || __put_user(req32.param, &request->param)
36106 - || __put_user((void __user *)(unsigned long)req32.value,
36107 + || __put_user((unsigned long)req32.value,
36108 &request->value))
36109 return -EFAULT;
36110
36111 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36112 #define compat_radeon_cp_setparam NULL
36113 #endif /* X86_64 || IA64 */
36114
36115 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36116 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36117 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36118 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36119 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36120 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36121 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36122 {
36123 unsigned int nr = DRM_IOCTL_NR(cmd);
36124 - drm_ioctl_compat_t *fn = NULL;
36125 int ret;
36126
36127 if (nr < DRM_COMMAND_BASE)
36128 return drm_compat_ioctl(filp, cmd, arg);
36129
36130 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36131 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36132 -
36133 - if (fn != NULL)
36134 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36135 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36136 ret = (*fn) (filp, cmd, arg);
36137 - else
36138 + } else
36139 ret = drm_ioctl(filp, cmd, arg);
36140
36141 return ret;
36142 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36143 index e771033..a0bc6b3 100644
36144 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36145 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36146 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36147 unsigned int ret;
36148 RING_LOCALS;
36149
36150 - atomic_inc(&dev_priv->swi_emitted);
36151 - ret = atomic_read(&dev_priv->swi_emitted);
36152 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36153 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36154
36155 BEGIN_RING(4);
36156 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36157 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36158 drm_radeon_private_t *dev_priv =
36159 (drm_radeon_private_t *) dev->dev_private;
36160
36161 - atomic_set(&dev_priv->swi_emitted, 0);
36162 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36163 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36164
36165 dev->max_vblank_count = 0x001fffff;
36166 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36167 index 8e9057b..af6dacb 100644
36168 --- a/drivers/gpu/drm/radeon/radeon_state.c
36169 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36170 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36171 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36172 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36173
36174 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36175 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36176 sarea_priv->nbox * sizeof(depth_boxes[0])))
36177 return -EFAULT;
36178
36179 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36180 {
36181 drm_radeon_private_t *dev_priv = dev->dev_private;
36182 drm_radeon_getparam_t *param = data;
36183 - int value;
36184 + int value = 0;
36185
36186 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36187
36188 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36189 index 93f760e..8088227 100644
36190 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36191 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36192 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36193 man->size = size >> PAGE_SHIFT;
36194 }
36195
36196 -static struct vm_operations_struct radeon_ttm_vm_ops;
36197 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36198 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36199
36200 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36201 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36202 }
36203 if (unlikely(ttm_vm_ops == NULL)) {
36204 ttm_vm_ops = vma->vm_ops;
36205 + pax_open_kernel();
36206 radeon_ttm_vm_ops = *ttm_vm_ops;
36207 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36208 + pax_close_kernel();
36209 }
36210 vma->vm_ops = &radeon_ttm_vm_ops;
36211 return 0;
36212 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36213 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36214 else
36215 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36216 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36217 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36218 - radeon_mem_types_list[i].driver_features = 0;
36219 + pax_open_kernel();
36220 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36221 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36222 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36223 if (i == 0)
36224 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36225 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36226 else
36227 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36228 -
36229 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36230 + pax_close_kernel();
36231 }
36232 /* Add ttm page pool to debugfs */
36233 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36234 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36235 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36236 - radeon_mem_types_list[i].driver_features = 0;
36237 - radeon_mem_types_list[i++].data = NULL;
36238 + pax_open_kernel();
36239 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36240 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36241 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36242 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36243 + pax_close_kernel();
36244 #ifdef CONFIG_SWIOTLB
36245 if (swiotlb_nr_tbl()) {
36246 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36247 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36248 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36249 - radeon_mem_types_list[i].driver_features = 0;
36250 - radeon_mem_types_list[i++].data = NULL;
36251 + pax_open_kernel();
36252 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36253 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36254 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36255 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36256 + pax_close_kernel();
36257 }
36258 #endif
36259 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36260 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36261 index 5706d2a..17aedaa 100644
36262 --- a/drivers/gpu/drm/radeon/rs690.c
36263 +++ b/drivers/gpu/drm/radeon/rs690.c
36264 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36265 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36266 rdev->pm.sideport_bandwidth.full)
36267 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36268 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36269 + read_delay_latency.full = dfixed_const(800 * 1000);
36270 read_delay_latency.full = dfixed_div(read_delay_latency,
36271 rdev->pm.igp_sideport_mclk);
36272 + a.full = dfixed_const(370);
36273 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36274 } else {
36275 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36276 rdev->pm.k8_bandwidth.full)
36277 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36278 index bd2a3b4..122d9ad 100644
36279 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36280 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36281 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36282 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36283 struct shrink_control *sc)
36284 {
36285 - static atomic_t start_pool = ATOMIC_INIT(0);
36286 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36287 unsigned i;
36288 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36289 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36290 struct ttm_page_pool *pool;
36291 int shrink_pages = sc->nr_to_scan;
36292
36293 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36294 index 1eb060c..188b1fc 100644
36295 --- a/drivers/gpu/drm/udl/udl_fb.c
36296 +++ b/drivers/gpu/drm/udl/udl_fb.c
36297 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36298 fb_deferred_io_cleanup(info);
36299 kfree(info->fbdefio);
36300 info->fbdefio = NULL;
36301 - info->fbops->fb_mmap = udl_fb_mmap;
36302 }
36303
36304 pr_warn("released /dev/fb%d user=%d count=%d\n",
36305 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36306 index 893a650..6190d3b 100644
36307 --- a/drivers/gpu/drm/via/via_drv.h
36308 +++ b/drivers/gpu/drm/via/via_drv.h
36309 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36310 typedef uint32_t maskarray_t[5];
36311
36312 typedef struct drm_via_irq {
36313 - atomic_t irq_received;
36314 + atomic_unchecked_t irq_received;
36315 uint32_t pending_mask;
36316 uint32_t enable_mask;
36317 wait_queue_head_t irq_queue;
36318 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36319 struct timeval last_vblank;
36320 int last_vblank_valid;
36321 unsigned usec_per_vblank;
36322 - atomic_t vbl_received;
36323 + atomic_unchecked_t vbl_received;
36324 drm_via_state_t hc_state;
36325 char pci_buf[VIA_PCI_BUF_SIZE];
36326 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36327 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36328 index ac98964..5dbf512 100644
36329 --- a/drivers/gpu/drm/via/via_irq.c
36330 +++ b/drivers/gpu/drm/via/via_irq.c
36331 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36332 if (crtc != 0)
36333 return 0;
36334
36335 - return atomic_read(&dev_priv->vbl_received);
36336 + return atomic_read_unchecked(&dev_priv->vbl_received);
36337 }
36338
36339 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36340 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36341
36342 status = VIA_READ(VIA_REG_INTERRUPT);
36343 if (status & VIA_IRQ_VBLANK_PENDING) {
36344 - atomic_inc(&dev_priv->vbl_received);
36345 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36346 + atomic_inc_unchecked(&dev_priv->vbl_received);
36347 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36348 do_gettimeofday(&cur_vblank);
36349 if (dev_priv->last_vblank_valid) {
36350 dev_priv->usec_per_vblank =
36351 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36352 dev_priv->last_vblank = cur_vblank;
36353 dev_priv->last_vblank_valid = 1;
36354 }
36355 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36356 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36357 DRM_DEBUG("US per vblank is: %u\n",
36358 dev_priv->usec_per_vblank);
36359 }
36360 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36361
36362 for (i = 0; i < dev_priv->num_irqs; ++i) {
36363 if (status & cur_irq->pending_mask) {
36364 - atomic_inc(&cur_irq->irq_received);
36365 + atomic_inc_unchecked(&cur_irq->irq_received);
36366 DRM_WAKEUP(&cur_irq->irq_queue);
36367 handled = 1;
36368 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36369 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36370 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36371 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36372 masks[irq][4]));
36373 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36374 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36375 } else {
36376 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36377 (((cur_irq_sequence =
36378 - atomic_read(&cur_irq->irq_received)) -
36379 + atomic_read_unchecked(&cur_irq->irq_received)) -
36380 *sequence) <= (1 << 23)));
36381 }
36382 *sequence = cur_irq_sequence;
36383 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36384 }
36385
36386 for (i = 0; i < dev_priv->num_irqs; ++i) {
36387 - atomic_set(&cur_irq->irq_received, 0);
36388 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36389 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36390 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36391 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36392 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36393 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36394 case VIA_IRQ_RELATIVE:
36395 irqwait->request.sequence +=
36396 - atomic_read(&cur_irq->irq_received);
36397 + atomic_read_unchecked(&cur_irq->irq_received);
36398 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36399 case VIA_IRQ_ABSOLUTE:
36400 break;
36401 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36402 index 13aeda7..4a952d1 100644
36403 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36404 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36405 @@ -290,7 +290,7 @@ struct vmw_private {
36406 * Fencing and IRQs.
36407 */
36408
36409 - atomic_t marker_seq;
36410 + atomic_unchecked_t marker_seq;
36411 wait_queue_head_t fence_queue;
36412 wait_queue_head_t fifo_queue;
36413 int fence_queue_waiters; /* Protected by hw_mutex */
36414 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36415 index 3eb1486..0a47ee9 100644
36416 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36417 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36418 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36419 (unsigned int) min,
36420 (unsigned int) fifo->capabilities);
36421
36422 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36423 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36424 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36425 vmw_marker_queue_init(&fifo->marker_queue);
36426 return vmw_fifo_send_fence(dev_priv, &dummy);
36427 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36428 if (reserveable)
36429 iowrite32(bytes, fifo_mem +
36430 SVGA_FIFO_RESERVED);
36431 - return fifo_mem + (next_cmd >> 2);
36432 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36433 } else {
36434 need_bounce = true;
36435 }
36436 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36437
36438 fm = vmw_fifo_reserve(dev_priv, bytes);
36439 if (unlikely(fm == NULL)) {
36440 - *seqno = atomic_read(&dev_priv->marker_seq);
36441 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36442 ret = -ENOMEM;
36443 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36444 false, 3*HZ);
36445 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36446 }
36447
36448 do {
36449 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36450 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36451 } while (*seqno == 0);
36452
36453 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36454 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36455 index 4640adb..e1384ed 100644
36456 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36457 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36458 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36459 * emitted. Then the fence is stale and signaled.
36460 */
36461
36462 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36463 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36464 > VMW_FENCE_WRAP);
36465
36466 return ret;
36467 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36468
36469 if (fifo_idle)
36470 down_read(&fifo_state->rwsem);
36471 - signal_seq = atomic_read(&dev_priv->marker_seq);
36472 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36473 ret = 0;
36474
36475 for (;;) {
36476 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36477 index 8a8725c..afed796 100644
36478 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36479 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36480 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36481 while (!vmw_lag_lt(queue, us)) {
36482 spin_lock(&queue->lock);
36483 if (list_empty(&queue->head))
36484 - seqno = atomic_read(&dev_priv->marker_seq);
36485 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36486 else {
36487 marker = list_first_entry(&queue->head,
36488 struct vmw_marker, head);
36489 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36490 index ceb3040..6160c5c 100644
36491 --- a/drivers/hid/hid-core.c
36492 +++ b/drivers/hid/hid-core.c
36493 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36494
36495 int hid_add_device(struct hid_device *hdev)
36496 {
36497 - static atomic_t id = ATOMIC_INIT(0);
36498 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36499 int ret;
36500
36501 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36502 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
36503 /* XXX hack, any other cleaner solution after the driver core
36504 * is converted to allow more than 20 bytes as the device name? */
36505 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36506 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36507 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36508
36509 hid_debug_register(hdev, dev_name(&hdev->dev));
36510 ret = device_add(&hdev->dev);
36511 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36512 index eec3291..8ed706b 100644
36513 --- a/drivers/hid/hid-wiimote-debug.c
36514 +++ b/drivers/hid/hid-wiimote-debug.c
36515 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36516 else if (size == 0)
36517 return -EIO;
36518
36519 - if (copy_to_user(u, buf, size))
36520 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36521 return -EFAULT;
36522
36523 *off += size;
36524 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36525 index 773a2f2..7ce08bc 100644
36526 --- a/drivers/hv/channel.c
36527 +++ b/drivers/hv/channel.c
36528 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36529 int ret = 0;
36530 int t;
36531
36532 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36533 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36534 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36535 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36536
36537 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36538 if (ret)
36539 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36540 index 3648f8f..30ef30d 100644
36541 --- a/drivers/hv/hv.c
36542 +++ b/drivers/hv/hv.c
36543 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36544 u64 output_address = (output) ? virt_to_phys(output) : 0;
36545 u32 output_address_hi = output_address >> 32;
36546 u32 output_address_lo = output_address & 0xFFFFFFFF;
36547 - void *hypercall_page = hv_context.hypercall_page;
36548 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36549
36550 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36551 "=a"(hv_status_lo) : "d" (control_hi),
36552 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36553 index d8d1fad..b91caf7 100644
36554 --- a/drivers/hv/hyperv_vmbus.h
36555 +++ b/drivers/hv/hyperv_vmbus.h
36556 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
36557 struct vmbus_connection {
36558 enum vmbus_connect_state conn_state;
36559
36560 - atomic_t next_gpadl_handle;
36561 + atomic_unchecked_t next_gpadl_handle;
36562
36563 /*
36564 * Represents channel interrupts. Each bit position represents a
36565 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36566 index 8e1a9ec..4687821 100644
36567 --- a/drivers/hv/vmbus_drv.c
36568 +++ b/drivers/hv/vmbus_drv.c
36569 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36570 {
36571 int ret = 0;
36572
36573 - static atomic_t device_num = ATOMIC_INIT(0);
36574 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36575
36576 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36577 - atomic_inc_return(&device_num));
36578 + atomic_inc_return_unchecked(&device_num));
36579
36580 child_device_obj->device.bus = &hv_bus;
36581 child_device_obj->device.parent = &hv_acpi_dev->dev;
36582 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36583 index 1672e2a..4a6297c 100644
36584 --- a/drivers/hwmon/acpi_power_meter.c
36585 +++ b/drivers/hwmon/acpi_power_meter.c
36586 @@ -117,7 +117,7 @@ struct sensor_template {
36587 struct device_attribute *devattr,
36588 const char *buf, size_t count);
36589 int index;
36590 -};
36591 +} __do_const;
36592
36593 /* Averaging interval */
36594 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36595 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36596 struct sensor_template *attrs)
36597 {
36598 struct device *dev = &resource->acpi_dev->dev;
36599 - struct sensor_device_attribute *sensors =
36600 + sensor_device_attribute_no_const *sensors =
36601 &resource->sensors[resource->num_sensors];
36602 int res = 0;
36603
36604 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36605 index b41baff..4953e4d 100644
36606 --- a/drivers/hwmon/applesmc.c
36607 +++ b/drivers/hwmon/applesmc.c
36608 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36609 {
36610 struct applesmc_node_group *grp;
36611 struct applesmc_dev_attr *node;
36612 - struct attribute *attr;
36613 + attribute_no_const *attr;
36614 int ret, i;
36615
36616 for (grp = groups; grp->format; grp++) {
36617 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36618 index 56dbcfb..9874bf1 100644
36619 --- a/drivers/hwmon/asus_atk0110.c
36620 +++ b/drivers/hwmon/asus_atk0110.c
36621 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36622 struct atk_sensor_data {
36623 struct list_head list;
36624 struct atk_data *data;
36625 - struct device_attribute label_attr;
36626 - struct device_attribute input_attr;
36627 - struct device_attribute limit1_attr;
36628 - struct device_attribute limit2_attr;
36629 + device_attribute_no_const label_attr;
36630 + device_attribute_no_const input_attr;
36631 + device_attribute_no_const limit1_attr;
36632 + device_attribute_no_const limit2_attr;
36633 char label_attr_name[ATTR_NAME_SIZE];
36634 char input_attr_name[ATTR_NAME_SIZE];
36635 char limit1_attr_name[ATTR_NAME_SIZE];
36636 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36637 static struct device_attribute atk_name_attr =
36638 __ATTR(name, 0444, atk_name_show, NULL);
36639
36640 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36641 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36642 sysfs_show_func show)
36643 {
36644 sysfs_attr_init(&attr->attr);
36645 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36646 index d64923d..72591e8 100644
36647 --- a/drivers/hwmon/coretemp.c
36648 +++ b/drivers/hwmon/coretemp.c
36649 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36650 return NOTIFY_OK;
36651 }
36652
36653 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36654 +static struct notifier_block coretemp_cpu_notifier = {
36655 .notifier_call = coretemp_cpu_callback,
36656 };
36657
36658 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36659 index a14f634..2916ee2 100644
36660 --- a/drivers/hwmon/ibmaem.c
36661 +++ b/drivers/hwmon/ibmaem.c
36662 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36663 struct aem_rw_sensor_template *rw)
36664 {
36665 struct device *dev = &data->pdev->dev;
36666 - struct sensor_device_attribute *sensors = data->sensors;
36667 + sensor_device_attribute_no_const *sensors = data->sensors;
36668 int err;
36669
36670 /* Set up read-only sensors */
36671 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36672 index 7d19b1b..8fdaaac 100644
36673 --- a/drivers/hwmon/pmbus/pmbus_core.c
36674 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36675 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36676
36677 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36678 do { \
36679 - struct sensor_device_attribute *a \
36680 + sensor_device_attribute_no_const *a \
36681 = &data->_type##s[data->num_##_type##s].attribute; \
36682 BUG_ON(data->num_attributes >= data->max_attributes); \
36683 sysfs_attr_init(&a->dev_attr.attr); \
36684 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36685 index 8047fed..1e956f0 100644
36686 --- a/drivers/hwmon/sht15.c
36687 +++ b/drivers/hwmon/sht15.c
36688 @@ -169,7 +169,7 @@ struct sht15_data {
36689 int supply_uV;
36690 bool supply_uV_valid;
36691 struct work_struct update_supply_work;
36692 - atomic_t interrupt_handled;
36693 + atomic_unchecked_t interrupt_handled;
36694 };
36695
36696 /**
36697 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36698 return ret;
36699
36700 gpio_direction_input(data->pdata->gpio_data);
36701 - atomic_set(&data->interrupt_handled, 0);
36702 + atomic_set_unchecked(&data->interrupt_handled, 0);
36703
36704 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36705 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36706 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36707 /* Only relevant if the interrupt hasn't occurred. */
36708 - if (!atomic_read(&data->interrupt_handled))
36709 + if (!atomic_read_unchecked(&data->interrupt_handled))
36710 schedule_work(&data->read_work);
36711 }
36712 ret = wait_event_timeout(data->wait_queue,
36713 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36714
36715 /* First disable the interrupt */
36716 disable_irq_nosync(irq);
36717 - atomic_inc(&data->interrupt_handled);
36718 + atomic_inc_unchecked(&data->interrupt_handled);
36719 /* Then schedule a reading work struct */
36720 if (data->state != SHT15_READING_NOTHING)
36721 schedule_work(&data->read_work);
36722 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36723 * If not, then start the interrupt again - care here as could
36724 * have gone low in meantime so verify it hasn't!
36725 */
36726 - atomic_set(&data->interrupt_handled, 0);
36727 + atomic_set_unchecked(&data->interrupt_handled, 0);
36728 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36729 /* If still not occurred or another handler was scheduled */
36730 if (gpio_get_value(data->pdata->gpio_data)
36731 - || atomic_read(&data->interrupt_handled))
36732 + || atomic_read_unchecked(&data->interrupt_handled))
36733 return;
36734 }
36735
36736 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36737 index 76f157b..9c0db1b 100644
36738 --- a/drivers/hwmon/via-cputemp.c
36739 +++ b/drivers/hwmon/via-cputemp.c
36740 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36741 return NOTIFY_OK;
36742 }
36743
36744 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36745 +static struct notifier_block via_cputemp_cpu_notifier = {
36746 .notifier_call = via_cputemp_cpu_callback,
36747 };
36748
36749 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36750 index 378fcb5..5e91fa8 100644
36751 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36752 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36753 @@ -43,7 +43,7 @@
36754 extern struct i2c_adapter amd756_smbus;
36755
36756 static struct i2c_adapter *s4882_adapter;
36757 -static struct i2c_algorithm *s4882_algo;
36758 +static i2c_algorithm_no_const *s4882_algo;
36759
36760 /* Wrapper access functions for multiplexed SMBus */
36761 static DEFINE_MUTEX(amd756_lock);
36762 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36763 index 29015eb..af2d8e9 100644
36764 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36765 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36766 @@ -41,7 +41,7 @@
36767 extern struct i2c_adapter *nforce2_smbus;
36768
36769 static struct i2c_adapter *s4985_adapter;
36770 -static struct i2c_algorithm *s4985_algo;
36771 +static i2c_algorithm_no_const *s4985_algo;
36772
36773 /* Wrapper access functions for multiplexed SMBus */
36774 static DEFINE_MUTEX(nforce2_lock);
36775 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36776 index 8126824..55a2798 100644
36777 --- a/drivers/ide/ide-cd.c
36778 +++ b/drivers/ide/ide-cd.c
36779 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36780 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36781 if ((unsigned long)buf & alignment
36782 || blk_rq_bytes(rq) & q->dma_pad_mask
36783 - || object_is_on_stack(buf))
36784 + || object_starts_on_stack(buf))
36785 drive->dma = 0;
36786 }
36787 }
36788 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36789 index 8848f16..f8e6dd8 100644
36790 --- a/drivers/iio/industrialio-core.c
36791 +++ b/drivers/iio/industrialio-core.c
36792 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36793 }
36794
36795 static
36796 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36797 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36798 const char *postfix,
36799 struct iio_chan_spec const *chan,
36800 ssize_t (*readfunc)(struct device *dev,
36801 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36802 index 394fea2..c833880 100644
36803 --- a/drivers/infiniband/core/cm.c
36804 +++ b/drivers/infiniband/core/cm.c
36805 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36806
36807 struct cm_counter_group {
36808 struct kobject obj;
36809 - atomic_long_t counter[CM_ATTR_COUNT];
36810 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36811 };
36812
36813 struct cm_counter_attribute {
36814 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36815 struct ib_mad_send_buf *msg = NULL;
36816 int ret;
36817
36818 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36819 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36820 counter[CM_REQ_COUNTER]);
36821
36822 /* Quick state check to discard duplicate REQs. */
36823 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36824 if (!cm_id_priv)
36825 return;
36826
36827 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36828 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36829 counter[CM_REP_COUNTER]);
36830 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36831 if (ret)
36832 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36833 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36834 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36835 spin_unlock_irq(&cm_id_priv->lock);
36836 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36837 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36838 counter[CM_RTU_COUNTER]);
36839 goto out;
36840 }
36841 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36842 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36843 dreq_msg->local_comm_id);
36844 if (!cm_id_priv) {
36845 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36846 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36847 counter[CM_DREQ_COUNTER]);
36848 cm_issue_drep(work->port, work->mad_recv_wc);
36849 return -EINVAL;
36850 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36851 case IB_CM_MRA_REP_RCVD:
36852 break;
36853 case IB_CM_TIMEWAIT:
36854 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36855 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36856 counter[CM_DREQ_COUNTER]);
36857 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36858 goto unlock;
36859 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36860 cm_free_msg(msg);
36861 goto deref;
36862 case IB_CM_DREQ_RCVD:
36863 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36864 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36865 counter[CM_DREQ_COUNTER]);
36866 goto unlock;
36867 default:
36868 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36869 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36870 cm_id_priv->msg, timeout)) {
36871 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36872 - atomic_long_inc(&work->port->
36873 + atomic_long_inc_unchecked(&work->port->
36874 counter_group[CM_RECV_DUPLICATES].
36875 counter[CM_MRA_COUNTER]);
36876 goto out;
36877 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36878 break;
36879 case IB_CM_MRA_REQ_RCVD:
36880 case IB_CM_MRA_REP_RCVD:
36881 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36882 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36883 counter[CM_MRA_COUNTER]);
36884 /* fall through */
36885 default:
36886 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36887 case IB_CM_LAP_IDLE:
36888 break;
36889 case IB_CM_MRA_LAP_SENT:
36890 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36891 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36892 counter[CM_LAP_COUNTER]);
36893 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36894 goto unlock;
36895 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36896 cm_free_msg(msg);
36897 goto deref;
36898 case IB_CM_LAP_RCVD:
36899 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36900 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36901 counter[CM_LAP_COUNTER]);
36902 goto unlock;
36903 default:
36904 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36905 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36906 if (cur_cm_id_priv) {
36907 spin_unlock_irq(&cm.lock);
36908 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36909 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36910 counter[CM_SIDR_REQ_COUNTER]);
36911 goto out; /* Duplicate message. */
36912 }
36913 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36914 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36915 msg->retries = 1;
36916
36917 - atomic_long_add(1 + msg->retries,
36918 + atomic_long_add_unchecked(1 + msg->retries,
36919 &port->counter_group[CM_XMIT].counter[attr_index]);
36920 if (msg->retries)
36921 - atomic_long_add(msg->retries,
36922 + atomic_long_add_unchecked(msg->retries,
36923 &port->counter_group[CM_XMIT_RETRIES].
36924 counter[attr_index]);
36925
36926 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36927 }
36928
36929 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36930 - atomic_long_inc(&port->counter_group[CM_RECV].
36931 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36932 counter[attr_id - CM_ATTR_ID_OFFSET]);
36933
36934 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36935 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36936 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36937
36938 return sprintf(buf, "%ld\n",
36939 - atomic_long_read(&group->counter[cm_attr->index]));
36940 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36941 }
36942
36943 static const struct sysfs_ops cm_counter_ops = {
36944 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36945 index 176c8f9..2627b62 100644
36946 --- a/drivers/infiniband/core/fmr_pool.c
36947 +++ b/drivers/infiniband/core/fmr_pool.c
36948 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36949
36950 struct task_struct *thread;
36951
36952 - atomic_t req_ser;
36953 - atomic_t flush_ser;
36954 + atomic_unchecked_t req_ser;
36955 + atomic_unchecked_t flush_ser;
36956
36957 wait_queue_head_t force_wait;
36958 };
36959 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36960 struct ib_fmr_pool *pool = pool_ptr;
36961
36962 do {
36963 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36964 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36965 ib_fmr_batch_release(pool);
36966
36967 - atomic_inc(&pool->flush_ser);
36968 + atomic_inc_unchecked(&pool->flush_ser);
36969 wake_up_interruptible(&pool->force_wait);
36970
36971 if (pool->flush_function)
36972 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36973 }
36974
36975 set_current_state(TASK_INTERRUPTIBLE);
36976 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36977 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36978 !kthread_should_stop())
36979 schedule();
36980 __set_current_state(TASK_RUNNING);
36981 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36982 pool->dirty_watermark = params->dirty_watermark;
36983 pool->dirty_len = 0;
36984 spin_lock_init(&pool->pool_lock);
36985 - atomic_set(&pool->req_ser, 0);
36986 - atomic_set(&pool->flush_ser, 0);
36987 + atomic_set_unchecked(&pool->req_ser, 0);
36988 + atomic_set_unchecked(&pool->flush_ser, 0);
36989 init_waitqueue_head(&pool->force_wait);
36990
36991 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36992 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36993 }
36994 spin_unlock_irq(&pool->pool_lock);
36995
36996 - serial = atomic_inc_return(&pool->req_ser);
36997 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36998 wake_up_process(pool->thread);
36999
37000 if (wait_event_interruptible(pool->force_wait,
37001 - atomic_read(&pool->flush_ser) - serial >= 0))
37002 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37003 return -EINTR;
37004
37005 return 0;
37006 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37007 } else {
37008 list_add_tail(&fmr->list, &pool->dirty_list);
37009 if (++pool->dirty_len >= pool->dirty_watermark) {
37010 - atomic_inc(&pool->req_ser);
37011 + atomic_inc_unchecked(&pool->req_ser);
37012 wake_up_process(pool->thread);
37013 }
37014 }
37015 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37016 index afd8179..598063f 100644
37017 --- a/drivers/infiniband/hw/cxgb4/mem.c
37018 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37019 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37020 int err;
37021 struct fw_ri_tpte tpt;
37022 u32 stag_idx;
37023 - static atomic_t key;
37024 + static atomic_unchecked_t key;
37025
37026 if (c4iw_fatal_error(rdev))
37027 return -EIO;
37028 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37029 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37030 rdev->stats.stag.max = rdev->stats.stag.cur;
37031 mutex_unlock(&rdev->stats.lock);
37032 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37033 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37034 }
37035 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37036 __func__, stag_state, type, pdid, stag_idx);
37037 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37038 index 79b3dbc..96e5fcc 100644
37039 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37040 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37041 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37042 struct ib_atomic_eth *ateth;
37043 struct ipath_ack_entry *e;
37044 u64 vaddr;
37045 - atomic64_t *maddr;
37046 + atomic64_unchecked_t *maddr;
37047 u64 sdata;
37048 u32 rkey;
37049 u8 next;
37050 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37051 IB_ACCESS_REMOTE_ATOMIC)))
37052 goto nack_acc_unlck;
37053 /* Perform atomic OP and save result. */
37054 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37055 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37056 sdata = be64_to_cpu(ateth->swap_data);
37057 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37058 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37059 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37060 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37061 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37062 be64_to_cpu(ateth->compare_data),
37063 sdata);
37064 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37065 index 1f95bba..9530f87 100644
37066 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37067 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37068 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37069 unsigned long flags;
37070 struct ib_wc wc;
37071 u64 sdata;
37072 - atomic64_t *maddr;
37073 + atomic64_unchecked_t *maddr;
37074 enum ib_wc_status send_status;
37075
37076 /*
37077 @@ -382,11 +382,11 @@ again:
37078 IB_ACCESS_REMOTE_ATOMIC)))
37079 goto acc_err;
37080 /* Perform atomic OP and save result. */
37081 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37082 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37083 sdata = wqe->wr.wr.atomic.compare_add;
37084 *(u64 *) sqp->s_sge.sge.vaddr =
37085 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37086 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37087 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37088 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37089 sdata, wqe->wr.wr.atomic.swap);
37090 goto send_comp;
37091 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37092 index 9d3e5c1..d9afe4a 100644
37093 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37094 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37095 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37096 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37097 }
37098
37099 -int mthca_QUERY_FW(struct mthca_dev *dev)
37100 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37101 {
37102 struct mthca_mailbox *mailbox;
37103 u32 *outbox;
37104 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37105 index ed9a989..e0c5871 100644
37106 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37107 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37108 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37109 return key;
37110 }
37111
37112 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37113 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37114 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37115 {
37116 struct mthca_mailbox *mailbox;
37117 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37118 index 5b152a3..c1f3e83 100644
37119 --- a/drivers/infiniband/hw/nes/nes.c
37120 +++ b/drivers/infiniband/hw/nes/nes.c
37121 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37122 LIST_HEAD(nes_adapter_list);
37123 static LIST_HEAD(nes_dev_list);
37124
37125 -atomic_t qps_destroyed;
37126 +atomic_unchecked_t qps_destroyed;
37127
37128 static unsigned int ee_flsh_adapter;
37129 static unsigned int sysfs_nonidx_addr;
37130 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37131 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37132 struct nes_adapter *nesadapter = nesdev->nesadapter;
37133
37134 - atomic_inc(&qps_destroyed);
37135 + atomic_inc_unchecked(&qps_destroyed);
37136
37137 /* Free the control structures */
37138
37139 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37140 index 33cc589..3bd6538 100644
37141 --- a/drivers/infiniband/hw/nes/nes.h
37142 +++ b/drivers/infiniband/hw/nes/nes.h
37143 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37144 extern unsigned int wqm_quanta;
37145 extern struct list_head nes_adapter_list;
37146
37147 -extern atomic_t cm_connects;
37148 -extern atomic_t cm_accepts;
37149 -extern atomic_t cm_disconnects;
37150 -extern atomic_t cm_closes;
37151 -extern atomic_t cm_connecteds;
37152 -extern atomic_t cm_connect_reqs;
37153 -extern atomic_t cm_rejects;
37154 -extern atomic_t mod_qp_timouts;
37155 -extern atomic_t qps_created;
37156 -extern atomic_t qps_destroyed;
37157 -extern atomic_t sw_qps_destroyed;
37158 +extern atomic_unchecked_t cm_connects;
37159 +extern atomic_unchecked_t cm_accepts;
37160 +extern atomic_unchecked_t cm_disconnects;
37161 +extern atomic_unchecked_t cm_closes;
37162 +extern atomic_unchecked_t cm_connecteds;
37163 +extern atomic_unchecked_t cm_connect_reqs;
37164 +extern atomic_unchecked_t cm_rejects;
37165 +extern atomic_unchecked_t mod_qp_timouts;
37166 +extern atomic_unchecked_t qps_created;
37167 +extern atomic_unchecked_t qps_destroyed;
37168 +extern atomic_unchecked_t sw_qps_destroyed;
37169 extern u32 mh_detected;
37170 extern u32 mh_pauses_sent;
37171 extern u32 cm_packets_sent;
37172 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37173 extern u32 cm_packets_received;
37174 extern u32 cm_packets_dropped;
37175 extern u32 cm_packets_retrans;
37176 -extern atomic_t cm_listens_created;
37177 -extern atomic_t cm_listens_destroyed;
37178 +extern atomic_unchecked_t cm_listens_created;
37179 +extern atomic_unchecked_t cm_listens_destroyed;
37180 extern u32 cm_backlog_drops;
37181 -extern atomic_t cm_loopbacks;
37182 -extern atomic_t cm_nodes_created;
37183 -extern atomic_t cm_nodes_destroyed;
37184 -extern atomic_t cm_accel_dropped_pkts;
37185 -extern atomic_t cm_resets_recvd;
37186 -extern atomic_t pau_qps_created;
37187 -extern atomic_t pau_qps_destroyed;
37188 +extern atomic_unchecked_t cm_loopbacks;
37189 +extern atomic_unchecked_t cm_nodes_created;
37190 +extern atomic_unchecked_t cm_nodes_destroyed;
37191 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37192 +extern atomic_unchecked_t cm_resets_recvd;
37193 +extern atomic_unchecked_t pau_qps_created;
37194 +extern atomic_unchecked_t pau_qps_destroyed;
37195
37196 extern u32 int_mod_timer_init;
37197 extern u32 int_mod_cq_depth_256;
37198 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37199 index 22ea67e..dcbe3bc 100644
37200 --- a/drivers/infiniband/hw/nes/nes_cm.c
37201 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37202 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37203 u32 cm_packets_retrans;
37204 u32 cm_packets_created;
37205 u32 cm_packets_received;
37206 -atomic_t cm_listens_created;
37207 -atomic_t cm_listens_destroyed;
37208 +atomic_unchecked_t cm_listens_created;
37209 +atomic_unchecked_t cm_listens_destroyed;
37210 u32 cm_backlog_drops;
37211 -atomic_t cm_loopbacks;
37212 -atomic_t cm_nodes_created;
37213 -atomic_t cm_nodes_destroyed;
37214 -atomic_t cm_accel_dropped_pkts;
37215 -atomic_t cm_resets_recvd;
37216 +atomic_unchecked_t cm_loopbacks;
37217 +atomic_unchecked_t cm_nodes_created;
37218 +atomic_unchecked_t cm_nodes_destroyed;
37219 +atomic_unchecked_t cm_accel_dropped_pkts;
37220 +atomic_unchecked_t cm_resets_recvd;
37221
37222 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37223 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37224 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37225
37226 static struct nes_cm_core *g_cm_core;
37227
37228 -atomic_t cm_connects;
37229 -atomic_t cm_accepts;
37230 -atomic_t cm_disconnects;
37231 -atomic_t cm_closes;
37232 -atomic_t cm_connecteds;
37233 -atomic_t cm_connect_reqs;
37234 -atomic_t cm_rejects;
37235 +atomic_unchecked_t cm_connects;
37236 +atomic_unchecked_t cm_accepts;
37237 +atomic_unchecked_t cm_disconnects;
37238 +atomic_unchecked_t cm_closes;
37239 +atomic_unchecked_t cm_connecteds;
37240 +atomic_unchecked_t cm_connect_reqs;
37241 +atomic_unchecked_t cm_rejects;
37242
37243 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37244 {
37245 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37246 kfree(listener);
37247 listener = NULL;
37248 ret = 0;
37249 - atomic_inc(&cm_listens_destroyed);
37250 + atomic_inc_unchecked(&cm_listens_destroyed);
37251 } else {
37252 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37253 }
37254 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37255 cm_node->rem_mac);
37256
37257 add_hte_node(cm_core, cm_node);
37258 - atomic_inc(&cm_nodes_created);
37259 + atomic_inc_unchecked(&cm_nodes_created);
37260
37261 return cm_node;
37262 }
37263 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37264 }
37265
37266 atomic_dec(&cm_core->node_cnt);
37267 - atomic_inc(&cm_nodes_destroyed);
37268 + atomic_inc_unchecked(&cm_nodes_destroyed);
37269 nesqp = cm_node->nesqp;
37270 if (nesqp) {
37271 nesqp->cm_node = NULL;
37272 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37273
37274 static void drop_packet(struct sk_buff *skb)
37275 {
37276 - atomic_inc(&cm_accel_dropped_pkts);
37277 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37278 dev_kfree_skb_any(skb);
37279 }
37280
37281 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37282 {
37283
37284 int reset = 0; /* whether to send reset in case of err.. */
37285 - atomic_inc(&cm_resets_recvd);
37286 + atomic_inc_unchecked(&cm_resets_recvd);
37287 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37288 " refcnt=%d\n", cm_node, cm_node->state,
37289 atomic_read(&cm_node->ref_count));
37290 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37291 rem_ref_cm_node(cm_node->cm_core, cm_node);
37292 return NULL;
37293 }
37294 - atomic_inc(&cm_loopbacks);
37295 + atomic_inc_unchecked(&cm_loopbacks);
37296 loopbackremotenode->loopbackpartner = cm_node;
37297 loopbackremotenode->tcp_cntxt.rcv_wscale =
37298 NES_CM_DEFAULT_RCV_WND_SCALE;
37299 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37300 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37301 else {
37302 rem_ref_cm_node(cm_core, cm_node);
37303 - atomic_inc(&cm_accel_dropped_pkts);
37304 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37305 dev_kfree_skb_any(skb);
37306 }
37307 break;
37308 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37309
37310 if ((cm_id) && (cm_id->event_handler)) {
37311 if (issue_disconn) {
37312 - atomic_inc(&cm_disconnects);
37313 + atomic_inc_unchecked(&cm_disconnects);
37314 cm_event.event = IW_CM_EVENT_DISCONNECT;
37315 cm_event.status = disconn_status;
37316 cm_event.local_addr = cm_id->local_addr;
37317 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37318 }
37319
37320 if (issue_close) {
37321 - atomic_inc(&cm_closes);
37322 + atomic_inc_unchecked(&cm_closes);
37323 nes_disconnect(nesqp, 1);
37324
37325 cm_id->provider_data = nesqp;
37326 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37327
37328 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37329 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37330 - atomic_inc(&cm_accepts);
37331 + atomic_inc_unchecked(&cm_accepts);
37332
37333 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37334 netdev_refcnt_read(nesvnic->netdev));
37335 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37336 struct nes_cm_core *cm_core;
37337 u8 *start_buff;
37338
37339 - atomic_inc(&cm_rejects);
37340 + atomic_inc_unchecked(&cm_rejects);
37341 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37342 loopback = cm_node->loopbackpartner;
37343 cm_core = cm_node->cm_core;
37344 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37345 ntohl(cm_id->local_addr.sin_addr.s_addr),
37346 ntohs(cm_id->local_addr.sin_port));
37347
37348 - atomic_inc(&cm_connects);
37349 + atomic_inc_unchecked(&cm_connects);
37350 nesqp->active_conn = 1;
37351
37352 /* cache the cm_id in the qp */
37353 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37354 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37355 return err;
37356 }
37357 - atomic_inc(&cm_listens_created);
37358 + atomic_inc_unchecked(&cm_listens_created);
37359 }
37360
37361 cm_id->add_ref(cm_id);
37362 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37363
37364 if (nesqp->destroyed)
37365 return;
37366 - atomic_inc(&cm_connecteds);
37367 + atomic_inc_unchecked(&cm_connecteds);
37368 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37369 " local port 0x%04X. jiffies = %lu.\n",
37370 nesqp->hwqp.qp_id,
37371 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37372
37373 cm_id->add_ref(cm_id);
37374 ret = cm_id->event_handler(cm_id, &cm_event);
37375 - atomic_inc(&cm_closes);
37376 + atomic_inc_unchecked(&cm_closes);
37377 cm_event.event = IW_CM_EVENT_CLOSE;
37378 cm_event.status = 0;
37379 cm_event.provider_data = cm_id->provider_data;
37380 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37381 return;
37382 cm_id = cm_node->cm_id;
37383
37384 - atomic_inc(&cm_connect_reqs);
37385 + atomic_inc_unchecked(&cm_connect_reqs);
37386 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37387 cm_node, cm_id, jiffies);
37388
37389 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37390 return;
37391 cm_id = cm_node->cm_id;
37392
37393 - atomic_inc(&cm_connect_reqs);
37394 + atomic_inc_unchecked(&cm_connect_reqs);
37395 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37396 cm_node, cm_id, jiffies);
37397
37398 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37399 index 4166452..fc952c3 100644
37400 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37401 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37402 @@ -40,8 +40,8 @@
37403 #include "nes.h"
37404 #include "nes_mgt.h"
37405
37406 -atomic_t pau_qps_created;
37407 -atomic_t pau_qps_destroyed;
37408 +atomic_unchecked_t pau_qps_created;
37409 +atomic_unchecked_t pau_qps_destroyed;
37410
37411 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37412 {
37413 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37414 {
37415 struct sk_buff *skb;
37416 unsigned long flags;
37417 - atomic_inc(&pau_qps_destroyed);
37418 + atomic_inc_unchecked(&pau_qps_destroyed);
37419
37420 /* Free packets that have not yet been forwarded */
37421 /* Lock is acquired by skb_dequeue when removing the skb */
37422 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37423 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37424 skb_queue_head_init(&nesqp->pau_list);
37425 spin_lock_init(&nesqp->pau_lock);
37426 - atomic_inc(&pau_qps_created);
37427 + atomic_inc_unchecked(&pau_qps_created);
37428 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37429 }
37430
37431 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37432 index 9542e16..a008c40 100644
37433 --- a/drivers/infiniband/hw/nes/nes_nic.c
37434 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37435 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37436 target_stat_values[++index] = mh_detected;
37437 target_stat_values[++index] = mh_pauses_sent;
37438 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37439 - target_stat_values[++index] = atomic_read(&cm_connects);
37440 - target_stat_values[++index] = atomic_read(&cm_accepts);
37441 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37442 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37443 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37444 - target_stat_values[++index] = atomic_read(&cm_rejects);
37445 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37446 - target_stat_values[++index] = atomic_read(&qps_created);
37447 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37448 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37449 - target_stat_values[++index] = atomic_read(&cm_closes);
37450 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37451 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37452 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37453 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37454 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37455 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37456 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37457 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37458 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37459 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37460 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37461 target_stat_values[++index] = cm_packets_sent;
37462 target_stat_values[++index] = cm_packets_bounced;
37463 target_stat_values[++index] = cm_packets_created;
37464 target_stat_values[++index] = cm_packets_received;
37465 target_stat_values[++index] = cm_packets_dropped;
37466 target_stat_values[++index] = cm_packets_retrans;
37467 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37468 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37469 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37470 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37471 target_stat_values[++index] = cm_backlog_drops;
37472 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37473 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37474 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37475 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37476 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37477 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37478 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37479 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37480 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37481 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37482 target_stat_values[++index] = nesadapter->free_4kpbl;
37483 target_stat_values[++index] = nesadapter->free_256pbl;
37484 target_stat_values[++index] = int_mod_timer_init;
37485 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37486 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37487 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37488 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37489 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37490 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37491 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37492 }
37493
37494 /**
37495 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37496 index 07e4fba..685f041 100644
37497 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37498 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37499 @@ -46,9 +46,9 @@
37500
37501 #include <rdma/ib_umem.h>
37502
37503 -atomic_t mod_qp_timouts;
37504 -atomic_t qps_created;
37505 -atomic_t sw_qps_destroyed;
37506 +atomic_unchecked_t mod_qp_timouts;
37507 +atomic_unchecked_t qps_created;
37508 +atomic_unchecked_t sw_qps_destroyed;
37509
37510 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37511
37512 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37513 if (init_attr->create_flags)
37514 return ERR_PTR(-EINVAL);
37515
37516 - atomic_inc(&qps_created);
37517 + atomic_inc_unchecked(&qps_created);
37518 switch (init_attr->qp_type) {
37519 case IB_QPT_RC:
37520 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37521 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37522 struct iw_cm_event cm_event;
37523 int ret = 0;
37524
37525 - atomic_inc(&sw_qps_destroyed);
37526 + atomic_inc_unchecked(&sw_qps_destroyed);
37527 nesqp->destroyed = 1;
37528
37529 /* Blow away the connection if it exists. */
37530 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37531 index 4d11575..3e890e5 100644
37532 --- a/drivers/infiniband/hw/qib/qib.h
37533 +++ b/drivers/infiniband/hw/qib/qib.h
37534 @@ -51,6 +51,7 @@
37535 #include <linux/completion.h>
37536 #include <linux/kref.h>
37537 #include <linux/sched.h>
37538 +#include <linux/slab.h>
37539
37540 #include "qib_common.h"
37541 #include "qib_verbs.h"
37542 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37543 index da739d9..da1c7f4 100644
37544 --- a/drivers/input/gameport/gameport.c
37545 +++ b/drivers/input/gameport/gameport.c
37546 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37547 */
37548 static void gameport_init_port(struct gameport *gameport)
37549 {
37550 - static atomic_t gameport_no = ATOMIC_INIT(0);
37551 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37552
37553 __module_get(THIS_MODULE);
37554
37555 mutex_init(&gameport->drv_mutex);
37556 device_initialize(&gameport->dev);
37557 dev_set_name(&gameport->dev, "gameport%lu",
37558 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37559 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37560 gameport->dev.bus = &gameport_bus;
37561 gameport->dev.release = gameport_release_port;
37562 if (gameport->parent)
37563 diff --git a/drivers/input/input.c b/drivers/input/input.c
37564 index c044699..174d71a 100644
37565 --- a/drivers/input/input.c
37566 +++ b/drivers/input/input.c
37567 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37568 */
37569 int input_register_device(struct input_dev *dev)
37570 {
37571 - static atomic_t input_no = ATOMIC_INIT(0);
37572 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37573 struct input_devres *devres = NULL;
37574 struct input_handler *handler;
37575 unsigned int packet_size;
37576 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37577 dev->setkeycode = input_default_setkeycode;
37578
37579 dev_set_name(&dev->dev, "input%ld",
37580 - (unsigned long) atomic_inc_return(&input_no) - 1);
37581 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37582
37583 error = device_add(&dev->dev);
37584 if (error)
37585 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37586 index 04c69af..5f92d00 100644
37587 --- a/drivers/input/joystick/sidewinder.c
37588 +++ b/drivers/input/joystick/sidewinder.c
37589 @@ -30,6 +30,7 @@
37590 #include <linux/kernel.h>
37591 #include <linux/module.h>
37592 #include <linux/slab.h>
37593 +#include <linux/sched.h>
37594 #include <linux/init.h>
37595 #include <linux/input.h>
37596 #include <linux/gameport.h>
37597 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37598 index d6cbfe9..6225402 100644
37599 --- a/drivers/input/joystick/xpad.c
37600 +++ b/drivers/input/joystick/xpad.c
37601 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37602
37603 static int xpad_led_probe(struct usb_xpad *xpad)
37604 {
37605 - static atomic_t led_seq = ATOMIC_INIT(0);
37606 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37607 long led_no;
37608 struct xpad_led *led;
37609 struct led_classdev *led_cdev;
37610 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37611 if (!led)
37612 return -ENOMEM;
37613
37614 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37615 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37616
37617 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37618 led->xpad = xpad;
37619 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37620 index fe1df23..5b710f3 100644
37621 --- a/drivers/input/mouse/psmouse.h
37622 +++ b/drivers/input/mouse/psmouse.h
37623 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37624 ssize_t (*set)(struct psmouse *psmouse, void *data,
37625 const char *buf, size_t count);
37626 bool protect;
37627 -};
37628 +} __do_const;
37629 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37630
37631 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37632 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37633 index 4c842c3..590b0bf 100644
37634 --- a/drivers/input/mousedev.c
37635 +++ b/drivers/input/mousedev.c
37636 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37637
37638 spin_unlock_irq(&client->packet_lock);
37639
37640 - if (copy_to_user(buffer, data, count))
37641 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37642 return -EFAULT;
37643
37644 return count;
37645 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37646 index 25fc597..558bf3b 100644
37647 --- a/drivers/input/serio/serio.c
37648 +++ b/drivers/input/serio/serio.c
37649 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37650 */
37651 static void serio_init_port(struct serio *serio)
37652 {
37653 - static atomic_t serio_no = ATOMIC_INIT(0);
37654 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37655
37656 __module_get(THIS_MODULE);
37657
37658 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37659 mutex_init(&serio->drv_mutex);
37660 device_initialize(&serio->dev);
37661 dev_set_name(&serio->dev, "serio%ld",
37662 - (long)atomic_inc_return(&serio_no) - 1);
37663 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37664 serio->dev.bus = &serio_bus;
37665 serio->dev.release = serio_release_port;
37666 serio->dev.groups = serio_device_attr_groups;
37667 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37668 index ddbdaca..be18a78 100644
37669 --- a/drivers/iommu/iommu.c
37670 +++ b/drivers/iommu/iommu.c
37671 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37672 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37673 {
37674 bus_register_notifier(bus, &iommu_bus_nb);
37675 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37676 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37677 }
37678
37679 /**
37680 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37681 index 89562a8..218999b 100644
37682 --- a/drivers/isdn/capi/capi.c
37683 +++ b/drivers/isdn/capi/capi.c
37684 @@ -81,8 +81,8 @@ struct capiminor {
37685
37686 struct capi20_appl *ap;
37687 u32 ncci;
37688 - atomic_t datahandle;
37689 - atomic_t msgid;
37690 + atomic_unchecked_t datahandle;
37691 + atomic_unchecked_t msgid;
37692
37693 struct tty_port port;
37694 int ttyinstop;
37695 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37696 capimsg_setu16(s, 2, mp->ap->applid);
37697 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37698 capimsg_setu8 (s, 5, CAPI_RESP);
37699 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37700 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37701 capimsg_setu32(s, 8, mp->ncci);
37702 capimsg_setu16(s, 12, datahandle);
37703 }
37704 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37705 mp->outbytes -= len;
37706 spin_unlock_bh(&mp->outlock);
37707
37708 - datahandle = atomic_inc_return(&mp->datahandle);
37709 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37710 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37711 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37712 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37713 capimsg_setu16(skb->data, 2, mp->ap->applid);
37714 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37715 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37716 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37717 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37718 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37719 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37720 capimsg_setu16(skb->data, 16, len); /* Data length */
37721 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37722 index 67abf3f..076b3a6 100644
37723 --- a/drivers/isdn/gigaset/interface.c
37724 +++ b/drivers/isdn/gigaset/interface.c
37725 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37726 }
37727 tty->driver_data = cs;
37728
37729 - ++cs->port.count;
37730 + atomic_inc(&cs->port.count);
37731
37732 - if (cs->port.count == 1) {
37733 + if (atomic_read(&cs->port.count) == 1) {
37734 tty_port_tty_set(&cs->port, tty);
37735 tty->low_latency = 1;
37736 }
37737 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37738
37739 if (!cs->connected)
37740 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37741 - else if (!cs->port.count)
37742 + else if (!atomic_read(&cs->port.count))
37743 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37744 - else if (!--cs->port.count)
37745 + else if (!atomic_dec_return(&cs->port.count))
37746 tty_port_tty_set(&cs->port, NULL);
37747
37748 mutex_unlock(&cs->mutex);
37749 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37750 index 821f7ac..28d4030 100644
37751 --- a/drivers/isdn/hardware/avm/b1.c
37752 +++ b/drivers/isdn/hardware/avm/b1.c
37753 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37754 }
37755 if (left) {
37756 if (t4file->user) {
37757 - if (copy_from_user(buf, dp, left))
37758 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37759 return -EFAULT;
37760 } else {
37761 memcpy(buf, dp, left);
37762 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37763 }
37764 if (left) {
37765 if (config->user) {
37766 - if (copy_from_user(buf, dp, left))
37767 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37768 return -EFAULT;
37769 } else {
37770 memcpy(buf, dp, left);
37771 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37772 index e09dc8a..15e2efb 100644
37773 --- a/drivers/isdn/i4l/isdn_tty.c
37774 +++ b/drivers/isdn/i4l/isdn_tty.c
37775 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37776
37777 #ifdef ISDN_DEBUG_MODEM_OPEN
37778 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37779 - port->count);
37780 + atomic_read(&port->count));
37781 #endif
37782 - port->count++;
37783 + atomic_inc(&port->count);
37784 port->tty = tty;
37785 /*
37786 * Start up serial port
37787 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37788 #endif
37789 return;
37790 }
37791 - if ((tty->count == 1) && (port->count != 1)) {
37792 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37793 /*
37794 * Uh, oh. tty->count is 1, which means that the tty
37795 * structure will be freed. Info->count should always
37796 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37797 * serial port won't be shutdown.
37798 */
37799 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37800 - "info->count is %d\n", port->count);
37801 - port->count = 1;
37802 + "info->count is %d\n", atomic_read(&port->count));
37803 + atomic_set(&port->count, 1);
37804 }
37805 - if (--port->count < 0) {
37806 + if (atomic_dec_return(&port->count) < 0) {
37807 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37808 - info->line, port->count);
37809 - port->count = 0;
37810 + info->line, atomic_read(&port->count));
37811 + atomic_set(&port->count, 0);
37812 }
37813 - if (port->count) {
37814 + if (atomic_read(&port->count)) {
37815 #ifdef ISDN_DEBUG_MODEM_OPEN
37816 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37817 #endif
37818 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37819 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37820 return;
37821 isdn_tty_shutdown(info);
37822 - port->count = 0;
37823 + atomic_set(&port->count, 0);
37824 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37825 port->tty = NULL;
37826 wake_up_interruptible(&port->open_wait);
37827 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37828 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37829 modem_info *info = &dev->mdm.info[i];
37830
37831 - if (info->port.count == 0)
37832 + if (atomic_read(&info->port.count) == 0)
37833 continue;
37834 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37835 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37836 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37837 index e74df7c..03a03ba 100644
37838 --- a/drivers/isdn/icn/icn.c
37839 +++ b/drivers/isdn/icn/icn.c
37840 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37841 if (count > len)
37842 count = len;
37843 if (user) {
37844 - if (copy_from_user(msg, buf, count))
37845 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37846 return -EFAULT;
37847 } else
37848 memcpy(msg, buf, count);
37849 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37850 index 6a8405d..0bd1c7e 100644
37851 --- a/drivers/leds/leds-clevo-mail.c
37852 +++ b/drivers/leds/leds-clevo-mail.c
37853 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37854 * detected as working, but in reality it is not) as low as
37855 * possible.
37856 */
37857 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37858 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37859 {
37860 .callback = clevo_mail_led_dmi_callback,
37861 .ident = "Clevo D410J",
37862 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37863 index ec9b287..65c9bf4 100644
37864 --- a/drivers/leds/leds-ss4200.c
37865 +++ b/drivers/leds/leds-ss4200.c
37866 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37867 * detected as working, but in reality it is not) as low as
37868 * possible.
37869 */
37870 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37871 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37872 {
37873 .callback = ss4200_led_dmi_callback,
37874 .ident = "Intel SS4200-E",
37875 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37876 index a5ebc00..982886f 100644
37877 --- a/drivers/lguest/core.c
37878 +++ b/drivers/lguest/core.c
37879 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37880 * it's worked so far. The end address needs +1 because __get_vm_area
37881 * allocates an extra guard page, so we need space for that.
37882 */
37883 +
37884 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37885 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37886 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37887 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37888 +#else
37889 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37890 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37891 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37892 +#endif
37893 +
37894 if (!switcher_vma) {
37895 err = -ENOMEM;
37896 printk("lguest: could not map switcher pages high\n");
37897 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37898 * Now the Switcher is mapped at the right address, we can't fail!
37899 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37900 */
37901 - memcpy(switcher_vma->addr, start_switcher_text,
37902 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37903 end_switcher_text - start_switcher_text);
37904
37905 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37906 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37907 index 3b62be16..e33134a 100644
37908 --- a/drivers/lguest/page_tables.c
37909 +++ b/drivers/lguest/page_tables.c
37910 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37911 /*:*/
37912
37913 #ifdef CONFIG_X86_PAE
37914 -static void release_pmd(pmd_t *spmd)
37915 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37916 {
37917 /* If the entry's not present, there's nothing to release. */
37918 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37919 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37920 index 4af12e1..0e89afe 100644
37921 --- a/drivers/lguest/x86/core.c
37922 +++ b/drivers/lguest/x86/core.c
37923 @@ -59,7 +59,7 @@ static struct {
37924 /* Offset from where switcher.S was compiled to where we've copied it */
37925 static unsigned long switcher_offset(void)
37926 {
37927 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37928 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37929 }
37930
37931 /* This cpu's struct lguest_pages. */
37932 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37933 * These copies are pretty cheap, so we do them unconditionally: */
37934 /* Save the current Host top-level page directory.
37935 */
37936 +
37937 +#ifdef CONFIG_PAX_PER_CPU_PGD
37938 + pages->state.host_cr3 = read_cr3();
37939 +#else
37940 pages->state.host_cr3 = __pa(current->mm->pgd);
37941 +#endif
37942 +
37943 /*
37944 * Set up the Guest's page tables to see this CPU's pages (and no
37945 * other CPU's pages).
37946 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37947 * compiled-in switcher code and the high-mapped copy we just made.
37948 */
37949 for (i = 0; i < IDT_ENTRIES; i++)
37950 - default_idt_entries[i] += switcher_offset();
37951 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37952
37953 /*
37954 * Set up the Switcher's per-cpu areas.
37955 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37956 * it will be undisturbed when we switch. To change %cs and jump we
37957 * need this structure to feed to Intel's "lcall" instruction.
37958 */
37959 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37960 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37961 lguest_entry.segment = LGUEST_CS;
37962
37963 /*
37964 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37965 index 40634b0..4f5855e 100644
37966 --- a/drivers/lguest/x86/switcher_32.S
37967 +++ b/drivers/lguest/x86/switcher_32.S
37968 @@ -87,6 +87,7 @@
37969 #include <asm/page.h>
37970 #include <asm/segment.h>
37971 #include <asm/lguest.h>
37972 +#include <asm/processor-flags.h>
37973
37974 // We mark the start of the code to copy
37975 // It's placed in .text tho it's never run here
37976 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37977 // Changes type when we load it: damn Intel!
37978 // For after we switch over our page tables
37979 // That entry will be read-only: we'd crash.
37980 +
37981 +#ifdef CONFIG_PAX_KERNEXEC
37982 + mov %cr0, %edx
37983 + xor $X86_CR0_WP, %edx
37984 + mov %edx, %cr0
37985 +#endif
37986 +
37987 movl $(GDT_ENTRY_TSS*8), %edx
37988 ltr %dx
37989
37990 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37991 // Let's clear it again for our return.
37992 // The GDT descriptor of the Host
37993 // Points to the table after two "size" bytes
37994 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37995 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37996 // Clear "used" from type field (byte 5, bit 2)
37997 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37998 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37999 +
38000 +#ifdef CONFIG_PAX_KERNEXEC
38001 + mov %cr0, %eax
38002 + xor $X86_CR0_WP, %eax
38003 + mov %eax, %cr0
38004 +#endif
38005
38006 // Once our page table's switched, the Guest is live!
38007 // The Host fades as we run this final step.
38008 @@ -295,13 +309,12 @@ deliver_to_host:
38009 // I consulted gcc, and it gave
38010 // These instructions, which I gladly credit:
38011 leal (%edx,%ebx,8), %eax
38012 - movzwl (%eax),%edx
38013 - movl 4(%eax), %eax
38014 - xorw %ax, %ax
38015 - orl %eax, %edx
38016 + movl 4(%eax), %edx
38017 + movw (%eax), %dx
38018 // Now the address of the handler's in %edx
38019 // We call it now: its "iret" drops us home.
38020 - jmp *%edx
38021 + ljmp $__KERNEL_CS, $1f
38022 +1: jmp *%edx
38023
38024 // Every interrupt can come to us here
38025 // But we must truly tell each apart.
38026 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38027 index 7155945..4bcc562 100644
38028 --- a/drivers/md/bitmap.c
38029 +++ b/drivers/md/bitmap.c
38030 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38031 chunk_kb ? "KB" : "B");
38032 if (bitmap->storage.file) {
38033 seq_printf(seq, ", file: ");
38034 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38035 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38036 }
38037
38038 seq_printf(seq, "\n");
38039 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38040 index eee353d..74504c4 100644
38041 --- a/drivers/md/dm-ioctl.c
38042 +++ b/drivers/md/dm-ioctl.c
38043 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38044 cmd == DM_LIST_VERSIONS_CMD)
38045 return 0;
38046
38047 - if ((cmd == DM_DEV_CREATE_CMD)) {
38048 + if (cmd == DM_DEV_CREATE_CMD) {
38049 if (!*param->name) {
38050 DMWARN("name not supplied when creating device");
38051 return -EINVAL;
38052 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38053 index 7f24190..0e18099 100644
38054 --- a/drivers/md/dm-raid1.c
38055 +++ b/drivers/md/dm-raid1.c
38056 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38057
38058 struct mirror {
38059 struct mirror_set *ms;
38060 - atomic_t error_count;
38061 + atomic_unchecked_t error_count;
38062 unsigned long error_type;
38063 struct dm_dev *dev;
38064 sector_t offset;
38065 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38066 struct mirror *m;
38067
38068 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38069 - if (!atomic_read(&m->error_count))
38070 + if (!atomic_read_unchecked(&m->error_count))
38071 return m;
38072
38073 return NULL;
38074 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38075 * simple way to tell if a device has encountered
38076 * errors.
38077 */
38078 - atomic_inc(&m->error_count);
38079 + atomic_inc_unchecked(&m->error_count);
38080
38081 if (test_and_set_bit(error_type, &m->error_type))
38082 return;
38083 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38084 struct mirror *m = get_default_mirror(ms);
38085
38086 do {
38087 - if (likely(!atomic_read(&m->error_count)))
38088 + if (likely(!atomic_read_unchecked(&m->error_count)))
38089 return m;
38090
38091 if (m-- == ms->mirror)
38092 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
38093 {
38094 struct mirror *default_mirror = get_default_mirror(m->ms);
38095
38096 - return !atomic_read(&default_mirror->error_count);
38097 + return !atomic_read_unchecked(&default_mirror->error_count);
38098 }
38099
38100 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38101 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38102 */
38103 if (likely(region_in_sync(ms, region, 1)))
38104 m = choose_mirror(ms, bio->bi_sector);
38105 - else if (m && atomic_read(&m->error_count))
38106 + else if (m && atomic_read_unchecked(&m->error_count))
38107 m = NULL;
38108
38109 if (likely(m))
38110 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38111 }
38112
38113 ms->mirror[mirror].ms = ms;
38114 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38115 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38116 ms->mirror[mirror].error_type = 0;
38117 ms->mirror[mirror].offset = offset;
38118
38119 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
38120 */
38121 static char device_status_char(struct mirror *m)
38122 {
38123 - if (!atomic_read(&(m->error_count)))
38124 + if (!atomic_read_unchecked(&(m->error_count)))
38125 return 'A';
38126
38127 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38128 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38129 index aaecefa..23b3026 100644
38130 --- a/drivers/md/dm-stripe.c
38131 +++ b/drivers/md/dm-stripe.c
38132 @@ -20,7 +20,7 @@ struct stripe {
38133 struct dm_dev *dev;
38134 sector_t physical_start;
38135
38136 - atomic_t error_count;
38137 + atomic_unchecked_t error_count;
38138 };
38139
38140 struct stripe_c {
38141 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38142 kfree(sc);
38143 return r;
38144 }
38145 - atomic_set(&(sc->stripe[i].error_count), 0);
38146 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38147 }
38148
38149 ti->private = sc;
38150 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38151 DMEMIT("%d ", sc->stripes);
38152 for (i = 0; i < sc->stripes; i++) {
38153 DMEMIT("%s ", sc->stripe[i].dev->name);
38154 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38155 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38156 'D' : 'A';
38157 }
38158 buffer[i] = '\0';
38159 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38160 */
38161 for (i = 0; i < sc->stripes; i++)
38162 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38163 - atomic_inc(&(sc->stripe[i].error_count));
38164 - if (atomic_read(&(sc->stripe[i].error_count)) <
38165 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38166 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38167 DM_IO_ERROR_THRESHOLD)
38168 schedule_work(&sc->trigger_event);
38169 }
38170 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38171 index daf25d0..d74f49f 100644
38172 --- a/drivers/md/dm-table.c
38173 +++ b/drivers/md/dm-table.c
38174 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38175 if (!dev_size)
38176 return 0;
38177
38178 - if ((start >= dev_size) || (start + len > dev_size)) {
38179 + if ((start >= dev_size) || (len > dev_size - start)) {
38180 DMWARN("%s: %s too small for target: "
38181 "start=%llu, len=%llu, dev_size=%llu",
38182 dm_device_name(ti->table->md), bdevname(bdev, b),
38183 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38184 index 4d6e853..a234157 100644
38185 --- a/drivers/md/dm-thin-metadata.c
38186 +++ b/drivers/md/dm-thin-metadata.c
38187 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38188 {
38189 pmd->info.tm = pmd->tm;
38190 pmd->info.levels = 2;
38191 - pmd->info.value_type.context = pmd->data_sm;
38192 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38193 pmd->info.value_type.size = sizeof(__le64);
38194 pmd->info.value_type.inc = data_block_inc;
38195 pmd->info.value_type.dec = data_block_dec;
38196 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38197
38198 pmd->bl_info.tm = pmd->tm;
38199 pmd->bl_info.levels = 1;
38200 - pmd->bl_info.value_type.context = pmd->data_sm;
38201 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38202 pmd->bl_info.value_type.size = sizeof(__le64);
38203 pmd->bl_info.value_type.inc = data_block_inc;
38204 pmd->bl_info.value_type.dec = data_block_dec;
38205 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38206 index 0d8f086..f5a91d5 100644
38207 --- a/drivers/md/dm.c
38208 +++ b/drivers/md/dm.c
38209 @@ -170,9 +170,9 @@ struct mapped_device {
38210 /*
38211 * Event handling.
38212 */
38213 - atomic_t event_nr;
38214 + atomic_unchecked_t event_nr;
38215 wait_queue_head_t eventq;
38216 - atomic_t uevent_seq;
38217 + atomic_unchecked_t uevent_seq;
38218 struct list_head uevent_list;
38219 spinlock_t uevent_lock; /* Protect access to uevent_list */
38220
38221 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
38222 rwlock_init(&md->map_lock);
38223 atomic_set(&md->holders, 1);
38224 atomic_set(&md->open_count, 0);
38225 - atomic_set(&md->event_nr, 0);
38226 - atomic_set(&md->uevent_seq, 0);
38227 + atomic_set_unchecked(&md->event_nr, 0);
38228 + atomic_set_unchecked(&md->uevent_seq, 0);
38229 INIT_LIST_HEAD(&md->uevent_list);
38230 spin_lock_init(&md->uevent_lock);
38231
38232 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38233
38234 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38235
38236 - atomic_inc(&md->event_nr);
38237 + atomic_inc_unchecked(&md->event_nr);
38238 wake_up(&md->eventq);
38239 }
38240
38241 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38242
38243 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38244 {
38245 - return atomic_add_return(1, &md->uevent_seq);
38246 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38247 }
38248
38249 uint32_t dm_get_event_nr(struct mapped_device *md)
38250 {
38251 - return atomic_read(&md->event_nr);
38252 + return atomic_read_unchecked(&md->event_nr);
38253 }
38254
38255 int dm_wait_event(struct mapped_device *md, int event_nr)
38256 {
38257 return wait_event_interruptible(md->eventq,
38258 - (event_nr != atomic_read(&md->event_nr)));
38259 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38260 }
38261
38262 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38263 diff --git a/drivers/md/md.c b/drivers/md/md.c
38264 index f363135..9b38815 100644
38265 --- a/drivers/md/md.c
38266 +++ b/drivers/md/md.c
38267 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38268 * start build, activate spare
38269 */
38270 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38271 -static atomic_t md_event_count;
38272 +static atomic_unchecked_t md_event_count;
38273 void md_new_event(struct mddev *mddev)
38274 {
38275 - atomic_inc(&md_event_count);
38276 + atomic_inc_unchecked(&md_event_count);
38277 wake_up(&md_event_waiters);
38278 }
38279 EXPORT_SYMBOL_GPL(md_new_event);
38280 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38281 */
38282 static void md_new_event_inintr(struct mddev *mddev)
38283 {
38284 - atomic_inc(&md_event_count);
38285 + atomic_inc_unchecked(&md_event_count);
38286 wake_up(&md_event_waiters);
38287 }
38288
38289 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38290 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38291 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38292 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38293 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38294 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38295
38296 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38297 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38298 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38299 else
38300 sb->resync_offset = cpu_to_le64(0);
38301
38302 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38303 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38304
38305 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38306 sb->size = cpu_to_le64(mddev->dev_sectors);
38307 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38308 static ssize_t
38309 errors_show(struct md_rdev *rdev, char *page)
38310 {
38311 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38312 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38313 }
38314
38315 static ssize_t
38316 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38317 char *e;
38318 unsigned long n = simple_strtoul(buf, &e, 10);
38319 if (*buf && (*e == 0 || *e == '\n')) {
38320 - atomic_set(&rdev->corrected_errors, n);
38321 + atomic_set_unchecked(&rdev->corrected_errors, n);
38322 return len;
38323 }
38324 return -EINVAL;
38325 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38326 rdev->sb_loaded = 0;
38327 rdev->bb_page = NULL;
38328 atomic_set(&rdev->nr_pending, 0);
38329 - atomic_set(&rdev->read_errors, 0);
38330 - atomic_set(&rdev->corrected_errors, 0);
38331 + atomic_set_unchecked(&rdev->read_errors, 0);
38332 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38333
38334 INIT_LIST_HEAD(&rdev->same_set);
38335 init_waitqueue_head(&rdev->blocked_wait);
38336 @@ -6987,7 +6987,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38337
38338 spin_unlock(&pers_lock);
38339 seq_printf(seq, "\n");
38340 - seq->poll_event = atomic_read(&md_event_count);
38341 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38342 return 0;
38343 }
38344 if (v == (void*)2) {
38345 @@ -7090,7 +7090,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38346 return error;
38347
38348 seq = file->private_data;
38349 - seq->poll_event = atomic_read(&md_event_count);
38350 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38351 return error;
38352 }
38353
38354 @@ -7104,7 +7104,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38355 /* always allow read */
38356 mask = POLLIN | POLLRDNORM;
38357
38358 - if (seq->poll_event != atomic_read(&md_event_count))
38359 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38360 mask |= POLLERR | POLLPRI;
38361 return mask;
38362 }
38363 @@ -7148,7 +7148,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38364 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38365 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38366 (int)part_stat_read(&disk->part0, sectors[1]) -
38367 - atomic_read(&disk->sync_io);
38368 + atomic_read_unchecked(&disk->sync_io);
38369 /* sync IO will cause sync_io to increase before the disk_stats
38370 * as sync_io is counted when a request starts, and
38371 * disk_stats is counted when it completes.
38372 diff --git a/drivers/md/md.h b/drivers/md/md.h
38373 index eca59c3..7c42285 100644
38374 --- a/drivers/md/md.h
38375 +++ b/drivers/md/md.h
38376 @@ -94,13 +94,13 @@ struct md_rdev {
38377 * only maintained for arrays that
38378 * support hot removal
38379 */
38380 - atomic_t read_errors; /* number of consecutive read errors that
38381 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38382 * we have tried to ignore.
38383 */
38384 struct timespec last_read_error; /* monotonic time since our
38385 * last read error
38386 */
38387 - atomic_t corrected_errors; /* number of corrected read errors,
38388 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38389 * for reporting to userspace and storing
38390 * in superblock.
38391 */
38392 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38393
38394 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38395 {
38396 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38397 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38398 }
38399
38400 struct md_personality
38401 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38402 index 1cbfc6b..56e1dbb 100644
38403 --- a/drivers/md/persistent-data/dm-space-map.h
38404 +++ b/drivers/md/persistent-data/dm-space-map.h
38405 @@ -60,6 +60,7 @@ struct dm_space_map {
38406 int (*root_size)(struct dm_space_map *sm, size_t *result);
38407 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38408 };
38409 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38410
38411 /*----------------------------------------------------------------*/
38412
38413 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38414 index fd86b37..a5389ef 100644
38415 --- a/drivers/md/raid1.c
38416 +++ b/drivers/md/raid1.c
38417 @@ -1821,7 +1821,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38418 if (r1_sync_page_io(rdev, sect, s,
38419 bio->bi_io_vec[idx].bv_page,
38420 READ) != 0)
38421 - atomic_add(s, &rdev->corrected_errors);
38422 + atomic_add_unchecked(s, &rdev->corrected_errors);
38423 }
38424 sectors -= s;
38425 sect += s;
38426 @@ -2043,7 +2043,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38427 test_bit(In_sync, &rdev->flags)) {
38428 if (r1_sync_page_io(rdev, sect, s,
38429 conf->tmppage, READ)) {
38430 - atomic_add(s, &rdev->corrected_errors);
38431 + atomic_add_unchecked(s, &rdev->corrected_errors);
38432 printk(KERN_INFO
38433 "md/raid1:%s: read error corrected "
38434 "(%d sectors at %llu on %s)\n",
38435 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38436 index b3898d4..23a462b 100644
38437 --- a/drivers/md/raid10.c
38438 +++ b/drivers/md/raid10.c
38439 @@ -1881,7 +1881,7 @@ static void end_sync_read(struct bio *bio, int error)
38440 /* The write handler will notice the lack of
38441 * R10BIO_Uptodate and record any errors etc
38442 */
38443 - atomic_add(r10_bio->sectors,
38444 + atomic_add_unchecked(r10_bio->sectors,
38445 &conf->mirrors[d].rdev->corrected_errors);
38446
38447 /* for reconstruct, we always reschedule after a read.
38448 @@ -2230,7 +2230,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38449 {
38450 struct timespec cur_time_mon;
38451 unsigned long hours_since_last;
38452 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38453 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38454
38455 ktime_get_ts(&cur_time_mon);
38456
38457 @@ -2252,9 +2252,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38458 * overflowing the shift of read_errors by hours_since_last.
38459 */
38460 if (hours_since_last >= 8 * sizeof(read_errors))
38461 - atomic_set(&rdev->read_errors, 0);
38462 + atomic_set_unchecked(&rdev->read_errors, 0);
38463 else
38464 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38465 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38466 }
38467
38468 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38469 @@ -2308,8 +2308,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38470 return;
38471
38472 check_decay_read_errors(mddev, rdev);
38473 - atomic_inc(&rdev->read_errors);
38474 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38475 + atomic_inc_unchecked(&rdev->read_errors);
38476 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38477 char b[BDEVNAME_SIZE];
38478 bdevname(rdev->bdev, b);
38479
38480 @@ -2317,7 +2317,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38481 "md/raid10:%s: %s: Raid device exceeded "
38482 "read_error threshold [cur %d:max %d]\n",
38483 mdname(mddev), b,
38484 - atomic_read(&rdev->read_errors), max_read_errors);
38485 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38486 printk(KERN_NOTICE
38487 "md/raid10:%s: %s: Failing raid device\n",
38488 mdname(mddev), b);
38489 @@ -2472,7 +2472,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38490 sect +
38491 choose_data_offset(r10_bio, rdev)),
38492 bdevname(rdev->bdev, b));
38493 - atomic_add(s, &rdev->corrected_errors);
38494 + atomic_add_unchecked(s, &rdev->corrected_errors);
38495 }
38496
38497 rdev_dec_pending(rdev, mddev);
38498 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38499 index 94ce78e..df99e24 100644
38500 --- a/drivers/md/raid5.c
38501 +++ b/drivers/md/raid5.c
38502 @@ -1800,21 +1800,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38503 mdname(conf->mddev), STRIPE_SECTORS,
38504 (unsigned long long)s,
38505 bdevname(rdev->bdev, b));
38506 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38507 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38508 clear_bit(R5_ReadError, &sh->dev[i].flags);
38509 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38510 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38511 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38512
38513 - if (atomic_read(&rdev->read_errors))
38514 - atomic_set(&rdev->read_errors, 0);
38515 + if (atomic_read_unchecked(&rdev->read_errors))
38516 + atomic_set_unchecked(&rdev->read_errors, 0);
38517 } else {
38518 const char *bdn = bdevname(rdev->bdev, b);
38519 int retry = 0;
38520 int set_bad = 0;
38521
38522 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38523 - atomic_inc(&rdev->read_errors);
38524 + atomic_inc_unchecked(&rdev->read_errors);
38525 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38526 printk_ratelimited(
38527 KERN_WARNING
38528 @@ -1842,7 +1842,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38529 mdname(conf->mddev),
38530 (unsigned long long)s,
38531 bdn);
38532 - } else if (atomic_read(&rdev->read_errors)
38533 + } else if (atomic_read_unchecked(&rdev->read_errors)
38534 > conf->max_nr_stripes)
38535 printk(KERN_WARNING
38536 "md/raid:%s: Too many read errors, failing device %s.\n",
38537 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38538 index d33101a..6b13069 100644
38539 --- a/drivers/media/dvb-core/dvbdev.c
38540 +++ b/drivers/media/dvb-core/dvbdev.c
38541 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38542 const struct dvb_device *template, void *priv, int type)
38543 {
38544 struct dvb_device *dvbdev;
38545 - struct file_operations *dvbdevfops;
38546 + file_operations_no_const *dvbdevfops;
38547 struct device *clsdev;
38548 int minor;
38549 int id;
38550 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38551 index 404f63a..4796533 100644
38552 --- a/drivers/media/dvb-frontends/dib3000.h
38553 +++ b/drivers/media/dvb-frontends/dib3000.h
38554 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38555 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38556 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38557 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38558 -};
38559 +} __no_const;
38560
38561 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
38562 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38563 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38564 index bc78354..42c9459 100644
38565 --- a/drivers/media/pci/cx88/cx88-video.c
38566 +++ b/drivers/media/pci/cx88/cx88-video.c
38567 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38568
38569 /* ------------------------------------------------------------------ */
38570
38571 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38572 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38573 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38574 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38575 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38576 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38577
38578 module_param_array(video_nr, int, NULL, 0444);
38579 module_param_array(vbi_nr, int, NULL, 0444);
38580 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38581 index 8e9a668..78d6310 100644
38582 --- a/drivers/media/platform/omap/omap_vout.c
38583 +++ b/drivers/media/platform/omap/omap_vout.c
38584 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38585 OMAP_VIDEO2,
38586 };
38587
38588 -static struct videobuf_queue_ops video_vbq_ops;
38589 /* Variables configurable through module params*/
38590 static u32 video1_numbuffers = 3;
38591 static u32 video2_numbuffers = 3;
38592 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38593 {
38594 struct videobuf_queue *q;
38595 struct omap_vout_device *vout = NULL;
38596 + static struct videobuf_queue_ops video_vbq_ops = {
38597 + .buf_setup = omap_vout_buffer_setup,
38598 + .buf_prepare = omap_vout_buffer_prepare,
38599 + .buf_release = omap_vout_buffer_release,
38600 + .buf_queue = omap_vout_buffer_queue,
38601 + };
38602
38603 vout = video_drvdata(file);
38604 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38605 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38606 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38607
38608 q = &vout->vbq;
38609 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38610 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38611 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38612 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38613 spin_lock_init(&vout->vbq_lock);
38614
38615 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38616 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38617 index b671e20..34088b7 100644
38618 --- a/drivers/media/platform/s5p-tv/mixer.h
38619 +++ b/drivers/media/platform/s5p-tv/mixer.h
38620 @@ -155,7 +155,7 @@ struct mxr_layer {
38621 /** layer index (unique identifier) */
38622 int idx;
38623 /** callbacks for layer methods */
38624 - struct mxr_layer_ops ops;
38625 + struct mxr_layer_ops *ops;
38626 /** format array */
38627 const struct mxr_format **fmt_array;
38628 /** size of format array */
38629 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38630 index b93a21f..2535195 100644
38631 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38632 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38633 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38634 {
38635 struct mxr_layer *layer;
38636 int ret;
38637 - struct mxr_layer_ops ops = {
38638 + static struct mxr_layer_ops ops = {
38639 .release = mxr_graph_layer_release,
38640 .buffer_set = mxr_graph_buffer_set,
38641 .stream_set = mxr_graph_stream_set,
38642 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38643 index 3b1670a..595c939 100644
38644 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38645 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38646 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38647 layer->update_buf = next;
38648 }
38649
38650 - layer->ops.buffer_set(layer, layer->update_buf);
38651 + layer->ops->buffer_set(layer, layer->update_buf);
38652
38653 if (done && done != layer->shadow_buf)
38654 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38655 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38656 index 1f3b743..e839271 100644
38657 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38658 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38659 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38660 layer->geo.src.height = layer->geo.src.full_height;
38661
38662 mxr_geometry_dump(mdev, &layer->geo);
38663 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38664 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38665 mxr_geometry_dump(mdev, &layer->geo);
38666 }
38667
38668 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38669 layer->geo.dst.full_width = mbus_fmt.width;
38670 layer->geo.dst.full_height = mbus_fmt.height;
38671 layer->geo.dst.field = mbus_fmt.field;
38672 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38673 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38674
38675 mxr_geometry_dump(mdev, &layer->geo);
38676 }
38677 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38678 /* set source size to highest accepted value */
38679 geo->src.full_width = max(geo->dst.full_width, pix->width);
38680 geo->src.full_height = max(geo->dst.full_height, pix->height);
38681 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38682 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38683 mxr_geometry_dump(mdev, &layer->geo);
38684 /* set cropping to total visible screen */
38685 geo->src.width = pix->width;
38686 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38687 geo->src.x_offset = 0;
38688 geo->src.y_offset = 0;
38689 /* assure consistency of geometry */
38690 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38691 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38692 mxr_geometry_dump(mdev, &layer->geo);
38693 /* set full size to lowest possible value */
38694 geo->src.full_width = 0;
38695 geo->src.full_height = 0;
38696 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38697 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38698 mxr_geometry_dump(mdev, &layer->geo);
38699
38700 /* returning results */
38701 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38702 target->width = s->r.width;
38703 target->height = s->r.height;
38704
38705 - layer->ops.fix_geometry(layer, stage, s->flags);
38706 + layer->ops->fix_geometry(layer, stage, s->flags);
38707
38708 /* retrieve update selection rectangle */
38709 res.left = target->x_offset;
38710 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38711 mxr_output_get(mdev);
38712
38713 mxr_layer_update_output(layer);
38714 - layer->ops.format_set(layer);
38715 + layer->ops->format_set(layer);
38716 /* enabling layer in hardware */
38717 spin_lock_irqsave(&layer->enq_slock, flags);
38718 layer->state = MXR_LAYER_STREAMING;
38719 spin_unlock_irqrestore(&layer->enq_slock, flags);
38720
38721 - layer->ops.stream_set(layer, MXR_ENABLE);
38722 + layer->ops->stream_set(layer, MXR_ENABLE);
38723 mxr_streamer_get(mdev);
38724
38725 return 0;
38726 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38727 spin_unlock_irqrestore(&layer->enq_slock, flags);
38728
38729 /* disabling layer in hardware */
38730 - layer->ops.stream_set(layer, MXR_DISABLE);
38731 + layer->ops->stream_set(layer, MXR_DISABLE);
38732 /* remove one streamer */
38733 mxr_streamer_put(mdev);
38734 /* allow changes in output configuration */
38735 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38736
38737 void mxr_layer_release(struct mxr_layer *layer)
38738 {
38739 - if (layer->ops.release)
38740 - layer->ops.release(layer);
38741 + if (layer->ops->release)
38742 + layer->ops->release(layer);
38743 }
38744
38745 void mxr_base_layer_release(struct mxr_layer *layer)
38746 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38747
38748 layer->mdev = mdev;
38749 layer->idx = idx;
38750 - layer->ops = *ops;
38751 + layer->ops = ops;
38752
38753 spin_lock_init(&layer->enq_slock);
38754 INIT_LIST_HEAD(&layer->enq_list);
38755 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38756 index 3d13a63..da31bf1 100644
38757 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38758 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38759 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38760 {
38761 struct mxr_layer *layer;
38762 int ret;
38763 - struct mxr_layer_ops ops = {
38764 + static struct mxr_layer_ops ops = {
38765 .release = mxr_vp_layer_release,
38766 .buffer_set = mxr_vp_buffer_set,
38767 .stream_set = mxr_vp_stream_set,
38768 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38769 index 643d80a..56bb96b 100644
38770 --- a/drivers/media/radio/radio-cadet.c
38771 +++ b/drivers/media/radio/radio-cadet.c
38772 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38773 unsigned char readbuf[RDS_BUFFER];
38774 int i = 0;
38775
38776 + if (count > RDS_BUFFER)
38777 + return -EFAULT;
38778 mutex_lock(&dev->lock);
38779 if (dev->rdsstat == 0)
38780 cadet_start_rds(dev);
38781 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38782 while (i < count && dev->rdsin != dev->rdsout)
38783 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38784
38785 - if (i && copy_to_user(data, readbuf, i))
38786 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38787 i = -EFAULT;
38788 unlock:
38789 mutex_unlock(&dev->lock);
38790 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38791 index 3940bb0..fb3952a 100644
38792 --- a/drivers/media/usb/dvb-usb/cxusb.c
38793 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38794 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38795
38796 struct dib0700_adapter_state {
38797 int (*set_param_save) (struct dvb_frontend *);
38798 -};
38799 +} __no_const;
38800
38801 static int dib7070_set_param_override(struct dvb_frontend *fe)
38802 {
38803 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38804 index 9382895..ac8093c 100644
38805 --- a/drivers/media/usb/dvb-usb/dw2102.c
38806 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38807 @@ -95,7 +95,7 @@ struct su3000_state {
38808
38809 struct s6x0_state {
38810 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38811 -};
38812 +} __no_const;
38813
38814 /* debug */
38815 static int dvb_usb_dw2102_debug;
38816 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38817 index aa6e7c7..4cd8061 100644
38818 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38819 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38820 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38821 struct file *file, void *fh, void *p);
38822 } u;
38823 void (*debug)(const void *arg, bool write_only);
38824 -};
38825 +} __do_const;
38826 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38827
38828 /* This control needs a priority check */
38829 #define INFO_FL_PRIO (1 << 0)
38830 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38831 struct video_device *vfd = video_devdata(file);
38832 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38833 bool write_only = false;
38834 - struct v4l2_ioctl_info default_info;
38835 + v4l2_ioctl_info_no_const default_info;
38836 const struct v4l2_ioctl_info *info;
38837 void *fh = file->private_data;
38838 struct v4l2_fh *vfh = NULL;
38839 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38840 index 29b2172..a7c5b31 100644
38841 --- a/drivers/memstick/host/r592.c
38842 +++ b/drivers/memstick/host/r592.c
38843 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38844 /* Executes one TPC (data is read/written from small or large fifo) */
38845 static void r592_execute_tpc(struct r592_device *dev)
38846 {
38847 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38848 + bool is_write;
38849 int len, error;
38850 u32 status, reg;
38851
38852 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38853 return;
38854 }
38855
38856 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38857 len = dev->req->long_data ?
38858 dev->req->sg.length : dev->req->data_len;
38859
38860 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38861 index fb69baa..3aeea2e 100644
38862 --- a/drivers/message/fusion/mptbase.c
38863 +++ b/drivers/message/fusion/mptbase.c
38864 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38865 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38866 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38867
38868 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38869 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38870 +#else
38871 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38872 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38873 +#endif
38874 +
38875 /*
38876 * Rounding UP to nearest 4-kB boundary here...
38877 */
38878 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38879 ioc->facts.GlobalCredits);
38880
38881 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38882 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38883 + NULL, NULL);
38884 +#else
38885 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38886 +#endif
38887 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38888 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38889 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38890 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38891 index fa43c39..daeb158 100644
38892 --- a/drivers/message/fusion/mptsas.c
38893 +++ b/drivers/message/fusion/mptsas.c
38894 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38895 return 0;
38896 }
38897
38898 +static inline void
38899 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38900 +{
38901 + if (phy_info->port_details) {
38902 + phy_info->port_details->rphy = rphy;
38903 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38904 + ioc->name, rphy));
38905 + }
38906 +
38907 + if (rphy) {
38908 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38909 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38910 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38911 + ioc->name, rphy, rphy->dev.release));
38912 + }
38913 +}
38914 +
38915 /* no mutex */
38916 static void
38917 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38918 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38919 return NULL;
38920 }
38921
38922 -static inline void
38923 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38924 -{
38925 - if (phy_info->port_details) {
38926 - phy_info->port_details->rphy = rphy;
38927 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38928 - ioc->name, rphy));
38929 - }
38930 -
38931 - if (rphy) {
38932 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38933 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38934 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38935 - ioc->name, rphy, rphy->dev.release));
38936 - }
38937 -}
38938 -
38939 static inline struct sas_port *
38940 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38941 {
38942 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38943 index 164afa7..b6b2e74 100644
38944 --- a/drivers/message/fusion/mptscsih.c
38945 +++ b/drivers/message/fusion/mptscsih.c
38946 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38947
38948 h = shost_priv(SChost);
38949
38950 - if (h) {
38951 - if (h->info_kbuf == NULL)
38952 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38953 - return h->info_kbuf;
38954 - h->info_kbuf[0] = '\0';
38955 + if (!h)
38956 + return NULL;
38957
38958 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38959 - h->info_kbuf[size-1] = '\0';
38960 - }
38961 + if (h->info_kbuf == NULL)
38962 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38963 + return h->info_kbuf;
38964 + h->info_kbuf[0] = '\0';
38965 +
38966 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38967 + h->info_kbuf[size-1] = '\0';
38968
38969 return h->info_kbuf;
38970 }
38971 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38972 index 8001aa6..b137580 100644
38973 --- a/drivers/message/i2o/i2o_proc.c
38974 +++ b/drivers/message/i2o/i2o_proc.c
38975 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38976 "Array Controller Device"
38977 };
38978
38979 -static char *chtostr(char *tmp, u8 *chars, int n)
38980 -{
38981 - tmp[0] = 0;
38982 - return strncat(tmp, (char *)chars, n);
38983 -}
38984 -
38985 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38986 char *group)
38987 {
38988 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38989 } *result;
38990
38991 i2o_exec_execute_ddm_table ddm_table;
38992 - char tmp[28 + 1];
38993
38994 result = kmalloc(sizeof(*result), GFP_KERNEL);
38995 if (!result)
38996 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38997
38998 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38999 seq_printf(seq, "%-#8x", ddm_table.module_id);
39000 - seq_printf(seq, "%-29s",
39001 - chtostr(tmp, ddm_table.module_name_version, 28));
39002 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39003 seq_printf(seq, "%9d ", ddm_table.data_size);
39004 seq_printf(seq, "%8d", ddm_table.code_size);
39005
39006 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39007
39008 i2o_driver_result_table *result;
39009 i2o_driver_store_table *dst;
39010 - char tmp[28 + 1];
39011
39012 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39013 if (result == NULL)
39014 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39015
39016 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39017 seq_printf(seq, "%-#8x", dst->module_id);
39018 - seq_printf(seq, "%-29s",
39019 - chtostr(tmp, dst->module_name_version, 28));
39020 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39021 + seq_printf(seq, "%-.28s", dst->module_name_version);
39022 + seq_printf(seq, "%-.8s", dst->date);
39023 seq_printf(seq, "%8d ", dst->module_size);
39024 seq_printf(seq, "%8d ", dst->mpb_size);
39025 seq_printf(seq, "0x%04x", dst->module_flags);
39026 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39027 // == (allow) 512d bytes (max)
39028 static u16 *work16 = (u16 *) work32;
39029 int token;
39030 - char tmp[16 + 1];
39031
39032 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39033
39034 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39035 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39036 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39037 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39038 - seq_printf(seq, "Vendor info : %s\n",
39039 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39040 - seq_printf(seq, "Product info : %s\n",
39041 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39042 - seq_printf(seq, "Description : %s\n",
39043 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39044 - seq_printf(seq, "Product rev. : %s\n",
39045 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39046 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39047 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39048 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39049 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39050
39051 seq_printf(seq, "Serial number : ");
39052 print_serial_number(seq, (u8 *) (work32 + 16),
39053 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39054 u8 pad[256]; // allow up to 256 byte (max) serial number
39055 } result;
39056
39057 - char tmp[24 + 1];
39058 -
39059 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39060
39061 if (token < 0) {
39062 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39063 }
39064
39065 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39066 - seq_printf(seq, "Module name : %s\n",
39067 - chtostr(tmp, result.module_name, 24));
39068 - seq_printf(seq, "Module revision : %s\n",
39069 - chtostr(tmp, result.module_rev, 8));
39070 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39071 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39072
39073 seq_printf(seq, "Serial number : ");
39074 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39075 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39076 u8 instance_number[4];
39077 } result;
39078
39079 - char tmp[64 + 1];
39080 -
39081 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39082
39083 if (token < 0) {
39084 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39085 return 0;
39086 }
39087
39088 - seq_printf(seq, "Device name : %s\n",
39089 - chtostr(tmp, result.device_name, 64));
39090 - seq_printf(seq, "Service name : %s\n",
39091 - chtostr(tmp, result.service_name, 64));
39092 - seq_printf(seq, "Physical name : %s\n",
39093 - chtostr(tmp, result.physical_location, 64));
39094 - seq_printf(seq, "Instance number : %s\n",
39095 - chtostr(tmp, result.instance_number, 4));
39096 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39097 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39098 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39099 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39100
39101 return 0;
39102 }
39103 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39104 index a8c08f3..155fe3d 100644
39105 --- a/drivers/message/i2o/iop.c
39106 +++ b/drivers/message/i2o/iop.c
39107 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39108
39109 spin_lock_irqsave(&c->context_list_lock, flags);
39110
39111 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39112 - atomic_inc(&c->context_list_counter);
39113 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39114 + atomic_inc_unchecked(&c->context_list_counter);
39115
39116 - entry->context = atomic_read(&c->context_list_counter);
39117 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39118
39119 list_add(&entry->list, &c->context_list);
39120
39121 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39122
39123 #if BITS_PER_LONG == 64
39124 spin_lock_init(&c->context_list_lock);
39125 - atomic_set(&c->context_list_counter, 0);
39126 + atomic_set_unchecked(&c->context_list_counter, 0);
39127 INIT_LIST_HEAD(&c->context_list);
39128 #endif
39129
39130 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39131 index 45ece11..8efa218 100644
39132 --- a/drivers/mfd/janz-cmodio.c
39133 +++ b/drivers/mfd/janz-cmodio.c
39134 @@ -13,6 +13,7 @@
39135
39136 #include <linux/kernel.h>
39137 #include <linux/module.h>
39138 +#include <linux/slab.h>
39139 #include <linux/init.h>
39140 #include <linux/pci.h>
39141 #include <linux/interrupt.h>
39142 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39143 index a5f9888..1c0ed56 100644
39144 --- a/drivers/mfd/twl4030-irq.c
39145 +++ b/drivers/mfd/twl4030-irq.c
39146 @@ -35,6 +35,7 @@
39147 #include <linux/of.h>
39148 #include <linux/irqdomain.h>
39149 #include <linux/i2c/twl.h>
39150 +#include <asm/pgtable.h>
39151
39152 #include "twl-core.h"
39153
39154 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39155 * Install an irq handler for each of the SIH modules;
39156 * clone dummy irq_chip since PIH can't *do* anything
39157 */
39158 - twl4030_irq_chip = dummy_irq_chip;
39159 - twl4030_irq_chip.name = "twl4030";
39160 + pax_open_kernel();
39161 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39162 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39163
39164 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39165 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39166 + pax_close_kernel();
39167
39168 for (i = irq_base; i < irq_end; i++) {
39169 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39170 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39171 index 277a8db..0e0b754 100644
39172 --- a/drivers/mfd/twl6030-irq.c
39173 +++ b/drivers/mfd/twl6030-irq.c
39174 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39175 * install an irq handler for each of the modules;
39176 * clone dummy irq_chip since PIH can't *do* anything
39177 */
39178 - twl6030_irq_chip = dummy_irq_chip;
39179 - twl6030_irq_chip.name = "twl6030";
39180 - twl6030_irq_chip.irq_set_type = NULL;
39181 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39182 + pax_open_kernel();
39183 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39184 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39185 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39186 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39187 + pax_close_kernel();
39188
39189 for (i = irq_base; i < irq_end; i++) {
39190 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39191 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39192 index f428d86..274c368 100644
39193 --- a/drivers/misc/c2port/core.c
39194 +++ b/drivers/misc/c2port/core.c
39195 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
39196 mutex_init(&c2dev->mutex);
39197
39198 /* Create binary file */
39199 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39200 + pax_open_kernel();
39201 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39202 + pax_close_kernel();
39203 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39204 if (unlikely(ret))
39205 goto error_device_create_bin_file;
39206 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39207 index 3aa9a96..59cf685 100644
39208 --- a/drivers/misc/kgdbts.c
39209 +++ b/drivers/misc/kgdbts.c
39210 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
39211 char before[BREAK_INSTR_SIZE];
39212 char after[BREAK_INSTR_SIZE];
39213
39214 - probe_kernel_read(before, (char *)kgdbts_break_test,
39215 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39216 BREAK_INSTR_SIZE);
39217 init_simple_test();
39218 ts.tst = plant_and_detach_test;
39219 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
39220 /* Activate test with initial breakpoint */
39221 if (!is_early)
39222 kgdb_breakpoint();
39223 - probe_kernel_read(after, (char *)kgdbts_break_test,
39224 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39225 BREAK_INSTR_SIZE);
39226 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39227 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39228 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39229 index 4a87e5c..76bdf5c 100644
39230 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39231 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39232 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39233 * the lid is closed. This leads to interrupts as soon as a little move
39234 * is done.
39235 */
39236 - atomic_inc(&lis3->count);
39237 + atomic_inc_unchecked(&lis3->count);
39238
39239 wake_up_interruptible(&lis3->misc_wait);
39240 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39241 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39242 if (lis3->pm_dev)
39243 pm_runtime_get_sync(lis3->pm_dev);
39244
39245 - atomic_set(&lis3->count, 0);
39246 + atomic_set_unchecked(&lis3->count, 0);
39247 return 0;
39248 }
39249
39250 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39251 add_wait_queue(&lis3->misc_wait, &wait);
39252 while (true) {
39253 set_current_state(TASK_INTERRUPTIBLE);
39254 - data = atomic_xchg(&lis3->count, 0);
39255 + data = atomic_xchg_unchecked(&lis3->count, 0);
39256 if (data)
39257 break;
39258
39259 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39260 struct lis3lv02d, miscdev);
39261
39262 poll_wait(file, &lis3->misc_wait, wait);
39263 - if (atomic_read(&lis3->count))
39264 + if (atomic_read_unchecked(&lis3->count))
39265 return POLLIN | POLLRDNORM;
39266 return 0;
39267 }
39268 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39269 index c439c82..1f20f57 100644
39270 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39271 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39272 @@ -297,7 +297,7 @@ struct lis3lv02d {
39273 struct input_polled_dev *idev; /* input device */
39274 struct platform_device *pdev; /* platform device */
39275 struct regulator_bulk_data regulators[2];
39276 - atomic_t count; /* interrupt count after last read */
39277 + atomic_unchecked_t count; /* interrupt count after last read */
39278 union axis_conversion ac; /* hw -> logical axis */
39279 int mapped_btns[3];
39280
39281 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39282 index 2f30bad..c4c13d0 100644
39283 --- a/drivers/misc/sgi-gru/gruhandles.c
39284 +++ b/drivers/misc/sgi-gru/gruhandles.c
39285 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39286 unsigned long nsec;
39287
39288 nsec = CLKS2NSEC(clks);
39289 - atomic_long_inc(&mcs_op_statistics[op].count);
39290 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39291 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39292 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39293 if (mcs_op_statistics[op].max < nsec)
39294 mcs_op_statistics[op].max = nsec;
39295 }
39296 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39297 index 950dbe9..eeef0f8 100644
39298 --- a/drivers/misc/sgi-gru/gruprocfs.c
39299 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39300 @@ -32,9 +32,9 @@
39301
39302 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39303
39304 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39305 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39306 {
39307 - unsigned long val = atomic_long_read(v);
39308 + unsigned long val = atomic_long_read_unchecked(v);
39309
39310 seq_printf(s, "%16lu %s\n", val, id);
39311 }
39312 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39313
39314 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39315 for (op = 0; op < mcsop_last; op++) {
39316 - count = atomic_long_read(&mcs_op_statistics[op].count);
39317 - total = atomic_long_read(&mcs_op_statistics[op].total);
39318 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39319 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39320 max = mcs_op_statistics[op].max;
39321 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39322 count ? total / count : 0, max);
39323 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39324 index 5c3ce24..4915ccb 100644
39325 --- a/drivers/misc/sgi-gru/grutables.h
39326 +++ b/drivers/misc/sgi-gru/grutables.h
39327 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39328 * GRU statistics.
39329 */
39330 struct gru_stats_s {
39331 - atomic_long_t vdata_alloc;
39332 - atomic_long_t vdata_free;
39333 - atomic_long_t gts_alloc;
39334 - atomic_long_t gts_free;
39335 - atomic_long_t gms_alloc;
39336 - atomic_long_t gms_free;
39337 - atomic_long_t gts_double_allocate;
39338 - atomic_long_t assign_context;
39339 - atomic_long_t assign_context_failed;
39340 - atomic_long_t free_context;
39341 - atomic_long_t load_user_context;
39342 - atomic_long_t load_kernel_context;
39343 - atomic_long_t lock_kernel_context;
39344 - atomic_long_t unlock_kernel_context;
39345 - atomic_long_t steal_user_context;
39346 - atomic_long_t steal_kernel_context;
39347 - atomic_long_t steal_context_failed;
39348 - atomic_long_t nopfn;
39349 - atomic_long_t asid_new;
39350 - atomic_long_t asid_next;
39351 - atomic_long_t asid_wrap;
39352 - atomic_long_t asid_reuse;
39353 - atomic_long_t intr;
39354 - atomic_long_t intr_cbr;
39355 - atomic_long_t intr_tfh;
39356 - atomic_long_t intr_spurious;
39357 - atomic_long_t intr_mm_lock_failed;
39358 - atomic_long_t call_os;
39359 - atomic_long_t call_os_wait_queue;
39360 - atomic_long_t user_flush_tlb;
39361 - atomic_long_t user_unload_context;
39362 - atomic_long_t user_exception;
39363 - atomic_long_t set_context_option;
39364 - atomic_long_t check_context_retarget_intr;
39365 - atomic_long_t check_context_unload;
39366 - atomic_long_t tlb_dropin;
39367 - atomic_long_t tlb_preload_page;
39368 - atomic_long_t tlb_dropin_fail_no_asid;
39369 - atomic_long_t tlb_dropin_fail_upm;
39370 - atomic_long_t tlb_dropin_fail_invalid;
39371 - atomic_long_t tlb_dropin_fail_range_active;
39372 - atomic_long_t tlb_dropin_fail_idle;
39373 - atomic_long_t tlb_dropin_fail_fmm;
39374 - atomic_long_t tlb_dropin_fail_no_exception;
39375 - atomic_long_t tfh_stale_on_fault;
39376 - atomic_long_t mmu_invalidate_range;
39377 - atomic_long_t mmu_invalidate_page;
39378 - atomic_long_t flush_tlb;
39379 - atomic_long_t flush_tlb_gru;
39380 - atomic_long_t flush_tlb_gru_tgh;
39381 - atomic_long_t flush_tlb_gru_zero_asid;
39382 + atomic_long_unchecked_t vdata_alloc;
39383 + atomic_long_unchecked_t vdata_free;
39384 + atomic_long_unchecked_t gts_alloc;
39385 + atomic_long_unchecked_t gts_free;
39386 + atomic_long_unchecked_t gms_alloc;
39387 + atomic_long_unchecked_t gms_free;
39388 + atomic_long_unchecked_t gts_double_allocate;
39389 + atomic_long_unchecked_t assign_context;
39390 + atomic_long_unchecked_t assign_context_failed;
39391 + atomic_long_unchecked_t free_context;
39392 + atomic_long_unchecked_t load_user_context;
39393 + atomic_long_unchecked_t load_kernel_context;
39394 + atomic_long_unchecked_t lock_kernel_context;
39395 + atomic_long_unchecked_t unlock_kernel_context;
39396 + atomic_long_unchecked_t steal_user_context;
39397 + atomic_long_unchecked_t steal_kernel_context;
39398 + atomic_long_unchecked_t steal_context_failed;
39399 + atomic_long_unchecked_t nopfn;
39400 + atomic_long_unchecked_t asid_new;
39401 + atomic_long_unchecked_t asid_next;
39402 + atomic_long_unchecked_t asid_wrap;
39403 + atomic_long_unchecked_t asid_reuse;
39404 + atomic_long_unchecked_t intr;
39405 + atomic_long_unchecked_t intr_cbr;
39406 + atomic_long_unchecked_t intr_tfh;
39407 + atomic_long_unchecked_t intr_spurious;
39408 + atomic_long_unchecked_t intr_mm_lock_failed;
39409 + atomic_long_unchecked_t call_os;
39410 + atomic_long_unchecked_t call_os_wait_queue;
39411 + atomic_long_unchecked_t user_flush_tlb;
39412 + atomic_long_unchecked_t user_unload_context;
39413 + atomic_long_unchecked_t user_exception;
39414 + atomic_long_unchecked_t set_context_option;
39415 + atomic_long_unchecked_t check_context_retarget_intr;
39416 + atomic_long_unchecked_t check_context_unload;
39417 + atomic_long_unchecked_t tlb_dropin;
39418 + atomic_long_unchecked_t tlb_preload_page;
39419 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39420 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39421 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39422 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39423 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39424 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39425 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39426 + atomic_long_unchecked_t tfh_stale_on_fault;
39427 + atomic_long_unchecked_t mmu_invalidate_range;
39428 + atomic_long_unchecked_t mmu_invalidate_page;
39429 + atomic_long_unchecked_t flush_tlb;
39430 + atomic_long_unchecked_t flush_tlb_gru;
39431 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39432 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39433
39434 - atomic_long_t copy_gpa;
39435 - atomic_long_t read_gpa;
39436 + atomic_long_unchecked_t copy_gpa;
39437 + atomic_long_unchecked_t read_gpa;
39438
39439 - atomic_long_t mesq_receive;
39440 - atomic_long_t mesq_receive_none;
39441 - atomic_long_t mesq_send;
39442 - atomic_long_t mesq_send_failed;
39443 - atomic_long_t mesq_noop;
39444 - atomic_long_t mesq_send_unexpected_error;
39445 - atomic_long_t mesq_send_lb_overflow;
39446 - atomic_long_t mesq_send_qlimit_reached;
39447 - atomic_long_t mesq_send_amo_nacked;
39448 - atomic_long_t mesq_send_put_nacked;
39449 - atomic_long_t mesq_page_overflow;
39450 - atomic_long_t mesq_qf_locked;
39451 - atomic_long_t mesq_qf_noop_not_full;
39452 - atomic_long_t mesq_qf_switch_head_failed;
39453 - atomic_long_t mesq_qf_unexpected_error;
39454 - atomic_long_t mesq_noop_unexpected_error;
39455 - atomic_long_t mesq_noop_lb_overflow;
39456 - atomic_long_t mesq_noop_qlimit_reached;
39457 - atomic_long_t mesq_noop_amo_nacked;
39458 - atomic_long_t mesq_noop_put_nacked;
39459 - atomic_long_t mesq_noop_page_overflow;
39460 + atomic_long_unchecked_t mesq_receive;
39461 + atomic_long_unchecked_t mesq_receive_none;
39462 + atomic_long_unchecked_t mesq_send;
39463 + atomic_long_unchecked_t mesq_send_failed;
39464 + atomic_long_unchecked_t mesq_noop;
39465 + atomic_long_unchecked_t mesq_send_unexpected_error;
39466 + atomic_long_unchecked_t mesq_send_lb_overflow;
39467 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39468 + atomic_long_unchecked_t mesq_send_amo_nacked;
39469 + atomic_long_unchecked_t mesq_send_put_nacked;
39470 + atomic_long_unchecked_t mesq_page_overflow;
39471 + atomic_long_unchecked_t mesq_qf_locked;
39472 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39473 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39474 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39475 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39476 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39477 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39478 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39479 + atomic_long_unchecked_t mesq_noop_put_nacked;
39480 + atomic_long_unchecked_t mesq_noop_page_overflow;
39481
39482 };
39483
39484 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39485 tghop_invalidate, mcsop_last};
39486
39487 struct mcs_op_statistic {
39488 - atomic_long_t count;
39489 - atomic_long_t total;
39490 + atomic_long_unchecked_t count;
39491 + atomic_long_unchecked_t total;
39492 unsigned long max;
39493 };
39494
39495 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39496
39497 #define STAT(id) do { \
39498 if (gru_options & OPT_STATS) \
39499 - atomic_long_inc(&gru_stats.id); \
39500 + atomic_long_inc_unchecked(&gru_stats.id); \
39501 } while (0)
39502
39503 #ifdef CONFIG_SGI_GRU_DEBUG
39504 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39505 index c862cd4..0d176fe 100644
39506 --- a/drivers/misc/sgi-xp/xp.h
39507 +++ b/drivers/misc/sgi-xp/xp.h
39508 @@ -288,7 +288,7 @@ struct xpc_interface {
39509 xpc_notify_func, void *);
39510 void (*received) (short, int, void *);
39511 enum xp_retval (*partid_to_nasids) (short, void *);
39512 -};
39513 +} __no_const;
39514
39515 extern struct xpc_interface xpc_interface;
39516
39517 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39518 index b94d5f7..7f494c5 100644
39519 --- a/drivers/misc/sgi-xp/xpc.h
39520 +++ b/drivers/misc/sgi-xp/xpc.h
39521 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39522 void (*received_payload) (struct xpc_channel *, void *);
39523 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39524 };
39525 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39526
39527 /* struct xpc_partition act_state values (for XPC HB) */
39528
39529 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39530 /* found in xpc_main.c */
39531 extern struct device *xpc_part;
39532 extern struct device *xpc_chan;
39533 -extern struct xpc_arch_operations xpc_arch_ops;
39534 +extern xpc_arch_operations_no_const xpc_arch_ops;
39535 extern int xpc_disengage_timelimit;
39536 extern int xpc_disengage_timedout;
39537 extern int xpc_activate_IRQ_rcvd;
39538 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39539 index d971817..33bdca5 100644
39540 --- a/drivers/misc/sgi-xp/xpc_main.c
39541 +++ b/drivers/misc/sgi-xp/xpc_main.c
39542 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39543 .notifier_call = xpc_system_die,
39544 };
39545
39546 -struct xpc_arch_operations xpc_arch_ops;
39547 +xpc_arch_operations_no_const xpc_arch_ops;
39548
39549 /*
39550 * Timer function to enforce the timelimit on the partition disengage.
39551 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39552
39553 if (((die_args->trapnr == X86_TRAP_MF) ||
39554 (die_args->trapnr == X86_TRAP_XF)) &&
39555 - !user_mode_vm(die_args->regs))
39556 + !user_mode(die_args->regs))
39557 xpc_die_deactivate();
39558
39559 break;
39560 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39561 index 6d8f701..35b6369 100644
39562 --- a/drivers/mmc/core/mmc_ops.c
39563 +++ b/drivers/mmc/core/mmc_ops.c
39564 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39565 void *data_buf;
39566 int is_on_stack;
39567
39568 - is_on_stack = object_is_on_stack(buf);
39569 + is_on_stack = object_starts_on_stack(buf);
39570 if (is_on_stack) {
39571 /*
39572 * dma onto stack is unsafe/nonportable, but callers to this
39573 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39574 index 53b8fd9..615b462 100644
39575 --- a/drivers/mmc/host/dw_mmc.h
39576 +++ b/drivers/mmc/host/dw_mmc.h
39577 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39578 int (*parse_dt)(struct dw_mci *host);
39579 int (*setup_bus)(struct dw_mci *host,
39580 struct device_node *slot_np, u8 bus_width);
39581 -};
39582 +} __do_const;
39583 #endif /* _DW_MMC_H_ */
39584 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39585 index 82a8de1..3c56ccb 100644
39586 --- a/drivers/mmc/host/sdhci-s3c.c
39587 +++ b/drivers/mmc/host/sdhci-s3c.c
39588 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39589 * we can use overriding functions instead of default.
39590 */
39591 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39592 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39593 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39594 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39595 + pax_open_kernel();
39596 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39597 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39598 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39599 + pax_close_kernel();
39600 }
39601
39602 /* It supports additional host capabilities if needed */
39603 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39604 index a4eb8b5..8c0628f 100644
39605 --- a/drivers/mtd/devices/doc2000.c
39606 +++ b/drivers/mtd/devices/doc2000.c
39607 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39608
39609 /* The ECC will not be calculated correctly if less than 512 is written */
39610 /* DBB-
39611 - if (len != 0x200 && eccbuf)
39612 + if (len != 0x200)
39613 printk(KERN_WARNING
39614 "ECC needs a full sector write (adr: %lx size %lx)\n",
39615 (long) to, (long) len);
39616 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39617 index 0c8bb6b..6f35deb 100644
39618 --- a/drivers/mtd/nand/denali.c
39619 +++ b/drivers/mtd/nand/denali.c
39620 @@ -24,6 +24,7 @@
39621 #include <linux/slab.h>
39622 #include <linux/mtd/mtd.h>
39623 #include <linux/module.h>
39624 +#include <linux/slab.h>
39625
39626 #include "denali.h"
39627
39628 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39629 index 51b9d6a..52af9a7 100644
39630 --- a/drivers/mtd/nftlmount.c
39631 +++ b/drivers/mtd/nftlmount.c
39632 @@ -24,6 +24,7 @@
39633 #include <asm/errno.h>
39634 #include <linux/delay.h>
39635 #include <linux/slab.h>
39636 +#include <linux/sched.h>
39637 #include <linux/mtd/mtd.h>
39638 #include <linux/mtd/nand.h>
39639 #include <linux/mtd/nftl.h>
39640 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39641 index 8dd6ba5..419cc1d 100644
39642 --- a/drivers/mtd/sm_ftl.c
39643 +++ b/drivers/mtd/sm_ftl.c
39644 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39645 #define SM_CIS_VENDOR_OFFSET 0x59
39646 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39647 {
39648 - struct attribute_group *attr_group;
39649 + attribute_group_no_const *attr_group;
39650 struct attribute **attributes;
39651 struct sm_sysfs_attribute *vendor_attribute;
39652
39653 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39654 index 045dc53..b1e5473 100644
39655 --- a/drivers/net/bonding/bond_main.c
39656 +++ b/drivers/net/bonding/bond_main.c
39657 @@ -4865,7 +4865,7 @@ static unsigned int bond_get_num_tx_queues(void)
39658 return tx_queues;
39659 }
39660
39661 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39662 +static struct rtnl_link_ops bond_link_ops = {
39663 .kind = "bond",
39664 .priv_size = sizeof(struct bonding),
39665 .setup = bond_setup,
39666 @@ -4990,8 +4990,8 @@ static void __exit bonding_exit(void)
39667
39668 bond_destroy_debugfs();
39669
39670 - rtnl_link_unregister(&bond_link_ops);
39671 unregister_pernet_subsys(&bond_net_ops);
39672 + rtnl_link_unregister(&bond_link_ops);
39673
39674 #ifdef CONFIG_NET_POLL_CONTROLLER
39675 /*
39676 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39677 index 70dba5d..11a0919 100644
39678 --- a/drivers/net/ethernet/8390/ax88796.c
39679 +++ b/drivers/net/ethernet/8390/ax88796.c
39680 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39681 if (ax->plat->reg_offsets)
39682 ei_local->reg_offset = ax->plat->reg_offsets;
39683 else {
39684 + resource_size_t _mem_size = mem_size;
39685 + do_div(_mem_size, 0x18);
39686 ei_local->reg_offset = ax->reg_offsets;
39687 for (ret = 0; ret < 0x18; ret++)
39688 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39689 + ax->reg_offsets[ret] = _mem_size * ret;
39690 }
39691
39692 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39693 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39694 index 0991534..8098e92 100644
39695 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39696 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39697 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39698 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39699 {
39700 /* RX_MODE controlling object */
39701 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39702 + bnx2x_init_rx_mode_obj(bp);
39703
39704 /* multicast configuration controlling object */
39705 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39706 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39707 index 10bc093..a2fb42a 100644
39708 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39709 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39710 @@ -2136,12 +2136,12 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
39711 break;
39712 default:
39713 BNX2X_ERR("Non valid capability ID\n");
39714 - rval = -EINVAL;
39715 + rval = 1;
39716 break;
39717 }
39718 } else {
39719 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39720 - rval = -EINVAL;
39721 + rval = 1;
39722 }
39723
39724 DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
39725 @@ -2167,12 +2167,12 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num)
39726 break;
39727 default:
39728 BNX2X_ERR("Non valid TC-ID\n");
39729 - rval = -EINVAL;
39730 + rval = 1;
39731 break;
39732 }
39733 } else {
39734 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39735 - rval = -EINVAL;
39736 + rval = 1;
39737 }
39738
39739 return rval;
39740 @@ -2185,7 +2185,7 @@ static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num)
39741 return -EINVAL;
39742 }
39743
39744 -static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39745 +static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39746 {
39747 struct bnx2x *bp = netdev_priv(netdev);
39748 DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
39749 @@ -2387,12 +2387,12 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
39750 break;
39751 default:
39752 BNX2X_ERR("Non valid featrue-ID\n");
39753 - rval = -EINVAL;
39754 + rval = 1;
39755 break;
39756 }
39757 } else {
39758 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39759 - rval = -EINVAL;
39760 + rval = 1;
39761 }
39762
39763 return rval;
39764 @@ -2428,12 +2428,12 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid,
39765 break;
39766 default:
39767 BNX2X_ERR("Non valid featrue-ID\n");
39768 - rval = -EINVAL;
39769 + rval = 1;
39770 break;
39771 }
39772 } else {
39773 DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
39774 - rval = -EINVAL;
39775 + rval = 1;
39776 }
39777
39778 return rval;
39779 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39780 index 5523da3..4fcf274 100644
39781 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39782 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39783 @@ -4767,7 +4767,7 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
39784 q);
39785 }
39786
39787 - if (!NO_FCOE(bp)) {
39788 + if (!NO_FCOE(bp) && CNIC_ENABLED(bp)) {
39789 fp = &bp->fp[FCOE_IDX(bp)];
39790 queue_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
39791
39792 @@ -13047,6 +13047,7 @@ static int bnx2x_unregister_cnic(struct net_device *dev)
39793 RCU_INIT_POINTER(bp->cnic_ops, NULL);
39794 mutex_unlock(&bp->cnic_mutex);
39795 synchronize_rcu();
39796 + bp->cnic_enabled = false;
39797 kfree(bp->cnic_kwq);
39798 bp->cnic_kwq = NULL;
39799
39800 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39801 index 09b625e..15b16fe 100644
39802 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39803 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39804 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39805 return rc;
39806 }
39807
39808 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39809 - struct bnx2x_rx_mode_obj *o)
39810 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39811 {
39812 if (CHIP_IS_E1x(bp)) {
39813 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39814 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39815 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39816 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39817 } else {
39818 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39819 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39820 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39821 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39822 }
39823 }
39824
39825 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39826 index adbd91b..58ec94a 100644
39827 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39828 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39829 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39830
39831 /********************* RX MODE ****************/
39832
39833 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39834 - struct bnx2x_rx_mode_obj *o);
39835 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39836
39837 /**
39838 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39839 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39840 index 6f9b74c..7f219b8 100644
39841 --- a/drivers/net/ethernet/broadcom/tg3.h
39842 +++ b/drivers/net/ethernet/broadcom/tg3.h
39843 @@ -146,6 +146,7 @@
39844 #define CHIPREV_ID_5750_A0 0x4000
39845 #define CHIPREV_ID_5750_A1 0x4001
39846 #define CHIPREV_ID_5750_A3 0x4003
39847 +#define CHIPREV_ID_5750_C1 0x4201
39848 #define CHIPREV_ID_5750_C2 0x4202
39849 #define CHIPREV_ID_5752_A0_HW 0x5000
39850 #define CHIPREV_ID_5752_A0 0x6000
39851 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39852 index 8cffcdf..aadf043 100644
39853 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39854 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39855 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39856 */
39857 struct l2t_skb_cb {
39858 arp_failure_handler_func arp_failure_handler;
39859 -};
39860 +} __no_const;
39861
39862 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39863
39864 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39865 index 4c83003..2a2a5b9 100644
39866 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39867 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39868 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39869 for (i=0; i<ETH_ALEN; i++) {
39870 tmp.addr[i] = dev->dev_addr[i];
39871 }
39872 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39873 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39874 break;
39875
39876 case DE4X5_SET_HWADDR: /* Set the hardware address */
39877 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39878 spin_lock_irqsave(&lp->lock, flags);
39879 memcpy(&statbuf, &lp->pktStats, ioc->len);
39880 spin_unlock_irqrestore(&lp->lock, flags);
39881 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39882 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39883 return -EFAULT;
39884 break;
39885 }
39886 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39887 index 4d6f3c5..449bc5c 100644
39888 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39889 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39890 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39891
39892 if (wrapped)
39893 newacc += 65536;
39894 - ACCESS_ONCE(*acc) = newacc;
39895 + ACCESS_ONCE_RW(*acc) = newacc;
39896 }
39897
39898 void be_parse_stats(struct be_adapter *adapter)
39899 @@ -759,8 +759,9 @@ static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter,
39900
39901 if (vlan_tx_tag_present(skb)) {
39902 vlan_tag = be_get_tx_vlan_tag(adapter, skb);
39903 - __vlan_put_tag(skb, vlan_tag);
39904 - skb->vlan_tci = 0;
39905 + skb = __vlan_put_tag(skb, vlan_tag);
39906 + if (skb)
39907 + skb->vlan_tci = 0;
39908 }
39909
39910 return skb;
39911 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39912 index 74d749e..eefb1bd 100644
39913 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39914 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39915 @@ -31,6 +31,8 @@
39916 #include <linux/netdevice.h>
39917 #include <linux/phy.h>
39918 #include <linux/platform_device.h>
39919 +#include <linux/interrupt.h>
39920 +#include <linux/irqreturn.h>
39921 #include <net/ip.h>
39922
39923 #include "ftgmac100.h"
39924 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39925 index b901a01..1ff32ee 100644
39926 --- a/drivers/net/ethernet/faraday/ftmac100.c
39927 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39928 @@ -31,6 +31,8 @@
39929 #include <linux/module.h>
39930 #include <linux/netdevice.h>
39931 #include <linux/platform_device.h>
39932 +#include <linux/interrupt.h>
39933 +#include <linux/irqreturn.h>
39934
39935 #include "ftmac100.h"
39936
39937 diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
39938 index a59f077..7925d77 100644
39939 --- a/drivers/net/ethernet/intel/e100.c
39940 +++ b/drivers/net/ethernet/intel/e100.c
39941 @@ -870,7 +870,7 @@ err_unlock:
39942 }
39943
39944 static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39945 - void (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39946 + int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39947 {
39948 struct cb *cb;
39949 unsigned long flags;
39950 @@ -888,10 +888,13 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39951 nic->cbs_avail--;
39952 cb->skb = skb;
39953
39954 + err = cb_prepare(nic, cb, skb);
39955 + if (err)
39956 + goto err_unlock;
39957 +
39958 if (unlikely(!nic->cbs_avail))
39959 err = -ENOSPC;
39960
39961 - cb_prepare(nic, cb, skb);
39962
39963 /* Order is important otherwise we'll be in a race with h/w:
39964 * set S-bit in current first, then clear S-bit in previous. */
39965 @@ -1091,7 +1094,7 @@ static void e100_get_defaults(struct nic *nic)
39966 nic->mii.mdio_write = mdio_write;
39967 }
39968
39969 -static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39970 +static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39971 {
39972 struct config *config = &cb->u.config;
39973 u8 *c = (u8 *)config;
39974 @@ -1181,6 +1184,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39975 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
39976 "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
39977 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
39978 + return 0;
39979 }
39980
39981 /*************************************************************************
39982 @@ -1331,7 +1335,7 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
39983 return fw;
39984 }
39985
39986 -static void e100_setup_ucode(struct nic *nic, struct cb *cb,
39987 +static int e100_setup_ucode(struct nic *nic, struct cb *cb,
39988 struct sk_buff *skb)
39989 {
39990 const struct firmware *fw = (void *)skb;
39991 @@ -1358,6 +1362,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb,
39992 cb->u.ucode[min_size] |= cpu_to_le32((BUNDLESMALL) ? 0xFFFF : 0xFF80);
39993
39994 cb->command = cpu_to_le16(cb_ucode | cb_el);
39995 + return 0;
39996 }
39997
39998 static inline int e100_load_ucode_wait(struct nic *nic)
39999 @@ -1400,18 +1405,20 @@ static inline int e100_load_ucode_wait(struct nic *nic)
40000 return err;
40001 }
40002
40003 -static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40004 +static int e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40005 struct sk_buff *skb)
40006 {
40007 cb->command = cpu_to_le16(cb_iaaddr);
40008 memcpy(cb->u.iaaddr, nic->netdev->dev_addr, ETH_ALEN);
40009 + return 0;
40010 }
40011
40012 -static void e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40013 +static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40014 {
40015 cb->command = cpu_to_le16(cb_dump);
40016 cb->u.dump_buffer_addr = cpu_to_le32(nic->dma_addr +
40017 offsetof(struct mem, dump_buf));
40018 + return 0;
40019 }
40020
40021 static int e100_phy_check_without_mii(struct nic *nic)
40022 @@ -1581,7 +1588,7 @@ static int e100_hw_init(struct nic *nic)
40023 return 0;
40024 }
40025
40026 -static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40027 +static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40028 {
40029 struct net_device *netdev = nic->netdev;
40030 struct netdev_hw_addr *ha;
40031 @@ -1596,6 +1603,7 @@ static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40032 memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &ha->addr,
40033 ETH_ALEN);
40034 }
40035 + return 0;
40036 }
40037
40038 static void e100_set_multicast_list(struct net_device *netdev)
40039 @@ -1756,11 +1764,18 @@ static void e100_watchdog(unsigned long data)
40040 round_jiffies(jiffies + E100_WATCHDOG_PERIOD));
40041 }
40042
40043 -static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40044 +static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
40045 struct sk_buff *skb)
40046 {
40047 + dma_addr_t dma_addr;
40048 cb->command = nic->tx_command;
40049
40050 + dma_addr = pci_map_single(nic->pdev,
40051 + skb->data, skb->len, PCI_DMA_TODEVICE);
40052 + /* If we can't map the skb, have the upper layer try later */
40053 + if (pci_dma_mapping_error(nic->pdev, dma_addr))
40054 + return -ENOMEM;
40055 +
40056 /*
40057 * Use the last 4 bytes of the SKB payload packet as the CRC, used for
40058 * testing, ie sending frames with bad CRC.
40059 @@ -1777,11 +1792,10 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40060 cb->u.tcb.tcb_byte_count = 0;
40061 cb->u.tcb.threshold = nic->tx_threshold;
40062 cb->u.tcb.tbd_count = 1;
40063 - cb->u.tcb.tbd.buf_addr = cpu_to_le32(pci_map_single(nic->pdev,
40064 - skb->data, skb->len, PCI_DMA_TODEVICE));
40065 - /* check for mapping failure? */
40066 + cb->u.tcb.tbd.buf_addr = cpu_to_le32(dma_addr);
40067 cb->u.tcb.tbd.size = cpu_to_le16(skb->len);
40068 skb_tx_timestamp(skb);
40069 + return 0;
40070 }
40071
40072 static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
40073 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40074 index bb9256a..56d8752 100644
40075 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40076 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40077 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40078 }
40079
40080 /* update the base incval used to calculate frequency adjustment */
40081 - ACCESS_ONCE(adapter->base_incval) = incval;
40082 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40083 smp_mb();
40084
40085 /* need lock to prevent incorrect read while modifying cyclecounter */
40086 diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
40087 index c124e67..db9b897 100644
40088 --- a/drivers/net/ethernet/lantiq_etop.c
40089 +++ b/drivers/net/ethernet/lantiq_etop.c
40090 @@ -769,7 +769,7 @@ ltq_etop_probe(struct platform_device *pdev)
40091 return 0;
40092
40093 err_free:
40094 - kfree(dev);
40095 + free_netdev(dev);
40096 err_out:
40097 return err;
40098 }
40099 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40100 index fbe5363..266b4e3 100644
40101 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40102 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40103 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40104 struct __vxge_hw_fifo *fifo;
40105 struct vxge_hw_fifo_config *config;
40106 u32 txdl_size, txdl_per_memblock;
40107 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40108 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40109 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40110 + };
40111 +
40112 struct __vxge_hw_virtualpath *vpath;
40113
40114 if ((vp == NULL) || (attr == NULL)) {
40115 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40116 goto exit;
40117 }
40118
40119 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40120 -
40121 fifo->mempool =
40122 __vxge_hw_mempool_create(vpath->hldev,
40123 fifo->config->memblock_size,
40124 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40125 index 2d849da..23bba3b 100644
40126 --- a/drivers/net/ethernet/realtek/r8169.c
40127 +++ b/drivers/net/ethernet/realtek/r8169.c
40128 @@ -741,22 +741,22 @@ struct rtl8169_private {
40129 struct mdio_ops {
40130 void (*write)(struct rtl8169_private *, int, int);
40131 int (*read)(struct rtl8169_private *, int);
40132 - } mdio_ops;
40133 + } __no_const mdio_ops;
40134
40135 struct pll_power_ops {
40136 void (*down)(struct rtl8169_private *);
40137 void (*up)(struct rtl8169_private *);
40138 - } pll_power_ops;
40139 + } __no_const pll_power_ops;
40140
40141 struct jumbo_ops {
40142 void (*enable)(struct rtl8169_private *);
40143 void (*disable)(struct rtl8169_private *);
40144 - } jumbo_ops;
40145 + } __no_const jumbo_ops;
40146
40147 struct csi_ops {
40148 void (*write)(struct rtl8169_private *, int, int);
40149 u32 (*read)(struct rtl8169_private *, int);
40150 - } csi_ops;
40151 + } __no_const csi_ops;
40152
40153 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40154 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40155 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40156 index 3f93624..cf01144 100644
40157 --- a/drivers/net/ethernet/sfc/ptp.c
40158 +++ b/drivers/net/ethernet/sfc/ptp.c
40159 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40160 (u32)((u64)ptp->start.dma_addr >> 32));
40161
40162 /* Clear flag that signals MC ready */
40163 - ACCESS_ONCE(*start) = 0;
40164 + ACCESS_ONCE_RW(*start) = 0;
40165 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40166 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40167
40168 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40169 index 0c74a70..3bc6f68 100644
40170 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40171 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40172 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40173
40174 writel(value, ioaddr + MMC_CNTRL);
40175
40176 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40177 - MMC_CNTRL, value);
40178 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40179 +// MMC_CNTRL, value);
40180 }
40181
40182 /* To mask all all interrupts.*/
40183 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40184 index e6fe0d8..2b7d752 100644
40185 --- a/drivers/net/hyperv/hyperv_net.h
40186 +++ b/drivers/net/hyperv/hyperv_net.h
40187 @@ -101,7 +101,7 @@ struct rndis_device {
40188
40189 enum rndis_device_state state;
40190 bool link_state;
40191 - atomic_t new_req_id;
40192 + atomic_unchecked_t new_req_id;
40193
40194 spinlock_t request_lock;
40195 struct list_head req_list;
40196 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40197 index 2b657d4..9903bc0 100644
40198 --- a/drivers/net/hyperv/rndis_filter.c
40199 +++ b/drivers/net/hyperv/rndis_filter.c
40200 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40201 * template
40202 */
40203 set = &rndis_msg->msg.set_req;
40204 - set->req_id = atomic_inc_return(&dev->new_req_id);
40205 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40206
40207 /* Add to the request list */
40208 spin_lock_irqsave(&dev->request_lock, flags);
40209 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40210
40211 /* Setup the rndis set */
40212 halt = &request->request_msg.msg.halt_req;
40213 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40214 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40215
40216 /* Ignore return since this msg is optional. */
40217 rndis_filter_send_request(dev, request);
40218 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40219 index 1e9cb0b..7839125 100644
40220 --- a/drivers/net/ieee802154/fakehard.c
40221 +++ b/drivers/net/ieee802154/fakehard.c
40222 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40223 phy->transmit_power = 0xbf;
40224
40225 dev->netdev_ops = &fake_ops;
40226 - dev->ml_priv = &fake_mlme;
40227 + dev->ml_priv = (void *)&fake_mlme;
40228
40229 priv = netdev_priv(dev);
40230 priv->phy = phy;
40231 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40232 index e5cb723..1fc0461 100644
40233 --- a/drivers/net/macvlan.c
40234 +++ b/drivers/net/macvlan.c
40235 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40236 int macvlan_link_register(struct rtnl_link_ops *ops)
40237 {
40238 /* common fields */
40239 - ops->priv_size = sizeof(struct macvlan_dev);
40240 - ops->validate = macvlan_validate;
40241 - ops->maxtype = IFLA_MACVLAN_MAX;
40242 - ops->policy = macvlan_policy;
40243 - ops->changelink = macvlan_changelink;
40244 - ops->get_size = macvlan_get_size;
40245 - ops->fill_info = macvlan_fill_info;
40246 + pax_open_kernel();
40247 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40248 + *(void **)&ops->validate = macvlan_validate;
40249 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40250 + *(const void **)&ops->policy = macvlan_policy;
40251 + *(void **)&ops->changelink = macvlan_changelink;
40252 + *(void **)&ops->get_size = macvlan_get_size;
40253 + *(void **)&ops->fill_info = macvlan_fill_info;
40254 + pax_close_kernel();
40255
40256 return rtnl_link_register(ops);
40257 };
40258 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40259 return NOTIFY_DONE;
40260 }
40261
40262 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40263 +static struct notifier_block macvlan_notifier_block = {
40264 .notifier_call = macvlan_device_event,
40265 };
40266
40267 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40268 index 0f0f9ce..0ca5819 100644
40269 --- a/drivers/net/macvtap.c
40270 +++ b/drivers/net/macvtap.c
40271 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40272 return NOTIFY_DONE;
40273 }
40274
40275 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40276 +static struct notifier_block macvtap_notifier_block = {
40277 .notifier_call = macvtap_device_event,
40278 };
40279
40280 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40281 index daec9b0..6428fcb 100644
40282 --- a/drivers/net/phy/mdio-bitbang.c
40283 +++ b/drivers/net/phy/mdio-bitbang.c
40284 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40285 struct mdiobb_ctrl *ctrl = bus->priv;
40286
40287 module_put(ctrl->ops->owner);
40288 + mdiobus_unregister(bus);
40289 mdiobus_free(bus);
40290 }
40291 EXPORT_SYMBOL(free_mdio_bitbang);
40292 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40293 index 508570e..f706dc7 100644
40294 --- a/drivers/net/ppp/ppp_generic.c
40295 +++ b/drivers/net/ppp/ppp_generic.c
40296 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40297 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40298 struct ppp_stats stats;
40299 struct ppp_comp_stats cstats;
40300 - char *vers;
40301
40302 switch (cmd) {
40303 case SIOCGPPPSTATS:
40304 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40305 break;
40306
40307 case SIOCGPPPVER:
40308 - vers = PPP_VERSION;
40309 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40310 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40311 break;
40312 err = 0;
40313 break;
40314 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40315 index 8efe47a..a8075c5 100644
40316 --- a/drivers/net/team/team.c
40317 +++ b/drivers/net/team/team.c
40318 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
40319 return NOTIFY_DONE;
40320 }
40321
40322 -static struct notifier_block team_notifier_block __read_mostly = {
40323 +static struct notifier_block team_notifier_block = {
40324 .notifier_call = team_device_event,
40325 };
40326
40327 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40328 index cb95fe5..16909e2 100644
40329 --- a/drivers/net/tun.c
40330 +++ b/drivers/net/tun.c
40331 @@ -1594,7 +1594,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
40332
40333 if (tun->flags & TUN_TAP_MQ &&
40334 (tun->numqueues + tun->numdisabled > 1))
40335 - return err;
40336 + return -EBUSY;
40337 }
40338 else {
40339 char *name;
40340 @@ -1838,7 +1838,7 @@ unlock:
40341 }
40342
40343 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40344 - unsigned long arg, int ifreq_len)
40345 + unsigned long arg, size_t ifreq_len)
40346 {
40347 struct tun_file *tfile = file->private_data;
40348 struct tun_struct *tun;
40349 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40350 int vnet_hdr_sz;
40351 int ret;
40352
40353 + if (ifreq_len > sizeof ifr)
40354 + return -EFAULT;
40355 +
40356 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40357 if (copy_from_user(&ifr, argp, ifreq_len))
40358 return -EFAULT;
40359 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40360 index cd8ccb2..cff5144 100644
40361 --- a/drivers/net/usb/hso.c
40362 +++ b/drivers/net/usb/hso.c
40363 @@ -71,7 +71,7 @@
40364 #include <asm/byteorder.h>
40365 #include <linux/serial_core.h>
40366 #include <linux/serial.h>
40367 -
40368 +#include <asm/local.h>
40369
40370 #define MOD_AUTHOR "Option Wireless"
40371 #define MOD_DESCRIPTION "USB High Speed Option driver"
40372 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40373 struct urb *urb;
40374
40375 urb = serial->rx_urb[0];
40376 - if (serial->port.count > 0) {
40377 + if (atomic_read(&serial->port.count) > 0) {
40378 count = put_rxbuf_data(urb, serial);
40379 if (count == -1)
40380 return;
40381 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40382 DUMP1(urb->transfer_buffer, urb->actual_length);
40383
40384 /* Anyone listening? */
40385 - if (serial->port.count == 0)
40386 + if (atomic_read(&serial->port.count) == 0)
40387 return;
40388
40389 if (status == 0) {
40390 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40391 tty_port_tty_set(&serial->port, tty);
40392
40393 /* check for port already opened, if not set the termios */
40394 - serial->port.count++;
40395 - if (serial->port.count == 1) {
40396 + if (atomic_inc_return(&serial->port.count) == 1) {
40397 serial->rx_state = RX_IDLE;
40398 /* Force default termio settings */
40399 _hso_serial_set_termios(tty, NULL);
40400 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40401 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40402 if (result) {
40403 hso_stop_serial_device(serial->parent);
40404 - serial->port.count--;
40405 + atomic_dec(&serial->port.count);
40406 kref_put(&serial->parent->ref, hso_serial_ref_free);
40407 }
40408 } else {
40409 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40410
40411 /* reset the rts and dtr */
40412 /* do the actual close */
40413 - serial->port.count--;
40414 + atomic_dec(&serial->port.count);
40415
40416 - if (serial->port.count <= 0) {
40417 - serial->port.count = 0;
40418 + if (atomic_read(&serial->port.count) <= 0) {
40419 + atomic_set(&serial->port.count, 0);
40420 tty_port_tty_set(&serial->port, NULL);
40421 if (!usb_gone)
40422 hso_stop_serial_device(serial->parent);
40423 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40424
40425 /* the actual setup */
40426 spin_lock_irqsave(&serial->serial_lock, flags);
40427 - if (serial->port.count)
40428 + if (atomic_read(&serial->port.count))
40429 _hso_serial_set_termios(tty, old);
40430 else
40431 tty->termios = *old;
40432 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40433 D1("Pending read interrupt on port %d\n", i);
40434 spin_lock(&serial->serial_lock);
40435 if (serial->rx_state == RX_IDLE &&
40436 - serial->port.count > 0) {
40437 + atomic_read(&serial->port.count) > 0) {
40438 /* Setup and send a ctrl req read on
40439 * port i */
40440 if (!serial->rx_urb_filled[0]) {
40441 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
40442 /* Start all serial ports */
40443 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40444 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40445 - if (dev2ser(serial_table[i])->port.count) {
40446 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40447 result =
40448 hso_start_serial_device(serial_table[i], GFP_NOIO);
40449 hso_kick_transmit(dev2ser(serial_table[i]));
40450 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40451 index 6993bfa..9053a34 100644
40452 --- a/drivers/net/vxlan.c
40453 +++ b/drivers/net/vxlan.c
40454 @@ -1428,7 +1428,7 @@ nla_put_failure:
40455 return -EMSGSIZE;
40456 }
40457
40458 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40459 +static struct rtnl_link_ops vxlan_link_ops = {
40460 .kind = "vxlan",
40461 .maxtype = IFLA_VXLAN_MAX,
40462 .policy = vxlan_policy,
40463 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40464 index 77fa428..996b355 100644
40465 --- a/drivers/net/wireless/at76c50x-usb.c
40466 +++ b/drivers/net/wireless/at76c50x-usb.c
40467 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40468 }
40469
40470 /* Convert timeout from the DFU status to jiffies */
40471 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40472 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40473 {
40474 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40475 | (s->poll_timeout[1] << 8)
40476 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40477 index 8d78253..bebbb68 100644
40478 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40479 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40480 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40481 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40482 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40483
40484 - ACCESS_ONCE(ads->ds_link) = i->link;
40485 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40486 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40487 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40488
40489 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40490 ctl6 = SM(i->keytype, AR_EncrType);
40491 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40492
40493 if ((i->is_first || i->is_last) &&
40494 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40495 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40496 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40497 | set11nTries(i->rates, 1)
40498 | set11nTries(i->rates, 2)
40499 | set11nTries(i->rates, 3)
40500 | (i->dur_update ? AR_DurUpdateEna : 0)
40501 | SM(0, AR_BurstDur);
40502
40503 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40504 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40505 | set11nRate(i->rates, 1)
40506 | set11nRate(i->rates, 2)
40507 | set11nRate(i->rates, 3);
40508 } else {
40509 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40510 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40511 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40512 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40513 }
40514
40515 if (!i->is_first) {
40516 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40517 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40518 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40519 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40520 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40521 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40522 return;
40523 }
40524
40525 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40526 break;
40527 }
40528
40529 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40530 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40531 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40532 | SM(i->txpower, AR_XmitPower)
40533 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40534 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40535 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40536 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40537
40538 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40539 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40540 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40541 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40542
40543 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40544 return;
40545
40546 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40547 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40548 | set11nPktDurRTSCTS(i->rates, 1);
40549
40550 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40551 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40552 | set11nPktDurRTSCTS(i->rates, 3);
40553
40554 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40555 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40556 | set11nRateFlags(i->rates, 1)
40557 | set11nRateFlags(i->rates, 2)
40558 | set11nRateFlags(i->rates, 3)
40559 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40560 index 301bf72..3f5654f 100644
40561 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40562 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40563 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40564 (i->qcu << AR_TxQcuNum_S) | desc_len;
40565
40566 checksum += val;
40567 - ACCESS_ONCE(ads->info) = val;
40568 + ACCESS_ONCE_RW(ads->info) = val;
40569
40570 checksum += i->link;
40571 - ACCESS_ONCE(ads->link) = i->link;
40572 + ACCESS_ONCE_RW(ads->link) = i->link;
40573
40574 checksum += i->buf_addr[0];
40575 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40576 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40577 checksum += i->buf_addr[1];
40578 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40579 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40580 checksum += i->buf_addr[2];
40581 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40582 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40583 checksum += i->buf_addr[3];
40584 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40585 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40586
40587 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40588 - ACCESS_ONCE(ads->ctl3) = val;
40589 + ACCESS_ONCE_RW(ads->ctl3) = val;
40590 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40591 - ACCESS_ONCE(ads->ctl5) = val;
40592 + ACCESS_ONCE_RW(ads->ctl5) = val;
40593 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40594 - ACCESS_ONCE(ads->ctl7) = val;
40595 + ACCESS_ONCE_RW(ads->ctl7) = val;
40596 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40597 - ACCESS_ONCE(ads->ctl9) = val;
40598 + ACCESS_ONCE_RW(ads->ctl9) = val;
40599
40600 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40601 - ACCESS_ONCE(ads->ctl10) = checksum;
40602 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40603
40604 if (i->is_first || i->is_last) {
40605 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40606 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40607 | set11nTries(i->rates, 1)
40608 | set11nTries(i->rates, 2)
40609 | set11nTries(i->rates, 3)
40610 | (i->dur_update ? AR_DurUpdateEna : 0)
40611 | SM(0, AR_BurstDur);
40612
40613 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40614 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40615 | set11nRate(i->rates, 1)
40616 | set11nRate(i->rates, 2)
40617 | set11nRate(i->rates, 3);
40618 } else {
40619 - ACCESS_ONCE(ads->ctl13) = 0;
40620 - ACCESS_ONCE(ads->ctl14) = 0;
40621 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40622 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40623 }
40624
40625 ads->ctl20 = 0;
40626 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40627
40628 ctl17 = SM(i->keytype, AR_EncrType);
40629 if (!i->is_first) {
40630 - ACCESS_ONCE(ads->ctl11) = 0;
40631 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40632 - ACCESS_ONCE(ads->ctl15) = 0;
40633 - ACCESS_ONCE(ads->ctl16) = 0;
40634 - ACCESS_ONCE(ads->ctl17) = ctl17;
40635 - ACCESS_ONCE(ads->ctl18) = 0;
40636 - ACCESS_ONCE(ads->ctl19) = 0;
40637 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40638 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40639 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40640 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40641 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40642 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40643 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40644 return;
40645 }
40646
40647 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40648 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40649 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40650 | SM(i->txpower, AR_XmitPower)
40651 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40652 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40653 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40654 ctl12 |= SM(val, AR_PAPRDChainMask);
40655
40656 - ACCESS_ONCE(ads->ctl12) = ctl12;
40657 - ACCESS_ONCE(ads->ctl17) = ctl17;
40658 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40659 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40660
40661 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40662 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40663 | set11nPktDurRTSCTS(i->rates, 1);
40664
40665 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40666 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40667 | set11nPktDurRTSCTS(i->rates, 3);
40668
40669 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40670 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40671 | set11nRateFlags(i->rates, 1)
40672 | set11nRateFlags(i->rates, 2)
40673 | set11nRateFlags(i->rates, 3)
40674 | SM(i->rtscts_rate, AR_RTSCTSRate);
40675
40676 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40677 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40678 }
40679
40680 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40681 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40682 index 9d26fc5..60d9f14 100644
40683 --- a/drivers/net/wireless/ath/ath9k/hw.h
40684 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40685 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
40686
40687 /* ANI */
40688 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40689 -};
40690 +} __no_const;
40691
40692 /**
40693 * struct ath_hw_ops - callbacks used by hardware code and driver code
40694 @@ -688,7 +688,7 @@ struct ath_hw_ops {
40695 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
40696 struct ath_hw_antcomb_conf *antconf);
40697 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
40698 -};
40699 +} __no_const;
40700
40701 struct ath_nf_limits {
40702 s16 max;
40703 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40704 index 3726cd6..b655808 100644
40705 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40706 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40707 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40708 */
40709 if (il3945_mod_params.disable_hw_scan) {
40710 D_INFO("Disabling hw_scan\n");
40711 - il3945_mac_ops.hw_scan = NULL;
40712 + pax_open_kernel();
40713 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40714 + pax_close_kernel();
40715 }
40716
40717 D_INFO("*** LOAD DRIVER ***\n");
40718 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40719 index 5b9533e..7733880 100644
40720 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40721 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40722 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40723 {
40724 struct iwl_priv *priv = file->private_data;
40725 char buf[64];
40726 - int buf_size;
40727 + size_t buf_size;
40728 u32 offset, len;
40729
40730 memset(buf, 0, sizeof(buf));
40731 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40732 struct iwl_priv *priv = file->private_data;
40733
40734 char buf[8];
40735 - int buf_size;
40736 + size_t buf_size;
40737 u32 reset_flag;
40738
40739 memset(buf, 0, sizeof(buf));
40740 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40741 {
40742 struct iwl_priv *priv = file->private_data;
40743 char buf[8];
40744 - int buf_size;
40745 + size_t buf_size;
40746 int ht40;
40747
40748 memset(buf, 0, sizeof(buf));
40749 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40750 {
40751 struct iwl_priv *priv = file->private_data;
40752 char buf[8];
40753 - int buf_size;
40754 + size_t buf_size;
40755 int value;
40756
40757 memset(buf, 0, sizeof(buf));
40758 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40759 {
40760 struct iwl_priv *priv = file->private_data;
40761 char buf[8];
40762 - int buf_size;
40763 + size_t buf_size;
40764 int clear;
40765
40766 memset(buf, 0, sizeof(buf));
40767 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40768 {
40769 struct iwl_priv *priv = file->private_data;
40770 char buf[8];
40771 - int buf_size;
40772 + size_t buf_size;
40773 int trace;
40774
40775 memset(buf, 0, sizeof(buf));
40776 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40777 {
40778 struct iwl_priv *priv = file->private_data;
40779 char buf[8];
40780 - int buf_size;
40781 + size_t buf_size;
40782 int missed;
40783
40784 memset(buf, 0, sizeof(buf));
40785 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40786
40787 struct iwl_priv *priv = file->private_data;
40788 char buf[8];
40789 - int buf_size;
40790 + size_t buf_size;
40791 int plcp;
40792
40793 memset(buf, 0, sizeof(buf));
40794 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40795
40796 struct iwl_priv *priv = file->private_data;
40797 char buf[8];
40798 - int buf_size;
40799 + size_t buf_size;
40800 int flush;
40801
40802 memset(buf, 0, sizeof(buf));
40803 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40804
40805 struct iwl_priv *priv = file->private_data;
40806 char buf[8];
40807 - int buf_size;
40808 + size_t buf_size;
40809 int rts;
40810
40811 if (!priv->cfg->ht_params)
40812 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40813 {
40814 struct iwl_priv *priv = file->private_data;
40815 char buf[8];
40816 - int buf_size;
40817 + size_t buf_size;
40818
40819 memset(buf, 0, sizeof(buf));
40820 buf_size = min(count, sizeof(buf) - 1);
40821 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40822 struct iwl_priv *priv = file->private_data;
40823 u32 event_log_flag;
40824 char buf[8];
40825 - int buf_size;
40826 + size_t buf_size;
40827
40828 /* check that the interface is up */
40829 if (!iwl_is_ready(priv))
40830 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40831 struct iwl_priv *priv = file->private_data;
40832 char buf[8];
40833 u32 calib_disabled;
40834 - int buf_size;
40835 + size_t buf_size;
40836
40837 memset(buf, 0, sizeof(buf));
40838 buf_size = min(count, sizeof(buf) - 1);
40839 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40840 index 35708b9..31f7754 100644
40841 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40842 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40843 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40844 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40845
40846 char buf[8];
40847 - int buf_size;
40848 + size_t buf_size;
40849 u32 reset_flag;
40850
40851 memset(buf, 0, sizeof(buf));
40852 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40853 {
40854 struct iwl_trans *trans = file->private_data;
40855 char buf[8];
40856 - int buf_size;
40857 + size_t buf_size;
40858 int csr;
40859
40860 memset(buf, 0, sizeof(buf));
40861 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40862 index ff90855..e46d223 100644
40863 --- a/drivers/net/wireless/mac80211_hwsim.c
40864 +++ b/drivers/net/wireless/mac80211_hwsim.c
40865 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
40866
40867 if (channels > 1) {
40868 hwsim_if_comb.num_different_channels = channels;
40869 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40870 - mac80211_hwsim_ops.cancel_hw_scan =
40871 - mac80211_hwsim_cancel_hw_scan;
40872 - mac80211_hwsim_ops.sw_scan_start = NULL;
40873 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40874 - mac80211_hwsim_ops.remain_on_channel =
40875 - mac80211_hwsim_roc;
40876 - mac80211_hwsim_ops.cancel_remain_on_channel =
40877 - mac80211_hwsim_croc;
40878 - mac80211_hwsim_ops.add_chanctx =
40879 - mac80211_hwsim_add_chanctx;
40880 - mac80211_hwsim_ops.remove_chanctx =
40881 - mac80211_hwsim_remove_chanctx;
40882 - mac80211_hwsim_ops.change_chanctx =
40883 - mac80211_hwsim_change_chanctx;
40884 - mac80211_hwsim_ops.assign_vif_chanctx =
40885 - mac80211_hwsim_assign_vif_chanctx;
40886 - mac80211_hwsim_ops.unassign_vif_chanctx =
40887 - mac80211_hwsim_unassign_vif_chanctx;
40888 + pax_open_kernel();
40889 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40890 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40891 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40892 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40893 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40894 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40895 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40896 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40897 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40898 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40899 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40900 + pax_close_kernel();
40901 }
40902
40903 spin_lock_init(&hwsim_radio_lock);
40904 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40905 index abe1d03..fb02c22 100644
40906 --- a/drivers/net/wireless/rndis_wlan.c
40907 +++ b/drivers/net/wireless/rndis_wlan.c
40908 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40909
40910 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40911
40912 - if (rts_threshold < 0 || rts_threshold > 2347)
40913 + if (rts_threshold > 2347)
40914 rts_threshold = 2347;
40915
40916 tmp = cpu_to_le32(rts_threshold);
40917 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40918 index 0751b35..246ba3e 100644
40919 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40920 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40921 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40922 * for hardware which doesn't support hardware
40923 * sequence counting.
40924 */
40925 - atomic_t seqno;
40926 + atomic_unchecked_t seqno;
40927 };
40928
40929 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40930 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40931 index e488b94..14b6a0c 100644
40932 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40933 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40934 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40935 * sequence counter given by mac80211.
40936 */
40937 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40938 - seqno = atomic_add_return(0x10, &intf->seqno);
40939 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40940 else
40941 - seqno = atomic_read(&intf->seqno);
40942 + seqno = atomic_read_unchecked(&intf->seqno);
40943
40944 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40945 hdr->seq_ctrl |= cpu_to_le16(seqno);
40946 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40947 index e57ee48..541cf6c 100644
40948 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40949 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40950 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40951
40952 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40953
40954 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40955 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40956 + pax_open_kernel();
40957 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40958 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40959 + pax_close_kernel();
40960
40961 wl1251_info("using dedicated interrupt line");
40962 } else {
40963 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40964 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40965 + pax_open_kernel();
40966 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40967 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40968 + pax_close_kernel();
40969
40970 wl1251_info("using SDIO interrupt");
40971 }
40972 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40973 index e5f5f8f..fdf15b7 100644
40974 --- a/drivers/net/wireless/ti/wl12xx/main.c
40975 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40976 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40977 sizeof(wl->conf.mem));
40978
40979 /* read data preparation is only needed by wl127x */
40980 - wl->ops->prepare_read = wl127x_prepare_read;
40981 + pax_open_kernel();
40982 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40983 + pax_close_kernel();
40984
40985 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40986 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40987 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40988 sizeof(wl->conf.mem));
40989
40990 /* read data preparation is only needed by wl127x */
40991 - wl->ops->prepare_read = wl127x_prepare_read;
40992 + pax_open_kernel();
40993 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40994 + pax_close_kernel();
40995
40996 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40997 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40998 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40999 index 8d8c1f8..e754844 100644
41000 --- a/drivers/net/wireless/ti/wl18xx/main.c
41001 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41002 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41003 }
41004
41005 if (!checksum_param) {
41006 - wl18xx_ops.set_rx_csum = NULL;
41007 - wl18xx_ops.init_vif = NULL;
41008 + pax_open_kernel();
41009 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41010 + *(void **)&wl18xx_ops.init_vif = NULL;
41011 + pax_close_kernel();
41012 }
41013
41014 /* Enable 11a Band only if we have 5G antennas */
41015 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41016 index ef2b171..bb513a6 100644
41017 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41018 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41019 @@ -387,7 +387,7 @@ static inline void handle_regs_int(struct urb *urb)
41020 {
41021 struct zd_usb *usb = urb->context;
41022 struct zd_usb_interrupt *intr = &usb->intr;
41023 - int len;
41024 + unsigned int len;
41025 u16 int_num;
41026
41027 ZD_ASSERT(in_interrupt());
41028 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41029 index d93b2b6..ae50401 100644
41030 --- a/drivers/oprofile/buffer_sync.c
41031 +++ b/drivers/oprofile/buffer_sync.c
41032 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41033 if (cookie == NO_COOKIE)
41034 offset = pc;
41035 if (cookie == INVALID_COOKIE) {
41036 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41037 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41038 offset = pc;
41039 }
41040 if (cookie != last_cookie) {
41041 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41042 /* add userspace sample */
41043
41044 if (!mm) {
41045 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41046 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41047 return 0;
41048 }
41049
41050 cookie = lookup_dcookie(mm, s->eip, &offset);
41051
41052 if (cookie == INVALID_COOKIE) {
41053 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41054 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41055 return 0;
41056 }
41057
41058 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41059 /* ignore backtraces if failed to add a sample */
41060 if (state == sb_bt_start) {
41061 state = sb_bt_ignore;
41062 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41063 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41064 }
41065 }
41066 release_mm(mm);
41067 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41068 index c0cc4e7..44d4e54 100644
41069 --- a/drivers/oprofile/event_buffer.c
41070 +++ b/drivers/oprofile/event_buffer.c
41071 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41072 }
41073
41074 if (buffer_pos == buffer_size) {
41075 - atomic_inc(&oprofile_stats.event_lost_overflow);
41076 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41077 return;
41078 }
41079
41080 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41081 index ed2c3ec..deda85a 100644
41082 --- a/drivers/oprofile/oprof.c
41083 +++ b/drivers/oprofile/oprof.c
41084 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41085 if (oprofile_ops.switch_events())
41086 return;
41087
41088 - atomic_inc(&oprofile_stats.multiplex_counter);
41089 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41090 start_switch_worker();
41091 }
41092
41093 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41094 index 84a208d..d61b0a1 100644
41095 --- a/drivers/oprofile/oprofile_files.c
41096 +++ b/drivers/oprofile/oprofile_files.c
41097 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41098
41099 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41100
41101 -static ssize_t timeout_read(struct file *file, char __user *buf,
41102 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41103 size_t count, loff_t *offset)
41104 {
41105 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41106 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41107 index 917d28e..d62d981 100644
41108 --- a/drivers/oprofile/oprofile_stats.c
41109 +++ b/drivers/oprofile/oprofile_stats.c
41110 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41111 cpu_buf->sample_invalid_eip = 0;
41112 }
41113
41114 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41115 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41116 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41117 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41118 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41119 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41120 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41121 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41122 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41123 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41124 }
41125
41126
41127 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41128 index 38b6fc0..b5cbfce 100644
41129 --- a/drivers/oprofile/oprofile_stats.h
41130 +++ b/drivers/oprofile/oprofile_stats.h
41131 @@ -13,11 +13,11 @@
41132 #include <linux/atomic.h>
41133
41134 struct oprofile_stat_struct {
41135 - atomic_t sample_lost_no_mm;
41136 - atomic_t sample_lost_no_mapping;
41137 - atomic_t bt_lost_no_mapping;
41138 - atomic_t event_lost_overflow;
41139 - atomic_t multiplex_counter;
41140 + atomic_unchecked_t sample_lost_no_mm;
41141 + atomic_unchecked_t sample_lost_no_mapping;
41142 + atomic_unchecked_t bt_lost_no_mapping;
41143 + atomic_unchecked_t event_lost_overflow;
41144 + atomic_unchecked_t multiplex_counter;
41145 };
41146
41147 extern struct oprofile_stat_struct oprofile_stats;
41148 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41149 index 849357c..b83c1e0 100644
41150 --- a/drivers/oprofile/oprofilefs.c
41151 +++ b/drivers/oprofile/oprofilefs.c
41152 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
41153
41154
41155 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41156 - char const *name, atomic_t *val)
41157 + char const *name, atomic_unchecked_t *val)
41158 {
41159 return __oprofilefs_create_file(sb, root, name,
41160 &atomic_ro_fops, 0444, val);
41161 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41162 index 93404f7..4a313d8 100644
41163 --- a/drivers/oprofile/timer_int.c
41164 +++ b/drivers/oprofile/timer_int.c
41165 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41166 return NOTIFY_OK;
41167 }
41168
41169 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41170 +static struct notifier_block oprofile_cpu_notifier = {
41171 .notifier_call = oprofile_cpu_notify,
41172 };
41173
41174 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41175 index 3f56bc0..707d642 100644
41176 --- a/drivers/parport/procfs.c
41177 +++ b/drivers/parport/procfs.c
41178 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41179
41180 *ppos += len;
41181
41182 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41183 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41184 }
41185
41186 #ifdef CONFIG_PARPORT_1284
41187 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41188
41189 *ppos += len;
41190
41191 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41192 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41193 }
41194 #endif /* IEEE1284.3 support. */
41195
41196 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41197 index c35e8ad..fc33beb 100644
41198 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41199 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41200 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41201 goto init_cleanup;
41202 }
41203
41204 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41205 + pax_open_kernel();
41206 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41207 + pax_close_kernel();
41208 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41209
41210 return retval;
41211 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41212 index a6a71c4..c91097b 100644
41213 --- a/drivers/pci/hotplug/cpcihp_generic.c
41214 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41215 @@ -73,7 +73,6 @@ static u16 port;
41216 static unsigned int enum_bit;
41217 static u8 enum_mask;
41218
41219 -static struct cpci_hp_controller_ops generic_hpc_ops;
41220 static struct cpci_hp_controller generic_hpc;
41221
41222 static int __init validate_parameters(void)
41223 @@ -139,6 +138,10 @@ static int query_enum(void)
41224 return ((value & enum_mask) == enum_mask);
41225 }
41226
41227 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41228 + .query_enum = query_enum,
41229 +};
41230 +
41231 static int __init cpcihp_generic_init(void)
41232 {
41233 int status;
41234 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41235 pci_dev_put(dev);
41236
41237 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41238 - generic_hpc_ops.query_enum = query_enum;
41239 generic_hpc.ops = &generic_hpc_ops;
41240
41241 status = cpci_hp_register_controller(&generic_hpc);
41242 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41243 index 449b4bb..257e2e8 100644
41244 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41245 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41246 @@ -59,7 +59,6 @@
41247 /* local variables */
41248 static bool debug;
41249 static bool poll;
41250 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41251 static struct cpci_hp_controller zt5550_hpc;
41252
41253 /* Primary cPCI bus bridge device */
41254 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41255 return 0;
41256 }
41257
41258 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41259 + .query_enum = zt5550_hc_query_enum,
41260 +};
41261 +
41262 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41263 {
41264 int status;
41265 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41266 dbg("returned from zt5550_hc_config");
41267
41268 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41269 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41270 zt5550_hpc.ops = &zt5550_hpc_ops;
41271 if(!poll) {
41272 zt5550_hpc.irq = hc_dev->irq;
41273 zt5550_hpc.irq_flags = IRQF_SHARED;
41274 zt5550_hpc.dev_id = hc_dev;
41275
41276 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41277 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41278 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41279 + pax_open_kernel();
41280 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41281 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41282 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41283 + pax_open_kernel();
41284 } else {
41285 info("using ENUM# polling mode");
41286 }
41287 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41288 index 76ba8a1..20ca857 100644
41289 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41290 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41291 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41292
41293 void compaq_nvram_init (void __iomem *rom_start)
41294 {
41295 +
41296 +#ifndef CONFIG_PAX_KERNEXEC
41297 if (rom_start) {
41298 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41299 }
41300 +#endif
41301 +
41302 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41303
41304 /* initialize our int15 lock */
41305 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41306 index 202f4a9..8ee47d0 100644
41307 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41308 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41309 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41310 return -EINVAL;
41311 }
41312
41313 - slot->ops->owner = owner;
41314 - slot->ops->mod_name = mod_name;
41315 + pax_open_kernel();
41316 + *(struct module **)&slot->ops->owner = owner;
41317 + *(const char **)&slot->ops->mod_name = mod_name;
41318 + pax_close_kernel();
41319
41320 mutex_lock(&pci_hp_mutex);
41321 /*
41322 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41323 index 939bd1d..a1459c9 100644
41324 --- a/drivers/pci/hotplug/pciehp_core.c
41325 +++ b/drivers/pci/hotplug/pciehp_core.c
41326 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41327 struct slot *slot = ctrl->slot;
41328 struct hotplug_slot *hotplug = NULL;
41329 struct hotplug_slot_info *info = NULL;
41330 - struct hotplug_slot_ops *ops = NULL;
41331 + hotplug_slot_ops_no_const *ops = NULL;
41332 char name[SLOT_NAME_SIZE];
41333 int retval = -ENOMEM;
41334
41335 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41336 index 9c6e9bb..2916736 100644
41337 --- a/drivers/pci/pci-sysfs.c
41338 +++ b/drivers/pci/pci-sysfs.c
41339 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41340 {
41341 /* allocate attribute structure, piggyback attribute name */
41342 int name_len = write_combine ? 13 : 10;
41343 - struct bin_attribute *res_attr;
41344 + bin_attribute_no_const *res_attr;
41345 int retval;
41346
41347 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41348 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41349 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41350 {
41351 int retval;
41352 - struct bin_attribute *attr;
41353 + bin_attribute_no_const *attr;
41354
41355 /* If the device has VPD, try to expose it in sysfs. */
41356 if (dev->vpd) {
41357 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41358 {
41359 int retval;
41360 int rom_size = 0;
41361 - struct bin_attribute *attr;
41362 + bin_attribute_no_const *attr;
41363
41364 if (!sysfs_initialized)
41365 return -EACCES;
41366 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41367 index e851829..a1a7196 100644
41368 --- a/drivers/pci/pci.h
41369 +++ b/drivers/pci/pci.h
41370 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
41371 struct pci_vpd {
41372 unsigned int len;
41373 const struct pci_vpd_ops *ops;
41374 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41375 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41376 };
41377
41378 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41379 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41380 index 8474b6a..ee81993 100644
41381 --- a/drivers/pci/pcie/aspm.c
41382 +++ b/drivers/pci/pcie/aspm.c
41383 @@ -27,9 +27,9 @@
41384 #define MODULE_PARAM_PREFIX "pcie_aspm."
41385
41386 /* Note: those are not register definitions */
41387 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41388 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41389 -#define ASPM_STATE_L1 (4) /* L1 state */
41390 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41391 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41392 +#define ASPM_STATE_L1 (4U) /* L1 state */
41393 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41394 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41395
41396 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41397 index 6186f03..1a78714 100644
41398 --- a/drivers/pci/probe.c
41399 +++ b/drivers/pci/probe.c
41400 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41401 struct pci_bus_region region;
41402 bool bar_too_big = false, bar_disabled = false;
41403
41404 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41405 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41406
41407 /* No printks while decoding is disabled! */
41408 if (!dev->mmio_always_on) {
41409 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41410 index 9b8505c..f00870a 100644
41411 --- a/drivers/pci/proc.c
41412 +++ b/drivers/pci/proc.c
41413 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41414 static int __init pci_proc_init(void)
41415 {
41416 struct pci_dev *dev = NULL;
41417 +
41418 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41419 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41420 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41421 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41422 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41423 +#endif
41424 +#else
41425 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41426 +#endif
41427 proc_create("devices", 0, proc_bus_pci_dir,
41428 &proc_bus_pci_dev_operations);
41429 proc_initialized = 1;
41430 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41431 index 2111dbb..79e434b 100644
41432 --- a/drivers/platform/x86/msi-laptop.c
41433 +++ b/drivers/platform/x86/msi-laptop.c
41434 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41435 int result;
41436
41437 /* allow userland write sysfs file */
41438 - dev_attr_bluetooth.store = store_bluetooth;
41439 - dev_attr_wlan.store = store_wlan;
41440 - dev_attr_threeg.store = store_threeg;
41441 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41442 - dev_attr_wlan.attr.mode |= S_IWUSR;
41443 - dev_attr_threeg.attr.mode |= S_IWUSR;
41444 + pax_open_kernel();
41445 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41446 + *(void **)&dev_attr_wlan.store = store_wlan;
41447 + *(void **)&dev_attr_threeg.store = store_threeg;
41448 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41449 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41450 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41451 + pax_close_kernel();
41452
41453 /* disable hardware control by fn key */
41454 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
41455 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41456 index 0fe987f..6f3d5c3 100644
41457 --- a/drivers/platform/x86/sony-laptop.c
41458 +++ b/drivers/platform/x86/sony-laptop.c
41459 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
41460 }
41461
41462 /* High speed charging function */
41463 -static struct device_attribute *hsc_handle;
41464 +static device_attribute_no_const *hsc_handle;
41465
41466 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41467 struct device_attribute *attr,
41468 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41469 index f946ca7..f25c833 100644
41470 --- a/drivers/platform/x86/thinkpad_acpi.c
41471 +++ b/drivers/platform/x86/thinkpad_acpi.c
41472 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
41473 return 0;
41474 }
41475
41476 -void static hotkey_mask_warn_incomplete_mask(void)
41477 +static void hotkey_mask_warn_incomplete_mask(void)
41478 {
41479 /* log only what the user can fix... */
41480 const u32 wantedmask = hotkey_driver_mask &
41481 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41482 }
41483 }
41484
41485 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41486 - struct tp_nvram_state *newn,
41487 - const u32 event_mask)
41488 -{
41489 -
41490 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41491 do { \
41492 if ((event_mask & (1 << __scancode)) && \
41493 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41494 tpacpi_hotkey_send_key(__scancode); \
41495 } while (0)
41496
41497 - void issue_volchange(const unsigned int oldvol,
41498 - const unsigned int newvol)
41499 - {
41500 - unsigned int i = oldvol;
41501 +static void issue_volchange(const unsigned int oldvol,
41502 + const unsigned int newvol,
41503 + const u32 event_mask)
41504 +{
41505 + unsigned int i = oldvol;
41506
41507 - while (i > newvol) {
41508 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41509 - i--;
41510 - }
41511 - while (i < newvol) {
41512 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41513 - i++;
41514 - }
41515 + while (i > newvol) {
41516 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41517 + i--;
41518 }
41519 + while (i < newvol) {
41520 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41521 + i++;
41522 + }
41523 +}
41524
41525 - void issue_brightnesschange(const unsigned int oldbrt,
41526 - const unsigned int newbrt)
41527 - {
41528 - unsigned int i = oldbrt;
41529 +static void issue_brightnesschange(const unsigned int oldbrt,
41530 + const unsigned int newbrt,
41531 + const u32 event_mask)
41532 +{
41533 + unsigned int i = oldbrt;
41534
41535 - while (i > newbrt) {
41536 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41537 - i--;
41538 - }
41539 - while (i < newbrt) {
41540 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41541 - i++;
41542 - }
41543 + while (i > newbrt) {
41544 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41545 + i--;
41546 + }
41547 + while (i < newbrt) {
41548 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41549 + i++;
41550 }
41551 +}
41552
41553 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41554 + struct tp_nvram_state *newn,
41555 + const u32 event_mask)
41556 +{
41557 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41558 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41559 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41560 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41561 oldn->volume_level != newn->volume_level) {
41562 /* recently muted, or repeated mute keypress, or
41563 * multiple presses ending in mute */
41564 - issue_volchange(oldn->volume_level, newn->volume_level);
41565 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41566 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41567 }
41568 } else {
41569 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41570 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41571 }
41572 if (oldn->volume_level != newn->volume_level) {
41573 - issue_volchange(oldn->volume_level, newn->volume_level);
41574 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41575 } else if (oldn->volume_toggle != newn->volume_toggle) {
41576 /* repeated vol up/down keypress at end of scale ? */
41577 if (newn->volume_level == 0)
41578 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41579 /* handle brightness */
41580 if (oldn->brightness_level != newn->brightness_level) {
41581 issue_brightnesschange(oldn->brightness_level,
41582 - newn->brightness_level);
41583 + newn->brightness_level,
41584 + event_mask);
41585 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41586 /* repeated key presses that didn't change state */
41587 if (newn->brightness_level == 0)
41588 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41589 && !tp_features.bright_unkfw)
41590 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41591 }
41592 +}
41593
41594 #undef TPACPI_COMPARE_KEY
41595 #undef TPACPI_MAY_SEND_KEY
41596 -}
41597
41598 /*
41599 * Polling driver
41600 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41601 index 769d265..a3a05ca 100644
41602 --- a/drivers/pnp/pnpbios/bioscalls.c
41603 +++ b/drivers/pnp/pnpbios/bioscalls.c
41604 @@ -58,7 +58,7 @@ do { \
41605 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41606 } while(0)
41607
41608 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41609 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41610 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41611
41612 /*
41613 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41614
41615 cpu = get_cpu();
41616 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41617 +
41618 + pax_open_kernel();
41619 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41620 + pax_close_kernel();
41621
41622 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41623 spin_lock_irqsave(&pnp_bios_lock, flags);
41624 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41625 :"memory");
41626 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41627
41628 + pax_open_kernel();
41629 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41630 + pax_close_kernel();
41631 +
41632 put_cpu();
41633
41634 /* If we get here and this is set then the PnP BIOS faulted on us. */
41635 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41636 return status;
41637 }
41638
41639 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41640 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41641 {
41642 int i;
41643
41644 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41645 pnp_bios_callpoint.offset = header->fields.pm16offset;
41646 pnp_bios_callpoint.segment = PNP_CS16;
41647
41648 + pax_open_kernel();
41649 +
41650 for_each_possible_cpu(i) {
41651 struct desc_struct *gdt = get_cpu_gdt_table(i);
41652 if (!gdt)
41653 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41654 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41655 (unsigned long)__va(header->fields.pm16dseg));
41656 }
41657 +
41658 + pax_close_kernel();
41659 }
41660 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41661 index 3e6db1c..1fbbdae 100644
41662 --- a/drivers/pnp/resource.c
41663 +++ b/drivers/pnp/resource.c
41664 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41665 return 1;
41666
41667 /* check if the resource is valid */
41668 - if (*irq < 0 || *irq > 15)
41669 + if (*irq > 15)
41670 return 0;
41671
41672 /* check if the resource is reserved */
41673 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41674 return 1;
41675
41676 /* check if the resource is valid */
41677 - if (*dma < 0 || *dma == 4 || *dma > 7)
41678 + if (*dma == 4 || *dma > 7)
41679 return 0;
41680
41681 /* check if the resource is reserved */
41682 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41683 index 7df7c5f..bd48c47 100644
41684 --- a/drivers/power/pda_power.c
41685 +++ b/drivers/power/pda_power.c
41686 @@ -37,7 +37,11 @@ static int polling;
41687
41688 #ifdef CONFIG_USB_OTG_UTILS
41689 static struct usb_phy *transceiver;
41690 -static struct notifier_block otg_nb;
41691 +static int otg_handle_notification(struct notifier_block *nb,
41692 + unsigned long event, void *unused);
41693 +static struct notifier_block otg_nb = {
41694 + .notifier_call = otg_handle_notification
41695 +};
41696 #endif
41697
41698 static struct regulator *ac_draw;
41699 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41700
41701 #ifdef CONFIG_USB_OTG_UTILS
41702 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41703 - otg_nb.notifier_call = otg_handle_notification;
41704 ret = usb_register_notifier(transceiver, &otg_nb);
41705 if (ret) {
41706 dev_err(dev, "failure to register otg notifier\n");
41707 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41708 index cc439fd..8fa30df 100644
41709 --- a/drivers/power/power_supply.h
41710 +++ b/drivers/power/power_supply.h
41711 @@ -16,12 +16,12 @@ struct power_supply;
41712
41713 #ifdef CONFIG_SYSFS
41714
41715 -extern void power_supply_init_attrs(struct device_type *dev_type);
41716 +extern void power_supply_init_attrs(void);
41717 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41718
41719 #else
41720
41721 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41722 +static inline void power_supply_init_attrs(void) {}
41723 #define power_supply_uevent NULL
41724
41725 #endif /* CONFIG_SYSFS */
41726 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41727 index 8a7cfb3..72e6e9b 100644
41728 --- a/drivers/power/power_supply_core.c
41729 +++ b/drivers/power/power_supply_core.c
41730 @@ -24,7 +24,10 @@
41731 struct class *power_supply_class;
41732 EXPORT_SYMBOL_GPL(power_supply_class);
41733
41734 -static struct device_type power_supply_dev_type;
41735 +extern const struct attribute_group *power_supply_attr_groups[];
41736 +static struct device_type power_supply_dev_type = {
41737 + .groups = power_supply_attr_groups,
41738 +};
41739
41740 static int __power_supply_changed_work(struct device *dev, void *data)
41741 {
41742 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41743 return PTR_ERR(power_supply_class);
41744
41745 power_supply_class->dev_uevent = power_supply_uevent;
41746 - power_supply_init_attrs(&power_supply_dev_type);
41747 + power_supply_init_attrs();
41748
41749 return 0;
41750 }
41751 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41752 index 40fa3b7..d9c2e0e 100644
41753 --- a/drivers/power/power_supply_sysfs.c
41754 +++ b/drivers/power/power_supply_sysfs.c
41755 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
41756 .is_visible = power_supply_attr_is_visible,
41757 };
41758
41759 -static const struct attribute_group *power_supply_attr_groups[] = {
41760 +const struct attribute_group *power_supply_attr_groups[] = {
41761 &power_supply_attr_group,
41762 NULL,
41763 };
41764
41765 -void power_supply_init_attrs(struct device_type *dev_type)
41766 +void power_supply_init_attrs(void)
41767 {
41768 int i;
41769
41770 - dev_type->groups = power_supply_attr_groups;
41771 -
41772 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41773 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41774 }
41775 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41776 index 4d7c635..9860196 100644
41777 --- a/drivers/regulator/max8660.c
41778 +++ b/drivers/regulator/max8660.c
41779 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41780 max8660->shadow_regs[MAX8660_OVER1] = 5;
41781 } else {
41782 /* Otherwise devices can be toggled via software */
41783 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41784 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41785 + pax_open_kernel();
41786 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41787 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41788 + pax_close_kernel();
41789 }
41790
41791 /*
41792 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41793 index 9a8ea91..c483dd9 100644
41794 --- a/drivers/regulator/max8973-regulator.c
41795 +++ b/drivers/regulator/max8973-regulator.c
41796 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41797 if (!pdata->enable_ext_control) {
41798 max->desc.enable_reg = MAX8973_VOUT;
41799 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41800 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41801 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41802 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41803 + pax_open_kernel();
41804 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41805 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41806 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41807 + pax_close_kernel();
41808 }
41809
41810 max->enable_external_control = pdata->enable_ext_control;
41811 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41812 index 0d84b1f..c2da6ac 100644
41813 --- a/drivers/regulator/mc13892-regulator.c
41814 +++ b/drivers/regulator/mc13892-regulator.c
41815 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41816 }
41817 mc13xxx_unlock(mc13892);
41818
41819 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41820 + pax_open_kernel();
41821 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41822 = mc13892_vcam_set_mode;
41823 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41824 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41825 = mc13892_vcam_get_mode;
41826 + pax_close_kernel();
41827
41828 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41829 ARRAY_SIZE(mc13892_regulators));
41830 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41831 index 16630aa..6afc992 100644
41832 --- a/drivers/rtc/rtc-cmos.c
41833 +++ b/drivers/rtc/rtc-cmos.c
41834 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41835 hpet_rtc_timer_init();
41836
41837 /* export at least the first block of NVRAM */
41838 - nvram.size = address_space - NVRAM_OFFSET;
41839 + pax_open_kernel();
41840 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41841 + pax_close_kernel();
41842 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41843 if (retval < 0) {
41844 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41845 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41846 index 9a86b4b..3a383dc 100644
41847 --- a/drivers/rtc/rtc-dev.c
41848 +++ b/drivers/rtc/rtc-dev.c
41849 @@ -14,6 +14,7 @@
41850 #include <linux/module.h>
41851 #include <linux/rtc.h>
41852 #include <linux/sched.h>
41853 +#include <linux/grsecurity.h>
41854 #include "rtc-core.h"
41855
41856 static dev_t rtc_devt;
41857 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
41858 if (copy_from_user(&tm, uarg, sizeof(tm)))
41859 return -EFAULT;
41860
41861 + gr_log_timechange();
41862 +
41863 return rtc_set_time(rtc, &tm);
41864
41865 case RTC_PIE_ON:
41866 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41867 index e0d0ba4..3c65868 100644
41868 --- a/drivers/rtc/rtc-ds1307.c
41869 +++ b/drivers/rtc/rtc-ds1307.c
41870 @@ -106,7 +106,7 @@ struct ds1307 {
41871 u8 offset; /* register's offset */
41872 u8 regs[11];
41873 u16 nvram_offset;
41874 - struct bin_attribute *nvram;
41875 + bin_attribute_no_const *nvram;
41876 enum ds_type type;
41877 unsigned long flags;
41878 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41879 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41880 index 130f29a..6179d03 100644
41881 --- a/drivers/rtc/rtc-m48t59.c
41882 +++ b/drivers/rtc/rtc-m48t59.c
41883 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41884 goto out;
41885 }
41886
41887 - m48t59_nvram_attr.size = pdata->offset;
41888 + pax_open_kernel();
41889 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41890 + pax_close_kernel();
41891
41892 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41893 if (ret) {
41894 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41895 index e693af6..2e525b6 100644
41896 --- a/drivers/scsi/bfa/bfa_fcpim.h
41897 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41898 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41899
41900 struct bfa_itn_s {
41901 bfa_isr_func_t isr;
41902 -};
41903 +} __no_const;
41904
41905 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41906 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41907 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41908 index 23a90e7..9cf04ee 100644
41909 --- a/drivers/scsi/bfa/bfa_ioc.h
41910 +++ b/drivers/scsi/bfa/bfa_ioc.h
41911 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41912 bfa_ioc_disable_cbfn_t disable_cbfn;
41913 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41914 bfa_ioc_reset_cbfn_t reset_cbfn;
41915 -};
41916 +} __no_const;
41917
41918 /*
41919 * IOC event notification mechanism.
41920 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41921 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41922 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41923 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41924 -};
41925 +} __no_const;
41926
41927 /*
41928 * Queue element to wait for room in request queue. FIFO order is
41929 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41930 index 593085a..47aa999 100644
41931 --- a/drivers/scsi/hosts.c
41932 +++ b/drivers/scsi/hosts.c
41933 @@ -42,7 +42,7 @@
41934 #include "scsi_logging.h"
41935
41936
41937 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41938 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41939
41940
41941 static void scsi_host_cls_release(struct device *dev)
41942 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41943 * subtract one because we increment first then return, but we need to
41944 * know what the next host number was before increment
41945 */
41946 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41947 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41948 shost->dma_channel = 0xff;
41949
41950 /* These three are default values which can be overridden */
41951 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41952 index 4f33806..afd6f60 100644
41953 --- a/drivers/scsi/hpsa.c
41954 +++ b/drivers/scsi/hpsa.c
41955 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41956 unsigned long flags;
41957
41958 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41959 - return h->access.command_completed(h, q);
41960 + return h->access->command_completed(h, q);
41961
41962 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41963 a = rq->head[rq->current_entry];
41964 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
41965 while (!list_empty(&h->reqQ)) {
41966 c = list_entry(h->reqQ.next, struct CommandList, list);
41967 /* can't do anything if fifo is full */
41968 - if ((h->access.fifo_full(h))) {
41969 + if ((h->access->fifo_full(h))) {
41970 dev_warn(&h->pdev->dev, "fifo full\n");
41971 break;
41972 }
41973 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
41974
41975 /* Tell the controller execute command */
41976 spin_unlock_irqrestore(&h->lock, flags);
41977 - h->access.submit_command(h, c);
41978 + h->access->submit_command(h, c);
41979 spin_lock_irqsave(&h->lock, flags);
41980 }
41981 spin_unlock_irqrestore(&h->lock, flags);
41982 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
41983
41984 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41985 {
41986 - return h->access.command_completed(h, q);
41987 + return h->access->command_completed(h, q);
41988 }
41989
41990 static inline bool interrupt_pending(struct ctlr_info *h)
41991 {
41992 - return h->access.intr_pending(h);
41993 + return h->access->intr_pending(h);
41994 }
41995
41996 static inline long interrupt_not_for_us(struct ctlr_info *h)
41997 {
41998 - return (h->access.intr_pending(h) == 0) ||
41999 + return (h->access->intr_pending(h) == 0) ||
42000 (h->interrupts_enabled == 0);
42001 }
42002
42003 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42004 if (prod_index < 0)
42005 return -ENODEV;
42006 h->product_name = products[prod_index].product_name;
42007 - h->access = *(products[prod_index].access);
42008 + h->access = products[prod_index].access;
42009
42010 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42011 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42012 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42013
42014 assert_spin_locked(&lockup_detector_lock);
42015 remove_ctlr_from_lockup_detector_list(h);
42016 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42017 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42018 spin_lock_irqsave(&h->lock, flags);
42019 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42020 spin_unlock_irqrestore(&h->lock, flags);
42021 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
42022 }
42023
42024 /* make sure the board interrupts are off */
42025 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42026 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42027
42028 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42029 goto clean2;
42030 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
42031 * fake ones to scoop up any residual completions.
42032 */
42033 spin_lock_irqsave(&h->lock, flags);
42034 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42035 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42036 spin_unlock_irqrestore(&h->lock, flags);
42037 free_irqs(h);
42038 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42039 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
42040 dev_info(&h->pdev->dev, "Board READY.\n");
42041 dev_info(&h->pdev->dev,
42042 "Waiting for stale completions to drain.\n");
42043 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42044 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42045 msleep(10000);
42046 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42047 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42048
42049 rc = controller_reset_failed(h->cfgtable);
42050 if (rc)
42051 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
42052 }
42053
42054 /* Turn the interrupts on so we can service requests */
42055 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42056 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42057
42058 hpsa_hba_inquiry(h);
42059 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42060 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42061 * To write all data in the battery backed cache to disks
42062 */
42063 hpsa_flush_cache(h);
42064 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42065 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42066 hpsa_free_irqs_and_disable_msix(h);
42067 }
42068
42069 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42070 return;
42071 }
42072 /* Change the access methods to the performant access methods */
42073 - h->access = SA5_performant_access;
42074 + h->access = &SA5_performant_access;
42075 h->transMethod = CFGTBL_Trans_Performant;
42076 }
42077
42078 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42079 index 9816479..c5d4e97 100644
42080 --- a/drivers/scsi/hpsa.h
42081 +++ b/drivers/scsi/hpsa.h
42082 @@ -79,7 +79,7 @@ struct ctlr_info {
42083 unsigned int msix_vector;
42084 unsigned int msi_vector;
42085 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42086 - struct access_method access;
42087 + struct access_method *access;
42088
42089 /* queue and queue Info */
42090 struct list_head reqQ;
42091 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42092 index c772d8d..35c362c 100644
42093 --- a/drivers/scsi/libfc/fc_exch.c
42094 +++ b/drivers/scsi/libfc/fc_exch.c
42095 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42096 u16 pool_max_index;
42097
42098 struct {
42099 - atomic_t no_free_exch;
42100 - atomic_t no_free_exch_xid;
42101 - atomic_t xid_not_found;
42102 - atomic_t xid_busy;
42103 - atomic_t seq_not_found;
42104 - atomic_t non_bls_resp;
42105 + atomic_unchecked_t no_free_exch;
42106 + atomic_unchecked_t no_free_exch_xid;
42107 + atomic_unchecked_t xid_not_found;
42108 + atomic_unchecked_t xid_busy;
42109 + atomic_unchecked_t seq_not_found;
42110 + atomic_unchecked_t non_bls_resp;
42111 } stats;
42112 };
42113
42114 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42115 /* allocate memory for exchange */
42116 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42117 if (!ep) {
42118 - atomic_inc(&mp->stats.no_free_exch);
42119 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42120 goto out;
42121 }
42122 memset(ep, 0, sizeof(*ep));
42123 @@ -786,7 +786,7 @@ out:
42124 return ep;
42125 err:
42126 spin_unlock_bh(&pool->lock);
42127 - atomic_inc(&mp->stats.no_free_exch_xid);
42128 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42129 mempool_free(ep, mp->ep_pool);
42130 return NULL;
42131 }
42132 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42133 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42134 ep = fc_exch_find(mp, xid);
42135 if (!ep) {
42136 - atomic_inc(&mp->stats.xid_not_found);
42137 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42138 reject = FC_RJT_OX_ID;
42139 goto out;
42140 }
42141 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42142 ep = fc_exch_find(mp, xid);
42143 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42144 if (ep) {
42145 - atomic_inc(&mp->stats.xid_busy);
42146 + atomic_inc_unchecked(&mp->stats.xid_busy);
42147 reject = FC_RJT_RX_ID;
42148 goto rel;
42149 }
42150 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42151 }
42152 xid = ep->xid; /* get our XID */
42153 } else if (!ep) {
42154 - atomic_inc(&mp->stats.xid_not_found);
42155 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42156 reject = FC_RJT_RX_ID; /* XID not found */
42157 goto out;
42158 }
42159 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42160 } else {
42161 sp = &ep->seq;
42162 if (sp->id != fh->fh_seq_id) {
42163 - atomic_inc(&mp->stats.seq_not_found);
42164 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42165 if (f_ctl & FC_FC_END_SEQ) {
42166 /*
42167 * Update sequence_id based on incoming last
42168 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42169
42170 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42171 if (!ep) {
42172 - atomic_inc(&mp->stats.xid_not_found);
42173 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42174 goto out;
42175 }
42176 if (ep->esb_stat & ESB_ST_COMPLETE) {
42177 - atomic_inc(&mp->stats.xid_not_found);
42178 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42179 goto rel;
42180 }
42181 if (ep->rxid == FC_XID_UNKNOWN)
42182 ep->rxid = ntohs(fh->fh_rx_id);
42183 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42184 - atomic_inc(&mp->stats.xid_not_found);
42185 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42186 goto rel;
42187 }
42188 if (ep->did != ntoh24(fh->fh_s_id) &&
42189 ep->did != FC_FID_FLOGI) {
42190 - atomic_inc(&mp->stats.xid_not_found);
42191 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42192 goto rel;
42193 }
42194 sof = fr_sof(fp);
42195 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42196 sp->ssb_stat |= SSB_ST_RESP;
42197 sp->id = fh->fh_seq_id;
42198 } else if (sp->id != fh->fh_seq_id) {
42199 - atomic_inc(&mp->stats.seq_not_found);
42200 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42201 goto rel;
42202 }
42203
42204 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42205 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42206
42207 if (!sp)
42208 - atomic_inc(&mp->stats.xid_not_found);
42209 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42210 else
42211 - atomic_inc(&mp->stats.non_bls_resp);
42212 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42213
42214 fc_frame_free(fp);
42215 }
42216 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42217
42218 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42219 mp = ema->mp;
42220 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42221 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42222 st->fc_no_free_exch_xid +=
42223 - atomic_read(&mp->stats.no_free_exch_xid);
42224 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42225 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42226 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42227 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42228 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42229 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42230 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42231 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42232 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42233 }
42234 }
42235 EXPORT_SYMBOL(fc_exch_update_stats);
42236 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42237 index bdb81cd..d3c7c2c 100644
42238 --- a/drivers/scsi/libsas/sas_ata.c
42239 +++ b/drivers/scsi/libsas/sas_ata.c
42240 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42241 .postreset = ata_std_postreset,
42242 .error_handler = ata_std_error_handler,
42243 .post_internal_cmd = sas_ata_post_internal,
42244 - .qc_defer = ata_std_qc_defer,
42245 + .qc_defer = ata_std_qc_defer,
42246 .qc_prep = ata_noop_qc_prep,
42247 .qc_issue = sas_ata_qc_issue,
42248 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42249 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42250 index df4c13a..a51e90c 100644
42251 --- a/drivers/scsi/lpfc/lpfc.h
42252 +++ b/drivers/scsi/lpfc/lpfc.h
42253 @@ -424,7 +424,7 @@ struct lpfc_vport {
42254 struct dentry *debug_nodelist;
42255 struct dentry *vport_debugfs_root;
42256 struct lpfc_debugfs_trc *disc_trc;
42257 - atomic_t disc_trc_cnt;
42258 + atomic_unchecked_t disc_trc_cnt;
42259 #endif
42260 uint8_t stat_data_enabled;
42261 uint8_t stat_data_blocked;
42262 @@ -842,8 +842,8 @@ struct lpfc_hba {
42263 struct timer_list fabric_block_timer;
42264 unsigned long bit_flags;
42265 #define FABRIC_COMANDS_BLOCKED 0
42266 - atomic_t num_rsrc_err;
42267 - atomic_t num_cmd_success;
42268 + atomic_unchecked_t num_rsrc_err;
42269 + atomic_unchecked_t num_cmd_success;
42270 unsigned long last_rsrc_error_time;
42271 unsigned long last_ramp_down_time;
42272 unsigned long last_ramp_up_time;
42273 @@ -879,7 +879,7 @@ struct lpfc_hba {
42274
42275 struct dentry *debug_slow_ring_trc;
42276 struct lpfc_debugfs_trc *slow_ring_trc;
42277 - atomic_t slow_ring_trc_cnt;
42278 + atomic_unchecked_t slow_ring_trc_cnt;
42279 /* iDiag debugfs sub-directory */
42280 struct dentry *idiag_root;
42281 struct dentry *idiag_pci_cfg;
42282 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42283 index f63f5ff..de29189 100644
42284 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42285 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42286 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42287
42288 #include <linux/debugfs.h>
42289
42290 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42291 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42292 static unsigned long lpfc_debugfs_start_time = 0L;
42293
42294 /* iDiag */
42295 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42296 lpfc_debugfs_enable = 0;
42297
42298 len = 0;
42299 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42300 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42301 (lpfc_debugfs_max_disc_trc - 1);
42302 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42303 dtp = vport->disc_trc + i;
42304 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42305 lpfc_debugfs_enable = 0;
42306
42307 len = 0;
42308 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42309 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42310 (lpfc_debugfs_max_slow_ring_trc - 1);
42311 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42312 dtp = phba->slow_ring_trc + i;
42313 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42314 !vport || !vport->disc_trc)
42315 return;
42316
42317 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42318 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42319 (lpfc_debugfs_max_disc_trc - 1);
42320 dtp = vport->disc_trc + index;
42321 dtp->fmt = fmt;
42322 dtp->data1 = data1;
42323 dtp->data2 = data2;
42324 dtp->data3 = data3;
42325 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42326 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42327 dtp->jif = jiffies;
42328 #endif
42329 return;
42330 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42331 !phba || !phba->slow_ring_trc)
42332 return;
42333
42334 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42335 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42336 (lpfc_debugfs_max_slow_ring_trc - 1);
42337 dtp = phba->slow_ring_trc + index;
42338 dtp->fmt = fmt;
42339 dtp->data1 = data1;
42340 dtp->data2 = data2;
42341 dtp->data3 = data3;
42342 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42343 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42344 dtp->jif = jiffies;
42345 #endif
42346 return;
42347 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42348 "slow_ring buffer\n");
42349 goto debug_failed;
42350 }
42351 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42352 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42353 memset(phba->slow_ring_trc, 0,
42354 (sizeof(struct lpfc_debugfs_trc) *
42355 lpfc_debugfs_max_slow_ring_trc));
42356 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42357 "buffer\n");
42358 goto debug_failed;
42359 }
42360 - atomic_set(&vport->disc_trc_cnt, 0);
42361 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42362
42363 snprintf(name, sizeof(name), "discovery_trace");
42364 vport->debug_disc_trc =
42365 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42366 index 89ad558..76956c4 100644
42367 --- a/drivers/scsi/lpfc/lpfc_init.c
42368 +++ b/drivers/scsi/lpfc/lpfc_init.c
42369 @@ -10618,8 +10618,10 @@ lpfc_init(void)
42370 "misc_register returned with status %d", error);
42371
42372 if (lpfc_enable_npiv) {
42373 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42374 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42375 + pax_open_kernel();
42376 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42377 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42378 + pax_close_kernel();
42379 }
42380 lpfc_transport_template =
42381 fc_attach_transport(&lpfc_transport_functions);
42382 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42383 index 60e5a17..ff7a793 100644
42384 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42385 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42386 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42387 uint32_t evt_posted;
42388
42389 spin_lock_irqsave(&phba->hbalock, flags);
42390 - atomic_inc(&phba->num_rsrc_err);
42391 + atomic_inc_unchecked(&phba->num_rsrc_err);
42392 phba->last_rsrc_error_time = jiffies;
42393
42394 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42395 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42396 unsigned long flags;
42397 struct lpfc_hba *phba = vport->phba;
42398 uint32_t evt_posted;
42399 - atomic_inc(&phba->num_cmd_success);
42400 + atomic_inc_unchecked(&phba->num_cmd_success);
42401
42402 if (vport->cfg_lun_queue_depth <= queue_depth)
42403 return;
42404 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42405 unsigned long num_rsrc_err, num_cmd_success;
42406 int i;
42407
42408 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42409 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42410 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42411 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42412
42413 /*
42414 * The error and success command counters are global per
42415 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42416 }
42417 }
42418 lpfc_destroy_vport_work_array(phba, vports);
42419 - atomic_set(&phba->num_rsrc_err, 0);
42420 - atomic_set(&phba->num_cmd_success, 0);
42421 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42422 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42423 }
42424
42425 /**
42426 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42427 }
42428 }
42429 lpfc_destroy_vport_work_array(phba, vports);
42430 - atomic_set(&phba->num_rsrc_err, 0);
42431 - atomic_set(&phba->num_cmd_success, 0);
42432 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42433 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42434 }
42435
42436 /**
42437 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42438 index b46f5e9..c4c4ccb 100644
42439 --- a/drivers/scsi/pmcraid.c
42440 +++ b/drivers/scsi/pmcraid.c
42441 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42442 res->scsi_dev = scsi_dev;
42443 scsi_dev->hostdata = res;
42444 res->change_detected = 0;
42445 - atomic_set(&res->read_failures, 0);
42446 - atomic_set(&res->write_failures, 0);
42447 + atomic_set_unchecked(&res->read_failures, 0);
42448 + atomic_set_unchecked(&res->write_failures, 0);
42449 rc = 0;
42450 }
42451 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42452 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42453
42454 /* If this was a SCSI read/write command keep count of errors */
42455 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42456 - atomic_inc(&res->read_failures);
42457 + atomic_inc_unchecked(&res->read_failures);
42458 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42459 - atomic_inc(&res->write_failures);
42460 + atomic_inc_unchecked(&res->write_failures);
42461
42462 if (!RES_IS_GSCSI(res->cfg_entry) &&
42463 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42464 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42465 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42466 * hrrq_id assigned here in queuecommand
42467 */
42468 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42469 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42470 pinstance->num_hrrq;
42471 cmd->cmd_done = pmcraid_io_done;
42472
42473 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42474 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42475 * hrrq_id assigned here in queuecommand
42476 */
42477 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42478 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42479 pinstance->num_hrrq;
42480
42481 if (request_size) {
42482 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42483
42484 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42485 /* add resources only after host is added into system */
42486 - if (!atomic_read(&pinstance->expose_resources))
42487 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42488 return;
42489
42490 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42491 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42492 init_waitqueue_head(&pinstance->reset_wait_q);
42493
42494 atomic_set(&pinstance->outstanding_cmds, 0);
42495 - atomic_set(&pinstance->last_message_id, 0);
42496 - atomic_set(&pinstance->expose_resources, 0);
42497 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42498 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42499
42500 INIT_LIST_HEAD(&pinstance->free_res_q);
42501 INIT_LIST_HEAD(&pinstance->used_res_q);
42502 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42503 /* Schedule worker thread to handle CCN and take care of adding and
42504 * removing devices to OS
42505 */
42506 - atomic_set(&pinstance->expose_resources, 1);
42507 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42508 schedule_work(&pinstance->worker_q);
42509 return rc;
42510
42511 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42512 index e1d150f..6c6df44 100644
42513 --- a/drivers/scsi/pmcraid.h
42514 +++ b/drivers/scsi/pmcraid.h
42515 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42516 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42517
42518 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42519 - atomic_t last_message_id;
42520 + atomic_unchecked_t last_message_id;
42521
42522 /* configuration table */
42523 struct pmcraid_config_table *cfg_table;
42524 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42525 atomic_t outstanding_cmds;
42526
42527 /* should add/delete resources to mid-layer now ?*/
42528 - atomic_t expose_resources;
42529 + atomic_unchecked_t expose_resources;
42530
42531
42532
42533 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42534 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42535 };
42536 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42537 - atomic_t read_failures; /* count of failed READ commands */
42538 - atomic_t write_failures; /* count of failed WRITE commands */
42539 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42540 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42541
42542 /* To indicate add/delete/modify during CCN */
42543 u8 change_detected;
42544 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42545 index 83d7984..a27d947 100644
42546 --- a/drivers/scsi/qla2xxx/qla_attr.c
42547 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42548 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42549 return 0;
42550 }
42551
42552 -struct fc_function_template qla2xxx_transport_functions = {
42553 +fc_function_template_no_const qla2xxx_transport_functions = {
42554
42555 .show_host_node_name = 1,
42556 .show_host_port_name = 1,
42557 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42558 .bsg_timeout = qla24xx_bsg_timeout,
42559 };
42560
42561 -struct fc_function_template qla2xxx_transport_vport_functions = {
42562 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42563
42564 .show_host_node_name = 1,
42565 .show_host_port_name = 1,
42566 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42567 index 2411d1a..4673766 100644
42568 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42569 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42570 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42571 struct device_attribute;
42572 extern struct device_attribute *qla2x00_host_attrs[];
42573 struct fc_function_template;
42574 -extern struct fc_function_template qla2xxx_transport_functions;
42575 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42576 +extern fc_function_template_no_const qla2xxx_transport_functions;
42577 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42578 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42579 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42580 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42581 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42582 index 10d23f8..a7d5d4c 100644
42583 --- a/drivers/scsi/qla2xxx/qla_os.c
42584 +++ b/drivers/scsi/qla2xxx/qla_os.c
42585 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42586 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42587 /* Ok, a 64bit DMA mask is applicable. */
42588 ha->flags.enable_64bit_addressing = 1;
42589 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42590 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42591 + pax_open_kernel();
42592 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42593 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42594 + pax_close_kernel();
42595 return;
42596 }
42597 }
42598 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42599 index 329d553..f20d31d 100644
42600 --- a/drivers/scsi/qla4xxx/ql4_def.h
42601 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42602 @@ -273,7 +273,7 @@ struct ddb_entry {
42603 * (4000 only) */
42604 atomic_t relogin_timer; /* Max Time to wait for
42605 * relogin to complete */
42606 - atomic_t relogin_retry_count; /* Num of times relogin has been
42607 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42608 * retried */
42609 uint32_t default_time2wait; /* Default Min time between
42610 * relogins (+aens) */
42611 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42612 index 4cec123..7c1329f 100644
42613 --- a/drivers/scsi/qla4xxx/ql4_os.c
42614 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42615 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42616 */
42617 if (!iscsi_is_session_online(cls_sess)) {
42618 /* Reset retry relogin timer */
42619 - atomic_inc(&ddb_entry->relogin_retry_count);
42620 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42621 DEBUG2(ql4_printk(KERN_INFO, ha,
42622 "%s: index[%d] relogin timed out-retrying"
42623 " relogin (%d), retry (%d)\n", __func__,
42624 ddb_entry->fw_ddb_index,
42625 - atomic_read(&ddb_entry->relogin_retry_count),
42626 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42627 ddb_entry->default_time2wait + 4));
42628 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42629 atomic_set(&ddb_entry->retry_relogin_timer,
42630 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42631
42632 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42633 atomic_set(&ddb_entry->relogin_timer, 0);
42634 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42635 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42636 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42637 ddb_entry->default_relogin_timeout =
42638 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42639 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42640 index 2c0d0ec..4e8681a 100644
42641 --- a/drivers/scsi/scsi.c
42642 +++ b/drivers/scsi/scsi.c
42643 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42644 unsigned long timeout;
42645 int rtn = 0;
42646
42647 - atomic_inc(&cmd->device->iorequest_cnt);
42648 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42649
42650 /* check if the device is still usable */
42651 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42652 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42653 index f1bf5af..f67e943 100644
42654 --- a/drivers/scsi/scsi_lib.c
42655 +++ b/drivers/scsi/scsi_lib.c
42656 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42657 shost = sdev->host;
42658 scsi_init_cmd_errh(cmd);
42659 cmd->result = DID_NO_CONNECT << 16;
42660 - atomic_inc(&cmd->device->iorequest_cnt);
42661 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42662
42663 /*
42664 * SCSI request completion path will do scsi_device_unbusy(),
42665 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
42666
42667 INIT_LIST_HEAD(&cmd->eh_entry);
42668
42669 - atomic_inc(&cmd->device->iodone_cnt);
42670 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42671 if (cmd->result)
42672 - atomic_inc(&cmd->device->ioerr_cnt);
42673 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42674
42675 disposition = scsi_decide_disposition(cmd);
42676 if (disposition != SUCCESS &&
42677 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42678 index 931a7d9..0c2a754 100644
42679 --- a/drivers/scsi/scsi_sysfs.c
42680 +++ b/drivers/scsi/scsi_sysfs.c
42681 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42682 char *buf) \
42683 { \
42684 struct scsi_device *sdev = to_scsi_device(dev); \
42685 - unsigned long long count = atomic_read(&sdev->field); \
42686 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42687 return snprintf(buf, 20, "0x%llx\n", count); \
42688 } \
42689 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42690 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42691 index 84a1fdf..693b0d6 100644
42692 --- a/drivers/scsi/scsi_tgt_lib.c
42693 +++ b/drivers/scsi/scsi_tgt_lib.c
42694 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42695 int err;
42696
42697 dprintk("%lx %u\n", uaddr, len);
42698 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42699 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42700 if (err) {
42701 /*
42702 * TODO: need to fixup sg_tablesize, max_segment_size,
42703 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42704 index e894ca7..de9d7660 100644
42705 --- a/drivers/scsi/scsi_transport_fc.c
42706 +++ b/drivers/scsi/scsi_transport_fc.c
42707 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42708 * Netlink Infrastructure
42709 */
42710
42711 -static atomic_t fc_event_seq;
42712 +static atomic_unchecked_t fc_event_seq;
42713
42714 /**
42715 * fc_get_event_number - Obtain the next sequential FC event number
42716 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42717 u32
42718 fc_get_event_number(void)
42719 {
42720 - return atomic_add_return(1, &fc_event_seq);
42721 + return atomic_add_return_unchecked(1, &fc_event_seq);
42722 }
42723 EXPORT_SYMBOL(fc_get_event_number);
42724
42725 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42726 {
42727 int error;
42728
42729 - atomic_set(&fc_event_seq, 0);
42730 + atomic_set_unchecked(&fc_event_seq, 0);
42731
42732 error = transport_class_register(&fc_host_class);
42733 if (error)
42734 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42735 char *cp;
42736
42737 *val = simple_strtoul(buf, &cp, 0);
42738 - if ((*cp && (*cp != '\n')) || (*val < 0))
42739 + if (*cp && (*cp != '\n'))
42740 return -EINVAL;
42741 /*
42742 * Check for overflow; dev_loss_tmo is u32
42743 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42744 index 31969f2..2b348f0 100644
42745 --- a/drivers/scsi/scsi_transport_iscsi.c
42746 +++ b/drivers/scsi/scsi_transport_iscsi.c
42747 @@ -79,7 +79,7 @@ struct iscsi_internal {
42748 struct transport_container session_cont;
42749 };
42750
42751 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42752 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42753 static struct workqueue_struct *iscsi_eh_timer_workq;
42754
42755 static DEFINE_IDA(iscsi_sess_ida);
42756 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42757 int err;
42758
42759 ihost = shost->shost_data;
42760 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42761 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42762
42763 if (target_id == ISCSI_MAX_TARGET) {
42764 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42765 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
42766 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42767 ISCSI_TRANSPORT_VERSION);
42768
42769 - atomic_set(&iscsi_session_nr, 0);
42770 + atomic_set_unchecked(&iscsi_session_nr, 0);
42771
42772 err = class_register(&iscsi_transport_class);
42773 if (err)
42774 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42775 index f379c7f..e8fc69c 100644
42776 --- a/drivers/scsi/scsi_transport_srp.c
42777 +++ b/drivers/scsi/scsi_transport_srp.c
42778 @@ -33,7 +33,7 @@
42779 #include "scsi_transport_srp_internal.h"
42780
42781 struct srp_host_attrs {
42782 - atomic_t next_port_id;
42783 + atomic_unchecked_t next_port_id;
42784 };
42785 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42786
42787 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42788 struct Scsi_Host *shost = dev_to_shost(dev);
42789 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42790
42791 - atomic_set(&srp_host->next_port_id, 0);
42792 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42793 return 0;
42794 }
42795
42796 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42797 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42798 rport->roles = ids->roles;
42799
42800 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42801 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42802 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42803
42804 transport_setup_device(&rport->dev);
42805 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42806 index 7992635..609faf8 100644
42807 --- a/drivers/scsi/sd.c
42808 +++ b/drivers/scsi/sd.c
42809 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42810 sdkp->disk = gd;
42811 sdkp->index = index;
42812 atomic_set(&sdkp->openers, 0);
42813 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42814 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42815
42816 if (!sdp->request_queue->rq_timeout) {
42817 if (sdp->type != TYPE_MOD)
42818 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42819 index be2c9a6..275525c 100644
42820 --- a/drivers/scsi/sg.c
42821 +++ b/drivers/scsi/sg.c
42822 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42823 sdp->disk->disk_name,
42824 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42825 NULL,
42826 - (char *)arg);
42827 + (char __user *)arg);
42828 case BLKTRACESTART:
42829 return blk_trace_startstop(sdp->device->request_queue, 1);
42830 case BLKTRACESTOP:
42831 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42832 index 19ee901..6e8c2ef 100644
42833 --- a/drivers/spi/spi.c
42834 +++ b/drivers/spi/spi.c
42835 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
42836 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42837
42838 /* portable code must never pass more than 32 bytes */
42839 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42840 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42841
42842 static u8 *buf;
42843
42844 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42845 index c7a5f97..71ecd35 100644
42846 --- a/drivers/staging/iio/iio_hwmon.c
42847 +++ b/drivers/staging/iio/iio_hwmon.c
42848 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
42849 static int iio_hwmon_probe(struct platform_device *pdev)
42850 {
42851 struct iio_hwmon_state *st;
42852 - struct sensor_device_attribute *a;
42853 + sensor_device_attribute_no_const *a;
42854 int ret, i;
42855 int in_i = 1, temp_i = 1, curr_i = 1;
42856 enum iio_chan_type type;
42857 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42858 index 34afc16..ffe44dd 100644
42859 --- a/drivers/staging/octeon/ethernet-rx.c
42860 +++ b/drivers/staging/octeon/ethernet-rx.c
42861 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42862 /* Increment RX stats for virtual ports */
42863 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42864 #ifdef CONFIG_64BIT
42865 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42866 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42867 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42868 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42869 #else
42870 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42871 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42872 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42873 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42874 #endif
42875 }
42876 netif_receive_skb(skb);
42877 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42878 dev->name);
42879 */
42880 #ifdef CONFIG_64BIT
42881 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42882 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42883 #else
42884 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42885 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42886 #endif
42887 dev_kfree_skb_irq(skb);
42888 }
42889 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42890 index ef32dc1..a159d68 100644
42891 --- a/drivers/staging/octeon/ethernet.c
42892 +++ b/drivers/staging/octeon/ethernet.c
42893 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42894 * since the RX tasklet also increments it.
42895 */
42896 #ifdef CONFIG_64BIT
42897 - atomic64_add(rx_status.dropped_packets,
42898 - (atomic64_t *)&priv->stats.rx_dropped);
42899 + atomic64_add_unchecked(rx_status.dropped_packets,
42900 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42901 #else
42902 - atomic_add(rx_status.dropped_packets,
42903 - (atomic_t *)&priv->stats.rx_dropped);
42904 + atomic_add_unchecked(rx_status.dropped_packets,
42905 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42906 #endif
42907 }
42908
42909 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42910 index a2b7e03..aaf3630 100644
42911 --- a/drivers/staging/ramster/tmem.c
42912 +++ b/drivers/staging/ramster/tmem.c
42913 @@ -50,25 +50,25 @@
42914 * A tmem host implementation must use this function to register callbacks
42915 * for memory allocation.
42916 */
42917 -static struct tmem_hostops tmem_hostops;
42918 +static struct tmem_hostops *tmem_hostops;
42919
42920 static void tmem_objnode_tree_init(void);
42921
42922 void tmem_register_hostops(struct tmem_hostops *m)
42923 {
42924 tmem_objnode_tree_init();
42925 - tmem_hostops = *m;
42926 + tmem_hostops = m;
42927 }
42928
42929 /*
42930 * A tmem host implementation must use this function to register
42931 * callbacks for a page-accessible memory (PAM) implementation.
42932 */
42933 -static struct tmem_pamops tmem_pamops;
42934 +static struct tmem_pamops *tmem_pamops;
42935
42936 void tmem_register_pamops(struct tmem_pamops *m)
42937 {
42938 - tmem_pamops = *m;
42939 + tmem_pamops = m;
42940 }
42941
42942 /*
42943 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42944 obj->pampd_count = 0;
42945 #ifdef CONFIG_RAMSTER
42946 if (tmem_pamops.new_obj != NULL)
42947 - (*tmem_pamops.new_obj)(obj);
42948 + (tmem_pamops->new_obj)(obj);
42949 #endif
42950 SET_SENTINEL(obj, OBJ);
42951
42952 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42953 rbnode = rb_next(rbnode);
42954 tmem_pampd_destroy_all_in_obj(obj, true);
42955 tmem_obj_free(obj, hb);
42956 - (*tmem_hostops.obj_free)(obj, pool);
42957 + (tmem_hostops->obj_free)(obj, pool);
42958 }
42959 spin_unlock(&hb->lock);
42960 }
42961 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
42962 ASSERT_SENTINEL(obj, OBJ);
42963 BUG_ON(obj->pool == NULL);
42964 ASSERT_SENTINEL(obj->pool, POOL);
42965 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
42966 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
42967 if (unlikely(objnode == NULL))
42968 goto out;
42969 objnode->obj = obj;
42970 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
42971 ASSERT_SENTINEL(pool, POOL);
42972 objnode->obj->objnode_count--;
42973 objnode->obj = NULL;
42974 - (*tmem_hostops.objnode_free)(objnode, pool);
42975 + (tmem_hostops->objnode_free)(objnode, pool);
42976 }
42977
42978 /*
42979 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
42980 void *old_pampd = *(void **)slot;
42981 *(void **)slot = new_pampd;
42982 if (!no_free)
42983 - (*tmem_pamops.free)(old_pampd, obj->pool,
42984 + (tmem_pamops->free)(old_pampd, obj->pool,
42985 NULL, 0, false);
42986 ret = new_pampd;
42987 }
42988 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
42989 if (objnode->slots[i]) {
42990 if (ht == 1) {
42991 obj->pampd_count--;
42992 - (*tmem_pamops.free)(objnode->slots[i],
42993 + (tmem_pamops->free)(objnode->slots[i],
42994 obj->pool, NULL, 0, true);
42995 objnode->slots[i] = NULL;
42996 continue;
42997 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42998 return;
42999 if (obj->objnode_tree_height == 0) {
43000 obj->pampd_count--;
43001 - (*tmem_pamops.free)(obj->objnode_tree_root,
43002 + (tmem_pamops->free)(obj->objnode_tree_root,
43003 obj->pool, NULL, 0, true);
43004 } else {
43005 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
43006 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43007 obj->objnode_tree_root = NULL;
43008 #ifdef CONFIG_RAMSTER
43009 if (tmem_pamops.free_obj != NULL)
43010 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
43011 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
43012 #endif
43013 }
43014
43015 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43016 /* if found, is a dup put, flush the old one */
43017 pampd_del = tmem_pampd_delete_from_obj(obj, index);
43018 BUG_ON(pampd_del != pampd);
43019 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43020 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43021 if (obj->pampd_count == 0) {
43022 objnew = obj;
43023 objfound = NULL;
43024 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43025 pampd = NULL;
43026 }
43027 } else {
43028 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
43029 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
43030 if (unlikely(obj == NULL)) {
43031 ret = -ENOMEM;
43032 goto out;
43033 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43034 if (unlikely(ret == -ENOMEM))
43035 /* may have partially built objnode tree ("stump") */
43036 goto delete_and_free;
43037 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
43038 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
43039 goto out;
43040
43041 delete_and_free:
43042 (void)tmem_pampd_delete_from_obj(obj, index);
43043 if (pampd)
43044 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
43045 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
43046 if (objnew) {
43047 tmem_obj_free(objnew, hb);
43048 - (*tmem_hostops.obj_free)(objnew, pool);
43049 + (tmem_hostops->obj_free)(objnew, pool);
43050 }
43051 out:
43052 spin_unlock(&hb->lock);
43053 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
43054 if (pampd != NULL) {
43055 BUG_ON(obj == NULL);
43056 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
43057 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
43058 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
43059 } else if (delete) {
43060 BUG_ON(obj == NULL);
43061 (void)tmem_pampd_delete_from_obj(obj, index);
43062 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43063 int ret = 0;
43064
43065 if (!is_ephemeral(pool))
43066 - new_pampd = (*tmem_pamops.repatriate_preload)(
43067 + new_pampd = (tmem_pamops->repatriate_preload)(
43068 old_pampd, pool, oidp, index, &intransit);
43069 if (intransit)
43070 ret = -EAGAIN;
43071 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43072 /* must release the hb->lock else repatriate can't sleep */
43073 spin_unlock(&hb->lock);
43074 if (!intransit)
43075 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
43076 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
43077 oidp, index, free, data);
43078 if (ret == -EAGAIN) {
43079 /* rare I think, but should cond_resched()??? */
43080 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
43081 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
43082 /* if we bug here, pamops wasn't properly set up for ramster */
43083 BUG_ON(tmem_pamops.replace_in_obj == NULL);
43084 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
43085 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
43086 out:
43087 spin_unlock(&hb->lock);
43088 return ret;
43089 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43090 if (free) {
43091 if (obj->pampd_count == 0) {
43092 tmem_obj_free(obj, hb);
43093 - (*tmem_hostops.obj_free)(obj, pool);
43094 + (tmem_hostops->obj_free)(obj, pool);
43095 obj = NULL;
43096 }
43097 }
43098 if (free)
43099 - ret = (*tmem_pamops.get_data_and_free)(
43100 + ret = (tmem_pamops->get_data_and_free)(
43101 data, sizep, raw, pampd, pool, oidp, index);
43102 else
43103 - ret = (*tmem_pamops.get_data)(
43104 + ret = (tmem_pamops->get_data)(
43105 data, sizep, raw, pampd, pool, oidp, index);
43106 if (ret < 0)
43107 goto out;
43108 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
43109 pampd = tmem_pampd_delete_from_obj(obj, index);
43110 if (pampd == NULL)
43111 goto out;
43112 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43113 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43114 if (obj->pampd_count == 0) {
43115 tmem_obj_free(obj, hb);
43116 - (*tmem_hostops.obj_free)(obj, pool);
43117 + (tmem_hostops->obj_free)(obj, pool);
43118 }
43119 ret = 0;
43120
43121 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
43122 goto out;
43123 tmem_pampd_destroy_all_in_obj(obj, false);
43124 tmem_obj_free(obj, hb);
43125 - (*tmem_hostops.obj_free)(obj, pool);
43126 + (tmem_hostops->obj_free)(obj, pool);
43127 ret = 0;
43128
43129 out:
43130 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43131 index dc23395..cf7e9b1 100644
43132 --- a/drivers/staging/rtl8712/rtl871x_io.h
43133 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43134 @@ -108,7 +108,7 @@ struct _io_ops {
43135 u8 *pmem);
43136 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43137 u8 *pmem);
43138 -};
43139 +} __no_const;
43140
43141 struct io_req {
43142 struct list_head list;
43143 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43144 index 1f5088b..0e59820 100644
43145 --- a/drivers/staging/sbe-2t3e3/netdev.c
43146 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43147 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43148 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43149
43150 if (rlen)
43151 - if (copy_to_user(data, &resp, rlen))
43152 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43153 return -EFAULT;
43154
43155 return 0;
43156 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43157 index 5dddc4d..34fcb2f 100644
43158 --- a/drivers/staging/usbip/vhci.h
43159 +++ b/drivers/staging/usbip/vhci.h
43160 @@ -83,7 +83,7 @@ struct vhci_hcd {
43161 unsigned resuming:1;
43162 unsigned long re_timeout;
43163
43164 - atomic_t seqnum;
43165 + atomic_unchecked_t seqnum;
43166
43167 /*
43168 * NOTE:
43169 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43170 index c3aa219..bf8b3de 100644
43171 --- a/drivers/staging/usbip/vhci_hcd.c
43172 +++ b/drivers/staging/usbip/vhci_hcd.c
43173 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
43174 return;
43175 }
43176
43177 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43178 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43179 if (priv->seqnum == 0xffff)
43180 dev_info(&urb->dev->dev, "seqnum max\n");
43181
43182 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43183 return -ENOMEM;
43184 }
43185
43186 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43187 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43188 if (unlink->seqnum == 0xffff)
43189 pr_info("seqnum max\n");
43190
43191 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
43192 vdev->rhport = rhport;
43193 }
43194
43195 - atomic_set(&vhci->seqnum, 0);
43196 + atomic_set_unchecked(&vhci->seqnum, 0);
43197 spin_lock_init(&vhci->lock);
43198
43199 hcd->power_budget = 0; /* no limit */
43200 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43201 index ba5f1c0..11d8122 100644
43202 --- a/drivers/staging/usbip/vhci_rx.c
43203 +++ b/drivers/staging/usbip/vhci_rx.c
43204 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43205 if (!urb) {
43206 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43207 pr_info("max seqnum %d\n",
43208 - atomic_read(&the_controller->seqnum));
43209 + atomic_read_unchecked(&the_controller->seqnum));
43210 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43211 return;
43212 }
43213 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43214 index 5f13890..36a044b 100644
43215 --- a/drivers/staging/vt6655/hostap.c
43216 +++ b/drivers/staging/vt6655/hostap.c
43217 @@ -73,14 +73,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(PSDevice pDevice, int rtnl_locked)
43224 {
43225 PSDevice 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 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice 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/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43244 index 26a7d0e..897b083 100644
43245 --- a/drivers/staging/vt6656/hostap.c
43246 +++ b/drivers/staging/vt6656/hostap.c
43247 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43248 *
43249 */
43250
43251 +static net_device_ops_no_const apdev_netdev_ops;
43252 +
43253 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43254 {
43255 PSDevice apdev_priv;
43256 struct net_device *dev = pDevice->dev;
43257 int ret;
43258 - const struct net_device_ops apdev_netdev_ops = {
43259 - .ndo_start_xmit = pDevice->tx_80211,
43260 - };
43261
43262 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43263
43264 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43265 *apdev_priv = *pDevice;
43266 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43267
43268 + /* only half broken now */
43269 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43270 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43271
43272 pDevice->apdev->type = ARPHRD_IEEE80211;
43273 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43274 index 56c8e60..1920c63 100644
43275 --- a/drivers/staging/zcache/tmem.c
43276 +++ b/drivers/staging/zcache/tmem.c
43277 @@ -39,7 +39,7 @@
43278 * A tmem host implementation must use this function to register callbacks
43279 * for memory allocation.
43280 */
43281 -static struct tmem_hostops tmem_hostops;
43282 +static tmem_hostops_no_const tmem_hostops;
43283
43284 static void tmem_objnode_tree_init(void);
43285
43286 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43287 * A tmem host implementation must use this function to register
43288 * callbacks for a page-accessible memory (PAM) implementation
43289 */
43290 -static struct tmem_pamops tmem_pamops;
43291 +static tmem_pamops_no_const tmem_pamops;
43292
43293 void tmem_register_pamops(struct tmem_pamops *m)
43294 {
43295 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43296 index 0d4aa82..f7832d4 100644
43297 --- a/drivers/staging/zcache/tmem.h
43298 +++ b/drivers/staging/zcache/tmem.h
43299 @@ -180,6 +180,7 @@ struct tmem_pamops {
43300 void (*new_obj)(struct tmem_obj *);
43301 int (*replace_in_obj)(void *, struct tmem_obj *);
43302 };
43303 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43304 extern void tmem_register_pamops(struct tmem_pamops *m);
43305
43306 /* memory allocation methods provided by the host implementation */
43307 @@ -189,6 +190,7 @@ struct tmem_hostops {
43308 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43309 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43310 };
43311 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43312 extern void tmem_register_hostops(struct tmem_hostops *m);
43313
43314 /* core tmem accessor functions */
43315 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43316 index 96f4981..4daaa7e 100644
43317 --- a/drivers/target/target_core_device.c
43318 +++ b/drivers/target/target_core_device.c
43319 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43320 spin_lock_init(&dev->se_port_lock);
43321 spin_lock_init(&dev->se_tmr_lock);
43322 spin_lock_init(&dev->qf_cmd_lock);
43323 - atomic_set(&dev->dev_ordered_id, 0);
43324 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43325 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43326 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43327 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43328 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43329 index fcf880f..a4d1e8f 100644
43330 --- a/drivers/target/target_core_transport.c
43331 +++ b/drivers/target/target_core_transport.c
43332 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43333 * Used to determine when ORDERED commands should go from
43334 * Dormant to Active status.
43335 */
43336 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43337 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43338 smp_mb__after_atomic_inc();
43339 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43340 cmd->se_ordered_id, cmd->sam_task_attr,
43341 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43342 index b09c8d1f..c4225c0 100644
43343 --- a/drivers/tty/cyclades.c
43344 +++ b/drivers/tty/cyclades.c
43345 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43346 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43347 info->port.count);
43348 #endif
43349 - info->port.count++;
43350 + atomic_inc(&info->port.count);
43351 #ifdef CY_DEBUG_COUNT
43352 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43353 - current->pid, info->port.count);
43354 + current->pid, atomic_read(&info->port.count));
43355 #endif
43356
43357 /*
43358 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43359 for (j = 0; j < cy_card[i].nports; j++) {
43360 info = &cy_card[i].ports[j];
43361
43362 - if (info->port.count) {
43363 + if (atomic_read(&info->port.count)) {
43364 /* XXX is the ldisc num worth this? */
43365 struct tty_struct *tty;
43366 struct tty_ldisc *ld;
43367 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43368 index 13ee53b..418d164 100644
43369 --- a/drivers/tty/hvc/hvc_console.c
43370 +++ b/drivers/tty/hvc/hvc_console.c
43371 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43372
43373 spin_lock_irqsave(&hp->port.lock, flags);
43374 /* Check and then increment for fast path open. */
43375 - if (hp->port.count++ > 0) {
43376 + if (atomic_inc_return(&hp->port.count) > 1) {
43377 spin_unlock_irqrestore(&hp->port.lock, flags);
43378 hvc_kick();
43379 return 0;
43380 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43381
43382 spin_lock_irqsave(&hp->port.lock, flags);
43383
43384 - if (--hp->port.count == 0) {
43385 + if (atomic_dec_return(&hp->port.count) == 0) {
43386 spin_unlock_irqrestore(&hp->port.lock, flags);
43387 /* We are done with the tty pointer now. */
43388 tty_port_tty_set(&hp->port, NULL);
43389 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43390 */
43391 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43392 } else {
43393 - if (hp->port.count < 0)
43394 + if (atomic_read(&hp->port.count) < 0)
43395 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43396 - hp->vtermno, hp->port.count);
43397 + hp->vtermno, atomic_read(&hp->port.count));
43398 spin_unlock_irqrestore(&hp->port.lock, flags);
43399 }
43400 }
43401 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43402 * open->hangup case this can be called after the final close so prevent
43403 * that from happening for now.
43404 */
43405 - if (hp->port.count <= 0) {
43406 + if (atomic_read(&hp->port.count) <= 0) {
43407 spin_unlock_irqrestore(&hp->port.lock, flags);
43408 return;
43409 }
43410
43411 - hp->port.count = 0;
43412 + atomic_set(&hp->port.count, 0);
43413 spin_unlock_irqrestore(&hp->port.lock, flags);
43414 tty_port_tty_set(&hp->port, NULL);
43415
43416 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43417 return -EPIPE;
43418
43419 /* FIXME what's this (unprotected) check for? */
43420 - if (hp->port.count <= 0)
43421 + if (atomic_read(&hp->port.count) <= 0)
43422 return -EIO;
43423
43424 spin_lock_irqsave(&hp->lock, flags);
43425 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43426 index 8776357..b2d4afd 100644
43427 --- a/drivers/tty/hvc/hvcs.c
43428 +++ b/drivers/tty/hvc/hvcs.c
43429 @@ -83,6 +83,7 @@
43430 #include <asm/hvcserver.h>
43431 #include <asm/uaccess.h>
43432 #include <asm/vio.h>
43433 +#include <asm/local.h>
43434
43435 /*
43436 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43437 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43438
43439 spin_lock_irqsave(&hvcsd->lock, flags);
43440
43441 - if (hvcsd->port.count > 0) {
43442 + if (atomic_read(&hvcsd->port.count) > 0) {
43443 spin_unlock_irqrestore(&hvcsd->lock, flags);
43444 printk(KERN_INFO "HVCS: vterm state unchanged. "
43445 "The hvcs device node is still in use.\n");
43446 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43447 }
43448 }
43449
43450 - hvcsd->port.count = 0;
43451 + atomic_set(&hvcsd->port.count, 0);
43452 hvcsd->port.tty = tty;
43453 tty->driver_data = hvcsd;
43454
43455 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43456 unsigned long flags;
43457
43458 spin_lock_irqsave(&hvcsd->lock, flags);
43459 - hvcsd->port.count++;
43460 + atomic_inc(&hvcsd->port.count);
43461 hvcsd->todo_mask |= HVCS_SCHED_READ;
43462 spin_unlock_irqrestore(&hvcsd->lock, flags);
43463
43464 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43465 hvcsd = tty->driver_data;
43466
43467 spin_lock_irqsave(&hvcsd->lock, flags);
43468 - if (--hvcsd->port.count == 0) {
43469 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43470
43471 vio_disable_interrupts(hvcsd->vdev);
43472
43473 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43474
43475 free_irq(irq, hvcsd);
43476 return;
43477 - } else if (hvcsd->port.count < 0) {
43478 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43479 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43480 " is missmanaged.\n",
43481 - hvcsd->vdev->unit_address, hvcsd->port.count);
43482 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43483 }
43484
43485 spin_unlock_irqrestore(&hvcsd->lock, flags);
43486 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43487
43488 spin_lock_irqsave(&hvcsd->lock, flags);
43489 /* Preserve this so that we know how many kref refs to put */
43490 - temp_open_count = hvcsd->port.count;
43491 + temp_open_count = atomic_read(&hvcsd->port.count);
43492
43493 /*
43494 * Don't kref put inside the spinlock because the destruction
43495 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43496 tty->driver_data = NULL;
43497 hvcsd->port.tty = NULL;
43498
43499 - hvcsd->port.count = 0;
43500 + atomic_set(&hvcsd->port.count, 0);
43501
43502 /* This will drop any buffered data on the floor which is OK in a hangup
43503 * scenario. */
43504 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
43505 * the middle of a write operation? This is a crummy place to do this
43506 * but we want to keep it all in the spinlock.
43507 */
43508 - if (hvcsd->port.count <= 0) {
43509 + if (atomic_read(&hvcsd->port.count) <= 0) {
43510 spin_unlock_irqrestore(&hvcsd->lock, flags);
43511 return -ENODEV;
43512 }
43513 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43514 {
43515 struct hvcs_struct *hvcsd = tty->driver_data;
43516
43517 - if (!hvcsd || hvcsd->port.count <= 0)
43518 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43519 return 0;
43520
43521 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43522 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43523 index 2cde13d..645d78f 100644
43524 --- a/drivers/tty/ipwireless/tty.c
43525 +++ b/drivers/tty/ipwireless/tty.c
43526 @@ -29,6 +29,7 @@
43527 #include <linux/tty_driver.h>
43528 #include <linux/tty_flip.h>
43529 #include <linux/uaccess.h>
43530 +#include <asm/local.h>
43531
43532 #include "tty.h"
43533 #include "network.h"
43534 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43535 mutex_unlock(&tty->ipw_tty_mutex);
43536 return -ENODEV;
43537 }
43538 - if (tty->port.count == 0)
43539 + if (atomic_read(&tty->port.count) == 0)
43540 tty->tx_bytes_queued = 0;
43541
43542 - tty->port.count++;
43543 + atomic_inc(&tty->port.count);
43544
43545 tty->port.tty = linux_tty;
43546 linux_tty->driver_data = tty;
43547 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43548
43549 static void do_ipw_close(struct ipw_tty *tty)
43550 {
43551 - tty->port.count--;
43552 -
43553 - if (tty->port.count == 0) {
43554 + if (atomic_dec_return(&tty->port.count) == 0) {
43555 struct tty_struct *linux_tty = tty->port.tty;
43556
43557 if (linux_tty != NULL) {
43558 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43559 return;
43560
43561 mutex_lock(&tty->ipw_tty_mutex);
43562 - if (tty->port.count == 0) {
43563 + if (atomic_read(&tty->port.count) == 0) {
43564 mutex_unlock(&tty->ipw_tty_mutex);
43565 return;
43566 }
43567 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43568 return;
43569 }
43570
43571 - if (!tty->port.count) {
43572 + if (!atomic_read(&tty->port.count)) {
43573 mutex_unlock(&tty->ipw_tty_mutex);
43574 return;
43575 }
43576 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43577 return -ENODEV;
43578
43579 mutex_lock(&tty->ipw_tty_mutex);
43580 - if (!tty->port.count) {
43581 + if (!atomic_read(&tty->port.count)) {
43582 mutex_unlock(&tty->ipw_tty_mutex);
43583 return -EINVAL;
43584 }
43585 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43586 if (!tty)
43587 return -ENODEV;
43588
43589 - if (!tty->port.count)
43590 + if (!atomic_read(&tty->port.count))
43591 return -EINVAL;
43592
43593 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43594 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43595 if (!tty)
43596 return 0;
43597
43598 - if (!tty->port.count)
43599 + if (!atomic_read(&tty->port.count))
43600 return 0;
43601
43602 return tty->tx_bytes_queued;
43603 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43604 if (!tty)
43605 return -ENODEV;
43606
43607 - if (!tty->port.count)
43608 + if (!atomic_read(&tty->port.count))
43609 return -EINVAL;
43610
43611 return get_control_lines(tty);
43612 @@ -391,7 +390,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43613 if (!tty)
43614 return -ENODEV;
43615
43616 - if (!tty->port.count)
43617 + if (!atomic_read(&tty->port.count))
43618 return -EINVAL;
43619
43620 return set_control_lines(tty, set, clear);
43621 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43622 if (!tty)
43623 return -ENODEV;
43624
43625 - if (!tty->port.count)
43626 + if (!atomic_read(&tty->port.count))
43627 return -EINVAL;
43628
43629 /* FIXME: Exactly how is the tty object locked here .. */
43630 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43631 * are gone */
43632 mutex_lock(&ttyj->ipw_tty_mutex);
43633 }
43634 - while (ttyj->port.count)
43635 + while (atomic_read(&ttyj->port.count))
43636 do_ipw_close(ttyj);
43637 ipwireless_disassociate_network_ttys(network,
43638 ttyj->channel_idx);
43639 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43640 index f9d2850..b006f04 100644
43641 --- a/drivers/tty/moxa.c
43642 +++ b/drivers/tty/moxa.c
43643 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43644 }
43645
43646 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43647 - ch->port.count++;
43648 + atomic_inc(&ch->port.count);
43649 tty->driver_data = ch;
43650 tty_port_tty_set(&ch->port, tty);
43651 mutex_lock(&ch->port.mutex);
43652 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43653 index bfd6771..e0d93c4 100644
43654 --- a/drivers/tty/n_gsm.c
43655 +++ b/drivers/tty/n_gsm.c
43656 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43657 spin_lock_init(&dlci->lock);
43658 mutex_init(&dlci->mutex);
43659 dlci->fifo = &dlci->_fifo;
43660 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43661 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43662 kfree(dlci);
43663 return NULL;
43664 }
43665 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43666 struct gsm_dlci *dlci = tty->driver_data;
43667 struct tty_port *port = &dlci->port;
43668
43669 - port->count++;
43670 + atomic_inc(&port->count);
43671 dlci_get(dlci);
43672 dlci_get(dlci->gsm->dlci[0]);
43673 mux_get(dlci->gsm);
43674 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43675 index 19083ef..6e34e97 100644
43676 --- a/drivers/tty/n_tty.c
43677 +++ b/drivers/tty/n_tty.c
43678 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43679 {
43680 *ops = tty_ldisc_N_TTY;
43681 ops->owner = NULL;
43682 - ops->refcount = ops->flags = 0;
43683 + atomic_set(&ops->refcount, 0);
43684 + ops->flags = 0;
43685 }
43686 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43687 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43688 index ac35c90..c47deac 100644
43689 --- a/drivers/tty/pty.c
43690 +++ b/drivers/tty/pty.c
43691 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
43692 panic("Couldn't register Unix98 pts driver");
43693
43694 /* Now create the /dev/ptmx special device */
43695 + pax_open_kernel();
43696 tty_default_fops(&ptmx_fops);
43697 - ptmx_fops.open = ptmx_open;
43698 + *(void **)&ptmx_fops.open = ptmx_open;
43699 + pax_close_kernel();
43700
43701 cdev_init(&ptmx_cdev, &ptmx_fops);
43702 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43703 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43704 index e42009a..566a036 100644
43705 --- a/drivers/tty/rocket.c
43706 +++ b/drivers/tty/rocket.c
43707 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43708 tty->driver_data = info;
43709 tty_port_tty_set(port, tty);
43710
43711 - if (port->count++ == 0) {
43712 + if (atomic_inc_return(&port->count) == 1) {
43713 atomic_inc(&rp_num_ports_open);
43714
43715 #ifdef ROCKET_DEBUG_OPEN
43716 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43717 #endif
43718 }
43719 #ifdef ROCKET_DEBUG_OPEN
43720 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43721 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43722 #endif
43723
43724 /*
43725 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
43726 spin_unlock_irqrestore(&info->port.lock, flags);
43727 return;
43728 }
43729 - if (info->port.count)
43730 + if (atomic_read(&info->port.count))
43731 atomic_dec(&rp_num_ports_open);
43732 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43733 spin_unlock_irqrestore(&info->port.lock, flags);
43734 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43735 index 1002054..dd644a8 100644
43736 --- a/drivers/tty/serial/kgdboc.c
43737 +++ b/drivers/tty/serial/kgdboc.c
43738 @@ -24,8 +24,9 @@
43739 #define MAX_CONFIG_LEN 40
43740
43741 static struct kgdb_io kgdboc_io_ops;
43742 +static struct kgdb_io kgdboc_io_ops_console;
43743
43744 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43745 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43746 static int configured = -1;
43747
43748 static char config[MAX_CONFIG_LEN];
43749 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43750 kgdboc_unregister_kbd();
43751 if (configured == 1)
43752 kgdb_unregister_io_module(&kgdboc_io_ops);
43753 + else if (configured == 2)
43754 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43755 }
43756
43757 static int configure_kgdboc(void)
43758 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43759 int err;
43760 char *cptr = config;
43761 struct console *cons;
43762 + int is_console = 0;
43763
43764 err = kgdboc_option_setup(config);
43765 if (err || !strlen(config) || isspace(config[0]))
43766 goto noconfig;
43767
43768 err = -ENODEV;
43769 - kgdboc_io_ops.is_console = 0;
43770 kgdb_tty_driver = NULL;
43771
43772 kgdboc_use_kms = 0;
43773 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43774 int idx;
43775 if (cons->device && cons->device(cons, &idx) == p &&
43776 idx == tty_line) {
43777 - kgdboc_io_ops.is_console = 1;
43778 + is_console = 1;
43779 break;
43780 }
43781 cons = cons->next;
43782 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43783 kgdb_tty_line = tty_line;
43784
43785 do_register:
43786 - err = kgdb_register_io_module(&kgdboc_io_ops);
43787 + if (is_console) {
43788 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43789 + configured = 2;
43790 + } else {
43791 + err = kgdb_register_io_module(&kgdboc_io_ops);
43792 + configured = 1;
43793 + }
43794 if (err)
43795 goto noconfig;
43796
43797 @@ -205,8 +214,6 @@ do_register:
43798 if (err)
43799 goto nmi_con_failed;
43800
43801 - configured = 1;
43802 -
43803 return 0;
43804
43805 nmi_con_failed:
43806 @@ -223,7 +230,7 @@ noconfig:
43807 static int __init init_kgdboc(void)
43808 {
43809 /* Already configured? */
43810 - if (configured == 1)
43811 + if (configured >= 1)
43812 return 0;
43813
43814 return configure_kgdboc();
43815 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43816 if (config[len - 1] == '\n')
43817 config[len - 1] = '\0';
43818
43819 - if (configured == 1)
43820 + if (configured >= 1)
43821 cleanup_kgdboc();
43822
43823 /* Go and configure with the new params. */
43824 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43825 .post_exception = kgdboc_post_exp_handler,
43826 };
43827
43828 +static struct kgdb_io kgdboc_io_ops_console = {
43829 + .name = "kgdboc",
43830 + .read_char = kgdboc_get_char,
43831 + .write_char = kgdboc_put_char,
43832 + .pre_exception = kgdboc_pre_exp_handler,
43833 + .post_exception = kgdboc_post_exp_handler,
43834 + .is_console = 1
43835 +};
43836 +
43837 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43838 /* This is only available if kgdboc is a built in for early debugging */
43839 static int __init kgdboc_early_init(char *opt)
43840 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43841 index e514b3a..c73d614 100644
43842 --- a/drivers/tty/serial/samsung.c
43843 +++ b/drivers/tty/serial/samsung.c
43844 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43845 }
43846 }
43847
43848 +static int s3c64xx_serial_startup(struct uart_port *port);
43849 static int s3c24xx_serial_startup(struct uart_port *port)
43850 {
43851 struct s3c24xx_uart_port *ourport = to_ourport(port);
43852 int ret;
43853
43854 + /* Startup sequence is different for s3c64xx and higher SoC's */
43855 + if (s3c24xx_serial_has_interrupt_mask(port))
43856 + return s3c64xx_serial_startup(port);
43857 +
43858 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43859 port->mapbase, port->membase);
43860
43861 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43862 /* setup info for port */
43863 port->dev = &platdev->dev;
43864
43865 - /* Startup sequence is different for s3c64xx and higher SoC's */
43866 - if (s3c24xx_serial_has_interrupt_mask(port))
43867 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43868 -
43869 port->uartclk = 1;
43870
43871 if (cfg->uart_flags & UPF_CONS_FLOW) {
43872 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43873 index 2c7230a..2104f16 100644
43874 --- a/drivers/tty/serial/serial_core.c
43875 +++ b/drivers/tty/serial/serial_core.c
43876 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
43877 uart_flush_buffer(tty);
43878 uart_shutdown(tty, state);
43879 spin_lock_irqsave(&port->lock, flags);
43880 - port->count = 0;
43881 + atomic_set(&port->count, 0);
43882 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43883 spin_unlock_irqrestore(&port->lock, flags);
43884 tty_port_tty_set(port, NULL);
43885 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43886 goto end;
43887 }
43888
43889 - port->count++;
43890 + atomic_inc(&port->count);
43891 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43892 retval = -ENXIO;
43893 goto err_dec_count;
43894 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43895 /*
43896 * Make sure the device is in D0 state.
43897 */
43898 - if (port->count == 1)
43899 + if (atomic_read(&port->count) == 1)
43900 uart_change_pm(state, 0);
43901
43902 /*
43903 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43904 end:
43905 return retval;
43906 err_dec_count:
43907 - port->count--;
43908 + atomic_inc(&port->count);
43909 mutex_unlock(&port->mutex);
43910 goto end;
43911 }
43912 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43913 index 9e071f6..f30ae69 100644
43914 --- a/drivers/tty/synclink.c
43915 +++ b/drivers/tty/synclink.c
43916 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43917
43918 if (debug_level >= DEBUG_LEVEL_INFO)
43919 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43920 - __FILE__,__LINE__, info->device_name, info->port.count);
43921 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43922
43923 if (tty_port_close_start(&info->port, tty, filp) == 0)
43924 goto cleanup;
43925 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43926 cleanup:
43927 if (debug_level >= DEBUG_LEVEL_INFO)
43928 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43929 - tty->driver->name, info->port.count);
43930 + tty->driver->name, atomic_read(&info->port.count));
43931
43932 } /* end of mgsl_close() */
43933
43934 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43935
43936 mgsl_flush_buffer(tty);
43937 shutdown(info);
43938 -
43939 - info->port.count = 0;
43940 +
43941 + atomic_set(&info->port.count, 0);
43942 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43943 info->port.tty = NULL;
43944
43945 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43946
43947 if (debug_level >= DEBUG_LEVEL_INFO)
43948 printk("%s(%d):block_til_ready before block 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 spin_lock_irqsave(&info->irq_spinlock, flags);
43953 if (!tty_hung_up_p(filp)) {
43954 extra_count = true;
43955 - port->count--;
43956 + atomic_dec(&port->count);
43957 }
43958 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43959 port->blocked_open++;
43960 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43961
43962 if (debug_level >= DEBUG_LEVEL_INFO)
43963 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43964 - __FILE__,__LINE__, tty->driver->name, port->count );
43965 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43966
43967 tty_unlock(tty);
43968 schedule();
43969 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43970
43971 /* FIXME: Racy on hangup during close wait */
43972 if (extra_count)
43973 - port->count++;
43974 + atomic_inc(&port->count);
43975 port->blocked_open--;
43976
43977 if (debug_level >= DEBUG_LEVEL_INFO)
43978 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43979 - __FILE__,__LINE__, tty->driver->name, port->count );
43980 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43981
43982 if (!retval)
43983 port->flags |= ASYNC_NORMAL_ACTIVE;
43984 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43985
43986 if (debug_level >= DEBUG_LEVEL_INFO)
43987 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43988 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43989 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43990
43991 /* If port is closing, signal caller to try again */
43992 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43993 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43994 spin_unlock_irqrestore(&info->netlock, flags);
43995 goto cleanup;
43996 }
43997 - info->port.count++;
43998 + atomic_inc(&info->port.count);
43999 spin_unlock_irqrestore(&info->netlock, flags);
44000
44001 - if (info->port.count == 1) {
44002 + if (atomic_read(&info->port.count) == 1) {
44003 /* 1st open on this device, init hardware */
44004 retval = startup(info);
44005 if (retval < 0)
44006 @@ -3451,8 +3451,8 @@ cleanup:
44007 if (retval) {
44008 if (tty->count == 1)
44009 info->port.tty = NULL; /* tty layer will release tty struct */
44010 - if(info->port.count)
44011 - info->port.count--;
44012 + if (atomic_read(&info->port.count))
44013 + atomic_dec(&info->port.count);
44014 }
44015
44016 return retval;
44017 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44018 unsigned short new_crctype;
44019
44020 /* return error if TTY interface open */
44021 - if (info->port.count)
44022 + if (atomic_read(&info->port.count))
44023 return -EBUSY;
44024
44025 switch (encoding)
44026 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
44027
44028 /* arbitrate between network and tty opens */
44029 spin_lock_irqsave(&info->netlock, flags);
44030 - if (info->port.count != 0 || info->netcount != 0) {
44031 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44032 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44033 spin_unlock_irqrestore(&info->netlock, flags);
44034 return -EBUSY;
44035 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44036 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44037
44038 /* return error if TTY interface open */
44039 - if (info->port.count)
44040 + if (atomic_read(&info->port.count))
44041 return -EBUSY;
44042
44043 if (cmd != SIOCWANDEV)
44044 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44045 index aba1e59..877ac33 100644
44046 --- a/drivers/tty/synclink_gt.c
44047 +++ b/drivers/tty/synclink_gt.c
44048 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44049 tty->driver_data = info;
44050 info->port.tty = tty;
44051
44052 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44053 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44054
44055 /* If port is closing, signal caller to try again */
44056 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44057 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44058 mutex_unlock(&info->port.mutex);
44059 goto cleanup;
44060 }
44061 - info->port.count++;
44062 + atomic_inc(&info->port.count);
44063 spin_unlock_irqrestore(&info->netlock, flags);
44064
44065 - if (info->port.count == 1) {
44066 + if (atomic_read(&info->port.count) == 1) {
44067 /* 1st open on this device, init hardware */
44068 retval = startup(info);
44069 if (retval < 0) {
44070 @@ -716,8 +716,8 @@ cleanup:
44071 if (retval) {
44072 if (tty->count == 1)
44073 info->port.tty = NULL; /* tty layer will release tty struct */
44074 - if(info->port.count)
44075 - info->port.count--;
44076 + if(atomic_read(&info->port.count))
44077 + atomic_dec(&info->port.count);
44078 }
44079
44080 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44081 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44082
44083 if (sanity_check(info, tty->name, "close"))
44084 return;
44085 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44086 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44087
44088 if (tty_port_close_start(&info->port, tty, filp) == 0)
44089 goto cleanup;
44090 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44091 tty_port_close_end(&info->port, tty);
44092 info->port.tty = NULL;
44093 cleanup:
44094 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44095 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44096 }
44097
44098 static void hangup(struct tty_struct *tty)
44099 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
44100 shutdown(info);
44101
44102 spin_lock_irqsave(&info->port.lock, flags);
44103 - info->port.count = 0;
44104 + atomic_set(&info->port.count, 0);
44105 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44106 info->port.tty = NULL;
44107 spin_unlock_irqrestore(&info->port.lock, flags);
44108 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44109 unsigned short new_crctype;
44110
44111 /* return error if TTY interface open */
44112 - if (info->port.count)
44113 + if (atomic_read(&info->port.count))
44114 return -EBUSY;
44115
44116 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44117 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
44118
44119 /* arbitrate between network and tty opens */
44120 spin_lock_irqsave(&info->netlock, flags);
44121 - if (info->port.count != 0 || info->netcount != 0) {
44122 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44123 DBGINFO(("%s hdlc_open busy\n", dev->name));
44124 spin_unlock_irqrestore(&info->netlock, flags);
44125 return -EBUSY;
44126 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44127 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44128
44129 /* return error if TTY interface open */
44130 - if (info->port.count)
44131 + if (atomic_read(&info->port.count))
44132 return -EBUSY;
44133
44134 if (cmd != SIOCWANDEV)
44135 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44136 if (port == NULL)
44137 continue;
44138 spin_lock(&port->lock);
44139 - if ((port->port.count || port->netcount) &&
44140 + if ((atomic_read(&port->port.count) || port->netcount) &&
44141 port->pending_bh && !port->bh_running &&
44142 !port->bh_requested) {
44143 DBGISR(("%s bh queued\n", port->device_name));
44144 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44145 spin_lock_irqsave(&info->lock, flags);
44146 if (!tty_hung_up_p(filp)) {
44147 extra_count = true;
44148 - port->count--;
44149 + atomic_dec(&port->count);
44150 }
44151 spin_unlock_irqrestore(&info->lock, flags);
44152 port->blocked_open++;
44153 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44154 remove_wait_queue(&port->open_wait, &wait);
44155
44156 if (extra_count)
44157 - port->count++;
44158 + atomic_inc(&port->count);
44159 port->blocked_open--;
44160
44161 if (!retval)
44162 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44163 index fd43fb6..34704ad 100644
44164 --- a/drivers/tty/synclinkmp.c
44165 +++ b/drivers/tty/synclinkmp.c
44166 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44167
44168 if (debug_level >= DEBUG_LEVEL_INFO)
44169 printk("%s(%d):%s open(), old ref count = %d\n",
44170 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44171 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44172
44173 /* If port is closing, signal caller to try again */
44174 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44175 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44176 spin_unlock_irqrestore(&info->netlock, flags);
44177 goto cleanup;
44178 }
44179 - info->port.count++;
44180 + atomic_inc(&info->port.count);
44181 spin_unlock_irqrestore(&info->netlock, flags);
44182
44183 - if (info->port.count == 1) {
44184 + if (atomic_read(&info->port.count) == 1) {
44185 /* 1st open on this device, init hardware */
44186 retval = startup(info);
44187 if (retval < 0)
44188 @@ -797,8 +797,8 @@ cleanup:
44189 if (retval) {
44190 if (tty->count == 1)
44191 info->port.tty = NULL; /* tty layer will release tty struct */
44192 - if(info->port.count)
44193 - info->port.count--;
44194 + if(atomic_read(&info->port.count))
44195 + atomic_dec(&info->port.count);
44196 }
44197
44198 return retval;
44199 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44200
44201 if (debug_level >= DEBUG_LEVEL_INFO)
44202 printk("%s(%d):%s close() entry, count=%d\n",
44203 - __FILE__,__LINE__, info->device_name, info->port.count);
44204 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44205
44206 if (tty_port_close_start(&info->port, tty, filp) == 0)
44207 goto cleanup;
44208 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44209 cleanup:
44210 if (debug_level >= DEBUG_LEVEL_INFO)
44211 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44212 - tty->driver->name, info->port.count);
44213 + tty->driver->name, atomic_read(&info->port.count));
44214 }
44215
44216 /* Called by tty_hangup() when a hangup is signaled.
44217 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
44218 shutdown(info);
44219
44220 spin_lock_irqsave(&info->port.lock, flags);
44221 - info->port.count = 0;
44222 + atomic_set(&info->port.count, 0);
44223 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44224 info->port.tty = NULL;
44225 spin_unlock_irqrestore(&info->port.lock, flags);
44226 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44227 unsigned short new_crctype;
44228
44229 /* return error if TTY interface open */
44230 - if (info->port.count)
44231 + if (atomic_read(&info->port.count))
44232 return -EBUSY;
44233
44234 switch (encoding)
44235 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
44236
44237 /* arbitrate between network and tty opens */
44238 spin_lock_irqsave(&info->netlock, flags);
44239 - if (info->port.count != 0 || info->netcount != 0) {
44240 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44241 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44242 spin_unlock_irqrestore(&info->netlock, flags);
44243 return -EBUSY;
44244 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44245 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44246
44247 /* return error if TTY interface open */
44248 - if (info->port.count)
44249 + if (atomic_read(&info->port.count))
44250 return -EBUSY;
44251
44252 if (cmd != SIOCWANDEV)
44253 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44254 * do not request bottom half processing if the
44255 * device is not open in a normal mode.
44256 */
44257 - if ( port && (port->port.count || port->netcount) &&
44258 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44259 port->pending_bh && !port->bh_running &&
44260 !port->bh_requested ) {
44261 if ( debug_level >= DEBUG_LEVEL_ISR )
44262 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44263
44264 if (debug_level >= DEBUG_LEVEL_INFO)
44265 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44266 - __FILE__,__LINE__, tty->driver->name, port->count );
44267 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44268
44269 spin_lock_irqsave(&info->lock, flags);
44270 if (!tty_hung_up_p(filp)) {
44271 extra_count = true;
44272 - port->count--;
44273 + atomic_dec(&port->count);
44274 }
44275 spin_unlock_irqrestore(&info->lock, flags);
44276 port->blocked_open++;
44277 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44278
44279 if (debug_level >= DEBUG_LEVEL_INFO)
44280 printk("%s(%d):%s block_til_ready() count=%d\n",
44281 - __FILE__,__LINE__, tty->driver->name, port->count );
44282 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44283
44284 tty_unlock(tty);
44285 schedule();
44286 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44287 remove_wait_queue(&port->open_wait, &wait);
44288
44289 if (extra_count)
44290 - port->count++;
44291 + atomic_inc(&port->count);
44292 port->blocked_open--;
44293
44294 if (debug_level >= DEBUG_LEVEL_INFO)
44295 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44296 - __FILE__,__LINE__, tty->driver->name, port->count );
44297 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44298
44299 if (!retval)
44300 port->flags |= ASYNC_NORMAL_ACTIVE;
44301 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44302 index b3c4a25..723916f 100644
44303 --- a/drivers/tty/sysrq.c
44304 +++ b/drivers/tty/sysrq.c
44305 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44306 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44307 size_t count, loff_t *ppos)
44308 {
44309 - if (count) {
44310 + if (count && capable(CAP_SYS_ADMIN)) {
44311 char c;
44312
44313 if (get_user(c, buf))
44314 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44315 index 892ecda..90cbf36 100644
44316 --- a/drivers/tty/tty_io.c
44317 +++ b/drivers/tty/tty_io.c
44318 @@ -3401,7 +3401,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44319
44320 void tty_default_fops(struct file_operations *fops)
44321 {
44322 - *fops = tty_fops;
44323 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44324 }
44325
44326 /*
44327 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44328 index 78f1be2..3e98910 100644
44329 --- a/drivers/tty/tty_ldisc.c
44330 +++ b/drivers/tty/tty_ldisc.c
44331 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
44332 if (atomic_dec_and_test(&ld->users)) {
44333 struct tty_ldisc_ops *ldo = ld->ops;
44334
44335 - ldo->refcount--;
44336 + atomic_dec(&ldo->refcount);
44337 module_put(ldo->owner);
44338 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44339
44340 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44341 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44342 tty_ldiscs[disc] = new_ldisc;
44343 new_ldisc->num = disc;
44344 - new_ldisc->refcount = 0;
44345 + atomic_set(&new_ldisc->refcount, 0);
44346 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44347
44348 return ret;
44349 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
44350 return -EINVAL;
44351
44352 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44353 - if (tty_ldiscs[disc]->refcount)
44354 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44355 ret = -EBUSY;
44356 else
44357 tty_ldiscs[disc] = NULL;
44358 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44359 if (ldops) {
44360 ret = ERR_PTR(-EAGAIN);
44361 if (try_module_get(ldops->owner)) {
44362 - ldops->refcount++;
44363 + atomic_inc(&ldops->refcount);
44364 ret = ldops;
44365 }
44366 }
44367 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44368 unsigned long flags;
44369
44370 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44371 - ldops->refcount--;
44372 + atomic_dec(&ldops->refcount);
44373 module_put(ldops->owner);
44374 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44375 }
44376 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44377 index b7ff59d..7c6105e 100644
44378 --- a/drivers/tty/tty_port.c
44379 +++ b/drivers/tty/tty_port.c
44380 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44381 unsigned long flags;
44382
44383 spin_lock_irqsave(&port->lock, flags);
44384 - port->count = 0;
44385 + atomic_set(&port->count, 0);
44386 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44387 if (port->tty) {
44388 set_bit(TTY_IO_ERROR, &port->tty->flags);
44389 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44390 /* The port lock protects the port counts */
44391 spin_lock_irqsave(&port->lock, flags);
44392 if (!tty_hung_up_p(filp))
44393 - port->count--;
44394 + atomic_dec(&port->count);
44395 port->blocked_open++;
44396 spin_unlock_irqrestore(&port->lock, flags);
44397
44398 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44399 we must not mess that up further */
44400 spin_lock_irqsave(&port->lock, flags);
44401 if (!tty_hung_up_p(filp))
44402 - port->count++;
44403 + atomic_inc(&port->count);
44404 port->blocked_open--;
44405 if (retval == 0)
44406 port->flags |= ASYNC_NORMAL_ACTIVE;
44407 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
44408 return 0;
44409 }
44410
44411 - if (tty->count == 1 && port->count != 1) {
44412 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44413 printk(KERN_WARNING
44414 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44415 - port->count);
44416 - port->count = 1;
44417 + atomic_read(&port->count));
44418 + atomic_set(&port->count, 1);
44419 }
44420 - if (--port->count < 0) {
44421 + if (atomic_dec_return(&port->count) < 0) {
44422 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44423 - port->count);
44424 - port->count = 0;
44425 + atomic_read(&port->count));
44426 + atomic_set(&port->count, 0);
44427 }
44428
44429 - if (port->count) {
44430 + if (atomic_read(&port->count)) {
44431 spin_unlock_irqrestore(&port->lock, flags);
44432 if (port->ops->drop)
44433 port->ops->drop(port);
44434 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44435 {
44436 spin_lock_irq(&port->lock);
44437 if (!tty_hung_up_p(filp))
44438 - ++port->count;
44439 + atomic_inc(&port->count);
44440 spin_unlock_irq(&port->lock);
44441 tty_port_tty_set(port, tty);
44442
44443 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44444 index 681765b..d3ccdf2 100644
44445 --- a/drivers/tty/vt/keyboard.c
44446 +++ b/drivers/tty/vt/keyboard.c
44447 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44448 kbd->kbdmode == VC_OFF) &&
44449 value != KVAL(K_SAK))
44450 return; /* SAK is allowed even in raw mode */
44451 +
44452 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44453 + {
44454 + void *func = fn_handler[value];
44455 + if (func == fn_show_state || func == fn_show_ptregs ||
44456 + func == fn_show_mem)
44457 + return;
44458 + }
44459 +#endif
44460 +
44461 fn_handler[value](vc);
44462 }
44463
44464 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44465 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44466 return -EFAULT;
44467
44468 - if (!capable(CAP_SYS_TTY_CONFIG))
44469 - perm = 0;
44470 -
44471 switch (cmd) {
44472 case KDGKBENT:
44473 /* Ensure another thread doesn't free it under us */
44474 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44475 spin_unlock_irqrestore(&kbd_event_lock, flags);
44476 return put_user(val, &user_kbe->kb_value);
44477 case KDSKBENT:
44478 + if (!capable(CAP_SYS_TTY_CONFIG))
44479 + perm = 0;
44480 +
44481 if (!perm)
44482 return -EPERM;
44483 if (!i && v == K_NOSUCHMAP) {
44484 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44485 int i, j, k;
44486 int ret;
44487
44488 - if (!capable(CAP_SYS_TTY_CONFIG))
44489 - perm = 0;
44490 -
44491 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44492 if (!kbs) {
44493 ret = -ENOMEM;
44494 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44495 kfree(kbs);
44496 return ((p && *p) ? -EOVERFLOW : 0);
44497 case KDSKBSENT:
44498 + if (!capable(CAP_SYS_TTY_CONFIG))
44499 + perm = 0;
44500 +
44501 if (!perm) {
44502 ret = -EPERM;
44503 goto reterr;
44504 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44505 index 5110f36..8dc0a74 100644
44506 --- a/drivers/uio/uio.c
44507 +++ b/drivers/uio/uio.c
44508 @@ -25,6 +25,7 @@
44509 #include <linux/kobject.h>
44510 #include <linux/cdev.h>
44511 #include <linux/uio_driver.h>
44512 +#include <asm/local.h>
44513
44514 #define UIO_MAX_DEVICES (1U << MINORBITS)
44515
44516 @@ -32,10 +33,10 @@ struct uio_device {
44517 struct module *owner;
44518 struct device *dev;
44519 int minor;
44520 - atomic_t event;
44521 + atomic_unchecked_t event;
44522 struct fasync_struct *async_queue;
44523 wait_queue_head_t wait;
44524 - int vma_count;
44525 + local_t vma_count;
44526 struct uio_info *info;
44527 struct kobject *map_dir;
44528 struct kobject *portio_dir;
44529 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44530 struct device_attribute *attr, char *buf)
44531 {
44532 struct uio_device *idev = dev_get_drvdata(dev);
44533 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44534 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44535 }
44536
44537 static struct device_attribute uio_class_attributes[] = {
44538 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
44539 {
44540 struct uio_device *idev = info->uio_dev;
44541
44542 - atomic_inc(&idev->event);
44543 + atomic_inc_unchecked(&idev->event);
44544 wake_up_interruptible(&idev->wait);
44545 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44546 }
44547 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44548 }
44549
44550 listener->dev = idev;
44551 - listener->event_count = atomic_read(&idev->event);
44552 + listener->event_count = atomic_read_unchecked(&idev->event);
44553 filep->private_data = listener;
44554
44555 if (idev->info->open) {
44556 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44557 return -EIO;
44558
44559 poll_wait(filep, &idev->wait, wait);
44560 - if (listener->event_count != atomic_read(&idev->event))
44561 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44562 return POLLIN | POLLRDNORM;
44563 return 0;
44564 }
44565 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44566 do {
44567 set_current_state(TASK_INTERRUPTIBLE);
44568
44569 - event_count = atomic_read(&idev->event);
44570 + event_count = atomic_read_unchecked(&idev->event);
44571 if (event_count != listener->event_count) {
44572 if (copy_to_user(buf, &event_count, count))
44573 retval = -EFAULT;
44574 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44575 static void uio_vma_open(struct vm_area_struct *vma)
44576 {
44577 struct uio_device *idev = vma->vm_private_data;
44578 - idev->vma_count++;
44579 + local_inc(&idev->vma_count);
44580 }
44581
44582 static void uio_vma_close(struct vm_area_struct *vma)
44583 {
44584 struct uio_device *idev = vma->vm_private_data;
44585 - idev->vma_count--;
44586 + local_dec(&idev->vma_count);
44587 }
44588
44589 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44590 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
44591 idev->owner = owner;
44592 idev->info = info;
44593 init_waitqueue_head(&idev->wait);
44594 - atomic_set(&idev->event, 0);
44595 + atomic_set_unchecked(&idev->event, 0);
44596
44597 ret = uio_get_minor(idev);
44598 if (ret)
44599 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44600 index b7eb86a..36d28af 100644
44601 --- a/drivers/usb/atm/cxacru.c
44602 +++ b/drivers/usb/atm/cxacru.c
44603 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44604 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44605 if (ret < 2)
44606 return -EINVAL;
44607 - if (index < 0 || index > 0x7f)
44608 + if (index > 0x7f)
44609 return -EINVAL;
44610 pos += tmp;
44611
44612 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44613 index 35f10bf..6a38a0b 100644
44614 --- a/drivers/usb/atm/usbatm.c
44615 +++ b/drivers/usb/atm/usbatm.c
44616 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44617 if (printk_ratelimit())
44618 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44619 __func__, vpi, vci);
44620 - atomic_inc(&vcc->stats->rx_err);
44621 + atomic_inc_unchecked(&vcc->stats->rx_err);
44622 return;
44623 }
44624
44625 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44626 if (length > ATM_MAX_AAL5_PDU) {
44627 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44628 __func__, length, vcc);
44629 - atomic_inc(&vcc->stats->rx_err);
44630 + atomic_inc_unchecked(&vcc->stats->rx_err);
44631 goto out;
44632 }
44633
44634 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44635 if (sarb->len < pdu_length) {
44636 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44637 __func__, pdu_length, sarb->len, vcc);
44638 - atomic_inc(&vcc->stats->rx_err);
44639 + atomic_inc_unchecked(&vcc->stats->rx_err);
44640 goto out;
44641 }
44642
44643 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44644 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44645 __func__, vcc);
44646 - atomic_inc(&vcc->stats->rx_err);
44647 + atomic_inc_unchecked(&vcc->stats->rx_err);
44648 goto out;
44649 }
44650
44651 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44652 if (printk_ratelimit())
44653 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44654 __func__, length);
44655 - atomic_inc(&vcc->stats->rx_drop);
44656 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44657 goto out;
44658 }
44659
44660 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44661
44662 vcc->push(vcc, skb);
44663
44664 - atomic_inc(&vcc->stats->rx);
44665 + atomic_inc_unchecked(&vcc->stats->rx);
44666 out:
44667 skb_trim(sarb, 0);
44668 }
44669 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44670 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44671
44672 usbatm_pop(vcc, skb);
44673 - atomic_inc(&vcc->stats->tx);
44674 + atomic_inc_unchecked(&vcc->stats->tx);
44675
44676 skb = skb_dequeue(&instance->sndqueue);
44677 }
44678 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44679 if (!left--)
44680 return sprintf(page,
44681 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44682 - atomic_read(&atm_dev->stats.aal5.tx),
44683 - atomic_read(&atm_dev->stats.aal5.tx_err),
44684 - atomic_read(&atm_dev->stats.aal5.rx),
44685 - atomic_read(&atm_dev->stats.aal5.rx_err),
44686 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44687 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44688 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44689 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44690 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44691 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44692
44693 if (!left--) {
44694 if (instance->disconnected)
44695 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44696 index cbacea9..246cccd 100644
44697 --- a/drivers/usb/core/devices.c
44698 +++ b/drivers/usb/core/devices.c
44699 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44700 * time it gets called.
44701 */
44702 static struct device_connect_event {
44703 - atomic_t count;
44704 + atomic_unchecked_t count;
44705 wait_queue_head_t wait;
44706 } device_event = {
44707 .count = ATOMIC_INIT(1),
44708 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44709
44710 void usbfs_conn_disc_event(void)
44711 {
44712 - atomic_add(2, &device_event.count);
44713 + atomic_add_unchecked(2, &device_event.count);
44714 wake_up(&device_event.wait);
44715 }
44716
44717 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
44718
44719 poll_wait(file, &device_event.wait, wait);
44720
44721 - event_count = atomic_read(&device_event.count);
44722 + event_count = atomic_read_unchecked(&device_event.count);
44723 if (file->f_version != event_count) {
44724 file->f_version = event_count;
44725 return POLLIN | POLLRDNORM;
44726 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44727 index 8e64adf..9a33a3c 100644
44728 --- a/drivers/usb/core/hcd.c
44729 +++ b/drivers/usb/core/hcd.c
44730 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44731 */
44732 usb_get_urb(urb);
44733 atomic_inc(&urb->use_count);
44734 - atomic_inc(&urb->dev->urbnum);
44735 + atomic_inc_unchecked(&urb->dev->urbnum);
44736 usbmon_urb_submit(&hcd->self, urb);
44737
44738 /* NOTE requirements on root-hub callers (usbfs and the hub
44739 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44740 urb->hcpriv = NULL;
44741 INIT_LIST_HEAD(&urb->urb_list);
44742 atomic_dec(&urb->use_count);
44743 - atomic_dec(&urb->dev->urbnum);
44744 + atomic_dec_unchecked(&urb->dev->urbnum);
44745 if (atomic_read(&urb->reject))
44746 wake_up(&usb_kill_urb_queue);
44747 usb_put_urb(urb);
44748 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44749 index 131f736..99004c3 100644
44750 --- a/drivers/usb/core/message.c
44751 +++ b/drivers/usb/core/message.c
44752 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44753 * method can wait for it to complete. Since you don't have a handle on the
44754 * URB used, you can't cancel the request.
44755 */
44756 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44757 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44758 __u8 requesttype, __u16 value, __u16 index, void *data,
44759 __u16 size, int timeout)
44760 {
44761 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44762 index 818e4a0..0fc9589 100644
44763 --- a/drivers/usb/core/sysfs.c
44764 +++ b/drivers/usb/core/sysfs.c
44765 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44766 struct usb_device *udev;
44767
44768 udev = to_usb_device(dev);
44769 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44770 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44771 }
44772 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44773
44774 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44775 index f81b925..78d22ec 100644
44776 --- a/drivers/usb/core/usb.c
44777 +++ b/drivers/usb/core/usb.c
44778 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44779 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44780 dev->state = USB_STATE_ATTACHED;
44781 dev->lpm_disable_count = 1;
44782 - atomic_set(&dev->urbnum, 0);
44783 + atomic_set_unchecked(&dev->urbnum, 0);
44784
44785 INIT_LIST_HEAD(&dev->ep0.urb_list);
44786 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44787 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44788 index 5e29dde..eca992f 100644
44789 --- a/drivers/usb/early/ehci-dbgp.c
44790 +++ b/drivers/usb/early/ehci-dbgp.c
44791 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44792
44793 #ifdef CONFIG_KGDB
44794 static struct kgdb_io kgdbdbgp_io_ops;
44795 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44796 +static struct kgdb_io kgdbdbgp_io_ops_console;
44797 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44798 #else
44799 #define dbgp_kgdb_mode (0)
44800 #endif
44801 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44802 .write_char = kgdbdbgp_write_char,
44803 };
44804
44805 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44806 + .name = "kgdbdbgp",
44807 + .read_char = kgdbdbgp_read_char,
44808 + .write_char = kgdbdbgp_write_char,
44809 + .is_console = 1
44810 +};
44811 +
44812 static int kgdbdbgp_wait_time;
44813
44814 static int __init kgdbdbgp_parse_config(char *str)
44815 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44816 ptr++;
44817 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44818 }
44819 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44820 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44821 + if (early_dbgp_console.index != -1)
44822 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44823 + else
44824 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44825
44826 return 0;
44827 }
44828 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44829 index 598dcc1..032dd4f 100644
44830 --- a/drivers/usb/gadget/u_serial.c
44831 +++ b/drivers/usb/gadget/u_serial.c
44832 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44833 spin_lock_irq(&port->port_lock);
44834
44835 /* already open? Great. */
44836 - if (port->port.count) {
44837 + if (atomic_read(&port->port.count)) {
44838 status = 0;
44839 - port->port.count++;
44840 + atomic_inc(&port->port.count);
44841
44842 /* currently opening/closing? wait ... */
44843 } else if (port->openclose) {
44844 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44845 tty->driver_data = port;
44846 port->port.tty = tty;
44847
44848 - port->port.count = 1;
44849 + atomic_set(&port->port.count, 1);
44850 port->openclose = false;
44851
44852 /* if connected, start the I/O stream */
44853 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44854
44855 spin_lock_irq(&port->port_lock);
44856
44857 - if (port->port.count != 1) {
44858 - if (port->port.count == 0)
44859 + if (atomic_read(&port->port.count) != 1) {
44860 + if (atomic_read(&port->port.count) == 0)
44861 WARN_ON(1);
44862 else
44863 - --port->port.count;
44864 + atomic_dec(&port->port.count);
44865 goto exit;
44866 }
44867
44868 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44869 * and sleep if necessary
44870 */
44871 port->openclose = true;
44872 - port->port.count = 0;
44873 + atomic_set(&port->port.count, 0);
44874
44875 gser = port->port_usb;
44876 if (gser && gser->disconnect)
44877 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44878 int cond;
44879
44880 spin_lock_irq(&port->port_lock);
44881 - cond = (port->port.count == 0) && !port->openclose;
44882 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44883 spin_unlock_irq(&port->port_lock);
44884 return cond;
44885 }
44886 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44887 /* if it's already open, start I/O ... and notify the serial
44888 * protocol about open/close status (connect/disconnect).
44889 */
44890 - if (port->port.count) {
44891 + if (atomic_read(&port->port.count)) {
44892 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44893 gs_start_io(port);
44894 if (gser->connect)
44895 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44896
44897 port->port_usb = NULL;
44898 gser->ioport = NULL;
44899 - if (port->port.count > 0 || port->openclose) {
44900 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44901 wake_up_interruptible(&port->drain_wait);
44902 if (port->port.tty)
44903 tty_hangup(port->port.tty);
44904 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44905
44906 /* finally, free any unused/unusable I/O buffers */
44907 spin_lock_irqsave(&port->port_lock, flags);
44908 - if (port->port.count == 0 && !port->openclose)
44909 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44910 gs_buf_free(&port->port_write_buf);
44911 gs_free_requests(gser->out, &port->read_pool, NULL);
44912 gs_free_requests(gser->out, &port->read_queue, NULL);
44913 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44914 index 5f3bcd3..bfca43f 100644
44915 --- a/drivers/usb/serial/console.c
44916 +++ b/drivers/usb/serial/console.c
44917 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44918
44919 info->port = port;
44920
44921 - ++port->port.count;
44922 + atomic_inc(&port->port.count);
44923 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44924 if (serial->type->set_termios) {
44925 /*
44926 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44927 }
44928 /* Now that any required fake tty operations are completed restore
44929 * the tty port count */
44930 - --port->port.count;
44931 + atomic_dec(&port->port.count);
44932 /* The console is special in terms of closing the device so
44933 * indicate this port is now acting as a system console. */
44934 port->port.console = 1;
44935 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44936 free_tty:
44937 kfree(tty);
44938 reset_open_count:
44939 - port->port.count = 0;
44940 + atomic_set(&port->port.count, 0);
44941 usb_autopm_put_interface(serial->interface);
44942 error_get_interface:
44943 usb_serial_put(serial);
44944 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44945 index 6c3586a..a94e621 100644
44946 --- a/drivers/usb/storage/realtek_cr.c
44947 +++ b/drivers/usb/storage/realtek_cr.c
44948 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44949
44950 buf = kmalloc(len, GFP_NOIO);
44951 if (buf == NULL)
44952 - return USB_STOR_TRANSPORT_ERROR;
44953 + return -ENOMEM;
44954
44955 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44956
44957 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44958 index 75f70f0..d467e1a 100644
44959 --- a/drivers/usb/storage/usb.h
44960 +++ b/drivers/usb/storage/usb.h
44961 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44962 __u8 useProtocol;
44963 __u8 useTransport;
44964 int (*initFunction)(struct us_data *);
44965 -};
44966 +} __do_const;
44967
44968
44969 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44970 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44971 index d6bea3e..60b250e 100644
44972 --- a/drivers/usb/wusbcore/wa-hc.h
44973 +++ b/drivers/usb/wusbcore/wa-hc.h
44974 @@ -192,7 +192,7 @@ struct wahc {
44975 struct list_head xfer_delayed_list;
44976 spinlock_t xfer_list_lock;
44977 struct work_struct xfer_work;
44978 - atomic_t xfer_id_count;
44979 + atomic_unchecked_t xfer_id_count;
44980 };
44981
44982
44983 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44984 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44985 spin_lock_init(&wa->xfer_list_lock);
44986 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44987 - atomic_set(&wa->xfer_id_count, 1);
44988 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44989 }
44990
44991 /**
44992 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44993 index 57c01ab..8a05959 100644
44994 --- a/drivers/usb/wusbcore/wa-xfer.c
44995 +++ b/drivers/usb/wusbcore/wa-xfer.c
44996 @@ -296,7 +296,7 @@ out:
44997 */
44998 static void wa_xfer_id_init(struct wa_xfer *xfer)
44999 {
45000 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
45001 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
45002 }
45003
45004 /*
45005 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
45006 index 8c55011..eed4ae1a 100644
45007 --- a/drivers/video/aty/aty128fb.c
45008 +++ b/drivers/video/aty/aty128fb.c
45009 @@ -149,7 +149,7 @@ enum {
45010 };
45011
45012 /* Must match above enum */
45013 -static char * const r128_family[] = {
45014 +static const char * const r128_family[] = {
45015 "AGP",
45016 "PCI",
45017 "PRO AGP",
45018 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45019 index 4f27fdc..d3537e6 100644
45020 --- a/drivers/video/aty/atyfb_base.c
45021 +++ b/drivers/video/aty/atyfb_base.c
45022 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45023 par->accel_flags = var->accel_flags; /* hack */
45024
45025 if (var->accel_flags) {
45026 - info->fbops->fb_sync = atyfb_sync;
45027 + pax_open_kernel();
45028 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45029 + pax_close_kernel();
45030 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45031 } else {
45032 - info->fbops->fb_sync = NULL;
45033 + pax_open_kernel();
45034 + *(void **)&info->fbops->fb_sync = NULL;
45035 + pax_close_kernel();
45036 info->flags |= FBINFO_HWACCEL_DISABLED;
45037 }
45038
45039 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45040 index 95ec042..e6affdd 100644
45041 --- a/drivers/video/aty/mach64_cursor.c
45042 +++ b/drivers/video/aty/mach64_cursor.c
45043 @@ -7,6 +7,7 @@
45044 #include <linux/string.h>
45045
45046 #include <asm/io.h>
45047 +#include <asm/pgtable.h>
45048
45049 #ifdef __sparc__
45050 #include <asm/fbio.h>
45051 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45052 info->sprite.buf_align = 16; /* and 64 lines tall. */
45053 info->sprite.flags = FB_PIXMAP_IO;
45054
45055 - info->fbops->fb_cursor = atyfb_cursor;
45056 + pax_open_kernel();
45057 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45058 + pax_close_kernel();
45059
45060 return 0;
45061 }
45062 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45063 index 6c5ed6b..b727c88 100644
45064 --- a/drivers/video/backlight/kb3886_bl.c
45065 +++ b/drivers/video/backlight/kb3886_bl.c
45066 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45067 static unsigned long kb3886bl_flags;
45068 #define KB3886BL_SUSPENDED 0x01
45069
45070 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45071 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45072 {
45073 .ident = "Sahara Touch-iT",
45074 .matches = {
45075 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45076 index 88cad6b..dd746c7 100644
45077 --- a/drivers/video/fb_defio.c
45078 +++ b/drivers/video/fb_defio.c
45079 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45080
45081 BUG_ON(!fbdefio);
45082 mutex_init(&fbdefio->lock);
45083 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45084 + pax_open_kernel();
45085 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45086 + pax_close_kernel();
45087 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45088 INIT_LIST_HEAD(&fbdefio->pagelist);
45089 if (fbdefio->delay == 0) /* set a default of 1 s */
45090 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45091 page->mapping = NULL;
45092 }
45093
45094 - info->fbops->fb_mmap = NULL;
45095 + *(void **)&info->fbops->fb_mmap = NULL;
45096 mutex_destroy(&fbdefio->lock);
45097 }
45098 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45099 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45100 index 5c3960d..15cf8fc 100644
45101 --- a/drivers/video/fbcmap.c
45102 +++ b/drivers/video/fbcmap.c
45103 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45104 rc = -ENODEV;
45105 goto out;
45106 }
45107 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45108 - !info->fbops->fb_setcmap)) {
45109 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45110 rc = -EINVAL;
45111 goto out1;
45112 }
45113 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45114 index 0a49456..fd5be1b 100644
45115 --- a/drivers/video/fbmem.c
45116 +++ b/drivers/video/fbmem.c
45117 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45118 image->dx += image->width + 8;
45119 }
45120 } else if (rotate == FB_ROTATE_UD) {
45121 - for (x = 0; x < num && image->dx >= 0; x++) {
45122 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45123 info->fbops->fb_imageblit(info, image);
45124 image->dx -= image->width + 8;
45125 }
45126 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45127 image->dy += image->height + 8;
45128 }
45129 } else if (rotate == FB_ROTATE_CCW) {
45130 - for (x = 0; x < num && image->dy >= 0; x++) {
45131 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45132 info->fbops->fb_imageblit(info, image);
45133 image->dy -= image->height + 8;
45134 }
45135 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45136 return -EFAULT;
45137 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45138 return -EINVAL;
45139 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45140 + if (con2fb.framebuffer >= FB_MAX)
45141 return -EINVAL;
45142 if (!registered_fb[con2fb.framebuffer])
45143 request_module("fb%d", con2fb.framebuffer);
45144 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45145 index 7672d2e..b56437f 100644
45146 --- a/drivers/video/i810/i810_accel.c
45147 +++ b/drivers/video/i810/i810_accel.c
45148 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45149 }
45150 }
45151 printk("ringbuffer lockup!!!\n");
45152 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45153 i810_report_error(mmio);
45154 par->dev_flags |= LOCKUP;
45155 info->pixmap.scan_align = 1;
45156 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45157 index 3c14e43..eafa544 100644
45158 --- a/drivers/video/logo/logo_linux_clut224.ppm
45159 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45160 @@ -1,1604 +1,1123 @@
45161 P3
45162 -# Standard 224-color Linux logo
45163 80 80
45164 255
45165 - 0 0 0 0 0 0 0 0 0 0 0 0
45166 - 0 0 0 0 0 0 0 0 0 0 0 0
45167 - 0 0 0 0 0 0 0 0 0 0 0 0
45168 - 0 0 0 0 0 0 0 0 0 0 0 0
45169 - 0 0 0 0 0 0 0 0 0 0 0 0
45170 - 0 0 0 0 0 0 0 0 0 0 0 0
45171 - 0 0 0 0 0 0 0 0 0 0 0 0
45172 - 0 0 0 0 0 0 0 0 0 0 0 0
45173 - 0 0 0 0 0 0 0 0 0 0 0 0
45174 - 6 6 6 6 6 6 10 10 10 10 10 10
45175 - 10 10 10 6 6 6 6 6 6 6 6 6
45176 - 0 0 0 0 0 0 0 0 0 0 0 0
45177 - 0 0 0 0 0 0 0 0 0 0 0 0
45178 - 0 0 0 0 0 0 0 0 0 0 0 0
45179 - 0 0 0 0 0 0 0 0 0 0 0 0
45180 - 0 0 0 0 0 0 0 0 0 0 0 0
45181 - 0 0 0 0 0 0 0 0 0 0 0 0
45182 - 0 0 0 0 0 0 0 0 0 0 0 0
45183 - 0 0 0 0 0 0 0 0 0 0 0 0
45184 - 0 0 0 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 6 6 6 10 10 10 14 14 14
45194 - 22 22 22 26 26 26 30 30 30 34 34 34
45195 - 30 30 30 30 30 30 26 26 26 18 18 18
45196 - 14 14 14 10 10 10 6 6 6 0 0 0
45197 - 0 0 0 0 0 0 0 0 0 0 0 0
45198 - 0 0 0 0 0 0 0 0 0 0 0 0
45199 - 0 0 0 0 0 0 0 0 0 0 0 0
45200 - 0 0 0 0 0 0 0 0 0 0 0 0
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 0 0 0 0 0 0 0 0 0 0 0 0
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 0 0 0 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 0 0 0 0 0 0
45206 - 0 0 0 0 0 1 0 0 1 0 0 0
45207 - 0 0 0 0 0 0 0 0 0 0 0 0
45208 - 0 0 0 0 0 0 0 0 0 0 0 0
45209 - 0 0 0 0 0 0 0 0 0 0 0 0
45210 - 0 0 0 0 0 0 0 0 0 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 6 6 6 14 14 14 26 26 26 42 42 42
45214 - 54 54 54 66 66 66 78 78 78 78 78 78
45215 - 78 78 78 74 74 74 66 66 66 54 54 54
45216 - 42 42 42 26 26 26 18 18 18 10 10 10
45217 - 6 6 6 0 0 0 0 0 0 0 0 0
45218 - 0 0 0 0 0 0 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 0 0 0
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 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 1 0 0 0 0 0 0 0 0 0
45227 - 0 0 0 0 0 0 0 0 0 0 0 0
45228 - 0 0 0 0 0 0 0 0 0 0 0 0
45229 - 0 0 0 0 0 0 0 0 0 0 0 0
45230 - 0 0 0 0 0 0 0 0 0 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 10 10 10
45233 - 22 22 22 42 42 42 66 66 66 86 86 86
45234 - 66 66 66 38 38 38 38 38 38 22 22 22
45235 - 26 26 26 34 34 34 54 54 54 66 66 66
45236 - 86 86 86 70 70 70 46 46 46 26 26 26
45237 - 14 14 14 6 6 6 0 0 0 0 0 0
45238 - 0 0 0 0 0 0 0 0 0 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 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 1 0 0 1 0 0 1 0 0 0
45247 - 0 0 0 0 0 0 0 0 0 0 0 0
45248 - 0 0 0 0 0 0 0 0 0 0 0 0
45249 - 0 0 0 0 0 0 0 0 0 0 0 0
45250 - 0 0 0 0 0 0 0 0 0 0 0 0
45251 - 0 0 0 0 0 0 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 10 10 10 26 26 26
45253 - 50 50 50 82 82 82 58 58 58 6 6 6
45254 - 2 2 6 2 2 6 2 2 6 2 2 6
45255 - 2 2 6 2 2 6 2 2 6 2 2 6
45256 - 6 6 6 54 54 54 86 86 86 66 66 66
45257 - 38 38 38 18 18 18 6 6 6 0 0 0
45258 - 0 0 0 0 0 0 0 0 0 0 0 0
45259 - 0 0 0 0 0 0 0 0 0 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 0 0 0 0 0 0 0 0 0 0
45263 - 0 0 0 0 0 0 0 0 0 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 6 6 6 22 22 22 50 50 50
45273 - 78 78 78 34 34 34 2 2 6 2 2 6
45274 - 2 2 6 2 2 6 2 2 6 2 2 6
45275 - 2 2 6 2 2 6 2 2 6 2 2 6
45276 - 2 2 6 2 2 6 6 6 6 70 70 70
45277 - 78 78 78 46 46 46 22 22 22 6 6 6
45278 - 0 0 0 0 0 0 0 0 0 0 0 0
45279 - 0 0 0 0 0 0 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 0 0 0 0 0 0 0 0 0 0
45283 - 0 0 0 0 0 0 0 0 0 0 0 0
45284 - 0 0 0 0 0 0 0 0 0 0 0 0
45285 - 0 0 0 0 0 0 0 0 0 0 0 0
45286 - 0 0 1 0 0 1 0 0 1 0 0 0
45287 - 0 0 0 0 0 0 0 0 0 0 0 0
45288 - 0 0 0 0 0 0 0 0 0 0 0 0
45289 - 0 0 0 0 0 0 0 0 0 0 0 0
45290 - 0 0 0 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 6 6 6 18 18 18 42 42 42 82 82 82
45293 - 26 26 26 2 2 6 2 2 6 2 2 6
45294 - 2 2 6 2 2 6 2 2 6 2 2 6
45295 - 2 2 6 2 2 6 2 2 6 14 14 14
45296 - 46 46 46 34 34 34 6 6 6 2 2 6
45297 - 42 42 42 78 78 78 42 42 42 18 18 18
45298 - 6 6 6 0 0 0 0 0 0 0 0 0
45299 - 0 0 0 0 0 0 0 0 0 0 0 0
45300 - 0 0 0 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 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 1 0 0 0 0 0 1 0 0 0
45307 - 0 0 0 0 0 0 0 0 0 0 0 0
45308 - 0 0 0 0 0 0 0 0 0 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 0 0 0 0 0 0 0 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 10 10 10 30 30 30 66 66 66 58 58 58
45313 - 2 2 6 2 2 6 2 2 6 2 2 6
45314 - 2 2 6 2 2 6 2 2 6 2 2 6
45315 - 2 2 6 2 2 6 2 2 6 26 26 26
45316 - 86 86 86 101 101 101 46 46 46 10 10 10
45317 - 2 2 6 58 58 58 70 70 70 34 34 34
45318 - 10 10 10 0 0 0 0 0 0 0 0 0
45319 - 0 0 0 0 0 0 0 0 0 0 0 0
45320 - 0 0 0 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 0 0 0
45322 - 0 0 0 0 0 0 0 0 0 0 0 0
45323 - 0 0 0 0 0 0 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 1 0 0 1 0 0 1 0 0 0
45327 - 0 0 0 0 0 0 0 0 0 0 0 0
45328 - 0 0 0 0 0 0 0 0 0 0 0 0
45329 - 0 0 0 0 0 0 0 0 0 0 0 0
45330 - 0 0 0 0 0 0 0 0 0 0 0 0
45331 - 0 0 0 0 0 0 0 0 0 0 0 0
45332 - 14 14 14 42 42 42 86 86 86 10 10 10
45333 - 2 2 6 2 2 6 2 2 6 2 2 6
45334 - 2 2 6 2 2 6 2 2 6 2 2 6
45335 - 2 2 6 2 2 6 2 2 6 30 30 30
45336 - 94 94 94 94 94 94 58 58 58 26 26 26
45337 - 2 2 6 6 6 6 78 78 78 54 54 54
45338 - 22 22 22 6 6 6 0 0 0 0 0 0
45339 - 0 0 0 0 0 0 0 0 0 0 0 0
45340 - 0 0 0 0 0 0 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 0 0 0
45342 - 0 0 0 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 0 0 0 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 6 6 6
45352 - 22 22 22 62 62 62 62 62 62 2 2 6
45353 - 2 2 6 2 2 6 2 2 6 2 2 6
45354 - 2 2 6 2 2 6 2 2 6 2 2 6
45355 - 2 2 6 2 2 6 2 2 6 26 26 26
45356 - 54 54 54 38 38 38 18 18 18 10 10 10
45357 - 2 2 6 2 2 6 34 34 34 82 82 82
45358 - 38 38 38 14 14 14 0 0 0 0 0 0
45359 - 0 0 0 0 0 0 0 0 0 0 0 0
45360 - 0 0 0 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 0 0 0 0 0 0 0
45363 - 0 0 0 0 0 0 0 0 0 0 0 0
45364 - 0 0 0 0 0 0 0 0 0 0 0 0
45365 - 0 0 0 0 0 0 0 0 0 0 0 0
45366 - 0 0 0 0 0 1 0 0 1 0 0 0
45367 - 0 0 0 0 0 0 0 0 0 0 0 0
45368 - 0 0 0 0 0 0 0 0 0 0 0 0
45369 - 0 0 0 0 0 0 0 0 0 0 0 0
45370 - 0 0 0 0 0 0 0 0 0 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 6 6 6
45372 - 30 30 30 78 78 78 30 30 30 2 2 6
45373 - 2 2 6 2 2 6 2 2 6 2 2 6
45374 - 2 2 6 2 2 6 2 2 6 2 2 6
45375 - 2 2 6 2 2 6 2 2 6 10 10 10
45376 - 10 10 10 2 2 6 2 2 6 2 2 6
45377 - 2 2 6 2 2 6 2 2 6 78 78 78
45378 - 50 50 50 18 18 18 6 6 6 0 0 0
45379 - 0 0 0 0 0 0 0 0 0 0 0 0
45380 - 0 0 0 0 0 0 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 0 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 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 1 0 0 0 0 0 0 0 0 0
45387 - 0 0 0 0 0 0 0 0 0 0 0 0
45388 - 0 0 0 0 0 0 0 0 0 0 0 0
45389 - 0 0 0 0 0 0 0 0 0 0 0 0
45390 - 0 0 0 0 0 0 0 0 0 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 10 10 10
45392 - 38 38 38 86 86 86 14 14 14 2 2 6
45393 - 2 2 6 2 2 6 2 2 6 2 2 6
45394 - 2 2 6 2 2 6 2 2 6 2 2 6
45395 - 2 2 6 2 2 6 2 2 6 2 2 6
45396 - 2 2 6 2 2 6 2 2 6 2 2 6
45397 - 2 2 6 2 2 6 2 2 6 54 54 54
45398 - 66 66 66 26 26 26 6 6 6 0 0 0
45399 - 0 0 0 0 0 0 0 0 0 0 0 0
45400 - 0 0 0 0 0 0 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 0 0 0 0 0 0 0
45403 - 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 1 0 0 1 0 0 0
45407 - 0 0 0 0 0 0 0 0 0 0 0 0
45408 - 0 0 0 0 0 0 0 0 0 0 0 0
45409 - 0 0 0 0 0 0 0 0 0 0 0 0
45410 - 0 0 0 0 0 0 0 0 0 0 0 0
45411 - 0 0 0 0 0 0 0 0 0 14 14 14
45412 - 42 42 42 82 82 82 2 2 6 2 2 6
45413 - 2 2 6 6 6 6 10 10 10 2 2 6
45414 - 2 2 6 2 2 6 2 2 6 2 2 6
45415 - 2 2 6 2 2 6 2 2 6 6 6 6
45416 - 14 14 14 10 10 10 2 2 6 2 2 6
45417 - 2 2 6 2 2 6 2 2 6 18 18 18
45418 - 82 82 82 34 34 34 10 10 10 0 0 0
45419 - 0 0 0 0 0 0 0 0 0 0 0 0
45420 - 0 0 0 0 0 0 0 0 0 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 0 0 0
45423 - 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 1 0 0 0 0 0 0 0 0 0
45427 - 0 0 0 0 0 0 0 0 0 0 0 0
45428 - 0 0 0 0 0 0 0 0 0 0 0 0
45429 - 0 0 0 0 0 0 0 0 0 0 0 0
45430 - 0 0 0 0 0 0 0 0 0 0 0 0
45431 - 0 0 0 0 0 0 0 0 0 14 14 14
45432 - 46 46 46 86 86 86 2 2 6 2 2 6
45433 - 6 6 6 6 6 6 22 22 22 34 34 34
45434 - 6 6 6 2 2 6 2 2 6 2 2 6
45435 - 2 2 6 2 2 6 18 18 18 34 34 34
45436 - 10 10 10 50 50 50 22 22 22 2 2 6
45437 - 2 2 6 2 2 6 2 2 6 10 10 10
45438 - 86 86 86 42 42 42 14 14 14 0 0 0
45439 - 0 0 0 0 0 0 0 0 0 0 0 0
45440 - 0 0 0 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 0 0 0 0 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 1 0 0 1 0 0 1 0 0 0
45447 - 0 0 0 0 0 0 0 0 0 0 0 0
45448 - 0 0 0 0 0 0 0 0 0 0 0 0
45449 - 0 0 0 0 0 0 0 0 0 0 0 0
45450 - 0 0 0 0 0 0 0 0 0 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 14 14 14
45452 - 46 46 46 86 86 86 2 2 6 2 2 6
45453 - 38 38 38 116 116 116 94 94 94 22 22 22
45454 - 22 22 22 2 2 6 2 2 6 2 2 6
45455 - 14 14 14 86 86 86 138 138 138 162 162 162
45456 -154 154 154 38 38 38 26 26 26 6 6 6
45457 - 2 2 6 2 2 6 2 2 6 2 2 6
45458 - 86 86 86 46 46 46 14 14 14 0 0 0
45459 - 0 0 0 0 0 0 0 0 0 0 0 0
45460 - 0 0 0 0 0 0 0 0 0 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 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 14 14 14
45472 - 46 46 46 86 86 86 2 2 6 14 14 14
45473 -134 134 134 198 198 198 195 195 195 116 116 116
45474 - 10 10 10 2 2 6 2 2 6 6 6 6
45475 -101 98 89 187 187 187 210 210 210 218 218 218
45476 -214 214 214 134 134 134 14 14 14 6 6 6
45477 - 2 2 6 2 2 6 2 2 6 2 2 6
45478 - 86 86 86 50 50 50 18 18 18 6 6 6
45479 - 0 0 0 0 0 0 0 0 0 0 0 0
45480 - 0 0 0 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 0 0 0 0 0 0 0 0 0 0
45483 - 0 0 0 0 0 0 0 0 0 0 0 0
45484 - 0 0 0 0 0 0 0 0 0 0 0 0
45485 - 0 0 0 0 0 0 0 0 1 0 0 0
45486 - 0 0 1 0 0 1 0 0 1 0 0 0
45487 - 0 0 0 0 0 0 0 0 0 0 0 0
45488 - 0 0 0 0 0 0 0 0 0 0 0 0
45489 - 0 0 0 0 0 0 0 0 0 0 0 0
45490 - 0 0 0 0 0 0 0 0 0 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 14 14 14
45492 - 46 46 46 86 86 86 2 2 6 54 54 54
45493 -218 218 218 195 195 195 226 226 226 246 246 246
45494 - 58 58 58 2 2 6 2 2 6 30 30 30
45495 -210 210 210 253 253 253 174 174 174 123 123 123
45496 -221 221 221 234 234 234 74 74 74 2 2 6
45497 - 2 2 6 2 2 6 2 2 6 2 2 6
45498 - 70 70 70 58 58 58 22 22 22 6 6 6
45499 - 0 0 0 0 0 0 0 0 0 0 0 0
45500 - 0 0 0 0 0 0 0 0 0 0 0 0
45501 - 0 0 0 0 0 0 0 0 0 0 0 0
45502 - 0 0 0 0 0 0 0 0 0 0 0 0
45503 - 0 0 0 0 0 0 0 0 0 0 0 0
45504 - 0 0 0 0 0 0 0 0 0 0 0 0
45505 - 0 0 0 0 0 0 0 0 0 0 0 0
45506 - 0 0 0 0 0 0 0 0 0 0 0 0
45507 - 0 0 0 0 0 0 0 0 0 0 0 0
45508 - 0 0 0 0 0 0 0 0 0 0 0 0
45509 - 0 0 0 0 0 0 0 0 0 0 0 0
45510 - 0 0 0 0 0 0 0 0 0 0 0 0
45511 - 0 0 0 0 0 0 0 0 0 14 14 14
45512 - 46 46 46 82 82 82 2 2 6 106 106 106
45513 -170 170 170 26 26 26 86 86 86 226 226 226
45514 -123 123 123 10 10 10 14 14 14 46 46 46
45515 -231 231 231 190 190 190 6 6 6 70 70 70
45516 - 90 90 90 238 238 238 158 158 158 2 2 6
45517 - 2 2 6 2 2 6 2 2 6 2 2 6
45518 - 70 70 70 58 58 58 22 22 22 6 6 6
45519 - 0 0 0 0 0 0 0 0 0 0 0 0
45520 - 0 0 0 0 0 0 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 0 0 0 0
45522 - 0 0 0 0 0 0 0 0 0 0 0 0
45523 - 0 0 0 0 0 0 0 0 0 0 0 0
45524 - 0 0 0 0 0 0 0 0 0 0 0 0
45525 - 0 0 0 0 0 0 0 0 1 0 0 0
45526 - 0 0 1 0 0 1 0 0 1 0 0 0
45527 - 0 0 0 0 0 0 0 0 0 0 0 0
45528 - 0 0 0 0 0 0 0 0 0 0 0 0
45529 - 0 0 0 0 0 0 0 0 0 0 0 0
45530 - 0 0 0 0 0 0 0 0 0 0 0 0
45531 - 0 0 0 0 0 0 0 0 0 14 14 14
45532 - 42 42 42 86 86 86 6 6 6 116 116 116
45533 -106 106 106 6 6 6 70 70 70 149 149 149
45534 -128 128 128 18 18 18 38 38 38 54 54 54
45535 -221 221 221 106 106 106 2 2 6 14 14 14
45536 - 46 46 46 190 190 190 198 198 198 2 2 6
45537 - 2 2 6 2 2 6 2 2 6 2 2 6
45538 - 74 74 74 62 62 62 22 22 22 6 6 6
45539 - 0 0 0 0 0 0 0 0 0 0 0 0
45540 - 0 0 0 0 0 0 0 0 0 0 0 0
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 0 0 0
45543 - 0 0 0 0 0 0 0 0 0 0 0 0
45544 - 0 0 0 0 0 0 0 0 0 0 0 0
45545 - 0 0 0 0 0 0 0 0 1 0 0 0
45546 - 0 0 1 0 0 0 0 0 1 0 0 0
45547 - 0 0 0 0 0 0 0 0 0 0 0 0
45548 - 0 0 0 0 0 0 0 0 0 0 0 0
45549 - 0 0 0 0 0 0 0 0 0 0 0 0
45550 - 0 0 0 0 0 0 0 0 0 0 0 0
45551 - 0 0 0 0 0 0 0 0 0 14 14 14
45552 - 42 42 42 94 94 94 14 14 14 101 101 101
45553 -128 128 128 2 2 6 18 18 18 116 116 116
45554 -118 98 46 121 92 8 121 92 8 98 78 10
45555 -162 162 162 106 106 106 2 2 6 2 2 6
45556 - 2 2 6 195 195 195 195 195 195 6 6 6
45557 - 2 2 6 2 2 6 2 2 6 2 2 6
45558 - 74 74 74 62 62 62 22 22 22 6 6 6
45559 - 0 0 0 0 0 0 0 0 0 0 0 0
45560 - 0 0 0 0 0 0 0 0 0 0 0 0
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 0 0 0 0 0 0
45563 - 0 0 0 0 0 0 0 0 0 0 0 0
45564 - 0 0 0 0 0 0 0 0 0 0 0 0
45565 - 0 0 0 0 0 0 0 0 1 0 0 1
45566 - 0 0 1 0 0 0 0 0 1 0 0 0
45567 - 0 0 0 0 0 0 0 0 0 0 0 0
45568 - 0 0 0 0 0 0 0 0 0 0 0 0
45569 - 0 0 0 0 0 0 0 0 0 0 0 0
45570 - 0 0 0 0 0 0 0 0 0 0 0 0
45571 - 0 0 0 0 0 0 0 0 0 10 10 10
45572 - 38 38 38 90 90 90 14 14 14 58 58 58
45573 -210 210 210 26 26 26 54 38 6 154 114 10
45574 -226 170 11 236 186 11 225 175 15 184 144 12
45575 -215 174 15 175 146 61 37 26 9 2 2 6
45576 - 70 70 70 246 246 246 138 138 138 2 2 6
45577 - 2 2 6 2 2 6 2 2 6 2 2 6
45578 - 70 70 70 66 66 66 26 26 26 6 6 6
45579 - 0 0 0 0 0 0 0 0 0 0 0 0
45580 - 0 0 0 0 0 0 0 0 0 0 0 0
45581 - 0 0 0 0 0 0 0 0 0 0 0 0
45582 - 0 0 0 0 0 0 0 0 0 0 0 0
45583 - 0 0 0 0 0 0 0 0 0 0 0 0
45584 - 0 0 0 0 0 0 0 0 0 0 0 0
45585 - 0 0 0 0 0 0 0 0 0 0 0 0
45586 - 0 0 0 0 0 0 0 0 0 0 0 0
45587 - 0 0 0 0 0 0 0 0 0 0 0 0
45588 - 0 0 0 0 0 0 0 0 0 0 0 0
45589 - 0 0 0 0 0 0 0 0 0 0 0 0
45590 - 0 0 0 0 0 0 0 0 0 0 0 0
45591 - 0 0 0 0 0 0 0 0 0 10 10 10
45592 - 38 38 38 86 86 86 14 14 14 10 10 10
45593 -195 195 195 188 164 115 192 133 9 225 175 15
45594 -239 182 13 234 190 10 232 195 16 232 200 30
45595 -245 207 45 241 208 19 232 195 16 184 144 12
45596 -218 194 134 211 206 186 42 42 42 2 2 6
45597 - 2 2 6 2 2 6 2 2 6 2 2 6
45598 - 50 50 50 74 74 74 30 30 30 6 6 6
45599 - 0 0 0 0 0 0 0 0 0 0 0 0
45600 - 0 0 0 0 0 0 0 0 0 0 0 0
45601 - 0 0 0 0 0 0 0 0 0 0 0 0
45602 - 0 0 0 0 0 0 0 0 0 0 0 0
45603 - 0 0 0 0 0 0 0 0 0 0 0 0
45604 - 0 0 0 0 0 0 0 0 0 0 0 0
45605 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45612 - 34 34 34 86 86 86 14 14 14 2 2 6
45613 -121 87 25 192 133 9 219 162 10 239 182 13
45614 -236 186 11 232 195 16 241 208 19 244 214 54
45615 -246 218 60 246 218 38 246 215 20 241 208 19
45616 -241 208 19 226 184 13 121 87 25 2 2 6
45617 - 2 2 6 2 2 6 2 2 6 2 2 6
45618 - 50 50 50 82 82 82 34 34 34 10 10 10
45619 - 0 0 0 0 0 0 0 0 0 0 0 0
45620 - 0 0 0 0 0 0 0 0 0 0 0 0
45621 - 0 0 0 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 0 0 0 0 0 0 0 0 0
45623 - 0 0 0 0 0 0 0 0 0 0 0 0
45624 - 0 0 0 0 0 0 0 0 0 0 0 0
45625 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45632 - 34 34 34 82 82 82 30 30 30 61 42 6
45633 -180 123 7 206 145 10 230 174 11 239 182 13
45634 -234 190 10 238 202 15 241 208 19 246 218 74
45635 -246 218 38 246 215 20 246 215 20 246 215 20
45636 -226 184 13 215 174 15 184 144 12 6 6 6
45637 - 2 2 6 2 2 6 2 2 6 2 2 6
45638 - 26 26 26 94 94 94 42 42 42 14 14 14
45639 - 0 0 0 0 0 0 0 0 0 0 0 0
45640 - 0 0 0 0 0 0 0 0 0 0 0 0
45641 - 0 0 0 0 0 0 0 0 0 0 0 0
45642 - 0 0 0 0 0 0 0 0 0 0 0 0
45643 - 0 0 0 0 0 0 0 0 0 0 0 0
45644 - 0 0 0 0 0 0 0 0 0 0 0 0
45645 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45652 - 30 30 30 78 78 78 50 50 50 104 69 6
45653 -192 133 9 216 158 10 236 178 12 236 186 11
45654 -232 195 16 241 208 19 244 214 54 245 215 43
45655 -246 215 20 246 215 20 241 208 19 198 155 10
45656 -200 144 11 216 158 10 156 118 10 2 2 6
45657 - 2 2 6 2 2 6 2 2 6 2 2 6
45658 - 6 6 6 90 90 90 54 54 54 18 18 18
45659 - 6 6 6 0 0 0 0 0 0 0 0 0
45660 - 0 0 0 0 0 0 0 0 0 0 0 0
45661 - 0 0 0 0 0 0 0 0 0 0 0 0
45662 - 0 0 0 0 0 0 0 0 0 0 0 0
45663 - 0 0 0 0 0 0 0 0 0 0 0 0
45664 - 0 0 0 0 0 0 0 0 0 0 0 0
45665 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45672 - 30 30 30 78 78 78 46 46 46 22 22 22
45673 -137 92 6 210 162 10 239 182 13 238 190 10
45674 -238 202 15 241 208 19 246 215 20 246 215 20
45675 -241 208 19 203 166 17 185 133 11 210 150 10
45676 -216 158 10 210 150 10 102 78 10 2 2 6
45677 - 6 6 6 54 54 54 14 14 14 2 2 6
45678 - 2 2 6 62 62 62 74 74 74 30 30 30
45679 - 10 10 10 0 0 0 0 0 0 0 0 0
45680 - 0 0 0 0 0 0 0 0 0 0 0 0
45681 - 0 0 0 0 0 0 0 0 0 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 0 0 0
45683 - 0 0 0 0 0 0 0 0 0 0 0 0
45684 - 0 0 0 0 0 0 0 0 0 0 0 0
45685 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45692 - 34 34 34 78 78 78 50 50 50 6 6 6
45693 - 94 70 30 139 102 15 190 146 13 226 184 13
45694 -232 200 30 232 195 16 215 174 15 190 146 13
45695 -168 122 10 192 133 9 210 150 10 213 154 11
45696 -202 150 34 182 157 106 101 98 89 2 2 6
45697 - 2 2 6 78 78 78 116 116 116 58 58 58
45698 - 2 2 6 22 22 22 90 90 90 46 46 46
45699 - 18 18 18 6 6 6 0 0 0 0 0 0
45700 - 0 0 0 0 0 0 0 0 0 0 0 0
45701 - 0 0 0 0 0 0 0 0 0 0 0 0
45702 - 0 0 0 0 0 0 0 0 0 0 0 0
45703 - 0 0 0 0 0 0 0 0 0 0 0 0
45704 - 0 0 0 0 0 0 0 0 0 0 0 0
45705 - 0 0 0 0 0 0 0 0 0 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 10 10 10
45712 - 38 38 38 86 86 86 50 50 50 6 6 6
45713 -128 128 128 174 154 114 156 107 11 168 122 10
45714 -198 155 10 184 144 12 197 138 11 200 144 11
45715 -206 145 10 206 145 10 197 138 11 188 164 115
45716 -195 195 195 198 198 198 174 174 174 14 14 14
45717 - 2 2 6 22 22 22 116 116 116 116 116 116
45718 - 22 22 22 2 2 6 74 74 74 70 70 70
45719 - 30 30 30 10 10 10 0 0 0 0 0 0
45720 - 0 0 0 0 0 0 0 0 0 0 0 0
45721 - 0 0 0 0 0 0 0 0 0 0 0 0
45722 - 0 0 0 0 0 0 0 0 0 0 0 0
45723 - 0 0 0 0 0 0 0 0 0 0 0 0
45724 - 0 0 0 0 0 0 0 0 0 0 0 0
45725 - 0 0 0 0 0 0 0 0 0 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 6 6 6 18 18 18
45732 - 50 50 50 101 101 101 26 26 26 10 10 10
45733 -138 138 138 190 190 190 174 154 114 156 107 11
45734 -197 138 11 200 144 11 197 138 11 192 133 9
45735 -180 123 7 190 142 34 190 178 144 187 187 187
45736 -202 202 202 221 221 221 214 214 214 66 66 66
45737 - 2 2 6 2 2 6 50 50 50 62 62 62
45738 - 6 6 6 2 2 6 10 10 10 90 90 90
45739 - 50 50 50 18 18 18 6 6 6 0 0 0
45740 - 0 0 0 0 0 0 0 0 0 0 0 0
45741 - 0 0 0 0 0 0 0 0 0 0 0 0
45742 - 0 0 0 0 0 0 0 0 0 0 0 0
45743 - 0 0 0 0 0 0 0 0 0 0 0 0
45744 - 0 0 0 0 0 0 0 0 0 0 0 0
45745 - 0 0 0 0 0 0 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 10 10 10 34 34 34
45752 - 74 74 74 74 74 74 2 2 6 6 6 6
45753 -144 144 144 198 198 198 190 190 190 178 166 146
45754 -154 121 60 156 107 11 156 107 11 168 124 44
45755 -174 154 114 187 187 187 190 190 190 210 210 210
45756 -246 246 246 253 253 253 253 253 253 182 182 182
45757 - 6 6 6 2 2 6 2 2 6 2 2 6
45758 - 2 2 6 2 2 6 2 2 6 62 62 62
45759 - 74 74 74 34 34 34 14 14 14 0 0 0
45760 - 0 0 0 0 0 0 0 0 0 0 0 0
45761 - 0 0 0 0 0 0 0 0 0 0 0 0
45762 - 0 0 0 0 0 0 0 0 0 0 0 0
45763 - 0 0 0 0 0 0 0 0 0 0 0 0
45764 - 0 0 0 0 0 0 0 0 0 0 0 0
45765 - 0 0 0 0 0 0 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 10 10 10 22 22 22 54 54 54
45772 - 94 94 94 18 18 18 2 2 6 46 46 46
45773 -234 234 234 221 221 221 190 190 190 190 190 190
45774 -190 190 190 187 187 187 187 187 187 190 190 190
45775 -190 190 190 195 195 195 214 214 214 242 242 242
45776 -253 253 253 253 253 253 253 253 253 253 253 253
45777 - 82 82 82 2 2 6 2 2 6 2 2 6
45778 - 2 2 6 2 2 6 2 2 6 14 14 14
45779 - 86 86 86 54 54 54 22 22 22 6 6 6
45780 - 0 0 0 0 0 0 0 0 0 0 0 0
45781 - 0 0 0 0 0 0 0 0 0 0 0 0
45782 - 0 0 0 0 0 0 0 0 0 0 0 0
45783 - 0 0 0 0 0 0 0 0 0 0 0 0
45784 - 0 0 0 0 0 0 0 0 0 0 0 0
45785 - 0 0 0 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 - 6 6 6 18 18 18 46 46 46 90 90 90
45792 - 46 46 46 18 18 18 6 6 6 182 182 182
45793 -253 253 253 246 246 246 206 206 206 190 190 190
45794 -190 190 190 190 190 190 190 190 190 190 190 190
45795 -206 206 206 231 231 231 250 250 250 253 253 253
45796 -253 253 253 253 253 253 253 253 253 253 253 253
45797 -202 202 202 14 14 14 2 2 6 2 2 6
45798 - 2 2 6 2 2 6 2 2 6 2 2 6
45799 - 42 42 42 86 86 86 42 42 42 18 18 18
45800 - 6 6 6 0 0 0 0 0 0 0 0 0
45801 - 0 0 0 0 0 0 0 0 0 0 0 0
45802 - 0 0 0 0 0 0 0 0 0 0 0 0
45803 - 0 0 0 0 0 0 0 0 0 0 0 0
45804 - 0 0 0 0 0 0 0 0 0 0 0 0
45805 - 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 6 6 6
45811 - 14 14 14 38 38 38 74 74 74 66 66 66
45812 - 2 2 6 6 6 6 90 90 90 250 250 250
45813 -253 253 253 253 253 253 238 238 238 198 198 198
45814 -190 190 190 190 190 190 195 195 195 221 221 221
45815 -246 246 246 253 253 253 253 253 253 253 253 253
45816 -253 253 253 253 253 253 253 253 253 253 253 253
45817 -253 253 253 82 82 82 2 2 6 2 2 6
45818 - 2 2 6 2 2 6 2 2 6 2 2 6
45819 - 2 2 6 78 78 78 70 70 70 34 34 34
45820 - 14 14 14 6 6 6 0 0 0 0 0 0
45821 - 0 0 0 0 0 0 0 0 0 0 0 0
45822 - 0 0 0 0 0 0 0 0 0 0 0 0
45823 - 0 0 0 0 0 0 0 0 0 0 0 0
45824 - 0 0 0 0 0 0 0 0 0 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 14 14 14
45831 - 34 34 34 66 66 66 78 78 78 6 6 6
45832 - 2 2 6 18 18 18 218 218 218 253 253 253
45833 -253 253 253 253 253 253 253 253 253 246 246 246
45834 -226 226 226 231 231 231 246 246 246 253 253 253
45835 -253 253 253 253 253 253 253 253 253 253 253 253
45836 -253 253 253 253 253 253 253 253 253 253 253 253
45837 -253 253 253 178 178 178 2 2 6 2 2 6
45838 - 2 2 6 2 2 6 2 2 6 2 2 6
45839 - 2 2 6 18 18 18 90 90 90 62 62 62
45840 - 30 30 30 10 10 10 0 0 0 0 0 0
45841 - 0 0 0 0 0 0 0 0 0 0 0 0
45842 - 0 0 0 0 0 0 0 0 0 0 0 0
45843 - 0 0 0 0 0 0 0 0 0 0 0 0
45844 - 0 0 0 0 0 0 0 0 0 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 10 10 10 26 26 26
45851 - 58 58 58 90 90 90 18 18 18 2 2 6
45852 - 2 2 6 110 110 110 253 253 253 253 253 253
45853 -253 253 253 253 253 253 253 253 253 253 253 253
45854 -250 250 250 253 253 253 253 253 253 253 253 253
45855 -253 253 253 253 253 253 253 253 253 253 253 253
45856 -253 253 253 253 253 253 253 253 253 253 253 253
45857 -253 253 253 231 231 231 18 18 18 2 2 6
45858 - 2 2 6 2 2 6 2 2 6 2 2 6
45859 - 2 2 6 2 2 6 18 18 18 94 94 94
45860 - 54 54 54 26 26 26 10 10 10 0 0 0
45861 - 0 0 0 0 0 0 0 0 0 0 0 0
45862 - 0 0 0 0 0 0 0 0 0 0 0 0
45863 - 0 0 0 0 0 0 0 0 0 0 0 0
45864 - 0 0 0 0 0 0 0 0 0 0 0 0
45865 - 0 0 0 0 0 0 0 0 0 0 0 0
45866 - 0 0 0 0 0 0 0 0 0 0 0 0
45867 - 0 0 0 0 0 0 0 0 0 0 0 0
45868 - 0 0 0 0 0 0 0 0 0 0 0 0
45869 - 0 0 0 0 0 0 0 0 0 0 0 0
45870 - 0 0 0 6 6 6 22 22 22 50 50 50
45871 - 90 90 90 26 26 26 2 2 6 2 2 6
45872 - 14 14 14 195 195 195 250 250 250 253 253 253
45873 -253 253 253 253 253 253 253 253 253 253 253 253
45874 -253 253 253 253 253 253 253 253 253 253 253 253
45875 -253 253 253 253 253 253 253 253 253 253 253 253
45876 -253 253 253 253 253 253 253 253 253 253 253 253
45877 -250 250 250 242 242 242 54 54 54 2 2 6
45878 - 2 2 6 2 2 6 2 2 6 2 2 6
45879 - 2 2 6 2 2 6 2 2 6 38 38 38
45880 - 86 86 86 50 50 50 22 22 22 6 6 6
45881 - 0 0 0 0 0 0 0 0 0 0 0 0
45882 - 0 0 0 0 0 0 0 0 0 0 0 0
45883 - 0 0 0 0 0 0 0 0 0 0 0 0
45884 - 0 0 0 0 0 0 0 0 0 0 0 0
45885 - 0 0 0 0 0 0 0 0 0 0 0 0
45886 - 0 0 0 0 0 0 0 0 0 0 0 0
45887 - 0 0 0 0 0 0 0 0 0 0 0 0
45888 - 0 0 0 0 0 0 0 0 0 0 0 0
45889 - 0 0 0 0 0 0 0 0 0 0 0 0
45890 - 6 6 6 14 14 14 38 38 38 82 82 82
45891 - 34 34 34 2 2 6 2 2 6 2 2 6
45892 - 42 42 42 195 195 195 246 246 246 253 253 253
45893 -253 253 253 253 253 253 253 253 253 250 250 250
45894 -242 242 242 242 242 242 250 250 250 253 253 253
45895 -253 253 253 253 253 253 253 253 253 253 253 253
45896 -253 253 253 250 250 250 246 246 246 238 238 238
45897 -226 226 226 231 231 231 101 101 101 6 6 6
45898 - 2 2 6 2 2 6 2 2 6 2 2 6
45899 - 2 2 6 2 2 6 2 2 6 2 2 6
45900 - 38 38 38 82 82 82 42 42 42 14 14 14
45901 - 6 6 6 0 0 0 0 0 0 0 0 0
45902 - 0 0 0 0 0 0 0 0 0 0 0 0
45903 - 0 0 0 0 0 0 0 0 0 0 0 0
45904 - 0 0 0 0 0 0 0 0 0 0 0 0
45905 - 0 0 0 0 0 0 0 0 0 0 0 0
45906 - 0 0 0 0 0 0 0 0 0 0 0 0
45907 - 0 0 0 0 0 0 0 0 0 0 0 0
45908 - 0 0 0 0 0 0 0 0 0 0 0 0
45909 - 0 0 0 0 0 0 0 0 0 0 0 0
45910 - 10 10 10 26 26 26 62 62 62 66 66 66
45911 - 2 2 6 2 2 6 2 2 6 6 6 6
45912 - 70 70 70 170 170 170 206 206 206 234 234 234
45913 -246 246 246 250 250 250 250 250 250 238 238 238
45914 -226 226 226 231 231 231 238 238 238 250 250 250
45915 -250 250 250 250 250 250 246 246 246 231 231 231
45916 -214 214 214 206 206 206 202 202 202 202 202 202
45917 -198 198 198 202 202 202 182 182 182 18 18 18
45918 - 2 2 6 2 2 6 2 2 6 2 2 6
45919 - 2 2 6 2 2 6 2 2 6 2 2 6
45920 - 2 2 6 62 62 62 66 66 66 30 30 30
45921 - 10 10 10 0 0 0 0 0 0 0 0 0
45922 - 0 0 0 0 0 0 0 0 0 0 0 0
45923 - 0 0 0 0 0 0 0 0 0 0 0 0
45924 - 0 0 0 0 0 0 0 0 0 0 0 0
45925 - 0 0 0 0 0 0 0 0 0 0 0 0
45926 - 0 0 0 0 0 0 0 0 0 0 0 0
45927 - 0 0 0 0 0 0 0 0 0 0 0 0
45928 - 0 0 0 0 0 0 0 0 0 0 0 0
45929 - 0 0 0 0 0 0 0 0 0 0 0 0
45930 - 14 14 14 42 42 42 82 82 82 18 18 18
45931 - 2 2 6 2 2 6 2 2 6 10 10 10
45932 - 94 94 94 182 182 182 218 218 218 242 242 242
45933 -250 250 250 253 253 253 253 253 253 250 250 250
45934 -234 234 234 253 253 253 253 253 253 253 253 253
45935 -253 253 253 253 253 253 253 253 253 246 246 246
45936 -238 238 238 226 226 226 210 210 210 202 202 202
45937 -195 195 195 195 195 195 210 210 210 158 158 158
45938 - 6 6 6 14 14 14 50 50 50 14 14 14
45939 - 2 2 6 2 2 6 2 2 6 2 2 6
45940 - 2 2 6 6 6 6 86 86 86 46 46 46
45941 - 18 18 18 6 6 6 0 0 0 0 0 0
45942 - 0 0 0 0 0 0 0 0 0 0 0 0
45943 - 0 0 0 0 0 0 0 0 0 0 0 0
45944 - 0 0 0 0 0 0 0 0 0 0 0 0
45945 - 0 0 0 0 0 0 0 0 0 0 0 0
45946 - 0 0 0 0 0 0 0 0 0 0 0 0
45947 - 0 0 0 0 0 0 0 0 0 0 0 0
45948 - 0 0 0 0 0 0 0 0 0 0 0 0
45949 - 0 0 0 0 0 0 0 0 0 6 6 6
45950 - 22 22 22 54 54 54 70 70 70 2 2 6
45951 - 2 2 6 10 10 10 2 2 6 22 22 22
45952 -166 166 166 231 231 231 250 250 250 253 253 253
45953 -253 253 253 253 253 253 253 253 253 250 250 250
45954 -242 242 242 253 253 253 253 253 253 253 253 253
45955 -253 253 253 253 253 253 253 253 253 253 253 253
45956 -253 253 253 253 253 253 253 253 253 246 246 246
45957 -231 231 231 206 206 206 198 198 198 226 226 226
45958 - 94 94 94 2 2 6 6 6 6 38 38 38
45959 - 30 30 30 2 2 6 2 2 6 2 2 6
45960 - 2 2 6 2 2 6 62 62 62 66 66 66
45961 - 26 26 26 10 10 10 0 0 0 0 0 0
45962 - 0 0 0 0 0 0 0 0 0 0 0 0
45963 - 0 0 0 0 0 0 0 0 0 0 0 0
45964 - 0 0 0 0 0 0 0 0 0 0 0 0
45965 - 0 0 0 0 0 0 0 0 0 0 0 0
45966 - 0 0 0 0 0 0 0 0 0 0 0 0
45967 - 0 0 0 0 0 0 0 0 0 0 0 0
45968 - 0 0 0 0 0 0 0 0 0 0 0 0
45969 - 0 0 0 0 0 0 0 0 0 10 10 10
45970 - 30 30 30 74 74 74 50 50 50 2 2 6
45971 - 26 26 26 26 26 26 2 2 6 106 106 106
45972 -238 238 238 253 253 253 253 253 253 253 253 253
45973 -253 253 253 253 253 253 253 253 253 253 253 253
45974 -253 253 253 253 253 253 253 253 253 253 253 253
45975 -253 253 253 253 253 253 253 253 253 253 253 253
45976 -253 253 253 253 253 253 253 253 253 253 253 253
45977 -253 253 253 246 246 246 218 218 218 202 202 202
45978 -210 210 210 14 14 14 2 2 6 2 2 6
45979 - 30 30 30 22 22 22 2 2 6 2 2 6
45980 - 2 2 6 2 2 6 18 18 18 86 86 86
45981 - 42 42 42 14 14 14 0 0 0 0 0 0
45982 - 0 0 0 0 0 0 0 0 0 0 0 0
45983 - 0 0 0 0 0 0 0 0 0 0 0 0
45984 - 0 0 0 0 0 0 0 0 0 0 0 0
45985 - 0 0 0 0 0 0 0 0 0 0 0 0
45986 - 0 0 0 0 0 0 0 0 0 0 0 0
45987 - 0 0 0 0 0 0 0 0 0 0 0 0
45988 - 0 0 0 0 0 0 0 0 0 0 0 0
45989 - 0 0 0 0 0 0 0 0 0 14 14 14
45990 - 42 42 42 90 90 90 22 22 22 2 2 6
45991 - 42 42 42 2 2 6 18 18 18 218 218 218
45992 -253 253 253 253 253 253 253 253 253 253 253 253
45993 -253 253 253 253 253 253 253 253 253 253 253 253
45994 -253 253 253 253 253 253 253 253 253 253 253 253
45995 -253 253 253 253 253 253 253 253 253 253 253 253
45996 -253 253 253 253 253 253 253 253 253 253 253 253
45997 -253 253 253 253 253 253 250 250 250 221 221 221
45998 -218 218 218 101 101 101 2 2 6 14 14 14
45999 - 18 18 18 38 38 38 10 10 10 2 2 6
46000 - 2 2 6 2 2 6 2 2 6 78 78 78
46001 - 58 58 58 22 22 22 6 6 6 0 0 0
46002 - 0 0 0 0 0 0 0 0 0 0 0 0
46003 - 0 0 0 0 0 0 0 0 0 0 0 0
46004 - 0 0 0 0 0 0 0 0 0 0 0 0
46005 - 0 0 0 0 0 0 0 0 0 0 0 0
46006 - 0 0 0 0 0 0 0 0 0 0 0 0
46007 - 0 0 0 0 0 0 0 0 0 0 0 0
46008 - 0 0 0 0 0 0 0 0 0 0 0 0
46009 - 0 0 0 0 0 0 6 6 6 18 18 18
46010 - 54 54 54 82 82 82 2 2 6 26 26 26
46011 - 22 22 22 2 2 6 123 123 123 253 253 253
46012 -253 253 253 253 253 253 253 253 253 253 253 253
46013 -253 253 253 253 253 253 253 253 253 253 253 253
46014 -253 253 253 253 253 253 253 253 253 253 253 253
46015 -253 253 253 253 253 253 253 253 253 253 253 253
46016 -253 253 253 253 253 253 253 253 253 253 253 253
46017 -253 253 253 253 253 253 253 253 253 250 250 250
46018 -238 238 238 198 198 198 6 6 6 38 38 38
46019 - 58 58 58 26 26 26 38 38 38 2 2 6
46020 - 2 2 6 2 2 6 2 2 6 46 46 46
46021 - 78 78 78 30 30 30 10 10 10 0 0 0
46022 - 0 0 0 0 0 0 0 0 0 0 0 0
46023 - 0 0 0 0 0 0 0 0 0 0 0 0
46024 - 0 0 0 0 0 0 0 0 0 0 0 0
46025 - 0 0 0 0 0 0 0 0 0 0 0 0
46026 - 0 0 0 0 0 0 0 0 0 0 0 0
46027 - 0 0 0 0 0 0 0 0 0 0 0 0
46028 - 0 0 0 0 0 0 0 0 0 0 0 0
46029 - 0 0 0 0 0 0 10 10 10 30 30 30
46030 - 74 74 74 58 58 58 2 2 6 42 42 42
46031 - 2 2 6 22 22 22 231 231 231 253 253 253
46032 -253 253 253 253 253 253 253 253 253 253 253 253
46033 -253 253 253 253 253 253 253 253 253 250 250 250
46034 -253 253 253 253 253 253 253 253 253 253 253 253
46035 -253 253 253 253 253 253 253 253 253 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 253 253 253
46038 -253 253 253 246 246 246 46 46 46 38 38 38
46039 - 42 42 42 14 14 14 38 38 38 14 14 14
46040 - 2 2 6 2 2 6 2 2 6 6 6 6
46041 - 86 86 86 46 46 46 14 14 14 0 0 0
46042 - 0 0 0 0 0 0 0 0 0 0 0 0
46043 - 0 0 0 0 0 0 0 0 0 0 0 0
46044 - 0 0 0 0 0 0 0 0 0 0 0 0
46045 - 0 0 0 0 0 0 0 0 0 0 0 0
46046 - 0 0 0 0 0 0 0 0 0 0 0 0
46047 - 0 0 0 0 0 0 0 0 0 0 0 0
46048 - 0 0 0 0 0 0 0 0 0 0 0 0
46049 - 0 0 0 6 6 6 14 14 14 42 42 42
46050 - 90 90 90 18 18 18 18 18 18 26 26 26
46051 - 2 2 6 116 116 116 253 253 253 253 253 253
46052 -253 253 253 253 253 253 253 253 253 253 253 253
46053 -253 253 253 253 253 253 250 250 250 238 238 238
46054 -253 253 253 253 253 253 253 253 253 253 253 253
46055 -253 253 253 253 253 253 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 253 253 253 253 253 253
46058 -253 253 253 253 253 253 94 94 94 6 6 6
46059 - 2 2 6 2 2 6 10 10 10 34 34 34
46060 - 2 2 6 2 2 6 2 2 6 2 2 6
46061 - 74 74 74 58 58 58 22 22 22 6 6 6
46062 - 0 0 0 0 0 0 0 0 0 0 0 0
46063 - 0 0 0 0 0 0 0 0 0 0 0 0
46064 - 0 0 0 0 0 0 0 0 0 0 0 0
46065 - 0 0 0 0 0 0 0 0 0 0 0 0
46066 - 0 0 0 0 0 0 0 0 0 0 0 0
46067 - 0 0 0 0 0 0 0 0 0 0 0 0
46068 - 0 0 0 0 0 0 0 0 0 0 0 0
46069 - 0 0 0 10 10 10 26 26 26 66 66 66
46070 - 82 82 82 2 2 6 38 38 38 6 6 6
46071 - 14 14 14 210 210 210 253 253 253 253 253 253
46072 -253 253 253 253 253 253 253 253 253 253 253 253
46073 -253 253 253 253 253 253 246 246 246 242 242 242
46074 -253 253 253 253 253 253 253 253 253 253 253 253
46075 -253 253 253 253 253 253 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 253 253 253 253 253 253
46078 -253 253 253 253 253 253 144 144 144 2 2 6
46079 - 2 2 6 2 2 6 2 2 6 46 46 46
46080 - 2 2 6 2 2 6 2 2 6 2 2 6
46081 - 42 42 42 74 74 74 30 30 30 10 10 10
46082 - 0 0 0 0 0 0 0 0 0 0 0 0
46083 - 0 0 0 0 0 0 0 0 0 0 0 0
46084 - 0 0 0 0 0 0 0 0 0 0 0 0
46085 - 0 0 0 0 0 0 0 0 0 0 0 0
46086 - 0 0 0 0 0 0 0 0 0 0 0 0
46087 - 0 0 0 0 0 0 0 0 0 0 0 0
46088 - 0 0 0 0 0 0 0 0 0 0 0 0
46089 - 6 6 6 14 14 14 42 42 42 90 90 90
46090 - 26 26 26 6 6 6 42 42 42 2 2 6
46091 - 74 74 74 250 250 250 253 253 253 253 253 253
46092 -253 253 253 253 253 253 253 253 253 253 253 253
46093 -253 253 253 253 253 253 242 242 242 242 242 242
46094 -253 253 253 253 253 253 253 253 253 253 253 253
46095 -253 253 253 253 253 253 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 253 253 253 253 253 253
46098 -253 253 253 253 253 253 182 182 182 2 2 6
46099 - 2 2 6 2 2 6 2 2 6 46 46 46
46100 - 2 2 6 2 2 6 2 2 6 2 2 6
46101 - 10 10 10 86 86 86 38 38 38 10 10 10
46102 - 0 0 0 0 0 0 0 0 0 0 0 0
46103 - 0 0 0 0 0 0 0 0 0 0 0 0
46104 - 0 0 0 0 0 0 0 0 0 0 0 0
46105 - 0 0 0 0 0 0 0 0 0 0 0 0
46106 - 0 0 0 0 0 0 0 0 0 0 0 0
46107 - 0 0 0 0 0 0 0 0 0 0 0 0
46108 - 0 0 0 0 0 0 0 0 0 0 0 0
46109 - 10 10 10 26 26 26 66 66 66 82 82 82
46110 - 2 2 6 22 22 22 18 18 18 2 2 6
46111 -149 149 149 253 253 253 253 253 253 253 253 253
46112 -253 253 253 253 253 253 253 253 253 253 253 253
46113 -253 253 253 253 253 253 234 234 234 242 242 242
46114 -253 253 253 253 253 253 253 253 253 253 253 253
46115 -253 253 253 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 253 253 253 253 253 253
46118 -253 253 253 253 253 253 206 206 206 2 2 6
46119 - 2 2 6 2 2 6 2 2 6 38 38 38
46120 - 2 2 6 2 2 6 2 2 6 2 2 6
46121 - 6 6 6 86 86 86 46 46 46 14 14 14
46122 - 0 0 0 0 0 0 0 0 0 0 0 0
46123 - 0 0 0 0 0 0 0 0 0 0 0 0
46124 - 0 0 0 0 0 0 0 0 0 0 0 0
46125 - 0 0 0 0 0 0 0 0 0 0 0 0
46126 - 0 0 0 0 0 0 0 0 0 0 0 0
46127 - 0 0 0 0 0 0 0 0 0 0 0 0
46128 - 0 0 0 0 0 0 0 0 0 6 6 6
46129 - 18 18 18 46 46 46 86 86 86 18 18 18
46130 - 2 2 6 34 34 34 10 10 10 6 6 6
46131 -210 210 210 253 253 253 253 253 253 253 253 253
46132 -253 253 253 253 253 253 253 253 253 253 253 253
46133 -253 253 253 253 253 253 234 234 234 242 242 242
46134 -253 253 253 253 253 253 253 253 253 253 253 253
46135 -253 253 253 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 253 253 253 253 253 253
46138 -253 253 253 253 253 253 221 221 221 6 6 6
46139 - 2 2 6 2 2 6 6 6 6 30 30 30
46140 - 2 2 6 2 2 6 2 2 6 2 2 6
46141 - 2 2 6 82 82 82 54 54 54 18 18 18
46142 - 6 6 6 0 0 0 0 0 0 0 0 0
46143 - 0 0 0 0 0 0 0 0 0 0 0 0
46144 - 0 0 0 0 0 0 0 0 0 0 0 0
46145 - 0 0 0 0 0 0 0 0 0 0 0 0
46146 - 0 0 0 0 0 0 0 0 0 0 0 0
46147 - 0 0 0 0 0 0 0 0 0 0 0 0
46148 - 0 0 0 0 0 0 0 0 0 10 10 10
46149 - 26 26 26 66 66 66 62 62 62 2 2 6
46150 - 2 2 6 38 38 38 10 10 10 26 26 26
46151 -238 238 238 253 253 253 253 253 253 253 253 253
46152 -253 253 253 253 253 253 253 253 253 253 253 253
46153 -253 253 253 253 253 253 231 231 231 238 238 238
46154 -253 253 253 253 253 253 253 253 253 253 253 253
46155 -253 253 253 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 253 253 253 253 253 253
46158 -253 253 253 253 253 253 231 231 231 6 6 6
46159 - 2 2 6 2 2 6 10 10 10 30 30 30
46160 - 2 2 6 2 2 6 2 2 6 2 2 6
46161 - 2 2 6 66 66 66 58 58 58 22 22 22
46162 - 6 6 6 0 0 0 0 0 0 0 0 0
46163 - 0 0 0 0 0 0 0 0 0 0 0 0
46164 - 0 0 0 0 0 0 0 0 0 0 0 0
46165 - 0 0 0 0 0 0 0 0 0 0 0 0
46166 - 0 0 0 0 0 0 0 0 0 0 0 0
46167 - 0 0 0 0 0 0 0 0 0 0 0 0
46168 - 0 0 0 0 0 0 0 0 0 10 10 10
46169 - 38 38 38 78 78 78 6 6 6 2 2 6
46170 - 2 2 6 46 46 46 14 14 14 42 42 42
46171 -246 246 246 253 253 253 253 253 253 253 253 253
46172 -253 253 253 253 253 253 253 253 253 253 253 253
46173 -253 253 253 253 253 253 231 231 231 242 242 242
46174 -253 253 253 253 253 253 253 253 253 253 253 253
46175 -253 253 253 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 253 253 253 253 253 253
46178 -253 253 253 253 253 253 234 234 234 10 10 10
46179 - 2 2 6 2 2 6 22 22 22 14 14 14
46180 - 2 2 6 2 2 6 2 2 6 2 2 6
46181 - 2 2 6 66 66 66 62 62 62 22 22 22
46182 - 6 6 6 0 0 0 0 0 0 0 0 0
46183 - 0 0 0 0 0 0 0 0 0 0 0 0
46184 - 0 0 0 0 0 0 0 0 0 0 0 0
46185 - 0 0 0 0 0 0 0 0 0 0 0 0
46186 - 0 0 0 0 0 0 0 0 0 0 0 0
46187 - 0 0 0 0 0 0 0 0 0 0 0 0
46188 - 0 0 0 0 0 0 6 6 6 18 18 18
46189 - 50 50 50 74 74 74 2 2 6 2 2 6
46190 - 14 14 14 70 70 70 34 34 34 62 62 62
46191 -250 250 250 253 253 253 253 253 253 253 253 253
46192 -253 253 253 253 253 253 253 253 253 253 253 253
46193 -253 253 253 253 253 253 231 231 231 246 246 246
46194 -253 253 253 253 253 253 253 253 253 253 253 253
46195 -253 253 253 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 253 253 253 253 253 253
46198 -253 253 253 253 253 253 234 234 234 14 14 14
46199 - 2 2 6 2 2 6 30 30 30 2 2 6
46200 - 2 2 6 2 2 6 2 2 6 2 2 6
46201 - 2 2 6 66 66 66 62 62 62 22 22 22
46202 - 6 6 6 0 0 0 0 0 0 0 0 0
46203 - 0 0 0 0 0 0 0 0 0 0 0 0
46204 - 0 0 0 0 0 0 0 0 0 0 0 0
46205 - 0 0 0 0 0 0 0 0 0 0 0 0
46206 - 0 0 0 0 0 0 0 0 0 0 0 0
46207 - 0 0 0 0 0 0 0 0 0 0 0 0
46208 - 0 0 0 0 0 0 6 6 6 18 18 18
46209 - 54 54 54 62 62 62 2 2 6 2 2 6
46210 - 2 2 6 30 30 30 46 46 46 70 70 70
46211 -250 250 250 253 253 253 253 253 253 253 253 253
46212 -253 253 253 253 253 253 253 253 253 253 253 253
46213 -253 253 253 253 253 253 231 231 231 246 246 246
46214 -253 253 253 253 253 253 253 253 253 253 253 253
46215 -253 253 253 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 253 253 253 253 253 253
46218 -253 253 253 253 253 253 226 226 226 10 10 10
46219 - 2 2 6 6 6 6 30 30 30 2 2 6
46220 - 2 2 6 2 2 6 2 2 6 2 2 6
46221 - 2 2 6 66 66 66 58 58 58 22 22 22
46222 - 6 6 6 0 0 0 0 0 0 0 0 0
46223 - 0 0 0 0 0 0 0 0 0 0 0 0
46224 - 0 0 0 0 0 0 0 0 0 0 0 0
46225 - 0 0 0 0 0 0 0 0 0 0 0 0
46226 - 0 0 0 0 0 0 0 0 0 0 0 0
46227 - 0 0 0 0 0 0 0 0 0 0 0 0
46228 - 0 0 0 0 0 0 6 6 6 22 22 22
46229 - 58 58 58 62 62 62 2 2 6 2 2 6
46230 - 2 2 6 2 2 6 30 30 30 78 78 78
46231 -250 250 250 253 253 253 253 253 253 253 253 253
46232 -253 253 253 253 253 253 253 253 253 253 253 253
46233 -253 253 253 253 253 253 231 231 231 246 246 246
46234 -253 253 253 253 253 253 253 253 253 253 253 253
46235 -253 253 253 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 253 253 253 253 253 253
46238 -253 253 253 253 253 253 206 206 206 2 2 6
46239 - 22 22 22 34 34 34 18 14 6 22 22 22
46240 - 26 26 26 18 18 18 6 6 6 2 2 6
46241 - 2 2 6 82 82 82 54 54 54 18 18 18
46242 - 6 6 6 0 0 0 0 0 0 0 0 0
46243 - 0 0 0 0 0 0 0 0 0 0 0 0
46244 - 0 0 0 0 0 0 0 0 0 0 0 0
46245 - 0 0 0 0 0 0 0 0 0 0 0 0
46246 - 0 0 0 0 0 0 0 0 0 0 0 0
46247 - 0 0 0 0 0 0 0 0 0 0 0 0
46248 - 0 0 0 0 0 0 6 6 6 26 26 26
46249 - 62 62 62 106 106 106 74 54 14 185 133 11
46250 -210 162 10 121 92 8 6 6 6 62 62 62
46251 -238 238 238 253 253 253 253 253 253 253 253 253
46252 -253 253 253 253 253 253 253 253 253 253 253 253
46253 -253 253 253 253 253 253 231 231 231 246 246 246
46254 -253 253 253 253 253 253 253 253 253 253 253 253
46255 -253 253 253 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 253 253 253 253 253 253
46258 -253 253 253 253 253 253 158 158 158 18 18 18
46259 - 14 14 14 2 2 6 2 2 6 2 2 6
46260 - 6 6 6 18 18 18 66 66 66 38 38 38
46261 - 6 6 6 94 94 94 50 50 50 18 18 18
46262 - 6 6 6 0 0 0 0 0 0 0 0 0
46263 - 0 0 0 0 0 0 0 0 0 0 0 0
46264 - 0 0 0 0 0 0 0 0 0 0 0 0
46265 - 0 0 0 0 0 0 0 0 0 0 0 0
46266 - 0 0 0 0 0 0 0 0 0 0 0 0
46267 - 0 0 0 0 0 0 0 0 0 6 6 6
46268 - 10 10 10 10 10 10 18 18 18 38 38 38
46269 - 78 78 78 142 134 106 216 158 10 242 186 14
46270 -246 190 14 246 190 14 156 118 10 10 10 10
46271 - 90 90 90 238 238 238 253 253 253 253 253 253
46272 -253 253 253 253 253 253 253 253 253 253 253 253
46273 -253 253 253 253 253 253 231 231 231 250 250 250
46274 -253 253 253 253 253 253 253 253 253 253 253 253
46275 -253 253 253 253 253 253 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 253 253 253 246 230 190
46278 -238 204 91 238 204 91 181 142 44 37 26 9
46279 - 2 2 6 2 2 6 2 2 6 2 2 6
46280 - 2 2 6 2 2 6 38 38 38 46 46 46
46281 - 26 26 26 106 106 106 54 54 54 18 18 18
46282 - 6 6 6 0 0 0 0 0 0 0 0 0
46283 - 0 0 0 0 0 0 0 0 0 0 0 0
46284 - 0 0 0 0 0 0 0 0 0 0 0 0
46285 - 0 0 0 0 0 0 0 0 0 0 0 0
46286 - 0 0 0 0 0 0 0 0 0 0 0 0
46287 - 0 0 0 6 6 6 14 14 14 22 22 22
46288 - 30 30 30 38 38 38 50 50 50 70 70 70
46289 -106 106 106 190 142 34 226 170 11 242 186 14
46290 -246 190 14 246 190 14 246 190 14 154 114 10
46291 - 6 6 6 74 74 74 226 226 226 253 253 253
46292 -253 253 253 253 253 253 253 253 253 253 253 253
46293 -253 253 253 253 253 253 231 231 231 250 250 250
46294 -253 253 253 253 253 253 253 253 253 253 253 253
46295 -253 253 253 253 253 253 253 253 253 253 253 253
46296 -253 253 253 253 253 253 253 253 253 253 253 253
46297 -253 253 253 253 253 253 253 253 253 228 184 62
46298 -241 196 14 241 208 19 232 195 16 38 30 10
46299 - 2 2 6 2 2 6 2 2 6 2 2 6
46300 - 2 2 6 6 6 6 30 30 30 26 26 26
46301 -203 166 17 154 142 90 66 66 66 26 26 26
46302 - 6 6 6 0 0 0 0 0 0 0 0 0
46303 - 0 0 0 0 0 0 0 0 0 0 0 0
46304 - 0 0 0 0 0 0 0 0 0 0 0 0
46305 - 0 0 0 0 0 0 0 0 0 0 0 0
46306 - 0 0 0 0 0 0 0 0 0 0 0 0
46307 - 6 6 6 18 18 18 38 38 38 58 58 58
46308 - 78 78 78 86 86 86 101 101 101 123 123 123
46309 -175 146 61 210 150 10 234 174 13 246 186 14
46310 -246 190 14 246 190 14 246 190 14 238 190 10
46311 -102 78 10 2 2 6 46 46 46 198 198 198
46312 -253 253 253 253 253 253 253 253 253 253 253 253
46313 -253 253 253 253 253 253 234 234 234 242 242 242
46314 -253 253 253 253 253 253 253 253 253 253 253 253
46315 -253 253 253 253 253 253 253 253 253 253 253 253
46316 -253 253 253 253 253 253 253 253 253 253 253 253
46317 -253 253 253 253 253 253 253 253 253 224 178 62
46318 -242 186 14 241 196 14 210 166 10 22 18 6
46319 - 2 2 6 2 2 6 2 2 6 2 2 6
46320 - 2 2 6 2 2 6 6 6 6 121 92 8
46321 -238 202 15 232 195 16 82 82 82 34 34 34
46322 - 10 10 10 0 0 0 0 0 0 0 0 0
46323 - 0 0 0 0 0 0 0 0 0 0 0 0
46324 - 0 0 0 0 0 0 0 0 0 0 0 0
46325 - 0 0 0 0 0 0 0 0 0 0 0 0
46326 - 0 0 0 0 0 0 0 0 0 0 0 0
46327 - 14 14 14 38 38 38 70 70 70 154 122 46
46328 -190 142 34 200 144 11 197 138 11 197 138 11
46329 -213 154 11 226 170 11 242 186 14 246 190 14
46330 -246 190 14 246 190 14 246 190 14 246 190 14
46331 -225 175 15 46 32 6 2 2 6 22 22 22
46332 -158 158 158 250 250 250 253 253 253 253 253 253
46333 -253 253 253 253 253 253 253 253 253 253 253 253
46334 -253 253 253 253 253 253 253 253 253 253 253 253
46335 -253 253 253 253 253 253 253 253 253 253 253 253
46336 -253 253 253 253 253 253 253 253 253 253 253 253
46337 -253 253 253 250 250 250 242 242 242 224 178 62
46338 -239 182 13 236 186 11 213 154 11 46 32 6
46339 - 2 2 6 2 2 6 2 2 6 2 2 6
46340 - 2 2 6 2 2 6 61 42 6 225 175 15
46341 -238 190 10 236 186 11 112 100 78 42 42 42
46342 - 14 14 14 0 0 0 0 0 0 0 0 0
46343 - 0 0 0 0 0 0 0 0 0 0 0 0
46344 - 0 0 0 0 0 0 0 0 0 0 0 0
46345 - 0 0 0 0 0 0 0 0 0 0 0 0
46346 - 0 0 0 0 0 0 0 0 0 6 6 6
46347 - 22 22 22 54 54 54 154 122 46 213 154 11
46348 -226 170 11 230 174 11 226 170 11 226 170 11
46349 -236 178 12 242 186 14 246 190 14 246 190 14
46350 -246 190 14 246 190 14 246 190 14 246 190 14
46351 -241 196 14 184 144 12 10 10 10 2 2 6
46352 - 6 6 6 116 116 116 242 242 242 253 253 253
46353 -253 253 253 253 253 253 253 253 253 253 253 253
46354 -253 253 253 253 253 253 253 253 253 253 253 253
46355 -253 253 253 253 253 253 253 253 253 253 253 253
46356 -253 253 253 253 253 253 253 253 253 253 253 253
46357 -253 253 253 231 231 231 198 198 198 214 170 54
46358 -236 178 12 236 178 12 210 150 10 137 92 6
46359 - 18 14 6 2 2 6 2 2 6 2 2 6
46360 - 6 6 6 70 47 6 200 144 11 236 178 12
46361 -239 182 13 239 182 13 124 112 88 58 58 58
46362 - 22 22 22 6 6 6 0 0 0 0 0 0
46363 - 0 0 0 0 0 0 0 0 0 0 0 0
46364 - 0 0 0 0 0 0 0 0 0 0 0 0
46365 - 0 0 0 0 0 0 0 0 0 0 0 0
46366 - 0 0 0 0 0 0 0 0 0 10 10 10
46367 - 30 30 30 70 70 70 180 133 36 226 170 11
46368 -239 182 13 242 186 14 242 186 14 246 186 14
46369 -246 190 14 246 190 14 246 190 14 246 190 14
46370 -246 190 14 246 190 14 246 190 14 246 190 14
46371 -246 190 14 232 195 16 98 70 6 2 2 6
46372 - 2 2 6 2 2 6 66 66 66 221 221 221
46373 -253 253 253 253 253 253 253 253 253 253 253 253
46374 -253 253 253 253 253 253 253 253 253 253 253 253
46375 -253 253 253 253 253 253 253 253 253 253 253 253
46376 -253 253 253 253 253 253 253 253 253 253 253 253
46377 -253 253 253 206 206 206 198 198 198 214 166 58
46378 -230 174 11 230 174 11 216 158 10 192 133 9
46379 -163 110 8 116 81 8 102 78 10 116 81 8
46380 -167 114 7 197 138 11 226 170 11 239 182 13
46381 -242 186 14 242 186 14 162 146 94 78 78 78
46382 - 34 34 34 14 14 14 6 6 6 0 0 0
46383 - 0 0 0 0 0 0 0 0 0 0 0 0
46384 - 0 0 0 0 0 0 0 0 0 0 0 0
46385 - 0 0 0 0 0 0 0 0 0 0 0 0
46386 - 0 0 0 0 0 0 0 0 0 6 6 6
46387 - 30 30 30 78 78 78 190 142 34 226 170 11
46388 -239 182 13 246 190 14 246 190 14 246 190 14
46389 -246 190 14 246 190 14 246 190 14 246 190 14
46390 -246 190 14 246 190 14 246 190 14 246 190 14
46391 -246 190 14 241 196 14 203 166 17 22 18 6
46392 - 2 2 6 2 2 6 2 2 6 38 38 38
46393 -218 218 218 253 253 253 253 253 253 253 253 253
46394 -253 253 253 253 253 253 253 253 253 253 253 253
46395 -253 253 253 253 253 253 253 253 253 253 253 253
46396 -253 253 253 253 253 253 253 253 253 253 253 253
46397 -250 250 250 206 206 206 198 198 198 202 162 69
46398 -226 170 11 236 178 12 224 166 10 210 150 10
46399 -200 144 11 197 138 11 192 133 9 197 138 11
46400 -210 150 10 226 170 11 242 186 14 246 190 14
46401 -246 190 14 246 186 14 225 175 15 124 112 88
46402 - 62 62 62 30 30 30 14 14 14 6 6 6
46403 - 0 0 0 0 0 0 0 0 0 0 0 0
46404 - 0 0 0 0 0 0 0 0 0 0 0 0
46405 - 0 0 0 0 0 0 0 0 0 0 0 0
46406 - 0 0 0 0 0 0 0 0 0 10 10 10
46407 - 30 30 30 78 78 78 174 135 50 224 166 10
46408 -239 182 13 246 190 14 246 190 14 246 190 14
46409 -246 190 14 246 190 14 246 190 14 246 190 14
46410 -246 190 14 246 190 14 246 190 14 246 190 14
46411 -246 190 14 246 190 14 241 196 14 139 102 15
46412 - 2 2 6 2 2 6 2 2 6 2 2 6
46413 - 78 78 78 250 250 250 253 253 253 253 253 253
46414 -253 253 253 253 253 253 253 253 253 253 253 253
46415 -253 253 253 253 253 253 253 253 253 253 253 253
46416 -253 253 253 253 253 253 253 253 253 253 253 253
46417 -250 250 250 214 214 214 198 198 198 190 150 46
46418 -219 162 10 236 178 12 234 174 13 224 166 10
46419 -216 158 10 213 154 11 213 154 11 216 158 10
46420 -226 170 11 239 182 13 246 190 14 246 190 14
46421 -246 190 14 246 190 14 242 186 14 206 162 42
46422 -101 101 101 58 58 58 30 30 30 14 14 14
46423 - 6 6 6 0 0 0 0 0 0 0 0 0
46424 - 0 0 0 0 0 0 0 0 0 0 0 0
46425 - 0 0 0 0 0 0 0 0 0 0 0 0
46426 - 0 0 0 0 0 0 0 0 0 10 10 10
46427 - 30 30 30 74 74 74 174 135 50 216 158 10
46428 -236 178 12 246 190 14 246 190 14 246 190 14
46429 -246 190 14 246 190 14 246 190 14 246 190 14
46430 -246 190 14 246 190 14 246 190 14 246 190 14
46431 -246 190 14 246 190 14 241 196 14 226 184 13
46432 - 61 42 6 2 2 6 2 2 6 2 2 6
46433 - 22 22 22 238 238 238 253 253 253 253 253 253
46434 -253 253 253 253 253 253 253 253 253 253 253 253
46435 -253 253 253 253 253 253 253 253 253 253 253 253
46436 -253 253 253 253 253 253 253 253 253 253 253 253
46437 -253 253 253 226 226 226 187 187 187 180 133 36
46438 -216 158 10 236 178 12 239 182 13 236 178 12
46439 -230 174 11 226 170 11 226 170 11 230 174 11
46440 -236 178 12 242 186 14 246 190 14 246 190 14
46441 -246 190 14 246 190 14 246 186 14 239 182 13
46442 -206 162 42 106 106 106 66 66 66 34 34 34
46443 - 14 14 14 6 6 6 0 0 0 0 0 0
46444 - 0 0 0 0 0 0 0 0 0 0 0 0
46445 - 0 0 0 0 0 0 0 0 0 0 0 0
46446 - 0 0 0 0 0 0 0 0 0 6 6 6
46447 - 26 26 26 70 70 70 163 133 67 213 154 11
46448 -236 178 12 246 190 14 246 190 14 246 190 14
46449 -246 190 14 246 190 14 246 190 14 246 190 14
46450 -246 190 14 246 190 14 246 190 14 246 190 14
46451 -246 190 14 246 190 14 246 190 14 241 196 14
46452 -190 146 13 18 14 6 2 2 6 2 2 6
46453 - 46 46 46 246 246 246 253 253 253 253 253 253
46454 -253 253 253 253 253 253 253 253 253 253 253 253
46455 -253 253 253 253 253 253 253 253 253 253 253 253
46456 -253 253 253 253 253 253 253 253 253 253 253 253
46457 -253 253 253 221 221 221 86 86 86 156 107 11
46458 -216 158 10 236 178 12 242 186 14 246 186 14
46459 -242 186 14 239 182 13 239 182 13 242 186 14
46460 -242 186 14 246 186 14 246 190 14 246 190 14
46461 -246 190 14 246 190 14 246 190 14 246 190 14
46462 -242 186 14 225 175 15 142 122 72 66 66 66
46463 - 30 30 30 10 10 10 0 0 0 0 0 0
46464 - 0 0 0 0 0 0 0 0 0 0 0 0
46465 - 0 0 0 0 0 0 0 0 0 0 0 0
46466 - 0 0 0 0 0 0 0 0 0 6 6 6
46467 - 26 26 26 70 70 70 163 133 67 210 150 10
46468 -236 178 12 246 190 14 246 190 14 246 190 14
46469 -246 190 14 246 190 14 246 190 14 246 190 14
46470 -246 190 14 246 190 14 246 190 14 246 190 14
46471 -246 190 14 246 190 14 246 190 14 246 190 14
46472 -232 195 16 121 92 8 34 34 34 106 106 106
46473 -221 221 221 253 253 253 253 253 253 253 253 253
46474 -253 253 253 253 253 253 253 253 253 253 253 253
46475 -253 253 253 253 253 253 253 253 253 253 253 253
46476 -253 253 253 253 253 253 253 253 253 253 253 253
46477 -242 242 242 82 82 82 18 14 6 163 110 8
46478 -216 158 10 236 178 12 242 186 14 246 190 14
46479 -246 190 14 246 190 14 246 190 14 246 190 14
46480 -246 190 14 246 190 14 246 190 14 246 190 14
46481 -246 190 14 246 190 14 246 190 14 246 190 14
46482 -246 190 14 246 190 14 242 186 14 163 133 67
46483 - 46 46 46 18 18 18 6 6 6 0 0 0
46484 - 0 0 0 0 0 0 0 0 0 0 0 0
46485 - 0 0 0 0 0 0 0 0 0 0 0 0
46486 - 0 0 0 0 0 0 0 0 0 10 10 10
46487 - 30 30 30 78 78 78 163 133 67 210 150 10
46488 -236 178 12 246 186 14 246 190 14 246 190 14
46489 -246 190 14 246 190 14 246 190 14 246 190 14
46490 -246 190 14 246 190 14 246 190 14 246 190 14
46491 -246 190 14 246 190 14 246 190 14 246 190 14
46492 -241 196 14 215 174 15 190 178 144 253 253 253
46493 -253 253 253 253 253 253 253 253 253 253 253 253
46494 -253 253 253 253 253 253 253 253 253 253 253 253
46495 -253 253 253 253 253 253 253 253 253 253 253 253
46496 -253 253 253 253 253 253 253 253 253 218 218 218
46497 - 58 58 58 2 2 6 22 18 6 167 114 7
46498 -216 158 10 236 178 12 246 186 14 246 190 14
46499 -246 190 14 246 190 14 246 190 14 246 190 14
46500 -246 190 14 246 190 14 246 190 14 246 190 14
46501 -246 190 14 246 190 14 246 190 14 246 190 14
46502 -246 190 14 246 186 14 242 186 14 190 150 46
46503 - 54 54 54 22 22 22 6 6 6 0 0 0
46504 - 0 0 0 0 0 0 0 0 0 0 0 0
46505 - 0 0 0 0 0 0 0 0 0 0 0 0
46506 - 0 0 0 0 0 0 0 0 0 14 14 14
46507 - 38 38 38 86 86 86 180 133 36 213 154 11
46508 -236 178 12 246 186 14 246 190 14 246 190 14
46509 -246 190 14 246 190 14 246 190 14 246 190 14
46510 -246 190 14 246 190 14 246 190 14 246 190 14
46511 -246 190 14 246 190 14 246 190 14 246 190 14
46512 -246 190 14 232 195 16 190 146 13 214 214 214
46513 -253 253 253 253 253 253 253 253 253 253 253 253
46514 -253 253 253 253 253 253 253 253 253 253 253 253
46515 -253 253 253 253 253 253 253 253 253 253 253 253
46516 -253 253 253 250 250 250 170 170 170 26 26 26
46517 - 2 2 6 2 2 6 37 26 9 163 110 8
46518 -219 162 10 239 182 13 246 186 14 246 190 14
46519 -246 190 14 246 190 14 246 190 14 246 190 14
46520 -246 190 14 246 190 14 246 190 14 246 190 14
46521 -246 190 14 246 190 14 246 190 14 246 190 14
46522 -246 186 14 236 178 12 224 166 10 142 122 72
46523 - 46 46 46 18 18 18 6 6 6 0 0 0
46524 - 0 0 0 0 0 0 0 0 0 0 0 0
46525 - 0 0 0 0 0 0 0 0 0 0 0 0
46526 - 0 0 0 0 0 0 6 6 6 18 18 18
46527 - 50 50 50 109 106 95 192 133 9 224 166 10
46528 -242 186 14 246 190 14 246 190 14 246 190 14
46529 -246 190 14 246 190 14 246 190 14 246 190 14
46530 -246 190 14 246 190 14 246 190 14 246 190 14
46531 -246 190 14 246 190 14 246 190 14 246 190 14
46532 -242 186 14 226 184 13 210 162 10 142 110 46
46533 -226 226 226 253 253 253 253 253 253 253 253 253
46534 -253 253 253 253 253 253 253 253 253 253 253 253
46535 -253 253 253 253 253 253 253 253 253 253 253 253
46536 -198 198 198 66 66 66 2 2 6 2 2 6
46537 - 2 2 6 2 2 6 50 34 6 156 107 11
46538 -219 162 10 239 182 13 246 186 14 246 190 14
46539 -246 190 14 246 190 14 246 190 14 246 190 14
46540 -246 190 14 246 190 14 246 190 14 246 190 14
46541 -246 190 14 246 190 14 246 190 14 242 186 14
46542 -234 174 13 213 154 11 154 122 46 66 66 66
46543 - 30 30 30 10 10 10 0 0 0 0 0 0
46544 - 0 0 0 0 0 0 0 0 0 0 0 0
46545 - 0 0 0 0 0 0 0 0 0 0 0 0
46546 - 0 0 0 0 0 0 6 6 6 22 22 22
46547 - 58 58 58 154 121 60 206 145 10 234 174 13
46548 -242 186 14 246 186 14 246 190 14 246 190 14
46549 -246 190 14 246 190 14 246 190 14 246 190 14
46550 -246 190 14 246 190 14 246 190 14 246 190 14
46551 -246 190 14 246 190 14 246 190 14 246 190 14
46552 -246 186 14 236 178 12 210 162 10 163 110 8
46553 - 61 42 6 138 138 138 218 218 218 250 250 250
46554 -253 253 253 253 253 253 253 253 253 250 250 250
46555 -242 242 242 210 210 210 144 144 144 66 66 66
46556 - 6 6 6 2 2 6 2 2 6 2 2 6
46557 - 2 2 6 2 2 6 61 42 6 163 110 8
46558 -216 158 10 236 178 12 246 190 14 246 190 14
46559 -246 190 14 246 190 14 246 190 14 246 190 14
46560 -246 190 14 246 190 14 246 190 14 246 190 14
46561 -246 190 14 239 182 13 230 174 11 216 158 10
46562 -190 142 34 124 112 88 70 70 70 38 38 38
46563 - 18 18 18 6 6 6 0 0 0 0 0 0
46564 - 0 0 0 0 0 0 0 0 0 0 0 0
46565 - 0 0 0 0 0 0 0 0 0 0 0 0
46566 - 0 0 0 0 0 0 6 6 6 22 22 22
46567 - 62 62 62 168 124 44 206 145 10 224 166 10
46568 -236 178 12 239 182 13 242 186 14 242 186 14
46569 -246 186 14 246 190 14 246 190 14 246 190 14
46570 -246 190 14 246 190 14 246 190 14 246 190 14
46571 -246 190 14 246 190 14 246 190 14 246 190 14
46572 -246 190 14 236 178 12 216 158 10 175 118 6
46573 - 80 54 7 2 2 6 6 6 6 30 30 30
46574 - 54 54 54 62 62 62 50 50 50 38 38 38
46575 - 14 14 14 2 2 6 2 2 6 2 2 6
46576 - 2 2 6 2 2 6 2 2 6 2 2 6
46577 - 2 2 6 6 6 6 80 54 7 167 114 7
46578 -213 154 11 236 178 12 246 190 14 246 190 14
46579 -246 190 14 246 190 14 246 190 14 246 190 14
46580 -246 190 14 242 186 14 239 182 13 239 182 13
46581 -230 174 11 210 150 10 174 135 50 124 112 88
46582 - 82 82 82 54 54 54 34 34 34 18 18 18
46583 - 6 6 6 0 0 0 0 0 0 0 0 0
46584 - 0 0 0 0 0 0 0 0 0 0 0 0
46585 - 0 0 0 0 0 0 0 0 0 0 0 0
46586 - 0 0 0 0 0 0 6 6 6 18 18 18
46587 - 50 50 50 158 118 36 192 133 9 200 144 11
46588 -216 158 10 219 162 10 224 166 10 226 170 11
46589 -230 174 11 236 178 12 239 182 13 239 182 13
46590 -242 186 14 246 186 14 246 190 14 246 190 14
46591 -246 190 14 246 190 14 246 190 14 246 190 14
46592 -246 186 14 230 174 11 210 150 10 163 110 8
46593 -104 69 6 10 10 10 2 2 6 2 2 6
46594 - 2 2 6 2 2 6 2 2 6 2 2 6
46595 - 2 2 6 2 2 6 2 2 6 2 2 6
46596 - 2 2 6 2 2 6 2 2 6 2 2 6
46597 - 2 2 6 6 6 6 91 60 6 167 114 7
46598 -206 145 10 230 174 11 242 186 14 246 190 14
46599 -246 190 14 246 190 14 246 186 14 242 186 14
46600 -239 182 13 230 174 11 224 166 10 213 154 11
46601 -180 133 36 124 112 88 86 86 86 58 58 58
46602 - 38 38 38 22 22 22 10 10 10 6 6 6
46603 - 0 0 0 0 0 0 0 0 0 0 0 0
46604 - 0 0 0 0 0 0 0 0 0 0 0 0
46605 - 0 0 0 0 0 0 0 0 0 0 0 0
46606 - 0 0 0 0 0 0 0 0 0 14 14 14
46607 - 34 34 34 70 70 70 138 110 50 158 118 36
46608 -167 114 7 180 123 7 192 133 9 197 138 11
46609 -200 144 11 206 145 10 213 154 11 219 162 10
46610 -224 166 10 230 174 11 239 182 13 242 186 14
46611 -246 186 14 246 186 14 246 186 14 246 186 14
46612 -239 182 13 216 158 10 185 133 11 152 99 6
46613 -104 69 6 18 14 6 2 2 6 2 2 6
46614 - 2 2 6 2 2 6 2 2 6 2 2 6
46615 - 2 2 6 2 2 6 2 2 6 2 2 6
46616 - 2 2 6 2 2 6 2 2 6 2 2 6
46617 - 2 2 6 6 6 6 80 54 7 152 99 6
46618 -192 133 9 219 162 10 236 178 12 239 182 13
46619 -246 186 14 242 186 14 239 182 13 236 178 12
46620 -224 166 10 206 145 10 192 133 9 154 121 60
46621 - 94 94 94 62 62 62 42 42 42 22 22 22
46622 - 14 14 14 6 6 6 0 0 0 0 0 0
46623 - 0 0 0 0 0 0 0 0 0 0 0 0
46624 - 0 0 0 0 0 0 0 0 0 0 0 0
46625 - 0 0 0 0 0 0 0 0 0 0 0 0
46626 - 0 0 0 0 0 0 0 0 0 6 6 6
46627 - 18 18 18 34 34 34 58 58 58 78 78 78
46628 -101 98 89 124 112 88 142 110 46 156 107 11
46629 -163 110 8 167 114 7 175 118 6 180 123 7
46630 -185 133 11 197 138 11 210 150 10 219 162 10
46631 -226 170 11 236 178 12 236 178 12 234 174 13
46632 -219 162 10 197 138 11 163 110 8 130 83 6
46633 - 91 60 6 10 10 10 2 2 6 2 2 6
46634 - 18 18 18 38 38 38 38 38 38 38 38 38
46635 - 38 38 38 38 38 38 38 38 38 38 38 38
46636 - 38 38 38 38 38 38 26 26 26 2 2 6
46637 - 2 2 6 6 6 6 70 47 6 137 92 6
46638 -175 118 6 200 144 11 219 162 10 230 174 11
46639 -234 174 13 230 174 11 219 162 10 210 150 10
46640 -192 133 9 163 110 8 124 112 88 82 82 82
46641 - 50 50 50 30 30 30 14 14 14 6 6 6
46642 - 0 0 0 0 0 0 0 0 0 0 0 0
46643 - 0 0 0 0 0 0 0 0 0 0 0 0
46644 - 0 0 0 0 0 0 0 0 0 0 0 0
46645 - 0 0 0 0 0 0 0 0 0 0 0 0
46646 - 0 0 0 0 0 0 0 0 0 0 0 0
46647 - 6 6 6 14 14 14 22 22 22 34 34 34
46648 - 42 42 42 58 58 58 74 74 74 86 86 86
46649 -101 98 89 122 102 70 130 98 46 121 87 25
46650 -137 92 6 152 99 6 163 110 8 180 123 7
46651 -185 133 11 197 138 11 206 145 10 200 144 11
46652 -180 123 7 156 107 11 130 83 6 104 69 6
46653 - 50 34 6 54 54 54 110 110 110 101 98 89
46654 - 86 86 86 82 82 82 78 78 78 78 78 78
46655 - 78 78 78 78 78 78 78 78 78 78 78 78
46656 - 78 78 78 82 82 82 86 86 86 94 94 94
46657 -106 106 106 101 101 101 86 66 34 124 80 6
46658 -156 107 11 180 123 7 192 133 9 200 144 11
46659 -206 145 10 200 144 11 192 133 9 175 118 6
46660 -139 102 15 109 106 95 70 70 70 42 42 42
46661 - 22 22 22 10 10 10 0 0 0 0 0 0
46662 - 0 0 0 0 0 0 0 0 0 0 0 0
46663 - 0 0 0 0 0 0 0 0 0 0 0 0
46664 - 0 0 0 0 0 0 0 0 0 0 0 0
46665 - 0 0 0 0 0 0 0 0 0 0 0 0
46666 - 0 0 0 0 0 0 0 0 0 0 0 0
46667 - 0 0 0 0 0 0 6 6 6 10 10 10
46668 - 14 14 14 22 22 22 30 30 30 38 38 38
46669 - 50 50 50 62 62 62 74 74 74 90 90 90
46670 -101 98 89 112 100 78 121 87 25 124 80 6
46671 -137 92 6 152 99 6 152 99 6 152 99 6
46672 -138 86 6 124 80 6 98 70 6 86 66 30
46673 -101 98 89 82 82 82 58 58 58 46 46 46
46674 - 38 38 38 34 34 34 34 34 34 34 34 34
46675 - 34 34 34 34 34 34 34 34 34 34 34 34
46676 - 34 34 34 34 34 34 38 38 38 42 42 42
46677 - 54 54 54 82 82 82 94 86 76 91 60 6
46678 -134 86 6 156 107 11 167 114 7 175 118 6
46679 -175 118 6 167 114 7 152 99 6 121 87 25
46680 -101 98 89 62 62 62 34 34 34 18 18 18
46681 - 6 6 6 0 0 0 0 0 0 0 0 0
46682 - 0 0 0 0 0 0 0 0 0 0 0 0
46683 - 0 0 0 0 0 0 0 0 0 0 0 0
46684 - 0 0 0 0 0 0 0 0 0 0 0 0
46685 - 0 0 0 0 0 0 0 0 0 0 0 0
46686 - 0 0 0 0 0 0 0 0 0 0 0 0
46687 - 0 0 0 0 0 0 0 0 0 0 0 0
46688 - 0 0 0 6 6 6 6 6 6 10 10 10
46689 - 18 18 18 22 22 22 30 30 30 42 42 42
46690 - 50 50 50 66 66 66 86 86 86 101 98 89
46691 -106 86 58 98 70 6 104 69 6 104 69 6
46692 -104 69 6 91 60 6 82 62 34 90 90 90
46693 - 62 62 62 38 38 38 22 22 22 14 14 14
46694 - 10 10 10 10 10 10 10 10 10 10 10 10
46695 - 10 10 10 10 10 10 6 6 6 10 10 10
46696 - 10 10 10 10 10 10 10 10 10 14 14 14
46697 - 22 22 22 42 42 42 70 70 70 89 81 66
46698 - 80 54 7 104 69 6 124 80 6 137 92 6
46699 -134 86 6 116 81 8 100 82 52 86 86 86
46700 - 58 58 58 30 30 30 14 14 14 6 6 6
46701 - 0 0 0 0 0 0 0 0 0 0 0 0
46702 - 0 0 0 0 0 0 0 0 0 0 0 0
46703 - 0 0 0 0 0 0 0 0 0 0 0 0
46704 - 0 0 0 0 0 0 0 0 0 0 0 0
46705 - 0 0 0 0 0 0 0 0 0 0 0 0
46706 - 0 0 0 0 0 0 0 0 0 0 0 0
46707 - 0 0 0 0 0 0 0 0 0 0 0 0
46708 - 0 0 0 0 0 0 0 0 0 0 0 0
46709 - 0 0 0 6 6 6 10 10 10 14 14 14
46710 - 18 18 18 26 26 26 38 38 38 54 54 54
46711 - 70 70 70 86 86 86 94 86 76 89 81 66
46712 - 89 81 66 86 86 86 74 74 74 50 50 50
46713 - 30 30 30 14 14 14 6 6 6 0 0 0
46714 - 0 0 0 0 0 0 0 0 0 0 0 0
46715 - 0 0 0 0 0 0 0 0 0 0 0 0
46716 - 0 0 0 0 0 0 0 0 0 0 0 0
46717 - 6 6 6 18 18 18 34 34 34 58 58 58
46718 - 82 82 82 89 81 66 89 81 66 89 81 66
46719 - 94 86 66 94 86 76 74 74 74 50 50 50
46720 - 26 26 26 14 14 14 6 6 6 0 0 0
46721 - 0 0 0 0 0 0 0 0 0 0 0 0
46722 - 0 0 0 0 0 0 0 0 0 0 0 0
46723 - 0 0 0 0 0 0 0 0 0 0 0 0
46724 - 0 0 0 0 0 0 0 0 0 0 0 0
46725 - 0 0 0 0 0 0 0 0 0 0 0 0
46726 - 0 0 0 0 0 0 0 0 0 0 0 0
46727 - 0 0 0 0 0 0 0 0 0 0 0 0
46728 - 0 0 0 0 0 0 0 0 0 0 0 0
46729 - 0 0 0 0 0 0 0 0 0 0 0 0
46730 - 6 6 6 6 6 6 14 14 14 18 18 18
46731 - 30 30 30 38 38 38 46 46 46 54 54 54
46732 - 50 50 50 42 42 42 30 30 30 18 18 18
46733 - 10 10 10 0 0 0 0 0 0 0 0 0
46734 - 0 0 0 0 0 0 0 0 0 0 0 0
46735 - 0 0 0 0 0 0 0 0 0 0 0 0
46736 - 0 0 0 0 0 0 0 0 0 0 0 0
46737 - 0 0 0 6 6 6 14 14 14 26 26 26
46738 - 38 38 38 50 50 50 58 58 58 58 58 58
46739 - 54 54 54 42 42 42 30 30 30 18 18 18
46740 - 10 10 10 0 0 0 0 0 0 0 0 0
46741 - 0 0 0 0 0 0 0 0 0 0 0 0
46742 - 0 0 0 0 0 0 0 0 0 0 0 0
46743 - 0 0 0 0 0 0 0 0 0 0 0 0
46744 - 0 0 0 0 0 0 0 0 0 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 6 6 6
46751 - 6 6 6 10 10 10 14 14 14 18 18 18
46752 - 18 18 18 14 14 14 10 10 10 6 6 6
46753 - 0 0 0 0 0 0 0 0 0 0 0 0
46754 - 0 0 0 0 0 0 0 0 0 0 0 0
46755 - 0 0 0 0 0 0 0 0 0 0 0 0
46756 - 0 0 0 0 0 0 0 0 0 0 0 0
46757 - 0 0 0 0 0 0 0 0 0 6 6 6
46758 - 14 14 14 18 18 18 22 22 22 22 22 22
46759 - 18 18 18 14 14 14 10 10 10 6 6 6
46760 - 0 0 0 0 0 0 0 0 0 0 0 0
46761 - 0 0 0 0 0 0 0 0 0 0 0 0
46762 - 0 0 0 0 0 0 0 0 0 0 0 0
46763 - 0 0 0 0 0 0 0 0 0 0 0 0
46764 - 0 0 0 0 0 0 0 0 0 0 0 0
46765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46778 +4 4 4 4 4 4
46779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46792 +4 4 4 4 4 4
46793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46802 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46806 +4 4 4 4 4 4
46807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46814 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46816 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46820 +4 4 4 4 4 4
46821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46834 +4 4 4 4 4 4
46835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46844 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46848 +4 4 4 4 4 4
46849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46853 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46854 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46858 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46859 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46860 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46862 +4 4 4 4 4 4
46863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46867 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46868 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46869 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46872 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46873 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46874 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46875 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46876 +4 4 4 4 4 4
46877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46881 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46882 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46883 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46886 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46887 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46888 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46889 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46890 +4 4 4 4 4 4
46891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46894 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46895 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46896 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46897 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46898 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46899 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46900 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46901 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46902 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46903 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46904 +4 4 4 4 4 4
46905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46908 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46909 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46910 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46911 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46912 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46913 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46914 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46915 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46916 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46917 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46918 +4 4 4 4 4 4
46919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46922 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46923 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46924 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46925 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46926 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46927 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46928 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46929 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46930 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46931 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46932 +4 4 4 4 4 4
46933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46935 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46936 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46937 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46938 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46939 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46940 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46941 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46942 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46943 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46944 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46945 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46946 +4 4 4 4 4 4
46947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46949 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46950 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46951 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46952 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46953 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46954 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46955 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46956 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46957 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46958 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46959 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46960 +4 4 4 4 4 4
46961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46963 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46964 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46965 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46966 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46967 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46968 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46969 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46970 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46971 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46972 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46973 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46974 +4 4 4 4 4 4
46975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46977 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46978 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46979 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46980 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46981 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46982 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46983 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46984 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46985 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46986 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46987 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46988 +4 4 4 4 4 4
46989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46990 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46991 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46992 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46993 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46994 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46995 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46996 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46997 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46998 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46999 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
47000 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
47001 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
47002 +4 4 4 4 4 4
47003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47004 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
47005 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
47006 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
47007 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47008 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
47009 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
47010 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
47011 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
47012 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47013 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47014 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47015 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47016 +0 0 0 4 4 4
47017 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47018 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47019 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47020 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47021 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47022 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47023 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47024 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47025 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47026 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47027 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47028 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47029 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47030 +2 0 0 0 0 0
47031 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47032 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47033 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47034 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47035 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47036 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47037 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47038 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47039 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47040 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47041 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47042 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47043 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47044 +37 38 37 0 0 0
47045 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47046 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47047 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47048 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47049 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47050 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47051 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47052 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47053 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47054 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47055 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47056 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47057 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47058 +85 115 134 4 0 0
47059 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47060 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47061 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47062 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47063 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47064 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47065 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47066 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47067 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47068 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47069 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47070 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47071 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47072 +60 73 81 4 0 0
47073 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47074 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47075 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47076 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47077 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47078 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47079 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47080 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47081 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47082 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47083 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47084 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47085 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47086 +16 19 21 4 0 0
47087 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47088 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47089 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47090 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47091 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47092 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47093 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47094 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47095 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47096 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47097 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47098 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47099 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47100 +4 0 0 4 3 3
47101 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47102 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47103 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47104 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47105 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47106 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47107 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47108 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47109 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47110 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47111 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47112 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47113 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47114 +3 2 2 4 4 4
47115 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47116 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47117 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47118 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47119 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47120 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47121 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47122 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47123 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47124 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47125 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47126 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47127 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47128 +4 4 4 4 4 4
47129 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47130 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47131 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47132 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47133 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47134 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47135 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47136 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47137 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47138 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47139 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47140 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47141 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47142 +4 4 4 4 4 4
47143 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47144 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47145 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47146 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47147 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47148 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47149 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47150 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47151 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47152 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47153 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47154 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47155 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47156 +5 5 5 5 5 5
47157 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47158 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47159 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47160 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47161 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47162 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47163 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47164 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47165 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47166 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47167 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47168 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47169 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47170 +5 5 5 4 4 4
47171 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47172 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47173 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47174 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47175 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47176 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47177 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47178 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47179 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47180 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47181 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47182 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47183 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47184 +4 4 4 4 4 4
47185 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47186 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47187 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47188 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47189 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47190 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47191 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47192 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47193 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47194 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47195 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47196 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47197 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47198 +4 4 4 4 4 4
47199 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47200 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47201 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47202 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47203 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47204 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47205 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47206 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47207 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47208 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47209 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47210 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47211 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47212 +4 4 4 4 4 4
47213 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47214 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47215 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47216 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47217 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47218 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47219 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47220 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47221 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47222 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47223 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47224 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47226 +4 4 4 4 4 4
47227 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47228 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47229 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47230 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47231 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47232 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47233 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47234 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47235 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47236 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47237 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47238 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47240 +4 4 4 4 4 4
47241 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47242 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47243 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47244 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47245 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47246 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47247 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47248 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47249 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47250 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47251 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47254 +4 4 4 4 4 4
47255 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47256 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47257 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47258 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47259 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47260 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47261 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47262 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47263 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47264 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47265 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47267 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47268 +4 4 4 4 4 4
47269 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47270 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47271 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47272 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47273 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47274 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47275 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47276 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47277 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47278 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47279 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47281 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47282 +4 4 4 4 4 4
47283 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47284 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47285 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47286 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47287 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47288 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47289 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47290 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47291 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47292 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47293 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47295 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47296 +4 4 4 4 4 4
47297 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47298 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47299 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47300 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47301 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47302 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47303 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47304 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47305 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47306 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47307 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47309 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47310 +4 4 4 4 4 4
47311 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47312 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47313 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47314 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47315 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47316 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47317 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47318 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47319 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47320 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47321 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47324 +4 4 4 4 4 4
47325 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47326 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47327 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47328 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47329 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47330 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47331 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47332 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47333 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47334 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47335 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47338 +4 4 4 4 4 4
47339 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47340 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47341 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47342 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47343 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47344 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47345 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47346 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47347 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47348 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47349 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47352 +4 4 4 4 4 4
47353 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47354 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47355 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47356 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47357 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47358 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47359 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47360 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47361 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47362 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47363 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47366 +4 4 4 4 4 4
47367 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47368 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47369 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47370 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47371 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47372 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47373 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47374 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47375 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47376 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47377 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47380 +4 4 4 4 4 4
47381 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47382 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47383 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47384 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47385 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47386 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47387 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47388 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47389 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47390 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47391 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47394 +4 4 4 4 4 4
47395 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47396 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47397 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47398 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47399 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47400 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47401 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47402 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47403 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47404 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47405 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47408 +4 4 4 4 4 4
47409 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47410 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47411 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47412 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47413 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47414 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47415 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47416 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47417 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47418 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47419 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47422 +4 4 4 4 4 4
47423 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47424 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47425 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47426 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47427 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47428 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47429 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47430 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47431 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47432 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47433 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47436 +4 4 4 4 4 4
47437 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47438 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47439 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47440 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47441 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47442 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47443 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47444 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47445 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47446 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47447 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47450 +4 4 4 4 4 4
47451 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47452 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47453 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47454 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47455 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47456 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47457 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47458 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47459 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47460 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47461 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47464 +4 4 4 4 4 4
47465 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47466 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47467 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47468 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47469 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47470 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47471 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47472 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47473 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47474 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47475 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47478 +4 4 4 4 4 4
47479 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47480 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47481 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47482 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47483 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47484 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47485 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47486 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47487 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47488 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47489 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47492 +4 4 4 4 4 4
47493 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47494 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47495 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47496 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47497 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47498 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47499 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47500 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47501 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47502 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47503 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47506 +4 4 4 4 4 4
47507 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47508 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47509 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47510 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47511 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47512 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47513 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47514 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47515 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47516 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47517 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47520 +4 4 4 4 4 4
47521 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47522 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47523 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47524 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47525 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47526 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47527 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47528 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47529 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47530 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47531 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47534 +4 4 4 4 4 4
47535 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47536 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47537 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47538 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47539 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47540 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47541 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47542 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47543 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47544 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47545 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47548 +4 4 4 4 4 4
47549 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47550 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47551 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47552 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47553 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47554 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47555 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47556 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47557 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47558 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47559 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47562 +4 4 4 4 4 4
47563 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47564 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47565 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47566 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47567 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47568 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47569 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47570 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47571 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47572 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47573 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47576 +4 4 4 4 4 4
47577 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47578 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47579 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47580 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47581 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47582 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47583 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47584 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47585 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47586 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47590 +4 4 4 4 4 4
47591 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47592 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47593 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47594 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47595 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47596 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47597 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47598 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47599 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47600 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47604 +4 4 4 4 4 4
47605 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47606 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47607 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47608 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47609 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47610 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47611 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47612 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47613 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47614 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47618 +4 4 4 4 4 4
47619 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47620 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47621 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47622 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47623 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47624 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47625 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47626 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47627 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47628 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47632 +4 4 4 4 4 4
47633 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47634 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47635 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47636 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47637 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47638 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47639 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47640 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47641 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47642 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47646 +4 4 4 4 4 4
47647 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47648 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47649 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47650 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47651 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47652 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47653 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47654 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47655 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47660 +4 4 4 4 4 4
47661 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47662 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47663 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47664 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47665 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47666 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47667 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47668 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47669 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47674 +4 4 4 4 4 4
47675 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47676 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47677 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47678 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47679 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47680 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47681 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47682 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47688 +4 4 4 4 4 4
47689 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47690 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47691 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47692 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47693 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47694 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47695 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47696 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47702 +4 4 4 4 4 4
47703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47704 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47705 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47706 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47707 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47708 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47709 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47710 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47716 +4 4 4 4 4 4
47717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47718 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47719 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47720 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47721 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47722 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47723 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47724 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47730 +4 4 4 4 4 4
47731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47732 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47733 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47734 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47735 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47736 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47737 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47738 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47744 +4 4 4 4 4 4
47745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47747 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47748 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47749 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47750 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47751 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47752 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47758 +4 4 4 4 4 4
47759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47762 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47763 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47764 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47765 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47772 +4 4 4 4 4 4
47773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47776 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47777 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47778 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47779 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47786 +4 4 4 4 4 4
47787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47790 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47791 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47792 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47793 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47800 +4 4 4 4 4 4
47801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47802 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47804 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47805 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47806 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47807 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47814 +4 4 4 4 4 4
47815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47816 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47819 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47820 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47821 +6 6 6 4 3 3 5 5 5 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 4 4 4
47823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47828 +4 4 4 4 4 4
47829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47833 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47834 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47835 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47842 +4 4 4 4 4 4
47843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47844 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47847 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47848 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47849 +5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47856 +4 4 4 4 4 4
47857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47858 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47861 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47862 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
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 4 4 4 4 4 4 4 4 4
47866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47870 +4 4 4 4 4 4
47871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47875 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47876 +5 5 5 4 3 3 5 5 5 5 5 5 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 4 4 4 4 4 4
47880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47884 +4 4 4 4 4 4
47885 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47886 index fe92eed..106e085 100644
47887 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47888 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47889 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47890 struct mb862xxfb_par *par = info->par;
47891
47892 if (info->var.bits_per_pixel == 32) {
47893 - info->fbops->fb_fillrect = cfb_fillrect;
47894 - info->fbops->fb_copyarea = cfb_copyarea;
47895 - info->fbops->fb_imageblit = cfb_imageblit;
47896 + pax_open_kernel();
47897 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47898 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47899 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47900 + pax_close_kernel();
47901 } else {
47902 outreg(disp, GC_L0EM, 3);
47903 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47904 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47905 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47906 + pax_open_kernel();
47907 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47908 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47909 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47910 + pax_close_kernel();
47911 }
47912 outreg(draw, GDC_REG_DRAW_BASE, 0);
47913 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47914 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47915 index ff22871..b129bed 100644
47916 --- a/drivers/video/nvidia/nvidia.c
47917 +++ b/drivers/video/nvidia/nvidia.c
47918 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47919 info->fix.line_length = (info->var.xres_virtual *
47920 info->var.bits_per_pixel) >> 3;
47921 if (info->var.accel_flags) {
47922 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47923 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47924 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47925 - info->fbops->fb_sync = nvidiafb_sync;
47926 + pax_open_kernel();
47927 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47928 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47929 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47930 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47931 + pax_close_kernel();
47932 info->pixmap.scan_align = 4;
47933 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47934 info->flags |= FBINFO_READS_FAST;
47935 NVResetGraphics(info);
47936 } else {
47937 - info->fbops->fb_imageblit = cfb_imageblit;
47938 - info->fbops->fb_fillrect = cfb_fillrect;
47939 - info->fbops->fb_copyarea = cfb_copyarea;
47940 - info->fbops->fb_sync = NULL;
47941 + pax_open_kernel();
47942 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47943 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47944 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47945 + *(void **)&info->fbops->fb_sync = NULL;
47946 + pax_close_kernel();
47947 info->pixmap.scan_align = 1;
47948 info->flags |= FBINFO_HWACCEL_DISABLED;
47949 info->flags &= ~FBINFO_READS_FAST;
47950 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47951 info->pixmap.size = 8 * 1024;
47952 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47953
47954 - if (!hwcur)
47955 - info->fbops->fb_cursor = NULL;
47956 + if (!hwcur) {
47957 + pax_open_kernel();
47958 + *(void **)&info->fbops->fb_cursor = NULL;
47959 + pax_close_kernel();
47960 + }
47961
47962 info->var.accel_flags = (!noaccel);
47963
47964 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47965 index 76d9053..dec2bfd 100644
47966 --- a/drivers/video/s1d13xxxfb.c
47967 +++ b/drivers/video/s1d13xxxfb.c
47968 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47969
47970 switch(prod_id) {
47971 case S1D13506_PROD_ID: /* activate acceleration */
47972 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47973 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47974 + pax_open_kernel();
47975 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47976 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47977 + pax_close_kernel();
47978 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47979 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47980 break;
47981 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47982 index 97bd662..39fab85 100644
47983 --- a/drivers/video/smscufx.c
47984 +++ b/drivers/video/smscufx.c
47985 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47986 fb_deferred_io_cleanup(info);
47987 kfree(info->fbdefio);
47988 info->fbdefio = NULL;
47989 - info->fbops->fb_mmap = ufx_ops_mmap;
47990 + pax_open_kernel();
47991 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47992 + pax_close_kernel();
47993 }
47994
47995 pr_debug("released /dev/fb%d user=%d count=%d",
47996 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47997 index 86d449e..8e04dc5 100644
47998 --- a/drivers/video/udlfb.c
47999 +++ b/drivers/video/udlfb.c
48000 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
48001 dlfb_urb_completion(urb);
48002
48003 error:
48004 - atomic_add(bytes_sent, &dev->bytes_sent);
48005 - atomic_add(bytes_identical, &dev->bytes_identical);
48006 - atomic_add(width*height*2, &dev->bytes_rendered);
48007 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48008 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48009 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
48010 end_cycles = get_cycles();
48011 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48012 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48013 >> 10)), /* Kcycles */
48014 &dev->cpu_kcycles_used);
48015
48016 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48017 dlfb_urb_completion(urb);
48018
48019 error:
48020 - atomic_add(bytes_sent, &dev->bytes_sent);
48021 - atomic_add(bytes_identical, &dev->bytes_identical);
48022 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48023 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48024 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48025 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48026 end_cycles = get_cycles();
48027 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48028 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48029 >> 10)), /* Kcycles */
48030 &dev->cpu_kcycles_used);
48031 }
48032 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48033 fb_deferred_io_cleanup(info);
48034 kfree(info->fbdefio);
48035 info->fbdefio = NULL;
48036 - info->fbops->fb_mmap = dlfb_ops_mmap;
48037 + pax_open_kernel();
48038 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48039 + pax_close_kernel();
48040 }
48041
48042 pr_warn("released /dev/fb%d user=%d count=%d\n",
48043 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48044 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48045 struct dlfb_data *dev = fb_info->par;
48046 return snprintf(buf, PAGE_SIZE, "%u\n",
48047 - atomic_read(&dev->bytes_rendered));
48048 + atomic_read_unchecked(&dev->bytes_rendered));
48049 }
48050
48051 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48052 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48053 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48054 struct dlfb_data *dev = fb_info->par;
48055 return snprintf(buf, PAGE_SIZE, "%u\n",
48056 - atomic_read(&dev->bytes_identical));
48057 + atomic_read_unchecked(&dev->bytes_identical));
48058 }
48059
48060 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48061 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48062 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48063 struct dlfb_data *dev = fb_info->par;
48064 return snprintf(buf, PAGE_SIZE, "%u\n",
48065 - atomic_read(&dev->bytes_sent));
48066 + atomic_read_unchecked(&dev->bytes_sent));
48067 }
48068
48069 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48070 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48071 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48072 struct dlfb_data *dev = fb_info->par;
48073 return snprintf(buf, PAGE_SIZE, "%u\n",
48074 - atomic_read(&dev->cpu_kcycles_used));
48075 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48076 }
48077
48078 static ssize_t edid_show(
48079 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48080 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48081 struct dlfb_data *dev = fb_info->par;
48082
48083 - atomic_set(&dev->bytes_rendered, 0);
48084 - atomic_set(&dev->bytes_identical, 0);
48085 - atomic_set(&dev->bytes_sent, 0);
48086 - atomic_set(&dev->cpu_kcycles_used, 0);
48087 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48088 + atomic_set_unchecked(&dev->bytes_identical, 0);
48089 + atomic_set_unchecked(&dev->bytes_sent, 0);
48090 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48091
48092 return count;
48093 }
48094 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48095 index b75db01..ad2f34a 100644
48096 --- a/drivers/video/uvesafb.c
48097 +++ b/drivers/video/uvesafb.c
48098 @@ -19,6 +19,7 @@
48099 #include <linux/io.h>
48100 #include <linux/mutex.h>
48101 #include <linux/slab.h>
48102 +#include <linux/moduleloader.h>
48103 #include <video/edid.h>
48104 #include <video/uvesafb.h>
48105 #ifdef CONFIG_X86
48106 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48107 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48108 par->pmi_setpal = par->ypan = 0;
48109 } else {
48110 +
48111 +#ifdef CONFIG_PAX_KERNEXEC
48112 +#ifdef CONFIG_MODULES
48113 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48114 +#endif
48115 + if (!par->pmi_code) {
48116 + par->pmi_setpal = par->ypan = 0;
48117 + return 0;
48118 + }
48119 +#endif
48120 +
48121 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48122 + task->t.regs.edi);
48123 +
48124 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48125 + pax_open_kernel();
48126 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48127 + pax_close_kernel();
48128 +
48129 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48130 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48131 +#else
48132 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48133 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48134 +#endif
48135 +
48136 printk(KERN_INFO "uvesafb: protected mode interface info at "
48137 "%04x:%04x\n",
48138 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48139 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48140 par->ypan = ypan;
48141
48142 if (par->pmi_setpal || par->ypan) {
48143 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48144 if (__supported_pte_mask & _PAGE_NX) {
48145 par->pmi_setpal = par->ypan = 0;
48146 printk(KERN_WARNING "uvesafb: NX protection is actively."
48147 "We have better not to use the PMI.\n");
48148 - } else {
48149 + } else
48150 +#endif
48151 uvesafb_vbe_getpmi(task, par);
48152 - }
48153 }
48154 #else
48155 /* The protected mode interface is not available on non-x86. */
48156 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48157 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48158
48159 /* Disable blanking if the user requested so. */
48160 - if (!blank)
48161 - info->fbops->fb_blank = NULL;
48162 + if (!blank) {
48163 + pax_open_kernel();
48164 + *(void **)&info->fbops->fb_blank = NULL;
48165 + pax_close_kernel();
48166 + }
48167
48168 /*
48169 * Find out how much IO memory is required for the mode with
48170 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48171 info->flags = FBINFO_FLAG_DEFAULT |
48172 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48173
48174 - if (!par->ypan)
48175 - info->fbops->fb_pan_display = NULL;
48176 + if (!par->ypan) {
48177 + pax_open_kernel();
48178 + *(void **)&info->fbops->fb_pan_display = NULL;
48179 + pax_close_kernel();
48180 + }
48181 }
48182
48183 static void uvesafb_init_mtrr(struct fb_info *info)
48184 @@ -1836,6 +1866,11 @@ out:
48185 if (par->vbe_modes)
48186 kfree(par->vbe_modes);
48187
48188 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48189 + if (par->pmi_code)
48190 + module_free_exec(NULL, par->pmi_code);
48191 +#endif
48192 +
48193 framebuffer_release(info);
48194 return err;
48195 }
48196 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48197 kfree(par->vbe_state_orig);
48198 if (par->vbe_state_saved)
48199 kfree(par->vbe_state_saved);
48200 +
48201 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48202 + if (par->pmi_code)
48203 + module_free_exec(NULL, par->pmi_code);
48204 +#endif
48205 +
48206 }
48207
48208 framebuffer_release(info);
48209 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48210 index 501b340..d80aa17 100644
48211 --- a/drivers/video/vesafb.c
48212 +++ b/drivers/video/vesafb.c
48213 @@ -9,6 +9,7 @@
48214 */
48215
48216 #include <linux/module.h>
48217 +#include <linux/moduleloader.h>
48218 #include <linux/kernel.h>
48219 #include <linux/errno.h>
48220 #include <linux/string.h>
48221 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48222 static int vram_total __initdata; /* Set total amount of memory */
48223 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48224 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48225 -static void (*pmi_start)(void) __read_mostly;
48226 -static void (*pmi_pal) (void) __read_mostly;
48227 +static void (*pmi_start)(void) __read_only;
48228 +static void (*pmi_pal) (void) __read_only;
48229 static int depth __read_mostly;
48230 static int vga_compat __read_mostly;
48231 /* --------------------------------------------------------------------- */
48232 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48233 unsigned int size_vmode;
48234 unsigned int size_remap;
48235 unsigned int size_total;
48236 + void *pmi_code = NULL;
48237
48238 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48239 return -ENODEV;
48240 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48241 size_remap = size_total;
48242 vesafb_fix.smem_len = size_remap;
48243
48244 -#ifndef __i386__
48245 - screen_info.vesapm_seg = 0;
48246 -#endif
48247 -
48248 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48249 printk(KERN_WARNING
48250 "vesafb: cannot reserve video memory at 0x%lx\n",
48251 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48252 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48253 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48254
48255 +#ifdef __i386__
48256 +
48257 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48258 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48259 + if (!pmi_code)
48260 +#elif !defined(CONFIG_PAX_KERNEXEC)
48261 + if (0)
48262 +#endif
48263 +
48264 +#endif
48265 + screen_info.vesapm_seg = 0;
48266 +
48267 if (screen_info.vesapm_seg) {
48268 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48269 - screen_info.vesapm_seg,screen_info.vesapm_off);
48270 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48271 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48272 }
48273
48274 if (screen_info.vesapm_seg < 0xc000)
48275 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48276
48277 if (ypan || pmi_setpal) {
48278 unsigned short *pmi_base;
48279 +
48280 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48281 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48282 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48283 +
48284 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48285 + pax_open_kernel();
48286 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48287 +#else
48288 + pmi_code = pmi_base;
48289 +#endif
48290 +
48291 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48292 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48293 +
48294 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48295 + pmi_start = ktva_ktla(pmi_start);
48296 + pmi_pal = ktva_ktla(pmi_pal);
48297 + pax_close_kernel();
48298 +#endif
48299 +
48300 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48301 if (pmi_base[3]) {
48302 printk(KERN_INFO "vesafb: pmi: ports = ");
48303 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48304 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48305 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48306
48307 - if (!ypan)
48308 - info->fbops->fb_pan_display = NULL;
48309 + if (!ypan) {
48310 + pax_open_kernel();
48311 + *(void **)&info->fbops->fb_pan_display = NULL;
48312 + pax_close_kernel();
48313 + }
48314
48315 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48316 err = -ENOMEM;
48317 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48318 info->node, info->fix.id);
48319 return 0;
48320 err:
48321 +
48322 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48323 + module_free_exec(NULL, pmi_code);
48324 +#endif
48325 +
48326 if (info->screen_base)
48327 iounmap(info->screen_base);
48328 framebuffer_release(info);
48329 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48330 index 88714ae..16c2e11 100644
48331 --- a/drivers/video/via/via_clock.h
48332 +++ b/drivers/video/via/via_clock.h
48333 @@ -56,7 +56,7 @@ struct via_clock {
48334
48335 void (*set_engine_pll_state)(u8 state);
48336 void (*set_engine_pll)(struct via_pll_config config);
48337 -};
48338 +} __no_const;
48339
48340
48341 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48342 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48343 index fef20db..d28b1ab 100644
48344 --- a/drivers/xen/xenfs/xenstored.c
48345 +++ b/drivers/xen/xenfs/xenstored.c
48346 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48347 static int xsd_kva_open(struct inode *inode, struct file *file)
48348 {
48349 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48350 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48351 + NULL);
48352 +#else
48353 xen_store_interface);
48354 +#endif
48355 +
48356 if (!file->private_data)
48357 return -ENOMEM;
48358 return 0;
48359 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48360 index 890bed5..17ae73e 100644
48361 --- a/fs/9p/vfs_inode.c
48362 +++ b/fs/9p/vfs_inode.c
48363 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48364 void
48365 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48366 {
48367 - char *s = nd_get_link(nd);
48368 + const char *s = nd_get_link(nd);
48369
48370 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48371 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48372 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48373 index 0efd152..b5802ad 100644
48374 --- a/fs/Kconfig.binfmt
48375 +++ b/fs/Kconfig.binfmt
48376 @@ -89,7 +89,7 @@ config HAVE_AOUT
48377
48378 config BINFMT_AOUT
48379 tristate "Kernel support for a.out and ECOFF binaries"
48380 - depends on HAVE_AOUT
48381 + depends on HAVE_AOUT && BROKEN
48382 ---help---
48383 A.out (Assembler.OUTput) is a set of formats for libraries and
48384 executables used in the earliest versions of UNIX. Linux used
48385 diff --git a/fs/aio.c b/fs/aio.c
48386 index ed762ae..ee07789 100644
48387 --- a/fs/aio.c
48388 +++ b/fs/aio.c
48389 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48390 size += sizeof(struct io_event) * nr_events;
48391 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48392
48393 - if (nr_pages < 0)
48394 + if (nr_pages <= 0)
48395 return -EINVAL;
48396
48397 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48398 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
48399 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48400 {
48401 ssize_t ret;
48402 + struct iovec iovstack;
48403
48404 #ifdef CONFIG_COMPAT
48405 if (compat)
48406 ret = compat_rw_copy_check_uvector(type,
48407 (struct compat_iovec __user *)kiocb->ki_buf,
48408 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48409 + kiocb->ki_nbytes, 1, &iovstack,
48410 &kiocb->ki_iovec);
48411 else
48412 #endif
48413 ret = rw_copy_check_uvector(type,
48414 (struct iovec __user *)kiocb->ki_buf,
48415 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48416 + kiocb->ki_nbytes, 1, &iovstack,
48417 &kiocb->ki_iovec);
48418 if (ret < 0)
48419 goto out;
48420 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48421 if (ret < 0)
48422 goto out;
48423
48424 + if (kiocb->ki_iovec == &iovstack) {
48425 + kiocb->ki_inline_vec = iovstack;
48426 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48427 + }
48428 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48429 kiocb->ki_cur_seg = 0;
48430 /* ki_nbytes/left now reflect bytes instead of segs */
48431 diff --git a/fs/attr.c b/fs/attr.c
48432 index 1449adb..a2038c2 100644
48433 --- a/fs/attr.c
48434 +++ b/fs/attr.c
48435 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48436 unsigned long limit;
48437
48438 limit = rlimit(RLIMIT_FSIZE);
48439 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48440 if (limit != RLIM_INFINITY && offset > limit)
48441 goto out_sig;
48442 if (offset > inode->i_sb->s_maxbytes)
48443 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48444 index 03bc1d3..6205356 100644
48445 --- a/fs/autofs4/waitq.c
48446 +++ b/fs/autofs4/waitq.c
48447 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48448 {
48449 unsigned long sigpipe, flags;
48450 mm_segment_t fs;
48451 - const char *data = (const char *)addr;
48452 + const char __user *data = (const char __force_user *)addr;
48453 ssize_t wr = 0;
48454
48455 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48456 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48457 return 1;
48458 }
48459
48460 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48461 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48462 +#endif
48463 +
48464 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48465 enum autofs_notify notify)
48466 {
48467 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48468
48469 /* If this is a direct mount request create a dummy name */
48470 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48471 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48472 + /* this name does get written to userland via autofs4_write() */
48473 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48474 +#else
48475 qstr.len = sprintf(name, "%p", dentry);
48476 +#endif
48477 else {
48478 qstr.len = autofs4_getpath(sbi, dentry, &name);
48479 if (!qstr.len) {
48480 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48481 index 2722387..c8dd2a7 100644
48482 --- a/fs/befs/endian.h
48483 +++ b/fs/befs/endian.h
48484 @@ -11,7 +11,7 @@
48485
48486 #include <asm/byteorder.h>
48487
48488 -static inline u64
48489 +static inline u64 __intentional_overflow(-1)
48490 fs64_to_cpu(const struct super_block *sb, fs64 n)
48491 {
48492 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48493 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48494 return (__force fs64)cpu_to_be64(n);
48495 }
48496
48497 -static inline u32
48498 +static inline u32 __intentional_overflow(-1)
48499 fs32_to_cpu(const struct super_block *sb, fs32 n)
48500 {
48501 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48502 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48503 index 2b3bda8..6a2d4be 100644
48504 --- a/fs/befs/linuxvfs.c
48505 +++ b/fs/befs/linuxvfs.c
48506 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48507 {
48508 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48509 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48510 - char *link = nd_get_link(nd);
48511 + const char *link = nd_get_link(nd);
48512 if (!IS_ERR(link))
48513 kfree(link);
48514 }
48515 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48516 index 6043567..16a9239 100644
48517 --- a/fs/binfmt_aout.c
48518 +++ b/fs/binfmt_aout.c
48519 @@ -16,6 +16,7 @@
48520 #include <linux/string.h>
48521 #include <linux/fs.h>
48522 #include <linux/file.h>
48523 +#include <linux/security.h>
48524 #include <linux/stat.h>
48525 #include <linux/fcntl.h>
48526 #include <linux/ptrace.h>
48527 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48528 #endif
48529 # define START_STACK(u) ((void __user *)u.start_stack)
48530
48531 + memset(&dump, 0, sizeof(dump));
48532 +
48533 fs = get_fs();
48534 set_fs(KERNEL_DS);
48535 has_dumped = 1;
48536 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48537
48538 /* If the size of the dump file exceeds the rlimit, then see what would happen
48539 if we wrote the stack, but not the data area. */
48540 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48541 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48542 dump.u_dsize = 0;
48543
48544 /* Make sure we have enough room to write the stack and data areas. */
48545 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48546 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48547 dump.u_ssize = 0;
48548
48549 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48550 rlim = rlimit(RLIMIT_DATA);
48551 if (rlim >= RLIM_INFINITY)
48552 rlim = ~0;
48553 +
48554 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48555 if (ex.a_data + ex.a_bss > rlim)
48556 return -ENOMEM;
48557
48558 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48559
48560 install_exec_creds(bprm);
48561
48562 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48563 + current->mm->pax_flags = 0UL;
48564 +#endif
48565 +
48566 +#ifdef CONFIG_PAX_PAGEEXEC
48567 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48568 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48569 +
48570 +#ifdef CONFIG_PAX_EMUTRAMP
48571 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48572 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48573 +#endif
48574 +
48575 +#ifdef CONFIG_PAX_MPROTECT
48576 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48577 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48578 +#endif
48579 +
48580 + }
48581 +#endif
48582 +
48583 if (N_MAGIC(ex) == OMAGIC) {
48584 unsigned long text_addr, map_size;
48585 loff_t pos;
48586 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48587 }
48588
48589 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48590 - PROT_READ | PROT_WRITE | PROT_EXEC,
48591 + PROT_READ | PROT_WRITE,
48592 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48593 fd_offset + ex.a_text);
48594 if (error != N_DATADDR(ex)) {
48595 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48596 index 5843a47..160fbe2 100644
48597 --- a/fs/binfmt_elf.c
48598 +++ b/fs/binfmt_elf.c
48599 @@ -33,6 +33,7 @@
48600 #include <linux/elf.h>
48601 #include <linux/utsname.h>
48602 #include <linux/coredump.h>
48603 +#include <linux/xattr.h>
48604 #include <asm/uaccess.h>
48605 #include <asm/param.h>
48606 #include <asm/page.h>
48607 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48608 #define elf_core_dump NULL
48609 #endif
48610
48611 +#ifdef CONFIG_PAX_MPROTECT
48612 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48613 +#endif
48614 +
48615 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48616 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48617 #else
48618 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
48619 .load_binary = load_elf_binary,
48620 .load_shlib = load_elf_library,
48621 .core_dump = elf_core_dump,
48622 +
48623 +#ifdef CONFIG_PAX_MPROTECT
48624 + .handle_mprotect= elf_handle_mprotect,
48625 +#endif
48626 +
48627 .min_coredump = ELF_EXEC_PAGESIZE,
48628 };
48629
48630 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
48631
48632 static int set_brk(unsigned long start, unsigned long end)
48633 {
48634 + unsigned long e = end;
48635 +
48636 start = ELF_PAGEALIGN(start);
48637 end = ELF_PAGEALIGN(end);
48638 if (end > start) {
48639 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
48640 if (BAD_ADDR(addr))
48641 return addr;
48642 }
48643 - current->mm->start_brk = current->mm->brk = end;
48644 + current->mm->start_brk = current->mm->brk = e;
48645 return 0;
48646 }
48647
48648 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48649 elf_addr_t __user *u_rand_bytes;
48650 const char *k_platform = ELF_PLATFORM;
48651 const char *k_base_platform = ELF_BASE_PLATFORM;
48652 - unsigned char k_rand_bytes[16];
48653 + u32 k_rand_bytes[4];
48654 int items;
48655 elf_addr_t *elf_info;
48656 int ei_index = 0;
48657 const struct cred *cred = current_cred();
48658 struct vm_area_struct *vma;
48659 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48660
48661 /*
48662 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48663 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48664 * Generate 16 random bytes for userspace PRNG seeding.
48665 */
48666 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48667 - u_rand_bytes = (elf_addr_t __user *)
48668 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48669 + srandom32(k_rand_bytes[0] ^ random32());
48670 + srandom32(k_rand_bytes[1] ^ random32());
48671 + srandom32(k_rand_bytes[2] ^ random32());
48672 + srandom32(k_rand_bytes[3] ^ random32());
48673 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48674 + u_rand_bytes = (elf_addr_t __user *) p;
48675 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48676 return -EFAULT;
48677
48678 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48679 return -EFAULT;
48680 current->mm->env_end = p;
48681
48682 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48683 +
48684 /* Put the elf_info on the stack in the right place. */
48685 sp = (elf_addr_t __user *)envp + 1;
48686 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48687 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48688 return -EFAULT;
48689 return 0;
48690 }
48691 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48692 an ELF header */
48693
48694 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48695 - struct file *interpreter, unsigned long *interp_map_addr,
48696 - unsigned long no_base)
48697 + struct file *interpreter, unsigned long no_base)
48698 {
48699 struct elf_phdr *elf_phdata;
48700 struct elf_phdr *eppnt;
48701 - unsigned long load_addr = 0;
48702 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48703 int load_addr_set = 0;
48704 unsigned long last_bss = 0, elf_bss = 0;
48705 - unsigned long error = ~0UL;
48706 + unsigned long error = -EINVAL;
48707 unsigned long total_size;
48708 int retval, i, size;
48709
48710 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48711 goto out_close;
48712 }
48713
48714 +#ifdef CONFIG_PAX_SEGMEXEC
48715 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48716 + pax_task_size = SEGMEXEC_TASK_SIZE;
48717 +#endif
48718 +
48719 eppnt = elf_phdata;
48720 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48721 if (eppnt->p_type == PT_LOAD) {
48722 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48723 map_addr = elf_map(interpreter, load_addr + vaddr,
48724 eppnt, elf_prot, elf_type, total_size);
48725 total_size = 0;
48726 - if (!*interp_map_addr)
48727 - *interp_map_addr = map_addr;
48728 error = map_addr;
48729 if (BAD_ADDR(map_addr))
48730 goto out_close;
48731 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48732 k = load_addr + eppnt->p_vaddr;
48733 if (BAD_ADDR(k) ||
48734 eppnt->p_filesz > eppnt->p_memsz ||
48735 - eppnt->p_memsz > TASK_SIZE ||
48736 - TASK_SIZE - eppnt->p_memsz < k) {
48737 + eppnt->p_memsz > pax_task_size ||
48738 + pax_task_size - eppnt->p_memsz < k) {
48739 error = -ENOMEM;
48740 goto out_close;
48741 }
48742 @@ -530,6 +551,315 @@ out:
48743 return error;
48744 }
48745
48746 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48747 +#ifdef CONFIG_PAX_SOFTMODE
48748 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48749 +{
48750 + unsigned long pax_flags = 0UL;
48751 +
48752 +#ifdef CONFIG_PAX_PAGEEXEC
48753 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48754 + pax_flags |= MF_PAX_PAGEEXEC;
48755 +#endif
48756 +
48757 +#ifdef CONFIG_PAX_SEGMEXEC
48758 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48759 + pax_flags |= MF_PAX_SEGMEXEC;
48760 +#endif
48761 +
48762 +#ifdef CONFIG_PAX_EMUTRAMP
48763 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48764 + pax_flags |= MF_PAX_EMUTRAMP;
48765 +#endif
48766 +
48767 +#ifdef CONFIG_PAX_MPROTECT
48768 + if (elf_phdata->p_flags & PF_MPROTECT)
48769 + pax_flags |= MF_PAX_MPROTECT;
48770 +#endif
48771 +
48772 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48773 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48774 + pax_flags |= MF_PAX_RANDMMAP;
48775 +#endif
48776 +
48777 + return pax_flags;
48778 +}
48779 +#endif
48780 +
48781 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48782 +{
48783 + unsigned long pax_flags = 0UL;
48784 +
48785 +#ifdef CONFIG_PAX_PAGEEXEC
48786 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48787 + pax_flags |= MF_PAX_PAGEEXEC;
48788 +#endif
48789 +
48790 +#ifdef CONFIG_PAX_SEGMEXEC
48791 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48792 + pax_flags |= MF_PAX_SEGMEXEC;
48793 +#endif
48794 +
48795 +#ifdef CONFIG_PAX_EMUTRAMP
48796 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48797 + pax_flags |= MF_PAX_EMUTRAMP;
48798 +#endif
48799 +
48800 +#ifdef CONFIG_PAX_MPROTECT
48801 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48802 + pax_flags |= MF_PAX_MPROTECT;
48803 +#endif
48804 +
48805 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48806 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48807 + pax_flags |= MF_PAX_RANDMMAP;
48808 +#endif
48809 +
48810 + return pax_flags;
48811 +}
48812 +#endif
48813 +
48814 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48815 +#ifdef CONFIG_PAX_SOFTMODE
48816 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48817 +{
48818 + unsigned long pax_flags = 0UL;
48819 +
48820 +#ifdef CONFIG_PAX_PAGEEXEC
48821 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48822 + pax_flags |= MF_PAX_PAGEEXEC;
48823 +#endif
48824 +
48825 +#ifdef CONFIG_PAX_SEGMEXEC
48826 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48827 + pax_flags |= MF_PAX_SEGMEXEC;
48828 +#endif
48829 +
48830 +#ifdef CONFIG_PAX_EMUTRAMP
48831 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48832 + pax_flags |= MF_PAX_EMUTRAMP;
48833 +#endif
48834 +
48835 +#ifdef CONFIG_PAX_MPROTECT
48836 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48837 + pax_flags |= MF_PAX_MPROTECT;
48838 +#endif
48839 +
48840 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48841 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48842 + pax_flags |= MF_PAX_RANDMMAP;
48843 +#endif
48844 +
48845 + return pax_flags;
48846 +}
48847 +#endif
48848 +
48849 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48850 +{
48851 + unsigned long pax_flags = 0UL;
48852 +
48853 +#ifdef CONFIG_PAX_PAGEEXEC
48854 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48855 + pax_flags |= MF_PAX_PAGEEXEC;
48856 +#endif
48857 +
48858 +#ifdef CONFIG_PAX_SEGMEXEC
48859 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48860 + pax_flags |= MF_PAX_SEGMEXEC;
48861 +#endif
48862 +
48863 +#ifdef CONFIG_PAX_EMUTRAMP
48864 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48865 + pax_flags |= MF_PAX_EMUTRAMP;
48866 +#endif
48867 +
48868 +#ifdef CONFIG_PAX_MPROTECT
48869 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48870 + pax_flags |= MF_PAX_MPROTECT;
48871 +#endif
48872 +
48873 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48874 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48875 + pax_flags |= MF_PAX_RANDMMAP;
48876 +#endif
48877 +
48878 + return pax_flags;
48879 +}
48880 +#endif
48881 +
48882 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48883 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48884 +{
48885 + unsigned long pax_flags = 0UL;
48886 +
48887 +#ifdef CONFIG_PAX_EI_PAX
48888 +
48889 +#ifdef CONFIG_PAX_PAGEEXEC
48890 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48891 + pax_flags |= MF_PAX_PAGEEXEC;
48892 +#endif
48893 +
48894 +#ifdef CONFIG_PAX_SEGMEXEC
48895 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48896 + pax_flags |= MF_PAX_SEGMEXEC;
48897 +#endif
48898 +
48899 +#ifdef CONFIG_PAX_EMUTRAMP
48900 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48901 + pax_flags |= MF_PAX_EMUTRAMP;
48902 +#endif
48903 +
48904 +#ifdef CONFIG_PAX_MPROTECT
48905 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48906 + pax_flags |= MF_PAX_MPROTECT;
48907 +#endif
48908 +
48909 +#ifdef CONFIG_PAX_ASLR
48910 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48911 + pax_flags |= MF_PAX_RANDMMAP;
48912 +#endif
48913 +
48914 +#else
48915 +
48916 +#ifdef CONFIG_PAX_PAGEEXEC
48917 + pax_flags |= MF_PAX_PAGEEXEC;
48918 +#endif
48919 +
48920 +#ifdef CONFIG_PAX_SEGMEXEC
48921 + pax_flags |= MF_PAX_SEGMEXEC;
48922 +#endif
48923 +
48924 +#ifdef CONFIG_PAX_MPROTECT
48925 + pax_flags |= MF_PAX_MPROTECT;
48926 +#endif
48927 +
48928 +#ifdef CONFIG_PAX_RANDMMAP
48929 + if (randomize_va_space)
48930 + pax_flags |= MF_PAX_RANDMMAP;
48931 +#endif
48932 +
48933 +#endif
48934 +
48935 + return pax_flags;
48936 +}
48937 +
48938 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48939 +{
48940 +
48941 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48942 + unsigned long i;
48943 +
48944 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48945 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48946 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48947 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48948 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48949 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48950 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48951 + return ~0UL;
48952 +
48953 +#ifdef CONFIG_PAX_SOFTMODE
48954 + if (pax_softmode)
48955 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48956 + else
48957 +#endif
48958 +
48959 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48960 + break;
48961 + }
48962 +#endif
48963 +
48964 + return ~0UL;
48965 +}
48966 +
48967 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48968 +{
48969 +
48970 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48971 + ssize_t xattr_size, i;
48972 + unsigned char xattr_value[5];
48973 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48974 +
48975 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
48976 + if (xattr_size <= 0 || xattr_size > 5)
48977 + return ~0UL;
48978 +
48979 + for (i = 0; i < xattr_size; i++)
48980 + switch (xattr_value[i]) {
48981 + default:
48982 + return ~0UL;
48983 +
48984 +#define parse_flag(option1, option2, flag) \
48985 + case option1: \
48986 + if (pax_flags_hardmode & MF_PAX_##flag) \
48987 + return ~0UL; \
48988 + pax_flags_hardmode |= MF_PAX_##flag; \
48989 + break; \
48990 + case option2: \
48991 + if (pax_flags_softmode & MF_PAX_##flag) \
48992 + return ~0UL; \
48993 + pax_flags_softmode |= MF_PAX_##flag; \
48994 + break;
48995 +
48996 + parse_flag('p', 'P', PAGEEXEC);
48997 + parse_flag('e', 'E', EMUTRAMP);
48998 + parse_flag('m', 'M', MPROTECT);
48999 + parse_flag('r', 'R', RANDMMAP);
49000 + parse_flag('s', 'S', SEGMEXEC);
49001 +
49002 +#undef parse_flag
49003 + }
49004 +
49005 + if (pax_flags_hardmode & pax_flags_softmode)
49006 + return ~0UL;
49007 +
49008 +#ifdef CONFIG_PAX_SOFTMODE
49009 + if (pax_softmode)
49010 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
49011 + else
49012 +#endif
49013 +
49014 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49015 +#else
49016 + return ~0UL;
49017 +#endif
49018 +
49019 +}
49020 +
49021 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49022 +{
49023 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49024 +
49025 + pax_flags = pax_parse_ei_pax(elf_ex);
49026 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49027 + xattr_pax_flags = pax_parse_xattr_pax(file);
49028 +
49029 + if (pt_pax_flags == ~0UL)
49030 + pt_pax_flags = xattr_pax_flags;
49031 + else if (xattr_pax_flags == ~0UL)
49032 + xattr_pax_flags = pt_pax_flags;
49033 + if (pt_pax_flags != xattr_pax_flags)
49034 + return -EINVAL;
49035 + if (pt_pax_flags != ~0UL)
49036 + pax_flags = pt_pax_flags;
49037 +
49038 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49039 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49040 + if ((__supported_pte_mask & _PAGE_NX))
49041 + pax_flags &= ~MF_PAX_SEGMEXEC;
49042 + else
49043 + pax_flags &= ~MF_PAX_PAGEEXEC;
49044 + }
49045 +#endif
49046 +
49047 + if (0 > pax_check_flags(&pax_flags))
49048 + return -EINVAL;
49049 +
49050 + current->mm->pax_flags = pax_flags;
49051 + return 0;
49052 +}
49053 +#endif
49054 +
49055 /*
49056 * These are the functions used to load ELF style executables and shared
49057 * libraries. There is no binary dependent code anywhere else.
49058 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49059 {
49060 unsigned int random_variable = 0;
49061
49062 +#ifdef CONFIG_PAX_RANDUSTACK
49063 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49064 + return stack_top - current->mm->delta_stack;
49065 +#endif
49066 +
49067 if ((current->flags & PF_RANDOMIZE) &&
49068 !(current->personality & ADDR_NO_RANDOMIZE)) {
49069 random_variable = get_random_int() & STACK_RND_MASK;
49070 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49071 unsigned long load_addr = 0, load_bias = 0;
49072 int load_addr_set = 0;
49073 char * elf_interpreter = NULL;
49074 - unsigned long error;
49075 + unsigned long error = 0;
49076 struct elf_phdr *elf_ppnt, *elf_phdata;
49077 unsigned long elf_bss, elf_brk;
49078 int retval, i;
49079 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49080 unsigned long start_code, end_code, start_data, end_data;
49081 unsigned long reloc_func_desc __maybe_unused = 0;
49082 int executable_stack = EXSTACK_DEFAULT;
49083 - unsigned long def_flags = 0;
49084 struct pt_regs *regs = current_pt_regs();
49085 struct {
49086 struct elfhdr elf_ex;
49087 struct elfhdr interp_elf_ex;
49088 } *loc;
49089 + unsigned long pax_task_size = TASK_SIZE;
49090
49091 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49092 if (!loc) {
49093 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49094 goto out_free_dentry;
49095
49096 /* OK, This is the point of no return */
49097 - current->mm->def_flags = def_flags;
49098 +
49099 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49100 + current->mm->pax_flags = 0UL;
49101 +#endif
49102 +
49103 +#ifdef CONFIG_PAX_DLRESOLVE
49104 + current->mm->call_dl_resolve = 0UL;
49105 +#endif
49106 +
49107 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49108 + current->mm->call_syscall = 0UL;
49109 +#endif
49110 +
49111 +#ifdef CONFIG_PAX_ASLR
49112 + current->mm->delta_mmap = 0UL;
49113 + current->mm->delta_stack = 0UL;
49114 +#endif
49115 +
49116 + current->mm->def_flags = 0;
49117 +
49118 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49119 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49120 + send_sig(SIGKILL, current, 0);
49121 + goto out_free_dentry;
49122 + }
49123 +#endif
49124 +
49125 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49126 + pax_set_initial_flags(bprm);
49127 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49128 + if (pax_set_initial_flags_func)
49129 + (pax_set_initial_flags_func)(bprm);
49130 +#endif
49131 +
49132 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49133 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49134 + current->mm->context.user_cs_limit = PAGE_SIZE;
49135 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49136 + }
49137 +#endif
49138 +
49139 +#ifdef CONFIG_PAX_SEGMEXEC
49140 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49141 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49142 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49143 + pax_task_size = SEGMEXEC_TASK_SIZE;
49144 + current->mm->def_flags |= VM_NOHUGEPAGE;
49145 + }
49146 +#endif
49147 +
49148 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49149 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49150 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49151 + put_cpu();
49152 + }
49153 +#endif
49154
49155 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49156 may depend on the personality. */
49157 SET_PERSONALITY(loc->elf_ex);
49158 +
49159 +#ifdef CONFIG_PAX_ASLR
49160 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49161 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49162 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49163 + }
49164 +#endif
49165 +
49166 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49167 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49168 + executable_stack = EXSTACK_DISABLE_X;
49169 + current->personality &= ~READ_IMPLIES_EXEC;
49170 + } else
49171 +#endif
49172 +
49173 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49174 current->personality |= READ_IMPLIES_EXEC;
49175
49176 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49177 #else
49178 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49179 #endif
49180 +
49181 +#ifdef CONFIG_PAX_RANDMMAP
49182 + /* PaX: randomize base address at the default exe base if requested */
49183 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49184 +#ifdef CONFIG_SPARC64
49185 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49186 +#else
49187 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49188 +#endif
49189 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49190 + elf_flags |= MAP_FIXED;
49191 + }
49192 +#endif
49193 +
49194 }
49195
49196 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49197 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49198 * allowed task size. Note that p_filesz must always be
49199 * <= p_memsz so it is only necessary to check p_memsz.
49200 */
49201 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49202 - elf_ppnt->p_memsz > TASK_SIZE ||
49203 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49204 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49205 + elf_ppnt->p_memsz > pax_task_size ||
49206 + pax_task_size - elf_ppnt->p_memsz < k) {
49207 /* set_brk can never work. Avoid overflows. */
49208 send_sig(SIGKILL, current, 0);
49209 retval = -EINVAL;
49210 @@ -883,17 +1302,44 @@ static int load_elf_binary(struct linux_binprm *bprm)
49211 goto out_free_dentry;
49212 }
49213 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49214 - send_sig(SIGSEGV, current, 0);
49215 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49216 - goto out_free_dentry;
49217 + /*
49218 + * This bss-zeroing can fail if the ELF
49219 + * file specifies odd protections. So
49220 + * we don't check the return value
49221 + */
49222 }
49223
49224 +#ifdef CONFIG_PAX_RANDMMAP
49225 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49226 + unsigned long start, size, flags, vm_flags;
49227 +
49228 + start = ELF_PAGEALIGN(elf_brk);
49229 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49230 + flags = MAP_FIXED | MAP_PRIVATE;
49231 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49232 +
49233 + down_write(&current->mm->mmap_sem);
49234 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49235 + retval = -ENOMEM;
49236 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49237 +// if (current->personality & ADDR_NO_RANDOMIZE)
49238 +// vm_flags |= VM_READ | VM_MAYREAD;
49239 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
49240 + retval = IS_ERR_VALUE(start) ? start : 0;
49241 + }
49242 + up_write(&current->mm->mmap_sem);
49243 + if (retval == 0)
49244 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49245 + if (retval < 0) {
49246 + send_sig(SIGKILL, current, 0);
49247 + goto out_free_dentry;
49248 + }
49249 + }
49250 +#endif
49251 +
49252 if (elf_interpreter) {
49253 - unsigned long interp_map_addr = 0;
49254 -
49255 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49256 interpreter,
49257 - &interp_map_addr,
49258 load_bias);
49259 if (!IS_ERR((void *)elf_entry)) {
49260 /*
49261 @@ -1115,7 +1561,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49262 * Decide what to dump of a segment, part, all or none.
49263 */
49264 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49265 - unsigned long mm_flags)
49266 + unsigned long mm_flags, long signr)
49267 {
49268 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49269
49270 @@ -1153,7 +1599,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49271 if (vma->vm_file == NULL)
49272 return 0;
49273
49274 - if (FILTER(MAPPED_PRIVATE))
49275 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49276 goto whole;
49277
49278 /*
49279 @@ -1375,9 +1821,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49280 {
49281 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49282 int i = 0;
49283 - do
49284 + do {
49285 i += 2;
49286 - while (auxv[i - 2] != AT_NULL);
49287 + } while (auxv[i - 2] != AT_NULL);
49288 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49289 }
49290
49291 @@ -2007,14 +2453,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49292 }
49293
49294 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49295 - unsigned long mm_flags)
49296 + struct coredump_params *cprm)
49297 {
49298 struct vm_area_struct *vma;
49299 size_t size = 0;
49300
49301 for (vma = first_vma(current, gate_vma); vma != NULL;
49302 vma = next_vma(vma, gate_vma))
49303 - size += vma_dump_size(vma, mm_flags);
49304 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49305 return size;
49306 }
49307
49308 @@ -2108,7 +2554,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49309
49310 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49311
49312 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49313 + offset += elf_core_vma_data_size(gate_vma, cprm);
49314 offset += elf_core_extra_data_size();
49315 e_shoff = offset;
49316
49317 @@ -2122,10 +2568,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49318 offset = dataoff;
49319
49320 size += sizeof(*elf);
49321 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49322 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49323 goto end_coredump;
49324
49325 size += sizeof(*phdr4note);
49326 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49327 if (size > cprm->limit
49328 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49329 goto end_coredump;
49330 @@ -2139,7 +2587,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49331 phdr.p_offset = offset;
49332 phdr.p_vaddr = vma->vm_start;
49333 phdr.p_paddr = 0;
49334 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49335 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49336 phdr.p_memsz = vma->vm_end - vma->vm_start;
49337 offset += phdr.p_filesz;
49338 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49339 @@ -2150,6 +2598,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49340 phdr.p_align = ELF_EXEC_PAGESIZE;
49341
49342 size += sizeof(phdr);
49343 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49344 if (size > cprm->limit
49345 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49346 goto end_coredump;
49347 @@ -2174,7 +2623,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49348 unsigned long addr;
49349 unsigned long end;
49350
49351 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49352 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49353
49354 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49355 struct page *page;
49356 @@ -2183,6 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49357 page = get_dump_page(addr);
49358 if (page) {
49359 void *kaddr = kmap(page);
49360 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49361 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49362 !dump_write(cprm->file, kaddr,
49363 PAGE_SIZE);
49364 @@ -2200,6 +2650,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49365
49366 if (e_phnum == PN_XNUM) {
49367 size += sizeof(*shdr4extnum);
49368 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49369 if (size > cprm->limit
49370 || !dump_write(cprm->file, shdr4extnum,
49371 sizeof(*shdr4extnum)))
49372 @@ -2220,6 +2671,97 @@ out:
49373
49374 #endif /* CONFIG_ELF_CORE */
49375
49376 +#ifdef CONFIG_PAX_MPROTECT
49377 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49378 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49379 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49380 + *
49381 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49382 + * basis because we want to allow the common case and not the special ones.
49383 + */
49384 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49385 +{
49386 + struct elfhdr elf_h;
49387 + struct elf_phdr elf_p;
49388 + unsigned long i;
49389 + unsigned long oldflags;
49390 + bool is_textrel_rw, is_textrel_rx, is_relro;
49391 +
49392 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49393 + return;
49394 +
49395 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49396 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49397 +
49398 +#ifdef CONFIG_PAX_ELFRELOCS
49399 + /* possible TEXTREL */
49400 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49401 + 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);
49402 +#else
49403 + is_textrel_rw = false;
49404 + is_textrel_rx = false;
49405 +#endif
49406 +
49407 + /* possible RELRO */
49408 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49409 +
49410 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49411 + return;
49412 +
49413 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49414 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49415 +
49416 +#ifdef CONFIG_PAX_ETEXECRELOCS
49417 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49418 +#else
49419 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49420 +#endif
49421 +
49422 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49423 + !elf_check_arch(&elf_h) ||
49424 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49425 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49426 + return;
49427 +
49428 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49429 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49430 + return;
49431 + switch (elf_p.p_type) {
49432 + case PT_DYNAMIC:
49433 + if (!is_textrel_rw && !is_textrel_rx)
49434 + continue;
49435 + i = 0UL;
49436 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49437 + elf_dyn dyn;
49438 +
49439 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49440 + return;
49441 + if (dyn.d_tag == DT_NULL)
49442 + return;
49443 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49444 + gr_log_textrel(vma);
49445 + if (is_textrel_rw)
49446 + vma->vm_flags |= VM_MAYWRITE;
49447 + else
49448 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49449 + vma->vm_flags &= ~VM_MAYWRITE;
49450 + return;
49451 + }
49452 + i++;
49453 + }
49454 + return;
49455 +
49456 + case PT_GNU_RELRO:
49457 + if (!is_relro)
49458 + continue;
49459 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49460 + vma->vm_flags &= ~VM_MAYWRITE;
49461 + return;
49462 + }
49463 + }
49464 +}
49465 +#endif
49466 +
49467 static int __init init_elf_binfmt(void)
49468 {
49469 register_binfmt(&elf_format);
49470 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49471 index b563719..3868998 100644
49472 --- a/fs/binfmt_flat.c
49473 +++ b/fs/binfmt_flat.c
49474 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49475 realdatastart = (unsigned long) -ENOMEM;
49476 printk("Unable to allocate RAM for process data, errno %d\n",
49477 (int)-realdatastart);
49478 + down_write(&current->mm->mmap_sem);
49479 vm_munmap(textpos, text_len);
49480 + up_write(&current->mm->mmap_sem);
49481 ret = realdatastart;
49482 goto err;
49483 }
49484 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49485 }
49486 if (IS_ERR_VALUE(result)) {
49487 printk("Unable to read data+bss, errno %d\n", (int)-result);
49488 + down_write(&current->mm->mmap_sem);
49489 vm_munmap(textpos, text_len);
49490 vm_munmap(realdatastart, len);
49491 + up_write(&current->mm->mmap_sem);
49492 ret = result;
49493 goto err;
49494 }
49495 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49496 }
49497 if (IS_ERR_VALUE(result)) {
49498 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49499 + down_write(&current->mm->mmap_sem);
49500 vm_munmap(textpos, text_len + data_len + extra +
49501 MAX_SHARED_LIBS * sizeof(unsigned long));
49502 + up_write(&current->mm->mmap_sem);
49503 ret = result;
49504 goto err;
49505 }
49506 diff --git a/fs/bio.c b/fs/bio.c
49507 index b96fc6c..431d628 100644
49508 --- a/fs/bio.c
49509 +++ b/fs/bio.c
49510 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49511 /*
49512 * Overflow, abort
49513 */
49514 - if (end < start)
49515 + if (end < start || end - start > INT_MAX - nr_pages)
49516 return ERR_PTR(-EINVAL);
49517
49518 nr_pages += end - start;
49519 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49520 /*
49521 * Overflow, abort
49522 */
49523 - if (end < start)
49524 + if (end < start || end - start > INT_MAX - nr_pages)
49525 return ERR_PTR(-EINVAL);
49526
49527 nr_pages += end - start;
49528 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49529 const int read = bio_data_dir(bio) == READ;
49530 struct bio_map_data *bmd = bio->bi_private;
49531 int i;
49532 - char *p = bmd->sgvecs[0].iov_base;
49533 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49534
49535 __bio_for_each_segment(bvec, bio, i, 0) {
49536 char *addr = page_address(bvec->bv_page);
49537 diff --git a/fs/block_dev.c b/fs/block_dev.c
49538 index 883dc49..f27794a 100644
49539 --- a/fs/block_dev.c
49540 +++ b/fs/block_dev.c
49541 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49542 else if (bdev->bd_contains == bdev)
49543 return true; /* is a whole device which isn't held */
49544
49545 - else if (whole->bd_holder == bd_may_claim)
49546 + else if (whole->bd_holder == (void *)bd_may_claim)
49547 return true; /* is a partition of a device that is being partitioned */
49548 else if (whole->bd_holder != NULL)
49549 return false; /* is a partition of a held device */
49550 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49551 index ce1c169..1ef484f 100644
49552 --- a/fs/btrfs/ctree.c
49553 +++ b/fs/btrfs/ctree.c
49554 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49555 free_extent_buffer(buf);
49556 add_root_to_dirty_list(root);
49557 } else {
49558 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49559 - parent_start = parent->start;
49560 - else
49561 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49562 + if (parent)
49563 + parent_start = parent->start;
49564 + else
49565 + parent_start = 0;
49566 + } else
49567 parent_start = 0;
49568
49569 WARN_ON(trans->transid != btrfs_header_generation(parent));
49570 diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
49571 index d170412..a575d77 100644
49572 --- a/fs/btrfs/extent-tree.c
49573 +++ b/fs/btrfs/extent-tree.c
49574 @@ -6019,7 +6019,7 @@ again:
49575 if (ret == -ENOSPC) {
49576 if (!final_tried) {
49577 num_bytes = num_bytes >> 1;
49578 - num_bytes = num_bytes & ~(root->sectorsize - 1);
49579 + num_bytes = num_bytes & ~((u64)root->sectorsize - 1);
49580 num_bytes = max(num_bytes, min_alloc_size);
49581 if (num_bytes == min_alloc_size)
49582 final_tried = true;
49583 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
49584 index 7c4e6cc..8ad78b2 100644
49585 --- a/fs/btrfs/inode.c
49586 +++ b/fs/btrfs/inode.c
49587 @@ -17,6 +17,7 @@
49588 */
49589
49590 #include <linux/kernel.h>
49591 +#include <linux/module.h>
49592 #include <linux/bio.h>
49593 #include <linux/buffer_head.h>
49594 #include <linux/file.h>
49595 @@ -7314,7 +7315,7 @@ fail:
49596 return -ENOMEM;
49597 }
49598
49599 -static int btrfs_getattr(struct vfsmount *mnt,
49600 +int btrfs_getattr(struct vfsmount *mnt,
49601 struct dentry *dentry, struct kstat *stat)
49602 {
49603 struct inode *inode = dentry->d_inode;
49604 @@ -7328,6 +7329,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
49605 return 0;
49606 }
49607
49608 +EXPORT_SYMBOL(btrfs_getattr);
49609 +
49610 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
49611 +{
49612 + return BTRFS_I(inode)->root->anon_dev;
49613 +}
49614 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
49615 +
49616 /*
49617 * If a file is moved, it will inherit the cow and compression flags of the new
49618 * directory.
49619 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49620 index 338f259..b657640 100644
49621 --- a/fs/btrfs/ioctl.c
49622 +++ b/fs/btrfs/ioctl.c
49623 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49624 for (i = 0; i < num_types; i++) {
49625 struct btrfs_space_info *tmp;
49626
49627 + /* Don't copy in more than we allocated */
49628 if (!slot_count)
49629 break;
49630
49631 + slot_count--;
49632 +
49633 info = NULL;
49634 rcu_read_lock();
49635 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49636 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49637 memcpy(dest, &space, sizeof(space));
49638 dest++;
49639 space_args.total_spaces++;
49640 - slot_count--;
49641 }
49642 - if (!slot_count)
49643 - break;
49644 }
49645 up_read(&info->groups_sem);
49646 }
49647 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
49648 index 300e09a..9fe4539 100644
49649 --- a/fs/btrfs/relocation.c
49650 +++ b/fs/btrfs/relocation.c
49651 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
49652 }
49653 spin_unlock(&rc->reloc_root_tree.lock);
49654
49655 - BUG_ON((struct btrfs_root *)node->data != root);
49656 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
49657
49658 if (!del) {
49659 spin_lock(&rc->reloc_root_tree.lock);
49660 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49661 index d8982e9..29a85fa 100644
49662 --- a/fs/btrfs/super.c
49663 +++ b/fs/btrfs/super.c
49664 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49665 function, line, errstr);
49666 return;
49667 }
49668 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49669 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49670 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49671 }
49672 /*
49673 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49674 index 622f469..e8d2d55 100644
49675 --- a/fs/cachefiles/bind.c
49676 +++ b/fs/cachefiles/bind.c
49677 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49678 args);
49679
49680 /* start by checking things over */
49681 - ASSERT(cache->fstop_percent >= 0 &&
49682 - cache->fstop_percent < cache->fcull_percent &&
49683 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49684 cache->fcull_percent < cache->frun_percent &&
49685 cache->frun_percent < 100);
49686
49687 - ASSERT(cache->bstop_percent >= 0 &&
49688 - cache->bstop_percent < cache->bcull_percent &&
49689 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49690 cache->bcull_percent < cache->brun_percent &&
49691 cache->brun_percent < 100);
49692
49693 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49694 index 0a1467b..6a53245 100644
49695 --- a/fs/cachefiles/daemon.c
49696 +++ b/fs/cachefiles/daemon.c
49697 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49698 if (n > buflen)
49699 return -EMSGSIZE;
49700
49701 - if (copy_to_user(_buffer, buffer, n) != 0)
49702 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49703 return -EFAULT;
49704
49705 return n;
49706 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49707 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49708 return -EIO;
49709
49710 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49711 + if (datalen > PAGE_SIZE - 1)
49712 return -EOPNOTSUPP;
49713
49714 /* drag the command string into the kernel so we can parse it */
49715 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49716 if (args[0] != '%' || args[1] != '\0')
49717 return -EINVAL;
49718
49719 - if (fstop < 0 || fstop >= cache->fcull_percent)
49720 + if (fstop >= cache->fcull_percent)
49721 return cachefiles_daemon_range_error(cache, args);
49722
49723 cache->fstop_percent = fstop;
49724 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49725 if (args[0] != '%' || args[1] != '\0')
49726 return -EINVAL;
49727
49728 - if (bstop < 0 || bstop >= cache->bcull_percent)
49729 + if (bstop >= cache->bcull_percent)
49730 return cachefiles_daemon_range_error(cache, args);
49731
49732 cache->bstop_percent = bstop;
49733 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49734 index 4938251..7e01445 100644
49735 --- a/fs/cachefiles/internal.h
49736 +++ b/fs/cachefiles/internal.h
49737 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49738 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49739 struct rb_root active_nodes; /* active nodes (can't be culled) */
49740 rwlock_t active_lock; /* lock for active_nodes */
49741 - atomic_t gravecounter; /* graveyard uniquifier */
49742 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49743 unsigned frun_percent; /* when to stop culling (% files) */
49744 unsigned fcull_percent; /* when to start culling (% files) */
49745 unsigned fstop_percent; /* when to stop allocating (% files) */
49746 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49747 * proc.c
49748 */
49749 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49750 -extern atomic_t cachefiles_lookup_histogram[HZ];
49751 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49752 -extern atomic_t cachefiles_create_histogram[HZ];
49753 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49754 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49755 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49756
49757 extern int __init cachefiles_proc_init(void);
49758 extern void cachefiles_proc_cleanup(void);
49759 static inline
49760 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49761 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49762 {
49763 unsigned long jif = jiffies - start_jif;
49764 if (jif >= HZ)
49765 jif = HZ - 1;
49766 - atomic_inc(&histogram[jif]);
49767 + atomic_inc_unchecked(&histogram[jif]);
49768 }
49769
49770 #else
49771 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49772 index 8c01c5fc..15f982e 100644
49773 --- a/fs/cachefiles/namei.c
49774 +++ b/fs/cachefiles/namei.c
49775 @@ -317,7 +317,7 @@ try_again:
49776 /* first step is to make up a grave dentry in the graveyard */
49777 sprintf(nbuffer, "%08x%08x",
49778 (uint32_t) get_seconds(),
49779 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49780 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49781
49782 /* do the multiway lock magic */
49783 trap = lock_rename(cache->graveyard, dir);
49784 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49785 index eccd339..4c1d995 100644
49786 --- a/fs/cachefiles/proc.c
49787 +++ b/fs/cachefiles/proc.c
49788 @@ -14,9 +14,9 @@
49789 #include <linux/seq_file.h>
49790 #include "internal.h"
49791
49792 -atomic_t cachefiles_lookup_histogram[HZ];
49793 -atomic_t cachefiles_mkdir_histogram[HZ];
49794 -atomic_t cachefiles_create_histogram[HZ];
49795 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49796 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49797 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49798
49799 /*
49800 * display the latency histogram
49801 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49802 return 0;
49803 default:
49804 index = (unsigned long) v - 3;
49805 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49806 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49807 - z = atomic_read(&cachefiles_create_histogram[index]);
49808 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49809 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49810 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49811 if (x == 0 && y == 0 && z == 0)
49812 return 0;
49813
49814 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49815 index 4809922..aab2c39 100644
49816 --- a/fs/cachefiles/rdwr.c
49817 +++ b/fs/cachefiles/rdwr.c
49818 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49819 old_fs = get_fs();
49820 set_fs(KERNEL_DS);
49821 ret = file->f_op->write(
49822 - file, (const void __user *) data, len, &pos);
49823 + file, (const void __force_user *) data, len, &pos);
49824 set_fs(old_fs);
49825 kunmap(page);
49826 if (ret != len)
49827 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49828 index 8c1aabe..bbf856a 100644
49829 --- a/fs/ceph/dir.c
49830 +++ b/fs/ceph/dir.c
49831 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49832 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49833 struct ceph_mds_client *mdsc = fsc->mdsc;
49834 unsigned frag = fpos_frag(filp->f_pos);
49835 - int off = fpos_off(filp->f_pos);
49836 + unsigned int off = fpos_off(filp->f_pos);
49837 int err;
49838 u32 ftype;
49839 struct ceph_mds_reply_info_parsed *rinfo;
49840 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49841 index d9ea6ed..1e6c8ac 100644
49842 --- a/fs/cifs/cifs_debug.c
49843 +++ b/fs/cifs/cifs_debug.c
49844 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49845
49846 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49847 #ifdef CONFIG_CIFS_STATS2
49848 - atomic_set(&totBufAllocCount, 0);
49849 - atomic_set(&totSmBufAllocCount, 0);
49850 + atomic_set_unchecked(&totBufAllocCount, 0);
49851 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49852 #endif /* CONFIG_CIFS_STATS2 */
49853 spin_lock(&cifs_tcp_ses_lock);
49854 list_for_each(tmp1, &cifs_tcp_ses_list) {
49855 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49856 tcon = list_entry(tmp3,
49857 struct cifs_tcon,
49858 tcon_list);
49859 - atomic_set(&tcon->num_smbs_sent, 0);
49860 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49861 if (server->ops->clear_stats)
49862 server->ops->clear_stats(tcon);
49863 }
49864 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49865 smBufAllocCount.counter, cifs_min_small);
49866 #ifdef CONFIG_CIFS_STATS2
49867 seq_printf(m, "Total Large %d Small %d Allocations\n",
49868 - atomic_read(&totBufAllocCount),
49869 - atomic_read(&totSmBufAllocCount));
49870 + atomic_read_unchecked(&totBufAllocCount),
49871 + atomic_read_unchecked(&totSmBufAllocCount));
49872 #endif /* CONFIG_CIFS_STATS2 */
49873
49874 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49875 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49876 if (tcon->need_reconnect)
49877 seq_puts(m, "\tDISCONNECTED ");
49878 seq_printf(m, "\nSMBs: %d",
49879 - atomic_read(&tcon->num_smbs_sent));
49880 + atomic_read_unchecked(&tcon->num_smbs_sent));
49881 if (server->ops->print_stats)
49882 server->ops->print_stats(m, tcon);
49883 }
49884 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49885 index b9db388..9a73d6d 100644
49886 --- a/fs/cifs/cifsfs.c
49887 +++ b/fs/cifs/cifsfs.c
49888 @@ -1026,7 +1026,7 @@ cifs_init_request_bufs(void)
49889 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49890 cifs_req_cachep = kmem_cache_create("cifs_request",
49891 CIFSMaxBufSize + max_hdr_size, 0,
49892 - SLAB_HWCACHE_ALIGN, NULL);
49893 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49894 if (cifs_req_cachep == NULL)
49895 return -ENOMEM;
49896
49897 @@ -1053,7 +1053,7 @@ cifs_init_request_bufs(void)
49898 efficient to alloc 1 per page off the slab compared to 17K (5page)
49899 alloc of large cifs buffers even when page debugging is on */
49900 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49901 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49902 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49903 NULL);
49904 if (cifs_sm_req_cachep == NULL) {
49905 mempool_destroy(cifs_req_poolp);
49906 @@ -1138,8 +1138,8 @@ init_cifs(void)
49907 atomic_set(&bufAllocCount, 0);
49908 atomic_set(&smBufAllocCount, 0);
49909 #ifdef CONFIG_CIFS_STATS2
49910 - atomic_set(&totBufAllocCount, 0);
49911 - atomic_set(&totSmBufAllocCount, 0);
49912 + atomic_set_unchecked(&totBufAllocCount, 0);
49913 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49914 #endif /* CONFIG_CIFS_STATS2 */
49915
49916 atomic_set(&midCount, 0);
49917 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49918 index e6899ce..d6b2920 100644
49919 --- a/fs/cifs/cifsglob.h
49920 +++ b/fs/cifs/cifsglob.h
49921 @@ -751,35 +751,35 @@ struct cifs_tcon {
49922 __u16 Flags; /* optional support bits */
49923 enum statusEnum tidStatus;
49924 #ifdef CONFIG_CIFS_STATS
49925 - atomic_t num_smbs_sent;
49926 + atomic_unchecked_t num_smbs_sent;
49927 union {
49928 struct {
49929 - atomic_t num_writes;
49930 - atomic_t num_reads;
49931 - atomic_t num_flushes;
49932 - atomic_t num_oplock_brks;
49933 - atomic_t num_opens;
49934 - atomic_t num_closes;
49935 - atomic_t num_deletes;
49936 - atomic_t num_mkdirs;
49937 - atomic_t num_posixopens;
49938 - atomic_t num_posixmkdirs;
49939 - atomic_t num_rmdirs;
49940 - atomic_t num_renames;
49941 - atomic_t num_t2renames;
49942 - atomic_t num_ffirst;
49943 - atomic_t num_fnext;
49944 - atomic_t num_fclose;
49945 - atomic_t num_hardlinks;
49946 - atomic_t num_symlinks;
49947 - atomic_t num_locks;
49948 - atomic_t num_acl_get;
49949 - atomic_t num_acl_set;
49950 + atomic_unchecked_t num_writes;
49951 + atomic_unchecked_t num_reads;
49952 + atomic_unchecked_t num_flushes;
49953 + atomic_unchecked_t num_oplock_brks;
49954 + atomic_unchecked_t num_opens;
49955 + atomic_unchecked_t num_closes;
49956 + atomic_unchecked_t num_deletes;
49957 + atomic_unchecked_t num_mkdirs;
49958 + atomic_unchecked_t num_posixopens;
49959 + atomic_unchecked_t num_posixmkdirs;
49960 + atomic_unchecked_t num_rmdirs;
49961 + atomic_unchecked_t num_renames;
49962 + atomic_unchecked_t num_t2renames;
49963 + atomic_unchecked_t num_ffirst;
49964 + atomic_unchecked_t num_fnext;
49965 + atomic_unchecked_t num_fclose;
49966 + atomic_unchecked_t num_hardlinks;
49967 + atomic_unchecked_t num_symlinks;
49968 + atomic_unchecked_t num_locks;
49969 + atomic_unchecked_t num_acl_get;
49970 + atomic_unchecked_t num_acl_set;
49971 } cifs_stats;
49972 #ifdef CONFIG_CIFS_SMB2
49973 struct {
49974 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49975 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49976 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49977 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49978 } smb2_stats;
49979 #endif /* CONFIG_CIFS_SMB2 */
49980 } stats;
49981 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49982 }
49983
49984 #ifdef CONFIG_CIFS_STATS
49985 -#define cifs_stats_inc atomic_inc
49986 +#define cifs_stats_inc atomic_inc_unchecked
49987
49988 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49989 unsigned int bytes)
49990 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49991 /* Various Debug counters */
49992 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49993 #ifdef CONFIG_CIFS_STATS2
49994 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49995 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49996 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49997 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49998 #endif
49999 GLOBAL_EXTERN atomic_t smBufAllocCount;
50000 GLOBAL_EXTERN atomic_t midCount;
50001 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
50002 index 51dc2fb..1e12a33 100644
50003 --- a/fs/cifs/link.c
50004 +++ b/fs/cifs/link.c
50005 @@ -616,7 +616,7 @@ symlink_exit:
50006
50007 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
50008 {
50009 - char *p = nd_get_link(nd);
50010 + const char *p = nd_get_link(nd);
50011 if (!IS_ERR(p))
50012 kfree(p);
50013 }
50014 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
50015 index 3a00c0d..42d901c 100644
50016 --- a/fs/cifs/misc.c
50017 +++ b/fs/cifs/misc.c
50018 @@ -169,7 +169,7 @@ cifs_buf_get(void)
50019 memset(ret_buf, 0, buf_size + 3);
50020 atomic_inc(&bufAllocCount);
50021 #ifdef CONFIG_CIFS_STATS2
50022 - atomic_inc(&totBufAllocCount);
50023 + atomic_inc_unchecked(&totBufAllocCount);
50024 #endif /* CONFIG_CIFS_STATS2 */
50025 }
50026
50027 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
50028 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
50029 atomic_inc(&smBufAllocCount);
50030 #ifdef CONFIG_CIFS_STATS2
50031 - atomic_inc(&totSmBufAllocCount);
50032 + atomic_inc_unchecked(&totSmBufAllocCount);
50033 #endif /* CONFIG_CIFS_STATS2 */
50034
50035 }
50036 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50037 index 47bc5a8..10decbe 100644
50038 --- a/fs/cifs/smb1ops.c
50039 +++ b/fs/cifs/smb1ops.c
50040 @@ -586,27 +586,27 @@ static void
50041 cifs_clear_stats(struct cifs_tcon *tcon)
50042 {
50043 #ifdef CONFIG_CIFS_STATS
50044 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50045 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50046 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50047 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50048 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50049 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50050 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50051 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50052 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50053 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50054 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50055 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50056 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50057 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50058 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50059 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50060 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50061 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50062 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50063 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50064 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50065 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50066 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50067 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50068 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50069 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50070 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50071 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50072 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50073 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50074 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50075 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50076 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50077 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50078 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50079 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50080 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50081 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50082 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50083 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50084 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50085 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50086 #endif
50087 }
50088
50089 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50090 {
50091 #ifdef CONFIG_CIFS_STATS
50092 seq_printf(m, " Oplocks breaks: %d",
50093 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50094 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50095 seq_printf(m, "\nReads: %d Bytes: %llu",
50096 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50097 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50098 (long long)(tcon->bytes_read));
50099 seq_printf(m, "\nWrites: %d Bytes: %llu",
50100 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50101 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50102 (long long)(tcon->bytes_written));
50103 seq_printf(m, "\nFlushes: %d",
50104 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50105 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50106 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50107 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50108 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50109 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50110 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50111 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50112 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50113 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50114 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50115 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50116 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50117 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50118 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50119 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50120 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50121 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50122 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50123 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50124 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50125 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50126 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50127 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50128 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50129 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50130 seq_printf(m, "\nRenames: %d T2 Renames %d",
50131 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50132 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50133 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50134 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50135 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50136 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50137 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50138 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50139 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50140 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50141 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50142 #endif
50143 }
50144
50145 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50146 index bceffe7..cd1ae59 100644
50147 --- a/fs/cifs/smb2ops.c
50148 +++ b/fs/cifs/smb2ops.c
50149 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50150 #ifdef CONFIG_CIFS_STATS
50151 int i;
50152 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50153 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50154 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50155 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50156 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50157 }
50158 #endif
50159 }
50160 @@ -284,66 +284,66 @@ static void
50161 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50162 {
50163 #ifdef CONFIG_CIFS_STATS
50164 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50165 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50166 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50167 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50168 seq_printf(m, "\nNegotiates: %d sent %d failed",
50169 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50170 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50171 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50172 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50173 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50174 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50175 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50176 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50177 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50178 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50179 seq_printf(m, "\nLogoffs: %d sent %d failed",
50180 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50181 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50182 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50183 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50184 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50185 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50186 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50187 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50188 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50189 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50190 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50191 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50192 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50193 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50194 seq_printf(m, "\nCreates: %d sent %d failed",
50195 - atomic_read(&sent[SMB2_CREATE_HE]),
50196 - atomic_read(&failed[SMB2_CREATE_HE]));
50197 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50198 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50199 seq_printf(m, "\nCloses: %d sent %d failed",
50200 - atomic_read(&sent[SMB2_CLOSE_HE]),
50201 - atomic_read(&failed[SMB2_CLOSE_HE]));
50202 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50203 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50204 seq_printf(m, "\nFlushes: %d sent %d failed",
50205 - atomic_read(&sent[SMB2_FLUSH_HE]),
50206 - atomic_read(&failed[SMB2_FLUSH_HE]));
50207 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50208 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50209 seq_printf(m, "\nReads: %d sent %d failed",
50210 - atomic_read(&sent[SMB2_READ_HE]),
50211 - atomic_read(&failed[SMB2_READ_HE]));
50212 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50213 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50214 seq_printf(m, "\nWrites: %d sent %d failed",
50215 - atomic_read(&sent[SMB2_WRITE_HE]),
50216 - atomic_read(&failed[SMB2_WRITE_HE]));
50217 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50218 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50219 seq_printf(m, "\nLocks: %d sent %d failed",
50220 - atomic_read(&sent[SMB2_LOCK_HE]),
50221 - atomic_read(&failed[SMB2_LOCK_HE]));
50222 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50223 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50224 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50225 - atomic_read(&sent[SMB2_IOCTL_HE]),
50226 - atomic_read(&failed[SMB2_IOCTL_HE]));
50227 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50228 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50229 seq_printf(m, "\nCancels: %d sent %d failed",
50230 - atomic_read(&sent[SMB2_CANCEL_HE]),
50231 - atomic_read(&failed[SMB2_CANCEL_HE]));
50232 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50233 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50234 seq_printf(m, "\nEchos: %d sent %d failed",
50235 - atomic_read(&sent[SMB2_ECHO_HE]),
50236 - atomic_read(&failed[SMB2_ECHO_HE]));
50237 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50238 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50239 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50240 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50241 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50242 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50243 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50244 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50245 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50246 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50247 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50248 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50249 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50250 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50251 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50252 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50253 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50254 seq_printf(m, "\nSetInfos: %d sent %d failed",
50255 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50256 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50257 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50258 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50259 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50260 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50261 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50262 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50263 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50264 #endif
50265 }
50266
50267 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50268 index 41d9d07..dbb4772 100644
50269 --- a/fs/cifs/smb2pdu.c
50270 +++ b/fs/cifs/smb2pdu.c
50271 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50272 default:
50273 cERROR(1, "info level %u isn't supported",
50274 srch_inf->info_level);
50275 - rc = -EINVAL;
50276 - goto qdir_exit;
50277 + return -EINVAL;
50278 }
50279
50280 req->FileIndex = cpu_to_le32(index);
50281 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50282 index 958ae0e..505c9d0 100644
50283 --- a/fs/coda/cache.c
50284 +++ b/fs/coda/cache.c
50285 @@ -24,7 +24,7 @@
50286 #include "coda_linux.h"
50287 #include "coda_cache.h"
50288
50289 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50290 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50291
50292 /* replace or extend an acl cache hit */
50293 void coda_cache_enter(struct inode *inode, int mask)
50294 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50295 struct coda_inode_info *cii = ITOC(inode);
50296
50297 spin_lock(&cii->c_lock);
50298 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50299 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50300 if (cii->c_uid != current_fsuid()) {
50301 cii->c_uid = current_fsuid();
50302 cii->c_cached_perm = mask;
50303 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50304 {
50305 struct coda_inode_info *cii = ITOC(inode);
50306 spin_lock(&cii->c_lock);
50307 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50308 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50309 spin_unlock(&cii->c_lock);
50310 }
50311
50312 /* remove all acl caches */
50313 void coda_cache_clear_all(struct super_block *sb)
50314 {
50315 - atomic_inc(&permission_epoch);
50316 + atomic_inc_unchecked(&permission_epoch);
50317 }
50318
50319
50320 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50321 spin_lock(&cii->c_lock);
50322 hit = (mask & cii->c_cached_perm) == mask &&
50323 cii->c_uid == current_fsuid() &&
50324 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50325 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50326 spin_unlock(&cii->c_lock);
50327
50328 return hit;
50329 diff --git a/fs/compat.c b/fs/compat.c
50330 index a06dcbc..dacb6d3 100644
50331 --- a/fs/compat.c
50332 +++ b/fs/compat.c
50333 @@ -54,7 +54,7 @@
50334 #include <asm/ioctls.h>
50335 #include "internal.h"
50336
50337 -int compat_log = 1;
50338 +int compat_log = 0;
50339
50340 int compat_printk(const char *fmt, ...)
50341 {
50342 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50343
50344 set_fs(KERNEL_DS);
50345 /* The __user pointer cast is valid because of the set_fs() */
50346 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50347 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50348 set_fs(oldfs);
50349 /* truncating is ok because it's a user address */
50350 if (!ret)
50351 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50352 goto out;
50353
50354 ret = -EINVAL;
50355 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50356 + if (nr_segs > UIO_MAXIOV)
50357 goto out;
50358 if (nr_segs > fast_segs) {
50359 ret = -ENOMEM;
50360 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50361
50362 struct compat_readdir_callback {
50363 struct compat_old_linux_dirent __user *dirent;
50364 + struct file * file;
50365 int result;
50366 };
50367
50368 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50369 buf->result = -EOVERFLOW;
50370 return -EOVERFLOW;
50371 }
50372 +
50373 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50374 + return 0;
50375 +
50376 buf->result++;
50377 dirent = buf->dirent;
50378 if (!access_ok(VERIFY_WRITE, dirent,
50379 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50380
50381 buf.result = 0;
50382 buf.dirent = dirent;
50383 + buf.file = f.file;
50384
50385 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50386 if (buf.result)
50387 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50388 struct compat_getdents_callback {
50389 struct compat_linux_dirent __user *current_dir;
50390 struct compat_linux_dirent __user *previous;
50391 + struct file * file;
50392 int count;
50393 int error;
50394 };
50395 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50396 buf->error = -EOVERFLOW;
50397 return -EOVERFLOW;
50398 }
50399 +
50400 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50401 + return 0;
50402 +
50403 dirent = buf->previous;
50404 if (dirent) {
50405 if (__put_user(offset, &dirent->d_off))
50406 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50407 buf.previous = NULL;
50408 buf.count = count;
50409 buf.error = 0;
50410 + buf.file = f.file;
50411
50412 error = vfs_readdir(f.file, compat_filldir, &buf);
50413 if (error >= 0)
50414 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50415 struct compat_getdents_callback64 {
50416 struct linux_dirent64 __user *current_dir;
50417 struct linux_dirent64 __user *previous;
50418 + struct file * file;
50419 int count;
50420 int error;
50421 };
50422 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50423 buf->error = -EINVAL; /* only used if we fail.. */
50424 if (reclen > buf->count)
50425 return -EINVAL;
50426 +
50427 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50428 + return 0;
50429 +
50430 dirent = buf->previous;
50431
50432 if (dirent) {
50433 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50434 buf.previous = NULL;
50435 buf.count = count;
50436 buf.error = 0;
50437 + buf.file = f.file;
50438
50439 error = vfs_readdir(f.file, compat_filldir64, &buf);
50440 if (error >= 0)
50441 error = buf.error;
50442 lastdirent = buf.previous;
50443 if (lastdirent) {
50444 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50445 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50446 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50447 error = -EFAULT;
50448 else
50449 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50450 index a81147e..20bf2b5 100644
50451 --- a/fs/compat_binfmt_elf.c
50452 +++ b/fs/compat_binfmt_elf.c
50453 @@ -30,11 +30,13 @@
50454 #undef elf_phdr
50455 #undef elf_shdr
50456 #undef elf_note
50457 +#undef elf_dyn
50458 #undef elf_addr_t
50459 #define elfhdr elf32_hdr
50460 #define elf_phdr elf32_phdr
50461 #define elf_shdr elf32_shdr
50462 #define elf_note elf32_note
50463 +#define elf_dyn Elf32_Dyn
50464 #define elf_addr_t Elf32_Addr
50465
50466 /*
50467 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50468 index e2f57a0..3c78771 100644
50469 --- a/fs/compat_ioctl.c
50470 +++ b/fs/compat_ioctl.c
50471 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50472 return -EFAULT;
50473 if (__get_user(udata, &ss32->iomem_base))
50474 return -EFAULT;
50475 - ss.iomem_base = compat_ptr(udata);
50476 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50477 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50478 __get_user(ss.port_high, &ss32->port_high))
50479 return -EFAULT;
50480 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50481 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50482 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50483 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50484 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50485 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50486 return -EFAULT;
50487
50488 return ioctl_preallocate(file, p);
50489 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50490 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50491 {
50492 unsigned int a, b;
50493 - a = *(unsigned int *)p;
50494 - b = *(unsigned int *)q;
50495 + a = *(const unsigned int *)p;
50496 + b = *(const unsigned int *)q;
50497 if (a > b)
50498 return 1;
50499 if (a < b)
50500 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50501 index 712b10f..c33c4ca 100644
50502 --- a/fs/configfs/dir.c
50503 +++ b/fs/configfs/dir.c
50504 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
50505 static int configfs_depend_prep(struct dentry *origin,
50506 struct config_item *target)
50507 {
50508 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
50509 + struct configfs_dirent *child_sd, *sd;
50510 int ret = 0;
50511
50512 - BUG_ON(!origin || !sd);
50513 + BUG_ON(!origin || !origin->d_fsdata);
50514 + sd = origin->d_fsdata;
50515
50516 if (sd->s_element == target) /* Boo-yah */
50517 goto out;
50518 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50519 }
50520 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50521 struct configfs_dirent *next;
50522 - const char * name;
50523 + const unsigned char * name;
50524 + char d_name[sizeof(next->s_dentry->d_iname)];
50525 int len;
50526 struct inode *inode = NULL;
50527
50528 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50529 continue;
50530
50531 name = configfs_get_name(next);
50532 - len = strlen(name);
50533 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50534 + len = next->s_dentry->d_name.len;
50535 + memcpy(d_name, name, len);
50536 + name = d_name;
50537 + } else
50538 + len = strlen(name);
50539
50540 /*
50541 * We'll have a dentry and an inode for
50542 diff --git a/fs/coredump.c b/fs/coredump.c
50543 index 1774932..5812106 100644
50544 --- a/fs/coredump.c
50545 +++ b/fs/coredump.c
50546 @@ -52,7 +52,7 @@ struct core_name {
50547 char *corename;
50548 int used, size;
50549 };
50550 -static atomic_t call_count = ATOMIC_INIT(1);
50551 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50552
50553 /* The maximal length of core_pattern is also specified in sysctl.c */
50554
50555 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50556 {
50557 char *old_corename = cn->corename;
50558
50559 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50560 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50561 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50562
50563 if (!cn->corename) {
50564 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50565 int pid_in_pattern = 0;
50566 int err = 0;
50567
50568 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50569 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50570 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50571 cn->used = 0;
50572
50573 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50574 pipe = file->f_path.dentry->d_inode->i_pipe;
50575
50576 pipe_lock(pipe);
50577 - pipe->readers++;
50578 - pipe->writers--;
50579 + atomic_inc(&pipe->readers);
50580 + atomic_dec(&pipe->writers);
50581
50582 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50583 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50584 wake_up_interruptible_sync(&pipe->wait);
50585 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50586 pipe_wait(pipe);
50587 }
50588
50589 - pipe->readers--;
50590 - pipe->writers++;
50591 + atomic_dec(&pipe->readers);
50592 + atomic_inc(&pipe->writers);
50593 pipe_unlock(pipe);
50594
50595 }
50596 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50597 int ispipe;
50598 struct files_struct *displaced;
50599 bool need_nonrelative = false;
50600 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50601 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50602 + long signr = siginfo->si_signo;
50603 struct coredump_params cprm = {
50604 .siginfo = siginfo,
50605 .regs = signal_pt_regs(),
50606 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50607 .mm_flags = mm->flags,
50608 };
50609
50610 - audit_core_dumps(siginfo->si_signo);
50611 + audit_core_dumps(signr);
50612 +
50613 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50614 + gr_handle_brute_attach(cprm.mm_flags);
50615
50616 binfmt = mm->binfmt;
50617 if (!binfmt || !binfmt->core_dump)
50618 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50619 need_nonrelative = true;
50620 }
50621
50622 - retval = coredump_wait(siginfo->si_signo, &core_state);
50623 + retval = coredump_wait(signr, &core_state);
50624 if (retval < 0)
50625 goto fail_creds;
50626
50627 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50628 }
50629 cprm.limit = RLIM_INFINITY;
50630
50631 - dump_count = atomic_inc_return(&core_dump_count);
50632 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50633 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50634 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50635 task_tgid_vnr(current), current->comm);
50636 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50637 } else {
50638 struct inode *inode;
50639
50640 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50641 +
50642 if (cprm.limit < binfmt->min_coredump)
50643 goto fail_unlock;
50644
50645 @@ -640,7 +646,7 @@ close_fail:
50646 filp_close(cprm.file, NULL);
50647 fail_dropcount:
50648 if (ispipe)
50649 - atomic_dec(&core_dump_count);
50650 + atomic_dec_unchecked(&core_dump_count);
50651 fail_unlock:
50652 kfree(cn.corename);
50653 fail_corename:
50654 @@ -659,7 +665,7 @@ fail:
50655 */
50656 int dump_write(struct file *file, const void *addr, int nr)
50657 {
50658 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50659 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50660 }
50661 EXPORT_SYMBOL(dump_write);
50662
50663 diff --git a/fs/dcache.c b/fs/dcache.c
50664 index c3bbf85..5b71101 100644
50665 --- a/fs/dcache.c
50666 +++ b/fs/dcache.c
50667 @@ -3139,7 +3139,7 @@ void __init vfs_caches_init(unsigned long mempages)
50668 mempages -= reserve;
50669
50670 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50671 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50672 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50673
50674 dcache_init();
50675 inode_init();
50676 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50677 index a5f12b7..4ee8a6f 100644
50678 --- a/fs/debugfs/inode.c
50679 +++ b/fs/debugfs/inode.c
50680 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50681 */
50682 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50683 {
50684 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50685 + return __create_file(name, S_IFDIR | S_IRWXU,
50686 +#else
50687 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50688 +#endif
50689 parent, NULL, NULL);
50690 }
50691 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50692 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50693 index cc7709e..7e7211f 100644
50694 --- a/fs/ecryptfs/inode.c
50695 +++ b/fs/ecryptfs/inode.c
50696 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50697 old_fs = get_fs();
50698 set_fs(get_ds());
50699 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50700 - (char __user *)lower_buf,
50701 + (char __force_user *)lower_buf,
50702 PATH_MAX);
50703 set_fs(old_fs);
50704 if (rc < 0)
50705 @@ -706,7 +706,7 @@ out:
50706 static void
50707 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50708 {
50709 - char *buf = nd_get_link(nd);
50710 + const char *buf = nd_get_link(nd);
50711 if (!IS_ERR(buf)) {
50712 /* Free the char* */
50713 kfree(buf);
50714 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50715 index 412e6ed..d8263e8 100644
50716 --- a/fs/ecryptfs/miscdev.c
50717 +++ b/fs/ecryptfs/miscdev.c
50718 @@ -80,13 +80,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50719 int rc;
50720
50721 mutex_lock(&ecryptfs_daemon_hash_mux);
50722 - rc = try_module_get(THIS_MODULE);
50723 - if (rc == 0) {
50724 - rc = -EIO;
50725 - printk(KERN_ERR "%s: Error attempting to increment module use "
50726 - "count; rc = [%d]\n", __func__, rc);
50727 - goto out_unlock_daemon_list;
50728 - }
50729 rc = ecryptfs_find_daemon_by_euid(&daemon);
50730 if (!rc) {
50731 rc = -EINVAL;
50732 @@ -96,7 +89,7 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50733 if (rc) {
50734 printk(KERN_ERR "%s: Error attempting to spawn daemon; "
50735 "rc = [%d]\n", __func__, rc);
50736 - goto out_module_put_unlock_daemon_list;
50737 + goto out_unlock_daemon_list;
50738 }
50739 mutex_lock(&daemon->mux);
50740 if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) {
50741 @@ -108,9 +101,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50742 atomic_inc(&ecryptfs_num_miscdev_opens);
50743 out_unlock_daemon:
50744 mutex_unlock(&daemon->mux);
50745 -out_module_put_unlock_daemon_list:
50746 - if (rc)
50747 - module_put(THIS_MODULE);
50748 out_unlock_daemon_list:
50749 mutex_unlock(&ecryptfs_daemon_hash_mux);
50750 return rc;
50751 @@ -147,7 +137,6 @@ ecryptfs_miscdev_release(struct inode *inode, struct file *file)
50752 "bug.\n", __func__, rc);
50753 BUG();
50754 }
50755 - module_put(THIS_MODULE);
50756 return rc;
50757 }
50758
50759 @@ -315,7 +304,7 @@ check_list:
50760 goto out_unlock_msg_ctx;
50761 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50762 if (msg_ctx->msg) {
50763 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50764 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50765 goto out_unlock_msg_ctx;
50766 i += packet_length_size;
50767 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50768 @@ -471,6 +460,7 @@ out_free:
50769
50770
50771 static const struct file_operations ecryptfs_miscdev_fops = {
50772 + .owner = THIS_MODULE,
50773 .open = ecryptfs_miscdev_open,
50774 .poll = ecryptfs_miscdev_poll,
50775 .read = ecryptfs_miscdev_read,
50776 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50777 index b2a34a1..162fa69 100644
50778 --- a/fs/ecryptfs/read_write.c
50779 +++ b/fs/ecryptfs/read_write.c
50780 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
50781 return -EIO;
50782 fs_save = get_fs();
50783 set_fs(get_ds());
50784 - rc = vfs_write(lower_file, data, size, &offset);
50785 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
50786 set_fs(fs_save);
50787 mark_inode_dirty_sync(ecryptfs_inode);
50788 return rc;
50789 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50790 return -EIO;
50791 fs_save = get_fs();
50792 set_fs(get_ds());
50793 - rc = vfs_read(lower_file, data, size, &offset);
50794 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50795 set_fs(fs_save);
50796 return rc;
50797 }
50798 diff --git a/fs/exec.c b/fs/exec.c
50799 index 20df02c..9a87617 100644
50800 --- a/fs/exec.c
50801 +++ b/fs/exec.c
50802 @@ -55,8 +55,20 @@
50803 #include <linux/pipe_fs_i.h>
50804 #include <linux/oom.h>
50805 #include <linux/compat.h>
50806 +#include <linux/random.h>
50807 +#include <linux/seq_file.h>
50808 +#include <linux/coredump.h>
50809 +#include <linux/mman.h>
50810 +
50811 +#ifdef CONFIG_PAX_REFCOUNT
50812 +#include <linux/kallsyms.h>
50813 +#include <linux/kdebug.h>
50814 +#endif
50815 +
50816 +#include <trace/events/fs.h>
50817
50818 #include <asm/uaccess.h>
50819 +#include <asm/sections.h>
50820 #include <asm/mmu_context.h>
50821 #include <asm/tlb.h>
50822
50823 @@ -66,6 +78,18 @@
50824
50825 #include <trace/events/sched.h>
50826
50827 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50828 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50829 +{
50830 + 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");
50831 +}
50832 +#endif
50833 +
50834 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50835 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50836 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50837 +#endif
50838 +
50839 int suid_dumpable = 0;
50840
50841 static LIST_HEAD(formats);
50842 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50843 {
50844 BUG_ON(!fmt);
50845 write_lock(&binfmt_lock);
50846 - insert ? list_add(&fmt->lh, &formats) :
50847 - list_add_tail(&fmt->lh, &formats);
50848 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50849 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50850 write_unlock(&binfmt_lock);
50851 }
50852
50853 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
50854 void unregister_binfmt(struct linux_binfmt * fmt)
50855 {
50856 write_lock(&binfmt_lock);
50857 - list_del(&fmt->lh);
50858 + pax_list_del((struct list_head *)&fmt->lh);
50859 write_unlock(&binfmt_lock);
50860 }
50861
50862 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50863 int write)
50864 {
50865 struct page *page;
50866 - int ret;
50867
50868 -#ifdef CONFIG_STACK_GROWSUP
50869 - if (write) {
50870 - ret = expand_downwards(bprm->vma, pos);
50871 - if (ret < 0)
50872 - return NULL;
50873 - }
50874 -#endif
50875 - ret = get_user_pages(current, bprm->mm, pos,
50876 - 1, write, 1, &page, NULL);
50877 - if (ret <= 0)
50878 + if (0 > expand_downwards(bprm->vma, pos))
50879 + return NULL;
50880 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50881 return NULL;
50882
50883 if (write) {
50884 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50885 if (size <= ARG_MAX)
50886 return page;
50887
50888 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50889 + // only allow 512KB for argv+env on suid/sgid binaries
50890 + // to prevent easy ASLR exhaustion
50891 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50892 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50893 + (size > (512 * 1024))) {
50894 + put_page(page);
50895 + return NULL;
50896 + }
50897 +#endif
50898 +
50899 /*
50900 * Limit to 1/4-th the stack size for the argv+env strings.
50901 * This ensures that:
50902 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50903 vma->vm_end = STACK_TOP_MAX;
50904 vma->vm_start = vma->vm_end - PAGE_SIZE;
50905 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50906 +
50907 +#ifdef CONFIG_PAX_SEGMEXEC
50908 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50909 +#endif
50910 +
50911 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50912 INIT_LIST_HEAD(&vma->anon_vma_chain);
50913
50914 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50915 mm->stack_vm = mm->total_vm = 1;
50916 up_write(&mm->mmap_sem);
50917 bprm->p = vma->vm_end - sizeof(void *);
50918 +
50919 +#ifdef CONFIG_PAX_RANDUSTACK
50920 + if (randomize_va_space)
50921 + bprm->p ^= random32() & ~PAGE_MASK;
50922 +#endif
50923 +
50924 return 0;
50925 err:
50926 up_write(&mm->mmap_sem);
50927 @@ -396,7 +434,7 @@ struct user_arg_ptr {
50928 } ptr;
50929 };
50930
50931 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50932 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50933 {
50934 const char __user *native;
50935
50936 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50937 compat_uptr_t compat;
50938
50939 if (get_user(compat, argv.ptr.compat + nr))
50940 - return ERR_PTR(-EFAULT);
50941 + return (const char __force_user *)ERR_PTR(-EFAULT);
50942
50943 return compat_ptr(compat);
50944 }
50945 #endif
50946
50947 if (get_user(native, argv.ptr.native + nr))
50948 - return ERR_PTR(-EFAULT);
50949 + return (const char __force_user *)ERR_PTR(-EFAULT);
50950
50951 return native;
50952 }
50953 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
50954 if (!p)
50955 break;
50956
50957 - if (IS_ERR(p))
50958 + if (IS_ERR((const char __force_kernel *)p))
50959 return -EFAULT;
50960
50961 if (i >= max)
50962 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50963
50964 ret = -EFAULT;
50965 str = get_user_arg_ptr(argv, argc);
50966 - if (IS_ERR(str))
50967 + if (IS_ERR((const char __force_kernel *)str))
50968 goto out;
50969
50970 len = strnlen_user(str, MAX_ARG_STRLEN);
50971 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50972 int r;
50973 mm_segment_t oldfs = get_fs();
50974 struct user_arg_ptr argv = {
50975 - .ptr.native = (const char __user *const __user *)__argv,
50976 + .ptr.native = (const char __force_user *const __force_user *)__argv,
50977 };
50978
50979 set_fs(KERNEL_DS);
50980 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50981 unsigned long new_end = old_end - shift;
50982 struct mmu_gather tlb;
50983
50984 - BUG_ON(new_start > new_end);
50985 + if (new_start >= new_end || new_start < mmap_min_addr)
50986 + return -ENOMEM;
50987
50988 /*
50989 * ensure there are no vmas between where we want to go
50990 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50991 if (vma != find_vma(mm, new_start))
50992 return -EFAULT;
50993
50994 +#ifdef CONFIG_PAX_SEGMEXEC
50995 + BUG_ON(pax_find_mirror_vma(vma));
50996 +#endif
50997 +
50998 /*
50999 * cover the whole range: [new_start, old_end)
51000 */
51001 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51002 stack_top = arch_align_stack(stack_top);
51003 stack_top = PAGE_ALIGN(stack_top);
51004
51005 - if (unlikely(stack_top < mmap_min_addr) ||
51006 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
51007 - return -ENOMEM;
51008 -
51009 stack_shift = vma->vm_end - stack_top;
51010
51011 bprm->p -= stack_shift;
51012 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
51013 bprm->exec -= stack_shift;
51014
51015 down_write(&mm->mmap_sem);
51016 +
51017 + /* Move stack pages down in memory. */
51018 + if (stack_shift) {
51019 + ret = shift_arg_pages(vma, stack_shift);
51020 + if (ret)
51021 + goto out_unlock;
51022 + }
51023 +
51024 vm_flags = VM_STACK_FLAGS;
51025
51026 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51027 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51028 + vm_flags &= ~VM_EXEC;
51029 +
51030 +#ifdef CONFIG_PAX_MPROTECT
51031 + if (mm->pax_flags & MF_PAX_MPROTECT)
51032 + vm_flags &= ~VM_MAYEXEC;
51033 +#endif
51034 +
51035 + }
51036 +#endif
51037 +
51038 /*
51039 * Adjust stack execute permissions; explicitly enable for
51040 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
51041 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51042 goto out_unlock;
51043 BUG_ON(prev != vma);
51044
51045 - /* Move stack pages down in memory. */
51046 - if (stack_shift) {
51047 - ret = shift_arg_pages(vma, stack_shift);
51048 - if (ret)
51049 - goto out_unlock;
51050 - }
51051 -
51052 /* mprotect_fixup is overkill to remove the temporary stack flags */
51053 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
51054
51055 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
51056 #endif
51057 current->mm->start_stack = bprm->p;
51058 ret = expand_stack(vma, stack_base);
51059 +
51060 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
51061 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
51062 + unsigned long size, flags, vm_flags;
51063 +
51064 + size = STACK_TOP - vma->vm_end;
51065 + flags = MAP_FIXED | MAP_PRIVATE;
51066 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
51067 +
51068 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
51069 +
51070 +#ifdef CONFIG_X86
51071 + if (!ret) {
51072 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
51073 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
51074 + }
51075 +#endif
51076 +
51077 + }
51078 +#endif
51079 +
51080 if (ret)
51081 ret = -EFAULT;
51082
51083 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
51084
51085 fsnotify_open(file);
51086
51087 + trace_open_exec(name);
51088 +
51089 err = deny_write_access(file);
51090 if (err)
51091 goto exit;
51092 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
51093 old_fs = get_fs();
51094 set_fs(get_ds());
51095 /* The cast to a user pointer is valid due to the set_fs() */
51096 - result = vfs_read(file, (void __user *)addr, count, &pos);
51097 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51098 set_fs(old_fs);
51099 return result;
51100 }
51101 @@ -1247,7 +1322,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51102 }
51103 rcu_read_unlock();
51104
51105 - if (p->fs->users > n_fs) {
51106 + if (atomic_read(&p->fs->users) > n_fs) {
51107 bprm->unsafe |= LSM_UNSAFE_SHARE;
51108 } else {
51109 res = -EAGAIN;
51110 @@ -1447,6 +1522,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51111
51112 EXPORT_SYMBOL(search_binary_handler);
51113
51114 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51115 +static DEFINE_PER_CPU(u64, exec_counter);
51116 +static int __init init_exec_counters(void)
51117 +{
51118 + unsigned int cpu;
51119 +
51120 + for_each_possible_cpu(cpu) {
51121 + per_cpu(exec_counter, cpu) = (u64)cpu;
51122 + }
51123 +
51124 + return 0;
51125 +}
51126 +early_initcall(init_exec_counters);
51127 +static inline void increment_exec_counter(void)
51128 +{
51129 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51130 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51131 +}
51132 +#else
51133 +static inline void increment_exec_counter(void) {}
51134 +#endif
51135 +
51136 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51137 + struct user_arg_ptr argv);
51138 +
51139 /*
51140 * sys_execve() executes a new program.
51141 */
51142 @@ -1454,6 +1554,11 @@ static int do_execve_common(const char *filename,
51143 struct user_arg_ptr argv,
51144 struct user_arg_ptr envp)
51145 {
51146 +#ifdef CONFIG_GRKERNSEC
51147 + struct file *old_exec_file;
51148 + struct acl_subject_label *old_acl;
51149 + struct rlimit old_rlim[RLIM_NLIMITS];
51150 +#endif
51151 struct linux_binprm *bprm;
51152 struct file *file;
51153 struct files_struct *displaced;
51154 @@ -1461,6 +1566,8 @@ static int do_execve_common(const char *filename,
51155 int retval;
51156 const struct cred *cred = current_cred();
51157
51158 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
51159 +
51160 /*
51161 * We move the actual failure in case of RLIMIT_NPROC excess from
51162 * set*uid() to execve() because too many poorly written programs
51163 @@ -1501,12 +1608,27 @@ static int do_execve_common(const char *filename,
51164 if (IS_ERR(file))
51165 goto out_unmark;
51166
51167 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51168 + retval = -EPERM;
51169 + goto out_file;
51170 + }
51171 +
51172 sched_exec();
51173
51174 bprm->file = file;
51175 bprm->filename = filename;
51176 bprm->interp = filename;
51177
51178 + if (gr_process_user_ban()) {
51179 + retval = -EPERM;
51180 + goto out_file;
51181 + }
51182 +
51183 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
51184 + retval = -EACCES;
51185 + goto out_file;
51186 + }
51187 +
51188 retval = bprm_mm_init(bprm);
51189 if (retval)
51190 goto out_file;
51191 @@ -1523,24 +1645,65 @@ static int do_execve_common(const char *filename,
51192 if (retval < 0)
51193 goto out;
51194
51195 +#ifdef CONFIG_GRKERNSEC
51196 + old_acl = current->acl;
51197 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51198 + old_exec_file = current->exec_file;
51199 + get_file(file);
51200 + current->exec_file = file;
51201 +#endif
51202 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51203 + /* limit suid stack to 8MB
51204 + * we saved the old limits above and will restore them if this exec fails
51205 + */
51206 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51207 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51208 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51209 +#endif
51210 +
51211 + if (!gr_tpe_allow(file)) {
51212 + retval = -EACCES;
51213 + goto out_fail;
51214 + }
51215 +
51216 + if (gr_check_crash_exec(file)) {
51217 + retval = -EACCES;
51218 + goto out_fail;
51219 + }
51220 +
51221 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
51222 + bprm->unsafe);
51223 + if (retval < 0)
51224 + goto out_fail;
51225 +
51226 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51227 if (retval < 0)
51228 - goto out;
51229 + goto out_fail;
51230
51231 bprm->exec = bprm->p;
51232 retval = copy_strings(bprm->envc, envp, bprm);
51233 if (retval < 0)
51234 - goto out;
51235 + goto out_fail;
51236
51237 retval = copy_strings(bprm->argc, argv, bprm);
51238 if (retval < 0)
51239 - goto out;
51240 + goto out_fail;
51241 +
51242 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
51243 +
51244 + gr_handle_exec_args(bprm, argv);
51245
51246 retval = search_binary_handler(bprm);
51247 if (retval < 0)
51248 - goto out;
51249 + goto out_fail;
51250 +#ifdef CONFIG_GRKERNSEC
51251 + if (old_exec_file)
51252 + fput(old_exec_file);
51253 +#endif
51254
51255 /* execve succeeded */
51256 +
51257 + increment_exec_counter();
51258 current->fs->in_exec = 0;
51259 current->in_execve = 0;
51260 acct_update_integrals(current);
51261 @@ -1549,6 +1712,14 @@ static int do_execve_common(const char *filename,
51262 put_files_struct(displaced);
51263 return retval;
51264
51265 +out_fail:
51266 +#ifdef CONFIG_GRKERNSEC
51267 + current->acl = old_acl;
51268 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51269 + fput(current->exec_file);
51270 + current->exec_file = old_exec_file;
51271 +#endif
51272 +
51273 out:
51274 if (bprm->mm) {
51275 acct_arg_size(bprm, 0);
51276 @@ -1697,3 +1868,278 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51277 return error;
51278 }
51279 #endif
51280 +
51281 +int pax_check_flags(unsigned long *flags)
51282 +{
51283 + int retval = 0;
51284 +
51285 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51286 + if (*flags & MF_PAX_SEGMEXEC)
51287 + {
51288 + *flags &= ~MF_PAX_SEGMEXEC;
51289 + retval = -EINVAL;
51290 + }
51291 +#endif
51292 +
51293 + if ((*flags & MF_PAX_PAGEEXEC)
51294 +
51295 +#ifdef CONFIG_PAX_PAGEEXEC
51296 + && (*flags & MF_PAX_SEGMEXEC)
51297 +#endif
51298 +
51299 + )
51300 + {
51301 + *flags &= ~MF_PAX_PAGEEXEC;
51302 + retval = -EINVAL;
51303 + }
51304 +
51305 + if ((*flags & MF_PAX_MPROTECT)
51306 +
51307 +#ifdef CONFIG_PAX_MPROTECT
51308 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51309 +#endif
51310 +
51311 + )
51312 + {
51313 + *flags &= ~MF_PAX_MPROTECT;
51314 + retval = -EINVAL;
51315 + }
51316 +
51317 + if ((*flags & MF_PAX_EMUTRAMP)
51318 +
51319 +#ifdef CONFIG_PAX_EMUTRAMP
51320 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51321 +#endif
51322 +
51323 + )
51324 + {
51325 + *flags &= ~MF_PAX_EMUTRAMP;
51326 + retval = -EINVAL;
51327 + }
51328 +
51329 + return retval;
51330 +}
51331 +
51332 +EXPORT_SYMBOL(pax_check_flags);
51333 +
51334 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51335 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51336 +{
51337 + struct task_struct *tsk = current;
51338 + struct mm_struct *mm = current->mm;
51339 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51340 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51341 + char *path_exec = NULL;
51342 + char *path_fault = NULL;
51343 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51344 + siginfo_t info = { };
51345 +
51346 + if (buffer_exec && buffer_fault) {
51347 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51348 +
51349 + down_read(&mm->mmap_sem);
51350 + vma = mm->mmap;
51351 + while (vma && (!vma_exec || !vma_fault)) {
51352 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51353 + vma_exec = vma;
51354 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51355 + vma_fault = vma;
51356 + vma = vma->vm_next;
51357 + }
51358 + if (vma_exec) {
51359 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51360 + if (IS_ERR(path_exec))
51361 + path_exec = "<path too long>";
51362 + else {
51363 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51364 + if (path_exec) {
51365 + *path_exec = 0;
51366 + path_exec = buffer_exec;
51367 + } else
51368 + path_exec = "<path too long>";
51369 + }
51370 + }
51371 + if (vma_fault) {
51372 + start = vma_fault->vm_start;
51373 + end = vma_fault->vm_end;
51374 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51375 + if (vma_fault->vm_file) {
51376 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51377 + if (IS_ERR(path_fault))
51378 + path_fault = "<path too long>";
51379 + else {
51380 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51381 + if (path_fault) {
51382 + *path_fault = 0;
51383 + path_fault = buffer_fault;
51384 + } else
51385 + path_fault = "<path too long>";
51386 + }
51387 + } else
51388 + path_fault = "<anonymous mapping>";
51389 + }
51390 + up_read(&mm->mmap_sem);
51391 + }
51392 + if (tsk->signal->curr_ip)
51393 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51394 + else
51395 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51396 + 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),
51397 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51398 + free_page((unsigned long)buffer_exec);
51399 + free_page((unsigned long)buffer_fault);
51400 + pax_report_insns(regs, pc, sp);
51401 + info.si_signo = SIGKILL;
51402 + info.si_errno = 0;
51403 + info.si_code = SI_KERNEL;
51404 + info.si_pid = 0;
51405 + info.si_uid = 0;
51406 + do_coredump(&info);
51407 +}
51408 +#endif
51409 +
51410 +#ifdef CONFIG_PAX_REFCOUNT
51411 +void pax_report_refcount_overflow(struct pt_regs *regs)
51412 +{
51413 + if (current->signal->curr_ip)
51414 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51415 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51416 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51417 + else
51418 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51419 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51420 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51421 + show_regs(regs);
51422 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51423 +}
51424 +#endif
51425 +
51426 +#ifdef CONFIG_PAX_USERCOPY
51427 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51428 +static noinline int check_stack_object(const void *obj, unsigned long len)
51429 +{
51430 + const void * const stack = task_stack_page(current);
51431 + const void * const stackend = stack + THREAD_SIZE;
51432 +
51433 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51434 + const void *frame = NULL;
51435 + const void *oldframe;
51436 +#endif
51437 +
51438 + if (obj + len < obj)
51439 + return -1;
51440 +
51441 + if (obj + len <= stack || stackend <= obj)
51442 + return 0;
51443 +
51444 + if (obj < stack || stackend < obj + len)
51445 + return -1;
51446 +
51447 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51448 + oldframe = __builtin_frame_address(1);
51449 + if (oldframe)
51450 + frame = __builtin_frame_address(2);
51451 + /*
51452 + low ----------------------------------------------> high
51453 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51454 + ^----------------^
51455 + allow copies only within here
51456 + */
51457 + while (stack <= frame && frame < stackend) {
51458 + /* if obj + len extends past the last frame, this
51459 + check won't pass and the next frame will be 0,
51460 + causing us to bail out and correctly report
51461 + the copy as invalid
51462 + */
51463 + if (obj + len <= frame)
51464 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51465 + oldframe = frame;
51466 + frame = *(const void * const *)frame;
51467 + }
51468 + return -1;
51469 +#else
51470 + return 1;
51471 +#endif
51472 +}
51473 +
51474 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51475 +{
51476 + if (current->signal->curr_ip)
51477 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51478 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51479 + else
51480 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51481 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51482 + dump_stack();
51483 + gr_handle_kernel_exploit();
51484 + do_group_exit(SIGKILL);
51485 +}
51486 +#endif
51487 +
51488 +#ifdef CONFIG_PAX_USERCOPY
51489 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51490 +{
51491 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51492 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51493 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51494 +#else
51495 + unsigned long textlow = _stext;
51496 + unsigned long texthigh = _etext;
51497 +#endif
51498 +
51499 + if (high < textlow || low > texthigh)
51500 + return false;
51501 + else
51502 + return true;
51503 +}
51504 +#endif
51505 +
51506 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51507 +{
51508 +
51509 +#ifdef CONFIG_PAX_USERCOPY
51510 + const char *type;
51511 +
51512 + if (!n)
51513 + return;
51514 +
51515 + type = check_heap_object(ptr, n);
51516 + if (!type) {
51517 + int ret = check_stack_object(ptr, n);
51518 + if (ret == 1 || ret == 2)
51519 + return;
51520 + if (ret == 0) {
51521 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51522 + type = "<kernel text>";
51523 + else
51524 + return;
51525 + } else
51526 + type = "<process stack>";
51527 + }
51528 +
51529 + pax_report_usercopy(ptr, n, to_user, type);
51530 +#endif
51531 +
51532 +}
51533 +EXPORT_SYMBOL(__check_object_size);
51534 +
51535 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51536 +void pax_track_stack(void)
51537 +{
51538 + unsigned long sp = (unsigned long)&sp;
51539 + if (sp < current_thread_info()->lowest_stack &&
51540 + sp > (unsigned long)task_stack_page(current))
51541 + current_thread_info()->lowest_stack = sp;
51542 +}
51543 +EXPORT_SYMBOL(pax_track_stack);
51544 +#endif
51545 +
51546 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51547 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51548 +{
51549 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51550 + dump_stack();
51551 + do_group_exit(SIGKILL);
51552 +}
51553 +EXPORT_SYMBOL(report_size_overflow);
51554 +#endif
51555 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51556 index 2616d0e..2ffdec9 100644
51557 --- a/fs/ext2/balloc.c
51558 +++ b/fs/ext2/balloc.c
51559 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51560
51561 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51562 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51563 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51564 + if (free_blocks < root_blocks + 1 &&
51565 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51566 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51567 - !in_group_p (sbi->s_resgid))) {
51568 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51569 return 0;
51570 }
51571 return 1;
51572 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51573 index 22548f5..41521d8 100644
51574 --- a/fs/ext3/balloc.c
51575 +++ b/fs/ext3/balloc.c
51576 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51577
51578 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51579 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51580 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51581 + if (free_blocks < root_blocks + 1 &&
51582 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51583 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51584 - !in_group_p (sbi->s_resgid))) {
51585 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51586 return 0;
51587 }
51588 return 1;
51589 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51590 index 92e68b3..115d987 100644
51591 --- a/fs/ext4/balloc.c
51592 +++ b/fs/ext4/balloc.c
51593 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51594 /* Hm, nope. Are (enough) root reserved clusters available? */
51595 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51596 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51597 - capable(CAP_SYS_RESOURCE) ||
51598 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51599 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51600 + capable_nolog(CAP_SYS_RESOURCE)) {
51601
51602 if (free_clusters >= (nclusters + dirty_clusters))
51603 return 1;
51604 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51605 index bbcd6a0..2824592 100644
51606 --- a/fs/ext4/ext4.h
51607 +++ b/fs/ext4/ext4.h
51608 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
51609 unsigned long s_mb_last_start;
51610
51611 /* stats for buddy allocator */
51612 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51613 - atomic_t s_bal_success; /* we found long enough chunks */
51614 - atomic_t s_bal_allocated; /* in blocks */
51615 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51616 - atomic_t s_bal_goals; /* goal hits */
51617 - atomic_t s_bal_breaks; /* too long searches */
51618 - atomic_t s_bal_2orders; /* 2^order hits */
51619 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51620 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51621 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51622 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51623 + atomic_unchecked_t s_bal_goals; /* goal hits */
51624 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51625 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51626 spinlock_t s_bal_lock;
51627 unsigned long s_mb_buddies_generated;
51628 unsigned long long s_mb_generation_time;
51629 - atomic_t s_mb_lost_chunks;
51630 - atomic_t s_mb_preallocated;
51631 - atomic_t s_mb_discarded;
51632 + atomic_unchecked_t s_mb_lost_chunks;
51633 + atomic_unchecked_t s_mb_preallocated;
51634 + atomic_unchecked_t s_mb_discarded;
51635 atomic_t s_lock_busy;
51636
51637 /* locality groups */
51638 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51639 index 82f8c2d..ce7c889 100644
51640 --- a/fs/ext4/mballoc.c
51641 +++ b/fs/ext4/mballoc.c
51642 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51643 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51644
51645 if (EXT4_SB(sb)->s_mb_stats)
51646 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51647 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51648
51649 break;
51650 }
51651 @@ -2044,7 +2044,7 @@ repeat:
51652 ac->ac_status = AC_STATUS_CONTINUE;
51653 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51654 cr = 3;
51655 - atomic_inc(&sbi->s_mb_lost_chunks);
51656 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51657 goto repeat;
51658 }
51659 }
51660 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
51661 if (sbi->s_mb_stats) {
51662 ext4_msg(sb, KERN_INFO,
51663 "mballoc: %u blocks %u reqs (%u success)",
51664 - atomic_read(&sbi->s_bal_allocated),
51665 - atomic_read(&sbi->s_bal_reqs),
51666 - atomic_read(&sbi->s_bal_success));
51667 + atomic_read_unchecked(&sbi->s_bal_allocated),
51668 + atomic_read_unchecked(&sbi->s_bal_reqs),
51669 + atomic_read_unchecked(&sbi->s_bal_success));
51670 ext4_msg(sb, KERN_INFO,
51671 "mballoc: %u extents scanned, %u goal hits, "
51672 "%u 2^N hits, %u breaks, %u lost",
51673 - atomic_read(&sbi->s_bal_ex_scanned),
51674 - atomic_read(&sbi->s_bal_goals),
51675 - atomic_read(&sbi->s_bal_2orders),
51676 - atomic_read(&sbi->s_bal_breaks),
51677 - atomic_read(&sbi->s_mb_lost_chunks));
51678 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51679 + atomic_read_unchecked(&sbi->s_bal_goals),
51680 + atomic_read_unchecked(&sbi->s_bal_2orders),
51681 + atomic_read_unchecked(&sbi->s_bal_breaks),
51682 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51683 ext4_msg(sb, KERN_INFO,
51684 "mballoc: %lu generated and it took %Lu",
51685 sbi->s_mb_buddies_generated,
51686 sbi->s_mb_generation_time);
51687 ext4_msg(sb, KERN_INFO,
51688 "mballoc: %u preallocated, %u discarded",
51689 - atomic_read(&sbi->s_mb_preallocated),
51690 - atomic_read(&sbi->s_mb_discarded));
51691 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51692 + atomic_read_unchecked(&sbi->s_mb_discarded));
51693 }
51694
51695 free_percpu(sbi->s_locality_groups);
51696 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51697 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51698
51699 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51700 - atomic_inc(&sbi->s_bal_reqs);
51701 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51702 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51703 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51704 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51705 - atomic_inc(&sbi->s_bal_success);
51706 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51707 + atomic_inc_unchecked(&sbi->s_bal_success);
51708 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51709 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51710 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51711 - atomic_inc(&sbi->s_bal_goals);
51712 + atomic_inc_unchecked(&sbi->s_bal_goals);
51713 if (ac->ac_found > sbi->s_mb_max_to_scan)
51714 - atomic_inc(&sbi->s_bal_breaks);
51715 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51716 }
51717
51718 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51719 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51720 trace_ext4_mb_new_inode_pa(ac, pa);
51721
51722 ext4_mb_use_inode_pa(ac, pa);
51723 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51724 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51725
51726 ei = EXT4_I(ac->ac_inode);
51727 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51728 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51729 trace_ext4_mb_new_group_pa(ac, pa);
51730
51731 ext4_mb_use_group_pa(ac, pa);
51732 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51733 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51734
51735 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51736 lg = ac->ac_lg;
51737 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51738 * from the bitmap and continue.
51739 */
51740 }
51741 - atomic_add(free, &sbi->s_mb_discarded);
51742 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51743
51744 return err;
51745 }
51746 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51747 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51748 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51749 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51750 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51751 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51752 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51753
51754 return 0;
51755 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51756 index 24c767d..893aa55 100644
51757 --- a/fs/ext4/super.c
51758 +++ b/fs/ext4/super.c
51759 @@ -2429,7 +2429,7 @@ struct ext4_attr {
51760 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51761 const char *, size_t);
51762 int offset;
51763 -};
51764 +} __do_const;
51765
51766 static int parse_strtoul(const char *buf,
51767 unsigned long max, unsigned long *value)
51768 diff --git a/fs/fcntl.c b/fs/fcntl.c
51769 index 71a600a..20d87b1 100644
51770 --- a/fs/fcntl.c
51771 +++ b/fs/fcntl.c
51772 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51773 if (err)
51774 return err;
51775
51776 + if (gr_handle_chroot_fowner(pid, type))
51777 + return -ENOENT;
51778 + if (gr_check_protected_task_fowner(pid, type))
51779 + return -EACCES;
51780 +
51781 f_modown(filp, pid, type, force);
51782 return 0;
51783 }
51784 diff --git a/fs/fhandle.c b/fs/fhandle.c
51785 index 999ff5c..41f4109 100644
51786 --- a/fs/fhandle.c
51787 +++ b/fs/fhandle.c
51788 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51789 } else
51790 retval = 0;
51791 /* copy the mount id */
51792 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51793 - sizeof(*mnt_id)) ||
51794 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51795 copy_to_user(ufh, handle,
51796 sizeof(struct file_handle) + handle_bytes))
51797 retval = -EFAULT;
51798 diff --git a/fs/fifo.c b/fs/fifo.c
51799 index cf6f434..3d7942c 100644
51800 --- a/fs/fifo.c
51801 +++ b/fs/fifo.c
51802 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51803 */
51804 filp->f_op = &read_pipefifo_fops;
51805 pipe->r_counter++;
51806 - if (pipe->readers++ == 0)
51807 + if (atomic_inc_return(&pipe->readers) == 1)
51808 wake_up_partner(inode);
51809
51810 - if (!pipe->writers) {
51811 + if (!atomic_read(&pipe->writers)) {
51812 if ((filp->f_flags & O_NONBLOCK)) {
51813 /* suppress POLLHUP until we have
51814 * seen a writer */
51815 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51816 * errno=ENXIO when there is no process reading the FIFO.
51817 */
51818 ret = -ENXIO;
51819 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51820 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51821 goto err;
51822
51823 filp->f_op = &write_pipefifo_fops;
51824 pipe->w_counter++;
51825 - if (!pipe->writers++)
51826 + if (atomic_inc_return(&pipe->writers) == 1)
51827 wake_up_partner(inode);
51828
51829 - if (!pipe->readers) {
51830 + if (!atomic_read(&pipe->readers)) {
51831 if (wait_for_partner(inode, &pipe->r_counter))
51832 goto err_wr;
51833 }
51834 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51835 */
51836 filp->f_op = &rdwr_pipefifo_fops;
51837
51838 - pipe->readers++;
51839 - pipe->writers++;
51840 + atomic_inc(&pipe->readers);
51841 + atomic_inc(&pipe->writers);
51842 pipe->r_counter++;
51843 pipe->w_counter++;
51844 - if (pipe->readers == 1 || pipe->writers == 1)
51845 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51846 wake_up_partner(inode);
51847 break;
51848
51849 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51850 return 0;
51851
51852 err_rd:
51853 - if (!--pipe->readers)
51854 + if (atomic_dec_and_test(&pipe->readers))
51855 wake_up_interruptible(&pipe->wait);
51856 ret = -ERESTARTSYS;
51857 goto err;
51858
51859 err_wr:
51860 - if (!--pipe->writers)
51861 + if (atomic_dec_and_test(&pipe->writers))
51862 wake_up_interruptible(&pipe->wait);
51863 ret = -ERESTARTSYS;
51864 goto err;
51865
51866 err:
51867 - if (!pipe->readers && !pipe->writers)
51868 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51869 free_pipe_info(inode);
51870
51871 err_nocleanup:
51872 diff --git a/fs/file.c b/fs/file.c
51873 index 2b3570b..c57924b 100644
51874 --- a/fs/file.c
51875 +++ b/fs/file.c
51876 @@ -16,6 +16,7 @@
51877 #include <linux/slab.h>
51878 #include <linux/vmalloc.h>
51879 #include <linux/file.h>
51880 +#include <linux/security.h>
51881 #include <linux/fdtable.h>
51882 #include <linux/bitops.h>
51883 #include <linux/interrupt.h>
51884 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51885 if (!file)
51886 return __close_fd(files, fd);
51887
51888 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51889 if (fd >= rlimit(RLIMIT_NOFILE))
51890 return -EBADF;
51891
51892 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51893 if (unlikely(oldfd == newfd))
51894 return -EINVAL;
51895
51896 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51897 if (newfd >= rlimit(RLIMIT_NOFILE))
51898 return -EBADF;
51899
51900 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51901 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51902 {
51903 int err;
51904 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51905 if (from >= rlimit(RLIMIT_NOFILE))
51906 return -EINVAL;
51907 err = alloc_fd(from, flags);
51908 diff --git a/fs/filesystems.c b/fs/filesystems.c
51909 index da165f6..3671bdb 100644
51910 --- a/fs/filesystems.c
51911 +++ b/fs/filesystems.c
51912 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
51913 int len = dot ? dot - name : strlen(name);
51914
51915 fs = __get_fs_type(name, len);
51916 +
51917 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51918 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
51919 +#else
51920 if (!fs && (request_module("%.*s", len, name) == 0))
51921 +#endif
51922 fs = __get_fs_type(name, len);
51923
51924 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51925 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51926 index fe6ca58..65318cf 100644
51927 --- a/fs/fs_struct.c
51928 +++ b/fs/fs_struct.c
51929 @@ -4,6 +4,7 @@
51930 #include <linux/path.h>
51931 #include <linux/slab.h>
51932 #include <linux/fs_struct.h>
51933 +#include <linux/grsecurity.h>
51934 #include "internal.h"
51935
51936 /*
51937 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51938 write_seqcount_begin(&fs->seq);
51939 old_root = fs->root;
51940 fs->root = *path;
51941 + gr_set_chroot_entries(current, path);
51942 write_seqcount_end(&fs->seq);
51943 spin_unlock(&fs->lock);
51944 if (old_root.dentry)
51945 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51946 return 1;
51947 }
51948
51949 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51950 +{
51951 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51952 + return 0;
51953 + *p = *new;
51954 +
51955 + /* This function is only called from pivot_root(). Leave our
51956 + gr_chroot_dentry and is_chrooted flags as-is, so that a
51957 + pivoted root isn't treated as a chroot
51958 + */
51959 + //gr_set_chroot_entries(task, new);
51960 +
51961 + return 1;
51962 +}
51963 +
51964 void chroot_fs_refs(struct path *old_root, struct path *new_root)
51965 {
51966 struct task_struct *g, *p;
51967 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
51968 int hits = 0;
51969 spin_lock(&fs->lock);
51970 write_seqcount_begin(&fs->seq);
51971 - hits += replace_path(&fs->root, old_root, new_root);
51972 + hits += replace_root_path(p, &fs->root, old_root, new_root);
51973 hits += replace_path(&fs->pwd, old_root, new_root);
51974 write_seqcount_end(&fs->seq);
51975 while (hits--) {
51976 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
51977 task_lock(tsk);
51978 spin_lock(&fs->lock);
51979 tsk->fs = NULL;
51980 - kill = !--fs->users;
51981 + gr_clear_chroot_entries(tsk);
51982 + kill = !atomic_dec_return(&fs->users);
51983 spin_unlock(&fs->lock);
51984 task_unlock(tsk);
51985 if (kill)
51986 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51987 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51988 /* We don't need to lock fs - think why ;-) */
51989 if (fs) {
51990 - fs->users = 1;
51991 + atomic_set(&fs->users, 1);
51992 fs->in_exec = 0;
51993 spin_lock_init(&fs->lock);
51994 seqcount_init(&fs->seq);
51995 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51996 spin_lock(&old->lock);
51997 fs->root = old->root;
51998 path_get(&fs->root);
51999 + /* instead of calling gr_set_chroot_entries here,
52000 + we call it from every caller of this function
52001 + */
52002 fs->pwd = old->pwd;
52003 path_get(&fs->pwd);
52004 spin_unlock(&old->lock);
52005 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
52006
52007 task_lock(current);
52008 spin_lock(&fs->lock);
52009 - kill = !--fs->users;
52010 + kill = !atomic_dec_return(&fs->users);
52011 current->fs = new_fs;
52012 + gr_set_chroot_entries(current, &new_fs->root);
52013 spin_unlock(&fs->lock);
52014 task_unlock(current);
52015
52016 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
52017
52018 int current_umask(void)
52019 {
52020 - return current->fs->umask;
52021 + return current->fs->umask | gr_acl_umask();
52022 }
52023 EXPORT_SYMBOL(current_umask);
52024
52025 /* to be mentioned only in INIT_TASK */
52026 struct fs_struct init_fs = {
52027 - .users = 1,
52028 + .users = ATOMIC_INIT(1),
52029 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
52030 .seq = SEQCNT_ZERO,
52031 .umask = 0022,
52032 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
52033 index 8dcb114..b1072e2 100644
52034 --- a/fs/fscache/cookie.c
52035 +++ b/fs/fscache/cookie.c
52036 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
52037 parent ? (char *) parent->def->name : "<no-parent>",
52038 def->name, netfs_data);
52039
52040 - fscache_stat(&fscache_n_acquires);
52041 + fscache_stat_unchecked(&fscache_n_acquires);
52042
52043 /* if there's no parent cookie, then we don't create one here either */
52044 if (!parent) {
52045 - fscache_stat(&fscache_n_acquires_null);
52046 + fscache_stat_unchecked(&fscache_n_acquires_null);
52047 _leave(" [no parent]");
52048 return NULL;
52049 }
52050 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
52051 /* allocate and initialise a cookie */
52052 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
52053 if (!cookie) {
52054 - fscache_stat(&fscache_n_acquires_oom);
52055 + fscache_stat_unchecked(&fscache_n_acquires_oom);
52056 _leave(" [ENOMEM]");
52057 return NULL;
52058 }
52059 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52060
52061 switch (cookie->def->type) {
52062 case FSCACHE_COOKIE_TYPE_INDEX:
52063 - fscache_stat(&fscache_n_cookie_index);
52064 + fscache_stat_unchecked(&fscache_n_cookie_index);
52065 break;
52066 case FSCACHE_COOKIE_TYPE_DATAFILE:
52067 - fscache_stat(&fscache_n_cookie_data);
52068 + fscache_stat_unchecked(&fscache_n_cookie_data);
52069 break;
52070 default:
52071 - fscache_stat(&fscache_n_cookie_special);
52072 + fscache_stat_unchecked(&fscache_n_cookie_special);
52073 break;
52074 }
52075
52076 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52077 if (fscache_acquire_non_index_cookie(cookie) < 0) {
52078 atomic_dec(&parent->n_children);
52079 __fscache_cookie_put(cookie);
52080 - fscache_stat(&fscache_n_acquires_nobufs);
52081 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
52082 _leave(" = NULL");
52083 return NULL;
52084 }
52085 }
52086
52087 - fscache_stat(&fscache_n_acquires_ok);
52088 + fscache_stat_unchecked(&fscache_n_acquires_ok);
52089 _leave(" = %p", cookie);
52090 return cookie;
52091 }
52092 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
52093 cache = fscache_select_cache_for_object(cookie->parent);
52094 if (!cache) {
52095 up_read(&fscache_addremove_sem);
52096 - fscache_stat(&fscache_n_acquires_no_cache);
52097 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
52098 _leave(" = -ENOMEDIUM [no cache]");
52099 return -ENOMEDIUM;
52100 }
52101 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
52102 object = cache->ops->alloc_object(cache, cookie);
52103 fscache_stat_d(&fscache_n_cop_alloc_object);
52104 if (IS_ERR(object)) {
52105 - fscache_stat(&fscache_n_object_no_alloc);
52106 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
52107 ret = PTR_ERR(object);
52108 goto error;
52109 }
52110
52111 - fscache_stat(&fscache_n_object_alloc);
52112 + fscache_stat_unchecked(&fscache_n_object_alloc);
52113
52114 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
52115
52116 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52117
52118 _enter("{%s}", cookie->def->name);
52119
52120 - fscache_stat(&fscache_n_invalidates);
52121 + fscache_stat_unchecked(&fscache_n_invalidates);
52122
52123 /* Only permit invalidation of data files. Invalidating an index will
52124 * require the caller to release all its attachments to the tree rooted
52125 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52126 struct fscache_object *object;
52127 struct hlist_node *_p;
52128
52129 - fscache_stat(&fscache_n_updates);
52130 + fscache_stat_unchecked(&fscache_n_updates);
52131
52132 if (!cookie) {
52133 - fscache_stat(&fscache_n_updates_null);
52134 + fscache_stat_unchecked(&fscache_n_updates_null);
52135 _leave(" [no cookie]");
52136 return;
52137 }
52138 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52139 struct fscache_object *object;
52140 unsigned long event;
52141
52142 - fscache_stat(&fscache_n_relinquishes);
52143 + fscache_stat_unchecked(&fscache_n_relinquishes);
52144 if (retire)
52145 - fscache_stat(&fscache_n_relinquishes_retire);
52146 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52147
52148 if (!cookie) {
52149 - fscache_stat(&fscache_n_relinquishes_null);
52150 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52151 _leave(" [no cookie]");
52152 return;
52153 }
52154 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52155
52156 /* wait for the cookie to finish being instantiated (or to fail) */
52157 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52158 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52159 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52160 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52161 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52162 }
52163 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52164 index ee38fef..0a326d4 100644
52165 --- a/fs/fscache/internal.h
52166 +++ b/fs/fscache/internal.h
52167 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52168 * stats.c
52169 */
52170 #ifdef CONFIG_FSCACHE_STATS
52171 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52172 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52173 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52174 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52175
52176 -extern atomic_t fscache_n_op_pend;
52177 -extern atomic_t fscache_n_op_run;
52178 -extern atomic_t fscache_n_op_enqueue;
52179 -extern atomic_t fscache_n_op_deferred_release;
52180 -extern atomic_t fscache_n_op_release;
52181 -extern atomic_t fscache_n_op_gc;
52182 -extern atomic_t fscache_n_op_cancelled;
52183 -extern atomic_t fscache_n_op_rejected;
52184 +extern atomic_unchecked_t fscache_n_op_pend;
52185 +extern atomic_unchecked_t fscache_n_op_run;
52186 +extern atomic_unchecked_t fscache_n_op_enqueue;
52187 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52188 +extern atomic_unchecked_t fscache_n_op_release;
52189 +extern atomic_unchecked_t fscache_n_op_gc;
52190 +extern atomic_unchecked_t fscache_n_op_cancelled;
52191 +extern atomic_unchecked_t fscache_n_op_rejected;
52192
52193 -extern atomic_t fscache_n_attr_changed;
52194 -extern atomic_t fscache_n_attr_changed_ok;
52195 -extern atomic_t fscache_n_attr_changed_nobufs;
52196 -extern atomic_t fscache_n_attr_changed_nomem;
52197 -extern atomic_t fscache_n_attr_changed_calls;
52198 +extern atomic_unchecked_t fscache_n_attr_changed;
52199 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52200 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52201 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52202 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52203
52204 -extern atomic_t fscache_n_allocs;
52205 -extern atomic_t fscache_n_allocs_ok;
52206 -extern atomic_t fscache_n_allocs_wait;
52207 -extern atomic_t fscache_n_allocs_nobufs;
52208 -extern atomic_t fscache_n_allocs_intr;
52209 -extern atomic_t fscache_n_allocs_object_dead;
52210 -extern atomic_t fscache_n_alloc_ops;
52211 -extern atomic_t fscache_n_alloc_op_waits;
52212 +extern atomic_unchecked_t fscache_n_allocs;
52213 +extern atomic_unchecked_t fscache_n_allocs_ok;
52214 +extern atomic_unchecked_t fscache_n_allocs_wait;
52215 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52216 +extern atomic_unchecked_t fscache_n_allocs_intr;
52217 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52218 +extern atomic_unchecked_t fscache_n_alloc_ops;
52219 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52220
52221 -extern atomic_t fscache_n_retrievals;
52222 -extern atomic_t fscache_n_retrievals_ok;
52223 -extern atomic_t fscache_n_retrievals_wait;
52224 -extern atomic_t fscache_n_retrievals_nodata;
52225 -extern atomic_t fscache_n_retrievals_nobufs;
52226 -extern atomic_t fscache_n_retrievals_intr;
52227 -extern atomic_t fscache_n_retrievals_nomem;
52228 -extern atomic_t fscache_n_retrievals_object_dead;
52229 -extern atomic_t fscache_n_retrieval_ops;
52230 -extern atomic_t fscache_n_retrieval_op_waits;
52231 +extern atomic_unchecked_t fscache_n_retrievals;
52232 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52233 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52234 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52235 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52236 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52237 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52238 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52239 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52240 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52241
52242 -extern atomic_t fscache_n_stores;
52243 -extern atomic_t fscache_n_stores_ok;
52244 -extern atomic_t fscache_n_stores_again;
52245 -extern atomic_t fscache_n_stores_nobufs;
52246 -extern atomic_t fscache_n_stores_oom;
52247 -extern atomic_t fscache_n_store_ops;
52248 -extern atomic_t fscache_n_store_calls;
52249 -extern atomic_t fscache_n_store_pages;
52250 -extern atomic_t fscache_n_store_radix_deletes;
52251 -extern atomic_t fscache_n_store_pages_over_limit;
52252 +extern atomic_unchecked_t fscache_n_stores;
52253 +extern atomic_unchecked_t fscache_n_stores_ok;
52254 +extern atomic_unchecked_t fscache_n_stores_again;
52255 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52256 +extern atomic_unchecked_t fscache_n_stores_oom;
52257 +extern atomic_unchecked_t fscache_n_store_ops;
52258 +extern atomic_unchecked_t fscache_n_store_calls;
52259 +extern atomic_unchecked_t fscache_n_store_pages;
52260 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52261 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52262
52263 -extern atomic_t fscache_n_store_vmscan_not_storing;
52264 -extern atomic_t fscache_n_store_vmscan_gone;
52265 -extern atomic_t fscache_n_store_vmscan_busy;
52266 -extern atomic_t fscache_n_store_vmscan_cancelled;
52267 -extern atomic_t fscache_n_store_vmscan_wait;
52268 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52269 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52270 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52271 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52272 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52273
52274 -extern atomic_t fscache_n_marks;
52275 -extern atomic_t fscache_n_uncaches;
52276 +extern atomic_unchecked_t fscache_n_marks;
52277 +extern atomic_unchecked_t fscache_n_uncaches;
52278
52279 -extern atomic_t fscache_n_acquires;
52280 -extern atomic_t fscache_n_acquires_null;
52281 -extern atomic_t fscache_n_acquires_no_cache;
52282 -extern atomic_t fscache_n_acquires_ok;
52283 -extern atomic_t fscache_n_acquires_nobufs;
52284 -extern atomic_t fscache_n_acquires_oom;
52285 +extern atomic_unchecked_t fscache_n_acquires;
52286 +extern atomic_unchecked_t fscache_n_acquires_null;
52287 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52288 +extern atomic_unchecked_t fscache_n_acquires_ok;
52289 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52290 +extern atomic_unchecked_t fscache_n_acquires_oom;
52291
52292 -extern atomic_t fscache_n_invalidates;
52293 -extern atomic_t fscache_n_invalidates_run;
52294 +extern atomic_unchecked_t fscache_n_invalidates;
52295 +extern atomic_unchecked_t fscache_n_invalidates_run;
52296
52297 -extern atomic_t fscache_n_updates;
52298 -extern atomic_t fscache_n_updates_null;
52299 -extern atomic_t fscache_n_updates_run;
52300 +extern atomic_unchecked_t fscache_n_updates;
52301 +extern atomic_unchecked_t fscache_n_updates_null;
52302 +extern atomic_unchecked_t fscache_n_updates_run;
52303
52304 -extern atomic_t fscache_n_relinquishes;
52305 -extern atomic_t fscache_n_relinquishes_null;
52306 -extern atomic_t fscache_n_relinquishes_waitcrt;
52307 -extern atomic_t fscache_n_relinquishes_retire;
52308 +extern atomic_unchecked_t fscache_n_relinquishes;
52309 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52310 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52311 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52312
52313 -extern atomic_t fscache_n_cookie_index;
52314 -extern atomic_t fscache_n_cookie_data;
52315 -extern atomic_t fscache_n_cookie_special;
52316 +extern atomic_unchecked_t fscache_n_cookie_index;
52317 +extern atomic_unchecked_t fscache_n_cookie_data;
52318 +extern atomic_unchecked_t fscache_n_cookie_special;
52319
52320 -extern atomic_t fscache_n_object_alloc;
52321 -extern atomic_t fscache_n_object_no_alloc;
52322 -extern atomic_t fscache_n_object_lookups;
52323 -extern atomic_t fscache_n_object_lookups_negative;
52324 -extern atomic_t fscache_n_object_lookups_positive;
52325 -extern atomic_t fscache_n_object_lookups_timed_out;
52326 -extern atomic_t fscache_n_object_created;
52327 -extern atomic_t fscache_n_object_avail;
52328 -extern atomic_t fscache_n_object_dead;
52329 +extern atomic_unchecked_t fscache_n_object_alloc;
52330 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52331 +extern atomic_unchecked_t fscache_n_object_lookups;
52332 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52333 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52334 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52335 +extern atomic_unchecked_t fscache_n_object_created;
52336 +extern atomic_unchecked_t fscache_n_object_avail;
52337 +extern atomic_unchecked_t fscache_n_object_dead;
52338
52339 -extern atomic_t fscache_n_checkaux_none;
52340 -extern atomic_t fscache_n_checkaux_okay;
52341 -extern atomic_t fscache_n_checkaux_update;
52342 -extern atomic_t fscache_n_checkaux_obsolete;
52343 +extern atomic_unchecked_t fscache_n_checkaux_none;
52344 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52345 +extern atomic_unchecked_t fscache_n_checkaux_update;
52346 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52347
52348 extern atomic_t fscache_n_cop_alloc_object;
52349 extern atomic_t fscache_n_cop_lookup_object;
52350 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52351 atomic_inc(stat);
52352 }
52353
52354 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52355 +{
52356 + atomic_inc_unchecked(stat);
52357 +}
52358 +
52359 static inline void fscache_stat_d(atomic_t *stat)
52360 {
52361 atomic_dec(stat);
52362 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52363
52364 #define __fscache_stat(stat) (NULL)
52365 #define fscache_stat(stat) do {} while (0)
52366 +#define fscache_stat_unchecked(stat) do {} while (0)
52367 #define fscache_stat_d(stat) do {} while (0)
52368 #endif
52369
52370 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52371 index 50d41c1..10ee117 100644
52372 --- a/fs/fscache/object.c
52373 +++ b/fs/fscache/object.c
52374 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52375 /* Invalidate an object on disk */
52376 case FSCACHE_OBJECT_INVALIDATING:
52377 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52378 - fscache_stat(&fscache_n_invalidates_run);
52379 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52380 fscache_stat(&fscache_n_cop_invalidate_object);
52381 fscache_invalidate_object(object);
52382 fscache_stat_d(&fscache_n_cop_invalidate_object);
52383 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52384 /* update the object metadata on disk */
52385 case FSCACHE_OBJECT_UPDATING:
52386 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52387 - fscache_stat(&fscache_n_updates_run);
52388 + fscache_stat_unchecked(&fscache_n_updates_run);
52389 fscache_stat(&fscache_n_cop_update_object);
52390 object->cache->ops->update_object(object);
52391 fscache_stat_d(&fscache_n_cop_update_object);
52392 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52393 spin_lock(&object->lock);
52394 object->state = FSCACHE_OBJECT_DEAD;
52395 spin_unlock(&object->lock);
52396 - fscache_stat(&fscache_n_object_dead);
52397 + fscache_stat_unchecked(&fscache_n_object_dead);
52398 goto terminal_transit;
52399
52400 /* handle the parent cache of this object being withdrawn from
52401 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52402 spin_lock(&object->lock);
52403 object->state = FSCACHE_OBJECT_DEAD;
52404 spin_unlock(&object->lock);
52405 - fscache_stat(&fscache_n_object_dead);
52406 + fscache_stat_unchecked(&fscache_n_object_dead);
52407 goto terminal_transit;
52408
52409 /* complain about the object being woken up once it is
52410 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52411 parent->cookie->def->name, cookie->def->name,
52412 object->cache->tag->name);
52413
52414 - fscache_stat(&fscache_n_object_lookups);
52415 + fscache_stat_unchecked(&fscache_n_object_lookups);
52416 fscache_stat(&fscache_n_cop_lookup_object);
52417 ret = object->cache->ops->lookup_object(object);
52418 fscache_stat_d(&fscache_n_cop_lookup_object);
52419 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52420 if (ret == -ETIMEDOUT) {
52421 /* probably stuck behind another object, so move this one to
52422 * the back of the queue */
52423 - fscache_stat(&fscache_n_object_lookups_timed_out);
52424 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52425 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52426 }
52427
52428 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52429
52430 spin_lock(&object->lock);
52431 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52432 - fscache_stat(&fscache_n_object_lookups_negative);
52433 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52434
52435 /* transit here to allow write requests to begin stacking up
52436 * and read requests to begin returning ENODATA */
52437 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52438 * result, in which case there may be data available */
52439 spin_lock(&object->lock);
52440 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52441 - fscache_stat(&fscache_n_object_lookups_positive);
52442 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52443
52444 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52445
52446 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52447 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52448 } else {
52449 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52450 - fscache_stat(&fscache_n_object_created);
52451 + fscache_stat_unchecked(&fscache_n_object_created);
52452
52453 object->state = FSCACHE_OBJECT_AVAILABLE;
52454 spin_unlock(&object->lock);
52455 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52456 fscache_enqueue_dependents(object);
52457
52458 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52459 - fscache_stat(&fscache_n_object_avail);
52460 + fscache_stat_unchecked(&fscache_n_object_avail);
52461
52462 _leave("");
52463 }
52464 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52465 enum fscache_checkaux result;
52466
52467 if (!object->cookie->def->check_aux) {
52468 - fscache_stat(&fscache_n_checkaux_none);
52469 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52470 return FSCACHE_CHECKAUX_OKAY;
52471 }
52472
52473 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52474 switch (result) {
52475 /* entry okay as is */
52476 case FSCACHE_CHECKAUX_OKAY:
52477 - fscache_stat(&fscache_n_checkaux_okay);
52478 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52479 break;
52480
52481 /* entry requires update */
52482 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52483 - fscache_stat(&fscache_n_checkaux_update);
52484 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52485 break;
52486
52487 /* entry requires deletion */
52488 case FSCACHE_CHECKAUX_OBSOLETE:
52489 - fscache_stat(&fscache_n_checkaux_obsolete);
52490 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52491 break;
52492
52493 default:
52494 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52495 index 762a9ec..2023284 100644
52496 --- a/fs/fscache/operation.c
52497 +++ b/fs/fscache/operation.c
52498 @@ -17,7 +17,7 @@
52499 #include <linux/slab.h>
52500 #include "internal.h"
52501
52502 -atomic_t fscache_op_debug_id;
52503 +atomic_unchecked_t fscache_op_debug_id;
52504 EXPORT_SYMBOL(fscache_op_debug_id);
52505
52506 /**
52507 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52508 ASSERTCMP(atomic_read(&op->usage), >, 0);
52509 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52510
52511 - fscache_stat(&fscache_n_op_enqueue);
52512 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52513 switch (op->flags & FSCACHE_OP_TYPE) {
52514 case FSCACHE_OP_ASYNC:
52515 _debug("queue async");
52516 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52517 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52518 if (op->processor)
52519 fscache_enqueue_operation(op);
52520 - fscache_stat(&fscache_n_op_run);
52521 + fscache_stat_unchecked(&fscache_n_op_run);
52522 }
52523
52524 /*
52525 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52526 if (object->n_in_progress > 0) {
52527 atomic_inc(&op->usage);
52528 list_add_tail(&op->pend_link, &object->pending_ops);
52529 - fscache_stat(&fscache_n_op_pend);
52530 + fscache_stat_unchecked(&fscache_n_op_pend);
52531 } else if (!list_empty(&object->pending_ops)) {
52532 atomic_inc(&op->usage);
52533 list_add_tail(&op->pend_link, &object->pending_ops);
52534 - fscache_stat(&fscache_n_op_pend);
52535 + fscache_stat_unchecked(&fscache_n_op_pend);
52536 fscache_start_operations(object);
52537 } else {
52538 ASSERTCMP(object->n_in_progress, ==, 0);
52539 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52540 object->n_exclusive++; /* reads and writes must wait */
52541 atomic_inc(&op->usage);
52542 list_add_tail(&op->pend_link, &object->pending_ops);
52543 - fscache_stat(&fscache_n_op_pend);
52544 + fscache_stat_unchecked(&fscache_n_op_pend);
52545 ret = 0;
52546 } else {
52547 /* If we're in any other state, there must have been an I/O
52548 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52549 if (object->n_exclusive > 0) {
52550 atomic_inc(&op->usage);
52551 list_add_tail(&op->pend_link, &object->pending_ops);
52552 - fscache_stat(&fscache_n_op_pend);
52553 + fscache_stat_unchecked(&fscache_n_op_pend);
52554 } else if (!list_empty(&object->pending_ops)) {
52555 atomic_inc(&op->usage);
52556 list_add_tail(&op->pend_link, &object->pending_ops);
52557 - fscache_stat(&fscache_n_op_pend);
52558 + fscache_stat_unchecked(&fscache_n_op_pend);
52559 fscache_start_operations(object);
52560 } else {
52561 ASSERTCMP(object->n_exclusive, ==, 0);
52562 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52563 object->n_ops++;
52564 atomic_inc(&op->usage);
52565 list_add_tail(&op->pend_link, &object->pending_ops);
52566 - fscache_stat(&fscache_n_op_pend);
52567 + fscache_stat_unchecked(&fscache_n_op_pend);
52568 ret = 0;
52569 } else if (object->state == FSCACHE_OBJECT_DYING ||
52570 object->state == FSCACHE_OBJECT_LC_DYING ||
52571 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52572 - fscache_stat(&fscache_n_op_rejected);
52573 + fscache_stat_unchecked(&fscache_n_op_rejected);
52574 op->state = FSCACHE_OP_ST_CANCELLED;
52575 ret = -ENOBUFS;
52576 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52577 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52578 ret = -EBUSY;
52579 if (op->state == FSCACHE_OP_ST_PENDING) {
52580 ASSERT(!list_empty(&op->pend_link));
52581 - fscache_stat(&fscache_n_op_cancelled);
52582 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52583 list_del_init(&op->pend_link);
52584 if (do_cancel)
52585 do_cancel(op);
52586 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52587 while (!list_empty(&object->pending_ops)) {
52588 op = list_entry(object->pending_ops.next,
52589 struct fscache_operation, pend_link);
52590 - fscache_stat(&fscache_n_op_cancelled);
52591 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52592 list_del_init(&op->pend_link);
52593
52594 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52595 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52596 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52597 op->state = FSCACHE_OP_ST_DEAD;
52598
52599 - fscache_stat(&fscache_n_op_release);
52600 + fscache_stat_unchecked(&fscache_n_op_release);
52601
52602 if (op->release) {
52603 op->release(op);
52604 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52605 * lock, and defer it otherwise */
52606 if (!spin_trylock(&object->lock)) {
52607 _debug("defer put");
52608 - fscache_stat(&fscache_n_op_deferred_release);
52609 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52610
52611 cache = object->cache;
52612 spin_lock(&cache->op_gc_list_lock);
52613 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52614
52615 _debug("GC DEFERRED REL OBJ%x OP%x",
52616 object->debug_id, op->debug_id);
52617 - fscache_stat(&fscache_n_op_gc);
52618 + fscache_stat_unchecked(&fscache_n_op_gc);
52619
52620 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52621 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52622 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52623 index ff000e5..c44ec6d 100644
52624 --- a/fs/fscache/page.c
52625 +++ b/fs/fscache/page.c
52626 @@ -61,7 +61,7 @@ try_again:
52627 val = radix_tree_lookup(&cookie->stores, page->index);
52628 if (!val) {
52629 rcu_read_unlock();
52630 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52631 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52632 __fscache_uncache_page(cookie, page);
52633 return true;
52634 }
52635 @@ -91,11 +91,11 @@ try_again:
52636 spin_unlock(&cookie->stores_lock);
52637
52638 if (xpage) {
52639 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52640 - fscache_stat(&fscache_n_store_radix_deletes);
52641 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52642 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52643 ASSERTCMP(xpage, ==, page);
52644 } else {
52645 - fscache_stat(&fscache_n_store_vmscan_gone);
52646 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52647 }
52648
52649 wake_up_bit(&cookie->flags, 0);
52650 @@ -110,11 +110,11 @@ page_busy:
52651 * sleeping on memory allocation, so we may need to impose a timeout
52652 * too. */
52653 if (!(gfp & __GFP_WAIT)) {
52654 - fscache_stat(&fscache_n_store_vmscan_busy);
52655 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52656 return false;
52657 }
52658
52659 - fscache_stat(&fscache_n_store_vmscan_wait);
52660 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52661 __fscache_wait_on_page_write(cookie, page);
52662 gfp &= ~__GFP_WAIT;
52663 goto try_again;
52664 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52665 FSCACHE_COOKIE_STORING_TAG);
52666 if (!radix_tree_tag_get(&cookie->stores, page->index,
52667 FSCACHE_COOKIE_PENDING_TAG)) {
52668 - fscache_stat(&fscache_n_store_radix_deletes);
52669 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52670 xpage = radix_tree_delete(&cookie->stores, page->index);
52671 }
52672 spin_unlock(&cookie->stores_lock);
52673 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52674
52675 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52676
52677 - fscache_stat(&fscache_n_attr_changed_calls);
52678 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52679
52680 if (fscache_object_is_active(object)) {
52681 fscache_stat(&fscache_n_cop_attr_changed);
52682 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52683
52684 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52685
52686 - fscache_stat(&fscache_n_attr_changed);
52687 + fscache_stat_unchecked(&fscache_n_attr_changed);
52688
52689 op = kzalloc(sizeof(*op), GFP_KERNEL);
52690 if (!op) {
52691 - fscache_stat(&fscache_n_attr_changed_nomem);
52692 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52693 _leave(" = -ENOMEM");
52694 return -ENOMEM;
52695 }
52696 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52697 if (fscache_submit_exclusive_op(object, op) < 0)
52698 goto nobufs;
52699 spin_unlock(&cookie->lock);
52700 - fscache_stat(&fscache_n_attr_changed_ok);
52701 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52702 fscache_put_operation(op);
52703 _leave(" = 0");
52704 return 0;
52705 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52706 nobufs:
52707 spin_unlock(&cookie->lock);
52708 kfree(op);
52709 - fscache_stat(&fscache_n_attr_changed_nobufs);
52710 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52711 _leave(" = %d", -ENOBUFS);
52712 return -ENOBUFS;
52713 }
52714 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52715 /* allocate a retrieval operation and attempt to submit it */
52716 op = kzalloc(sizeof(*op), GFP_NOIO);
52717 if (!op) {
52718 - fscache_stat(&fscache_n_retrievals_nomem);
52719 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52720 return NULL;
52721 }
52722
52723 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52724 return 0;
52725 }
52726
52727 - fscache_stat(&fscache_n_retrievals_wait);
52728 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52729
52730 jif = jiffies;
52731 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52732 fscache_wait_bit_interruptible,
52733 TASK_INTERRUPTIBLE) != 0) {
52734 - fscache_stat(&fscache_n_retrievals_intr);
52735 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52736 _leave(" = -ERESTARTSYS");
52737 return -ERESTARTSYS;
52738 }
52739 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52740 */
52741 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52742 struct fscache_retrieval *op,
52743 - atomic_t *stat_op_waits,
52744 - atomic_t *stat_object_dead)
52745 + atomic_unchecked_t *stat_op_waits,
52746 + atomic_unchecked_t *stat_object_dead)
52747 {
52748 int ret;
52749
52750 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52751 goto check_if_dead;
52752
52753 _debug(">>> WT");
52754 - fscache_stat(stat_op_waits);
52755 + fscache_stat_unchecked(stat_op_waits);
52756 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52757 fscache_wait_bit_interruptible,
52758 TASK_INTERRUPTIBLE) != 0) {
52759 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52760
52761 check_if_dead:
52762 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52763 - fscache_stat(stat_object_dead);
52764 + fscache_stat_unchecked(stat_object_dead);
52765 _leave(" = -ENOBUFS [cancelled]");
52766 return -ENOBUFS;
52767 }
52768 if (unlikely(fscache_object_is_dead(object))) {
52769 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52770 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52771 - fscache_stat(stat_object_dead);
52772 + fscache_stat_unchecked(stat_object_dead);
52773 return -ENOBUFS;
52774 }
52775 return 0;
52776 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52777
52778 _enter("%p,%p,,,", cookie, page);
52779
52780 - fscache_stat(&fscache_n_retrievals);
52781 + fscache_stat_unchecked(&fscache_n_retrievals);
52782
52783 if (hlist_empty(&cookie->backing_objects))
52784 goto nobufs;
52785 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52786 goto nobufs_unlock_dec;
52787 spin_unlock(&cookie->lock);
52788
52789 - fscache_stat(&fscache_n_retrieval_ops);
52790 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52791
52792 /* pin the netfs read context in case we need to do the actual netfs
52793 * read because we've encountered a cache read failure */
52794 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52795
52796 error:
52797 if (ret == -ENOMEM)
52798 - fscache_stat(&fscache_n_retrievals_nomem);
52799 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52800 else if (ret == -ERESTARTSYS)
52801 - fscache_stat(&fscache_n_retrievals_intr);
52802 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52803 else if (ret == -ENODATA)
52804 - fscache_stat(&fscache_n_retrievals_nodata);
52805 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52806 else if (ret < 0)
52807 - fscache_stat(&fscache_n_retrievals_nobufs);
52808 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52809 else
52810 - fscache_stat(&fscache_n_retrievals_ok);
52811 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52812
52813 fscache_put_retrieval(op);
52814 _leave(" = %d", ret);
52815 @@ -467,7 +467,7 @@ nobufs_unlock:
52816 spin_unlock(&cookie->lock);
52817 kfree(op);
52818 nobufs:
52819 - fscache_stat(&fscache_n_retrievals_nobufs);
52820 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52821 _leave(" = -ENOBUFS");
52822 return -ENOBUFS;
52823 }
52824 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52825
52826 _enter("%p,,%d,,,", cookie, *nr_pages);
52827
52828 - fscache_stat(&fscache_n_retrievals);
52829 + fscache_stat_unchecked(&fscache_n_retrievals);
52830
52831 if (hlist_empty(&cookie->backing_objects))
52832 goto nobufs;
52833 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52834 goto nobufs_unlock_dec;
52835 spin_unlock(&cookie->lock);
52836
52837 - fscache_stat(&fscache_n_retrieval_ops);
52838 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52839
52840 /* pin the netfs read context in case we need to do the actual netfs
52841 * read because we've encountered a cache read failure */
52842 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52843
52844 error:
52845 if (ret == -ENOMEM)
52846 - fscache_stat(&fscache_n_retrievals_nomem);
52847 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52848 else if (ret == -ERESTARTSYS)
52849 - fscache_stat(&fscache_n_retrievals_intr);
52850 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52851 else if (ret == -ENODATA)
52852 - fscache_stat(&fscache_n_retrievals_nodata);
52853 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52854 else if (ret < 0)
52855 - fscache_stat(&fscache_n_retrievals_nobufs);
52856 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52857 else
52858 - fscache_stat(&fscache_n_retrievals_ok);
52859 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52860
52861 fscache_put_retrieval(op);
52862 _leave(" = %d", ret);
52863 @@ -591,7 +591,7 @@ nobufs_unlock:
52864 spin_unlock(&cookie->lock);
52865 kfree(op);
52866 nobufs:
52867 - fscache_stat(&fscache_n_retrievals_nobufs);
52868 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52869 _leave(" = -ENOBUFS");
52870 return -ENOBUFS;
52871 }
52872 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52873
52874 _enter("%p,%p,,,", cookie, page);
52875
52876 - fscache_stat(&fscache_n_allocs);
52877 + fscache_stat_unchecked(&fscache_n_allocs);
52878
52879 if (hlist_empty(&cookie->backing_objects))
52880 goto nobufs;
52881 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52882 goto nobufs_unlock;
52883 spin_unlock(&cookie->lock);
52884
52885 - fscache_stat(&fscache_n_alloc_ops);
52886 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52887
52888 ret = fscache_wait_for_retrieval_activation(
52889 object, op,
52890 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52891
52892 error:
52893 if (ret == -ERESTARTSYS)
52894 - fscache_stat(&fscache_n_allocs_intr);
52895 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52896 else if (ret < 0)
52897 - fscache_stat(&fscache_n_allocs_nobufs);
52898 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52899 else
52900 - fscache_stat(&fscache_n_allocs_ok);
52901 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52902
52903 fscache_put_retrieval(op);
52904 _leave(" = %d", ret);
52905 @@ -677,7 +677,7 @@ nobufs_unlock:
52906 spin_unlock(&cookie->lock);
52907 kfree(op);
52908 nobufs:
52909 - fscache_stat(&fscache_n_allocs_nobufs);
52910 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52911 _leave(" = -ENOBUFS");
52912 return -ENOBUFS;
52913 }
52914 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52915
52916 spin_lock(&cookie->stores_lock);
52917
52918 - fscache_stat(&fscache_n_store_calls);
52919 + fscache_stat_unchecked(&fscache_n_store_calls);
52920
52921 /* find a page to store */
52922 page = NULL;
52923 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52924 page = results[0];
52925 _debug("gang %d [%lx]", n, page->index);
52926 if (page->index > op->store_limit) {
52927 - fscache_stat(&fscache_n_store_pages_over_limit);
52928 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52929 goto superseded;
52930 }
52931
52932 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52933 spin_unlock(&cookie->stores_lock);
52934 spin_unlock(&object->lock);
52935
52936 - fscache_stat(&fscache_n_store_pages);
52937 + fscache_stat_unchecked(&fscache_n_store_pages);
52938 fscache_stat(&fscache_n_cop_write_page);
52939 ret = object->cache->ops->write_page(op, page);
52940 fscache_stat_d(&fscache_n_cop_write_page);
52941 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52942 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52943 ASSERT(PageFsCache(page));
52944
52945 - fscache_stat(&fscache_n_stores);
52946 + fscache_stat_unchecked(&fscache_n_stores);
52947
52948 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52949 _leave(" = -ENOBUFS [invalidating]");
52950 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52951 spin_unlock(&cookie->stores_lock);
52952 spin_unlock(&object->lock);
52953
52954 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52955 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52956 op->store_limit = object->store_limit;
52957
52958 if (fscache_submit_op(object, &op->op) < 0)
52959 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52960
52961 spin_unlock(&cookie->lock);
52962 radix_tree_preload_end();
52963 - fscache_stat(&fscache_n_store_ops);
52964 - fscache_stat(&fscache_n_stores_ok);
52965 + fscache_stat_unchecked(&fscache_n_store_ops);
52966 + fscache_stat_unchecked(&fscache_n_stores_ok);
52967
52968 /* the work queue now carries its own ref on the object */
52969 fscache_put_operation(&op->op);
52970 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52971 return 0;
52972
52973 already_queued:
52974 - fscache_stat(&fscache_n_stores_again);
52975 + fscache_stat_unchecked(&fscache_n_stores_again);
52976 already_pending:
52977 spin_unlock(&cookie->stores_lock);
52978 spin_unlock(&object->lock);
52979 spin_unlock(&cookie->lock);
52980 radix_tree_preload_end();
52981 kfree(op);
52982 - fscache_stat(&fscache_n_stores_ok);
52983 + fscache_stat_unchecked(&fscache_n_stores_ok);
52984 _leave(" = 0");
52985 return 0;
52986
52987 @@ -959,14 +959,14 @@ nobufs:
52988 spin_unlock(&cookie->lock);
52989 radix_tree_preload_end();
52990 kfree(op);
52991 - fscache_stat(&fscache_n_stores_nobufs);
52992 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52993 _leave(" = -ENOBUFS");
52994 return -ENOBUFS;
52995
52996 nomem_free:
52997 kfree(op);
52998 nomem:
52999 - fscache_stat(&fscache_n_stores_oom);
53000 + fscache_stat_unchecked(&fscache_n_stores_oom);
53001 _leave(" = -ENOMEM");
53002 return -ENOMEM;
53003 }
53004 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
53005 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
53006 ASSERTCMP(page, !=, NULL);
53007
53008 - fscache_stat(&fscache_n_uncaches);
53009 + fscache_stat_unchecked(&fscache_n_uncaches);
53010
53011 /* cache withdrawal may beat us to it */
53012 if (!PageFsCache(page))
53013 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
53014 struct fscache_cookie *cookie = op->op.object->cookie;
53015
53016 #ifdef CONFIG_FSCACHE_STATS
53017 - atomic_inc(&fscache_n_marks);
53018 + atomic_inc_unchecked(&fscache_n_marks);
53019 #endif
53020
53021 _debug("- mark %p{%lx}", page, page->index);
53022 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
53023 index 8179e8b..5072cc7 100644
53024 --- a/fs/fscache/stats.c
53025 +++ b/fs/fscache/stats.c
53026 @@ -18,99 +18,99 @@
53027 /*
53028 * operation counters
53029 */
53030 -atomic_t fscache_n_op_pend;
53031 -atomic_t fscache_n_op_run;
53032 -atomic_t fscache_n_op_enqueue;
53033 -atomic_t fscache_n_op_requeue;
53034 -atomic_t fscache_n_op_deferred_release;
53035 -atomic_t fscache_n_op_release;
53036 -atomic_t fscache_n_op_gc;
53037 -atomic_t fscache_n_op_cancelled;
53038 -atomic_t fscache_n_op_rejected;
53039 +atomic_unchecked_t fscache_n_op_pend;
53040 +atomic_unchecked_t fscache_n_op_run;
53041 +atomic_unchecked_t fscache_n_op_enqueue;
53042 +atomic_unchecked_t fscache_n_op_requeue;
53043 +atomic_unchecked_t fscache_n_op_deferred_release;
53044 +atomic_unchecked_t fscache_n_op_release;
53045 +atomic_unchecked_t fscache_n_op_gc;
53046 +atomic_unchecked_t fscache_n_op_cancelled;
53047 +atomic_unchecked_t fscache_n_op_rejected;
53048
53049 -atomic_t fscache_n_attr_changed;
53050 -atomic_t fscache_n_attr_changed_ok;
53051 -atomic_t fscache_n_attr_changed_nobufs;
53052 -atomic_t fscache_n_attr_changed_nomem;
53053 -atomic_t fscache_n_attr_changed_calls;
53054 +atomic_unchecked_t fscache_n_attr_changed;
53055 +atomic_unchecked_t fscache_n_attr_changed_ok;
53056 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
53057 +atomic_unchecked_t fscache_n_attr_changed_nomem;
53058 +atomic_unchecked_t fscache_n_attr_changed_calls;
53059
53060 -atomic_t fscache_n_allocs;
53061 -atomic_t fscache_n_allocs_ok;
53062 -atomic_t fscache_n_allocs_wait;
53063 -atomic_t fscache_n_allocs_nobufs;
53064 -atomic_t fscache_n_allocs_intr;
53065 -atomic_t fscache_n_allocs_object_dead;
53066 -atomic_t fscache_n_alloc_ops;
53067 -atomic_t fscache_n_alloc_op_waits;
53068 +atomic_unchecked_t fscache_n_allocs;
53069 +atomic_unchecked_t fscache_n_allocs_ok;
53070 +atomic_unchecked_t fscache_n_allocs_wait;
53071 +atomic_unchecked_t fscache_n_allocs_nobufs;
53072 +atomic_unchecked_t fscache_n_allocs_intr;
53073 +atomic_unchecked_t fscache_n_allocs_object_dead;
53074 +atomic_unchecked_t fscache_n_alloc_ops;
53075 +atomic_unchecked_t fscache_n_alloc_op_waits;
53076
53077 -atomic_t fscache_n_retrievals;
53078 -atomic_t fscache_n_retrievals_ok;
53079 -atomic_t fscache_n_retrievals_wait;
53080 -atomic_t fscache_n_retrievals_nodata;
53081 -atomic_t fscache_n_retrievals_nobufs;
53082 -atomic_t fscache_n_retrievals_intr;
53083 -atomic_t fscache_n_retrievals_nomem;
53084 -atomic_t fscache_n_retrievals_object_dead;
53085 -atomic_t fscache_n_retrieval_ops;
53086 -atomic_t fscache_n_retrieval_op_waits;
53087 +atomic_unchecked_t fscache_n_retrievals;
53088 +atomic_unchecked_t fscache_n_retrievals_ok;
53089 +atomic_unchecked_t fscache_n_retrievals_wait;
53090 +atomic_unchecked_t fscache_n_retrievals_nodata;
53091 +atomic_unchecked_t fscache_n_retrievals_nobufs;
53092 +atomic_unchecked_t fscache_n_retrievals_intr;
53093 +atomic_unchecked_t fscache_n_retrievals_nomem;
53094 +atomic_unchecked_t fscache_n_retrievals_object_dead;
53095 +atomic_unchecked_t fscache_n_retrieval_ops;
53096 +atomic_unchecked_t fscache_n_retrieval_op_waits;
53097
53098 -atomic_t fscache_n_stores;
53099 -atomic_t fscache_n_stores_ok;
53100 -atomic_t fscache_n_stores_again;
53101 -atomic_t fscache_n_stores_nobufs;
53102 -atomic_t fscache_n_stores_oom;
53103 -atomic_t fscache_n_store_ops;
53104 -atomic_t fscache_n_store_calls;
53105 -atomic_t fscache_n_store_pages;
53106 -atomic_t fscache_n_store_radix_deletes;
53107 -atomic_t fscache_n_store_pages_over_limit;
53108 +atomic_unchecked_t fscache_n_stores;
53109 +atomic_unchecked_t fscache_n_stores_ok;
53110 +atomic_unchecked_t fscache_n_stores_again;
53111 +atomic_unchecked_t fscache_n_stores_nobufs;
53112 +atomic_unchecked_t fscache_n_stores_oom;
53113 +atomic_unchecked_t fscache_n_store_ops;
53114 +atomic_unchecked_t fscache_n_store_calls;
53115 +atomic_unchecked_t fscache_n_store_pages;
53116 +atomic_unchecked_t fscache_n_store_radix_deletes;
53117 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53118
53119 -atomic_t fscache_n_store_vmscan_not_storing;
53120 -atomic_t fscache_n_store_vmscan_gone;
53121 -atomic_t fscache_n_store_vmscan_busy;
53122 -atomic_t fscache_n_store_vmscan_cancelled;
53123 -atomic_t fscache_n_store_vmscan_wait;
53124 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53125 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53126 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53127 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53128 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53129
53130 -atomic_t fscache_n_marks;
53131 -atomic_t fscache_n_uncaches;
53132 +atomic_unchecked_t fscache_n_marks;
53133 +atomic_unchecked_t fscache_n_uncaches;
53134
53135 -atomic_t fscache_n_acquires;
53136 -atomic_t fscache_n_acquires_null;
53137 -atomic_t fscache_n_acquires_no_cache;
53138 -atomic_t fscache_n_acquires_ok;
53139 -atomic_t fscache_n_acquires_nobufs;
53140 -atomic_t fscache_n_acquires_oom;
53141 +atomic_unchecked_t fscache_n_acquires;
53142 +atomic_unchecked_t fscache_n_acquires_null;
53143 +atomic_unchecked_t fscache_n_acquires_no_cache;
53144 +atomic_unchecked_t fscache_n_acquires_ok;
53145 +atomic_unchecked_t fscache_n_acquires_nobufs;
53146 +atomic_unchecked_t fscache_n_acquires_oom;
53147
53148 -atomic_t fscache_n_invalidates;
53149 -atomic_t fscache_n_invalidates_run;
53150 +atomic_unchecked_t fscache_n_invalidates;
53151 +atomic_unchecked_t fscache_n_invalidates_run;
53152
53153 -atomic_t fscache_n_updates;
53154 -atomic_t fscache_n_updates_null;
53155 -atomic_t fscache_n_updates_run;
53156 +atomic_unchecked_t fscache_n_updates;
53157 +atomic_unchecked_t fscache_n_updates_null;
53158 +atomic_unchecked_t fscache_n_updates_run;
53159
53160 -atomic_t fscache_n_relinquishes;
53161 -atomic_t fscache_n_relinquishes_null;
53162 -atomic_t fscache_n_relinquishes_waitcrt;
53163 -atomic_t fscache_n_relinquishes_retire;
53164 +atomic_unchecked_t fscache_n_relinquishes;
53165 +atomic_unchecked_t fscache_n_relinquishes_null;
53166 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53167 +atomic_unchecked_t fscache_n_relinquishes_retire;
53168
53169 -atomic_t fscache_n_cookie_index;
53170 -atomic_t fscache_n_cookie_data;
53171 -atomic_t fscache_n_cookie_special;
53172 +atomic_unchecked_t fscache_n_cookie_index;
53173 +atomic_unchecked_t fscache_n_cookie_data;
53174 +atomic_unchecked_t fscache_n_cookie_special;
53175
53176 -atomic_t fscache_n_object_alloc;
53177 -atomic_t fscache_n_object_no_alloc;
53178 -atomic_t fscache_n_object_lookups;
53179 -atomic_t fscache_n_object_lookups_negative;
53180 -atomic_t fscache_n_object_lookups_positive;
53181 -atomic_t fscache_n_object_lookups_timed_out;
53182 -atomic_t fscache_n_object_created;
53183 -atomic_t fscache_n_object_avail;
53184 -atomic_t fscache_n_object_dead;
53185 +atomic_unchecked_t fscache_n_object_alloc;
53186 +atomic_unchecked_t fscache_n_object_no_alloc;
53187 +atomic_unchecked_t fscache_n_object_lookups;
53188 +atomic_unchecked_t fscache_n_object_lookups_negative;
53189 +atomic_unchecked_t fscache_n_object_lookups_positive;
53190 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53191 +atomic_unchecked_t fscache_n_object_created;
53192 +atomic_unchecked_t fscache_n_object_avail;
53193 +atomic_unchecked_t fscache_n_object_dead;
53194
53195 -atomic_t fscache_n_checkaux_none;
53196 -atomic_t fscache_n_checkaux_okay;
53197 -atomic_t fscache_n_checkaux_update;
53198 -atomic_t fscache_n_checkaux_obsolete;
53199 +atomic_unchecked_t fscache_n_checkaux_none;
53200 +atomic_unchecked_t fscache_n_checkaux_okay;
53201 +atomic_unchecked_t fscache_n_checkaux_update;
53202 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53203
53204 atomic_t fscache_n_cop_alloc_object;
53205 atomic_t fscache_n_cop_lookup_object;
53206 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53207 seq_puts(m, "FS-Cache statistics\n");
53208
53209 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53210 - atomic_read(&fscache_n_cookie_index),
53211 - atomic_read(&fscache_n_cookie_data),
53212 - atomic_read(&fscache_n_cookie_special));
53213 + atomic_read_unchecked(&fscache_n_cookie_index),
53214 + atomic_read_unchecked(&fscache_n_cookie_data),
53215 + atomic_read_unchecked(&fscache_n_cookie_special));
53216
53217 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53218 - atomic_read(&fscache_n_object_alloc),
53219 - atomic_read(&fscache_n_object_no_alloc),
53220 - atomic_read(&fscache_n_object_avail),
53221 - atomic_read(&fscache_n_object_dead));
53222 + atomic_read_unchecked(&fscache_n_object_alloc),
53223 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53224 + atomic_read_unchecked(&fscache_n_object_avail),
53225 + atomic_read_unchecked(&fscache_n_object_dead));
53226 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53227 - atomic_read(&fscache_n_checkaux_none),
53228 - atomic_read(&fscache_n_checkaux_okay),
53229 - atomic_read(&fscache_n_checkaux_update),
53230 - atomic_read(&fscache_n_checkaux_obsolete));
53231 + atomic_read_unchecked(&fscache_n_checkaux_none),
53232 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53233 + atomic_read_unchecked(&fscache_n_checkaux_update),
53234 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53235
53236 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53237 - atomic_read(&fscache_n_marks),
53238 - atomic_read(&fscache_n_uncaches));
53239 + atomic_read_unchecked(&fscache_n_marks),
53240 + atomic_read_unchecked(&fscache_n_uncaches));
53241
53242 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53243 " oom=%u\n",
53244 - atomic_read(&fscache_n_acquires),
53245 - atomic_read(&fscache_n_acquires_null),
53246 - atomic_read(&fscache_n_acquires_no_cache),
53247 - atomic_read(&fscache_n_acquires_ok),
53248 - atomic_read(&fscache_n_acquires_nobufs),
53249 - atomic_read(&fscache_n_acquires_oom));
53250 + atomic_read_unchecked(&fscache_n_acquires),
53251 + atomic_read_unchecked(&fscache_n_acquires_null),
53252 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53253 + atomic_read_unchecked(&fscache_n_acquires_ok),
53254 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53255 + atomic_read_unchecked(&fscache_n_acquires_oom));
53256
53257 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53258 - atomic_read(&fscache_n_object_lookups),
53259 - atomic_read(&fscache_n_object_lookups_negative),
53260 - atomic_read(&fscache_n_object_lookups_positive),
53261 - atomic_read(&fscache_n_object_created),
53262 - atomic_read(&fscache_n_object_lookups_timed_out));
53263 + atomic_read_unchecked(&fscache_n_object_lookups),
53264 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53265 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53266 + atomic_read_unchecked(&fscache_n_object_created),
53267 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53268
53269 seq_printf(m, "Invals : n=%u run=%u\n",
53270 - atomic_read(&fscache_n_invalidates),
53271 - atomic_read(&fscache_n_invalidates_run));
53272 + atomic_read_unchecked(&fscache_n_invalidates),
53273 + atomic_read_unchecked(&fscache_n_invalidates_run));
53274
53275 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53276 - atomic_read(&fscache_n_updates),
53277 - atomic_read(&fscache_n_updates_null),
53278 - atomic_read(&fscache_n_updates_run));
53279 + atomic_read_unchecked(&fscache_n_updates),
53280 + atomic_read_unchecked(&fscache_n_updates_null),
53281 + atomic_read_unchecked(&fscache_n_updates_run));
53282
53283 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53284 - atomic_read(&fscache_n_relinquishes),
53285 - atomic_read(&fscache_n_relinquishes_null),
53286 - atomic_read(&fscache_n_relinquishes_waitcrt),
53287 - atomic_read(&fscache_n_relinquishes_retire));
53288 + atomic_read_unchecked(&fscache_n_relinquishes),
53289 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53290 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53291 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53292
53293 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53294 - atomic_read(&fscache_n_attr_changed),
53295 - atomic_read(&fscache_n_attr_changed_ok),
53296 - atomic_read(&fscache_n_attr_changed_nobufs),
53297 - atomic_read(&fscache_n_attr_changed_nomem),
53298 - atomic_read(&fscache_n_attr_changed_calls));
53299 + atomic_read_unchecked(&fscache_n_attr_changed),
53300 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53301 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53302 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53303 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53304
53305 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53306 - atomic_read(&fscache_n_allocs),
53307 - atomic_read(&fscache_n_allocs_ok),
53308 - atomic_read(&fscache_n_allocs_wait),
53309 - atomic_read(&fscache_n_allocs_nobufs),
53310 - atomic_read(&fscache_n_allocs_intr));
53311 + atomic_read_unchecked(&fscache_n_allocs),
53312 + atomic_read_unchecked(&fscache_n_allocs_ok),
53313 + atomic_read_unchecked(&fscache_n_allocs_wait),
53314 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53315 + atomic_read_unchecked(&fscache_n_allocs_intr));
53316 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53317 - atomic_read(&fscache_n_alloc_ops),
53318 - atomic_read(&fscache_n_alloc_op_waits),
53319 - atomic_read(&fscache_n_allocs_object_dead));
53320 + atomic_read_unchecked(&fscache_n_alloc_ops),
53321 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53322 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53323
53324 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53325 " int=%u oom=%u\n",
53326 - atomic_read(&fscache_n_retrievals),
53327 - atomic_read(&fscache_n_retrievals_ok),
53328 - atomic_read(&fscache_n_retrievals_wait),
53329 - atomic_read(&fscache_n_retrievals_nodata),
53330 - atomic_read(&fscache_n_retrievals_nobufs),
53331 - atomic_read(&fscache_n_retrievals_intr),
53332 - atomic_read(&fscache_n_retrievals_nomem));
53333 + atomic_read_unchecked(&fscache_n_retrievals),
53334 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53335 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53336 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53337 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53338 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53339 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53340 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53341 - atomic_read(&fscache_n_retrieval_ops),
53342 - atomic_read(&fscache_n_retrieval_op_waits),
53343 - atomic_read(&fscache_n_retrievals_object_dead));
53344 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53345 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53346 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53347
53348 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53349 - atomic_read(&fscache_n_stores),
53350 - atomic_read(&fscache_n_stores_ok),
53351 - atomic_read(&fscache_n_stores_again),
53352 - atomic_read(&fscache_n_stores_nobufs),
53353 - atomic_read(&fscache_n_stores_oom));
53354 + atomic_read_unchecked(&fscache_n_stores),
53355 + atomic_read_unchecked(&fscache_n_stores_ok),
53356 + atomic_read_unchecked(&fscache_n_stores_again),
53357 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53358 + atomic_read_unchecked(&fscache_n_stores_oom));
53359 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53360 - atomic_read(&fscache_n_store_ops),
53361 - atomic_read(&fscache_n_store_calls),
53362 - atomic_read(&fscache_n_store_pages),
53363 - atomic_read(&fscache_n_store_radix_deletes),
53364 - atomic_read(&fscache_n_store_pages_over_limit));
53365 + atomic_read_unchecked(&fscache_n_store_ops),
53366 + atomic_read_unchecked(&fscache_n_store_calls),
53367 + atomic_read_unchecked(&fscache_n_store_pages),
53368 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53369 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53370
53371 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53372 - atomic_read(&fscache_n_store_vmscan_not_storing),
53373 - atomic_read(&fscache_n_store_vmscan_gone),
53374 - atomic_read(&fscache_n_store_vmscan_busy),
53375 - atomic_read(&fscache_n_store_vmscan_cancelled),
53376 - atomic_read(&fscache_n_store_vmscan_wait));
53377 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53378 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53379 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53380 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53381 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53382
53383 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53384 - atomic_read(&fscache_n_op_pend),
53385 - atomic_read(&fscache_n_op_run),
53386 - atomic_read(&fscache_n_op_enqueue),
53387 - atomic_read(&fscache_n_op_cancelled),
53388 - atomic_read(&fscache_n_op_rejected));
53389 + atomic_read_unchecked(&fscache_n_op_pend),
53390 + atomic_read_unchecked(&fscache_n_op_run),
53391 + atomic_read_unchecked(&fscache_n_op_enqueue),
53392 + atomic_read_unchecked(&fscache_n_op_cancelled),
53393 + atomic_read_unchecked(&fscache_n_op_rejected));
53394 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53395 - atomic_read(&fscache_n_op_deferred_release),
53396 - atomic_read(&fscache_n_op_release),
53397 - atomic_read(&fscache_n_op_gc));
53398 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53399 + atomic_read_unchecked(&fscache_n_op_release),
53400 + atomic_read_unchecked(&fscache_n_op_gc));
53401
53402 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53403 atomic_read(&fscache_n_cop_alloc_object),
53404 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53405 index e397b67..b0d8709 100644
53406 --- a/fs/fuse/cuse.c
53407 +++ b/fs/fuse/cuse.c
53408 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
53409 INIT_LIST_HEAD(&cuse_conntbl[i]);
53410
53411 /* inherit and extend fuse_dev_operations */
53412 - cuse_channel_fops = fuse_dev_operations;
53413 - cuse_channel_fops.owner = THIS_MODULE;
53414 - cuse_channel_fops.open = cuse_channel_open;
53415 - cuse_channel_fops.release = cuse_channel_release;
53416 + pax_open_kernel();
53417 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53418 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53419 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53420 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53421 + pax_close_kernel();
53422
53423 cuse_class = class_create(THIS_MODULE, "cuse");
53424 if (IS_ERR(cuse_class))
53425 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53426 index e83351a..41e3c9c 100644
53427 --- a/fs/fuse/dev.c
53428 +++ b/fs/fuse/dev.c
53429 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53430 ret = 0;
53431 pipe_lock(pipe);
53432
53433 - if (!pipe->readers) {
53434 + if (!atomic_read(&pipe->readers)) {
53435 send_sig(SIGPIPE, current, 0);
53436 if (!ret)
53437 ret = -EPIPE;
53438 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53439 index 315e1f8..91f890c 100644
53440 --- a/fs/fuse/dir.c
53441 +++ b/fs/fuse/dir.c
53442 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
53443 return link;
53444 }
53445
53446 -static void free_link(char *link)
53447 +static void free_link(const char *link)
53448 {
53449 if (!IS_ERR(link))
53450 free_page((unsigned long) link);
53451 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53452 index 2b6f569..fcb4d1f 100644
53453 --- a/fs/gfs2/inode.c
53454 +++ b/fs/gfs2/inode.c
53455 @@ -1499,7 +1499,7 @@ out:
53456
53457 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53458 {
53459 - char *s = nd_get_link(nd);
53460 + const char *s = nd_get_link(nd);
53461 if (!IS_ERR(s))
53462 kfree(s);
53463 }
53464 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53465 index ccee8cc..144b5d7 100644
53466 --- a/fs/hugetlbfs/inode.c
53467 +++ b/fs/hugetlbfs/inode.c
53468 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53469 struct mm_struct *mm = current->mm;
53470 struct vm_area_struct *vma;
53471 struct hstate *h = hstate_file(file);
53472 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53473 struct vm_unmapped_area_info info;
53474
53475 if (len & ~huge_page_mask(h))
53476 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53477 return addr;
53478 }
53479
53480 +#ifdef CONFIG_PAX_RANDMMAP
53481 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53482 +#endif
53483 +
53484 if (addr) {
53485 addr = ALIGN(addr, huge_page_size(h));
53486 vma = find_vma(mm, addr);
53487 - if (TASK_SIZE - len >= addr &&
53488 - (!vma || addr + len <= vma->vm_start))
53489 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53490 return addr;
53491 }
53492
53493 info.flags = 0;
53494 info.length = len;
53495 info.low_limit = TASK_UNMAPPED_BASE;
53496 +
53497 +#ifdef CONFIG_PAX_RANDMMAP
53498 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53499 + info.low_limit += mm->delta_mmap;
53500 +#endif
53501 +
53502 info.high_limit = TASK_SIZE;
53503 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53504 info.align_offset = 0;
53505 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53506 .kill_sb = kill_litter_super,
53507 };
53508
53509 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53510 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53511
53512 static int can_do_hugetlb_shm(void)
53513 {
53514 diff --git a/fs/inode.c b/fs/inode.c
53515 index b98540e..6a439ea 100644
53516 --- a/fs/inode.c
53517 +++ b/fs/inode.c
53518 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
53519
53520 #ifdef CONFIG_SMP
53521 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53522 - static atomic_t shared_last_ino;
53523 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53524 + static atomic_unchecked_t shared_last_ino;
53525 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53526
53527 res = next - LAST_INO_BATCH;
53528 }
53529 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53530 index 4a6cf28..d3a29d3 100644
53531 --- a/fs/jffs2/erase.c
53532 +++ b/fs/jffs2/erase.c
53533 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53534 struct jffs2_unknown_node marker = {
53535 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53536 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53537 - .totlen = cpu_to_je32(c->cleanmarker_size)
53538 + .totlen = cpu_to_je32(c->cleanmarker_size),
53539 + .hdr_crc = cpu_to_je32(0)
53540 };
53541
53542 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53543 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53544 index a6597d6..41b30ec 100644
53545 --- a/fs/jffs2/wbuf.c
53546 +++ b/fs/jffs2/wbuf.c
53547 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53548 {
53549 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53550 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53551 - .totlen = constant_cpu_to_je32(8)
53552 + .totlen = constant_cpu_to_je32(8),
53553 + .hdr_crc = constant_cpu_to_je32(0)
53554 };
53555
53556 /*
53557 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53558 index 1a543be..a4e1363 100644
53559 --- a/fs/jfs/super.c
53560 +++ b/fs/jfs/super.c
53561 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
53562 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53563 int *flag)
53564 {
53565 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
53566 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
53567 char *p;
53568 struct jfs_sb_info *sbi = JFS_SBI(sb);
53569
53570 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53571 /* Don't do anything ;-) */
53572 break;
53573 case Opt_iocharset:
53574 - if (nls_map && nls_map != (void *) -1)
53575 + if (nls_map && nls_map != (const void *) -1)
53576 unload_nls(nls_map);
53577 if (!strcmp(args[0].from, "none"))
53578 nls_map = NULL;
53579 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
53580
53581 jfs_inode_cachep =
53582 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53583 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53584 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53585 init_once);
53586 if (jfs_inode_cachep == NULL)
53587 return -ENOMEM;
53588 diff --git a/fs/libfs.c b/fs/libfs.c
53589 index 916da8c..1588998 100644
53590 --- a/fs/libfs.c
53591 +++ b/fs/libfs.c
53592 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53593
53594 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53595 struct dentry *next;
53596 + char d_name[sizeof(next->d_iname)];
53597 + const unsigned char *name;
53598 +
53599 next = list_entry(p, struct dentry, d_u.d_child);
53600 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53601 if (!simple_positive(next)) {
53602 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53603
53604 spin_unlock(&next->d_lock);
53605 spin_unlock(&dentry->d_lock);
53606 - if (filldir(dirent, next->d_name.name,
53607 + name = next->d_name.name;
53608 + if (name == next->d_iname) {
53609 + memcpy(d_name, name, next->d_name.len);
53610 + name = d_name;
53611 + }
53612 + if (filldir(dirent, name,
53613 next->d_name.len, filp->f_pos,
53614 next->d_inode->i_ino,
53615 dt_type(next->d_inode)) < 0)
53616 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53617 index 52e5120..808936e 100644
53618 --- a/fs/lockd/clntproc.c
53619 +++ b/fs/lockd/clntproc.c
53620 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53621 /*
53622 * Cookie counter for NLM requests
53623 */
53624 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53625 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53626
53627 void nlmclnt_next_cookie(struct nlm_cookie *c)
53628 {
53629 - u32 cookie = atomic_inc_return(&nlm_cookie);
53630 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53631
53632 memcpy(c->data, &cookie, 4);
53633 c->len=4;
53634 diff --git a/fs/locks.c b/fs/locks.c
53635 index a94e331..060bce3 100644
53636 --- a/fs/locks.c
53637 +++ b/fs/locks.c
53638 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53639 return;
53640
53641 if (filp->f_op && filp->f_op->flock) {
53642 - struct file_lock fl = {
53643 + struct file_lock flock = {
53644 .fl_pid = current->tgid,
53645 .fl_file = filp,
53646 .fl_flags = FL_FLOCK,
53647 .fl_type = F_UNLCK,
53648 .fl_end = OFFSET_MAX,
53649 };
53650 - filp->f_op->flock(filp, F_SETLKW, &fl);
53651 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53652 - fl.fl_ops->fl_release_private(&fl);
53653 + filp->f_op->flock(filp, F_SETLKW, &flock);
53654 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53655 + flock.fl_ops->fl_release_private(&flock);
53656 }
53657
53658 lock_flocks();
53659 diff --git a/fs/namei.c b/fs/namei.c
53660 index ec97aef..e67718d 100644
53661 --- a/fs/namei.c
53662 +++ b/fs/namei.c
53663 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53664 if (ret != -EACCES)
53665 return ret;
53666
53667 +#ifdef CONFIG_GRKERNSEC
53668 + /* we'll block if we have to log due to a denied capability use */
53669 + if (mask & MAY_NOT_BLOCK)
53670 + return -ECHILD;
53671 +#endif
53672 +
53673 if (S_ISDIR(inode->i_mode)) {
53674 /* DACs are overridable for directories */
53675 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53676 - return 0;
53677 if (!(mask & MAY_WRITE))
53678 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53679 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53680 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53681 return 0;
53682 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53683 + return 0;
53684 return -EACCES;
53685 }
53686 /*
53687 + * Searching includes executable on directories, else just read.
53688 + */
53689 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53690 + if (mask == MAY_READ)
53691 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53692 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53693 + return 0;
53694 +
53695 + /*
53696 * Read/write DACs are always overridable.
53697 * Executable DACs are overridable when there is
53698 * at least one exec bit set.
53699 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53700 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53701 return 0;
53702
53703 - /*
53704 - * Searching includes executable on directories, else just read.
53705 - */
53706 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53707 - if (mask == MAY_READ)
53708 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53709 - return 0;
53710 -
53711 return -EACCES;
53712 }
53713
53714 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53715 {
53716 struct dentry *dentry = link->dentry;
53717 int error;
53718 - char *s;
53719 + const char *s;
53720
53721 BUG_ON(nd->flags & LOOKUP_RCU);
53722
53723 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53724 if (error)
53725 goto out_put_nd_path;
53726
53727 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53728 + dentry->d_inode, dentry, nd->path.mnt)) {
53729 + error = -EACCES;
53730 + goto out_put_nd_path;
53731 + }
53732 +
53733 nd->last_type = LAST_BIND;
53734 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53735 error = PTR_ERR(*p);
53736 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53737 break;
53738 res = walk_component(nd, path, &nd->last,
53739 nd->last_type, LOOKUP_FOLLOW);
53740 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53741 + res = -EACCES;
53742 put_link(nd, &link, cookie);
53743 } while (res > 0);
53744
53745 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
53746 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53747 {
53748 unsigned long a, b, adata, bdata, mask, hash, len;
53749 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53750 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53751
53752 hash = a = 0;
53753 len = -sizeof(unsigned long);
53754 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
53755 if (err)
53756 break;
53757 err = lookup_last(nd, &path);
53758 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53759 + err = -EACCES;
53760 put_link(nd, &link, cookie);
53761 }
53762 }
53763 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
53764 if (!err)
53765 err = complete_walk(nd);
53766
53767 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53768 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53769 + path_put(&nd->path);
53770 + err = -ENOENT;
53771 + }
53772 + }
53773 +
53774 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53775 if (!nd->inode->i_op->lookup) {
53776 path_put(&nd->path);
53777 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
53778 retval = path_lookupat(dfd, name->name,
53779 flags | LOOKUP_REVAL, nd);
53780
53781 - if (likely(!retval))
53782 + if (likely(!retval)) {
53783 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53784 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53785 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53786 + path_put(&nd->path);
53787 + return -ENOENT;
53788 + }
53789 + }
53790 + }
53791 return retval;
53792 }
53793
53794 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53795 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53796 return -EPERM;
53797
53798 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53799 + return -EPERM;
53800 + if (gr_handle_rawio(inode))
53801 + return -EPERM;
53802 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53803 + return -EACCES;
53804 +
53805 return 0;
53806 }
53807
53808 @@ -2611,7 +2650,7 @@ looked_up:
53809 * cleared otherwise prior to returning.
53810 */
53811 static int lookup_open(struct nameidata *nd, struct path *path,
53812 - struct file *file,
53813 + struct path *link, struct file *file,
53814 const struct open_flags *op,
53815 bool got_write, int *opened)
53816 {
53817 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53818 /* Negative dentry, just create the file */
53819 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53820 umode_t mode = op->mode;
53821 +
53822 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53823 + error = -EACCES;
53824 + goto out_dput;
53825 + }
53826 +
53827 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53828 + error = -EACCES;
53829 + goto out_dput;
53830 + }
53831 +
53832 if (!IS_POSIXACL(dir->d_inode))
53833 mode &= ~current_umask();
53834 /*
53835 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53836 nd->flags & LOOKUP_EXCL);
53837 if (error)
53838 goto out_dput;
53839 + else
53840 + gr_handle_create(dentry, nd->path.mnt);
53841 }
53842 out_no_open:
53843 path->dentry = dentry;
53844 @@ -2681,7 +2733,7 @@ out_dput:
53845 /*
53846 * Handle the last step of open()
53847 */
53848 -static int do_last(struct nameidata *nd, struct path *path,
53849 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53850 struct file *file, const struct open_flags *op,
53851 int *opened, struct filename *name)
53852 {
53853 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53854 error = complete_walk(nd);
53855 if (error)
53856 return error;
53857 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53858 + error = -ENOENT;
53859 + goto out;
53860 + }
53861 audit_inode(name, nd->path.dentry, 0);
53862 if (open_flag & O_CREAT) {
53863 error = -EISDIR;
53864 goto out;
53865 }
53866 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53867 + error = -EACCES;
53868 + goto out;
53869 + }
53870 goto finish_open;
53871 case LAST_BIND:
53872 error = complete_walk(nd);
53873 if (error)
53874 return error;
53875 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53876 + error = -ENOENT;
53877 + goto out;
53878 + }
53879 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53880 + error = -EACCES;
53881 + goto out;
53882 + }
53883 audit_inode(name, dir, 0);
53884 goto finish_open;
53885 }
53886 @@ -2768,7 +2836,7 @@ retry_lookup:
53887 */
53888 }
53889 mutex_lock(&dir->d_inode->i_mutex);
53890 - error = lookup_open(nd, path, file, op, got_write, opened);
53891 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53892 mutex_unlock(&dir->d_inode->i_mutex);
53893
53894 if (error <= 0) {
53895 @@ -2792,11 +2860,28 @@ retry_lookup:
53896 goto finish_open_created;
53897 }
53898
53899 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53900 + error = -ENOENT;
53901 + goto exit_dput;
53902 + }
53903 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53904 + error = -EACCES;
53905 + goto exit_dput;
53906 + }
53907 +
53908 /*
53909 * create/update audit record if it already exists.
53910 */
53911 - if (path->dentry->d_inode)
53912 + if (path->dentry->d_inode) {
53913 + /* only check if O_CREAT is specified, all other checks need to go
53914 + into may_open */
53915 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53916 + error = -EACCES;
53917 + goto exit_dput;
53918 + }
53919 +
53920 audit_inode(name, path->dentry, 0);
53921 + }
53922
53923 /*
53924 * If atomic_open() acquired write access it is dropped now due to
53925 @@ -2837,6 +2922,11 @@ finish_lookup:
53926 }
53927 }
53928 BUG_ON(inode != path->dentry->d_inode);
53929 + /* if we're resolving a symlink to another symlink */
53930 + if (link && gr_handle_symlink_owner(link, inode)) {
53931 + error = -EACCES;
53932 + goto out;
53933 + }
53934 return 1;
53935 }
53936
53937 @@ -2846,7 +2936,6 @@ finish_lookup:
53938 save_parent.dentry = nd->path.dentry;
53939 save_parent.mnt = mntget(path->mnt);
53940 nd->path.dentry = path->dentry;
53941 -
53942 }
53943 nd->inode = inode;
53944 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53945 @@ -2855,6 +2944,16 @@ finish_lookup:
53946 path_put(&save_parent);
53947 return error;
53948 }
53949 +
53950 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53951 + error = -ENOENT;
53952 + goto out;
53953 + }
53954 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53955 + error = -EACCES;
53956 + goto out;
53957 + }
53958 +
53959 error = -EISDIR;
53960 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53961 goto out;
53962 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53963 if (unlikely(error))
53964 goto out;
53965
53966 - error = do_last(nd, &path, file, op, &opened, pathname);
53967 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53968 while (unlikely(error > 0)) { /* trailing symlink */
53969 struct path link = path;
53970 void *cookie;
53971 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53972 error = follow_link(&link, nd, &cookie);
53973 if (unlikely(error))
53974 break;
53975 - error = do_last(nd, &path, file, op, &opened, pathname);
53976 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53977 put_link(nd, &link, cookie);
53978 }
53979 out:
53980 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53981 goto unlock;
53982
53983 error = -EEXIST;
53984 - if (dentry->d_inode)
53985 + if (dentry->d_inode) {
53986 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53987 + error = -ENOENT;
53988 + }
53989 goto fail;
53990 + }
53991 /*
53992 * Special case - lookup gave negative, but... we had foo/bar/
53993 * From the vfs_mknod() POV we just have a negative dentry -
53994 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53995 }
53996 EXPORT_SYMBOL(user_path_create);
53997
53998 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53999 +{
54000 + struct filename *tmp = getname(pathname);
54001 + struct dentry *res;
54002 + if (IS_ERR(tmp))
54003 + return ERR_CAST(tmp);
54004 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
54005 + if (IS_ERR(res))
54006 + putname(tmp);
54007 + else
54008 + *to = tmp;
54009 + return res;
54010 +}
54011 +
54012 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
54013 {
54014 int error = may_create(dir, dentry);
54015 @@ -3186,6 +3303,17 @@ retry:
54016
54017 if (!IS_POSIXACL(path.dentry->d_inode))
54018 mode &= ~current_umask();
54019 +
54020 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
54021 + error = -EPERM;
54022 + goto out;
54023 + }
54024 +
54025 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
54026 + error = -EACCES;
54027 + goto out;
54028 + }
54029 +
54030 error = security_path_mknod(&path, dentry, mode, dev);
54031 if (error)
54032 goto out;
54033 @@ -3202,6 +3330,8 @@ retry:
54034 break;
54035 }
54036 out:
54037 + if (!error)
54038 + gr_handle_create(dentry, path.mnt);
54039 done_path_create(&path, dentry);
54040 if (retry_estale(error, lookup_flags)) {
54041 lookup_flags |= LOOKUP_REVAL;
54042 @@ -3254,9 +3384,16 @@ retry:
54043
54044 if (!IS_POSIXACL(path.dentry->d_inode))
54045 mode &= ~current_umask();
54046 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
54047 + error = -EACCES;
54048 + goto out;
54049 + }
54050 error = security_path_mkdir(&path, dentry, mode);
54051 if (!error)
54052 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
54053 + if (!error)
54054 + gr_handle_create(dentry, path.mnt);
54055 +out:
54056 done_path_create(&path, dentry);
54057 if (retry_estale(error, lookup_flags)) {
54058 lookup_flags |= LOOKUP_REVAL;
54059 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
54060 struct filename *name;
54061 struct dentry *dentry;
54062 struct nameidata nd;
54063 + ino_t saved_ino = 0;
54064 + dev_t saved_dev = 0;
54065 unsigned int lookup_flags = 0;
54066 retry:
54067 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54068 @@ -3369,10 +3508,21 @@ retry:
54069 error = -ENOENT;
54070 goto exit3;
54071 }
54072 +
54073 + saved_ino = dentry->d_inode->i_ino;
54074 + saved_dev = gr_get_dev_from_dentry(dentry);
54075 +
54076 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
54077 + error = -EACCES;
54078 + goto exit3;
54079 + }
54080 +
54081 error = security_path_rmdir(&nd.path, dentry);
54082 if (error)
54083 goto exit3;
54084 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
54085 + if (!error && (saved_dev || saved_ino))
54086 + gr_handle_delete(saved_ino, saved_dev);
54087 exit3:
54088 dput(dentry);
54089 exit2:
54090 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
54091 struct dentry *dentry;
54092 struct nameidata nd;
54093 struct inode *inode = NULL;
54094 + ino_t saved_ino = 0;
54095 + dev_t saved_dev = 0;
54096 unsigned int lookup_flags = 0;
54097 retry:
54098 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54099 @@ -3464,10 +3616,22 @@ retry:
54100 if (!inode)
54101 goto slashes;
54102 ihold(inode);
54103 +
54104 + if (inode->i_nlink <= 1) {
54105 + saved_ino = inode->i_ino;
54106 + saved_dev = gr_get_dev_from_dentry(dentry);
54107 + }
54108 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
54109 + error = -EACCES;
54110 + goto exit2;
54111 + }
54112 +
54113 error = security_path_unlink(&nd.path, dentry);
54114 if (error)
54115 goto exit2;
54116 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54117 + if (!error && (saved_ino || saved_dev))
54118 + gr_handle_delete(saved_ino, saved_dev);
54119 exit2:
54120 dput(dentry);
54121 }
54122 @@ -3545,9 +3709,17 @@ retry:
54123 if (IS_ERR(dentry))
54124 goto out_putname;
54125
54126 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54127 + error = -EACCES;
54128 + goto out;
54129 + }
54130 +
54131 error = security_path_symlink(&path, dentry, from->name);
54132 if (!error)
54133 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54134 + if (!error)
54135 + gr_handle_create(dentry, path.mnt);
54136 +out:
54137 done_path_create(&path, dentry);
54138 if (retry_estale(error, lookup_flags)) {
54139 lookup_flags |= LOOKUP_REVAL;
54140 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54141 {
54142 struct dentry *new_dentry;
54143 struct path old_path, new_path;
54144 + struct filename *to = NULL;
54145 int how = 0;
54146 int error;
54147
54148 @@ -3644,7 +3817,7 @@ retry:
54149 if (error)
54150 return error;
54151
54152 - new_dentry = user_path_create(newdfd, newname, &new_path,
54153 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54154 (how & LOOKUP_REVAL));
54155 error = PTR_ERR(new_dentry);
54156 if (IS_ERR(new_dentry))
54157 @@ -3656,11 +3829,28 @@ retry:
54158 error = may_linkat(&old_path);
54159 if (unlikely(error))
54160 goto out_dput;
54161 +
54162 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54163 + old_path.dentry->d_inode,
54164 + old_path.dentry->d_inode->i_mode, to)) {
54165 + error = -EACCES;
54166 + goto out_dput;
54167 + }
54168 +
54169 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54170 + old_path.dentry, old_path.mnt, to)) {
54171 + error = -EACCES;
54172 + goto out_dput;
54173 + }
54174 +
54175 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54176 if (error)
54177 goto out_dput;
54178 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54179 + if (!error)
54180 + gr_handle_create(new_dentry, new_path.mnt);
54181 out_dput:
54182 + putname(to);
54183 done_path_create(&new_path, new_dentry);
54184 if (retry_estale(error, how)) {
54185 how |= LOOKUP_REVAL;
54186 @@ -3906,12 +4096,21 @@ retry:
54187 if (new_dentry == trap)
54188 goto exit5;
54189
54190 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54191 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54192 + to);
54193 + if (error)
54194 + goto exit5;
54195 +
54196 error = security_path_rename(&oldnd.path, old_dentry,
54197 &newnd.path, new_dentry);
54198 if (error)
54199 goto exit5;
54200 error = vfs_rename(old_dir->d_inode, old_dentry,
54201 new_dir->d_inode, new_dentry);
54202 + if (!error)
54203 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54204 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54205 exit5:
54206 dput(new_dentry);
54207 exit4:
54208 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54209
54210 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54211 {
54212 + char tmpbuf[64];
54213 + const char *newlink;
54214 int len;
54215
54216 len = PTR_ERR(link);
54217 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54218 len = strlen(link);
54219 if (len > (unsigned) buflen)
54220 len = buflen;
54221 - if (copy_to_user(buffer, link, len))
54222 +
54223 + if (len < sizeof(tmpbuf)) {
54224 + memcpy(tmpbuf, link, len);
54225 + newlink = tmpbuf;
54226 + } else
54227 + newlink = link;
54228 +
54229 + if (copy_to_user(buffer, newlink, len))
54230 len = -EFAULT;
54231 out:
54232 return len;
54233 diff --git a/fs/namespace.c b/fs/namespace.c
54234 index 5dd7709..6f64e9c 100644
54235 --- a/fs/namespace.c
54236 +++ b/fs/namespace.c
54237 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
54238 if (!(sb->s_flags & MS_RDONLY))
54239 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54240 up_write(&sb->s_umount);
54241 +
54242 + gr_log_remount(mnt->mnt_devname, retval);
54243 +
54244 return retval;
54245 }
54246
54247 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
54248 br_write_unlock(&vfsmount_lock);
54249 up_write(&namespace_sem);
54250 release_mounts(&umount_list);
54251 +
54252 + gr_log_unmount(mnt->mnt_devname, retval);
54253 +
54254 return retval;
54255 }
54256
54257 @@ -1713,7 +1719,7 @@ static int do_loopback(struct path *path, const char *old_name,
54258
54259 if (IS_ERR(mnt)) {
54260 err = PTR_ERR(mnt);
54261 - goto out;
54262 + goto out2;
54263 }
54264
54265 err = graft_tree(mnt, path);
54266 @@ -2294,6 +2300,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54267 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54268 MS_STRICTATIME);
54269
54270 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54271 + retval = -EPERM;
54272 + goto dput_out;
54273 + }
54274 +
54275 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54276 + retval = -EPERM;
54277 + goto dput_out;
54278 + }
54279 +
54280 if (flags & MS_REMOUNT)
54281 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54282 data_page);
54283 @@ -2308,6 +2324,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54284 dev_name, data_page);
54285 dput_out:
54286 path_put(&path);
54287 +
54288 + gr_log_mount(dev_name, dir_name, retval);
54289 +
54290 return retval;
54291 }
54292
54293 @@ -2594,6 +2613,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54294 if (error)
54295 goto out2;
54296
54297 + if (gr_handle_chroot_pivot()) {
54298 + error = -EPERM;
54299 + goto out2;
54300 + }
54301 +
54302 get_fs_root(current->fs, &root);
54303 error = lock_mount(&old);
54304 if (error)
54305 @@ -2842,7 +2866,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54306 !nsown_capable(CAP_SYS_ADMIN))
54307 return -EPERM;
54308
54309 - if (fs->users != 1)
54310 + if (atomic_read(&fs->users) != 1)
54311 return -EINVAL;
54312
54313 get_mnt_ns(mnt_ns);
54314 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54315 index 59461c9..b17c57e 100644
54316 --- a/fs/nfs/callback_xdr.c
54317 +++ b/fs/nfs/callback_xdr.c
54318 @@ -51,7 +51,7 @@ struct callback_op {
54319 callback_decode_arg_t decode_args;
54320 callback_encode_res_t encode_res;
54321 long res_maxsize;
54322 -};
54323 +} __do_const;
54324
54325 static struct callback_op callback_ops[];
54326
54327 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54328 index ebeb94c..ff35337 100644
54329 --- a/fs/nfs/inode.c
54330 +++ b/fs/nfs/inode.c
54331 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54332 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54333 }
54334
54335 -static atomic_long_t nfs_attr_generation_counter;
54336 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54337
54338 static unsigned long nfs_read_attr_generation_counter(void)
54339 {
54340 - return atomic_long_read(&nfs_attr_generation_counter);
54341 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54342 }
54343
54344 unsigned long nfs_inc_attr_generation_counter(void)
54345 {
54346 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54347 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54348 }
54349
54350 void nfs_fattr_init(struct nfs_fattr *fattr)
54351 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54352 index 9d1c5db..1e13db8 100644
54353 --- a/fs/nfsd/nfs4proc.c
54354 +++ b/fs/nfsd/nfs4proc.c
54355 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
54356 nfsd4op_rsize op_rsize_bop;
54357 stateid_getter op_get_currentstateid;
54358 stateid_setter op_set_currentstateid;
54359 -};
54360 +} __do_const;
54361
54362 static struct nfsd4_operation nfsd4_ops[];
54363
54364 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54365 index d1dd710..32ac0e8 100644
54366 --- a/fs/nfsd/nfs4xdr.c
54367 +++ b/fs/nfsd/nfs4xdr.c
54368 @@ -1456,7 +1456,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54369
54370 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54371
54372 -static nfsd4_dec nfsd4_dec_ops[] = {
54373 +static const nfsd4_dec nfsd4_dec_ops[] = {
54374 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54375 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54376 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54377 @@ -1496,7 +1496,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54378 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54379 };
54380
54381 -static nfsd4_dec nfsd41_dec_ops[] = {
54382 +static const nfsd4_dec nfsd41_dec_ops[] = {
54383 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54384 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54385 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54386 @@ -1558,7 +1558,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54387 };
54388
54389 struct nfsd4_minorversion_ops {
54390 - nfsd4_dec *decoders;
54391 + const nfsd4_dec *decoders;
54392 int nops;
54393 };
54394
54395 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
54396 index 2cbac34..6dc3889 100644
54397 --- a/fs/nfsd/nfscache.c
54398 +++ b/fs/nfsd/nfscache.c
54399 @@ -264,8 +264,10 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
54400 if (!(rp = rqstp->rq_cacherep) || cache_disabled)
54401 return;
54402
54403 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54404 - len >>= 2;
54405 + if (statp) {
54406 + len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54407 + len >>= 2;
54408 + }
54409
54410 /* Don't cache excessive amounts of data and XDR failures */
54411 if (!statp || len > (256 >> 2)) {
54412 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54413 index 69c6413..c0408d2 100644
54414 --- a/fs/nfsd/vfs.c
54415 +++ b/fs/nfsd/vfs.c
54416 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54417 } else {
54418 oldfs = get_fs();
54419 set_fs(KERNEL_DS);
54420 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54421 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54422 set_fs(oldfs);
54423 }
54424
54425 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54426
54427 /* Write the data. */
54428 oldfs = get_fs(); set_fs(KERNEL_DS);
54429 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54430 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54431 set_fs(oldfs);
54432 if (host_err < 0)
54433 goto out_nfserr;
54434 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54435 */
54436
54437 oldfs = get_fs(); set_fs(KERNEL_DS);
54438 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54439 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54440 set_fs(oldfs);
54441
54442 if (host_err < 0)
54443 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54444 index fea6bd5..8ee9d81 100644
54445 --- a/fs/nls/nls_base.c
54446 +++ b/fs/nls/nls_base.c
54447 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54448
54449 int register_nls(struct nls_table * nls)
54450 {
54451 - struct nls_table ** tmp = &tables;
54452 + struct nls_table *tmp = tables;
54453
54454 if (nls->next)
54455 return -EBUSY;
54456
54457 spin_lock(&nls_lock);
54458 - while (*tmp) {
54459 - if (nls == *tmp) {
54460 + while (tmp) {
54461 + if (nls == tmp) {
54462 spin_unlock(&nls_lock);
54463 return -EBUSY;
54464 }
54465 - tmp = &(*tmp)->next;
54466 + tmp = tmp->next;
54467 }
54468 - nls->next = tables;
54469 + pax_open_kernel();
54470 + *(struct nls_table **)&nls->next = tables;
54471 + pax_close_kernel();
54472 tables = nls;
54473 spin_unlock(&nls_lock);
54474 return 0;
54475 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54476
54477 int unregister_nls(struct nls_table * nls)
54478 {
54479 - struct nls_table ** tmp = &tables;
54480 + struct nls_table * const * tmp = &tables;
54481
54482 spin_lock(&nls_lock);
54483 while (*tmp) {
54484 if (nls == *tmp) {
54485 - *tmp = nls->next;
54486 + pax_open_kernel();
54487 + *(struct nls_table **)tmp = nls->next;
54488 + pax_close_kernel();
54489 spin_unlock(&nls_lock);
54490 return 0;
54491 }
54492 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54493 index 7424929..35f6be5 100644
54494 --- a/fs/nls/nls_euc-jp.c
54495 +++ b/fs/nls/nls_euc-jp.c
54496 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54497 p_nls = load_nls("cp932");
54498
54499 if (p_nls) {
54500 - table.charset2upper = p_nls->charset2upper;
54501 - table.charset2lower = p_nls->charset2lower;
54502 + pax_open_kernel();
54503 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54504 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54505 + pax_close_kernel();
54506 return register_nls(&table);
54507 }
54508
54509 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54510 index e7bc1d7..06bd4bb 100644
54511 --- a/fs/nls/nls_koi8-ru.c
54512 +++ b/fs/nls/nls_koi8-ru.c
54513 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54514 p_nls = load_nls("koi8-u");
54515
54516 if (p_nls) {
54517 - table.charset2upper = p_nls->charset2upper;
54518 - table.charset2lower = p_nls->charset2lower;
54519 + pax_open_kernel();
54520 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54521 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54522 + pax_close_kernel();
54523 return register_nls(&table);
54524 }
54525
54526 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54527 index 9ff4a5e..deb1f0f 100644
54528 --- a/fs/notify/fanotify/fanotify_user.c
54529 +++ b/fs/notify/fanotify/fanotify_user.c
54530 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54531
54532 fd = fanotify_event_metadata.fd;
54533 ret = -EFAULT;
54534 - if (copy_to_user(buf, &fanotify_event_metadata,
54535 - fanotify_event_metadata.event_len))
54536 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54537 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54538 goto out_close_fd;
54539
54540 ret = prepare_for_access_response(group, event, fd);
54541 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54542 index 7b51b05..5ea5ef6 100644
54543 --- a/fs/notify/notification.c
54544 +++ b/fs/notify/notification.c
54545 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54546 * get set to 0 so it will never get 'freed'
54547 */
54548 static struct fsnotify_event *q_overflow_event;
54549 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54550 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54551
54552 /**
54553 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54554 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54555 */
54556 u32 fsnotify_get_cookie(void)
54557 {
54558 - return atomic_inc_return(&fsnotify_sync_cookie);
54559 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54560 }
54561 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54562
54563 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54564 index 99e3610..02c1068 100644
54565 --- a/fs/ntfs/dir.c
54566 +++ b/fs/ntfs/dir.c
54567 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54568 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54569 ~(s64)(ndir->itype.index.block_size - 1)));
54570 /* Bounds checks. */
54571 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54572 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54573 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54574 "inode 0x%lx or driver bug.", vdir->i_ino);
54575 goto err_out;
54576 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54577 index 5b2d4f0..c6de396 100644
54578 --- a/fs/ntfs/file.c
54579 +++ b/fs/ntfs/file.c
54580 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54581 #endif /* NTFS_RW */
54582 };
54583
54584 -const struct file_operations ntfs_empty_file_ops = {};
54585 +const struct file_operations ntfs_empty_file_ops __read_only;
54586
54587 -const struct inode_operations ntfs_empty_inode_ops = {};
54588 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54589 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54590 index a9f78c7..ed8a381 100644
54591 --- a/fs/ocfs2/localalloc.c
54592 +++ b/fs/ocfs2/localalloc.c
54593 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54594 goto bail;
54595 }
54596
54597 - atomic_inc(&osb->alloc_stats.moves);
54598 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54599
54600 bail:
54601 if (handle)
54602 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54603 index d355e6e..578d905 100644
54604 --- a/fs/ocfs2/ocfs2.h
54605 +++ b/fs/ocfs2/ocfs2.h
54606 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54607
54608 struct ocfs2_alloc_stats
54609 {
54610 - atomic_t moves;
54611 - atomic_t local_data;
54612 - atomic_t bitmap_data;
54613 - atomic_t bg_allocs;
54614 - atomic_t bg_extends;
54615 + atomic_unchecked_t moves;
54616 + atomic_unchecked_t local_data;
54617 + atomic_unchecked_t bitmap_data;
54618 + atomic_unchecked_t bg_allocs;
54619 + atomic_unchecked_t bg_extends;
54620 };
54621
54622 enum ocfs2_local_alloc_state
54623 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54624 index b7e74b5..19c6536 100644
54625 --- a/fs/ocfs2/suballoc.c
54626 +++ b/fs/ocfs2/suballoc.c
54627 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54628 mlog_errno(status);
54629 goto bail;
54630 }
54631 - atomic_inc(&osb->alloc_stats.bg_extends);
54632 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54633
54634 /* You should never ask for this much metadata */
54635 BUG_ON(bits_wanted >
54636 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54637 mlog_errno(status);
54638 goto bail;
54639 }
54640 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54641 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54642
54643 *suballoc_loc = res.sr_bg_blkno;
54644 *suballoc_bit_start = res.sr_bit_offset;
54645 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54646 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54647 res->sr_bits);
54648
54649 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54650 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54651
54652 BUG_ON(res->sr_bits != 1);
54653
54654 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54655 mlog_errno(status);
54656 goto bail;
54657 }
54658 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54659 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54660
54661 BUG_ON(res.sr_bits != 1);
54662
54663 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54664 cluster_start,
54665 num_clusters);
54666 if (!status)
54667 - atomic_inc(&osb->alloc_stats.local_data);
54668 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54669 } else {
54670 if (min_clusters > (osb->bitmap_cpg - 1)) {
54671 /* The only paths asking for contiguousness
54672 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54673 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54674 res.sr_bg_blkno,
54675 res.sr_bit_offset);
54676 - atomic_inc(&osb->alloc_stats.bitmap_data);
54677 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54678 *num_clusters = res.sr_bits;
54679 }
54680 }
54681 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54682 index 0e91ec2..f4b3fc6 100644
54683 --- a/fs/ocfs2/super.c
54684 +++ b/fs/ocfs2/super.c
54685 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54686 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54687 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54688 "Stats",
54689 - atomic_read(&osb->alloc_stats.bitmap_data),
54690 - atomic_read(&osb->alloc_stats.local_data),
54691 - atomic_read(&osb->alloc_stats.bg_allocs),
54692 - atomic_read(&osb->alloc_stats.moves),
54693 - atomic_read(&osb->alloc_stats.bg_extends));
54694 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54695 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54696 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54697 + atomic_read_unchecked(&osb->alloc_stats.moves),
54698 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54699
54700 out += snprintf(buf + out, len - out,
54701 "%10s => State: %u Descriptor: %llu Size: %u bits "
54702 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54703 spin_lock_init(&osb->osb_xattr_lock);
54704 ocfs2_init_steal_slots(osb);
54705
54706 - atomic_set(&osb->alloc_stats.moves, 0);
54707 - atomic_set(&osb->alloc_stats.local_data, 0);
54708 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54709 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54710 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54711 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54712 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54713 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54714 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54715 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54716
54717 /* Copy the blockcheck stats from the superblock probe */
54718 osb->osb_ecc_stats = *stats;
54719 diff --git a/fs/open.c b/fs/open.c
54720 index 9b33c0c..2ffcca2 100644
54721 --- a/fs/open.c
54722 +++ b/fs/open.c
54723 @@ -31,6 +31,8 @@
54724 #include <linux/ima.h>
54725 #include <linux/dnotify.h>
54726
54727 +#define CREATE_TRACE_POINTS
54728 +#include <trace/events/fs.h>
54729 #include "internal.h"
54730
54731 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54732 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
54733 error = locks_verify_truncate(inode, NULL, length);
54734 if (!error)
54735 error = security_path_truncate(path);
54736 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54737 + error = -EACCES;
54738 if (!error)
54739 error = do_truncate(path->dentry, length, 0, NULL);
54740
54741 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54742 error = locks_verify_truncate(inode, f.file, length);
54743 if (!error)
54744 error = security_path_truncate(&f.file->f_path);
54745 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54746 + error = -EACCES;
54747 if (!error)
54748 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54749 sb_end_write(inode->i_sb);
54750 @@ -373,6 +379,9 @@ retry:
54751 if (__mnt_is_readonly(path.mnt))
54752 res = -EROFS;
54753
54754 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54755 + res = -EACCES;
54756 +
54757 out_path_release:
54758 path_put(&path);
54759 if (retry_estale(res, lookup_flags)) {
54760 @@ -404,6 +413,8 @@ retry:
54761 if (error)
54762 goto dput_and_out;
54763
54764 + gr_log_chdir(path.dentry, path.mnt);
54765 +
54766 set_fs_pwd(current->fs, &path);
54767
54768 dput_and_out:
54769 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54770 goto out_putf;
54771
54772 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54773 +
54774 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54775 + error = -EPERM;
54776 +
54777 + if (!error)
54778 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54779 +
54780 if (!error)
54781 set_fs_pwd(current->fs, &f.file->f_path);
54782 out_putf:
54783 @@ -462,7 +480,13 @@ retry:
54784 if (error)
54785 goto dput_and_out;
54786
54787 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54788 + goto dput_and_out;
54789 +
54790 set_fs_root(current->fs, &path);
54791 +
54792 + gr_handle_chroot_chdir(&path);
54793 +
54794 error = 0;
54795 dput_and_out:
54796 path_put(&path);
54797 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
54798 if (error)
54799 return error;
54800 mutex_lock(&inode->i_mutex);
54801 +
54802 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54803 + error = -EACCES;
54804 + goto out_unlock;
54805 + }
54806 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54807 + error = -EACCES;
54808 + goto out_unlock;
54809 + }
54810 +
54811 error = security_path_chmod(path, mode);
54812 if (error)
54813 goto out_unlock;
54814 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54815 uid = make_kuid(current_user_ns(), user);
54816 gid = make_kgid(current_user_ns(), group);
54817
54818 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54819 + return -EACCES;
54820 +
54821 newattrs.ia_valid = ATTR_CTIME;
54822 if (user != (uid_t) -1) {
54823 if (!uid_valid(uid))
54824 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54825 } else {
54826 fsnotify_open(f);
54827 fd_install(fd, f);
54828 + trace_do_sys_open(tmp->name, flags, mode);
54829 }
54830 }
54831 putname(tmp);
54832 diff --git a/fs/pipe.c b/fs/pipe.c
54833 index 8e2e73f..1ef1048 100644
54834 --- a/fs/pipe.c
54835 +++ b/fs/pipe.c
54836 @@ -438,9 +438,9 @@ redo:
54837 }
54838 if (bufs) /* More to do? */
54839 continue;
54840 - if (!pipe->writers)
54841 + if (!atomic_read(&pipe->writers))
54842 break;
54843 - if (!pipe->waiting_writers) {
54844 + if (!atomic_read(&pipe->waiting_writers)) {
54845 /* syscall merging: Usually we must not sleep
54846 * if O_NONBLOCK is set, or if we got some data.
54847 * But if a writer sleeps in kernel space, then
54848 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54849 mutex_lock(&inode->i_mutex);
54850 pipe = inode->i_pipe;
54851
54852 - if (!pipe->readers) {
54853 + if (!atomic_read(&pipe->readers)) {
54854 send_sig(SIGPIPE, current, 0);
54855 ret = -EPIPE;
54856 goto out;
54857 @@ -553,7 +553,7 @@ redo1:
54858 for (;;) {
54859 int bufs;
54860
54861 - if (!pipe->readers) {
54862 + if (!atomic_read(&pipe->readers)) {
54863 send_sig(SIGPIPE, current, 0);
54864 if (!ret)
54865 ret = -EPIPE;
54866 @@ -644,9 +644,9 @@ redo2:
54867 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54868 do_wakeup = 0;
54869 }
54870 - pipe->waiting_writers++;
54871 + atomic_inc(&pipe->waiting_writers);
54872 pipe_wait(pipe);
54873 - pipe->waiting_writers--;
54874 + atomic_dec(&pipe->waiting_writers);
54875 }
54876 out:
54877 mutex_unlock(&inode->i_mutex);
54878 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54879 mask = 0;
54880 if (filp->f_mode & FMODE_READ) {
54881 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54882 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54883 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54884 mask |= POLLHUP;
54885 }
54886
54887 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54888 * Most Unices do not set POLLERR for FIFOs but on Linux they
54889 * behave exactly like pipes for poll().
54890 */
54891 - if (!pipe->readers)
54892 + if (!atomic_read(&pipe->readers))
54893 mask |= POLLERR;
54894 }
54895
54896 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54897
54898 mutex_lock(&inode->i_mutex);
54899 pipe = inode->i_pipe;
54900 - pipe->readers -= decr;
54901 - pipe->writers -= decw;
54902 + atomic_sub(decr, &pipe->readers);
54903 + atomic_sub(decw, &pipe->writers);
54904
54905 - if (!pipe->readers && !pipe->writers) {
54906 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54907 free_pipe_info(inode);
54908 } else {
54909 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54910 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54911
54912 if (inode->i_pipe) {
54913 ret = 0;
54914 - inode->i_pipe->readers++;
54915 + atomic_inc(&inode->i_pipe->readers);
54916 }
54917
54918 mutex_unlock(&inode->i_mutex);
54919 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54920
54921 if (inode->i_pipe) {
54922 ret = 0;
54923 - inode->i_pipe->writers++;
54924 + atomic_inc(&inode->i_pipe->writers);
54925 }
54926
54927 mutex_unlock(&inode->i_mutex);
54928 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54929 if (inode->i_pipe) {
54930 ret = 0;
54931 if (filp->f_mode & FMODE_READ)
54932 - inode->i_pipe->readers++;
54933 + atomic_inc(&inode->i_pipe->readers);
54934 if (filp->f_mode & FMODE_WRITE)
54935 - inode->i_pipe->writers++;
54936 + atomic_inc(&inode->i_pipe->writers);
54937 }
54938
54939 mutex_unlock(&inode->i_mutex);
54940 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54941 inode->i_pipe = NULL;
54942 }
54943
54944 -static struct vfsmount *pipe_mnt __read_mostly;
54945 +struct vfsmount *pipe_mnt __read_mostly;
54946
54947 /*
54948 * pipefs_dname() is called from d_path().
54949 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54950 goto fail_iput;
54951 inode->i_pipe = pipe;
54952
54953 - pipe->readers = pipe->writers = 1;
54954 + atomic_set(&pipe->readers, 1);
54955 + atomic_set(&pipe->writers, 1);
54956 inode->i_fop = &rdwr_pipefifo_fops;
54957
54958 /*
54959 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54960 index 15af622..0e9f4467 100644
54961 --- a/fs/proc/Kconfig
54962 +++ b/fs/proc/Kconfig
54963 @@ -30,12 +30,12 @@ config PROC_FS
54964
54965 config PROC_KCORE
54966 bool "/proc/kcore support" if !ARM
54967 - depends on PROC_FS && MMU
54968 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54969
54970 config PROC_VMCORE
54971 bool "/proc/vmcore support"
54972 - depends on PROC_FS && CRASH_DUMP
54973 - default y
54974 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54975 + default n
54976 help
54977 Exports the dump image of crashed kernel in ELF format.
54978
54979 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54980 limited in memory.
54981
54982 config PROC_PAGE_MONITOR
54983 - default y
54984 - depends on PROC_FS && MMU
54985 + default n
54986 + depends on PROC_FS && MMU && !GRKERNSEC
54987 bool "Enable /proc page monitoring" if EXPERT
54988 help
54989 Various /proc files exist to monitor process memory utilization:
54990 diff --git a/fs/proc/array.c b/fs/proc/array.c
54991 index be3c22f..0df1564 100644
54992 --- a/fs/proc/array.c
54993 +++ b/fs/proc/array.c
54994 @@ -60,6 +60,7 @@
54995 #include <linux/tty.h>
54996 #include <linux/string.h>
54997 #include <linux/mman.h>
54998 +#include <linux/grsecurity.h>
54999 #include <linux/proc_fs.h>
55000 #include <linux/ioport.h>
55001 #include <linux/uaccess.h>
55002 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
55003 seq_putc(m, '\n');
55004 }
55005
55006 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55007 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
55008 +{
55009 + if (p->mm)
55010 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
55011 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
55012 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
55013 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
55014 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
55015 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
55016 + else
55017 + seq_printf(m, "PaX:\t-----\n");
55018 +}
55019 +#endif
55020 +
55021 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55022 struct pid *pid, struct task_struct *task)
55023 {
55024 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55025 task_cpus_allowed(m, task);
55026 cpuset_task_status_allowed(m, task);
55027 task_context_switch_counts(m, task);
55028 +
55029 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55030 + task_pax(m, task);
55031 +#endif
55032 +
55033 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
55034 + task_grsec_rbac(m, task);
55035 +#endif
55036 +
55037 return 0;
55038 }
55039
55040 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55041 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55042 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55043 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55044 +#endif
55045 +
55046 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55047 struct pid *pid, struct task_struct *task, int whole)
55048 {
55049 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55050 char tcomm[sizeof(task->comm)];
55051 unsigned long flags;
55052
55053 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55054 + if (current->exec_id != m->exec_id) {
55055 + gr_log_badprocpid("stat");
55056 + return 0;
55057 + }
55058 +#endif
55059 +
55060 state = *get_task_state(task);
55061 vsize = eip = esp = 0;
55062 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55063 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55064 gtime = task->gtime;
55065 }
55066
55067 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55068 + if (PAX_RAND_FLAGS(mm)) {
55069 + eip = 0;
55070 + esp = 0;
55071 + wchan = 0;
55072 + }
55073 +#endif
55074 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55075 + wchan = 0;
55076 + eip =0;
55077 + esp =0;
55078 +#endif
55079 +
55080 /* scale priority and nice values from timeslices to -20..20 */
55081 /* to make it look like a "normal" Unix priority/nice value */
55082 priority = task_prio(task);
55083 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55084 seq_put_decimal_ull(m, ' ', vsize);
55085 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55086 seq_put_decimal_ull(m, ' ', rsslim);
55087 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55088 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55089 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55090 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55091 +#else
55092 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55093 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55094 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55095 +#endif
55096 seq_put_decimal_ull(m, ' ', esp);
55097 seq_put_decimal_ull(m, ' ', eip);
55098 /* The signal information here is obsolete.
55099 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55100 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55101 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55102
55103 - if (mm && permitted) {
55104 + if (mm && permitted
55105 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55106 + && !PAX_RAND_FLAGS(mm)
55107 +#endif
55108 + ) {
55109 seq_put_decimal_ull(m, ' ', mm->start_data);
55110 seq_put_decimal_ull(m, ' ', mm->end_data);
55111 seq_put_decimal_ull(m, ' ', mm->start_brk);
55112 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55113 struct pid *pid, struct task_struct *task)
55114 {
55115 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55116 - struct mm_struct *mm = get_task_mm(task);
55117 + struct mm_struct *mm;
55118
55119 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55120 + if (current->exec_id != m->exec_id) {
55121 + gr_log_badprocpid("statm");
55122 + return 0;
55123 + }
55124 +#endif
55125 + mm = get_task_mm(task);
55126 if (mm) {
55127 size = task_statm(mm, &shared, &text, &data, &resident);
55128 mmput(mm);
55129 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55130 return 0;
55131 }
55132
55133 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55134 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55135 +{
55136 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55137 +}
55138 +#endif
55139 +
55140 #ifdef CONFIG_CHECKPOINT_RESTORE
55141 static struct pid *
55142 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55143 diff --git a/fs/proc/base.c b/fs/proc/base.c
55144 index 9b43ff77..0fa9564 100644
55145 --- a/fs/proc/base.c
55146 +++ b/fs/proc/base.c
55147 @@ -111,6 +111,14 @@ struct pid_entry {
55148 union proc_op op;
55149 };
55150
55151 +struct getdents_callback {
55152 + struct linux_dirent __user * current_dir;
55153 + struct linux_dirent __user * previous;
55154 + struct file * file;
55155 + int count;
55156 + int error;
55157 +};
55158 +
55159 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55160 .name = (NAME), \
55161 .len = sizeof(NAME) - 1, \
55162 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55163 if (!mm->arg_end)
55164 goto out_mm; /* Shh! No looking before we're done */
55165
55166 + if (gr_acl_handle_procpidmem(task))
55167 + goto out_mm;
55168 +
55169 len = mm->arg_end - mm->arg_start;
55170
55171 if (len > PAGE_SIZE)
55172 @@ -235,12 +246,28 @@ out:
55173 return res;
55174 }
55175
55176 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55177 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55178 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55179 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55180 +#endif
55181 +
55182 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55183 {
55184 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55185 int res = PTR_ERR(mm);
55186 if (mm && !IS_ERR(mm)) {
55187 unsigned int nwords = 0;
55188 +
55189 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55190 + /* allow if we're currently ptracing this task */
55191 + if (PAX_RAND_FLAGS(mm) &&
55192 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55193 + mmput(mm);
55194 + return 0;
55195 + }
55196 +#endif
55197 +
55198 do {
55199 nwords += 2;
55200 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55201 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55202 }
55203
55204
55205 -#ifdef CONFIG_KALLSYMS
55206 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55207 /*
55208 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55209 * Returns the resolved symbol. If that fails, simply return the address.
55210 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
55211 mutex_unlock(&task->signal->cred_guard_mutex);
55212 }
55213
55214 -#ifdef CONFIG_STACKTRACE
55215 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55216
55217 #define MAX_STACK_TRACE_DEPTH 64
55218
55219 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55220 return count;
55221 }
55222
55223 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55224 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55225 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55226 {
55227 long nr;
55228 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55229 /************************************************************************/
55230
55231 /* permission checks */
55232 -static int proc_fd_access_allowed(struct inode *inode)
55233 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55234 {
55235 struct task_struct *task;
55236 int allowed = 0;
55237 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55238 */
55239 task = get_proc_task(inode);
55240 if (task) {
55241 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55242 + if (log)
55243 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55244 + else
55245 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55246 put_task_struct(task);
55247 }
55248 return allowed;
55249 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55250 struct task_struct *task,
55251 int hide_pid_min)
55252 {
55253 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55254 + return false;
55255 +
55256 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55257 + rcu_read_lock();
55258 + {
55259 + const struct cred *tmpcred = current_cred();
55260 + const struct cred *cred = __task_cred(task);
55261 +
55262 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55263 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55264 + || in_group_p(grsec_proc_gid)
55265 +#endif
55266 + ) {
55267 + rcu_read_unlock();
55268 + return true;
55269 + }
55270 + }
55271 + rcu_read_unlock();
55272 +
55273 + if (!pid->hide_pid)
55274 + return false;
55275 +#endif
55276 +
55277 if (pid->hide_pid < hide_pid_min)
55278 return true;
55279 if (in_group_p(pid->pid_gid))
55280 return true;
55281 +
55282 return ptrace_may_access(task, PTRACE_MODE_READ);
55283 }
55284
55285 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55286 put_task_struct(task);
55287
55288 if (!has_perms) {
55289 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55290 + {
55291 +#else
55292 if (pid->hide_pid == 2) {
55293 +#endif
55294 /*
55295 * Let's make getdents(), stat(), and open()
55296 * consistent with each other. If a process
55297 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55298 if (!task)
55299 return -ESRCH;
55300
55301 + if (gr_acl_handle_procpidmem(task)) {
55302 + put_task_struct(task);
55303 + return -EPERM;
55304 + }
55305 +
55306 mm = mm_access(task, mode);
55307 put_task_struct(task);
55308
55309 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55310
55311 file->private_data = mm;
55312
55313 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55314 + file->f_version = current->exec_id;
55315 +#endif
55316 +
55317 return 0;
55318 }
55319
55320 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55321 ssize_t copied;
55322 char *page;
55323
55324 +#ifdef CONFIG_GRKERNSEC
55325 + if (write)
55326 + return -EPERM;
55327 +#endif
55328 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55329 + if (file->f_version != current->exec_id) {
55330 + gr_log_badprocpid("mem");
55331 + return 0;
55332 + }
55333 +#endif
55334 +
55335 if (!mm)
55336 return 0;
55337
55338 @@ -722,7 +801,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55339 goto free;
55340
55341 while (count > 0) {
55342 - int this_len = min_t(int, count, PAGE_SIZE);
55343 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55344
55345 if (write && copy_from_user(page, buf, this_len)) {
55346 copied = -EFAULT;
55347 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55348 if (!mm)
55349 return 0;
55350
55351 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55352 + if (file->f_version != current->exec_id) {
55353 + gr_log_badprocpid("environ");
55354 + return 0;
55355 + }
55356 +#endif
55357 +
55358 page = (char *)__get_free_page(GFP_TEMPORARY);
55359 if (!page)
55360 return -ENOMEM;
55361 @@ -823,7 +909,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55362 goto free;
55363 while (count > 0) {
55364 size_t this_len, max_len;
55365 - int retval;
55366 + ssize_t retval;
55367
55368 if (src >= (mm->env_end - mm->env_start))
55369 break;
55370 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55371 int error = -EACCES;
55372
55373 /* Are we allowed to snoop on the tasks file descriptors? */
55374 - if (!proc_fd_access_allowed(inode))
55375 + if (!proc_fd_access_allowed(inode, 0))
55376 goto out;
55377
55378 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55379 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55380 struct path path;
55381
55382 /* Are we allowed to snoop on the tasks file descriptors? */
55383 - if (!proc_fd_access_allowed(inode))
55384 - goto out;
55385 + /* logging this is needed for learning on chromium to work properly,
55386 + but we don't want to flood the logs from 'ps' which does a readlink
55387 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55388 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55389 + */
55390 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55391 + if (!proc_fd_access_allowed(inode,0))
55392 + goto out;
55393 + } else {
55394 + if (!proc_fd_access_allowed(inode,1))
55395 + goto out;
55396 + }
55397
55398 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55399 if (error)
55400 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55401 rcu_read_lock();
55402 cred = __task_cred(task);
55403 inode->i_uid = cred->euid;
55404 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55405 + inode->i_gid = grsec_proc_gid;
55406 +#else
55407 inode->i_gid = cred->egid;
55408 +#endif
55409 rcu_read_unlock();
55410 }
55411 security_task_to_inode(task, inode);
55412 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55413 return -ENOENT;
55414 }
55415 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55416 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55417 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55418 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55419 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55420 +#endif
55421 task_dumpable(task)) {
55422 cred = __task_cred(task);
55423 stat->uid = cred->euid;
55424 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55425 + stat->gid = grsec_proc_gid;
55426 +#else
55427 stat->gid = cred->egid;
55428 +#endif
55429 }
55430 }
55431 rcu_read_unlock();
55432 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55433
55434 if (task) {
55435 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55436 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55437 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55438 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55439 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55440 +#endif
55441 task_dumpable(task)) {
55442 rcu_read_lock();
55443 cred = __task_cred(task);
55444 inode->i_uid = cred->euid;
55445 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55446 + inode->i_gid = grsec_proc_gid;
55447 +#else
55448 inode->i_gid = cred->egid;
55449 +#endif
55450 rcu_read_unlock();
55451 } else {
55452 inode->i_uid = GLOBAL_ROOT_UID;
55453 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55454 if (!task)
55455 goto out_no_task;
55456
55457 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55458 + goto out;
55459 +
55460 /*
55461 * Yes, it does not scale. And it should not. Don't add
55462 * new entries into /proc/<tgid>/ without very good reasons.
55463 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
55464 if (!task)
55465 goto out_no_task;
55466
55467 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55468 + goto out;
55469 +
55470 ret = 0;
55471 i = filp->f_pos;
55472 switch (i) {
55473 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55474 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55475 #endif
55476 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55477 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55478 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55479 INF("syscall", S_IRUGO, proc_pid_syscall),
55480 #endif
55481 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55482 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55483 #ifdef CONFIG_SECURITY
55484 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55485 #endif
55486 -#ifdef CONFIG_KALLSYMS
55487 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55488 INF("wchan", S_IRUGO, proc_pid_wchan),
55489 #endif
55490 -#ifdef CONFIG_STACKTRACE
55491 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55492 ONE("stack", S_IRUGO, proc_pid_stack),
55493 #endif
55494 #ifdef CONFIG_SCHEDSTATS
55495 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55496 #ifdef CONFIG_HARDWALL
55497 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55498 #endif
55499 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55500 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55501 +#endif
55502 #ifdef CONFIG_USER_NS
55503 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55504 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55505 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55506 if (!inode)
55507 goto out;
55508
55509 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55510 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55511 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55512 + inode->i_gid = grsec_proc_gid;
55513 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55514 +#else
55515 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55516 +#endif
55517 inode->i_op = &proc_tgid_base_inode_operations;
55518 inode->i_fop = &proc_tgid_base_operations;
55519 inode->i_flags|=S_IMMUTABLE;
55520 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55521 if (!task)
55522 goto out;
55523
55524 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55525 + goto out_put_task;
55526 +
55527 result = proc_pid_instantiate(dir, dentry, task, NULL);
55528 +out_put_task:
55529 put_task_struct(task);
55530 out:
55531 return result;
55532 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55533 static int fake_filldir(void *buf, const char *name, int namelen,
55534 loff_t offset, u64 ino, unsigned d_type)
55535 {
55536 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55537 + __buf->error = -EINVAL;
55538 return 0;
55539 }
55540
55541 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
55542 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55543 #endif
55544 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55545 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55546 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55547 INF("syscall", S_IRUGO, proc_pid_syscall),
55548 #endif
55549 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55550 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
55551 #ifdef CONFIG_SECURITY
55552 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55553 #endif
55554 -#ifdef CONFIG_KALLSYMS
55555 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55556 INF("wchan", S_IRUGO, proc_pid_wchan),
55557 #endif
55558 -#ifdef CONFIG_STACKTRACE
55559 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55560 ONE("stack", S_IRUGO, proc_pid_stack),
55561 #endif
55562 #ifdef CONFIG_SCHEDSTATS
55563 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55564 index 82676e3..5f8518a 100644
55565 --- a/fs/proc/cmdline.c
55566 +++ b/fs/proc/cmdline.c
55567 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55568
55569 static int __init proc_cmdline_init(void)
55570 {
55571 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55572 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55573 +#else
55574 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55575 +#endif
55576 return 0;
55577 }
55578 module_init(proc_cmdline_init);
55579 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55580 index b143471..bb105e5 100644
55581 --- a/fs/proc/devices.c
55582 +++ b/fs/proc/devices.c
55583 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55584
55585 static int __init proc_devices_init(void)
55586 {
55587 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55588 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55589 +#else
55590 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55591 +#endif
55592 return 0;
55593 }
55594 module_init(proc_devices_init);
55595 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55596 index d7a4a28..0201742 100644
55597 --- a/fs/proc/fd.c
55598 +++ b/fs/proc/fd.c
55599 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55600 if (!task)
55601 return -ENOENT;
55602
55603 - files = get_files_struct(task);
55604 + if (!gr_acl_handle_procpidmem(task))
55605 + files = get_files_struct(task);
55606 put_task_struct(task);
55607
55608 if (files) {
55609 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55610 */
55611 int proc_fd_permission(struct inode *inode, int mask)
55612 {
55613 + struct task_struct *task;
55614 int rv = generic_permission(inode, mask);
55615 - if (rv == 0)
55616 - return 0;
55617 +
55618 if (task_pid(current) == proc_pid(inode))
55619 rv = 0;
55620 +
55621 + task = get_proc_task(inode);
55622 + if (task == NULL)
55623 + return rv;
55624 +
55625 + if (gr_acl_handle_procpidmem(task))
55626 + rv = -EACCES;
55627 +
55628 + put_task_struct(task);
55629 +
55630 return rv;
55631 }
55632
55633 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55634 index 0ac1e1b..0497e58 100644
55635 --- a/fs/proc/inode.c
55636 +++ b/fs/proc/inode.c
55637 @@ -21,11 +21,17 @@
55638 #include <linux/seq_file.h>
55639 #include <linux/slab.h>
55640 #include <linux/mount.h>
55641 +#include <linux/grsecurity.h>
55642
55643 #include <asm/uaccess.h>
55644
55645 #include "internal.h"
55646
55647 +#ifdef CONFIG_PROC_SYSCTL
55648 +extern const struct inode_operations proc_sys_inode_operations;
55649 +extern const struct inode_operations proc_sys_dir_operations;
55650 +#endif
55651 +
55652 static void proc_evict_inode(struct inode *inode)
55653 {
55654 struct proc_dir_entry *de;
55655 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
55656 ns = PROC_I(inode)->ns;
55657 if (ns_ops && ns)
55658 ns_ops->put(ns);
55659 +
55660 +#ifdef CONFIG_PROC_SYSCTL
55661 + if (inode->i_op == &proc_sys_inode_operations ||
55662 + inode->i_op == &proc_sys_dir_operations)
55663 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55664 +#endif
55665 +
55666 }
55667
55668 static struct kmem_cache * proc_inode_cachep;
55669 @@ -455,7 +468,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55670 if (de->mode) {
55671 inode->i_mode = de->mode;
55672 inode->i_uid = de->uid;
55673 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55674 + inode->i_gid = grsec_proc_gid;
55675 +#else
55676 inode->i_gid = de->gid;
55677 +#endif
55678 }
55679 if (de->size)
55680 inode->i_size = de->size;
55681 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55682 index 252544c..04395b9 100644
55683 --- a/fs/proc/internal.h
55684 +++ b/fs/proc/internal.h
55685 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55686 struct pid *pid, struct task_struct *task);
55687 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55688 struct pid *pid, struct task_struct *task);
55689 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55690 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55691 +#endif
55692 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55693
55694 extern const struct file_operations proc_tid_children_operations;
55695 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55696 index e96d4f1..8b116ed 100644
55697 --- a/fs/proc/kcore.c
55698 +++ b/fs/proc/kcore.c
55699 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55700 * the addresses in the elf_phdr on our list.
55701 */
55702 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55703 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55704 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55705 + if (tsz > buflen)
55706 tsz = buflen;
55707 -
55708 +
55709 while (buflen) {
55710 struct kcore_list *m;
55711
55712 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55713 kfree(elf_buf);
55714 } else {
55715 if (kern_addr_valid(start)) {
55716 - unsigned long n;
55717 + char *elf_buf;
55718 + mm_segment_t oldfs;
55719
55720 - n = copy_to_user(buffer, (char *)start, tsz);
55721 - /*
55722 - * We cannot distinguish between fault on source
55723 - * and fault on destination. When this happens
55724 - * we clear too and hope it will trigger the
55725 - * EFAULT again.
55726 - */
55727 - if (n) {
55728 - if (clear_user(buffer + tsz - n,
55729 - n))
55730 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55731 + if (!elf_buf)
55732 + return -ENOMEM;
55733 + oldfs = get_fs();
55734 + set_fs(KERNEL_DS);
55735 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55736 + set_fs(oldfs);
55737 + if (copy_to_user(buffer, elf_buf, tsz)) {
55738 + kfree(elf_buf);
55739 return -EFAULT;
55740 + }
55741 }
55742 + set_fs(oldfs);
55743 + kfree(elf_buf);
55744 } else {
55745 if (clear_user(buffer, tsz))
55746 return -EFAULT;
55747 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55748
55749 static int open_kcore(struct inode *inode, struct file *filp)
55750 {
55751 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55752 + return -EPERM;
55753 +#endif
55754 if (!capable(CAP_SYS_RAWIO))
55755 return -EPERM;
55756 if (kcore_need_update)
55757 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55758 index 80e4645..53e5fcf 100644
55759 --- a/fs/proc/meminfo.c
55760 +++ b/fs/proc/meminfo.c
55761 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55762 vmi.used >> 10,
55763 vmi.largest_chunk >> 10
55764 #ifdef CONFIG_MEMORY_FAILURE
55765 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
55766 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
55767 #endif
55768 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55769 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55770 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55771 index b1822dd..df622cb 100644
55772 --- a/fs/proc/nommu.c
55773 +++ b/fs/proc/nommu.c
55774 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55775 if (len < 1)
55776 len = 1;
55777 seq_printf(m, "%*c", len, ' ');
55778 - seq_path(m, &file->f_path, "");
55779 + seq_path(m, &file->f_path, "\n\\");
55780 }
55781
55782 seq_putc(m, '\n');
55783 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55784 index fe72cd0..21b52ff 100644
55785 --- a/fs/proc/proc_net.c
55786 +++ b/fs/proc/proc_net.c
55787 @@ -23,6 +23,7 @@
55788 #include <linux/nsproxy.h>
55789 #include <net/net_namespace.h>
55790 #include <linux/seq_file.h>
55791 +#include <linux/grsecurity.h>
55792
55793 #include "internal.h"
55794
55795 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55796 struct task_struct *task;
55797 struct nsproxy *ns;
55798 struct net *net = NULL;
55799 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55800 + const struct cred *cred = current_cred();
55801 +#endif
55802 +
55803 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55804 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55805 + return net;
55806 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55807 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55808 + return net;
55809 +#endif
55810
55811 rcu_read_lock();
55812 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55813 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55814 index 1827d88..43b0279 100644
55815 --- a/fs/proc/proc_sysctl.c
55816 +++ b/fs/proc/proc_sysctl.c
55817 @@ -12,11 +12,15 @@
55818 #include <linux/module.h>
55819 #include "internal.h"
55820
55821 +extern int gr_handle_chroot_sysctl(const int op);
55822 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55823 + const int op);
55824 +
55825 static const struct dentry_operations proc_sys_dentry_operations;
55826 static const struct file_operations proc_sys_file_operations;
55827 -static const struct inode_operations proc_sys_inode_operations;
55828 +const struct inode_operations proc_sys_inode_operations;
55829 static const struct file_operations proc_sys_dir_file_operations;
55830 -static const struct inode_operations proc_sys_dir_operations;
55831 +const struct inode_operations proc_sys_dir_operations;
55832
55833 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55834 {
55835 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55836
55837 err = NULL;
55838 d_set_d_op(dentry, &proc_sys_dentry_operations);
55839 +
55840 + gr_handle_proc_create(dentry, inode);
55841 +
55842 d_add(dentry, inode);
55843
55844 out:
55845 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55846 struct inode *inode = filp->f_path.dentry->d_inode;
55847 struct ctl_table_header *head = grab_header(inode);
55848 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55849 + int op = write ? MAY_WRITE : MAY_READ;
55850 ssize_t error;
55851 size_t res;
55852
55853 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55854 * and won't be until we finish.
55855 */
55856 error = -EPERM;
55857 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55858 + if (sysctl_perm(head, table, op))
55859 goto out;
55860
55861 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55862 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55863 if (!table->proc_handler)
55864 goto out;
55865
55866 +#ifdef CONFIG_GRKERNSEC
55867 + error = -EPERM;
55868 + if (gr_handle_chroot_sysctl(op))
55869 + goto out;
55870 + dget(filp->f_path.dentry);
55871 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55872 + dput(filp->f_path.dentry);
55873 + goto out;
55874 + }
55875 + dput(filp->f_path.dentry);
55876 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55877 + goto out;
55878 + if (write && !capable(CAP_SYS_ADMIN))
55879 + goto out;
55880 +#endif
55881 +
55882 /* careful: calling conventions are nasty here */
55883 res = count;
55884 error = table->proc_handler(table, write, buf, &res, ppos);
55885 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55886 return -ENOMEM;
55887 } else {
55888 d_set_d_op(child, &proc_sys_dentry_operations);
55889 +
55890 + gr_handle_proc_create(child, inode);
55891 +
55892 d_add(child, inode);
55893 }
55894 } else {
55895 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55896 if ((*pos)++ < file->f_pos)
55897 return 0;
55898
55899 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55900 + return 0;
55901 +
55902 if (unlikely(S_ISLNK(table->mode)))
55903 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55904 else
55905 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55906 if (IS_ERR(head))
55907 return PTR_ERR(head);
55908
55909 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55910 + return -ENOENT;
55911 +
55912 generic_fillattr(inode, stat);
55913 if (table)
55914 stat->mode = (stat->mode & S_IFMT) | table->mode;
55915 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55916 .llseek = generic_file_llseek,
55917 };
55918
55919 -static const struct inode_operations proc_sys_inode_operations = {
55920 +const struct inode_operations proc_sys_inode_operations = {
55921 .permission = proc_sys_permission,
55922 .setattr = proc_sys_setattr,
55923 .getattr = proc_sys_getattr,
55924 };
55925
55926 -static const struct inode_operations proc_sys_dir_operations = {
55927 +const struct inode_operations proc_sys_dir_operations = {
55928 .lookup = proc_sys_lookup,
55929 .permission = proc_sys_permission,
55930 .setattr = proc_sys_setattr,
55931 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55932 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55933 const char *name, int namelen)
55934 {
55935 - struct ctl_table *table;
55936 + ctl_table_no_const *table;
55937 struct ctl_dir *new;
55938 struct ctl_node *node;
55939 char *new_name;
55940 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55941 return NULL;
55942
55943 node = (struct ctl_node *)(new + 1);
55944 - table = (struct ctl_table *)(node + 1);
55945 + table = (ctl_table_no_const *)(node + 1);
55946 new_name = (char *)(table + 2);
55947 memcpy(new_name, name, namelen);
55948 new_name[namelen] = '\0';
55949 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55950 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55951 struct ctl_table_root *link_root)
55952 {
55953 - struct ctl_table *link_table, *entry, *link;
55954 + ctl_table_no_const *link_table, *link;
55955 + struct ctl_table *entry;
55956 struct ctl_table_header *links;
55957 struct ctl_node *node;
55958 char *link_name;
55959 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55960 return NULL;
55961
55962 node = (struct ctl_node *)(links + 1);
55963 - link_table = (struct ctl_table *)(node + nr_entries);
55964 + link_table = (ctl_table_no_const *)(node + nr_entries);
55965 link_name = (char *)&link_table[nr_entries + 1];
55966
55967 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55968 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55969 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55970 struct ctl_table *table)
55971 {
55972 - struct ctl_table *ctl_table_arg = NULL;
55973 - struct ctl_table *entry, *files;
55974 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55975 + struct ctl_table *entry;
55976 int nr_files = 0;
55977 int nr_dirs = 0;
55978 int err = -ENOMEM;
55979 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55980 nr_files++;
55981 }
55982
55983 - files = table;
55984 /* If there are mixed files and directories we need a new table */
55985 if (nr_dirs && nr_files) {
55986 - struct ctl_table *new;
55987 + ctl_table_no_const *new;
55988 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55989 GFP_KERNEL);
55990 if (!files)
55991 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55992 /* Register everything except a directory full of subdirectories */
55993 if (nr_files || !nr_dirs) {
55994 struct ctl_table_header *header;
55995 - header = __register_sysctl_table(set, path, files);
55996 + header = __register_sysctl_table(set, path, files ? files : table);
55997 if (!header) {
55998 kfree(ctl_table_arg);
55999 goto out;
56000 diff --git a/fs/proc/root.c b/fs/proc/root.c
56001 index 9c7fab1..ed1c8e0 100644
56002 --- a/fs/proc/root.c
56003 +++ b/fs/proc/root.c
56004 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
56005 #ifdef CONFIG_PROC_DEVICETREE
56006 proc_device_tree_init();
56007 #endif
56008 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56009 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56010 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
56011 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56012 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
56013 +#endif
56014 +#else
56015 proc_mkdir("bus", NULL);
56016 +#endif
56017 proc_sys_init();
56018 }
56019
56020 diff --git a/fs/proc/self.c b/fs/proc/self.c
56021 index aa5cc3b..c91a5d0 100644
56022 --- a/fs/proc/self.c
56023 +++ b/fs/proc/self.c
56024 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
56025 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
56026 void *cookie)
56027 {
56028 - char *s = nd_get_link(nd);
56029 + const char *s = nd_get_link(nd);
56030 if (!IS_ERR(s))
56031 kfree(s);
56032 }
56033 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
56034 index ca5ce7f..02c1cf0 100644
56035 --- a/fs/proc/task_mmu.c
56036 +++ b/fs/proc/task_mmu.c
56037 @@ -11,12 +11,19 @@
56038 #include <linux/rmap.h>
56039 #include <linux/swap.h>
56040 #include <linux/swapops.h>
56041 +#include <linux/grsecurity.h>
56042
56043 #include <asm/elf.h>
56044 #include <asm/uaccess.h>
56045 #include <asm/tlbflush.h>
56046 #include "internal.h"
56047
56048 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56049 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
56050 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
56051 + _mm->pax_flags & MF_PAX_SEGMEXEC))
56052 +#endif
56053 +
56054 void task_mem(struct seq_file *m, struct mm_struct *mm)
56055 {
56056 unsigned long data, text, lib, swap;
56057 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56058 "VmExe:\t%8lu kB\n"
56059 "VmLib:\t%8lu kB\n"
56060 "VmPTE:\t%8lu kB\n"
56061 - "VmSwap:\t%8lu kB\n",
56062 - hiwater_vm << (PAGE_SHIFT-10),
56063 + "VmSwap:\t%8lu kB\n"
56064 +
56065 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56066 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56067 +#endif
56068 +
56069 + ,hiwater_vm << (PAGE_SHIFT-10),
56070 total_vm << (PAGE_SHIFT-10),
56071 mm->locked_vm << (PAGE_SHIFT-10),
56072 mm->pinned_vm << (PAGE_SHIFT-10),
56073 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56074 data << (PAGE_SHIFT-10),
56075 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56076 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56077 - swap << (PAGE_SHIFT-10));
56078 + swap << (PAGE_SHIFT-10)
56079 +
56080 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56081 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56082 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56083 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56084 +#else
56085 + , mm->context.user_cs_base
56086 + , mm->context.user_cs_limit
56087 +#endif
56088 +#endif
56089 +
56090 + );
56091 }
56092
56093 unsigned long task_vsize(struct mm_struct *mm)
56094 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56095 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56096 }
56097
56098 - /* We don't show the stack guard page in /proc/maps */
56099 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56100 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56101 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56102 +#else
56103 start = vma->vm_start;
56104 - if (stack_guard_page_start(vma, start))
56105 - start += PAGE_SIZE;
56106 end = vma->vm_end;
56107 - if (stack_guard_page_end(vma, end))
56108 - end -= PAGE_SIZE;
56109 +#endif
56110
56111 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56112 start,
56113 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56114 flags & VM_WRITE ? 'w' : '-',
56115 flags & VM_EXEC ? 'x' : '-',
56116 flags & VM_MAYSHARE ? 's' : 'p',
56117 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56118 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56119 +#else
56120 pgoff,
56121 +#endif
56122 MAJOR(dev), MINOR(dev), ino, &len);
56123
56124 /*
56125 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56126 */
56127 if (file) {
56128 pad_len_spaces(m, len);
56129 - seq_path(m, &file->f_path, "\n");
56130 + seq_path(m, &file->f_path, "\n\\");
56131 goto done;
56132 }
56133
56134 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56135 * Thread stack in /proc/PID/task/TID/maps or
56136 * the main process stack.
56137 */
56138 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56139 - vma->vm_end >= mm->start_stack)) {
56140 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56141 + (vma->vm_start <= mm->start_stack &&
56142 + vma->vm_end >= mm->start_stack)) {
56143 name = "[stack]";
56144 } else {
56145 /* Thread stack in /proc/PID/maps */
56146 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56147 struct proc_maps_private *priv = m->private;
56148 struct task_struct *task = priv->task;
56149
56150 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56151 + if (current->exec_id != m->exec_id) {
56152 + gr_log_badprocpid("maps");
56153 + return 0;
56154 + }
56155 +#endif
56156 +
56157 show_map_vma(m, vma, is_pid);
56158
56159 if (m->count < m->size) /* vma is copied successfully */
56160 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56161 .private = &mss,
56162 };
56163
56164 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56165 + if (current->exec_id != m->exec_id) {
56166 + gr_log_badprocpid("smaps");
56167 + return 0;
56168 + }
56169 +#endif
56170 memset(&mss, 0, sizeof mss);
56171 - mss.vma = vma;
56172 - /* mmap_sem is held in m_start */
56173 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56174 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56175 -
56176 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56177 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56178 +#endif
56179 + mss.vma = vma;
56180 + /* mmap_sem is held in m_start */
56181 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56182 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56183 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56184 + }
56185 +#endif
56186 show_map_vma(m, vma, is_pid);
56187
56188 seq_printf(m,
56189 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56190 "KernelPageSize: %8lu kB\n"
56191 "MMUPageSize: %8lu kB\n"
56192 "Locked: %8lu kB\n",
56193 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56194 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56195 +#else
56196 (vma->vm_end - vma->vm_start) >> 10,
56197 +#endif
56198 mss.resident >> 10,
56199 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56200 mss.shared_clean >> 10,
56201 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56202 int n;
56203 char buffer[50];
56204
56205 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56206 + if (current->exec_id != m->exec_id) {
56207 + gr_log_badprocpid("numa_maps");
56208 + return 0;
56209 + }
56210 +#endif
56211 +
56212 if (!mm)
56213 return 0;
56214
56215 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56216 mpol_to_str(buffer, sizeof(buffer), pol);
56217 mpol_cond_put(pol);
56218
56219 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56220 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56221 +#else
56222 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56223 +#endif
56224
56225 if (file) {
56226 seq_printf(m, " file=");
56227 - seq_path(m, &file->f_path, "\n\t= ");
56228 + seq_path(m, &file->f_path, "\n\t\\= ");
56229 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56230 seq_printf(m, " heap");
56231 } else {
56232 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56233 index 1ccfa53..0848f95 100644
56234 --- a/fs/proc/task_nommu.c
56235 +++ b/fs/proc/task_nommu.c
56236 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56237 else
56238 bytes += kobjsize(mm);
56239
56240 - if (current->fs && current->fs->users > 1)
56241 + if (current->fs && atomic_read(&current->fs->users) > 1)
56242 sbytes += kobjsize(current->fs);
56243 else
56244 bytes += kobjsize(current->fs);
56245 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56246
56247 if (file) {
56248 pad_len_spaces(m, len);
56249 - seq_path(m, &file->f_path, "");
56250 + seq_path(m, &file->f_path, "\n\\");
56251 } else if (mm) {
56252 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56253
56254 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56255 index b00fcc9..e0c6381 100644
56256 --- a/fs/qnx6/qnx6.h
56257 +++ b/fs/qnx6/qnx6.h
56258 @@ -74,7 +74,7 @@ enum {
56259 BYTESEX_BE,
56260 };
56261
56262 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56263 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56264 {
56265 if (sbi->s_bytesex == BYTESEX_LE)
56266 return le64_to_cpu((__force __le64)n);
56267 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56268 return (__force __fs64)cpu_to_be64(n);
56269 }
56270
56271 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56272 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56273 {
56274 if (sbi->s_bytesex == BYTESEX_LE)
56275 return le32_to_cpu((__force __le32)n);
56276 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56277 index 16e8abb..2dcf914 100644
56278 --- a/fs/quota/netlink.c
56279 +++ b/fs/quota/netlink.c
56280 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56281 void quota_send_warning(struct kqid qid, dev_t dev,
56282 const char warntype)
56283 {
56284 - static atomic_t seq;
56285 + static atomic_unchecked_t seq;
56286 struct sk_buff *skb;
56287 void *msg_head;
56288 int ret;
56289 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56290 "VFS: Not enough memory to send quota warning.\n");
56291 return;
56292 }
56293 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56294 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56295 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56296 if (!msg_head) {
56297 printk(KERN_ERR
56298 diff --git a/fs/readdir.c b/fs/readdir.c
56299 index 5e69ef5..e5d9099 100644
56300 --- a/fs/readdir.c
56301 +++ b/fs/readdir.c
56302 @@ -17,6 +17,7 @@
56303 #include <linux/security.h>
56304 #include <linux/syscalls.h>
56305 #include <linux/unistd.h>
56306 +#include <linux/namei.h>
56307
56308 #include <asm/uaccess.h>
56309
56310 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56311
56312 struct readdir_callback {
56313 struct old_linux_dirent __user * dirent;
56314 + struct file * file;
56315 int result;
56316 };
56317
56318 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56319 buf->result = -EOVERFLOW;
56320 return -EOVERFLOW;
56321 }
56322 +
56323 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56324 + return 0;
56325 +
56326 buf->result++;
56327 dirent = buf->dirent;
56328 if (!access_ok(VERIFY_WRITE, dirent,
56329 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56330
56331 buf.result = 0;
56332 buf.dirent = dirent;
56333 + buf.file = f.file;
56334
56335 error = vfs_readdir(f.file, fillonedir, &buf);
56336 if (buf.result)
56337 @@ -139,6 +146,7 @@ struct linux_dirent {
56338 struct getdents_callback {
56339 struct linux_dirent __user * current_dir;
56340 struct linux_dirent __user * previous;
56341 + struct file * file;
56342 int count;
56343 int error;
56344 };
56345 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56346 buf->error = -EOVERFLOW;
56347 return -EOVERFLOW;
56348 }
56349 +
56350 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56351 + return 0;
56352 +
56353 dirent = buf->previous;
56354 if (dirent) {
56355 if (__put_user(offset, &dirent->d_off))
56356 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56357 buf.previous = NULL;
56358 buf.count = count;
56359 buf.error = 0;
56360 + buf.file = f.file;
56361
56362 error = vfs_readdir(f.file, filldir, &buf);
56363 if (error >= 0)
56364 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56365 struct getdents_callback64 {
56366 struct linux_dirent64 __user * current_dir;
56367 struct linux_dirent64 __user * previous;
56368 + struct file *file;
56369 int count;
56370 int error;
56371 };
56372 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56373 buf->error = -EINVAL; /* only used if we fail.. */
56374 if (reclen > buf->count)
56375 return -EINVAL;
56376 +
56377 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56378 + return 0;
56379 +
56380 dirent = buf->previous;
56381 if (dirent) {
56382 if (__put_user(offset, &dirent->d_off))
56383 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56384
56385 buf.current_dir = dirent;
56386 buf.previous = NULL;
56387 + buf.file = f.file;
56388 buf.count = count;
56389 buf.error = 0;
56390
56391 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56392 error = buf.error;
56393 lastdirent = buf.previous;
56394 if (lastdirent) {
56395 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56396 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56397 if (__put_user(d_off, &lastdirent->d_off))
56398 error = -EFAULT;
56399 else
56400 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56401 index 2b7882b..1c5ef48 100644
56402 --- a/fs/reiserfs/do_balan.c
56403 +++ b/fs/reiserfs/do_balan.c
56404 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56405 return;
56406 }
56407
56408 - atomic_inc(&(fs_generation(tb->tb_sb)));
56409 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56410 do_balance_starts(tb);
56411
56412 /* balance leaf returns 0 except if combining L R and S into
56413 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56414 index e60e870..f40ac16 100644
56415 --- a/fs/reiserfs/procfs.c
56416 +++ b/fs/reiserfs/procfs.c
56417 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56418 "SMALL_TAILS " : "NO_TAILS ",
56419 replay_only(sb) ? "REPLAY_ONLY " : "",
56420 convert_reiserfs(sb) ? "CONV " : "",
56421 - atomic_read(&r->s_generation_counter),
56422 + atomic_read_unchecked(&r->s_generation_counter),
56423 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56424 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56425 SF(s_good_search_by_key_reada), SF(s_bmaps),
56426 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56427 index 157e474..65a6114 100644
56428 --- a/fs/reiserfs/reiserfs.h
56429 +++ b/fs/reiserfs/reiserfs.h
56430 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56431 /* Comment? -Hans */
56432 wait_queue_head_t s_wait;
56433 /* To be obsoleted soon by per buffer seals.. -Hans */
56434 - atomic_t s_generation_counter; // increased by one every time the
56435 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56436 // tree gets re-balanced
56437 unsigned long s_properties; /* File system properties. Currently holds
56438 on-disk FS format */
56439 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56440 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56441
56442 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56443 -#define get_generation(s) atomic_read (&fs_generation(s))
56444 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56445 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56446 #define __fs_changed(gen,s) (gen != get_generation (s))
56447 #define fs_changed(gen,s) \
56448 diff --git a/fs/select.c b/fs/select.c
56449 index 2ef72d9..f213b17 100644
56450 --- a/fs/select.c
56451 +++ b/fs/select.c
56452 @@ -20,6 +20,7 @@
56453 #include <linux/export.h>
56454 #include <linux/slab.h>
56455 #include <linux/poll.h>
56456 +#include <linux/security.h>
56457 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56458 #include <linux/file.h>
56459 #include <linux/fdtable.h>
56460 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56461 struct poll_list *walk = head;
56462 unsigned long todo = nfds;
56463
56464 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56465 if (nfds > rlimit(RLIMIT_NOFILE))
56466 return -EINVAL;
56467
56468 diff --git a/fs/seq_file.c b/fs/seq_file.c
56469 index f2bc3df..239d4f6 100644
56470 --- a/fs/seq_file.c
56471 +++ b/fs/seq_file.c
56472 @@ -10,6 +10,7 @@
56473 #include <linux/seq_file.h>
56474 #include <linux/slab.h>
56475 #include <linux/cred.h>
56476 +#include <linux/sched.h>
56477
56478 #include <asm/uaccess.h>
56479 #include <asm/page.h>
56480 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56481 #ifdef CONFIG_USER_NS
56482 p->user_ns = file->f_cred->user_ns;
56483 #endif
56484 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56485 + p->exec_id = current->exec_id;
56486 +#endif
56487
56488 /*
56489 * Wrappers around seq_open(e.g. swaps_open) need to be
56490 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56491 return 0;
56492 }
56493 if (!m->buf) {
56494 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56495 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56496 if (!m->buf)
56497 return -ENOMEM;
56498 }
56499 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56500 Eoverflow:
56501 m->op->stop(m, p);
56502 kfree(m->buf);
56503 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56504 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56505 return !m->buf ? -ENOMEM : -EAGAIN;
56506 }
56507
56508 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56509
56510 /* grab buffer if we didn't have one */
56511 if (!m->buf) {
56512 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56513 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56514 if (!m->buf)
56515 goto Enomem;
56516 }
56517 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56518 goto Fill;
56519 m->op->stop(m, p);
56520 kfree(m->buf);
56521 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56522 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56523 if (!m->buf)
56524 goto Enomem;
56525 m->count = 0;
56526 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56527 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56528 void *data)
56529 {
56530 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56531 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56532 int res = -ENOMEM;
56533
56534 if (op) {
56535 diff --git a/fs/splice.c b/fs/splice.c
56536 index 6909d89..5b2e8f9 100644
56537 --- a/fs/splice.c
56538 +++ b/fs/splice.c
56539 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56540 pipe_lock(pipe);
56541
56542 for (;;) {
56543 - if (!pipe->readers) {
56544 + if (!atomic_read(&pipe->readers)) {
56545 send_sig(SIGPIPE, current, 0);
56546 if (!ret)
56547 ret = -EPIPE;
56548 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56549 do_wakeup = 0;
56550 }
56551
56552 - pipe->waiting_writers++;
56553 + atomic_inc(&pipe->waiting_writers);
56554 pipe_wait(pipe);
56555 - pipe->waiting_writers--;
56556 + atomic_dec(&pipe->waiting_writers);
56557 }
56558
56559 pipe_unlock(pipe);
56560 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56561 old_fs = get_fs();
56562 set_fs(get_ds());
56563 /* The cast to a user pointer is valid due to the set_fs() */
56564 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56565 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56566 set_fs(old_fs);
56567
56568 return res;
56569 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56570 old_fs = get_fs();
56571 set_fs(get_ds());
56572 /* The cast to a user pointer is valid due to the set_fs() */
56573 - res = vfs_write(file, (const char __user *)buf, count, &pos);
56574 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56575 set_fs(old_fs);
56576
56577 return res;
56578 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56579 goto err;
56580
56581 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56582 - vec[i].iov_base = (void __user *) page_address(page);
56583 + vec[i].iov_base = (void __force_user *) page_address(page);
56584 vec[i].iov_len = this_len;
56585 spd.pages[i] = page;
56586 spd.nr_pages++;
56587 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56588 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56589 {
56590 while (!pipe->nrbufs) {
56591 - if (!pipe->writers)
56592 + if (!atomic_read(&pipe->writers))
56593 return 0;
56594
56595 - if (!pipe->waiting_writers && sd->num_spliced)
56596 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56597 return 0;
56598
56599 if (sd->flags & SPLICE_F_NONBLOCK)
56600 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56601 * out of the pipe right after the splice_to_pipe(). So set
56602 * PIPE_READERS appropriately.
56603 */
56604 - pipe->readers = 1;
56605 + atomic_set(&pipe->readers, 1);
56606
56607 current->splice_pipe = pipe;
56608 }
56609 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56610 ret = -ERESTARTSYS;
56611 break;
56612 }
56613 - if (!pipe->writers)
56614 + if (!atomic_read(&pipe->writers))
56615 break;
56616 - if (!pipe->waiting_writers) {
56617 + if (!atomic_read(&pipe->waiting_writers)) {
56618 if (flags & SPLICE_F_NONBLOCK) {
56619 ret = -EAGAIN;
56620 break;
56621 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56622 pipe_lock(pipe);
56623
56624 while (pipe->nrbufs >= pipe->buffers) {
56625 - if (!pipe->readers) {
56626 + if (!atomic_read(&pipe->readers)) {
56627 send_sig(SIGPIPE, current, 0);
56628 ret = -EPIPE;
56629 break;
56630 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56631 ret = -ERESTARTSYS;
56632 break;
56633 }
56634 - pipe->waiting_writers++;
56635 + atomic_inc(&pipe->waiting_writers);
56636 pipe_wait(pipe);
56637 - pipe->waiting_writers--;
56638 + atomic_dec(&pipe->waiting_writers);
56639 }
56640
56641 pipe_unlock(pipe);
56642 @@ -1823,14 +1823,14 @@ retry:
56643 pipe_double_lock(ipipe, opipe);
56644
56645 do {
56646 - if (!opipe->readers) {
56647 + if (!atomic_read(&opipe->readers)) {
56648 send_sig(SIGPIPE, current, 0);
56649 if (!ret)
56650 ret = -EPIPE;
56651 break;
56652 }
56653
56654 - if (!ipipe->nrbufs && !ipipe->writers)
56655 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56656 break;
56657
56658 /*
56659 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56660 pipe_double_lock(ipipe, opipe);
56661
56662 do {
56663 - if (!opipe->readers) {
56664 + if (!atomic_read(&opipe->readers)) {
56665 send_sig(SIGPIPE, current, 0);
56666 if (!ret)
56667 ret = -EPIPE;
56668 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56669 * return EAGAIN if we have the potential of some data in the
56670 * future, otherwise just return 0
56671 */
56672 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56673 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56674 ret = -EAGAIN;
56675
56676 pipe_unlock(ipipe);
56677 diff --git a/fs/stat.c b/fs/stat.c
56678 index 14f4545..9b7f55b 100644
56679 --- a/fs/stat.c
56680 +++ b/fs/stat.c
56681 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56682 stat->gid = inode->i_gid;
56683 stat->rdev = inode->i_rdev;
56684 stat->size = i_size_read(inode);
56685 - stat->atime = inode->i_atime;
56686 - stat->mtime = inode->i_mtime;
56687 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56688 + stat->atime = inode->i_ctime;
56689 + stat->mtime = inode->i_ctime;
56690 + } else {
56691 + stat->atime = inode->i_atime;
56692 + stat->mtime = inode->i_mtime;
56693 + }
56694 stat->ctime = inode->i_ctime;
56695 stat->blksize = (1 << inode->i_blkbits);
56696 stat->blocks = inode->i_blocks;
56697 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
56698 if (retval)
56699 return retval;
56700
56701 - if (inode->i_op->getattr)
56702 - return inode->i_op->getattr(mnt, dentry, stat);
56703 + if (inode->i_op->getattr) {
56704 + retval = inode->i_op->getattr(mnt, dentry, stat);
56705 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56706 + stat->atime = stat->ctime;
56707 + stat->mtime = stat->ctime;
56708 + }
56709 + return retval;
56710 + }
56711
56712 generic_fillattr(inode, stat);
56713 return 0;
56714 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56715 index 614b2b5..4d321e6 100644
56716 --- a/fs/sysfs/bin.c
56717 +++ b/fs/sysfs/bin.c
56718 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56719 return ret;
56720 }
56721
56722 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56723 - void *buf, int len, int write)
56724 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56725 + void *buf, size_t len, int write)
56726 {
56727 struct file *file = vma->vm_file;
56728 struct bin_buffer *bb = file->private_data;
56729 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56730 - int ret;
56731 + ssize_t ret;
56732
56733 if (!bb->vm_ops)
56734 return -EINVAL;
56735 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56736 index 1f8c823..ed57cfe 100644
56737 --- a/fs/sysfs/dir.c
56738 +++ b/fs/sysfs/dir.c
56739 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56740 *
56741 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56742 */
56743 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56744 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56745 {
56746 unsigned long hash = init_name_hash();
56747 unsigned int len = strlen(name);
56748 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56749 struct sysfs_dirent *sd;
56750 int rc;
56751
56752 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56753 + const char *parent_name = parent_sd->s_name;
56754 +
56755 + mode = S_IFDIR | S_IRWXU;
56756 +
56757 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56758 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56759 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56760 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56761 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56762 +#endif
56763 +
56764 /* allocate */
56765 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56766 if (!sd)
56767 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56768 index 602f56d..6853db8 100644
56769 --- a/fs/sysfs/file.c
56770 +++ b/fs/sysfs/file.c
56771 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56772
56773 struct sysfs_open_dirent {
56774 atomic_t refcnt;
56775 - atomic_t event;
56776 + atomic_unchecked_t event;
56777 wait_queue_head_t poll;
56778 struct list_head buffers; /* goes through sysfs_buffer.list */
56779 };
56780 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56781 if (!sysfs_get_active(attr_sd))
56782 return -ENODEV;
56783
56784 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56785 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56786 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56787
56788 sysfs_put_active(attr_sd);
56789 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56790 return -ENOMEM;
56791
56792 atomic_set(&new_od->refcnt, 0);
56793 - atomic_set(&new_od->event, 1);
56794 + atomic_set_unchecked(&new_od->event, 1);
56795 init_waitqueue_head(&new_od->poll);
56796 INIT_LIST_HEAD(&new_od->buffers);
56797 goto retry;
56798 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56799
56800 sysfs_put_active(attr_sd);
56801
56802 - if (buffer->event != atomic_read(&od->event))
56803 + if (buffer->event != atomic_read_unchecked(&od->event))
56804 goto trigger;
56805
56806 return DEFAULT_POLLMASK;
56807 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56808
56809 od = sd->s_attr.open;
56810 if (od) {
56811 - atomic_inc(&od->event);
56812 + atomic_inc_unchecked(&od->event);
56813 wake_up_interruptible(&od->poll);
56814 }
56815
56816 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56817 index 3c9eb56..9dea5be 100644
56818 --- a/fs/sysfs/symlink.c
56819 +++ b/fs/sysfs/symlink.c
56820 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56821
56822 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56823 {
56824 - char *page = nd_get_link(nd);
56825 + const char *page = nd_get_link(nd);
56826 if (!IS_ERR(page))
56827 free_page((unsigned long)page);
56828 }
56829 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56830 index 69d4889..a810bd4 100644
56831 --- a/fs/sysv/sysv.h
56832 +++ b/fs/sysv/sysv.h
56833 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56834 #endif
56835 }
56836
56837 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56838 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56839 {
56840 if (sbi->s_bytesex == BYTESEX_PDP)
56841 return PDP_swab((__force __u32)n);
56842 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56843 index e18b988..f1d4ad0f 100644
56844 --- a/fs/ubifs/io.c
56845 +++ b/fs/ubifs/io.c
56846 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56847 return err;
56848 }
56849
56850 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56851 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56852 {
56853 int err;
56854
56855 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56856 index c175b4d..8f36a16 100644
56857 --- a/fs/udf/misc.c
56858 +++ b/fs/udf/misc.c
56859 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56860
56861 u8 udf_tag_checksum(const struct tag *t)
56862 {
56863 - u8 *data = (u8 *)t;
56864 + const u8 *data = (const u8 *)t;
56865 u8 checksum = 0;
56866 int i;
56867 for (i = 0; i < sizeof(struct tag); ++i)
56868 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56869 index 8d974c4..b82f6ec 100644
56870 --- a/fs/ufs/swab.h
56871 +++ b/fs/ufs/swab.h
56872 @@ -22,7 +22,7 @@ enum {
56873 BYTESEX_BE
56874 };
56875
56876 -static inline u64
56877 +static inline u64 __intentional_overflow(-1)
56878 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56879 {
56880 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56881 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56882 return (__force __fs64)cpu_to_be64(n);
56883 }
56884
56885 -static inline u32
56886 +static inline u32 __intentional_overflow(-1)
56887 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56888 {
56889 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56890 diff --git a/fs/utimes.c b/fs/utimes.c
56891 index f4fb7ec..3fe03c0 100644
56892 --- a/fs/utimes.c
56893 +++ b/fs/utimes.c
56894 @@ -1,6 +1,7 @@
56895 #include <linux/compiler.h>
56896 #include <linux/file.h>
56897 #include <linux/fs.h>
56898 +#include <linux/security.h>
56899 #include <linux/linkage.h>
56900 #include <linux/mount.h>
56901 #include <linux/namei.h>
56902 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56903 goto mnt_drop_write_and_out;
56904 }
56905 }
56906 +
56907 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56908 + error = -EACCES;
56909 + goto mnt_drop_write_and_out;
56910 + }
56911 +
56912 mutex_lock(&inode->i_mutex);
56913 error = notify_change(path->dentry, &newattrs);
56914 mutex_unlock(&inode->i_mutex);
56915 diff --git a/fs/xattr.c b/fs/xattr.c
56916 index 3377dff..4feded6 100644
56917 --- a/fs/xattr.c
56918 +++ b/fs/xattr.c
56919 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56920 * Extended attribute SET operations
56921 */
56922 static long
56923 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56924 +setxattr(struct path *path, const char __user *name, const void __user *value,
56925 size_t size, int flags)
56926 {
56927 int error;
56928 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56929 posix_acl_fix_xattr_from_user(kvalue, size);
56930 }
56931
56932 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56933 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56934 + error = -EACCES;
56935 + goto out;
56936 + }
56937 +
56938 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56939 out:
56940 if (vvalue)
56941 vfree(vvalue);
56942 @@ -377,7 +382,7 @@ retry:
56943 return error;
56944 error = mnt_want_write(path.mnt);
56945 if (!error) {
56946 - error = setxattr(path.dentry, name, value, size, flags);
56947 + error = setxattr(&path, name, value, size, flags);
56948 mnt_drop_write(path.mnt);
56949 }
56950 path_put(&path);
56951 @@ -401,7 +406,7 @@ retry:
56952 return error;
56953 error = mnt_want_write(path.mnt);
56954 if (!error) {
56955 - error = setxattr(path.dentry, name, value, size, flags);
56956 + error = setxattr(&path, name, value, size, flags);
56957 mnt_drop_write(path.mnt);
56958 }
56959 path_put(&path);
56960 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56961 const void __user *,value, size_t, size, int, flags)
56962 {
56963 struct fd f = fdget(fd);
56964 - struct dentry *dentry;
56965 int error = -EBADF;
56966
56967 if (!f.file)
56968 return error;
56969 - dentry = f.file->f_path.dentry;
56970 - audit_inode(NULL, dentry, 0);
56971 + audit_inode(NULL, f.file->f_path.dentry, 0);
56972 error = mnt_want_write_file(f.file);
56973 if (!error) {
56974 - error = setxattr(dentry, name, value, size, flags);
56975 + error = setxattr(&f.file->f_path, name, value, size, flags);
56976 mnt_drop_write_file(f.file);
56977 }
56978 fdput(f);
56979 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56980 index 9fbea87..6b19972 100644
56981 --- a/fs/xattr_acl.c
56982 +++ b/fs/xattr_acl.c
56983 @@ -76,8 +76,8 @@ struct posix_acl *
56984 posix_acl_from_xattr(struct user_namespace *user_ns,
56985 const void *value, size_t size)
56986 {
56987 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56988 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56989 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56990 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56991 int count;
56992 struct posix_acl *acl;
56993 struct posix_acl_entry *acl_e;
56994 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56995 index 572a858..12a9b0d 100644
56996 --- a/fs/xfs/xfs_bmap.c
56997 +++ b/fs/xfs/xfs_bmap.c
56998 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56999 int nmap,
57000 int ret_nmap);
57001 #else
57002 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
57003 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
57004 #endif /* DEBUG */
57005
57006 STATIC int
57007 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
57008 index 1b9fc3e..e1bdde0 100644
57009 --- a/fs/xfs/xfs_dir2_sf.c
57010 +++ b/fs/xfs/xfs_dir2_sf.c
57011 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
57012 }
57013
57014 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
57015 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57016 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
57017 + char name[sfep->namelen];
57018 + memcpy(name, sfep->name, sfep->namelen);
57019 + if (filldir(dirent, name, sfep->namelen,
57020 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
57021 + *offset = off & 0x7fffffff;
57022 + return 0;
57023 + }
57024 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57025 off & 0x7fffffff, ino, DT_UNKNOWN)) {
57026 *offset = off & 0x7fffffff;
57027 return 0;
57028 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
57029 index c1c3ef8..0952438 100644
57030 --- a/fs/xfs/xfs_ioctl.c
57031 +++ b/fs/xfs/xfs_ioctl.c
57032 @@ -127,7 +127,7 @@ xfs_find_handle(
57033 }
57034
57035 error = -EFAULT;
57036 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
57037 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
57038 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
57039 goto out_put;
57040
57041 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
57042 index d82efaa..0904a8e 100644
57043 --- a/fs/xfs/xfs_iops.c
57044 +++ b/fs/xfs/xfs_iops.c
57045 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57046 struct nameidata *nd,
57047 void *p)
57048 {
57049 - char *s = nd_get_link(nd);
57050 + const char *s = nd_get_link(nd);
57051
57052 if (!IS_ERR(s))
57053 kfree(s);
57054 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57055 new file mode 100644
57056 index 0000000..92247e4
57057 --- /dev/null
57058 +++ b/grsecurity/Kconfig
57059 @@ -0,0 +1,1021 @@
57060 +#
57061 +# grecurity configuration
57062 +#
57063 +menu "Memory Protections"
57064 +depends on GRKERNSEC
57065 +
57066 +config GRKERNSEC_KMEM
57067 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57068 + default y if GRKERNSEC_CONFIG_AUTO
57069 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57070 + help
57071 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57072 + be written to or read from to modify or leak the contents of the running
57073 + kernel. /dev/port will also not be allowed to be opened and support
57074 + for /dev/cpu/*/msr will be removed. If you have module
57075 + support disabled, enabling this will close up five ways that are
57076 + currently used to insert malicious code into the running kernel.
57077 +
57078 + Even with all these features enabled, we still highly recommend that
57079 + you use the RBAC system, as it is still possible for an attacker to
57080 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57081 +
57082 + If you are not using XFree86, you may be able to stop this additional
57083 + case by enabling the 'Disable privileged I/O' option. Though nothing
57084 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57085 + but only to video memory, which is the only writing we allow in this
57086 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57087 + not be allowed to mprotect it with PROT_WRITE later.
57088 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57089 + from working.
57090 +
57091 + It is highly recommended that you say Y here if you meet all the
57092 + conditions above.
57093 +
57094 +config GRKERNSEC_VM86
57095 + bool "Restrict VM86 mode"
57096 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57097 + depends on X86_32
57098 +
57099 + help
57100 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57101 + make use of a special execution mode on 32bit x86 processors called
57102 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57103 + video cards and will still work with this option enabled. The purpose
57104 + of the option is to prevent exploitation of emulation errors in
57105 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57106 + Nearly all users should be able to enable this option.
57107 +
57108 +config GRKERNSEC_IO
57109 + bool "Disable privileged I/O"
57110 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57111 + depends on X86
57112 + select RTC_CLASS
57113 + select RTC_INTF_DEV
57114 + select RTC_DRV_CMOS
57115 +
57116 + help
57117 + If you say Y here, all ioperm and iopl calls will return an error.
57118 + Ioperm and iopl can be used to modify the running kernel.
57119 + Unfortunately, some programs need this access to operate properly,
57120 + the most notable of which are XFree86 and hwclock. hwclock can be
57121 + remedied by having RTC support in the kernel, so real-time
57122 + clock support is enabled if this option is enabled, to ensure
57123 + that hwclock operates correctly. XFree86 still will not
57124 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57125 + IF YOU USE XFree86. If you use XFree86 and you still want to
57126 + protect your kernel against modification, use the RBAC system.
57127 +
57128 +config GRKERNSEC_JIT_HARDEN
57129 + bool "Harden BPF JIT against spray attacks"
57130 + default y if GRKERNSEC_CONFIG_AUTO
57131 + depends on BPF_JIT
57132 + help
57133 + If you say Y here, the native code generated by the kernel's Berkeley
57134 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57135 + attacks that attempt to fit attacker-beneficial instructions in
57136 + 32bit immediate fields of JIT-generated native instructions. The
57137 + attacker will generally aim to cause an unintended instruction sequence
57138 + of JIT-generated native code to execute by jumping into the middle of
57139 + a generated instruction. This feature effectively randomizes the 32bit
57140 + immediate constants present in the generated code to thwart such attacks.
57141 +
57142 + If you're using KERNEXEC, it's recommended that you enable this option
57143 + to supplement the hardening of the kernel.
57144 +
57145 +config GRKERNSEC_RAND_THREADSTACK
57146 + bool "Insert random gaps between thread stacks"
57147 + default y if GRKERNSEC_CONFIG_AUTO
57148 + depends on PAX_RANDMMAP && !PPC
57149 + help
57150 + If you say Y here, a random-sized gap will be enforced between allocated
57151 + thread stacks. Glibc's NPTL and other threading libraries that
57152 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57153 + The implementation currently provides 8 bits of entropy for the gap.
57154 +
57155 + Many distributions do not compile threaded remote services with the
57156 + -fstack-check argument to GCC, causing the variable-sized stack-based
57157 + allocator, alloca(), to not probe the stack on allocation. This
57158 + permits an unbounded alloca() to skip over any guard page and potentially
57159 + modify another thread's stack reliably. An enforced random gap
57160 + reduces the reliability of such an attack and increases the chance
57161 + that such a read/write to another thread's stack instead lands in
57162 + an unmapped area, causing a crash and triggering grsecurity's
57163 + anti-bruteforcing logic.
57164 +
57165 +config GRKERNSEC_PROC_MEMMAP
57166 + bool "Harden ASLR against information leaks and entropy reduction"
57167 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57168 + depends on PAX_NOEXEC || PAX_ASLR
57169 + help
57170 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57171 + give no information about the addresses of its mappings if
57172 + PaX features that rely on random addresses are enabled on the task.
57173 + In addition to sanitizing this information and disabling other
57174 + dangerous sources of information, this option causes reads of sensitive
57175 + /proc/<pid> entries where the file descriptor was opened in a different
57176 + task than the one performing the read. Such attempts are logged.
57177 + This option also limits argv/env strings for suid/sgid binaries
57178 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57179 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57180 + binaries to prevent alternative mmap layouts from being abused.
57181 +
57182 + If you use PaX it is essential that you say Y here as it closes up
57183 + several holes that make full ASLR useless locally.
57184 +
57185 +config GRKERNSEC_BRUTE
57186 + bool "Deter exploit bruteforcing"
57187 + default y if GRKERNSEC_CONFIG_AUTO
57188 + help
57189 + If you say Y here, attempts to bruteforce exploits against forking
57190 + daemons such as apache or sshd, as well as against suid/sgid binaries
57191 + will be deterred. When a child of a forking daemon is killed by PaX
57192 + or crashes due to an illegal instruction or other suspicious signal,
57193 + the parent process will be delayed 30 seconds upon every subsequent
57194 + fork until the administrator is able to assess the situation and
57195 + restart the daemon.
57196 + In the suid/sgid case, the attempt is logged, the user has all their
57197 + processes terminated, and they are prevented from executing any further
57198 + processes for 15 minutes.
57199 + It is recommended that you also enable signal logging in the auditing
57200 + section so that logs are generated when a process triggers a suspicious
57201 + signal.
57202 + If the sysctl option is enabled, a sysctl option with name
57203 + "deter_bruteforce" is created.
57204 +
57205 +
57206 +config GRKERNSEC_MODHARDEN
57207 + bool "Harden module auto-loading"
57208 + default y if GRKERNSEC_CONFIG_AUTO
57209 + depends on MODULES
57210 + help
57211 + If you say Y here, module auto-loading in response to use of some
57212 + feature implemented by an unloaded module will be restricted to
57213 + root users. Enabling this option helps defend against attacks
57214 + by unprivileged users who abuse the auto-loading behavior to
57215 + cause a vulnerable module to load that is then exploited.
57216 +
57217 + If this option prevents a legitimate use of auto-loading for a
57218 + non-root user, the administrator can execute modprobe manually
57219 + with the exact name of the module mentioned in the alert log.
57220 + Alternatively, the administrator can add the module to the list
57221 + of modules loaded at boot by modifying init scripts.
57222 +
57223 + Modification of init scripts will most likely be needed on
57224 + Ubuntu servers with encrypted home directory support enabled,
57225 + as the first non-root user logging in will cause the ecb(aes),
57226 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57227 +
57228 +config GRKERNSEC_HIDESYM
57229 + bool "Hide kernel symbols"
57230 + default y if GRKERNSEC_CONFIG_AUTO
57231 + select PAX_USERCOPY_SLABS
57232 + help
57233 + If you say Y here, getting information on loaded modules, and
57234 + displaying all kernel symbols through a syscall will be restricted
57235 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57236 + /proc/kallsyms will be restricted to the root user. The RBAC
57237 + system can hide that entry even from root.
57238 +
57239 + This option also prevents leaking of kernel addresses through
57240 + several /proc entries.
57241 +
57242 + Note that this option is only effective provided the following
57243 + conditions are met:
57244 + 1) The kernel using grsecurity is not precompiled by some distribution
57245 + 2) You have also enabled GRKERNSEC_DMESG
57246 + 3) You are using the RBAC system and hiding other files such as your
57247 + kernel image and System.map. Alternatively, enabling this option
57248 + causes the permissions on /boot, /lib/modules, and the kernel
57249 + source directory to change at compile time to prevent
57250 + reading by non-root users.
57251 + If the above conditions are met, this option will aid in providing a
57252 + useful protection against local kernel exploitation of overflows
57253 + and arbitrary read/write vulnerabilities.
57254 +
57255 +config GRKERNSEC_KERN_LOCKOUT
57256 + bool "Active kernel exploit response"
57257 + default y if GRKERNSEC_CONFIG_AUTO
57258 + depends on X86 || ARM || PPC || SPARC
57259 + help
57260 + If you say Y here, when a PaX alert is triggered due to suspicious
57261 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57262 + or an OOPS occurs due to bad memory accesses, instead of just
57263 + terminating the offending process (and potentially allowing
57264 + a subsequent exploit from the same user), we will take one of two
57265 + actions:
57266 + If the user was root, we will panic the system
57267 + If the user was non-root, we will log the attempt, terminate
57268 + all processes owned by the user, then prevent them from creating
57269 + any new processes until the system is restarted
57270 + This deters repeated kernel exploitation/bruteforcing attempts
57271 + and is useful for later forensics.
57272 +
57273 +endmenu
57274 +menu "Role Based Access Control Options"
57275 +depends on GRKERNSEC
57276 +
57277 +config GRKERNSEC_RBAC_DEBUG
57278 + bool
57279 +
57280 +config GRKERNSEC_NO_RBAC
57281 + bool "Disable RBAC system"
57282 + help
57283 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57284 + preventing the RBAC system from being enabled. You should only say Y
57285 + here if you have no intention of using the RBAC system, so as to prevent
57286 + an attacker with root access from misusing the RBAC system to hide files
57287 + and processes when loadable module support and /dev/[k]mem have been
57288 + locked down.
57289 +
57290 +config GRKERNSEC_ACL_HIDEKERN
57291 + bool "Hide kernel processes"
57292 + help
57293 + If you say Y here, all kernel threads will be hidden to all
57294 + processes but those whose subject has the "view hidden processes"
57295 + flag.
57296 +
57297 +config GRKERNSEC_ACL_MAXTRIES
57298 + int "Maximum tries before password lockout"
57299 + default 3
57300 + help
57301 + This option enforces the maximum number of times a user can attempt
57302 + to authorize themselves with the grsecurity RBAC system before being
57303 + denied the ability to attempt authorization again for a specified time.
57304 + The lower the number, the harder it will be to brute-force a password.
57305 +
57306 +config GRKERNSEC_ACL_TIMEOUT
57307 + int "Time to wait after max password tries, in seconds"
57308 + default 30
57309 + help
57310 + This option specifies the time the user must wait after attempting to
57311 + authorize to the RBAC system with the maximum number of invalid
57312 + passwords. The higher the number, the harder it will be to brute-force
57313 + a password.
57314 +
57315 +endmenu
57316 +menu "Filesystem Protections"
57317 +depends on GRKERNSEC
57318 +
57319 +config GRKERNSEC_PROC
57320 + bool "Proc restrictions"
57321 + default y if GRKERNSEC_CONFIG_AUTO
57322 + help
57323 + If you say Y here, the permissions of the /proc filesystem
57324 + will be altered to enhance system security and privacy. You MUST
57325 + choose either a user only restriction or a user and group restriction.
57326 + Depending upon the option you choose, you can either restrict users to
57327 + see only the processes they themselves run, or choose a group that can
57328 + view all processes and files normally restricted to root if you choose
57329 + the "restrict to user only" option. NOTE: If you're running identd or
57330 + ntpd as a non-root user, you will have to run it as the group you
57331 + specify here.
57332 +
57333 +config GRKERNSEC_PROC_USER
57334 + bool "Restrict /proc to user only"
57335 + depends on GRKERNSEC_PROC
57336 + help
57337 + If you say Y here, non-root users will only be able to view their own
57338 + processes, and restricts them from viewing network-related information,
57339 + and viewing kernel symbol and module information.
57340 +
57341 +config GRKERNSEC_PROC_USERGROUP
57342 + bool "Allow special group"
57343 + default y if GRKERNSEC_CONFIG_AUTO
57344 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57345 + help
57346 + If you say Y here, you will be able to select a group that will be
57347 + able to view all processes and network-related information. If you've
57348 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57349 + remain hidden. This option is useful if you want to run identd as
57350 + a non-root user. The group you select may also be chosen at boot time
57351 + via "grsec_proc_gid=" on the kernel commandline.
57352 +
57353 +config GRKERNSEC_PROC_GID
57354 + int "GID for special group"
57355 + depends on GRKERNSEC_PROC_USERGROUP
57356 + default 1001
57357 +
57358 +config GRKERNSEC_PROC_ADD
57359 + bool "Additional restrictions"
57360 + default y if GRKERNSEC_CONFIG_AUTO
57361 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57362 + help
57363 + If you say Y here, additional restrictions will be placed on
57364 + /proc that keep normal users from viewing device information and
57365 + slabinfo information that could be useful for exploits.
57366 +
57367 +config GRKERNSEC_LINK
57368 + bool "Linking restrictions"
57369 + default y if GRKERNSEC_CONFIG_AUTO
57370 + help
57371 + If you say Y here, /tmp race exploits will be prevented, since users
57372 + will no longer be able to follow symlinks owned by other users in
57373 + world-writable +t directories (e.g. /tmp), unless the owner of the
57374 + symlink is the owner of the directory. users will also not be
57375 + able to hardlink to files they do not own. If the sysctl option is
57376 + enabled, a sysctl option with name "linking_restrictions" is created.
57377 +
57378 +config GRKERNSEC_SYMLINKOWN
57379 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57380 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57381 + help
57382 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57383 + that prevents it from being used as a security feature. As Apache
57384 + verifies the symlink by performing a stat() against the target of
57385 + the symlink before it is followed, an attacker can setup a symlink
57386 + to point to a same-owned file, then replace the symlink with one
57387 + that targets another user's file just after Apache "validates" the
57388 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57389 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57390 + will be in place for the group you specify. If the sysctl option
57391 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57392 + created.
57393 +
57394 +config GRKERNSEC_SYMLINKOWN_GID
57395 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57396 + depends on GRKERNSEC_SYMLINKOWN
57397 + default 1006
57398 + help
57399 + Setting this GID determines what group kernel-enforced
57400 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57401 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57402 +
57403 +config GRKERNSEC_FIFO
57404 + bool "FIFO restrictions"
57405 + default y if GRKERNSEC_CONFIG_AUTO
57406 + help
57407 + If you say Y here, users will not be able to write to FIFOs they don't
57408 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57409 + the FIFO is the same owner of the directory it's held in. If the sysctl
57410 + option is enabled, a sysctl option with name "fifo_restrictions" is
57411 + created.
57412 +
57413 +config GRKERNSEC_SYSFS_RESTRICT
57414 + bool "Sysfs/debugfs restriction"
57415 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57416 + depends on SYSFS
57417 + help
57418 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57419 + any filesystem normally mounted under it (e.g. debugfs) will be
57420 + mostly accessible only by root. These filesystems generally provide access
57421 + to hardware and debug information that isn't appropriate for unprivileged
57422 + users of the system. Sysfs and debugfs have also become a large source
57423 + of new vulnerabilities, ranging from infoleaks to local compromise.
57424 + There has been very little oversight with an eye toward security involved
57425 + in adding new exporters of information to these filesystems, so their
57426 + use is discouraged.
57427 + For reasons of compatibility, a few directories have been whitelisted
57428 + for access by non-root users:
57429 + /sys/fs/selinux
57430 + /sys/fs/fuse
57431 + /sys/devices/system/cpu
57432 +
57433 +config GRKERNSEC_ROFS
57434 + bool "Runtime read-only mount protection"
57435 + help
57436 + If you say Y here, a sysctl option with name "romount_protect" will
57437 + be created. By setting this option to 1 at runtime, filesystems
57438 + will be protected in the following ways:
57439 + * No new writable mounts will be allowed
57440 + * Existing read-only mounts won't be able to be remounted read/write
57441 + * Write operations will be denied on all block devices
57442 + This option acts independently of grsec_lock: once it is set to 1,
57443 + it cannot be turned off. Therefore, please be mindful of the resulting
57444 + behavior if this option is enabled in an init script on a read-only
57445 + filesystem. This feature is mainly intended for secure embedded systems.
57446 +
57447 +config GRKERNSEC_DEVICE_SIDECHANNEL
57448 + bool "Eliminate stat/notify-based device sidechannels"
57449 + default y if GRKERNSEC_CONFIG_AUTO
57450 + help
57451 + If you say Y here, timing analyses on block or character
57452 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57453 + will be thwarted for unprivileged users. If a process without
57454 + CAP_MKNOD stats such a device, the last access and last modify times
57455 + will match the device's create time. No access or modify events
57456 + will be triggered through inotify/dnotify/fanotify for such devices.
57457 + This feature will prevent attacks that may at a minimum
57458 + allow an attacker to determine the administrator's password length.
57459 +
57460 +config GRKERNSEC_CHROOT
57461 + bool "Chroot jail restrictions"
57462 + default y if GRKERNSEC_CONFIG_AUTO
57463 + help
57464 + If you say Y here, you will be able to choose several options that will
57465 + make breaking out of a chrooted jail much more difficult. If you
57466 + encounter no software incompatibilities with the following options, it
57467 + is recommended that you enable each one.
57468 +
57469 +config GRKERNSEC_CHROOT_MOUNT
57470 + bool "Deny mounts"
57471 + default y if GRKERNSEC_CONFIG_AUTO
57472 + depends on GRKERNSEC_CHROOT
57473 + help
57474 + If you say Y here, processes inside a chroot will not be able to
57475 + mount or remount filesystems. If the sysctl option is enabled, a
57476 + sysctl option with name "chroot_deny_mount" is created.
57477 +
57478 +config GRKERNSEC_CHROOT_DOUBLE
57479 + bool "Deny double-chroots"
57480 + default y if GRKERNSEC_CONFIG_AUTO
57481 + depends on GRKERNSEC_CHROOT
57482 + help
57483 + If you say Y here, processes inside a chroot will not be able to chroot
57484 + again outside the chroot. This is a widely used method of breaking
57485 + out of a chroot jail and should not be allowed. If the sysctl
57486 + option is enabled, a sysctl option with name
57487 + "chroot_deny_chroot" is created.
57488 +
57489 +config GRKERNSEC_CHROOT_PIVOT
57490 + bool "Deny pivot_root in chroot"
57491 + default y if GRKERNSEC_CONFIG_AUTO
57492 + depends on GRKERNSEC_CHROOT
57493 + help
57494 + If you say Y here, processes inside a chroot will not be able to use
57495 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57496 + works similar to chroot in that it changes the root filesystem. This
57497 + function could be misused in a chrooted process to attempt to break out
57498 + of the chroot, and therefore should not be allowed. If the sysctl
57499 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57500 + created.
57501 +
57502 +config GRKERNSEC_CHROOT_CHDIR
57503 + bool "Enforce chdir(\"/\") on all chroots"
57504 + default y if GRKERNSEC_CONFIG_AUTO
57505 + depends on GRKERNSEC_CHROOT
57506 + help
57507 + If you say Y here, the current working directory of all newly-chrooted
57508 + applications will be set to the the root directory of the chroot.
57509 + The man page on chroot(2) states:
57510 + Note that this call does not change the current working
57511 + directory, so that `.' can be outside the tree rooted at
57512 + `/'. In particular, the super-user can escape from a
57513 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57514 +
57515 + It is recommended that you say Y here, since it's not known to break
57516 + any software. If the sysctl option is enabled, a sysctl option with
57517 + name "chroot_enforce_chdir" is created.
57518 +
57519 +config GRKERNSEC_CHROOT_CHMOD
57520 + bool "Deny (f)chmod +s"
57521 + default y if GRKERNSEC_CONFIG_AUTO
57522 + depends on GRKERNSEC_CHROOT
57523 + help
57524 + If you say Y here, processes inside a chroot will not be able to chmod
57525 + or fchmod files to make them have suid or sgid bits. This protects
57526 + against another published method of breaking a chroot. If the sysctl
57527 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57528 + created.
57529 +
57530 +config GRKERNSEC_CHROOT_FCHDIR
57531 + bool "Deny fchdir out of chroot"
57532 + default y if GRKERNSEC_CONFIG_AUTO
57533 + depends on GRKERNSEC_CHROOT
57534 + help
57535 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57536 + to a file descriptor of the chrooting process that points to a directory
57537 + outside the filesystem will be stopped. If the sysctl option
57538 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57539 +
57540 +config GRKERNSEC_CHROOT_MKNOD
57541 + bool "Deny mknod"
57542 + default y if GRKERNSEC_CONFIG_AUTO
57543 + depends on GRKERNSEC_CHROOT
57544 + help
57545 + If you say Y here, processes inside a chroot will not be allowed to
57546 + mknod. The problem with using mknod inside a chroot is that it
57547 + would allow an attacker to create a device entry that is the same
57548 + as one on the physical root of your system, which could range from
57549 + anything from the console device to a device for your harddrive (which
57550 + they could then use to wipe the drive or steal data). It is recommended
57551 + that you say Y here, unless you run into software incompatibilities.
57552 + If the sysctl option is enabled, a sysctl option with name
57553 + "chroot_deny_mknod" is created.
57554 +
57555 +config GRKERNSEC_CHROOT_SHMAT
57556 + bool "Deny shmat() out of chroot"
57557 + default y if GRKERNSEC_CONFIG_AUTO
57558 + depends on GRKERNSEC_CHROOT
57559 + help
57560 + If you say Y here, processes inside a chroot will not be able to attach
57561 + to shared memory segments that were created outside of the chroot jail.
57562 + It is recommended that you say Y here. If the sysctl option is enabled,
57563 + a sysctl option with name "chroot_deny_shmat" is created.
57564 +
57565 +config GRKERNSEC_CHROOT_UNIX
57566 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57567 + default y if GRKERNSEC_CONFIG_AUTO
57568 + depends on GRKERNSEC_CHROOT
57569 + help
57570 + If you say Y here, processes inside a chroot will not be able to
57571 + connect to abstract (meaning not belonging to a filesystem) Unix
57572 + domain sockets that were bound outside of a chroot. It is recommended
57573 + that you say Y here. If the sysctl option is enabled, a sysctl option
57574 + with name "chroot_deny_unix" is created.
57575 +
57576 +config GRKERNSEC_CHROOT_FINDTASK
57577 + bool "Protect outside processes"
57578 + default y if GRKERNSEC_CONFIG_AUTO
57579 + depends on GRKERNSEC_CHROOT
57580 + help
57581 + If you say Y here, processes inside a chroot will not be able to
57582 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57583 + getsid, or view any process outside of the chroot. If the sysctl
57584 + option is enabled, a sysctl option with name "chroot_findtask" is
57585 + created.
57586 +
57587 +config GRKERNSEC_CHROOT_NICE
57588 + bool "Restrict priority changes"
57589 + default y if GRKERNSEC_CONFIG_AUTO
57590 + depends on GRKERNSEC_CHROOT
57591 + help
57592 + If you say Y here, processes inside a chroot will not be able to raise
57593 + the priority of processes in the chroot, or alter the priority of
57594 + processes outside the chroot. This provides more security than simply
57595 + removing CAP_SYS_NICE from the process' capability set. If the
57596 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57597 + is created.
57598 +
57599 +config GRKERNSEC_CHROOT_SYSCTL
57600 + bool "Deny sysctl writes"
57601 + default y if GRKERNSEC_CONFIG_AUTO
57602 + depends on GRKERNSEC_CHROOT
57603 + help
57604 + If you say Y here, an attacker in a chroot will not be able to
57605 + write to sysctl entries, either by sysctl(2) or through a /proc
57606 + interface. It is strongly recommended that you say Y here. If the
57607 + sysctl option is enabled, a sysctl option with name
57608 + "chroot_deny_sysctl" is created.
57609 +
57610 +config GRKERNSEC_CHROOT_CAPS
57611 + bool "Capability restrictions"
57612 + default y if GRKERNSEC_CONFIG_AUTO
57613 + depends on GRKERNSEC_CHROOT
57614 + help
57615 + If you say Y here, the capabilities on all processes within a
57616 + chroot jail will be lowered to stop module insertion, raw i/o,
57617 + system and net admin tasks, rebooting the system, modifying immutable
57618 + files, modifying IPC owned by another, and changing the system time.
57619 + This is left an option because it can break some apps. Disable this
57620 + if your chrooted apps are having problems performing those kinds of
57621 + tasks. If the sysctl option is enabled, a sysctl option with
57622 + name "chroot_caps" is created.
57623 +
57624 +endmenu
57625 +menu "Kernel Auditing"
57626 +depends on GRKERNSEC
57627 +
57628 +config GRKERNSEC_AUDIT_GROUP
57629 + bool "Single group for auditing"
57630 + help
57631 + If you say Y here, the exec and chdir logging features will only operate
57632 + on a group you specify. This option is recommended if you only want to
57633 + watch certain users instead of having a large amount of logs from the
57634 + entire system. If the sysctl option is enabled, a sysctl option with
57635 + name "audit_group" is created.
57636 +
57637 +config GRKERNSEC_AUDIT_GID
57638 + int "GID for auditing"
57639 + depends on GRKERNSEC_AUDIT_GROUP
57640 + default 1007
57641 +
57642 +config GRKERNSEC_EXECLOG
57643 + bool "Exec logging"
57644 + help
57645 + If you say Y here, all execve() calls will be logged (since the
57646 + other exec*() calls are frontends to execve(), all execution
57647 + will be logged). Useful for shell-servers that like to keep track
57648 + of their users. If the sysctl option is enabled, a sysctl option with
57649 + name "exec_logging" is created.
57650 + WARNING: This option when enabled will produce a LOT of logs, especially
57651 + on an active system.
57652 +
57653 +config GRKERNSEC_RESLOG
57654 + bool "Resource logging"
57655 + default y if GRKERNSEC_CONFIG_AUTO
57656 + help
57657 + If you say Y here, all attempts to overstep resource limits will
57658 + be logged with the resource name, the requested size, and the current
57659 + limit. It is highly recommended that you say Y here. If the sysctl
57660 + option is enabled, a sysctl option with name "resource_logging" is
57661 + created. If the RBAC system is enabled, the sysctl value is ignored.
57662 +
57663 +config GRKERNSEC_CHROOT_EXECLOG
57664 + bool "Log execs within chroot"
57665 + help
57666 + If you say Y here, all executions inside a chroot jail will be logged
57667 + to syslog. This can cause a large amount of logs if certain
57668 + applications (eg. djb's daemontools) are installed on the system, and
57669 + is therefore left as an option. If the sysctl option is enabled, a
57670 + sysctl option with name "chroot_execlog" is created.
57671 +
57672 +config GRKERNSEC_AUDIT_PTRACE
57673 + bool "Ptrace logging"
57674 + help
57675 + If you say Y here, all attempts to attach to a process via ptrace
57676 + will be logged. If the sysctl option is enabled, a sysctl option
57677 + with name "audit_ptrace" is created.
57678 +
57679 +config GRKERNSEC_AUDIT_CHDIR
57680 + bool "Chdir logging"
57681 + help
57682 + If you say Y here, all chdir() calls will be logged. If the sysctl
57683 + option is enabled, a sysctl option with name "audit_chdir" is created.
57684 +
57685 +config GRKERNSEC_AUDIT_MOUNT
57686 + bool "(Un)Mount logging"
57687 + help
57688 + If you say Y here, all mounts and unmounts will be logged. If the
57689 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57690 + created.
57691 +
57692 +config GRKERNSEC_SIGNAL
57693 + bool "Signal logging"
57694 + default y if GRKERNSEC_CONFIG_AUTO
57695 + help
57696 + If you say Y here, certain important signals will be logged, such as
57697 + SIGSEGV, which will as a result inform you of when a error in a program
57698 + occurred, which in some cases could mean a possible exploit attempt.
57699 + If the sysctl option is enabled, a sysctl option with name
57700 + "signal_logging" is created.
57701 +
57702 +config GRKERNSEC_FORKFAIL
57703 + bool "Fork failure logging"
57704 + help
57705 + If you say Y here, all failed fork() attempts will be logged.
57706 + This could suggest a fork bomb, or someone attempting to overstep
57707 + their process limit. If the sysctl option is enabled, a sysctl option
57708 + with name "forkfail_logging" is created.
57709 +
57710 +config GRKERNSEC_TIME
57711 + bool "Time change logging"
57712 + default y if GRKERNSEC_CONFIG_AUTO
57713 + help
57714 + If you say Y here, any changes of the system clock will be logged.
57715 + If the sysctl option is enabled, a sysctl option with name
57716 + "timechange_logging" is created.
57717 +
57718 +config GRKERNSEC_PROC_IPADDR
57719 + bool "/proc/<pid>/ipaddr support"
57720 + default y if GRKERNSEC_CONFIG_AUTO
57721 + help
57722 + If you say Y here, a new entry will be added to each /proc/<pid>
57723 + directory that contains the IP address of the person using the task.
57724 + The IP is carried across local TCP and AF_UNIX stream sockets.
57725 + This information can be useful for IDS/IPSes to perform remote response
57726 + to a local attack. The entry is readable by only the owner of the
57727 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57728 + the RBAC system), and thus does not create privacy concerns.
57729 +
57730 +config GRKERNSEC_RWXMAP_LOG
57731 + bool 'Denied RWX mmap/mprotect logging'
57732 + default y if GRKERNSEC_CONFIG_AUTO
57733 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57734 + help
57735 + If you say Y here, calls to mmap() and mprotect() with explicit
57736 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57737 + denied by the PAX_MPROTECT feature. If the sysctl option is
57738 + enabled, a sysctl option with name "rwxmap_logging" is created.
57739 +
57740 +config GRKERNSEC_AUDIT_TEXTREL
57741 + bool 'ELF text relocations logging (READ HELP)'
57742 + depends on PAX_MPROTECT
57743 + help
57744 + If you say Y here, text relocations will be logged with the filename
57745 + of the offending library or binary. The purpose of the feature is
57746 + to help Linux distribution developers get rid of libraries and
57747 + binaries that need text relocations which hinder the future progress
57748 + of PaX. Only Linux distribution developers should say Y here, and
57749 + never on a production machine, as this option creates an information
57750 + leak that could aid an attacker in defeating the randomization of
57751 + a single memory region. If the sysctl option is enabled, a sysctl
57752 + option with name "audit_textrel" is created.
57753 +
57754 +endmenu
57755 +
57756 +menu "Executable Protections"
57757 +depends on GRKERNSEC
57758 +
57759 +config GRKERNSEC_DMESG
57760 + bool "Dmesg(8) restriction"
57761 + default y if GRKERNSEC_CONFIG_AUTO
57762 + help
57763 + If you say Y here, non-root users will not be able to use dmesg(8)
57764 + to view the contents of the kernel's circular log buffer.
57765 + The kernel's log buffer often contains kernel addresses and other
57766 + identifying information useful to an attacker in fingerprinting a
57767 + system for a targeted exploit.
57768 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57769 + created.
57770 +
57771 +config GRKERNSEC_HARDEN_PTRACE
57772 + bool "Deter ptrace-based process snooping"
57773 + default y if GRKERNSEC_CONFIG_AUTO
57774 + help
57775 + If you say Y here, TTY sniffers and other malicious monitoring
57776 + programs implemented through ptrace will be defeated. If you
57777 + have been using the RBAC system, this option has already been
57778 + enabled for several years for all users, with the ability to make
57779 + fine-grained exceptions.
57780 +
57781 + This option only affects the ability of non-root users to ptrace
57782 + processes that are not a descendent of the ptracing process.
57783 + This means that strace ./binary and gdb ./binary will still work,
57784 + but attaching to arbitrary processes will not. If the sysctl
57785 + option is enabled, a sysctl option with name "harden_ptrace" is
57786 + created.
57787 +
57788 +config GRKERNSEC_PTRACE_READEXEC
57789 + bool "Require read access to ptrace sensitive binaries"
57790 + default y if GRKERNSEC_CONFIG_AUTO
57791 + help
57792 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57793 + binaries. This option is useful in environments that
57794 + remove the read bits (e.g. file mode 4711) from suid binaries to
57795 + prevent infoleaking of their contents. This option adds
57796 + consistency to the use of that file mode, as the binary could normally
57797 + be read out when run without privileges while ptracing.
57798 +
57799 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57800 + is created.
57801 +
57802 +config GRKERNSEC_SETXID
57803 + bool "Enforce consistent multithreaded privileges"
57804 + default y if GRKERNSEC_CONFIG_AUTO
57805 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57806 + help
57807 + If you say Y here, a change from a root uid to a non-root uid
57808 + in a multithreaded application will cause the resulting uids,
57809 + gids, supplementary groups, and capabilities in that thread
57810 + to be propagated to the other threads of the process. In most
57811 + cases this is unnecessary, as glibc will emulate this behavior
57812 + on behalf of the application. Other libcs do not act in the
57813 + same way, allowing the other threads of the process to continue
57814 + running with root privileges. If the sysctl option is enabled,
57815 + a sysctl option with name "consistent_setxid" is created.
57816 +
57817 +config GRKERNSEC_TPE
57818 + bool "Trusted Path Execution (TPE)"
57819 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57820 + help
57821 + If you say Y here, you will be able to choose a gid to add to the
57822 + supplementary groups of users you want to mark as "untrusted."
57823 + These users will not be able to execute any files that are not in
57824 + root-owned directories writable only by root. If the sysctl option
57825 + is enabled, a sysctl option with name "tpe" is created.
57826 +
57827 +config GRKERNSEC_TPE_ALL
57828 + bool "Partially restrict all non-root users"
57829 + depends on GRKERNSEC_TPE
57830 + help
57831 + If you say Y here, all non-root users will be covered under
57832 + a weaker TPE restriction. This is separate from, and in addition to,
57833 + the main TPE options that you have selected elsewhere. Thus, if a
57834 + "trusted" GID is chosen, this restriction applies to even that GID.
57835 + Under this restriction, all non-root users will only be allowed to
57836 + execute files in directories they own that are not group or
57837 + world-writable, or in directories owned by root and writable only by
57838 + root. If the sysctl option is enabled, a sysctl option with name
57839 + "tpe_restrict_all" is created.
57840 +
57841 +config GRKERNSEC_TPE_INVERT
57842 + bool "Invert GID option"
57843 + depends on GRKERNSEC_TPE
57844 + help
57845 + If you say Y here, the group you specify in the TPE configuration will
57846 + decide what group TPE restrictions will be *disabled* for. This
57847 + option is useful if you want TPE restrictions to be applied to most
57848 + users on the system. If the sysctl option is enabled, a sysctl option
57849 + with name "tpe_invert" is created. Unlike other sysctl options, this
57850 + entry will default to on for backward-compatibility.
57851 +
57852 +config GRKERNSEC_TPE_GID
57853 + int
57854 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57855 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57856 +
57857 +config GRKERNSEC_TPE_UNTRUSTED_GID
57858 + int "GID for TPE-untrusted users"
57859 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57860 + default 1005
57861 + help
57862 + Setting this GID determines what group TPE restrictions will be
57863 + *enabled* for. If the sysctl option is enabled, a sysctl option
57864 + with name "tpe_gid" is created.
57865 +
57866 +config GRKERNSEC_TPE_TRUSTED_GID
57867 + int "GID for TPE-trusted users"
57868 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57869 + default 1005
57870 + help
57871 + Setting this GID determines what group TPE restrictions will be
57872 + *disabled* for. If the sysctl option is enabled, a sysctl option
57873 + with name "tpe_gid" is created.
57874 +
57875 +endmenu
57876 +menu "Network Protections"
57877 +depends on GRKERNSEC
57878 +
57879 +config GRKERNSEC_RANDNET
57880 + bool "Larger entropy pools"
57881 + default y if GRKERNSEC_CONFIG_AUTO
57882 + help
57883 + If you say Y here, the entropy pools used for many features of Linux
57884 + and grsecurity will be doubled in size. Since several grsecurity
57885 + features use additional randomness, it is recommended that you say Y
57886 + here. Saying Y here has a similar effect as modifying
57887 + /proc/sys/kernel/random/poolsize.
57888 +
57889 +config GRKERNSEC_BLACKHOLE
57890 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57891 + default y if GRKERNSEC_CONFIG_AUTO
57892 + depends on NET
57893 + help
57894 + If you say Y here, neither TCP resets nor ICMP
57895 + destination-unreachable packets will be sent in response to packets
57896 + sent to ports for which no associated listening process exists.
57897 + This feature supports both IPV4 and IPV6 and exempts the
57898 + loopback interface from blackholing. Enabling this feature
57899 + makes a host more resilient to DoS attacks and reduces network
57900 + visibility against scanners.
57901 +
57902 + The blackhole feature as-implemented is equivalent to the FreeBSD
57903 + blackhole feature, as it prevents RST responses to all packets, not
57904 + just SYNs. Under most application behavior this causes no
57905 + problems, but applications (like haproxy) may not close certain
57906 + connections in a way that cleanly terminates them on the remote
57907 + end, leaving the remote host in LAST_ACK state. Because of this
57908 + side-effect and to prevent intentional LAST_ACK DoSes, this
57909 + feature also adds automatic mitigation against such attacks.
57910 + The mitigation drastically reduces the amount of time a socket
57911 + can spend in LAST_ACK state. If you're using haproxy and not
57912 + all servers it connects to have this option enabled, consider
57913 + disabling this feature on the haproxy host.
57914 +
57915 + If the sysctl option is enabled, two sysctl options with names
57916 + "ip_blackhole" and "lastack_retries" will be created.
57917 + While "ip_blackhole" takes the standard zero/non-zero on/off
57918 + toggle, "lastack_retries" uses the same kinds of values as
57919 + "tcp_retries1" and "tcp_retries2". The default value of 4
57920 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57921 + state.
57922 +
57923 +config GRKERNSEC_NO_SIMULT_CONNECT
57924 + bool "Disable TCP Simultaneous Connect"
57925 + default y if GRKERNSEC_CONFIG_AUTO
57926 + depends on NET
57927 + help
57928 + If you say Y here, a feature by Willy Tarreau will be enabled that
57929 + removes a weakness in Linux's strict implementation of TCP that
57930 + allows two clients to connect to each other without either entering
57931 + a listening state. The weakness allows an attacker to easily prevent
57932 + a client from connecting to a known server provided the source port
57933 + for the connection is guessed correctly.
57934 +
57935 + As the weakness could be used to prevent an antivirus or IPS from
57936 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57937 + it should be eliminated by enabling this option. Though Linux is
57938 + one of few operating systems supporting simultaneous connect, it
57939 + has no legitimate use in practice and is rarely supported by firewalls.
57940 +
57941 +config GRKERNSEC_SOCKET
57942 + bool "Socket restrictions"
57943 + depends on NET
57944 + help
57945 + If you say Y here, you will be able to choose from several options.
57946 + If you assign a GID on your system and add it to the supplementary
57947 + groups of users you want to restrict socket access to, this patch
57948 + will perform up to three things, based on the option(s) you choose.
57949 +
57950 +config GRKERNSEC_SOCKET_ALL
57951 + bool "Deny any sockets to group"
57952 + depends on GRKERNSEC_SOCKET
57953 + help
57954 + If you say Y here, you will be able to choose a GID of whose users will
57955 + be unable to connect to other hosts from your machine or run server
57956 + applications from your machine. If the sysctl option is enabled, a
57957 + sysctl option with name "socket_all" is created.
57958 +
57959 +config GRKERNSEC_SOCKET_ALL_GID
57960 + int "GID to deny all sockets for"
57961 + depends on GRKERNSEC_SOCKET_ALL
57962 + default 1004
57963 + help
57964 + Here you can choose the GID to disable socket access for. Remember to
57965 + add the users you want socket access disabled for to the GID
57966 + specified here. If the sysctl option is enabled, a sysctl option
57967 + with name "socket_all_gid" is created.
57968 +
57969 +config GRKERNSEC_SOCKET_CLIENT
57970 + bool "Deny client sockets to group"
57971 + depends on GRKERNSEC_SOCKET
57972 + help
57973 + If you say Y here, you will be able to choose a GID of whose users will
57974 + be unable to connect to other hosts from your machine, but will be
57975 + able to run servers. If this option is enabled, all users in the group
57976 + you specify will have to use passive mode when initiating ftp transfers
57977 + from the shell on your machine. If the sysctl option is enabled, a
57978 + sysctl option with name "socket_client" is created.
57979 +
57980 +config GRKERNSEC_SOCKET_CLIENT_GID
57981 + int "GID to deny client sockets for"
57982 + depends on GRKERNSEC_SOCKET_CLIENT
57983 + default 1003
57984 + help
57985 + Here you can choose the GID to disable client socket access for.
57986 + Remember to add the users you want client socket access disabled for to
57987 + the GID specified here. If the sysctl option is enabled, a sysctl
57988 + option with name "socket_client_gid" is created.
57989 +
57990 +config GRKERNSEC_SOCKET_SERVER
57991 + bool "Deny server sockets to group"
57992 + depends on GRKERNSEC_SOCKET
57993 + help
57994 + If you say Y here, you will be able to choose a GID of whose users will
57995 + be unable to run server applications from your machine. If the sysctl
57996 + option is enabled, a sysctl option with name "socket_server" is created.
57997 +
57998 +config GRKERNSEC_SOCKET_SERVER_GID
57999 + int "GID to deny server sockets for"
58000 + depends on GRKERNSEC_SOCKET_SERVER
58001 + default 1002
58002 + help
58003 + Here you can choose the GID to disable server socket access for.
58004 + Remember to add the users you want server socket access disabled for to
58005 + the GID specified here. If the sysctl option is enabled, a sysctl
58006 + option with name "socket_server_gid" is created.
58007 +
58008 +endmenu
58009 +menu "Sysctl Support"
58010 +depends on GRKERNSEC && SYSCTL
58011 +
58012 +config GRKERNSEC_SYSCTL
58013 + bool "Sysctl support"
58014 + default y if GRKERNSEC_CONFIG_AUTO
58015 + help
58016 + If you say Y here, you will be able to change the options that
58017 + grsecurity runs with at bootup, without having to recompile your
58018 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
58019 + to enable (1) or disable (0) various features. All the sysctl entries
58020 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58021 + All features enabled in the kernel configuration are disabled at boot
58022 + if you do not say Y to the "Turn on features by default" option.
58023 + All options should be set at startup, and the grsec_lock entry should
58024 + be set to a non-zero value after all the options are set.
58025 + *THIS IS EXTREMELY IMPORTANT*
58026 +
58027 +config GRKERNSEC_SYSCTL_DISTRO
58028 + bool "Extra sysctl support for distro makers (READ HELP)"
58029 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58030 + help
58031 + If you say Y here, additional sysctl options will be created
58032 + for features that affect processes running as root. Therefore,
58033 + it is critical when using this option that the grsec_lock entry be
58034 + enabled after boot. Only distros with prebuilt kernel packages
58035 + with this option enabled that can ensure grsec_lock is enabled
58036 + after boot should use this option.
58037 + *Failure to set grsec_lock after boot makes all grsec features
58038 + this option covers useless*
58039 +
58040 + Currently this option creates the following sysctl entries:
58041 + "Disable Privileged I/O": "disable_priv_io"
58042 +
58043 +config GRKERNSEC_SYSCTL_ON
58044 + bool "Turn on features by default"
58045 + default y if GRKERNSEC_CONFIG_AUTO
58046 + depends on GRKERNSEC_SYSCTL
58047 + help
58048 + If you say Y here, instead of having all features enabled in the
58049 + kernel configuration disabled at boot time, the features will be
58050 + enabled at boot time. It is recommended you say Y here unless
58051 + there is some reason you would want all sysctl-tunable features to
58052 + be disabled by default. As mentioned elsewhere, it is important
58053 + to enable the grsec_lock entry once you have finished modifying
58054 + the sysctl entries.
58055 +
58056 +endmenu
58057 +menu "Logging Options"
58058 +depends on GRKERNSEC
58059 +
58060 +config GRKERNSEC_FLOODTIME
58061 + int "Seconds in between log messages (minimum)"
58062 + default 10
58063 + help
58064 + This option allows you to enforce the number of seconds between
58065 + grsecurity log messages. The default should be suitable for most
58066 + people, however, if you choose to change it, choose a value small enough
58067 + to allow informative logs to be produced, but large enough to
58068 + prevent flooding.
58069 +
58070 +config GRKERNSEC_FLOODBURST
58071 + int "Number of messages in a burst (maximum)"
58072 + default 6
58073 + help
58074 + This option allows you to choose the maximum number of messages allowed
58075 + within the flood time interval you chose in a separate option. The
58076 + default should be suitable for most people, however if you find that
58077 + many of your logs are being interpreted as flooding, you may want to
58078 + raise this value.
58079 +
58080 +endmenu
58081 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58082 new file mode 100644
58083 index 0000000..1b9afa9
58084 --- /dev/null
58085 +++ b/grsecurity/Makefile
58086 @@ -0,0 +1,38 @@
58087 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58088 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58089 +# into an RBAC system
58090 +#
58091 +# All code in this directory and various hooks inserted throughout the kernel
58092 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58093 +# under the GPL v2 or higher
58094 +
58095 +KBUILD_CFLAGS += -Werror
58096 +
58097 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58098 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58099 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58100 +
58101 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58102 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58103 + gracl_learn.o grsec_log.o
58104 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58105 +
58106 +ifdef CONFIG_NET
58107 +obj-y += grsec_sock.o
58108 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58109 +endif
58110 +
58111 +ifndef CONFIG_GRKERNSEC
58112 +obj-y += grsec_disabled.o
58113 +endif
58114 +
58115 +ifdef CONFIG_GRKERNSEC_HIDESYM
58116 +extra-y := grsec_hidesym.o
58117 +$(obj)/grsec_hidesym.o:
58118 + @-chmod -f 500 /boot
58119 + @-chmod -f 500 /lib/modules
58120 + @-chmod -f 500 /lib64/modules
58121 + @-chmod -f 500 /lib32/modules
58122 + @-chmod -f 700 .
58123 + @echo ' grsec: protected kernel image paths'
58124 +endif
58125 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58126 new file mode 100644
58127 index 0000000..b306b36
58128 --- /dev/null
58129 +++ b/grsecurity/gracl.c
58130 @@ -0,0 +1,4071 @@
58131 +#include <linux/kernel.h>
58132 +#include <linux/module.h>
58133 +#include <linux/sched.h>
58134 +#include <linux/mm.h>
58135 +#include <linux/file.h>
58136 +#include <linux/fs.h>
58137 +#include <linux/namei.h>
58138 +#include <linux/mount.h>
58139 +#include <linux/tty.h>
58140 +#include <linux/proc_fs.h>
58141 +#include <linux/lglock.h>
58142 +#include <linux/slab.h>
58143 +#include <linux/vmalloc.h>
58144 +#include <linux/types.h>
58145 +#include <linux/sysctl.h>
58146 +#include <linux/netdevice.h>
58147 +#include <linux/ptrace.h>
58148 +#include <linux/gracl.h>
58149 +#include <linux/gralloc.h>
58150 +#include <linux/security.h>
58151 +#include <linux/grinternal.h>
58152 +#include <linux/pid_namespace.h>
58153 +#include <linux/stop_machine.h>
58154 +#include <linux/fdtable.h>
58155 +#include <linux/percpu.h>
58156 +#include <linux/lglock.h>
58157 +#include <linux/hugetlb.h>
58158 +#include <linux/posix-timers.h>
58159 +#include "../fs/mount.h"
58160 +
58161 +#include <asm/uaccess.h>
58162 +#include <asm/errno.h>
58163 +#include <asm/mman.h>
58164 +
58165 +extern struct lglock vfsmount_lock;
58166 +
58167 +static struct acl_role_db acl_role_set;
58168 +static struct name_db name_set;
58169 +static struct inodev_db inodev_set;
58170 +
58171 +/* for keeping track of userspace pointers used for subjects, so we
58172 + can share references in the kernel as well
58173 +*/
58174 +
58175 +static struct path real_root;
58176 +
58177 +static struct acl_subj_map_db subj_map_set;
58178 +
58179 +static struct acl_role_label *default_role;
58180 +
58181 +static struct acl_role_label *role_list;
58182 +
58183 +static u16 acl_sp_role_value;
58184 +
58185 +extern char *gr_shared_page[4];
58186 +static DEFINE_MUTEX(gr_dev_mutex);
58187 +DEFINE_RWLOCK(gr_inode_lock);
58188 +
58189 +struct gr_arg *gr_usermode;
58190 +
58191 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58192 +
58193 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58194 +extern void gr_clear_learn_entries(void);
58195 +
58196 +unsigned char *gr_system_salt;
58197 +unsigned char *gr_system_sum;
58198 +
58199 +static struct sprole_pw **acl_special_roles = NULL;
58200 +static __u16 num_sprole_pws = 0;
58201 +
58202 +static struct acl_role_label *kernel_role = NULL;
58203 +
58204 +static unsigned int gr_auth_attempts = 0;
58205 +static unsigned long gr_auth_expires = 0UL;
58206 +
58207 +#ifdef CONFIG_NET
58208 +extern struct vfsmount *sock_mnt;
58209 +#endif
58210 +
58211 +extern struct vfsmount *pipe_mnt;
58212 +extern struct vfsmount *shm_mnt;
58213 +
58214 +#ifdef CONFIG_HUGETLBFS
58215 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58216 +#endif
58217 +
58218 +static struct acl_object_label *fakefs_obj_rw;
58219 +static struct acl_object_label *fakefs_obj_rwx;
58220 +
58221 +extern int gr_init_uidset(void);
58222 +extern void gr_free_uidset(void);
58223 +extern void gr_remove_uid(uid_t uid);
58224 +extern int gr_find_uid(uid_t uid);
58225 +
58226 +__inline__ int
58227 +gr_acl_is_enabled(void)
58228 +{
58229 + return (gr_status & GR_READY);
58230 +}
58231 +
58232 +#ifdef CONFIG_BTRFS_FS
58233 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
58234 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
58235 +#endif
58236 +
58237 +static inline dev_t __get_dev(const struct dentry *dentry)
58238 +{
58239 +#ifdef CONFIG_BTRFS_FS
58240 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
58241 + return get_btrfs_dev_from_inode(dentry->d_inode);
58242 + else
58243 +#endif
58244 + return dentry->d_inode->i_sb->s_dev;
58245 +}
58246 +
58247 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58248 +{
58249 + return __get_dev(dentry);
58250 +}
58251 +
58252 +static char gr_task_roletype_to_char(struct task_struct *task)
58253 +{
58254 + switch (task->role->roletype &
58255 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58256 + GR_ROLE_SPECIAL)) {
58257 + case GR_ROLE_DEFAULT:
58258 + return 'D';
58259 + case GR_ROLE_USER:
58260 + return 'U';
58261 + case GR_ROLE_GROUP:
58262 + return 'G';
58263 + case GR_ROLE_SPECIAL:
58264 + return 'S';
58265 + }
58266 +
58267 + return 'X';
58268 +}
58269 +
58270 +char gr_roletype_to_char(void)
58271 +{
58272 + return gr_task_roletype_to_char(current);
58273 +}
58274 +
58275 +__inline__ int
58276 +gr_acl_tpe_check(void)
58277 +{
58278 + if (unlikely(!(gr_status & GR_READY)))
58279 + return 0;
58280 + if (current->role->roletype & GR_ROLE_TPE)
58281 + return 1;
58282 + else
58283 + return 0;
58284 +}
58285 +
58286 +int
58287 +gr_handle_rawio(const struct inode *inode)
58288 +{
58289 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58290 + if (inode && S_ISBLK(inode->i_mode) &&
58291 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58292 + !capable(CAP_SYS_RAWIO))
58293 + return 1;
58294 +#endif
58295 + return 0;
58296 +}
58297 +
58298 +static int
58299 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58300 +{
58301 + if (likely(lena != lenb))
58302 + return 0;
58303 +
58304 + return !memcmp(a, b, lena);
58305 +}
58306 +
58307 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58308 +{
58309 + *buflen -= namelen;
58310 + if (*buflen < 0)
58311 + return -ENAMETOOLONG;
58312 + *buffer -= namelen;
58313 + memcpy(*buffer, str, namelen);
58314 + return 0;
58315 +}
58316 +
58317 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58318 +{
58319 + return prepend(buffer, buflen, name->name, name->len);
58320 +}
58321 +
58322 +static int prepend_path(const struct path *path, struct path *root,
58323 + char **buffer, int *buflen)
58324 +{
58325 + struct dentry *dentry = path->dentry;
58326 + struct vfsmount *vfsmnt = path->mnt;
58327 + struct mount *mnt = real_mount(vfsmnt);
58328 + bool slash = false;
58329 + int error = 0;
58330 +
58331 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58332 + struct dentry * parent;
58333 +
58334 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58335 + /* Global root? */
58336 + if (!mnt_has_parent(mnt)) {
58337 + goto out;
58338 + }
58339 + dentry = mnt->mnt_mountpoint;
58340 + mnt = mnt->mnt_parent;
58341 + vfsmnt = &mnt->mnt;
58342 + continue;
58343 + }
58344 + parent = dentry->d_parent;
58345 + prefetch(parent);
58346 + spin_lock(&dentry->d_lock);
58347 + error = prepend_name(buffer, buflen, &dentry->d_name);
58348 + spin_unlock(&dentry->d_lock);
58349 + if (!error)
58350 + error = prepend(buffer, buflen, "/", 1);
58351 + if (error)
58352 + break;
58353 +
58354 + slash = true;
58355 + dentry = parent;
58356 + }
58357 +
58358 +out:
58359 + if (!error && !slash)
58360 + error = prepend(buffer, buflen, "/", 1);
58361 +
58362 + return error;
58363 +}
58364 +
58365 +/* this must be called with vfsmount_lock and rename_lock held */
58366 +
58367 +static char *__our_d_path(const struct path *path, struct path *root,
58368 + char *buf, int buflen)
58369 +{
58370 + char *res = buf + buflen;
58371 + int error;
58372 +
58373 + prepend(&res, &buflen, "\0", 1);
58374 + error = prepend_path(path, root, &res, &buflen);
58375 + if (error)
58376 + return ERR_PTR(error);
58377 +
58378 + return res;
58379 +}
58380 +
58381 +static char *
58382 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58383 +{
58384 + char *retval;
58385 +
58386 + retval = __our_d_path(path, root, buf, buflen);
58387 + if (unlikely(IS_ERR(retval)))
58388 + retval = strcpy(buf, "<path too long>");
58389 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58390 + retval[1] = '\0';
58391 +
58392 + return retval;
58393 +}
58394 +
58395 +static char *
58396 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58397 + char *buf, int buflen)
58398 +{
58399 + struct path path;
58400 + char *res;
58401 +
58402 + path.dentry = (struct dentry *)dentry;
58403 + path.mnt = (struct vfsmount *)vfsmnt;
58404 +
58405 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58406 + by the RBAC system */
58407 + res = gen_full_path(&path, &real_root, buf, buflen);
58408 +
58409 + return res;
58410 +}
58411 +
58412 +static char *
58413 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58414 + char *buf, int buflen)
58415 +{
58416 + char *res;
58417 + struct path path;
58418 + struct path root;
58419 + struct task_struct *reaper = init_pid_ns.child_reaper;
58420 +
58421 + path.dentry = (struct dentry *)dentry;
58422 + path.mnt = (struct vfsmount *)vfsmnt;
58423 +
58424 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58425 + get_fs_root(reaper->fs, &root);
58426 +
58427 + br_read_lock(&vfsmount_lock);
58428 + write_seqlock(&rename_lock);
58429 + res = gen_full_path(&path, &root, buf, buflen);
58430 + write_sequnlock(&rename_lock);
58431 + br_read_unlock(&vfsmount_lock);
58432 +
58433 + path_put(&root);
58434 + return res;
58435 +}
58436 +
58437 +static char *
58438 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58439 +{
58440 + char *ret;
58441 + br_read_lock(&vfsmount_lock);
58442 + write_seqlock(&rename_lock);
58443 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58444 + PAGE_SIZE);
58445 + write_sequnlock(&rename_lock);
58446 + br_read_unlock(&vfsmount_lock);
58447 + return ret;
58448 +}
58449 +
58450 +static char *
58451 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58452 +{
58453 + char *ret;
58454 + char *buf;
58455 + int buflen;
58456 +
58457 + br_read_lock(&vfsmount_lock);
58458 + write_seqlock(&rename_lock);
58459 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58460 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58461 + buflen = (int)(ret - buf);
58462 + if (buflen >= 5)
58463 + prepend(&ret, &buflen, "/proc", 5);
58464 + else
58465 + ret = strcpy(buf, "<path too long>");
58466 + write_sequnlock(&rename_lock);
58467 + br_read_unlock(&vfsmount_lock);
58468 + return ret;
58469 +}
58470 +
58471 +char *
58472 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58473 +{
58474 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58475 + PAGE_SIZE);
58476 +}
58477 +
58478 +char *
58479 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58480 +{
58481 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58482 + PAGE_SIZE);
58483 +}
58484 +
58485 +char *
58486 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58487 +{
58488 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58489 + PAGE_SIZE);
58490 +}
58491 +
58492 +char *
58493 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58494 +{
58495 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58496 + PAGE_SIZE);
58497 +}
58498 +
58499 +char *
58500 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58501 +{
58502 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58503 + PAGE_SIZE);
58504 +}
58505 +
58506 +__inline__ __u32
58507 +to_gr_audit(const __u32 reqmode)
58508 +{
58509 + /* masks off auditable permission flags, then shifts them to create
58510 + auditing flags, and adds the special case of append auditing if
58511 + we're requesting write */
58512 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58513 +}
58514 +
58515 +struct acl_subject_label *
58516 +lookup_subject_map(const struct acl_subject_label *userp)
58517 +{
58518 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58519 + struct subject_map *match;
58520 +
58521 + match = subj_map_set.s_hash[index];
58522 +
58523 + while (match && match->user != userp)
58524 + match = match->next;
58525 +
58526 + if (match != NULL)
58527 + return match->kernel;
58528 + else
58529 + return NULL;
58530 +}
58531 +
58532 +static void
58533 +insert_subj_map_entry(struct subject_map *subjmap)
58534 +{
58535 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58536 + struct subject_map **curr;
58537 +
58538 + subjmap->prev = NULL;
58539 +
58540 + curr = &subj_map_set.s_hash[index];
58541 + if (*curr != NULL)
58542 + (*curr)->prev = subjmap;
58543 +
58544 + subjmap->next = *curr;
58545 + *curr = subjmap;
58546 +
58547 + return;
58548 +}
58549 +
58550 +static struct acl_role_label *
58551 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58552 + const gid_t gid)
58553 +{
58554 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58555 + struct acl_role_label *match;
58556 + struct role_allowed_ip *ipp;
58557 + unsigned int x;
58558 + u32 curr_ip = task->signal->curr_ip;
58559 +
58560 + task->signal->saved_ip = curr_ip;
58561 +
58562 + match = acl_role_set.r_hash[index];
58563 +
58564 + while (match) {
58565 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58566 + for (x = 0; x < match->domain_child_num; x++) {
58567 + if (match->domain_children[x] == uid)
58568 + goto found;
58569 + }
58570 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58571 + break;
58572 + match = match->next;
58573 + }
58574 +found:
58575 + if (match == NULL) {
58576 + try_group:
58577 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58578 + match = acl_role_set.r_hash[index];
58579 +
58580 + while (match) {
58581 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58582 + for (x = 0; x < match->domain_child_num; x++) {
58583 + if (match->domain_children[x] == gid)
58584 + goto found2;
58585 + }
58586 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58587 + break;
58588 + match = match->next;
58589 + }
58590 +found2:
58591 + if (match == NULL)
58592 + match = default_role;
58593 + if (match->allowed_ips == NULL)
58594 + return match;
58595 + else {
58596 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58597 + if (likely
58598 + ((ntohl(curr_ip) & ipp->netmask) ==
58599 + (ntohl(ipp->addr) & ipp->netmask)))
58600 + return match;
58601 + }
58602 + match = default_role;
58603 + }
58604 + } else if (match->allowed_ips == NULL) {
58605 + return match;
58606 + } else {
58607 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58608 + if (likely
58609 + ((ntohl(curr_ip) & ipp->netmask) ==
58610 + (ntohl(ipp->addr) & ipp->netmask)))
58611 + return match;
58612 + }
58613 + goto try_group;
58614 + }
58615 +
58616 + return match;
58617 +}
58618 +
58619 +struct acl_subject_label *
58620 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58621 + const struct acl_role_label *role)
58622 +{
58623 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58624 + struct acl_subject_label *match;
58625 +
58626 + match = role->subj_hash[index];
58627 +
58628 + while (match && (match->inode != ino || match->device != dev ||
58629 + (match->mode & GR_DELETED))) {
58630 + match = match->next;
58631 + }
58632 +
58633 + if (match && !(match->mode & GR_DELETED))
58634 + return match;
58635 + else
58636 + return NULL;
58637 +}
58638 +
58639 +struct acl_subject_label *
58640 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58641 + const struct acl_role_label *role)
58642 +{
58643 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58644 + struct acl_subject_label *match;
58645 +
58646 + match = role->subj_hash[index];
58647 +
58648 + while (match && (match->inode != ino || match->device != dev ||
58649 + !(match->mode & GR_DELETED))) {
58650 + match = match->next;
58651 + }
58652 +
58653 + if (match && (match->mode & GR_DELETED))
58654 + return match;
58655 + else
58656 + return NULL;
58657 +}
58658 +
58659 +static struct acl_object_label *
58660 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58661 + const struct acl_subject_label *subj)
58662 +{
58663 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58664 + struct acl_object_label *match;
58665 +
58666 + match = subj->obj_hash[index];
58667 +
58668 + while (match && (match->inode != ino || match->device != dev ||
58669 + (match->mode & GR_DELETED))) {
58670 + match = match->next;
58671 + }
58672 +
58673 + if (match && !(match->mode & GR_DELETED))
58674 + return match;
58675 + else
58676 + return NULL;
58677 +}
58678 +
58679 +static struct acl_object_label *
58680 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58681 + const struct acl_subject_label *subj)
58682 +{
58683 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58684 + struct acl_object_label *match;
58685 +
58686 + match = subj->obj_hash[index];
58687 +
58688 + while (match && (match->inode != ino || match->device != dev ||
58689 + !(match->mode & GR_DELETED))) {
58690 + match = match->next;
58691 + }
58692 +
58693 + if (match && (match->mode & GR_DELETED))
58694 + return match;
58695 +
58696 + match = subj->obj_hash[index];
58697 +
58698 + while (match && (match->inode != ino || match->device != dev ||
58699 + (match->mode & GR_DELETED))) {
58700 + match = match->next;
58701 + }
58702 +
58703 + if (match && !(match->mode & GR_DELETED))
58704 + return match;
58705 + else
58706 + return NULL;
58707 +}
58708 +
58709 +static struct name_entry *
58710 +lookup_name_entry(const char *name)
58711 +{
58712 + unsigned int len = strlen(name);
58713 + unsigned int key = full_name_hash(name, len);
58714 + unsigned int index = key % name_set.n_size;
58715 + struct name_entry *match;
58716 +
58717 + match = name_set.n_hash[index];
58718 +
58719 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58720 + match = match->next;
58721 +
58722 + return match;
58723 +}
58724 +
58725 +static struct name_entry *
58726 +lookup_name_entry_create(const char *name)
58727 +{
58728 + unsigned int len = strlen(name);
58729 + unsigned int key = full_name_hash(name, len);
58730 + unsigned int index = key % name_set.n_size;
58731 + struct name_entry *match;
58732 +
58733 + match = name_set.n_hash[index];
58734 +
58735 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58736 + !match->deleted))
58737 + match = match->next;
58738 +
58739 + if (match && match->deleted)
58740 + return match;
58741 +
58742 + match = name_set.n_hash[index];
58743 +
58744 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58745 + match->deleted))
58746 + match = match->next;
58747 +
58748 + if (match && !match->deleted)
58749 + return match;
58750 + else
58751 + return NULL;
58752 +}
58753 +
58754 +static struct inodev_entry *
58755 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58756 +{
58757 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58758 + struct inodev_entry *match;
58759 +
58760 + match = inodev_set.i_hash[index];
58761 +
58762 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58763 + match = match->next;
58764 +
58765 + return match;
58766 +}
58767 +
58768 +static void
58769 +insert_inodev_entry(struct inodev_entry *entry)
58770 +{
58771 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58772 + inodev_set.i_size);
58773 + struct inodev_entry **curr;
58774 +
58775 + entry->prev = NULL;
58776 +
58777 + curr = &inodev_set.i_hash[index];
58778 + if (*curr != NULL)
58779 + (*curr)->prev = entry;
58780 +
58781 + entry->next = *curr;
58782 + *curr = entry;
58783 +
58784 + return;
58785 +}
58786 +
58787 +static void
58788 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58789 +{
58790 + unsigned int index =
58791 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58792 + struct acl_role_label **curr;
58793 + struct acl_role_label *tmp, *tmp2;
58794 +
58795 + curr = &acl_role_set.r_hash[index];
58796 +
58797 + /* simple case, slot is empty, just set it to our role */
58798 + if (*curr == NULL) {
58799 + *curr = role;
58800 + } else {
58801 + /* example:
58802 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58803 + 2 -> 3
58804 + */
58805 + /* first check to see if we can already be reached via this slot */
58806 + tmp = *curr;
58807 + while (tmp && tmp != role)
58808 + tmp = tmp->next;
58809 + if (tmp == role) {
58810 + /* we don't need to add ourselves to this slot's chain */
58811 + return;
58812 + }
58813 + /* we need to add ourselves to this chain, two cases */
58814 + if (role->next == NULL) {
58815 + /* simple case, append the current chain to our role */
58816 + role->next = *curr;
58817 + *curr = role;
58818 + } else {
58819 + /* 1 -> 2 -> 3 -> 4
58820 + 2 -> 3 -> 4
58821 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58822 + */
58823 + /* trickier case: walk our role's chain until we find
58824 + the role for the start of the current slot's chain */
58825 + tmp = role;
58826 + tmp2 = *curr;
58827 + while (tmp->next && tmp->next != tmp2)
58828 + tmp = tmp->next;
58829 + if (tmp->next == tmp2) {
58830 + /* from example above, we found 3, so just
58831 + replace this slot's chain with ours */
58832 + *curr = role;
58833 + } else {
58834 + /* we didn't find a subset of our role's chain
58835 + in the current slot's chain, so append their
58836 + chain to ours, and set us as the first role in
58837 + the slot's chain
58838 +
58839 + we could fold this case with the case above,
58840 + but making it explicit for clarity
58841 + */
58842 + tmp->next = tmp2;
58843 + *curr = role;
58844 + }
58845 + }
58846 + }
58847 +
58848 + return;
58849 +}
58850 +
58851 +static void
58852 +insert_acl_role_label(struct acl_role_label *role)
58853 +{
58854 + int i;
58855 +
58856 + if (role_list == NULL) {
58857 + role_list = role;
58858 + role->prev = NULL;
58859 + } else {
58860 + role->prev = role_list;
58861 + role_list = role;
58862 + }
58863 +
58864 + /* used for hash chains */
58865 + role->next = NULL;
58866 +
58867 + if (role->roletype & GR_ROLE_DOMAIN) {
58868 + for (i = 0; i < role->domain_child_num; i++)
58869 + __insert_acl_role_label(role, role->domain_children[i]);
58870 + } else
58871 + __insert_acl_role_label(role, role->uidgid);
58872 +}
58873 +
58874 +static int
58875 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58876 +{
58877 + struct name_entry **curr, *nentry;
58878 + struct inodev_entry *ientry;
58879 + unsigned int len = strlen(name);
58880 + unsigned int key = full_name_hash(name, len);
58881 + unsigned int index = key % name_set.n_size;
58882 +
58883 + curr = &name_set.n_hash[index];
58884 +
58885 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58886 + curr = &((*curr)->next);
58887 +
58888 + if (*curr != NULL)
58889 + return 1;
58890 +
58891 + nentry = acl_alloc(sizeof (struct name_entry));
58892 + if (nentry == NULL)
58893 + return 0;
58894 + ientry = acl_alloc(sizeof (struct inodev_entry));
58895 + if (ientry == NULL)
58896 + return 0;
58897 + ientry->nentry = nentry;
58898 +
58899 + nentry->key = key;
58900 + nentry->name = name;
58901 + nentry->inode = inode;
58902 + nentry->device = device;
58903 + nentry->len = len;
58904 + nentry->deleted = deleted;
58905 +
58906 + nentry->prev = NULL;
58907 + curr = &name_set.n_hash[index];
58908 + if (*curr != NULL)
58909 + (*curr)->prev = nentry;
58910 + nentry->next = *curr;
58911 + *curr = nentry;
58912 +
58913 + /* insert us into the table searchable by inode/dev */
58914 + insert_inodev_entry(ientry);
58915 +
58916 + return 1;
58917 +}
58918 +
58919 +static void
58920 +insert_acl_obj_label(struct acl_object_label *obj,
58921 + struct acl_subject_label *subj)
58922 +{
58923 + unsigned int index =
58924 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58925 + struct acl_object_label **curr;
58926 +
58927 +
58928 + obj->prev = NULL;
58929 +
58930 + curr = &subj->obj_hash[index];
58931 + if (*curr != NULL)
58932 + (*curr)->prev = obj;
58933 +
58934 + obj->next = *curr;
58935 + *curr = obj;
58936 +
58937 + return;
58938 +}
58939 +
58940 +static void
58941 +insert_acl_subj_label(struct acl_subject_label *obj,
58942 + struct acl_role_label *role)
58943 +{
58944 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58945 + struct acl_subject_label **curr;
58946 +
58947 + obj->prev = NULL;
58948 +
58949 + curr = &role->subj_hash[index];
58950 + if (*curr != NULL)
58951 + (*curr)->prev = obj;
58952 +
58953 + obj->next = *curr;
58954 + *curr = obj;
58955 +
58956 + return;
58957 +}
58958 +
58959 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58960 +
58961 +static void *
58962 +create_table(__u32 * len, int elementsize)
58963 +{
58964 + unsigned int table_sizes[] = {
58965 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58966 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58967 + 4194301, 8388593, 16777213, 33554393, 67108859
58968 + };
58969 + void *newtable = NULL;
58970 + unsigned int pwr = 0;
58971 +
58972 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58973 + table_sizes[pwr] <= *len)
58974 + pwr++;
58975 +
58976 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58977 + return newtable;
58978 +
58979 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58980 + newtable =
58981 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58982 + else
58983 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58984 +
58985 + *len = table_sizes[pwr];
58986 +
58987 + return newtable;
58988 +}
58989 +
58990 +static int
58991 +init_variables(const struct gr_arg *arg)
58992 +{
58993 + struct task_struct *reaper = init_pid_ns.child_reaper;
58994 + unsigned int stacksize;
58995 +
58996 + subj_map_set.s_size = arg->role_db.num_subjects;
58997 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58998 + name_set.n_size = arg->role_db.num_objects;
58999 + inodev_set.i_size = arg->role_db.num_objects;
59000 +
59001 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
59002 + !name_set.n_size || !inodev_set.i_size)
59003 + return 1;
59004 +
59005 + if (!gr_init_uidset())
59006 + return 1;
59007 +
59008 + /* set up the stack that holds allocation info */
59009 +
59010 + stacksize = arg->role_db.num_pointers + 5;
59011 +
59012 + if (!acl_alloc_stack_init(stacksize))
59013 + return 1;
59014 +
59015 + /* grab reference for the real root dentry and vfsmount */
59016 + get_fs_root(reaper->fs, &real_root);
59017 +
59018 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59019 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59020 +#endif
59021 +
59022 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59023 + if (fakefs_obj_rw == NULL)
59024 + return 1;
59025 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59026 +
59027 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59028 + if (fakefs_obj_rwx == NULL)
59029 + return 1;
59030 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59031 +
59032 + subj_map_set.s_hash =
59033 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59034 + acl_role_set.r_hash =
59035 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59036 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59037 + inodev_set.i_hash =
59038 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59039 +
59040 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59041 + !name_set.n_hash || !inodev_set.i_hash)
59042 + return 1;
59043 +
59044 + memset(subj_map_set.s_hash, 0,
59045 + sizeof(struct subject_map *) * subj_map_set.s_size);
59046 + memset(acl_role_set.r_hash, 0,
59047 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59048 + memset(name_set.n_hash, 0,
59049 + sizeof (struct name_entry *) * name_set.n_size);
59050 + memset(inodev_set.i_hash, 0,
59051 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59052 +
59053 + return 0;
59054 +}
59055 +
59056 +/* free information not needed after startup
59057 + currently contains user->kernel pointer mappings for subjects
59058 +*/
59059 +
59060 +static void
59061 +free_init_variables(void)
59062 +{
59063 + __u32 i;
59064 +
59065 + if (subj_map_set.s_hash) {
59066 + for (i = 0; i < subj_map_set.s_size; i++) {
59067 + if (subj_map_set.s_hash[i]) {
59068 + kfree(subj_map_set.s_hash[i]);
59069 + subj_map_set.s_hash[i] = NULL;
59070 + }
59071 + }
59072 +
59073 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59074 + PAGE_SIZE)
59075 + kfree(subj_map_set.s_hash);
59076 + else
59077 + vfree(subj_map_set.s_hash);
59078 + }
59079 +
59080 + return;
59081 +}
59082 +
59083 +static void
59084 +free_variables(void)
59085 +{
59086 + struct acl_subject_label *s;
59087 + struct acl_role_label *r;
59088 + struct task_struct *task, *task2;
59089 + unsigned int x;
59090 +
59091 + gr_clear_learn_entries();
59092 +
59093 + read_lock(&tasklist_lock);
59094 + do_each_thread(task2, task) {
59095 + task->acl_sp_role = 0;
59096 + task->acl_role_id = 0;
59097 + task->acl = NULL;
59098 + task->role = NULL;
59099 + } while_each_thread(task2, task);
59100 + read_unlock(&tasklist_lock);
59101 +
59102 + /* release the reference to the real root dentry and vfsmount */
59103 + path_put(&real_root);
59104 + memset(&real_root, 0, sizeof(real_root));
59105 +
59106 + /* free all object hash tables */
59107 +
59108 + FOR_EACH_ROLE_START(r)
59109 + if (r->subj_hash == NULL)
59110 + goto next_role;
59111 + FOR_EACH_SUBJECT_START(r, s, x)
59112 + if (s->obj_hash == NULL)
59113 + break;
59114 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59115 + kfree(s->obj_hash);
59116 + else
59117 + vfree(s->obj_hash);
59118 + FOR_EACH_SUBJECT_END(s, x)
59119 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59120 + if (s->obj_hash == NULL)
59121 + break;
59122 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59123 + kfree(s->obj_hash);
59124 + else
59125 + vfree(s->obj_hash);
59126 + FOR_EACH_NESTED_SUBJECT_END(s)
59127 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59128 + kfree(r->subj_hash);
59129 + else
59130 + vfree(r->subj_hash);
59131 + r->subj_hash = NULL;
59132 +next_role:
59133 + FOR_EACH_ROLE_END(r)
59134 +
59135 + acl_free_all();
59136 +
59137 + if (acl_role_set.r_hash) {
59138 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59139 + PAGE_SIZE)
59140 + kfree(acl_role_set.r_hash);
59141 + else
59142 + vfree(acl_role_set.r_hash);
59143 + }
59144 + if (name_set.n_hash) {
59145 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59146 + PAGE_SIZE)
59147 + kfree(name_set.n_hash);
59148 + else
59149 + vfree(name_set.n_hash);
59150 + }
59151 +
59152 + if (inodev_set.i_hash) {
59153 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59154 + PAGE_SIZE)
59155 + kfree(inodev_set.i_hash);
59156 + else
59157 + vfree(inodev_set.i_hash);
59158 + }
59159 +
59160 + gr_free_uidset();
59161 +
59162 + memset(&name_set, 0, sizeof (struct name_db));
59163 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59164 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59165 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59166 +
59167 + default_role = NULL;
59168 + kernel_role = NULL;
59169 + role_list = NULL;
59170 +
59171 + return;
59172 +}
59173 +
59174 +static __u32
59175 +count_user_objs(struct acl_object_label *userp)
59176 +{
59177 + struct acl_object_label o_tmp;
59178 + __u32 num = 0;
59179 +
59180 + while (userp) {
59181 + if (copy_from_user(&o_tmp, userp,
59182 + sizeof (struct acl_object_label)))
59183 + break;
59184 +
59185 + userp = o_tmp.prev;
59186 + num++;
59187 + }
59188 +
59189 + return num;
59190 +}
59191 +
59192 +static struct acl_subject_label *
59193 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59194 +
59195 +static int
59196 +copy_user_glob(struct acl_object_label *obj)
59197 +{
59198 + struct acl_object_label *g_tmp, **guser;
59199 + unsigned int len;
59200 + char *tmp;
59201 +
59202 + if (obj->globbed == NULL)
59203 + return 0;
59204 +
59205 + guser = &obj->globbed;
59206 + while (*guser) {
59207 + g_tmp = (struct acl_object_label *)
59208 + acl_alloc(sizeof (struct acl_object_label));
59209 + if (g_tmp == NULL)
59210 + return -ENOMEM;
59211 +
59212 + if (copy_from_user(g_tmp, *guser,
59213 + sizeof (struct acl_object_label)))
59214 + return -EFAULT;
59215 +
59216 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59217 +
59218 + if (!len || len >= PATH_MAX)
59219 + return -EINVAL;
59220 +
59221 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59222 + return -ENOMEM;
59223 +
59224 + if (copy_from_user(tmp, g_tmp->filename, len))
59225 + return -EFAULT;
59226 + tmp[len-1] = '\0';
59227 + g_tmp->filename = tmp;
59228 +
59229 + *guser = g_tmp;
59230 + guser = &(g_tmp->next);
59231 + }
59232 +
59233 + return 0;
59234 +}
59235 +
59236 +static int
59237 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59238 + struct acl_role_label *role)
59239 +{
59240 + struct acl_object_label *o_tmp;
59241 + unsigned int len;
59242 + int ret;
59243 + char *tmp;
59244 +
59245 + while (userp) {
59246 + if ((o_tmp = (struct acl_object_label *)
59247 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59248 + return -ENOMEM;
59249 +
59250 + if (copy_from_user(o_tmp, userp,
59251 + sizeof (struct acl_object_label)))
59252 + return -EFAULT;
59253 +
59254 + userp = o_tmp->prev;
59255 +
59256 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59257 +
59258 + if (!len || len >= PATH_MAX)
59259 + return -EINVAL;
59260 +
59261 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59262 + return -ENOMEM;
59263 +
59264 + if (copy_from_user(tmp, o_tmp->filename, len))
59265 + return -EFAULT;
59266 + tmp[len-1] = '\0';
59267 + o_tmp->filename = tmp;
59268 +
59269 + insert_acl_obj_label(o_tmp, subj);
59270 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59271 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59272 + return -ENOMEM;
59273 +
59274 + ret = copy_user_glob(o_tmp);
59275 + if (ret)
59276 + return ret;
59277 +
59278 + if (o_tmp->nested) {
59279 + int already_copied;
59280 +
59281 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59282 + if (IS_ERR(o_tmp->nested))
59283 + return PTR_ERR(o_tmp->nested);
59284 +
59285 + /* insert into nested subject list if we haven't copied this one yet
59286 + to prevent duplicate entries */
59287 + if (!already_copied) {
59288 + o_tmp->nested->next = role->hash->first;
59289 + role->hash->first = o_tmp->nested;
59290 + }
59291 + }
59292 + }
59293 +
59294 + return 0;
59295 +}
59296 +
59297 +static __u32
59298 +count_user_subjs(struct acl_subject_label *userp)
59299 +{
59300 + struct acl_subject_label s_tmp;
59301 + __u32 num = 0;
59302 +
59303 + while (userp) {
59304 + if (copy_from_user(&s_tmp, userp,
59305 + sizeof (struct acl_subject_label)))
59306 + break;
59307 +
59308 + userp = s_tmp.prev;
59309 + }
59310 +
59311 + return num;
59312 +}
59313 +
59314 +static int
59315 +copy_user_allowedips(struct acl_role_label *rolep)
59316 +{
59317 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59318 +
59319 + ruserip = rolep->allowed_ips;
59320 +
59321 + while (ruserip) {
59322 + rlast = rtmp;
59323 +
59324 + if ((rtmp = (struct role_allowed_ip *)
59325 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59326 + return -ENOMEM;
59327 +
59328 + if (copy_from_user(rtmp, ruserip,
59329 + sizeof (struct role_allowed_ip)))
59330 + return -EFAULT;
59331 +
59332 + ruserip = rtmp->prev;
59333 +
59334 + if (!rlast) {
59335 + rtmp->prev = NULL;
59336 + rolep->allowed_ips = rtmp;
59337 + } else {
59338 + rlast->next = rtmp;
59339 + rtmp->prev = rlast;
59340 + }
59341 +
59342 + if (!ruserip)
59343 + rtmp->next = NULL;
59344 + }
59345 +
59346 + return 0;
59347 +}
59348 +
59349 +static int
59350 +copy_user_transitions(struct acl_role_label *rolep)
59351 +{
59352 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59353 +
59354 + unsigned int len;
59355 + char *tmp;
59356 +
59357 + rusertp = rolep->transitions;
59358 +
59359 + while (rusertp) {
59360 + rlast = rtmp;
59361 +
59362 + if ((rtmp = (struct role_transition *)
59363 + acl_alloc(sizeof (struct role_transition))) == NULL)
59364 + return -ENOMEM;
59365 +
59366 + if (copy_from_user(rtmp, rusertp,
59367 + sizeof (struct role_transition)))
59368 + return -EFAULT;
59369 +
59370 + rusertp = rtmp->prev;
59371 +
59372 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59373 +
59374 + if (!len || len >= GR_SPROLE_LEN)
59375 + return -EINVAL;
59376 +
59377 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59378 + return -ENOMEM;
59379 +
59380 + if (copy_from_user(tmp, rtmp->rolename, len))
59381 + return -EFAULT;
59382 + tmp[len-1] = '\0';
59383 + rtmp->rolename = tmp;
59384 +
59385 + if (!rlast) {
59386 + rtmp->prev = NULL;
59387 + rolep->transitions = rtmp;
59388 + } else {
59389 + rlast->next = rtmp;
59390 + rtmp->prev = rlast;
59391 + }
59392 +
59393 + if (!rusertp)
59394 + rtmp->next = NULL;
59395 + }
59396 +
59397 + return 0;
59398 +}
59399 +
59400 +static struct acl_subject_label *
59401 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59402 +{
59403 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59404 + unsigned int len;
59405 + char *tmp;
59406 + __u32 num_objs;
59407 + struct acl_ip_label **i_tmp, *i_utmp2;
59408 + struct gr_hash_struct ghash;
59409 + struct subject_map *subjmap;
59410 + unsigned int i_num;
59411 + int err;
59412 +
59413 + if (already_copied != NULL)
59414 + *already_copied = 0;
59415 +
59416 + s_tmp = lookup_subject_map(userp);
59417 +
59418 + /* we've already copied this subject into the kernel, just return
59419 + the reference to it, and don't copy it over again
59420 + */
59421 + if (s_tmp) {
59422 + if (already_copied != NULL)
59423 + *already_copied = 1;
59424 + return(s_tmp);
59425 + }
59426 +
59427 + if ((s_tmp = (struct acl_subject_label *)
59428 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59429 + return ERR_PTR(-ENOMEM);
59430 +
59431 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59432 + if (subjmap == NULL)
59433 + return ERR_PTR(-ENOMEM);
59434 +
59435 + subjmap->user = userp;
59436 + subjmap->kernel = s_tmp;
59437 + insert_subj_map_entry(subjmap);
59438 +
59439 + if (copy_from_user(s_tmp, userp,
59440 + sizeof (struct acl_subject_label)))
59441 + return ERR_PTR(-EFAULT);
59442 +
59443 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59444 +
59445 + if (!len || len >= PATH_MAX)
59446 + return ERR_PTR(-EINVAL);
59447 +
59448 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59449 + return ERR_PTR(-ENOMEM);
59450 +
59451 + if (copy_from_user(tmp, s_tmp->filename, len))
59452 + return ERR_PTR(-EFAULT);
59453 + tmp[len-1] = '\0';
59454 + s_tmp->filename = tmp;
59455 +
59456 + if (!strcmp(s_tmp->filename, "/"))
59457 + role->root_label = s_tmp;
59458 +
59459 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59460 + return ERR_PTR(-EFAULT);
59461 +
59462 + /* copy user and group transition tables */
59463 +
59464 + if (s_tmp->user_trans_num) {
59465 + uid_t *uidlist;
59466 +
59467 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59468 + if (uidlist == NULL)
59469 + return ERR_PTR(-ENOMEM);
59470 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59471 + return ERR_PTR(-EFAULT);
59472 +
59473 + s_tmp->user_transitions = uidlist;
59474 + }
59475 +
59476 + if (s_tmp->group_trans_num) {
59477 + gid_t *gidlist;
59478 +
59479 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59480 + if (gidlist == NULL)
59481 + return ERR_PTR(-ENOMEM);
59482 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59483 + return ERR_PTR(-EFAULT);
59484 +
59485 + s_tmp->group_transitions = gidlist;
59486 + }
59487 +
59488 + /* set up object hash table */
59489 + num_objs = count_user_objs(ghash.first);
59490 +
59491 + s_tmp->obj_hash_size = num_objs;
59492 + s_tmp->obj_hash =
59493 + (struct acl_object_label **)
59494 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59495 +
59496 + if (!s_tmp->obj_hash)
59497 + return ERR_PTR(-ENOMEM);
59498 +
59499 + memset(s_tmp->obj_hash, 0,
59500 + s_tmp->obj_hash_size *
59501 + sizeof (struct acl_object_label *));
59502 +
59503 + /* add in objects */
59504 + err = copy_user_objs(ghash.first, s_tmp, role);
59505 +
59506 + if (err)
59507 + return ERR_PTR(err);
59508 +
59509 + /* set pointer for parent subject */
59510 + if (s_tmp->parent_subject) {
59511 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59512 +
59513 + if (IS_ERR(s_tmp2))
59514 + return s_tmp2;
59515 +
59516 + s_tmp->parent_subject = s_tmp2;
59517 + }
59518 +
59519 + /* add in ip acls */
59520 +
59521 + if (!s_tmp->ip_num) {
59522 + s_tmp->ips = NULL;
59523 + goto insert;
59524 + }
59525 +
59526 + i_tmp =
59527 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59528 + sizeof (struct acl_ip_label *));
59529 +
59530 + if (!i_tmp)
59531 + return ERR_PTR(-ENOMEM);
59532 +
59533 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59534 + *(i_tmp + i_num) =
59535 + (struct acl_ip_label *)
59536 + acl_alloc(sizeof (struct acl_ip_label));
59537 + if (!*(i_tmp + i_num))
59538 + return ERR_PTR(-ENOMEM);
59539 +
59540 + if (copy_from_user
59541 + (&i_utmp2, s_tmp->ips + i_num,
59542 + sizeof (struct acl_ip_label *)))
59543 + return ERR_PTR(-EFAULT);
59544 +
59545 + if (copy_from_user
59546 + (*(i_tmp + i_num), i_utmp2,
59547 + sizeof (struct acl_ip_label)))
59548 + return ERR_PTR(-EFAULT);
59549 +
59550 + if ((*(i_tmp + i_num))->iface == NULL)
59551 + continue;
59552 +
59553 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59554 + if (!len || len >= IFNAMSIZ)
59555 + return ERR_PTR(-EINVAL);
59556 + tmp = acl_alloc(len);
59557 + if (tmp == NULL)
59558 + return ERR_PTR(-ENOMEM);
59559 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59560 + return ERR_PTR(-EFAULT);
59561 + (*(i_tmp + i_num))->iface = tmp;
59562 + }
59563 +
59564 + s_tmp->ips = i_tmp;
59565 +
59566 +insert:
59567 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59568 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59569 + return ERR_PTR(-ENOMEM);
59570 +
59571 + return s_tmp;
59572 +}
59573 +
59574 +static int
59575 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59576 +{
59577 + struct acl_subject_label s_pre;
59578 + struct acl_subject_label * ret;
59579 + int err;
59580 +
59581 + while (userp) {
59582 + if (copy_from_user(&s_pre, userp,
59583 + sizeof (struct acl_subject_label)))
59584 + return -EFAULT;
59585 +
59586 + ret = do_copy_user_subj(userp, role, NULL);
59587 +
59588 + err = PTR_ERR(ret);
59589 + if (IS_ERR(ret))
59590 + return err;
59591 +
59592 + insert_acl_subj_label(ret, role);
59593 +
59594 + userp = s_pre.prev;
59595 + }
59596 +
59597 + return 0;
59598 +}
59599 +
59600 +static int
59601 +copy_user_acl(struct gr_arg *arg)
59602 +{
59603 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59604 + struct acl_subject_label *subj_list;
59605 + struct sprole_pw *sptmp;
59606 + struct gr_hash_struct *ghash;
59607 + uid_t *domainlist;
59608 + unsigned int r_num;
59609 + unsigned int len;
59610 + char *tmp;
59611 + int err = 0;
59612 + __u16 i;
59613 + __u32 num_subjs;
59614 +
59615 + /* we need a default and kernel role */
59616 + if (arg->role_db.num_roles < 2)
59617 + return -EINVAL;
59618 +
59619 + /* copy special role authentication info from userspace */
59620 +
59621 + num_sprole_pws = arg->num_sprole_pws;
59622 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59623 +
59624 + if (!acl_special_roles && num_sprole_pws)
59625 + return -ENOMEM;
59626 +
59627 + for (i = 0; i < num_sprole_pws; i++) {
59628 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59629 + if (!sptmp)
59630 + return -ENOMEM;
59631 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59632 + sizeof (struct sprole_pw)))
59633 + return -EFAULT;
59634 +
59635 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59636 +
59637 + if (!len || len >= GR_SPROLE_LEN)
59638 + return -EINVAL;
59639 +
59640 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59641 + return -ENOMEM;
59642 +
59643 + if (copy_from_user(tmp, sptmp->rolename, len))
59644 + return -EFAULT;
59645 +
59646 + tmp[len-1] = '\0';
59647 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59648 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59649 +#endif
59650 + sptmp->rolename = tmp;
59651 + acl_special_roles[i] = sptmp;
59652 + }
59653 +
59654 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59655 +
59656 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59657 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59658 +
59659 + if (!r_tmp)
59660 + return -ENOMEM;
59661 +
59662 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59663 + sizeof (struct acl_role_label *)))
59664 + return -EFAULT;
59665 +
59666 + if (copy_from_user(r_tmp, r_utmp2,
59667 + sizeof (struct acl_role_label)))
59668 + return -EFAULT;
59669 +
59670 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59671 +
59672 + if (!len || len >= PATH_MAX)
59673 + return -EINVAL;
59674 +
59675 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59676 + return -ENOMEM;
59677 +
59678 + if (copy_from_user(tmp, r_tmp->rolename, len))
59679 + return -EFAULT;
59680 +
59681 + tmp[len-1] = '\0';
59682 + r_tmp->rolename = tmp;
59683 +
59684 + if (!strcmp(r_tmp->rolename, "default")
59685 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59686 + default_role = r_tmp;
59687 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59688 + kernel_role = r_tmp;
59689 + }
59690 +
59691 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59692 + return -ENOMEM;
59693 +
59694 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59695 + return -EFAULT;
59696 +
59697 + r_tmp->hash = ghash;
59698 +
59699 + num_subjs = count_user_subjs(r_tmp->hash->first);
59700 +
59701 + r_tmp->subj_hash_size = num_subjs;
59702 + r_tmp->subj_hash =
59703 + (struct acl_subject_label **)
59704 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59705 +
59706 + if (!r_tmp->subj_hash)
59707 + return -ENOMEM;
59708 +
59709 + err = copy_user_allowedips(r_tmp);
59710 + if (err)
59711 + return err;
59712 +
59713 + /* copy domain info */
59714 + if (r_tmp->domain_children != NULL) {
59715 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59716 + if (domainlist == NULL)
59717 + return -ENOMEM;
59718 +
59719 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59720 + return -EFAULT;
59721 +
59722 + r_tmp->domain_children = domainlist;
59723 + }
59724 +
59725 + err = copy_user_transitions(r_tmp);
59726 + if (err)
59727 + return err;
59728 +
59729 + memset(r_tmp->subj_hash, 0,
59730 + r_tmp->subj_hash_size *
59731 + sizeof (struct acl_subject_label *));
59732 +
59733 + /* acquire the list of subjects, then NULL out
59734 + the list prior to parsing the subjects for this role,
59735 + as during this parsing the list is replaced with a list
59736 + of *nested* subjects for the role
59737 + */
59738 + subj_list = r_tmp->hash->first;
59739 +
59740 + /* set nested subject list to null */
59741 + r_tmp->hash->first = NULL;
59742 +
59743 + err = copy_user_subjs(subj_list, r_tmp);
59744 +
59745 + if (err)
59746 + return err;
59747 +
59748 + insert_acl_role_label(r_tmp);
59749 + }
59750 +
59751 + if (default_role == NULL || kernel_role == NULL)
59752 + return -EINVAL;
59753 +
59754 + return err;
59755 +}
59756 +
59757 +static int
59758 +gracl_init(struct gr_arg *args)
59759 +{
59760 + int error = 0;
59761 +
59762 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59763 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59764 +
59765 + if (init_variables(args)) {
59766 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59767 + error = -ENOMEM;
59768 + free_variables();
59769 + goto out;
59770 + }
59771 +
59772 + error = copy_user_acl(args);
59773 + free_init_variables();
59774 + if (error) {
59775 + free_variables();
59776 + goto out;
59777 + }
59778 +
59779 + if ((error = gr_set_acls(0))) {
59780 + free_variables();
59781 + goto out;
59782 + }
59783 +
59784 + pax_open_kernel();
59785 + gr_status |= GR_READY;
59786 + pax_close_kernel();
59787 +
59788 + out:
59789 + return error;
59790 +}
59791 +
59792 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59793 +
59794 +static int
59795 +glob_match(const char *p, const char *n)
59796 +{
59797 + char c;
59798 +
59799 + while ((c = *p++) != '\0') {
59800 + switch (c) {
59801 + case '?':
59802 + if (*n == '\0')
59803 + return 1;
59804 + else if (*n == '/')
59805 + return 1;
59806 + break;
59807 + case '\\':
59808 + if (*n != c)
59809 + return 1;
59810 + break;
59811 + case '*':
59812 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59813 + if (*n == '/')
59814 + return 1;
59815 + else if (c == '?') {
59816 + if (*n == '\0')
59817 + return 1;
59818 + else
59819 + ++n;
59820 + }
59821 + }
59822 + if (c == '\0') {
59823 + return 0;
59824 + } else {
59825 + const char *endp;
59826 +
59827 + if ((endp = strchr(n, '/')) == NULL)
59828 + endp = n + strlen(n);
59829 +
59830 + if (c == '[') {
59831 + for (--p; n < endp; ++n)
59832 + if (!glob_match(p, n))
59833 + return 0;
59834 + } else if (c == '/') {
59835 + while (*n != '\0' && *n != '/')
59836 + ++n;
59837 + if (*n == '/' && !glob_match(p, n + 1))
59838 + return 0;
59839 + } else {
59840 + for (--p; n < endp; ++n)
59841 + if (*n == c && !glob_match(p, n))
59842 + return 0;
59843 + }
59844 +
59845 + return 1;
59846 + }
59847 + case '[':
59848 + {
59849 + int not;
59850 + char cold;
59851 +
59852 + if (*n == '\0' || *n == '/')
59853 + return 1;
59854 +
59855 + not = (*p == '!' || *p == '^');
59856 + if (not)
59857 + ++p;
59858 +
59859 + c = *p++;
59860 + for (;;) {
59861 + unsigned char fn = (unsigned char)*n;
59862 +
59863 + if (c == '\0')
59864 + return 1;
59865 + else {
59866 + if (c == fn)
59867 + goto matched;
59868 + cold = c;
59869 + c = *p++;
59870 +
59871 + if (c == '-' && *p != ']') {
59872 + unsigned char cend = *p++;
59873 +
59874 + if (cend == '\0')
59875 + return 1;
59876 +
59877 + if (cold <= fn && fn <= cend)
59878 + goto matched;
59879 +
59880 + c = *p++;
59881 + }
59882 + }
59883 +
59884 + if (c == ']')
59885 + break;
59886 + }
59887 + if (!not)
59888 + return 1;
59889 + break;
59890 + matched:
59891 + while (c != ']') {
59892 + if (c == '\0')
59893 + return 1;
59894 +
59895 + c = *p++;
59896 + }
59897 + if (not)
59898 + return 1;
59899 + }
59900 + break;
59901 + default:
59902 + if (c != *n)
59903 + return 1;
59904 + }
59905 +
59906 + ++n;
59907 + }
59908 +
59909 + if (*n == '\0')
59910 + return 0;
59911 +
59912 + if (*n == '/')
59913 + return 0;
59914 +
59915 + return 1;
59916 +}
59917 +
59918 +static struct acl_object_label *
59919 +chk_glob_label(struct acl_object_label *globbed,
59920 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59921 +{
59922 + struct acl_object_label *tmp;
59923 +
59924 + if (*path == NULL)
59925 + *path = gr_to_filename_nolock(dentry, mnt);
59926 +
59927 + tmp = globbed;
59928 +
59929 + while (tmp) {
59930 + if (!glob_match(tmp->filename, *path))
59931 + return tmp;
59932 + tmp = tmp->next;
59933 + }
59934 +
59935 + return NULL;
59936 +}
59937 +
59938 +static struct acl_object_label *
59939 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59940 + const ino_t curr_ino, const dev_t curr_dev,
59941 + const struct acl_subject_label *subj, char **path, const int checkglob)
59942 +{
59943 + struct acl_subject_label *tmpsubj;
59944 + struct acl_object_label *retval;
59945 + struct acl_object_label *retval2;
59946 +
59947 + tmpsubj = (struct acl_subject_label *) subj;
59948 + read_lock(&gr_inode_lock);
59949 + do {
59950 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59951 + if (retval) {
59952 + if (checkglob && retval->globbed) {
59953 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59954 + if (retval2)
59955 + retval = retval2;
59956 + }
59957 + break;
59958 + }
59959 + } while ((tmpsubj = tmpsubj->parent_subject));
59960 + read_unlock(&gr_inode_lock);
59961 +
59962 + return retval;
59963 +}
59964 +
59965 +static __inline__ struct acl_object_label *
59966 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59967 + struct dentry *curr_dentry,
59968 + const struct acl_subject_label *subj, char **path, const int checkglob)
59969 +{
59970 + int newglob = checkglob;
59971 + ino_t inode;
59972 + dev_t device;
59973 +
59974 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59975 + as we don't want a / * rule to match instead of the / object
59976 + don't do this for create lookups that call this function though, since they're looking up
59977 + on the parent and thus need globbing checks on all paths
59978 + */
59979 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59980 + newglob = GR_NO_GLOB;
59981 +
59982 + spin_lock(&curr_dentry->d_lock);
59983 + inode = curr_dentry->d_inode->i_ino;
59984 + device = __get_dev(curr_dentry);
59985 + spin_unlock(&curr_dentry->d_lock);
59986 +
59987 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59988 +}
59989 +
59990 +#ifdef CONFIG_HUGETLBFS
59991 +static inline bool
59992 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59993 +{
59994 + int i;
59995 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59996 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59997 + return true;
59998 + }
59999 +
60000 + return false;
60001 +}
60002 +#endif
60003 +
60004 +static struct acl_object_label *
60005 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60006 + const struct acl_subject_label *subj, char *path, const int checkglob)
60007 +{
60008 + struct dentry *dentry = (struct dentry *) l_dentry;
60009 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60010 + struct mount *real_mnt = real_mount(mnt);
60011 + struct acl_object_label *retval;
60012 + struct dentry *parent;
60013 +
60014 + br_read_lock(&vfsmount_lock);
60015 + write_seqlock(&rename_lock);
60016 +
60017 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
60018 +#ifdef CONFIG_NET
60019 + mnt == sock_mnt ||
60020 +#endif
60021 +#ifdef CONFIG_HUGETLBFS
60022 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60023 +#endif
60024 + /* ignore Eric Biederman */
60025 + IS_PRIVATE(l_dentry->d_inode))) {
60026 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60027 + goto out;
60028 + }
60029 +
60030 + for (;;) {
60031 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60032 + break;
60033 +
60034 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60035 + if (!mnt_has_parent(real_mnt))
60036 + break;
60037 +
60038 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60039 + if (retval != NULL)
60040 + goto out;
60041 +
60042 + dentry = real_mnt->mnt_mountpoint;
60043 + real_mnt = real_mnt->mnt_parent;
60044 + mnt = &real_mnt->mnt;
60045 + continue;
60046 + }
60047 +
60048 + parent = dentry->d_parent;
60049 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60050 + if (retval != NULL)
60051 + goto out;
60052 +
60053 + dentry = parent;
60054 + }
60055 +
60056 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60057 +
60058 + /* real_root is pinned so we don't have to hold a reference */
60059 + if (retval == NULL)
60060 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60061 +out:
60062 + write_sequnlock(&rename_lock);
60063 + br_read_unlock(&vfsmount_lock);
60064 +
60065 + BUG_ON(retval == NULL);
60066 +
60067 + return retval;
60068 +}
60069 +
60070 +static __inline__ struct acl_object_label *
60071 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60072 + const struct acl_subject_label *subj)
60073 +{
60074 + char *path = NULL;
60075 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60076 +}
60077 +
60078 +static __inline__ struct acl_object_label *
60079 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60080 + const struct acl_subject_label *subj)
60081 +{
60082 + char *path = NULL;
60083 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60084 +}
60085 +
60086 +static __inline__ struct acl_object_label *
60087 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60088 + const struct acl_subject_label *subj, char *path)
60089 +{
60090 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60091 +}
60092 +
60093 +static struct acl_subject_label *
60094 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60095 + const struct acl_role_label *role)
60096 +{
60097 + struct dentry *dentry = (struct dentry *) l_dentry;
60098 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60099 + struct mount *real_mnt = real_mount(mnt);
60100 + struct acl_subject_label *retval;
60101 + struct dentry *parent;
60102 +
60103 + br_read_lock(&vfsmount_lock);
60104 + write_seqlock(&rename_lock);
60105 +
60106 + for (;;) {
60107 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60108 + break;
60109 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60110 + if (!mnt_has_parent(real_mnt))
60111 + break;
60112 +
60113 + spin_lock(&dentry->d_lock);
60114 + read_lock(&gr_inode_lock);
60115 + retval =
60116 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60117 + __get_dev(dentry), role);
60118 + read_unlock(&gr_inode_lock);
60119 + spin_unlock(&dentry->d_lock);
60120 + if (retval != NULL)
60121 + goto out;
60122 +
60123 + dentry = real_mnt->mnt_mountpoint;
60124 + real_mnt = real_mnt->mnt_parent;
60125 + mnt = &real_mnt->mnt;
60126 + continue;
60127 + }
60128 +
60129 + spin_lock(&dentry->d_lock);
60130 + read_lock(&gr_inode_lock);
60131 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60132 + __get_dev(dentry), role);
60133 + read_unlock(&gr_inode_lock);
60134 + parent = dentry->d_parent;
60135 + spin_unlock(&dentry->d_lock);
60136 +
60137 + if (retval != NULL)
60138 + goto out;
60139 +
60140 + dentry = parent;
60141 + }
60142 +
60143 + spin_lock(&dentry->d_lock);
60144 + read_lock(&gr_inode_lock);
60145 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60146 + __get_dev(dentry), role);
60147 + read_unlock(&gr_inode_lock);
60148 + spin_unlock(&dentry->d_lock);
60149 +
60150 + if (unlikely(retval == NULL)) {
60151 + /* real_root is pinned, we don't need to hold a reference */
60152 + read_lock(&gr_inode_lock);
60153 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60154 + __get_dev(real_root.dentry), role);
60155 + read_unlock(&gr_inode_lock);
60156 + }
60157 +out:
60158 + write_sequnlock(&rename_lock);
60159 + br_read_unlock(&vfsmount_lock);
60160 +
60161 + BUG_ON(retval == NULL);
60162 +
60163 + return retval;
60164 +}
60165 +
60166 +static void
60167 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60168 +{
60169 + struct task_struct *task = current;
60170 + const struct cred *cred = current_cred();
60171 +
60172 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60173 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60174 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60175 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60176 +
60177 + return;
60178 +}
60179 +
60180 +static void
60181 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60182 +{
60183 + struct task_struct *task = current;
60184 + const struct cred *cred = current_cred();
60185 +
60186 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60187 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60188 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60189 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60190 +
60191 + return;
60192 +}
60193 +
60194 +static void
60195 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60196 +{
60197 + struct task_struct *task = current;
60198 + const struct cred *cred = current_cred();
60199 +
60200 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60201 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60202 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60203 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60204 +
60205 + return;
60206 +}
60207 +
60208 +__u32
60209 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60210 + const struct vfsmount * mnt)
60211 +{
60212 + __u32 retval = mode;
60213 + struct acl_subject_label *curracl;
60214 + struct acl_object_label *currobj;
60215 +
60216 + if (unlikely(!(gr_status & GR_READY)))
60217 + return (mode & ~GR_AUDITS);
60218 +
60219 + curracl = current->acl;
60220 +
60221 + currobj = chk_obj_label(dentry, mnt, curracl);
60222 + retval = currobj->mode & mode;
60223 +
60224 + /* if we're opening a specified transfer file for writing
60225 + (e.g. /dev/initctl), then transfer our role to init
60226 + */
60227 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60228 + current->role->roletype & GR_ROLE_PERSIST)) {
60229 + struct task_struct *task = init_pid_ns.child_reaper;
60230 +
60231 + if (task->role != current->role) {
60232 + task->acl_sp_role = 0;
60233 + task->acl_role_id = current->acl_role_id;
60234 + task->role = current->role;
60235 + rcu_read_lock();
60236 + read_lock(&grsec_exec_file_lock);
60237 + gr_apply_subject_to_task(task);
60238 + read_unlock(&grsec_exec_file_lock);
60239 + rcu_read_unlock();
60240 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60241 + }
60242 + }
60243 +
60244 + if (unlikely
60245 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60246 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60247 + __u32 new_mode = mode;
60248 +
60249 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60250 +
60251 + retval = new_mode;
60252 +
60253 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60254 + new_mode |= GR_INHERIT;
60255 +
60256 + if (!(mode & GR_NOLEARN))
60257 + gr_log_learn(dentry, mnt, new_mode);
60258 + }
60259 +
60260 + return retval;
60261 +}
60262 +
60263 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60264 + const struct dentry *parent,
60265 + const struct vfsmount *mnt)
60266 +{
60267 + struct name_entry *match;
60268 + struct acl_object_label *matchpo;
60269 + struct acl_subject_label *curracl;
60270 + char *path;
60271 +
60272 + if (unlikely(!(gr_status & GR_READY)))
60273 + return NULL;
60274 +
60275 + preempt_disable();
60276 + path = gr_to_filename_rbac(new_dentry, mnt);
60277 + match = lookup_name_entry_create(path);
60278 +
60279 + curracl = current->acl;
60280 +
60281 + if (match) {
60282 + read_lock(&gr_inode_lock);
60283 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60284 + read_unlock(&gr_inode_lock);
60285 +
60286 + if (matchpo) {
60287 + preempt_enable();
60288 + return matchpo;
60289 + }
60290 + }
60291 +
60292 + // lookup parent
60293 +
60294 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60295 +
60296 + preempt_enable();
60297 + return matchpo;
60298 +}
60299 +
60300 +__u32
60301 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60302 + const struct vfsmount * mnt, const __u32 mode)
60303 +{
60304 + struct acl_object_label *matchpo;
60305 + __u32 retval;
60306 +
60307 + if (unlikely(!(gr_status & GR_READY)))
60308 + return (mode & ~GR_AUDITS);
60309 +
60310 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60311 +
60312 + retval = matchpo->mode & mode;
60313 +
60314 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60315 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60316 + __u32 new_mode = mode;
60317 +
60318 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60319 +
60320 + gr_log_learn(new_dentry, mnt, new_mode);
60321 + return new_mode;
60322 + }
60323 +
60324 + return retval;
60325 +}
60326 +
60327 +__u32
60328 +gr_check_link(const struct dentry * new_dentry,
60329 + const struct dentry * parent_dentry,
60330 + const struct vfsmount * parent_mnt,
60331 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60332 +{
60333 + struct acl_object_label *obj;
60334 + __u32 oldmode, newmode;
60335 + __u32 needmode;
60336 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60337 + GR_DELETE | GR_INHERIT;
60338 +
60339 + if (unlikely(!(gr_status & GR_READY)))
60340 + return (GR_CREATE | GR_LINK);
60341 +
60342 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60343 + oldmode = obj->mode;
60344 +
60345 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60346 + newmode = obj->mode;
60347 +
60348 + needmode = newmode & checkmodes;
60349 +
60350 + // old name for hardlink must have at least the permissions of the new name
60351 + if ((oldmode & needmode) != needmode)
60352 + goto bad;
60353 +
60354 + // if old name had restrictions/auditing, make sure the new name does as well
60355 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60356 +
60357 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60358 + if (is_privileged_binary(old_dentry))
60359 + needmode |= GR_SETID;
60360 +
60361 + if ((newmode & needmode) != needmode)
60362 + goto bad;
60363 +
60364 + // enforce minimum permissions
60365 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60366 + return newmode;
60367 +bad:
60368 + needmode = oldmode;
60369 + if (is_privileged_binary(old_dentry))
60370 + needmode |= GR_SETID;
60371 +
60372 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60373 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60374 + return (GR_CREATE | GR_LINK);
60375 + } else if (newmode & GR_SUPPRESS)
60376 + return GR_SUPPRESS;
60377 + else
60378 + return 0;
60379 +}
60380 +
60381 +int
60382 +gr_check_hidden_task(const struct task_struct *task)
60383 +{
60384 + if (unlikely(!(gr_status & GR_READY)))
60385 + return 0;
60386 +
60387 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60388 + return 1;
60389 +
60390 + return 0;
60391 +}
60392 +
60393 +int
60394 +gr_check_protected_task(const struct task_struct *task)
60395 +{
60396 + if (unlikely(!(gr_status & GR_READY) || !task))
60397 + return 0;
60398 +
60399 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60400 + task->acl != current->acl)
60401 + return 1;
60402 +
60403 + return 0;
60404 +}
60405 +
60406 +int
60407 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60408 +{
60409 + struct task_struct *p;
60410 + int ret = 0;
60411 +
60412 + if (unlikely(!(gr_status & GR_READY) || !pid))
60413 + return ret;
60414 +
60415 + read_lock(&tasklist_lock);
60416 + do_each_pid_task(pid, type, p) {
60417 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60418 + p->acl != current->acl) {
60419 + ret = 1;
60420 + goto out;
60421 + }
60422 + } while_each_pid_task(pid, type, p);
60423 +out:
60424 + read_unlock(&tasklist_lock);
60425 +
60426 + return ret;
60427 +}
60428 +
60429 +void
60430 +gr_copy_label(struct task_struct *tsk)
60431 +{
60432 + tsk->signal->used_accept = 0;
60433 + tsk->acl_sp_role = 0;
60434 + tsk->acl_role_id = current->acl_role_id;
60435 + tsk->acl = current->acl;
60436 + tsk->role = current->role;
60437 + tsk->signal->curr_ip = current->signal->curr_ip;
60438 + tsk->signal->saved_ip = current->signal->saved_ip;
60439 + if (current->exec_file)
60440 + get_file(current->exec_file);
60441 + tsk->exec_file = current->exec_file;
60442 + tsk->is_writable = current->is_writable;
60443 + if (unlikely(current->signal->used_accept)) {
60444 + current->signal->curr_ip = 0;
60445 + current->signal->saved_ip = 0;
60446 + }
60447 +
60448 + return;
60449 +}
60450 +
60451 +static void
60452 +gr_set_proc_res(struct task_struct *task)
60453 +{
60454 + struct acl_subject_label *proc;
60455 + unsigned short i;
60456 +
60457 + proc = task->acl;
60458 +
60459 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60460 + return;
60461 +
60462 + for (i = 0; i < RLIM_NLIMITS; i++) {
60463 + if (!(proc->resmask & (1U << i)))
60464 + continue;
60465 +
60466 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60467 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60468 +
60469 + if (i == RLIMIT_CPU)
60470 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60471 + }
60472 +
60473 + return;
60474 +}
60475 +
60476 +extern int __gr_process_user_ban(struct user_struct *user);
60477 +
60478 +int
60479 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60480 +{
60481 + unsigned int i;
60482 + __u16 num;
60483 + uid_t *uidlist;
60484 + uid_t curuid;
60485 + int realok = 0;
60486 + int effectiveok = 0;
60487 + int fsok = 0;
60488 + uid_t globalreal, globaleffective, globalfs;
60489 +
60490 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60491 + struct user_struct *user;
60492 +
60493 + if (!uid_valid(real))
60494 + goto skipit;
60495 +
60496 + /* find user based on global namespace */
60497 +
60498 + globalreal = GR_GLOBAL_UID(real);
60499 +
60500 + user = find_user(make_kuid(&init_user_ns, globalreal));
60501 + if (user == NULL)
60502 + goto skipit;
60503 +
60504 + if (__gr_process_user_ban(user)) {
60505 + /* for find_user */
60506 + free_uid(user);
60507 + return 1;
60508 + }
60509 +
60510 + /* for find_user */
60511 + free_uid(user);
60512 +
60513 +skipit:
60514 +#endif
60515 +
60516 + if (unlikely(!(gr_status & GR_READY)))
60517 + return 0;
60518 +
60519 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60520 + gr_log_learn_uid_change(real, effective, fs);
60521 +
60522 + num = current->acl->user_trans_num;
60523 + uidlist = current->acl->user_transitions;
60524 +
60525 + if (uidlist == NULL)
60526 + return 0;
60527 +
60528 + if (!uid_valid(real)) {
60529 + realok = 1;
60530 + globalreal = (uid_t)-1;
60531 + } else {
60532 + globalreal = GR_GLOBAL_UID(real);
60533 + }
60534 + if (!uid_valid(effective)) {
60535 + effectiveok = 1;
60536 + globaleffective = (uid_t)-1;
60537 + } else {
60538 + globaleffective = GR_GLOBAL_UID(effective);
60539 + }
60540 + if (!uid_valid(fs)) {
60541 + fsok = 1;
60542 + globalfs = (uid_t)-1;
60543 + } else {
60544 + globalfs = GR_GLOBAL_UID(fs);
60545 + }
60546 +
60547 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60548 + for (i = 0; i < num; i++) {
60549 + curuid = uidlist[i];
60550 + if (globalreal == curuid)
60551 + realok = 1;
60552 + if (globaleffective == curuid)
60553 + effectiveok = 1;
60554 + if (globalfs == curuid)
60555 + fsok = 1;
60556 + }
60557 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60558 + for (i = 0; i < num; i++) {
60559 + curuid = uidlist[i];
60560 + if (globalreal == curuid)
60561 + break;
60562 + if (globaleffective == curuid)
60563 + break;
60564 + if (globalfs == curuid)
60565 + break;
60566 + }
60567 + /* not in deny list */
60568 + if (i == num) {
60569 + realok = 1;
60570 + effectiveok = 1;
60571 + fsok = 1;
60572 + }
60573 + }
60574 +
60575 + if (realok && effectiveok && fsok)
60576 + return 0;
60577 + else {
60578 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60579 + return 1;
60580 + }
60581 +}
60582 +
60583 +int
60584 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60585 +{
60586 + unsigned int i;
60587 + __u16 num;
60588 + gid_t *gidlist;
60589 + gid_t curgid;
60590 + int realok = 0;
60591 + int effectiveok = 0;
60592 + int fsok = 0;
60593 + gid_t globalreal, globaleffective, globalfs;
60594 +
60595 + if (unlikely(!(gr_status & GR_READY)))
60596 + return 0;
60597 +
60598 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60599 + gr_log_learn_gid_change(real, effective, fs);
60600 +
60601 + num = current->acl->group_trans_num;
60602 + gidlist = current->acl->group_transitions;
60603 +
60604 + if (gidlist == NULL)
60605 + return 0;
60606 +
60607 + if (!gid_valid(real)) {
60608 + realok = 1;
60609 + globalreal = (gid_t)-1;
60610 + } else {
60611 + globalreal = GR_GLOBAL_GID(real);
60612 + }
60613 + if (!gid_valid(effective)) {
60614 + effectiveok = 1;
60615 + globaleffective = (gid_t)-1;
60616 + } else {
60617 + globaleffective = GR_GLOBAL_GID(effective);
60618 + }
60619 + if (!gid_valid(fs)) {
60620 + fsok = 1;
60621 + globalfs = (gid_t)-1;
60622 + } else {
60623 + globalfs = GR_GLOBAL_GID(fs);
60624 + }
60625 +
60626 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60627 + for (i = 0; i < num; i++) {
60628 + curgid = gidlist[i];
60629 + if (globalreal == curgid)
60630 + realok = 1;
60631 + if (globaleffective == curgid)
60632 + effectiveok = 1;
60633 + if (globalfs == curgid)
60634 + fsok = 1;
60635 + }
60636 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60637 + for (i = 0; i < num; i++) {
60638 + curgid = gidlist[i];
60639 + if (globalreal == curgid)
60640 + break;
60641 + if (globaleffective == curgid)
60642 + break;
60643 + if (globalfs == curgid)
60644 + break;
60645 + }
60646 + /* not in deny list */
60647 + if (i == num) {
60648 + realok = 1;
60649 + effectiveok = 1;
60650 + fsok = 1;
60651 + }
60652 + }
60653 +
60654 + if (realok && effectiveok && fsok)
60655 + return 0;
60656 + else {
60657 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60658 + return 1;
60659 + }
60660 +}
60661 +
60662 +extern int gr_acl_is_capable(const int cap);
60663 +
60664 +void
60665 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60666 +{
60667 + struct acl_role_label *role = task->role;
60668 + struct acl_subject_label *subj = NULL;
60669 + struct acl_object_label *obj;
60670 + struct file *filp;
60671 + uid_t uid;
60672 + gid_t gid;
60673 +
60674 + if (unlikely(!(gr_status & GR_READY)))
60675 + return;
60676 +
60677 + uid = GR_GLOBAL_UID(kuid);
60678 + gid = GR_GLOBAL_GID(kgid);
60679 +
60680 + filp = task->exec_file;
60681 +
60682 + /* kernel process, we'll give them the kernel role */
60683 + if (unlikely(!filp)) {
60684 + task->role = kernel_role;
60685 + task->acl = kernel_role->root_label;
60686 + return;
60687 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60688 + role = lookup_acl_role_label(task, uid, gid);
60689 +
60690 + /* don't change the role if we're not a privileged process */
60691 + if (role && task->role != role &&
60692 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60693 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60694 + return;
60695 +
60696 + /* perform subject lookup in possibly new role
60697 + we can use this result below in the case where role == task->role
60698 + */
60699 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60700 +
60701 + /* if we changed uid/gid, but result in the same role
60702 + and are using inheritance, don't lose the inherited subject
60703 + if current subject is other than what normal lookup
60704 + would result in, we arrived via inheritance, don't
60705 + lose subject
60706 + */
60707 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60708 + (subj == task->acl)))
60709 + task->acl = subj;
60710 +
60711 + task->role = role;
60712 +
60713 + task->is_writable = 0;
60714 +
60715 + /* ignore additional mmap checks for processes that are writable
60716 + by the default ACL */
60717 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60718 + if (unlikely(obj->mode & GR_WRITE))
60719 + task->is_writable = 1;
60720 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60721 + if (unlikely(obj->mode & GR_WRITE))
60722 + task->is_writable = 1;
60723 +
60724 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60725 + 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);
60726 +#endif
60727 +
60728 + gr_set_proc_res(task);
60729 +
60730 + return;
60731 +}
60732 +
60733 +int
60734 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60735 + const int unsafe_flags)
60736 +{
60737 + struct task_struct *task = current;
60738 + struct acl_subject_label *newacl;
60739 + struct acl_object_label *obj;
60740 + __u32 retmode;
60741 +
60742 + if (unlikely(!(gr_status & GR_READY)))
60743 + return 0;
60744 +
60745 + newacl = chk_subj_label(dentry, mnt, task->role);
60746 +
60747 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60748 + did an exec
60749 + */
60750 + rcu_read_lock();
60751 + read_lock(&tasklist_lock);
60752 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60753 + (task->parent->acl->mode & GR_POVERRIDE))) {
60754 + read_unlock(&tasklist_lock);
60755 + rcu_read_unlock();
60756 + goto skip_check;
60757 + }
60758 + read_unlock(&tasklist_lock);
60759 + rcu_read_unlock();
60760 +
60761 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60762 + !(task->role->roletype & GR_ROLE_GOD) &&
60763 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60764 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60765 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60766 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60767 + else
60768 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60769 + return -EACCES;
60770 + }
60771 +
60772 +skip_check:
60773 +
60774 + obj = chk_obj_label(dentry, mnt, task->acl);
60775 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60776 +
60777 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60778 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60779 + if (obj->nested)
60780 + task->acl = obj->nested;
60781 + else
60782 + task->acl = newacl;
60783 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60784 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60785 +
60786 + task->is_writable = 0;
60787 +
60788 + /* ignore additional mmap checks for processes that are writable
60789 + by the default ACL */
60790 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60791 + if (unlikely(obj->mode & GR_WRITE))
60792 + task->is_writable = 1;
60793 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60794 + if (unlikely(obj->mode & GR_WRITE))
60795 + task->is_writable = 1;
60796 +
60797 + gr_set_proc_res(task);
60798 +
60799 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60800 + 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);
60801 +#endif
60802 + return 0;
60803 +}
60804 +
60805 +/* always called with valid inodev ptr */
60806 +static void
60807 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60808 +{
60809 + struct acl_object_label *matchpo;
60810 + struct acl_subject_label *matchps;
60811 + struct acl_subject_label *subj;
60812 + struct acl_role_label *role;
60813 + unsigned int x;
60814 +
60815 + FOR_EACH_ROLE_START(role)
60816 + FOR_EACH_SUBJECT_START(role, subj, x)
60817 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60818 + matchpo->mode |= GR_DELETED;
60819 + FOR_EACH_SUBJECT_END(subj,x)
60820 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60821 + /* nested subjects aren't in the role's subj_hash table */
60822 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60823 + matchpo->mode |= GR_DELETED;
60824 + FOR_EACH_NESTED_SUBJECT_END(subj)
60825 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60826 + matchps->mode |= GR_DELETED;
60827 + FOR_EACH_ROLE_END(role)
60828 +
60829 + inodev->nentry->deleted = 1;
60830 +
60831 + return;
60832 +}
60833 +
60834 +void
60835 +gr_handle_delete(const ino_t ino, const dev_t dev)
60836 +{
60837 + struct inodev_entry *inodev;
60838 +
60839 + if (unlikely(!(gr_status & GR_READY)))
60840 + return;
60841 +
60842 + write_lock(&gr_inode_lock);
60843 + inodev = lookup_inodev_entry(ino, dev);
60844 + if (inodev != NULL)
60845 + do_handle_delete(inodev, ino, dev);
60846 + write_unlock(&gr_inode_lock);
60847 +
60848 + return;
60849 +}
60850 +
60851 +static void
60852 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60853 + const ino_t newinode, const dev_t newdevice,
60854 + struct acl_subject_label *subj)
60855 +{
60856 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60857 + struct acl_object_label *match;
60858 +
60859 + match = subj->obj_hash[index];
60860 +
60861 + while (match && (match->inode != oldinode ||
60862 + match->device != olddevice ||
60863 + !(match->mode & GR_DELETED)))
60864 + match = match->next;
60865 +
60866 + if (match && (match->inode == oldinode)
60867 + && (match->device == olddevice)
60868 + && (match->mode & GR_DELETED)) {
60869 + if (match->prev == NULL) {
60870 + subj->obj_hash[index] = match->next;
60871 + if (match->next != NULL)
60872 + match->next->prev = NULL;
60873 + } else {
60874 + match->prev->next = match->next;
60875 + if (match->next != NULL)
60876 + match->next->prev = match->prev;
60877 + }
60878 + match->prev = NULL;
60879 + match->next = NULL;
60880 + match->inode = newinode;
60881 + match->device = newdevice;
60882 + match->mode &= ~GR_DELETED;
60883 +
60884 + insert_acl_obj_label(match, subj);
60885 + }
60886 +
60887 + return;
60888 +}
60889 +
60890 +static void
60891 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60892 + const ino_t newinode, const dev_t newdevice,
60893 + struct acl_role_label *role)
60894 +{
60895 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60896 + struct acl_subject_label *match;
60897 +
60898 + match = role->subj_hash[index];
60899 +
60900 + while (match && (match->inode != oldinode ||
60901 + match->device != olddevice ||
60902 + !(match->mode & GR_DELETED)))
60903 + match = match->next;
60904 +
60905 + if (match && (match->inode == oldinode)
60906 + && (match->device == olddevice)
60907 + && (match->mode & GR_DELETED)) {
60908 + if (match->prev == NULL) {
60909 + role->subj_hash[index] = match->next;
60910 + if (match->next != NULL)
60911 + match->next->prev = NULL;
60912 + } else {
60913 + match->prev->next = match->next;
60914 + if (match->next != NULL)
60915 + match->next->prev = match->prev;
60916 + }
60917 + match->prev = NULL;
60918 + match->next = NULL;
60919 + match->inode = newinode;
60920 + match->device = newdevice;
60921 + match->mode &= ~GR_DELETED;
60922 +
60923 + insert_acl_subj_label(match, role);
60924 + }
60925 +
60926 + return;
60927 +}
60928 +
60929 +static void
60930 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60931 + const ino_t newinode, const dev_t newdevice)
60932 +{
60933 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60934 + struct inodev_entry *match;
60935 +
60936 + match = inodev_set.i_hash[index];
60937 +
60938 + while (match && (match->nentry->inode != oldinode ||
60939 + match->nentry->device != olddevice || !match->nentry->deleted))
60940 + match = match->next;
60941 +
60942 + if (match && (match->nentry->inode == oldinode)
60943 + && (match->nentry->device == olddevice) &&
60944 + match->nentry->deleted) {
60945 + if (match->prev == NULL) {
60946 + inodev_set.i_hash[index] = match->next;
60947 + if (match->next != NULL)
60948 + match->next->prev = NULL;
60949 + } else {
60950 + match->prev->next = match->next;
60951 + if (match->next != NULL)
60952 + match->next->prev = match->prev;
60953 + }
60954 + match->prev = NULL;
60955 + match->next = NULL;
60956 + match->nentry->inode = newinode;
60957 + match->nentry->device = newdevice;
60958 + match->nentry->deleted = 0;
60959 +
60960 + insert_inodev_entry(match);
60961 + }
60962 +
60963 + return;
60964 +}
60965 +
60966 +static void
60967 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60968 +{
60969 + struct acl_subject_label *subj;
60970 + struct acl_role_label *role;
60971 + unsigned int x;
60972 +
60973 + FOR_EACH_ROLE_START(role)
60974 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60975 +
60976 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60977 + if ((subj->inode == ino) && (subj->device == dev)) {
60978 + subj->inode = ino;
60979 + subj->device = dev;
60980 + }
60981 + /* nested subjects aren't in the role's subj_hash table */
60982 + update_acl_obj_label(matchn->inode, matchn->device,
60983 + ino, dev, subj);
60984 + FOR_EACH_NESTED_SUBJECT_END(subj)
60985 + FOR_EACH_SUBJECT_START(role, subj, x)
60986 + update_acl_obj_label(matchn->inode, matchn->device,
60987 + ino, dev, subj);
60988 + FOR_EACH_SUBJECT_END(subj,x)
60989 + FOR_EACH_ROLE_END(role)
60990 +
60991 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60992 +
60993 + return;
60994 +}
60995 +
60996 +static void
60997 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60998 + const struct vfsmount *mnt)
60999 +{
61000 + ino_t ino = dentry->d_inode->i_ino;
61001 + dev_t dev = __get_dev(dentry);
61002 +
61003 + __do_handle_create(matchn, ino, dev);
61004 +
61005 + return;
61006 +}
61007 +
61008 +void
61009 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
61010 +{
61011 + struct name_entry *matchn;
61012 +
61013 + if (unlikely(!(gr_status & GR_READY)))
61014 + return;
61015 +
61016 + preempt_disable();
61017 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
61018 +
61019 + if (unlikely((unsigned long)matchn)) {
61020 + write_lock(&gr_inode_lock);
61021 + do_handle_create(matchn, dentry, mnt);
61022 + write_unlock(&gr_inode_lock);
61023 + }
61024 + preempt_enable();
61025 +
61026 + return;
61027 +}
61028 +
61029 +void
61030 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61031 +{
61032 + struct name_entry *matchn;
61033 +
61034 + if (unlikely(!(gr_status & GR_READY)))
61035 + return;
61036 +
61037 + preempt_disable();
61038 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61039 +
61040 + if (unlikely((unsigned long)matchn)) {
61041 + write_lock(&gr_inode_lock);
61042 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61043 + write_unlock(&gr_inode_lock);
61044 + }
61045 + preempt_enable();
61046 +
61047 + return;
61048 +}
61049 +
61050 +void
61051 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61052 + struct dentry *old_dentry,
61053 + struct dentry *new_dentry,
61054 + struct vfsmount *mnt, const __u8 replace)
61055 +{
61056 + struct name_entry *matchn;
61057 + struct inodev_entry *inodev;
61058 + struct inode *inode = new_dentry->d_inode;
61059 + ino_t old_ino = old_dentry->d_inode->i_ino;
61060 + dev_t old_dev = __get_dev(old_dentry);
61061 +
61062 + /* vfs_rename swaps the name and parent link for old_dentry and
61063 + new_dentry
61064 + at this point, old_dentry has the new name, parent link, and inode
61065 + for the renamed file
61066 + if a file is being replaced by a rename, new_dentry has the inode
61067 + and name for the replaced file
61068 + */
61069 +
61070 + if (unlikely(!(gr_status & GR_READY)))
61071 + return;
61072 +
61073 + preempt_disable();
61074 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61075 +
61076 + /* we wouldn't have to check d_inode if it weren't for
61077 + NFS silly-renaming
61078 + */
61079 +
61080 + write_lock(&gr_inode_lock);
61081 + if (unlikely(replace && inode)) {
61082 + ino_t new_ino = inode->i_ino;
61083 + dev_t new_dev = __get_dev(new_dentry);
61084 +
61085 + inodev = lookup_inodev_entry(new_ino, new_dev);
61086 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61087 + do_handle_delete(inodev, new_ino, new_dev);
61088 + }
61089 +
61090 + inodev = lookup_inodev_entry(old_ino, old_dev);
61091 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61092 + do_handle_delete(inodev, old_ino, old_dev);
61093 +
61094 + if (unlikely((unsigned long)matchn))
61095 + do_handle_create(matchn, old_dentry, mnt);
61096 +
61097 + write_unlock(&gr_inode_lock);
61098 + preempt_enable();
61099 +
61100 + return;
61101 +}
61102 +
61103 +static int
61104 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61105 + unsigned char **sum)
61106 +{
61107 + struct acl_role_label *r;
61108 + struct role_allowed_ip *ipp;
61109 + struct role_transition *trans;
61110 + unsigned int i;
61111 + int found = 0;
61112 + u32 curr_ip = current->signal->curr_ip;
61113 +
61114 + current->signal->saved_ip = curr_ip;
61115 +
61116 + /* check transition table */
61117 +
61118 + for (trans = current->role->transitions; trans; trans = trans->next) {
61119 + if (!strcmp(rolename, trans->rolename)) {
61120 + found = 1;
61121 + break;
61122 + }
61123 + }
61124 +
61125 + if (!found)
61126 + return 0;
61127 +
61128 + /* handle special roles that do not require authentication
61129 + and check ip */
61130 +
61131 + FOR_EACH_ROLE_START(r)
61132 + if (!strcmp(rolename, r->rolename) &&
61133 + (r->roletype & GR_ROLE_SPECIAL)) {
61134 + found = 0;
61135 + if (r->allowed_ips != NULL) {
61136 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61137 + if ((ntohl(curr_ip) & ipp->netmask) ==
61138 + (ntohl(ipp->addr) & ipp->netmask))
61139 + found = 1;
61140 + }
61141 + } else
61142 + found = 2;
61143 + if (!found)
61144 + return 0;
61145 +
61146 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61147 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61148 + *salt = NULL;
61149 + *sum = NULL;
61150 + return 1;
61151 + }
61152 + }
61153 + FOR_EACH_ROLE_END(r)
61154 +
61155 + for (i = 0; i < num_sprole_pws; i++) {
61156 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61157 + *salt = acl_special_roles[i]->salt;
61158 + *sum = acl_special_roles[i]->sum;
61159 + return 1;
61160 + }
61161 + }
61162 +
61163 + return 0;
61164 +}
61165 +
61166 +static void
61167 +assign_special_role(char *rolename)
61168 +{
61169 + struct acl_object_label *obj;
61170 + struct acl_role_label *r;
61171 + struct acl_role_label *assigned = NULL;
61172 + struct task_struct *tsk;
61173 + struct file *filp;
61174 +
61175 + FOR_EACH_ROLE_START(r)
61176 + if (!strcmp(rolename, r->rolename) &&
61177 + (r->roletype & GR_ROLE_SPECIAL)) {
61178 + assigned = r;
61179 + break;
61180 + }
61181 + FOR_EACH_ROLE_END(r)
61182 +
61183 + if (!assigned)
61184 + return;
61185 +
61186 + read_lock(&tasklist_lock);
61187 + read_lock(&grsec_exec_file_lock);
61188 +
61189 + tsk = current->real_parent;
61190 + if (tsk == NULL)
61191 + goto out_unlock;
61192 +
61193 + filp = tsk->exec_file;
61194 + if (filp == NULL)
61195 + goto out_unlock;
61196 +
61197 + tsk->is_writable = 0;
61198 +
61199 + tsk->acl_sp_role = 1;
61200 + tsk->acl_role_id = ++acl_sp_role_value;
61201 + tsk->role = assigned;
61202 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61203 +
61204 + /* ignore additional mmap checks for processes that are writable
61205 + by the default ACL */
61206 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61207 + if (unlikely(obj->mode & GR_WRITE))
61208 + tsk->is_writable = 1;
61209 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61210 + if (unlikely(obj->mode & GR_WRITE))
61211 + tsk->is_writable = 1;
61212 +
61213 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61214 + 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));
61215 +#endif
61216 +
61217 +out_unlock:
61218 + read_unlock(&grsec_exec_file_lock);
61219 + read_unlock(&tasklist_lock);
61220 + return;
61221 +}
61222 +
61223 +int gr_check_secure_terminal(struct task_struct *task)
61224 +{
61225 + struct task_struct *p, *p2, *p3;
61226 + struct files_struct *files;
61227 + struct fdtable *fdt;
61228 + struct file *our_file = NULL, *file;
61229 + int i;
61230 +
61231 + if (task->signal->tty == NULL)
61232 + return 1;
61233 +
61234 + files = get_files_struct(task);
61235 + if (files != NULL) {
61236 + rcu_read_lock();
61237 + fdt = files_fdtable(files);
61238 + for (i=0; i < fdt->max_fds; i++) {
61239 + file = fcheck_files(files, i);
61240 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61241 + get_file(file);
61242 + our_file = file;
61243 + }
61244 + }
61245 + rcu_read_unlock();
61246 + put_files_struct(files);
61247 + }
61248 +
61249 + if (our_file == NULL)
61250 + return 1;
61251 +
61252 + read_lock(&tasklist_lock);
61253 + do_each_thread(p2, p) {
61254 + files = get_files_struct(p);
61255 + if (files == NULL ||
61256 + (p->signal && p->signal->tty == task->signal->tty)) {
61257 + if (files != NULL)
61258 + put_files_struct(files);
61259 + continue;
61260 + }
61261 + rcu_read_lock();
61262 + fdt = files_fdtable(files);
61263 + for (i=0; i < fdt->max_fds; i++) {
61264 + file = fcheck_files(files, i);
61265 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61266 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61267 + p3 = task;
61268 + while (task_pid_nr(p3) > 0) {
61269 + if (p3 == p)
61270 + break;
61271 + p3 = p3->real_parent;
61272 + }
61273 + if (p3 == p)
61274 + break;
61275 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61276 + gr_handle_alertkill(p);
61277 + rcu_read_unlock();
61278 + put_files_struct(files);
61279 + read_unlock(&tasklist_lock);
61280 + fput(our_file);
61281 + return 0;
61282 + }
61283 + }
61284 + rcu_read_unlock();
61285 + put_files_struct(files);
61286 + } while_each_thread(p2, p);
61287 + read_unlock(&tasklist_lock);
61288 +
61289 + fput(our_file);
61290 + return 1;
61291 +}
61292 +
61293 +static int gr_rbac_disable(void *unused)
61294 +{
61295 + pax_open_kernel();
61296 + gr_status &= ~GR_READY;
61297 + pax_close_kernel();
61298 +
61299 + return 0;
61300 +}
61301 +
61302 +ssize_t
61303 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61304 +{
61305 + struct gr_arg_wrapper uwrap;
61306 + unsigned char *sprole_salt = NULL;
61307 + unsigned char *sprole_sum = NULL;
61308 + int error = sizeof (struct gr_arg_wrapper);
61309 + int error2 = 0;
61310 +
61311 + mutex_lock(&gr_dev_mutex);
61312 +
61313 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61314 + error = -EPERM;
61315 + goto out;
61316 + }
61317 +
61318 + if (count != sizeof (struct gr_arg_wrapper)) {
61319 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61320 + error = -EINVAL;
61321 + goto out;
61322 + }
61323 +
61324 +
61325 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61326 + gr_auth_expires = 0;
61327 + gr_auth_attempts = 0;
61328 + }
61329 +
61330 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61331 + error = -EFAULT;
61332 + goto out;
61333 + }
61334 +
61335 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61336 + error = -EINVAL;
61337 + goto out;
61338 + }
61339 +
61340 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61341 + error = -EFAULT;
61342 + goto out;
61343 + }
61344 +
61345 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61346 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61347 + time_after(gr_auth_expires, get_seconds())) {
61348 + error = -EBUSY;
61349 + goto out;
61350 + }
61351 +
61352 + /* if non-root trying to do anything other than use a special role,
61353 + do not attempt authentication, do not count towards authentication
61354 + locking
61355 + */
61356 +
61357 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61358 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61359 + gr_is_global_nonroot(current_uid())) {
61360 + error = -EPERM;
61361 + goto out;
61362 + }
61363 +
61364 + /* ensure pw and special role name are null terminated */
61365 +
61366 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61367 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61368 +
61369 + /* Okay.
61370 + * We have our enough of the argument structure..(we have yet
61371 + * to copy_from_user the tables themselves) . Copy the tables
61372 + * only if we need them, i.e. for loading operations. */
61373 +
61374 + switch (gr_usermode->mode) {
61375 + case GR_STATUS:
61376 + if (gr_status & GR_READY) {
61377 + error = 1;
61378 + if (!gr_check_secure_terminal(current))
61379 + error = 3;
61380 + } else
61381 + error = 2;
61382 + goto out;
61383 + case GR_SHUTDOWN:
61384 + if ((gr_status & GR_READY)
61385 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61386 + stop_machine(gr_rbac_disable, NULL, NULL);
61387 + free_variables();
61388 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61389 + memset(gr_system_salt, 0, GR_SALT_LEN);
61390 + memset(gr_system_sum, 0, GR_SHA_LEN);
61391 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61392 + } else if (gr_status & GR_READY) {
61393 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61394 + error = -EPERM;
61395 + } else {
61396 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61397 + error = -EAGAIN;
61398 + }
61399 + break;
61400 + case GR_ENABLE:
61401 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61402 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61403 + else {
61404 + if (gr_status & GR_READY)
61405 + error = -EAGAIN;
61406 + else
61407 + error = error2;
61408 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61409 + }
61410 + break;
61411 + case GR_RELOAD:
61412 + if (!(gr_status & GR_READY)) {
61413 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61414 + error = -EAGAIN;
61415 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61416 + stop_machine(gr_rbac_disable, NULL, NULL);
61417 + free_variables();
61418 + error2 = gracl_init(gr_usermode);
61419 + if (!error2)
61420 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61421 + else {
61422 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61423 + error = error2;
61424 + }
61425 + } else {
61426 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61427 + error = -EPERM;
61428 + }
61429 + break;
61430 + case GR_SEGVMOD:
61431 + if (unlikely(!(gr_status & GR_READY))) {
61432 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61433 + error = -EAGAIN;
61434 + break;
61435 + }
61436 +
61437 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61438 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61439 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61440 + struct acl_subject_label *segvacl;
61441 + segvacl =
61442 + lookup_acl_subj_label(gr_usermode->segv_inode,
61443 + gr_usermode->segv_device,
61444 + current->role);
61445 + if (segvacl) {
61446 + segvacl->crashes = 0;
61447 + segvacl->expires = 0;
61448 + }
61449 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61450 + gr_remove_uid(gr_usermode->segv_uid);
61451 + }
61452 + } else {
61453 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61454 + error = -EPERM;
61455 + }
61456 + break;
61457 + case GR_SPROLE:
61458 + case GR_SPROLEPAM:
61459 + if (unlikely(!(gr_status & GR_READY))) {
61460 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61461 + error = -EAGAIN;
61462 + break;
61463 + }
61464 +
61465 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61466 + current->role->expires = 0;
61467 + current->role->auth_attempts = 0;
61468 + }
61469 +
61470 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61471 + time_after(current->role->expires, get_seconds())) {
61472 + error = -EBUSY;
61473 + goto out;
61474 + }
61475 +
61476 + if (lookup_special_role_auth
61477 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61478 + && ((!sprole_salt && !sprole_sum)
61479 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61480 + char *p = "";
61481 + assign_special_role(gr_usermode->sp_role);
61482 + read_lock(&tasklist_lock);
61483 + if (current->real_parent)
61484 + p = current->real_parent->role->rolename;
61485 + read_unlock(&tasklist_lock);
61486 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61487 + p, acl_sp_role_value);
61488 + } else {
61489 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61490 + error = -EPERM;
61491 + if(!(current->role->auth_attempts++))
61492 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61493 +
61494 + goto out;
61495 + }
61496 + break;
61497 + case GR_UNSPROLE:
61498 + if (unlikely(!(gr_status & GR_READY))) {
61499 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61500 + error = -EAGAIN;
61501 + break;
61502 + }
61503 +
61504 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61505 + char *p = "";
61506 + int i = 0;
61507 +
61508 + read_lock(&tasklist_lock);
61509 + if (current->real_parent) {
61510 + p = current->real_parent->role->rolename;
61511 + i = current->real_parent->acl_role_id;
61512 + }
61513 + read_unlock(&tasklist_lock);
61514 +
61515 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61516 + gr_set_acls(1);
61517 + } else {
61518 + error = -EPERM;
61519 + goto out;
61520 + }
61521 + break;
61522 + default:
61523 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61524 + error = -EINVAL;
61525 + break;
61526 + }
61527 +
61528 + if (error != -EPERM)
61529 + goto out;
61530 +
61531 + if(!(gr_auth_attempts++))
61532 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61533 +
61534 + out:
61535 + mutex_unlock(&gr_dev_mutex);
61536 + return error;
61537 +}
61538 +
61539 +/* must be called with
61540 + rcu_read_lock();
61541 + read_lock(&tasklist_lock);
61542 + read_lock(&grsec_exec_file_lock);
61543 +*/
61544 +int gr_apply_subject_to_task(struct task_struct *task)
61545 +{
61546 + struct acl_object_label *obj;
61547 + char *tmpname;
61548 + struct acl_subject_label *tmpsubj;
61549 + struct file *filp;
61550 + struct name_entry *nmatch;
61551 +
61552 + filp = task->exec_file;
61553 + if (filp == NULL)
61554 + return 0;
61555 +
61556 + /* the following is to apply the correct subject
61557 + on binaries running when the RBAC system
61558 + is enabled, when the binaries have been
61559 + replaced or deleted since their execution
61560 + -----
61561 + when the RBAC system starts, the inode/dev
61562 + from exec_file will be one the RBAC system
61563 + is unaware of. It only knows the inode/dev
61564 + of the present file on disk, or the absence
61565 + of it.
61566 + */
61567 + preempt_disable();
61568 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61569 +
61570 + nmatch = lookup_name_entry(tmpname);
61571 + preempt_enable();
61572 + tmpsubj = NULL;
61573 + if (nmatch) {
61574 + if (nmatch->deleted)
61575 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61576 + else
61577 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61578 + if (tmpsubj != NULL)
61579 + task->acl = tmpsubj;
61580 + }
61581 + if (tmpsubj == NULL)
61582 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61583 + task->role);
61584 + if (task->acl) {
61585 + task->is_writable = 0;
61586 + /* ignore additional mmap checks for processes that are writable
61587 + by the default ACL */
61588 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61589 + if (unlikely(obj->mode & GR_WRITE))
61590 + task->is_writable = 1;
61591 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61592 + if (unlikely(obj->mode & GR_WRITE))
61593 + task->is_writable = 1;
61594 +
61595 + gr_set_proc_res(task);
61596 +
61597 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61598 + 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);
61599 +#endif
61600 + } else {
61601 + return 1;
61602 + }
61603 +
61604 + return 0;
61605 +}
61606 +
61607 +int
61608 +gr_set_acls(const int type)
61609 +{
61610 + struct task_struct *task, *task2;
61611 + struct acl_role_label *role = current->role;
61612 + __u16 acl_role_id = current->acl_role_id;
61613 + const struct cred *cred;
61614 + int ret;
61615 +
61616 + rcu_read_lock();
61617 + read_lock(&tasklist_lock);
61618 + read_lock(&grsec_exec_file_lock);
61619 + do_each_thread(task2, task) {
61620 + /* check to see if we're called from the exit handler,
61621 + if so, only replace ACLs that have inherited the admin
61622 + ACL */
61623 +
61624 + if (type && (task->role != role ||
61625 + task->acl_role_id != acl_role_id))
61626 + continue;
61627 +
61628 + task->acl_role_id = 0;
61629 + task->acl_sp_role = 0;
61630 +
61631 + if (task->exec_file) {
61632 + cred = __task_cred(task);
61633 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61634 + ret = gr_apply_subject_to_task(task);
61635 + if (ret) {
61636 + read_unlock(&grsec_exec_file_lock);
61637 + read_unlock(&tasklist_lock);
61638 + rcu_read_unlock();
61639 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61640 + return ret;
61641 + }
61642 + } else {
61643 + // it's a kernel process
61644 + task->role = kernel_role;
61645 + task->acl = kernel_role->root_label;
61646 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61647 + task->acl->mode &= ~GR_PROCFIND;
61648 +#endif
61649 + }
61650 + } while_each_thread(task2, task);
61651 + read_unlock(&grsec_exec_file_lock);
61652 + read_unlock(&tasklist_lock);
61653 + rcu_read_unlock();
61654 +
61655 + return 0;
61656 +}
61657 +
61658 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61659 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61660 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61661 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61662 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61663 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61664 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61665 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61666 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61667 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61668 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61669 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61670 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61671 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61672 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61673 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61674 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61675 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61676 +};
61677 +
61678 +void
61679 +gr_learn_resource(const struct task_struct *task,
61680 + const int res, const unsigned long wanted, const int gt)
61681 +{
61682 + struct acl_subject_label *acl;
61683 + const struct cred *cred;
61684 +
61685 + if (unlikely((gr_status & GR_READY) &&
61686 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61687 + goto skip_reslog;
61688 +
61689 + gr_log_resource(task, res, wanted, gt);
61690 +skip_reslog:
61691 +
61692 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61693 + return;
61694 +
61695 + acl = task->acl;
61696 +
61697 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61698 + !(acl->resmask & (1U << (unsigned short) res))))
61699 + return;
61700 +
61701 + if (wanted >= acl->res[res].rlim_cur) {
61702 + unsigned long res_add;
61703 +
61704 + res_add = wanted + res_learn_bumps[res];
61705 +
61706 + acl->res[res].rlim_cur = res_add;
61707 +
61708 + if (wanted > acl->res[res].rlim_max)
61709 + acl->res[res].rlim_max = res_add;
61710 +
61711 + /* only log the subject filename, since resource logging is supported for
61712 + single-subject learning only */
61713 + rcu_read_lock();
61714 + cred = __task_cred(task);
61715 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61716 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61717 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61718 + "", (unsigned long) res, &task->signal->saved_ip);
61719 + rcu_read_unlock();
61720 + }
61721 +
61722 + return;
61723 +}
61724 +EXPORT_SYMBOL(gr_learn_resource);
61725 +#endif
61726 +
61727 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61728 +void
61729 +pax_set_initial_flags(struct linux_binprm *bprm)
61730 +{
61731 + struct task_struct *task = current;
61732 + struct acl_subject_label *proc;
61733 + unsigned long flags;
61734 +
61735 + if (unlikely(!(gr_status & GR_READY)))
61736 + return;
61737 +
61738 + flags = pax_get_flags(task);
61739 +
61740 + proc = task->acl;
61741 +
61742 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61743 + flags &= ~MF_PAX_PAGEEXEC;
61744 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61745 + flags &= ~MF_PAX_SEGMEXEC;
61746 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61747 + flags &= ~MF_PAX_RANDMMAP;
61748 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61749 + flags &= ~MF_PAX_EMUTRAMP;
61750 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61751 + flags &= ~MF_PAX_MPROTECT;
61752 +
61753 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61754 + flags |= MF_PAX_PAGEEXEC;
61755 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61756 + flags |= MF_PAX_SEGMEXEC;
61757 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61758 + flags |= MF_PAX_RANDMMAP;
61759 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61760 + flags |= MF_PAX_EMUTRAMP;
61761 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61762 + flags |= MF_PAX_MPROTECT;
61763 +
61764 + pax_set_flags(task, flags);
61765 +
61766 + return;
61767 +}
61768 +#endif
61769 +
61770 +int
61771 +gr_handle_proc_ptrace(struct task_struct *task)
61772 +{
61773 + struct file *filp;
61774 + struct task_struct *tmp = task;
61775 + struct task_struct *curtemp = current;
61776 + __u32 retmode;
61777 +
61778 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61779 + if (unlikely(!(gr_status & GR_READY)))
61780 + return 0;
61781 +#endif
61782 +
61783 + read_lock(&tasklist_lock);
61784 + read_lock(&grsec_exec_file_lock);
61785 + filp = task->exec_file;
61786 +
61787 + while (task_pid_nr(tmp) > 0) {
61788 + if (tmp == curtemp)
61789 + break;
61790 + tmp = tmp->real_parent;
61791 + }
61792 +
61793 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61794 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61795 + read_unlock(&grsec_exec_file_lock);
61796 + read_unlock(&tasklist_lock);
61797 + return 1;
61798 + }
61799 +
61800 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61801 + if (!(gr_status & GR_READY)) {
61802 + read_unlock(&grsec_exec_file_lock);
61803 + read_unlock(&tasklist_lock);
61804 + return 0;
61805 + }
61806 +#endif
61807 +
61808 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61809 + read_unlock(&grsec_exec_file_lock);
61810 + read_unlock(&tasklist_lock);
61811 +
61812 + if (retmode & GR_NOPTRACE)
61813 + return 1;
61814 +
61815 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61816 + && (current->acl != task->acl || (current->acl != current->role->root_label
61817 + && task_pid_nr(current) != task_pid_nr(task))))
61818 + return 1;
61819 +
61820 + return 0;
61821 +}
61822 +
61823 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61824 +{
61825 + if (unlikely(!(gr_status & GR_READY)))
61826 + return;
61827 +
61828 + if (!(current->role->roletype & GR_ROLE_GOD))
61829 + return;
61830 +
61831 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61832 + p->role->rolename, gr_task_roletype_to_char(p),
61833 + p->acl->filename);
61834 +}
61835 +
61836 +int
61837 +gr_handle_ptrace(struct task_struct *task, const long request)
61838 +{
61839 + struct task_struct *tmp = task;
61840 + struct task_struct *curtemp = current;
61841 + __u32 retmode;
61842 +
61843 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61844 + if (unlikely(!(gr_status & GR_READY)))
61845 + return 0;
61846 +#endif
61847 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61848 + read_lock(&tasklist_lock);
61849 + while (task_pid_nr(tmp) > 0) {
61850 + if (tmp == curtemp)
61851 + break;
61852 + tmp = tmp->real_parent;
61853 + }
61854 +
61855 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61856 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61857 + read_unlock(&tasklist_lock);
61858 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61859 + return 1;
61860 + }
61861 + read_unlock(&tasklist_lock);
61862 + }
61863 +
61864 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61865 + if (!(gr_status & GR_READY))
61866 + return 0;
61867 +#endif
61868 +
61869 + read_lock(&grsec_exec_file_lock);
61870 + if (unlikely(!task->exec_file)) {
61871 + read_unlock(&grsec_exec_file_lock);
61872 + return 0;
61873 + }
61874 +
61875 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61876 + read_unlock(&grsec_exec_file_lock);
61877 +
61878 + if (retmode & GR_NOPTRACE) {
61879 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61880 + return 1;
61881 + }
61882 +
61883 + if (retmode & GR_PTRACERD) {
61884 + switch (request) {
61885 + case PTRACE_SEIZE:
61886 + case PTRACE_POKETEXT:
61887 + case PTRACE_POKEDATA:
61888 + case PTRACE_POKEUSR:
61889 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61890 + case PTRACE_SETREGS:
61891 + case PTRACE_SETFPREGS:
61892 +#endif
61893 +#ifdef CONFIG_X86
61894 + case PTRACE_SETFPXREGS:
61895 +#endif
61896 +#ifdef CONFIG_ALTIVEC
61897 + case PTRACE_SETVRREGS:
61898 +#endif
61899 + return 1;
61900 + default:
61901 + return 0;
61902 + }
61903 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61904 + !(current->role->roletype & GR_ROLE_GOD) &&
61905 + (current->acl != task->acl)) {
61906 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61907 + return 1;
61908 + }
61909 +
61910 + return 0;
61911 +}
61912 +
61913 +static int is_writable_mmap(const struct file *filp)
61914 +{
61915 + struct task_struct *task = current;
61916 + struct acl_object_label *obj, *obj2;
61917 +
61918 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61919 + !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))) {
61920 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61921 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61922 + task->role->root_label);
61923 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61924 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61925 + return 1;
61926 + }
61927 + }
61928 + return 0;
61929 +}
61930 +
61931 +int
61932 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61933 +{
61934 + __u32 mode;
61935 +
61936 + if (unlikely(!file || !(prot & PROT_EXEC)))
61937 + return 1;
61938 +
61939 + if (is_writable_mmap(file))
61940 + return 0;
61941 +
61942 + mode =
61943 + gr_search_file(file->f_path.dentry,
61944 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61945 + file->f_path.mnt);
61946 +
61947 + if (!gr_tpe_allow(file))
61948 + return 0;
61949 +
61950 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61951 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61952 + return 0;
61953 + } else if (unlikely(!(mode & GR_EXEC))) {
61954 + return 0;
61955 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61956 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61957 + return 1;
61958 + }
61959 +
61960 + return 1;
61961 +}
61962 +
61963 +int
61964 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61965 +{
61966 + __u32 mode;
61967 +
61968 + if (unlikely(!file || !(prot & PROT_EXEC)))
61969 + return 1;
61970 +
61971 + if (is_writable_mmap(file))
61972 + return 0;
61973 +
61974 + mode =
61975 + gr_search_file(file->f_path.dentry,
61976 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61977 + file->f_path.mnt);
61978 +
61979 + if (!gr_tpe_allow(file))
61980 + return 0;
61981 +
61982 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61983 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61984 + return 0;
61985 + } else if (unlikely(!(mode & GR_EXEC))) {
61986 + return 0;
61987 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61988 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61989 + return 1;
61990 + }
61991 +
61992 + return 1;
61993 +}
61994 +
61995 +void
61996 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61997 +{
61998 + unsigned long runtime;
61999 + unsigned long cputime;
62000 + unsigned int wday, cday;
62001 + __u8 whr, chr;
62002 + __u8 wmin, cmin;
62003 + __u8 wsec, csec;
62004 + struct timespec timeval;
62005 +
62006 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
62007 + !(task->acl->mode & GR_PROCACCT)))
62008 + return;
62009 +
62010 + do_posix_clock_monotonic_gettime(&timeval);
62011 + runtime = timeval.tv_sec - task->start_time.tv_sec;
62012 + wday = runtime / (3600 * 24);
62013 + runtime -= wday * (3600 * 24);
62014 + whr = runtime / 3600;
62015 + runtime -= whr * 3600;
62016 + wmin = runtime / 60;
62017 + runtime -= wmin * 60;
62018 + wsec = runtime;
62019 +
62020 + cputime = (task->utime + task->stime) / HZ;
62021 + cday = cputime / (3600 * 24);
62022 + cputime -= cday * (3600 * 24);
62023 + chr = cputime / 3600;
62024 + cputime -= chr * 3600;
62025 + cmin = cputime / 60;
62026 + cputime -= cmin * 60;
62027 + csec = cputime;
62028 +
62029 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62030 +
62031 + return;
62032 +}
62033 +
62034 +void gr_set_kernel_label(struct task_struct *task)
62035 +{
62036 + if (gr_status & GR_READY) {
62037 + task->role = kernel_role;
62038 + task->acl = kernel_role->root_label;
62039 + }
62040 + return;
62041 +}
62042 +
62043 +#ifdef CONFIG_TASKSTATS
62044 +int gr_is_taskstats_denied(int pid)
62045 +{
62046 + struct task_struct *task;
62047 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62048 + const struct cred *cred;
62049 +#endif
62050 + int ret = 0;
62051 +
62052 + /* restrict taskstats viewing to un-chrooted root users
62053 + who have the 'view' subject flag if the RBAC system is enabled
62054 + */
62055 +
62056 + rcu_read_lock();
62057 + read_lock(&tasklist_lock);
62058 + task = find_task_by_vpid(pid);
62059 + if (task) {
62060 +#ifdef CONFIG_GRKERNSEC_CHROOT
62061 + if (proc_is_chrooted(task))
62062 + ret = -EACCES;
62063 +#endif
62064 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62065 + cred = __task_cred(task);
62066 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62067 + if (gr_is_global_nonroot(cred->uid))
62068 + ret = -EACCES;
62069 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62070 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62071 + ret = -EACCES;
62072 +#endif
62073 +#endif
62074 + if (gr_status & GR_READY) {
62075 + if (!(task->acl->mode & GR_VIEW))
62076 + ret = -EACCES;
62077 + }
62078 + } else
62079 + ret = -ENOENT;
62080 +
62081 + read_unlock(&tasklist_lock);
62082 + rcu_read_unlock();
62083 +
62084 + return ret;
62085 +}
62086 +#endif
62087 +
62088 +/* AUXV entries are filled via a descendant of search_binary_handler
62089 + after we've already applied the subject for the target
62090 +*/
62091 +int gr_acl_enable_at_secure(void)
62092 +{
62093 + if (unlikely(!(gr_status & GR_READY)))
62094 + return 0;
62095 +
62096 + if (current->acl->mode & GR_ATSECURE)
62097 + return 1;
62098 +
62099 + return 0;
62100 +}
62101 +
62102 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62103 +{
62104 + struct task_struct *task = current;
62105 + struct dentry *dentry = file->f_path.dentry;
62106 + struct vfsmount *mnt = file->f_path.mnt;
62107 + struct acl_object_label *obj, *tmp;
62108 + struct acl_subject_label *subj;
62109 + unsigned int bufsize;
62110 + int is_not_root;
62111 + char *path;
62112 + dev_t dev = __get_dev(dentry);
62113 +
62114 + if (unlikely(!(gr_status & GR_READY)))
62115 + return 1;
62116 +
62117 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62118 + return 1;
62119 +
62120 + /* ignore Eric Biederman */
62121 + if (IS_PRIVATE(dentry->d_inode))
62122 + return 1;
62123 +
62124 + subj = task->acl;
62125 + read_lock(&gr_inode_lock);
62126 + do {
62127 + obj = lookup_acl_obj_label(ino, dev, subj);
62128 + if (obj != NULL) {
62129 + read_unlock(&gr_inode_lock);
62130 + return (obj->mode & GR_FIND) ? 1 : 0;
62131 + }
62132 + } while ((subj = subj->parent_subject));
62133 + read_unlock(&gr_inode_lock);
62134 +
62135 + /* this is purely an optimization since we're looking for an object
62136 + for the directory we're doing a readdir on
62137 + if it's possible for any globbed object to match the entry we're
62138 + filling into the directory, then the object we find here will be
62139 + an anchor point with attached globbed objects
62140 + */
62141 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62142 + if (obj->globbed == NULL)
62143 + return (obj->mode & GR_FIND) ? 1 : 0;
62144 +
62145 + is_not_root = ((obj->filename[0] == '/') &&
62146 + (obj->filename[1] == '\0')) ? 0 : 1;
62147 + bufsize = PAGE_SIZE - namelen - is_not_root;
62148 +
62149 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62150 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62151 + return 1;
62152 +
62153 + preempt_disable();
62154 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62155 + bufsize);
62156 +
62157 + bufsize = strlen(path);
62158 +
62159 + /* if base is "/", don't append an additional slash */
62160 + if (is_not_root)
62161 + *(path + bufsize) = '/';
62162 + memcpy(path + bufsize + is_not_root, name, namelen);
62163 + *(path + bufsize + namelen + is_not_root) = '\0';
62164 +
62165 + tmp = obj->globbed;
62166 + while (tmp) {
62167 + if (!glob_match(tmp->filename, path)) {
62168 + preempt_enable();
62169 + return (tmp->mode & GR_FIND) ? 1 : 0;
62170 + }
62171 + tmp = tmp->next;
62172 + }
62173 + preempt_enable();
62174 + return (obj->mode & GR_FIND) ? 1 : 0;
62175 +}
62176 +
62177 +void gr_put_exec_file(struct task_struct *task)
62178 +{
62179 + struct file *filp;
62180 +
62181 + write_lock(&grsec_exec_file_lock);
62182 + filp = task->exec_file;
62183 + task->exec_file = NULL;
62184 + write_unlock(&grsec_exec_file_lock);
62185 +
62186 + if (filp)
62187 + fput(filp);
62188 +
62189 + return;
62190 +}
62191 +
62192 +
62193 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62194 +EXPORT_SYMBOL(gr_acl_is_enabled);
62195 +#endif
62196 +EXPORT_SYMBOL(gr_set_kernel_label);
62197 +#ifdef CONFIG_SECURITY
62198 +EXPORT_SYMBOL(gr_check_user_change);
62199 +EXPORT_SYMBOL(gr_check_group_change);
62200 +#endif
62201 +
62202 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62203 new file mode 100644
62204 index 0000000..34fefda
62205 --- /dev/null
62206 +++ b/grsecurity/gracl_alloc.c
62207 @@ -0,0 +1,105 @@
62208 +#include <linux/kernel.h>
62209 +#include <linux/mm.h>
62210 +#include <linux/slab.h>
62211 +#include <linux/vmalloc.h>
62212 +#include <linux/gracl.h>
62213 +#include <linux/grsecurity.h>
62214 +
62215 +static unsigned long alloc_stack_next = 1;
62216 +static unsigned long alloc_stack_size = 1;
62217 +static void **alloc_stack;
62218 +
62219 +static __inline__ int
62220 +alloc_pop(void)
62221 +{
62222 + if (alloc_stack_next == 1)
62223 + return 0;
62224 +
62225 + kfree(alloc_stack[alloc_stack_next - 2]);
62226 +
62227 + alloc_stack_next--;
62228 +
62229 + return 1;
62230 +}
62231 +
62232 +static __inline__ int
62233 +alloc_push(void *buf)
62234 +{
62235 + if (alloc_stack_next >= alloc_stack_size)
62236 + return 1;
62237 +
62238 + alloc_stack[alloc_stack_next - 1] = buf;
62239 +
62240 + alloc_stack_next++;
62241 +
62242 + return 0;
62243 +}
62244 +
62245 +void *
62246 +acl_alloc(unsigned long len)
62247 +{
62248 + void *ret = NULL;
62249 +
62250 + if (!len || len > PAGE_SIZE)
62251 + goto out;
62252 +
62253 + ret = kmalloc(len, GFP_KERNEL);
62254 +
62255 + if (ret) {
62256 + if (alloc_push(ret)) {
62257 + kfree(ret);
62258 + ret = NULL;
62259 + }
62260 + }
62261 +
62262 +out:
62263 + return ret;
62264 +}
62265 +
62266 +void *
62267 +acl_alloc_num(unsigned long num, unsigned long len)
62268 +{
62269 + if (!len || (num > (PAGE_SIZE / len)))
62270 + return NULL;
62271 +
62272 + return acl_alloc(num * len);
62273 +}
62274 +
62275 +void
62276 +acl_free_all(void)
62277 +{
62278 + if (gr_acl_is_enabled() || !alloc_stack)
62279 + return;
62280 +
62281 + while (alloc_pop()) ;
62282 +
62283 + if (alloc_stack) {
62284 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62285 + kfree(alloc_stack);
62286 + else
62287 + vfree(alloc_stack);
62288 + }
62289 +
62290 + alloc_stack = NULL;
62291 + alloc_stack_size = 1;
62292 + alloc_stack_next = 1;
62293 +
62294 + return;
62295 +}
62296 +
62297 +int
62298 +acl_alloc_stack_init(unsigned long size)
62299 +{
62300 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62301 + alloc_stack =
62302 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62303 + else
62304 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62305 +
62306 + alloc_stack_size = size;
62307 +
62308 + if (!alloc_stack)
62309 + return 0;
62310 + else
62311 + return 1;
62312 +}
62313 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62314 new file mode 100644
62315 index 0000000..bdd51ea
62316 --- /dev/null
62317 +++ b/grsecurity/gracl_cap.c
62318 @@ -0,0 +1,110 @@
62319 +#include <linux/kernel.h>
62320 +#include <linux/module.h>
62321 +#include <linux/sched.h>
62322 +#include <linux/gracl.h>
62323 +#include <linux/grsecurity.h>
62324 +#include <linux/grinternal.h>
62325 +
62326 +extern const char *captab_log[];
62327 +extern int captab_log_entries;
62328 +
62329 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62330 +{
62331 + struct acl_subject_label *curracl;
62332 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62333 + kernel_cap_t cap_audit = __cap_empty_set;
62334 +
62335 + if (!gr_acl_is_enabled())
62336 + return 1;
62337 +
62338 + curracl = task->acl;
62339 +
62340 + cap_drop = curracl->cap_lower;
62341 + cap_mask = curracl->cap_mask;
62342 + cap_audit = curracl->cap_invert_audit;
62343 +
62344 + while ((curracl = curracl->parent_subject)) {
62345 + /* if the cap isn't specified in the current computed mask but is specified in the
62346 + current level subject, and is lowered in the current level subject, then add
62347 + it to the set of dropped capabilities
62348 + otherwise, add the current level subject's mask to the current computed mask
62349 + */
62350 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62351 + cap_raise(cap_mask, cap);
62352 + if (cap_raised(curracl->cap_lower, cap))
62353 + cap_raise(cap_drop, cap);
62354 + if (cap_raised(curracl->cap_invert_audit, cap))
62355 + cap_raise(cap_audit, cap);
62356 + }
62357 + }
62358 +
62359 + if (!cap_raised(cap_drop, cap)) {
62360 + if (cap_raised(cap_audit, cap))
62361 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62362 + return 1;
62363 + }
62364 +
62365 + curracl = task->acl;
62366 +
62367 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62368 + && cap_raised(cred->cap_effective, cap)) {
62369 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62370 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62371 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62372 + gr_to_filename(task->exec_file->f_path.dentry,
62373 + task->exec_file->f_path.mnt) : curracl->filename,
62374 + curracl->filename, 0UL,
62375 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62376 + return 1;
62377 + }
62378 +
62379 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62380 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62381 +
62382 + return 0;
62383 +}
62384 +
62385 +int
62386 +gr_acl_is_capable(const int cap)
62387 +{
62388 + return gr_task_acl_is_capable(current, current_cred(), cap);
62389 +}
62390 +
62391 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62392 +{
62393 + struct acl_subject_label *curracl;
62394 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62395 +
62396 + if (!gr_acl_is_enabled())
62397 + return 1;
62398 +
62399 + curracl = task->acl;
62400 +
62401 + cap_drop = curracl->cap_lower;
62402 + cap_mask = curracl->cap_mask;
62403 +
62404 + while ((curracl = curracl->parent_subject)) {
62405 + /* if the cap isn't specified in the current computed mask but is specified in the
62406 + current level subject, and is lowered in the current level subject, then add
62407 + it to the set of dropped capabilities
62408 + otherwise, add the current level subject's mask to the current computed mask
62409 + */
62410 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62411 + cap_raise(cap_mask, cap);
62412 + if (cap_raised(curracl->cap_lower, cap))
62413 + cap_raise(cap_drop, cap);
62414 + }
62415 + }
62416 +
62417 + if (!cap_raised(cap_drop, cap))
62418 + return 1;
62419 +
62420 + return 0;
62421 +}
62422 +
62423 +int
62424 +gr_acl_is_capable_nolog(const int cap)
62425 +{
62426 + return gr_task_acl_is_capable_nolog(current, cap);
62427 +}
62428 +
62429 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62430 new file mode 100644
62431 index 0000000..a340c17
62432 --- /dev/null
62433 +++ b/grsecurity/gracl_fs.c
62434 @@ -0,0 +1,431 @@
62435 +#include <linux/kernel.h>
62436 +#include <linux/sched.h>
62437 +#include <linux/types.h>
62438 +#include <linux/fs.h>
62439 +#include <linux/file.h>
62440 +#include <linux/stat.h>
62441 +#include <linux/grsecurity.h>
62442 +#include <linux/grinternal.h>
62443 +#include <linux/gracl.h>
62444 +
62445 +umode_t
62446 +gr_acl_umask(void)
62447 +{
62448 + if (unlikely(!gr_acl_is_enabled()))
62449 + return 0;
62450 +
62451 + return current->role->umask;
62452 +}
62453 +
62454 +__u32
62455 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62456 + const struct vfsmount * mnt)
62457 +{
62458 + __u32 mode;
62459 +
62460 + if (unlikely(!dentry->d_inode))
62461 + return GR_FIND;
62462 +
62463 + mode =
62464 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62465 +
62466 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62467 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62468 + return mode;
62469 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62470 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62471 + return 0;
62472 + } else if (unlikely(!(mode & GR_FIND)))
62473 + return 0;
62474 +
62475 + return GR_FIND;
62476 +}
62477 +
62478 +__u32
62479 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62480 + int acc_mode)
62481 +{
62482 + __u32 reqmode = GR_FIND;
62483 + __u32 mode;
62484 +
62485 + if (unlikely(!dentry->d_inode))
62486 + return reqmode;
62487 +
62488 + if (acc_mode & MAY_APPEND)
62489 + reqmode |= GR_APPEND;
62490 + else if (acc_mode & MAY_WRITE)
62491 + reqmode |= GR_WRITE;
62492 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62493 + reqmode |= GR_READ;
62494 +
62495 + mode =
62496 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62497 + mnt);
62498 +
62499 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62500 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62501 + reqmode & GR_READ ? " reading" : "",
62502 + reqmode & GR_WRITE ? " writing" : reqmode &
62503 + GR_APPEND ? " appending" : "");
62504 + return reqmode;
62505 + } else
62506 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62507 + {
62508 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62509 + reqmode & GR_READ ? " reading" : "",
62510 + reqmode & GR_WRITE ? " writing" : reqmode &
62511 + GR_APPEND ? " appending" : "");
62512 + return 0;
62513 + } else if (unlikely((mode & reqmode) != reqmode))
62514 + return 0;
62515 +
62516 + return reqmode;
62517 +}
62518 +
62519 +__u32
62520 +gr_acl_handle_creat(const struct dentry * dentry,
62521 + const struct dentry * p_dentry,
62522 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62523 + const int imode)
62524 +{
62525 + __u32 reqmode = GR_WRITE | GR_CREATE;
62526 + __u32 mode;
62527 +
62528 + if (acc_mode & MAY_APPEND)
62529 + reqmode |= GR_APPEND;
62530 + // if a directory was required or the directory already exists, then
62531 + // don't count this open as a read
62532 + if ((acc_mode & MAY_READ) &&
62533 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62534 + reqmode |= GR_READ;
62535 + if ((open_flags & O_CREAT) &&
62536 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62537 + reqmode |= GR_SETID;
62538 +
62539 + mode =
62540 + gr_check_create(dentry, p_dentry, p_mnt,
62541 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62542 +
62543 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62544 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62545 + reqmode & GR_READ ? " reading" : "",
62546 + reqmode & GR_WRITE ? " writing" : reqmode &
62547 + GR_APPEND ? " appending" : "");
62548 + return reqmode;
62549 + } else
62550 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62551 + {
62552 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62553 + reqmode & GR_READ ? " reading" : "",
62554 + reqmode & GR_WRITE ? " writing" : reqmode &
62555 + GR_APPEND ? " appending" : "");
62556 + return 0;
62557 + } else if (unlikely((mode & reqmode) != reqmode))
62558 + return 0;
62559 +
62560 + return reqmode;
62561 +}
62562 +
62563 +__u32
62564 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62565 + const int fmode)
62566 +{
62567 + __u32 mode, reqmode = GR_FIND;
62568 +
62569 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62570 + reqmode |= GR_EXEC;
62571 + if (fmode & S_IWOTH)
62572 + reqmode |= GR_WRITE;
62573 + if (fmode & S_IROTH)
62574 + reqmode |= GR_READ;
62575 +
62576 + mode =
62577 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62578 + mnt);
62579 +
62580 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62581 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62582 + reqmode & GR_READ ? " reading" : "",
62583 + reqmode & GR_WRITE ? " writing" : "",
62584 + reqmode & GR_EXEC ? " executing" : "");
62585 + return reqmode;
62586 + } else
62587 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62588 + {
62589 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62590 + reqmode & GR_READ ? " reading" : "",
62591 + reqmode & GR_WRITE ? " writing" : "",
62592 + reqmode & GR_EXEC ? " executing" : "");
62593 + return 0;
62594 + } else if (unlikely((mode & reqmode) != reqmode))
62595 + return 0;
62596 +
62597 + return reqmode;
62598 +}
62599 +
62600 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62601 +{
62602 + __u32 mode;
62603 +
62604 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62605 +
62606 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62607 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62608 + return mode;
62609 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62610 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62611 + return 0;
62612 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62613 + return 0;
62614 +
62615 + return (reqmode);
62616 +}
62617 +
62618 +__u32
62619 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62620 +{
62621 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62622 +}
62623 +
62624 +__u32
62625 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62626 +{
62627 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62628 +}
62629 +
62630 +__u32
62631 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62632 +{
62633 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62634 +}
62635 +
62636 +__u32
62637 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62638 +{
62639 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62640 +}
62641 +
62642 +__u32
62643 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62644 + umode_t *modeptr)
62645 +{
62646 + umode_t mode;
62647 +
62648 + *modeptr &= ~gr_acl_umask();
62649 + mode = *modeptr;
62650 +
62651 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62652 + return 1;
62653 +
62654 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62655 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62656 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62657 + GR_CHMOD_ACL_MSG);
62658 + } else {
62659 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62660 + }
62661 +}
62662 +
62663 +__u32
62664 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62665 +{
62666 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62667 +}
62668 +
62669 +__u32
62670 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62671 +{
62672 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62673 +}
62674 +
62675 +__u32
62676 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62677 +{
62678 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62679 +}
62680 +
62681 +__u32
62682 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62683 +{
62684 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62685 + GR_UNIXCONNECT_ACL_MSG);
62686 +}
62687 +
62688 +/* hardlinks require at minimum create and link permission,
62689 + any additional privilege required is based on the
62690 + privilege of the file being linked to
62691 +*/
62692 +__u32
62693 +gr_acl_handle_link(const struct dentry * new_dentry,
62694 + const struct dentry * parent_dentry,
62695 + const struct vfsmount * parent_mnt,
62696 + const struct dentry * old_dentry,
62697 + const struct vfsmount * old_mnt, const struct filename *to)
62698 +{
62699 + __u32 mode;
62700 + __u32 needmode = GR_CREATE | GR_LINK;
62701 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62702 +
62703 + mode =
62704 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62705 + old_mnt);
62706 +
62707 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62708 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62709 + return mode;
62710 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62711 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62712 + return 0;
62713 + } else if (unlikely((mode & needmode) != needmode))
62714 + return 0;
62715 +
62716 + return 1;
62717 +}
62718 +
62719 +__u32
62720 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62721 + const struct dentry * parent_dentry,
62722 + const struct vfsmount * parent_mnt, const struct filename *from)
62723 +{
62724 + __u32 needmode = GR_WRITE | GR_CREATE;
62725 + __u32 mode;
62726 +
62727 + mode =
62728 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62729 + GR_CREATE | GR_AUDIT_CREATE |
62730 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62731 +
62732 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62733 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62734 + return mode;
62735 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62736 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62737 + return 0;
62738 + } else if (unlikely((mode & needmode) != needmode))
62739 + return 0;
62740 +
62741 + return (GR_WRITE | GR_CREATE);
62742 +}
62743 +
62744 +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)
62745 +{
62746 + __u32 mode;
62747 +
62748 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62749 +
62750 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62751 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62752 + return mode;
62753 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62754 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62755 + return 0;
62756 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62757 + return 0;
62758 +
62759 + return (reqmode);
62760 +}
62761 +
62762 +__u32
62763 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62764 + const struct dentry * parent_dentry,
62765 + const struct vfsmount * parent_mnt,
62766 + const int mode)
62767 +{
62768 + __u32 reqmode = GR_WRITE | GR_CREATE;
62769 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62770 + reqmode |= GR_SETID;
62771 +
62772 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62773 + reqmode, GR_MKNOD_ACL_MSG);
62774 +}
62775 +
62776 +__u32
62777 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62778 + const struct dentry *parent_dentry,
62779 + const struct vfsmount *parent_mnt)
62780 +{
62781 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62782 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62783 +}
62784 +
62785 +#define RENAME_CHECK_SUCCESS(old, new) \
62786 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62787 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62788 +
62789 +int
62790 +gr_acl_handle_rename(struct dentry *new_dentry,
62791 + struct dentry *parent_dentry,
62792 + const struct vfsmount *parent_mnt,
62793 + struct dentry *old_dentry,
62794 + struct inode *old_parent_inode,
62795 + struct vfsmount *old_mnt, const struct filename *newname)
62796 +{
62797 + __u32 comp1, comp2;
62798 + int error = 0;
62799 +
62800 + if (unlikely(!gr_acl_is_enabled()))
62801 + return 0;
62802 +
62803 + if (!new_dentry->d_inode) {
62804 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62805 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62806 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62807 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62808 + GR_DELETE | GR_AUDIT_DELETE |
62809 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62810 + GR_SUPPRESS, old_mnt);
62811 + } else {
62812 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62813 + GR_CREATE | GR_DELETE |
62814 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62815 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62816 + GR_SUPPRESS, parent_mnt);
62817 + comp2 =
62818 + gr_search_file(old_dentry,
62819 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62820 + GR_DELETE | GR_AUDIT_DELETE |
62821 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62822 + }
62823 +
62824 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62825 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62826 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62827 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62828 + && !(comp2 & GR_SUPPRESS)) {
62829 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62830 + error = -EACCES;
62831 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62832 + error = -EACCES;
62833 +
62834 + return error;
62835 +}
62836 +
62837 +void
62838 +gr_acl_handle_exit(void)
62839 +{
62840 + u16 id;
62841 + char *rolename;
62842 +
62843 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62844 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62845 + id = current->acl_role_id;
62846 + rolename = current->role->rolename;
62847 + gr_set_acls(1);
62848 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62849 + }
62850 +
62851 + gr_put_exec_file(current);
62852 + return;
62853 +}
62854 +
62855 +int
62856 +gr_acl_handle_procpidmem(const struct task_struct *task)
62857 +{
62858 + if (unlikely(!gr_acl_is_enabled()))
62859 + return 0;
62860 +
62861 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62862 + return -EACCES;
62863 +
62864 + return 0;
62865 +}
62866 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62867 new file mode 100644
62868 index 0000000..8132048
62869 --- /dev/null
62870 +++ b/grsecurity/gracl_ip.c
62871 @@ -0,0 +1,387 @@
62872 +#include <linux/kernel.h>
62873 +#include <asm/uaccess.h>
62874 +#include <asm/errno.h>
62875 +#include <net/sock.h>
62876 +#include <linux/file.h>
62877 +#include <linux/fs.h>
62878 +#include <linux/net.h>
62879 +#include <linux/in.h>
62880 +#include <linux/skbuff.h>
62881 +#include <linux/ip.h>
62882 +#include <linux/udp.h>
62883 +#include <linux/types.h>
62884 +#include <linux/sched.h>
62885 +#include <linux/netdevice.h>
62886 +#include <linux/inetdevice.h>
62887 +#include <linux/gracl.h>
62888 +#include <linux/grsecurity.h>
62889 +#include <linux/grinternal.h>
62890 +
62891 +#define GR_BIND 0x01
62892 +#define GR_CONNECT 0x02
62893 +#define GR_INVERT 0x04
62894 +#define GR_BINDOVERRIDE 0x08
62895 +#define GR_CONNECTOVERRIDE 0x10
62896 +#define GR_SOCK_FAMILY 0x20
62897 +
62898 +static const char * gr_protocols[IPPROTO_MAX] = {
62899 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62900 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62901 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62902 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62903 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62904 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62905 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62906 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62907 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62908 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62909 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62910 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62911 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62912 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62913 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62914 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62915 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62916 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62917 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62918 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62919 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62920 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62921 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62922 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62923 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62924 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62925 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62926 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62927 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62928 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62929 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62930 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62931 + };
62932 +
62933 +static const char * gr_socktypes[SOCK_MAX] = {
62934 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62935 + "unknown:7", "unknown:8", "unknown:9", "packet"
62936 + };
62937 +
62938 +static const char * gr_sockfamilies[AF_MAX+1] = {
62939 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62940 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62941 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62942 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62943 + };
62944 +
62945 +const char *
62946 +gr_proto_to_name(unsigned char proto)
62947 +{
62948 + return gr_protocols[proto];
62949 +}
62950 +
62951 +const char *
62952 +gr_socktype_to_name(unsigned char type)
62953 +{
62954 + return gr_socktypes[type];
62955 +}
62956 +
62957 +const char *
62958 +gr_sockfamily_to_name(unsigned char family)
62959 +{
62960 + return gr_sockfamilies[family];
62961 +}
62962 +
62963 +int
62964 +gr_search_socket(const int domain, const int type, const int protocol)
62965 +{
62966 + struct acl_subject_label *curr;
62967 + const struct cred *cred = current_cred();
62968 +
62969 + if (unlikely(!gr_acl_is_enabled()))
62970 + goto exit;
62971 +
62972 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62973 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62974 + goto exit; // let the kernel handle it
62975 +
62976 + curr = current->acl;
62977 +
62978 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62979 + /* the family is allowed, if this is PF_INET allow it only if
62980 + the extra sock type/protocol checks pass */
62981 + if (domain == PF_INET)
62982 + goto inet_check;
62983 + goto exit;
62984 + } else {
62985 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62986 + __u32 fakeip = 0;
62987 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62988 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62989 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62990 + gr_to_filename(current->exec_file->f_path.dentry,
62991 + current->exec_file->f_path.mnt) :
62992 + curr->filename, curr->filename,
62993 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62994 + &current->signal->saved_ip);
62995 + goto exit;
62996 + }
62997 + goto exit_fail;
62998 + }
62999 +
63000 +inet_check:
63001 + /* the rest of this checking is for IPv4 only */
63002 + if (!curr->ips)
63003 + goto exit;
63004 +
63005 + if ((curr->ip_type & (1U << type)) &&
63006 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
63007 + goto exit;
63008 +
63009 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63010 + /* we don't place acls on raw sockets , and sometimes
63011 + dgram/ip sockets are opened for ioctl and not
63012 + bind/connect, so we'll fake a bind learn log */
63013 + if (type == SOCK_RAW || type == SOCK_PACKET) {
63014 + __u32 fakeip = 0;
63015 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63016 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63017 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63018 + gr_to_filename(current->exec_file->f_path.dentry,
63019 + current->exec_file->f_path.mnt) :
63020 + curr->filename, curr->filename,
63021 + &fakeip, 0, type,
63022 + protocol, GR_CONNECT, &current->signal->saved_ip);
63023 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63024 + __u32 fakeip = 0;
63025 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63026 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63027 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63028 + gr_to_filename(current->exec_file->f_path.dentry,
63029 + current->exec_file->f_path.mnt) :
63030 + curr->filename, curr->filename,
63031 + &fakeip, 0, type,
63032 + protocol, GR_BIND, &current->signal->saved_ip);
63033 + }
63034 + /* we'll log when they use connect or bind */
63035 + goto exit;
63036 + }
63037 +
63038 +exit_fail:
63039 + if (domain == PF_INET)
63040 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63041 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63042 + else
63043 +#ifndef CONFIG_IPV6
63044 + if (domain != PF_INET6)
63045 +#endif
63046 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63047 + gr_socktype_to_name(type), protocol);
63048 +
63049 + return 0;
63050 +exit:
63051 + return 1;
63052 +}
63053 +
63054 +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)
63055 +{
63056 + if ((ip->mode & mode) &&
63057 + (ip_port >= ip->low) &&
63058 + (ip_port <= ip->high) &&
63059 + ((ntohl(ip_addr) & our_netmask) ==
63060 + (ntohl(our_addr) & our_netmask))
63061 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63062 + && (ip->type & (1U << type))) {
63063 + if (ip->mode & GR_INVERT)
63064 + return 2; // specifically denied
63065 + else
63066 + return 1; // allowed
63067 + }
63068 +
63069 + return 0; // not specifically allowed, may continue parsing
63070 +}
63071 +
63072 +static int
63073 +gr_search_connectbind(const int full_mode, struct sock *sk,
63074 + struct sockaddr_in *addr, const int type)
63075 +{
63076 + char iface[IFNAMSIZ] = {0};
63077 + struct acl_subject_label *curr;
63078 + struct acl_ip_label *ip;
63079 + struct inet_sock *isk;
63080 + struct net_device *dev;
63081 + struct in_device *idev;
63082 + unsigned long i;
63083 + int ret;
63084 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63085 + __u32 ip_addr = 0;
63086 + __u32 our_addr;
63087 + __u32 our_netmask;
63088 + char *p;
63089 + __u16 ip_port = 0;
63090 + const struct cred *cred = current_cred();
63091 +
63092 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63093 + return 0;
63094 +
63095 + curr = current->acl;
63096 + isk = inet_sk(sk);
63097 +
63098 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63099 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63100 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63101 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63102 + struct sockaddr_in saddr;
63103 + int err;
63104 +
63105 + saddr.sin_family = AF_INET;
63106 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63107 + saddr.sin_port = isk->inet_sport;
63108 +
63109 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63110 + if (err)
63111 + return err;
63112 +
63113 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63114 + if (err)
63115 + return err;
63116 + }
63117 +
63118 + if (!curr->ips)
63119 + return 0;
63120 +
63121 + ip_addr = addr->sin_addr.s_addr;
63122 + ip_port = ntohs(addr->sin_port);
63123 +
63124 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63125 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63126 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63127 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63128 + gr_to_filename(current->exec_file->f_path.dentry,
63129 + current->exec_file->f_path.mnt) :
63130 + curr->filename, curr->filename,
63131 + &ip_addr, ip_port, type,
63132 + sk->sk_protocol, mode, &current->signal->saved_ip);
63133 + return 0;
63134 + }
63135 +
63136 + for (i = 0; i < curr->ip_num; i++) {
63137 + ip = *(curr->ips + i);
63138 + if (ip->iface != NULL) {
63139 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63140 + p = strchr(iface, ':');
63141 + if (p != NULL)
63142 + *p = '\0';
63143 + dev = dev_get_by_name(sock_net(sk), iface);
63144 + if (dev == NULL)
63145 + continue;
63146 + idev = in_dev_get(dev);
63147 + if (idev == NULL) {
63148 + dev_put(dev);
63149 + continue;
63150 + }
63151 + rcu_read_lock();
63152 + for_ifa(idev) {
63153 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63154 + our_addr = ifa->ifa_address;
63155 + our_netmask = 0xffffffff;
63156 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63157 + if (ret == 1) {
63158 + rcu_read_unlock();
63159 + in_dev_put(idev);
63160 + dev_put(dev);
63161 + return 0;
63162 + } else if (ret == 2) {
63163 + rcu_read_unlock();
63164 + in_dev_put(idev);
63165 + dev_put(dev);
63166 + goto denied;
63167 + }
63168 + }
63169 + } endfor_ifa(idev);
63170 + rcu_read_unlock();
63171 + in_dev_put(idev);
63172 + dev_put(dev);
63173 + } else {
63174 + our_addr = ip->addr;
63175 + our_netmask = ip->netmask;
63176 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63177 + if (ret == 1)
63178 + return 0;
63179 + else if (ret == 2)
63180 + goto denied;
63181 + }
63182 + }
63183 +
63184 +denied:
63185 + if (mode == GR_BIND)
63186 + 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));
63187 + else if (mode == GR_CONNECT)
63188 + 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));
63189 +
63190 + return -EACCES;
63191 +}
63192 +
63193 +int
63194 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63195 +{
63196 + /* always allow disconnection of dgram sockets with connect */
63197 + if (addr->sin_family == AF_UNSPEC)
63198 + return 0;
63199 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63200 +}
63201 +
63202 +int
63203 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63204 +{
63205 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63206 +}
63207 +
63208 +int gr_search_listen(struct socket *sock)
63209 +{
63210 + struct sock *sk = sock->sk;
63211 + struct sockaddr_in addr;
63212 +
63213 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63214 + addr.sin_port = inet_sk(sk)->inet_sport;
63215 +
63216 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63217 +}
63218 +
63219 +int gr_search_accept(struct socket *sock)
63220 +{
63221 + struct sock *sk = sock->sk;
63222 + struct sockaddr_in addr;
63223 +
63224 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63225 + addr.sin_port = inet_sk(sk)->inet_sport;
63226 +
63227 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63228 +}
63229 +
63230 +int
63231 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63232 +{
63233 + if (addr)
63234 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63235 + else {
63236 + struct sockaddr_in sin;
63237 + const struct inet_sock *inet = inet_sk(sk);
63238 +
63239 + sin.sin_addr.s_addr = inet->inet_daddr;
63240 + sin.sin_port = inet->inet_dport;
63241 +
63242 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63243 + }
63244 +}
63245 +
63246 +int
63247 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63248 +{
63249 + struct sockaddr_in sin;
63250 +
63251 + if (unlikely(skb->len < sizeof (struct udphdr)))
63252 + return 0; // skip this packet
63253 +
63254 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63255 + sin.sin_port = udp_hdr(skb)->source;
63256 +
63257 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63258 +}
63259 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63260 new file mode 100644
63261 index 0000000..25f54ef
63262 --- /dev/null
63263 +++ b/grsecurity/gracl_learn.c
63264 @@ -0,0 +1,207 @@
63265 +#include <linux/kernel.h>
63266 +#include <linux/mm.h>
63267 +#include <linux/sched.h>
63268 +#include <linux/poll.h>
63269 +#include <linux/string.h>
63270 +#include <linux/file.h>
63271 +#include <linux/types.h>
63272 +#include <linux/vmalloc.h>
63273 +#include <linux/grinternal.h>
63274 +
63275 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63276 + size_t count, loff_t *ppos);
63277 +extern int gr_acl_is_enabled(void);
63278 +
63279 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63280 +static int gr_learn_attached;
63281 +
63282 +/* use a 512k buffer */
63283 +#define LEARN_BUFFER_SIZE (512 * 1024)
63284 +
63285 +static DEFINE_SPINLOCK(gr_learn_lock);
63286 +static DEFINE_MUTEX(gr_learn_user_mutex);
63287 +
63288 +/* we need to maintain two buffers, so that the kernel context of grlearn
63289 + uses a semaphore around the userspace copying, and the other kernel contexts
63290 + use a spinlock when copying into the buffer, since they cannot sleep
63291 +*/
63292 +static char *learn_buffer;
63293 +static char *learn_buffer_user;
63294 +static int learn_buffer_len;
63295 +static int learn_buffer_user_len;
63296 +
63297 +static ssize_t
63298 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63299 +{
63300 + DECLARE_WAITQUEUE(wait, current);
63301 + ssize_t retval = 0;
63302 +
63303 + add_wait_queue(&learn_wait, &wait);
63304 + set_current_state(TASK_INTERRUPTIBLE);
63305 + do {
63306 + mutex_lock(&gr_learn_user_mutex);
63307 + spin_lock(&gr_learn_lock);
63308 + if (learn_buffer_len)
63309 + break;
63310 + spin_unlock(&gr_learn_lock);
63311 + mutex_unlock(&gr_learn_user_mutex);
63312 + if (file->f_flags & O_NONBLOCK) {
63313 + retval = -EAGAIN;
63314 + goto out;
63315 + }
63316 + if (signal_pending(current)) {
63317 + retval = -ERESTARTSYS;
63318 + goto out;
63319 + }
63320 +
63321 + schedule();
63322 + } while (1);
63323 +
63324 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63325 + learn_buffer_user_len = learn_buffer_len;
63326 + retval = learn_buffer_len;
63327 + learn_buffer_len = 0;
63328 +
63329 + spin_unlock(&gr_learn_lock);
63330 +
63331 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63332 + retval = -EFAULT;
63333 +
63334 + mutex_unlock(&gr_learn_user_mutex);
63335 +out:
63336 + set_current_state(TASK_RUNNING);
63337 + remove_wait_queue(&learn_wait, &wait);
63338 + return retval;
63339 +}
63340 +
63341 +static unsigned int
63342 +poll_learn(struct file * file, poll_table * wait)
63343 +{
63344 + poll_wait(file, &learn_wait, wait);
63345 +
63346 + if (learn_buffer_len)
63347 + return (POLLIN | POLLRDNORM);
63348 +
63349 + return 0;
63350 +}
63351 +
63352 +void
63353 +gr_clear_learn_entries(void)
63354 +{
63355 + char *tmp;
63356 +
63357 + mutex_lock(&gr_learn_user_mutex);
63358 + spin_lock(&gr_learn_lock);
63359 + tmp = learn_buffer;
63360 + learn_buffer = NULL;
63361 + spin_unlock(&gr_learn_lock);
63362 + if (tmp)
63363 + vfree(tmp);
63364 + if (learn_buffer_user != NULL) {
63365 + vfree(learn_buffer_user);
63366 + learn_buffer_user = NULL;
63367 + }
63368 + learn_buffer_len = 0;
63369 + mutex_unlock(&gr_learn_user_mutex);
63370 +
63371 + return;
63372 +}
63373 +
63374 +void
63375 +gr_add_learn_entry(const char *fmt, ...)
63376 +{
63377 + va_list args;
63378 + unsigned int len;
63379 +
63380 + if (!gr_learn_attached)
63381 + return;
63382 +
63383 + spin_lock(&gr_learn_lock);
63384 +
63385 + /* leave a gap at the end so we know when it's "full" but don't have to
63386 + compute the exact length of the string we're trying to append
63387 + */
63388 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63389 + spin_unlock(&gr_learn_lock);
63390 + wake_up_interruptible(&learn_wait);
63391 + return;
63392 + }
63393 + if (learn_buffer == NULL) {
63394 + spin_unlock(&gr_learn_lock);
63395 + return;
63396 + }
63397 +
63398 + va_start(args, fmt);
63399 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63400 + va_end(args);
63401 +
63402 + learn_buffer_len += len + 1;
63403 +
63404 + spin_unlock(&gr_learn_lock);
63405 + wake_up_interruptible(&learn_wait);
63406 +
63407 + return;
63408 +}
63409 +
63410 +static int
63411 +open_learn(struct inode *inode, struct file *file)
63412 +{
63413 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63414 + return -EBUSY;
63415 + if (file->f_mode & FMODE_READ) {
63416 + int retval = 0;
63417 + mutex_lock(&gr_learn_user_mutex);
63418 + if (learn_buffer == NULL)
63419 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63420 + if (learn_buffer_user == NULL)
63421 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63422 + if (learn_buffer == NULL) {
63423 + retval = -ENOMEM;
63424 + goto out_error;
63425 + }
63426 + if (learn_buffer_user == NULL) {
63427 + retval = -ENOMEM;
63428 + goto out_error;
63429 + }
63430 + learn_buffer_len = 0;
63431 + learn_buffer_user_len = 0;
63432 + gr_learn_attached = 1;
63433 +out_error:
63434 + mutex_unlock(&gr_learn_user_mutex);
63435 + return retval;
63436 + }
63437 + return 0;
63438 +}
63439 +
63440 +static int
63441 +close_learn(struct inode *inode, struct file *file)
63442 +{
63443 + if (file->f_mode & FMODE_READ) {
63444 + char *tmp = NULL;
63445 + mutex_lock(&gr_learn_user_mutex);
63446 + spin_lock(&gr_learn_lock);
63447 + tmp = learn_buffer;
63448 + learn_buffer = NULL;
63449 + spin_unlock(&gr_learn_lock);
63450 + if (tmp)
63451 + vfree(tmp);
63452 + if (learn_buffer_user != NULL) {
63453 + vfree(learn_buffer_user);
63454 + learn_buffer_user = NULL;
63455 + }
63456 + learn_buffer_len = 0;
63457 + learn_buffer_user_len = 0;
63458 + gr_learn_attached = 0;
63459 + mutex_unlock(&gr_learn_user_mutex);
63460 + }
63461 +
63462 + return 0;
63463 +}
63464 +
63465 +const struct file_operations grsec_fops = {
63466 + .read = read_learn,
63467 + .write = write_grsec_handler,
63468 + .open = open_learn,
63469 + .release = close_learn,
63470 + .poll = poll_learn,
63471 +};
63472 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63473 new file mode 100644
63474 index 0000000..39645c9
63475 --- /dev/null
63476 +++ b/grsecurity/gracl_res.c
63477 @@ -0,0 +1,68 @@
63478 +#include <linux/kernel.h>
63479 +#include <linux/sched.h>
63480 +#include <linux/gracl.h>
63481 +#include <linux/grinternal.h>
63482 +
63483 +static const char *restab_log[] = {
63484 + [RLIMIT_CPU] = "RLIMIT_CPU",
63485 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63486 + [RLIMIT_DATA] = "RLIMIT_DATA",
63487 + [RLIMIT_STACK] = "RLIMIT_STACK",
63488 + [RLIMIT_CORE] = "RLIMIT_CORE",
63489 + [RLIMIT_RSS] = "RLIMIT_RSS",
63490 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63491 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63492 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63493 + [RLIMIT_AS] = "RLIMIT_AS",
63494 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63495 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63496 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63497 + [RLIMIT_NICE] = "RLIMIT_NICE",
63498 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63499 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63500 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63501 +};
63502 +
63503 +void
63504 +gr_log_resource(const struct task_struct *task,
63505 + const int res, const unsigned long wanted, const int gt)
63506 +{
63507 + const struct cred *cred;
63508 + unsigned long rlim;
63509 +
63510 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63511 + return;
63512 +
63513 + // not yet supported resource
63514 + if (unlikely(!restab_log[res]))
63515 + return;
63516 +
63517 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63518 + rlim = task_rlimit_max(task, res);
63519 + else
63520 + rlim = task_rlimit(task, res);
63521 +
63522 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63523 + return;
63524 +
63525 + rcu_read_lock();
63526 + cred = __task_cred(task);
63527 +
63528 + if (res == RLIMIT_NPROC &&
63529 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63530 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63531 + goto out_rcu_unlock;
63532 + else if (res == RLIMIT_MEMLOCK &&
63533 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63534 + goto out_rcu_unlock;
63535 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63536 + goto out_rcu_unlock;
63537 + rcu_read_unlock();
63538 +
63539 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63540 +
63541 + return;
63542 +out_rcu_unlock:
63543 + rcu_read_unlock();
63544 + return;
63545 +}
63546 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63547 new file mode 100644
63548 index 0000000..cb1e5ab
63549 --- /dev/null
63550 +++ b/grsecurity/gracl_segv.c
63551 @@ -0,0 +1,303 @@
63552 +#include <linux/kernel.h>
63553 +#include <linux/mm.h>
63554 +#include <asm/uaccess.h>
63555 +#include <asm/errno.h>
63556 +#include <asm/mman.h>
63557 +#include <net/sock.h>
63558 +#include <linux/file.h>
63559 +#include <linux/fs.h>
63560 +#include <linux/net.h>
63561 +#include <linux/in.h>
63562 +#include <linux/slab.h>
63563 +#include <linux/types.h>
63564 +#include <linux/sched.h>
63565 +#include <linux/timer.h>
63566 +#include <linux/gracl.h>
63567 +#include <linux/grsecurity.h>
63568 +#include <linux/grinternal.h>
63569 +
63570 +static struct crash_uid *uid_set;
63571 +static unsigned short uid_used;
63572 +static DEFINE_SPINLOCK(gr_uid_lock);
63573 +extern rwlock_t gr_inode_lock;
63574 +extern struct acl_subject_label *
63575 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63576 + struct acl_role_label *role);
63577 +
63578 +#ifdef CONFIG_BTRFS_FS
63579 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
63580 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
63581 +#endif
63582 +
63583 +static inline dev_t __get_dev(const struct dentry *dentry)
63584 +{
63585 +#ifdef CONFIG_BTRFS_FS
63586 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
63587 + return get_btrfs_dev_from_inode(dentry->d_inode);
63588 + else
63589 +#endif
63590 + return dentry->d_inode->i_sb->s_dev;
63591 +}
63592 +
63593 +int
63594 +gr_init_uidset(void)
63595 +{
63596 + uid_set =
63597 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63598 + uid_used = 0;
63599 +
63600 + return uid_set ? 1 : 0;
63601 +}
63602 +
63603 +void
63604 +gr_free_uidset(void)
63605 +{
63606 + if (uid_set)
63607 + kfree(uid_set);
63608 +
63609 + return;
63610 +}
63611 +
63612 +int
63613 +gr_find_uid(const uid_t uid)
63614 +{
63615 + struct crash_uid *tmp = uid_set;
63616 + uid_t buid;
63617 + int low = 0, high = uid_used - 1, mid;
63618 +
63619 + while (high >= low) {
63620 + mid = (low + high) >> 1;
63621 + buid = tmp[mid].uid;
63622 + if (buid == uid)
63623 + return mid;
63624 + if (buid > uid)
63625 + high = mid - 1;
63626 + if (buid < uid)
63627 + low = mid + 1;
63628 + }
63629 +
63630 + return -1;
63631 +}
63632 +
63633 +static __inline__ void
63634 +gr_insertsort(void)
63635 +{
63636 + unsigned short i, j;
63637 + struct crash_uid index;
63638 +
63639 + for (i = 1; i < uid_used; i++) {
63640 + index = uid_set[i];
63641 + j = i;
63642 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63643 + uid_set[j] = uid_set[j - 1];
63644 + j--;
63645 + }
63646 + uid_set[j] = index;
63647 + }
63648 +
63649 + return;
63650 +}
63651 +
63652 +static __inline__ void
63653 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63654 +{
63655 + int loc;
63656 + uid_t uid = GR_GLOBAL_UID(kuid);
63657 +
63658 + if (uid_used == GR_UIDTABLE_MAX)
63659 + return;
63660 +
63661 + loc = gr_find_uid(uid);
63662 +
63663 + if (loc >= 0) {
63664 + uid_set[loc].expires = expires;
63665 + return;
63666 + }
63667 +
63668 + uid_set[uid_used].uid = uid;
63669 + uid_set[uid_used].expires = expires;
63670 + uid_used++;
63671 +
63672 + gr_insertsort();
63673 +
63674 + return;
63675 +}
63676 +
63677 +void
63678 +gr_remove_uid(const unsigned short loc)
63679 +{
63680 + unsigned short i;
63681 +
63682 + for (i = loc + 1; i < uid_used; i++)
63683 + uid_set[i - 1] = uid_set[i];
63684 +
63685 + uid_used--;
63686 +
63687 + return;
63688 +}
63689 +
63690 +int
63691 +gr_check_crash_uid(const kuid_t kuid)
63692 +{
63693 + int loc;
63694 + int ret = 0;
63695 + uid_t uid;
63696 +
63697 + if (unlikely(!gr_acl_is_enabled()))
63698 + return 0;
63699 +
63700 + uid = GR_GLOBAL_UID(kuid);
63701 +
63702 + spin_lock(&gr_uid_lock);
63703 + loc = gr_find_uid(uid);
63704 +
63705 + if (loc < 0)
63706 + goto out_unlock;
63707 +
63708 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63709 + gr_remove_uid(loc);
63710 + else
63711 + ret = 1;
63712 +
63713 +out_unlock:
63714 + spin_unlock(&gr_uid_lock);
63715 + return ret;
63716 +}
63717 +
63718 +static __inline__ int
63719 +proc_is_setxid(const struct cred *cred)
63720 +{
63721 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63722 + !uid_eq(cred->uid, cred->fsuid))
63723 + return 1;
63724 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63725 + !gid_eq(cred->gid, cred->fsgid))
63726 + return 1;
63727 +
63728 + return 0;
63729 +}
63730 +
63731 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63732 +
63733 +void
63734 +gr_handle_crash(struct task_struct *task, const int sig)
63735 +{
63736 + struct acl_subject_label *curr;
63737 + struct task_struct *tsk, *tsk2;
63738 + const struct cred *cred;
63739 + const struct cred *cred2;
63740 +
63741 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63742 + return;
63743 +
63744 + if (unlikely(!gr_acl_is_enabled()))
63745 + return;
63746 +
63747 + curr = task->acl;
63748 +
63749 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63750 + return;
63751 +
63752 + if (time_before_eq(curr->expires, get_seconds())) {
63753 + curr->expires = 0;
63754 + curr->crashes = 0;
63755 + }
63756 +
63757 + curr->crashes++;
63758 +
63759 + if (!curr->expires)
63760 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63761 +
63762 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63763 + time_after(curr->expires, get_seconds())) {
63764 + rcu_read_lock();
63765 + cred = __task_cred(task);
63766 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63767 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63768 + spin_lock(&gr_uid_lock);
63769 + gr_insert_uid(cred->uid, curr->expires);
63770 + spin_unlock(&gr_uid_lock);
63771 + curr->expires = 0;
63772 + curr->crashes = 0;
63773 + read_lock(&tasklist_lock);
63774 + do_each_thread(tsk2, tsk) {
63775 + cred2 = __task_cred(tsk);
63776 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63777 + gr_fake_force_sig(SIGKILL, tsk);
63778 + } while_each_thread(tsk2, tsk);
63779 + read_unlock(&tasklist_lock);
63780 + } else {
63781 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63782 + read_lock(&tasklist_lock);
63783 + read_lock(&grsec_exec_file_lock);
63784 + do_each_thread(tsk2, tsk) {
63785 + if (likely(tsk != task)) {
63786 + // if this thread has the same subject as the one that triggered
63787 + // RES_CRASH and it's the same binary, kill it
63788 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63789 + gr_fake_force_sig(SIGKILL, tsk);
63790 + }
63791 + } while_each_thread(tsk2, tsk);
63792 + read_unlock(&grsec_exec_file_lock);
63793 + read_unlock(&tasklist_lock);
63794 + }
63795 + rcu_read_unlock();
63796 + }
63797 +
63798 + return;
63799 +}
63800 +
63801 +int
63802 +gr_check_crash_exec(const struct file *filp)
63803 +{
63804 + struct acl_subject_label *curr;
63805 +
63806 + if (unlikely(!gr_acl_is_enabled()))
63807 + return 0;
63808 +
63809 + read_lock(&gr_inode_lock);
63810 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63811 + __get_dev(filp->f_path.dentry),
63812 + current->role);
63813 + read_unlock(&gr_inode_lock);
63814 +
63815 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63816 + (!curr->crashes && !curr->expires))
63817 + return 0;
63818 +
63819 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63820 + time_after(curr->expires, get_seconds()))
63821 + return 1;
63822 + else if (time_before_eq(curr->expires, get_seconds())) {
63823 + curr->crashes = 0;
63824 + curr->expires = 0;
63825 + }
63826 +
63827 + return 0;
63828 +}
63829 +
63830 +void
63831 +gr_handle_alertkill(struct task_struct *task)
63832 +{
63833 + struct acl_subject_label *curracl;
63834 + __u32 curr_ip;
63835 + struct task_struct *p, *p2;
63836 +
63837 + if (unlikely(!gr_acl_is_enabled()))
63838 + return;
63839 +
63840 + curracl = task->acl;
63841 + curr_ip = task->signal->curr_ip;
63842 +
63843 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63844 + read_lock(&tasklist_lock);
63845 + do_each_thread(p2, p) {
63846 + if (p->signal->curr_ip == curr_ip)
63847 + gr_fake_force_sig(SIGKILL, p);
63848 + } while_each_thread(p2, p);
63849 + read_unlock(&tasklist_lock);
63850 + } else if (curracl->mode & GR_KILLPROC)
63851 + gr_fake_force_sig(SIGKILL, task);
63852 +
63853 + return;
63854 +}
63855 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63856 new file mode 100644
63857 index 0000000..98011b0
63858 --- /dev/null
63859 +++ b/grsecurity/gracl_shm.c
63860 @@ -0,0 +1,40 @@
63861 +#include <linux/kernel.h>
63862 +#include <linux/mm.h>
63863 +#include <linux/sched.h>
63864 +#include <linux/file.h>
63865 +#include <linux/ipc.h>
63866 +#include <linux/gracl.h>
63867 +#include <linux/grsecurity.h>
63868 +#include <linux/grinternal.h>
63869 +
63870 +int
63871 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63872 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63873 +{
63874 + struct task_struct *task;
63875 +
63876 + if (!gr_acl_is_enabled())
63877 + return 1;
63878 +
63879 + rcu_read_lock();
63880 + read_lock(&tasklist_lock);
63881 +
63882 + task = find_task_by_vpid(shm_cprid);
63883 +
63884 + if (unlikely(!task))
63885 + task = find_task_by_vpid(shm_lapid);
63886 +
63887 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63888 + (task_pid_nr(task) == shm_lapid)) &&
63889 + (task->acl->mode & GR_PROTSHM) &&
63890 + (task->acl != current->acl))) {
63891 + read_unlock(&tasklist_lock);
63892 + rcu_read_unlock();
63893 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63894 + return 0;
63895 + }
63896 + read_unlock(&tasklist_lock);
63897 + rcu_read_unlock();
63898 +
63899 + return 1;
63900 +}
63901 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63902 new file mode 100644
63903 index 0000000..bc0be01
63904 --- /dev/null
63905 +++ b/grsecurity/grsec_chdir.c
63906 @@ -0,0 +1,19 @@
63907 +#include <linux/kernel.h>
63908 +#include <linux/sched.h>
63909 +#include <linux/fs.h>
63910 +#include <linux/file.h>
63911 +#include <linux/grsecurity.h>
63912 +#include <linux/grinternal.h>
63913 +
63914 +void
63915 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63916 +{
63917 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63918 + if ((grsec_enable_chdir && grsec_enable_group &&
63919 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63920 + !grsec_enable_group)) {
63921 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63922 + }
63923 +#endif
63924 + return;
63925 +}
63926 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63927 new file mode 100644
63928 index 0000000..6d2de57
63929 --- /dev/null
63930 +++ b/grsecurity/grsec_chroot.c
63931 @@ -0,0 +1,357 @@
63932 +#include <linux/kernel.h>
63933 +#include <linux/module.h>
63934 +#include <linux/sched.h>
63935 +#include <linux/file.h>
63936 +#include <linux/fs.h>
63937 +#include <linux/mount.h>
63938 +#include <linux/types.h>
63939 +#include "../fs/mount.h"
63940 +#include <linux/grsecurity.h>
63941 +#include <linux/grinternal.h>
63942 +
63943 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
63944 +{
63945 +#ifdef CONFIG_GRKERNSEC
63946 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63947 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
63948 + task->gr_is_chrooted = 1;
63949 + else
63950 + task->gr_is_chrooted = 0;
63951 +
63952 + task->gr_chroot_dentry = path->dentry;
63953 +#endif
63954 + return;
63955 +}
63956 +
63957 +void gr_clear_chroot_entries(struct task_struct *task)
63958 +{
63959 +#ifdef CONFIG_GRKERNSEC
63960 + task->gr_is_chrooted = 0;
63961 + task->gr_chroot_dentry = NULL;
63962 +#endif
63963 + return;
63964 +}
63965 +
63966 +int
63967 +gr_handle_chroot_unix(const pid_t pid)
63968 +{
63969 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63970 + struct task_struct *p;
63971 +
63972 + if (unlikely(!grsec_enable_chroot_unix))
63973 + return 1;
63974 +
63975 + if (likely(!proc_is_chrooted(current)))
63976 + return 1;
63977 +
63978 + rcu_read_lock();
63979 + read_lock(&tasklist_lock);
63980 + p = find_task_by_vpid_unrestricted(pid);
63981 + if (unlikely(p && !have_same_root(current, p))) {
63982 + read_unlock(&tasklist_lock);
63983 + rcu_read_unlock();
63984 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63985 + return 0;
63986 + }
63987 + read_unlock(&tasklist_lock);
63988 + rcu_read_unlock();
63989 +#endif
63990 + return 1;
63991 +}
63992 +
63993 +int
63994 +gr_handle_chroot_nice(void)
63995 +{
63996 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63997 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63998 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63999 + return -EPERM;
64000 + }
64001 +#endif
64002 + return 0;
64003 +}
64004 +
64005 +int
64006 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64007 +{
64008 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64009 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64010 + && proc_is_chrooted(current)) {
64011 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64012 + return -EACCES;
64013 + }
64014 +#endif
64015 + return 0;
64016 +}
64017 +
64018 +int
64019 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64020 +{
64021 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64022 + struct task_struct *p;
64023 + int ret = 0;
64024 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64025 + return ret;
64026 +
64027 + read_lock(&tasklist_lock);
64028 + do_each_pid_task(pid, type, p) {
64029 + if (!have_same_root(current, p)) {
64030 + ret = 1;
64031 + goto out;
64032 + }
64033 + } while_each_pid_task(pid, type, p);
64034 +out:
64035 + read_unlock(&tasklist_lock);
64036 + return ret;
64037 +#endif
64038 + return 0;
64039 +}
64040 +
64041 +int
64042 +gr_pid_is_chrooted(struct task_struct *p)
64043 +{
64044 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64045 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64046 + return 0;
64047 +
64048 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64049 + !have_same_root(current, p)) {
64050 + return 1;
64051 + }
64052 +#endif
64053 + return 0;
64054 +}
64055 +
64056 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64057 +
64058 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64059 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64060 +{
64061 + struct path path, currentroot;
64062 + int ret = 0;
64063 +
64064 + path.dentry = (struct dentry *)u_dentry;
64065 + path.mnt = (struct vfsmount *)u_mnt;
64066 + get_fs_root(current->fs, &currentroot);
64067 + if (path_is_under(&path, &currentroot))
64068 + ret = 1;
64069 + path_put(&currentroot);
64070 +
64071 + return ret;
64072 +}
64073 +#endif
64074 +
64075 +int
64076 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64077 +{
64078 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64079 + if (!grsec_enable_chroot_fchdir)
64080 + return 1;
64081 +
64082 + if (!proc_is_chrooted(current))
64083 + return 1;
64084 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64085 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64086 + return 0;
64087 + }
64088 +#endif
64089 + return 1;
64090 +}
64091 +
64092 +int
64093 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64094 + const time_t shm_createtime)
64095 +{
64096 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64097 + struct task_struct *p;
64098 + time_t starttime;
64099 +
64100 + if (unlikely(!grsec_enable_chroot_shmat))
64101 + return 1;
64102 +
64103 + if (likely(!proc_is_chrooted(current)))
64104 + return 1;
64105 +
64106 + rcu_read_lock();
64107 + read_lock(&tasklist_lock);
64108 +
64109 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64110 + starttime = p->start_time.tv_sec;
64111 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64112 + if (have_same_root(current, p)) {
64113 + goto allow;
64114 + } else {
64115 + read_unlock(&tasklist_lock);
64116 + rcu_read_unlock();
64117 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64118 + return 0;
64119 + }
64120 + }
64121 + /* creator exited, pid reuse, fall through to next check */
64122 + }
64123 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64124 + if (unlikely(!have_same_root(current, p))) {
64125 + read_unlock(&tasklist_lock);
64126 + rcu_read_unlock();
64127 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64128 + return 0;
64129 + }
64130 + }
64131 +
64132 +allow:
64133 + read_unlock(&tasklist_lock);
64134 + rcu_read_unlock();
64135 +#endif
64136 + return 1;
64137 +}
64138 +
64139 +void
64140 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64141 +{
64142 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64143 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64144 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64145 +#endif
64146 + return;
64147 +}
64148 +
64149 +int
64150 +gr_handle_chroot_mknod(const struct dentry *dentry,
64151 + const struct vfsmount *mnt, const int mode)
64152 +{
64153 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64154 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64155 + proc_is_chrooted(current)) {
64156 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64157 + return -EPERM;
64158 + }
64159 +#endif
64160 + return 0;
64161 +}
64162 +
64163 +int
64164 +gr_handle_chroot_mount(const struct dentry *dentry,
64165 + const struct vfsmount *mnt, const char *dev_name)
64166 +{
64167 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64168 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64169 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64170 + return -EPERM;
64171 + }
64172 +#endif
64173 + return 0;
64174 +}
64175 +
64176 +int
64177 +gr_handle_chroot_pivot(void)
64178 +{
64179 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64180 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64181 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64182 + return -EPERM;
64183 + }
64184 +#endif
64185 + return 0;
64186 +}
64187 +
64188 +int
64189 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64190 +{
64191 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64192 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64193 + !gr_is_outside_chroot(dentry, mnt)) {
64194 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64195 + return -EPERM;
64196 + }
64197 +#endif
64198 + return 0;
64199 +}
64200 +
64201 +extern const char *captab_log[];
64202 +extern int captab_log_entries;
64203 +
64204 +int
64205 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64206 +{
64207 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64208 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64209 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64210 + if (cap_raised(chroot_caps, cap)) {
64211 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64212 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64213 + }
64214 + return 0;
64215 + }
64216 + }
64217 +#endif
64218 + return 1;
64219 +}
64220 +
64221 +int
64222 +gr_chroot_is_capable(const int cap)
64223 +{
64224 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64225 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64226 +#endif
64227 + return 1;
64228 +}
64229 +
64230 +int
64231 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64232 +{
64233 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64234 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64235 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64236 + if (cap_raised(chroot_caps, cap)) {
64237 + return 0;
64238 + }
64239 + }
64240 +#endif
64241 + return 1;
64242 +}
64243 +
64244 +int
64245 +gr_chroot_is_capable_nolog(const int cap)
64246 +{
64247 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64248 + return gr_task_chroot_is_capable_nolog(current, cap);
64249 +#endif
64250 + return 1;
64251 +}
64252 +
64253 +int
64254 +gr_handle_chroot_sysctl(const int op)
64255 +{
64256 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64257 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64258 + proc_is_chrooted(current))
64259 + return -EACCES;
64260 +#endif
64261 + return 0;
64262 +}
64263 +
64264 +void
64265 +gr_handle_chroot_chdir(struct path *path)
64266 +{
64267 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64268 + if (grsec_enable_chroot_chdir)
64269 + set_fs_pwd(current->fs, path);
64270 +#endif
64271 + return;
64272 +}
64273 +
64274 +int
64275 +gr_handle_chroot_chmod(const struct dentry *dentry,
64276 + const struct vfsmount *mnt, const int mode)
64277 +{
64278 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64279 + /* allow chmod +s on directories, but not files */
64280 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64281 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64282 + proc_is_chrooted(current)) {
64283 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64284 + return -EPERM;
64285 + }
64286 +#endif
64287 + return 0;
64288 +}
64289 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64290 new file mode 100644
64291 index 0000000..207d409
64292 --- /dev/null
64293 +++ b/grsecurity/grsec_disabled.c
64294 @@ -0,0 +1,434 @@
64295 +#include <linux/kernel.h>
64296 +#include <linux/module.h>
64297 +#include <linux/sched.h>
64298 +#include <linux/file.h>
64299 +#include <linux/fs.h>
64300 +#include <linux/kdev_t.h>
64301 +#include <linux/net.h>
64302 +#include <linux/in.h>
64303 +#include <linux/ip.h>
64304 +#include <linux/skbuff.h>
64305 +#include <linux/sysctl.h>
64306 +
64307 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64308 +void
64309 +pax_set_initial_flags(struct linux_binprm *bprm)
64310 +{
64311 + return;
64312 +}
64313 +#endif
64314 +
64315 +#ifdef CONFIG_SYSCTL
64316 +__u32
64317 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64318 +{
64319 + return 0;
64320 +}
64321 +#endif
64322 +
64323 +#ifdef CONFIG_TASKSTATS
64324 +int gr_is_taskstats_denied(int pid)
64325 +{
64326 + return 0;
64327 +}
64328 +#endif
64329 +
64330 +int
64331 +gr_acl_is_enabled(void)
64332 +{
64333 + return 0;
64334 +}
64335 +
64336 +void
64337 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64338 +{
64339 + return;
64340 +}
64341 +
64342 +int
64343 +gr_handle_rawio(const struct inode *inode)
64344 +{
64345 + return 0;
64346 +}
64347 +
64348 +void
64349 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64350 +{
64351 + return;
64352 +}
64353 +
64354 +int
64355 +gr_handle_ptrace(struct task_struct *task, const long request)
64356 +{
64357 + return 0;
64358 +}
64359 +
64360 +int
64361 +gr_handle_proc_ptrace(struct task_struct *task)
64362 +{
64363 + return 0;
64364 +}
64365 +
64366 +int
64367 +gr_set_acls(const int type)
64368 +{
64369 + return 0;
64370 +}
64371 +
64372 +int
64373 +gr_check_hidden_task(const struct task_struct *tsk)
64374 +{
64375 + return 0;
64376 +}
64377 +
64378 +int
64379 +gr_check_protected_task(const struct task_struct *task)
64380 +{
64381 + return 0;
64382 +}
64383 +
64384 +int
64385 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64386 +{
64387 + return 0;
64388 +}
64389 +
64390 +void
64391 +gr_copy_label(struct task_struct *tsk)
64392 +{
64393 + return;
64394 +}
64395 +
64396 +void
64397 +gr_set_pax_flags(struct task_struct *task)
64398 +{
64399 + return;
64400 +}
64401 +
64402 +int
64403 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64404 + const int unsafe_share)
64405 +{
64406 + return 0;
64407 +}
64408 +
64409 +void
64410 +gr_handle_delete(const ino_t ino, const dev_t dev)
64411 +{
64412 + return;
64413 +}
64414 +
64415 +void
64416 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64417 +{
64418 + return;
64419 +}
64420 +
64421 +void
64422 +gr_handle_crash(struct task_struct *task, const int sig)
64423 +{
64424 + return;
64425 +}
64426 +
64427 +int
64428 +gr_check_crash_exec(const struct file *filp)
64429 +{
64430 + return 0;
64431 +}
64432 +
64433 +int
64434 +gr_check_crash_uid(const kuid_t uid)
64435 +{
64436 + return 0;
64437 +}
64438 +
64439 +void
64440 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64441 + struct dentry *old_dentry,
64442 + struct dentry *new_dentry,
64443 + struct vfsmount *mnt, const __u8 replace)
64444 +{
64445 + return;
64446 +}
64447 +
64448 +int
64449 +gr_search_socket(const int family, const int type, const int protocol)
64450 +{
64451 + return 1;
64452 +}
64453 +
64454 +int
64455 +gr_search_connectbind(const int mode, const struct socket *sock,
64456 + const struct sockaddr_in *addr)
64457 +{
64458 + return 0;
64459 +}
64460 +
64461 +void
64462 +gr_handle_alertkill(struct task_struct *task)
64463 +{
64464 + return;
64465 +}
64466 +
64467 +__u32
64468 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64469 +{
64470 + return 1;
64471 +}
64472 +
64473 +__u32
64474 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64475 + const struct vfsmount * mnt)
64476 +{
64477 + return 1;
64478 +}
64479 +
64480 +__u32
64481 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64482 + int acc_mode)
64483 +{
64484 + return 1;
64485 +}
64486 +
64487 +__u32
64488 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64489 +{
64490 + return 1;
64491 +}
64492 +
64493 +__u32
64494 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64495 +{
64496 + return 1;
64497 +}
64498 +
64499 +int
64500 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64501 + unsigned int *vm_flags)
64502 +{
64503 + return 1;
64504 +}
64505 +
64506 +__u32
64507 +gr_acl_handle_truncate(const struct dentry * dentry,
64508 + const struct vfsmount * mnt)
64509 +{
64510 + return 1;
64511 +}
64512 +
64513 +__u32
64514 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64515 +{
64516 + return 1;
64517 +}
64518 +
64519 +__u32
64520 +gr_acl_handle_access(const struct dentry * dentry,
64521 + const struct vfsmount * mnt, const int fmode)
64522 +{
64523 + return 1;
64524 +}
64525 +
64526 +__u32
64527 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64528 + umode_t *mode)
64529 +{
64530 + return 1;
64531 +}
64532 +
64533 +__u32
64534 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64535 +{
64536 + return 1;
64537 +}
64538 +
64539 +__u32
64540 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64541 +{
64542 + return 1;
64543 +}
64544 +
64545 +void
64546 +grsecurity_init(void)
64547 +{
64548 + return;
64549 +}
64550 +
64551 +umode_t gr_acl_umask(void)
64552 +{
64553 + return 0;
64554 +}
64555 +
64556 +__u32
64557 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64558 + const struct dentry * parent_dentry,
64559 + const struct vfsmount * parent_mnt,
64560 + const int mode)
64561 +{
64562 + return 1;
64563 +}
64564 +
64565 +__u32
64566 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64567 + const struct dentry * parent_dentry,
64568 + const struct vfsmount * parent_mnt)
64569 +{
64570 + return 1;
64571 +}
64572 +
64573 +__u32
64574 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64575 + const struct dentry * parent_dentry,
64576 + const struct vfsmount * parent_mnt, const struct filename *from)
64577 +{
64578 + return 1;
64579 +}
64580 +
64581 +__u32
64582 +gr_acl_handle_link(const struct dentry * new_dentry,
64583 + const struct dentry * parent_dentry,
64584 + const struct vfsmount * parent_mnt,
64585 + const struct dentry * old_dentry,
64586 + const struct vfsmount * old_mnt, const struct filename *to)
64587 +{
64588 + return 1;
64589 +}
64590 +
64591 +int
64592 +gr_acl_handle_rename(const struct dentry *new_dentry,
64593 + const struct dentry *parent_dentry,
64594 + const struct vfsmount *parent_mnt,
64595 + const struct dentry *old_dentry,
64596 + const struct inode *old_parent_inode,
64597 + const struct vfsmount *old_mnt, const struct filename *newname)
64598 +{
64599 + return 0;
64600 +}
64601 +
64602 +int
64603 +gr_acl_handle_filldir(const struct file *file, const char *name,
64604 + const int namelen, const ino_t ino)
64605 +{
64606 + return 1;
64607 +}
64608 +
64609 +int
64610 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64611 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64612 +{
64613 + return 1;
64614 +}
64615 +
64616 +int
64617 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64618 +{
64619 + return 0;
64620 +}
64621 +
64622 +int
64623 +gr_search_accept(const struct socket *sock)
64624 +{
64625 + return 0;
64626 +}
64627 +
64628 +int
64629 +gr_search_listen(const struct socket *sock)
64630 +{
64631 + return 0;
64632 +}
64633 +
64634 +int
64635 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64636 +{
64637 + return 0;
64638 +}
64639 +
64640 +__u32
64641 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64642 +{
64643 + return 1;
64644 +}
64645 +
64646 +__u32
64647 +gr_acl_handle_creat(const struct dentry * dentry,
64648 + const struct dentry * p_dentry,
64649 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64650 + const int imode)
64651 +{
64652 + return 1;
64653 +}
64654 +
64655 +void
64656 +gr_acl_handle_exit(void)
64657 +{
64658 + return;
64659 +}
64660 +
64661 +int
64662 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64663 +{
64664 + return 1;
64665 +}
64666 +
64667 +void
64668 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64669 +{
64670 + return;
64671 +}
64672 +
64673 +int
64674 +gr_acl_handle_procpidmem(const struct task_struct *task)
64675 +{
64676 + return 0;
64677 +}
64678 +
64679 +int
64680 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64681 +{
64682 + return 0;
64683 +}
64684 +
64685 +int
64686 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64687 +{
64688 + return 0;
64689 +}
64690 +
64691 +void
64692 +gr_set_kernel_label(struct task_struct *task)
64693 +{
64694 + return;
64695 +}
64696 +
64697 +int
64698 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64699 +{
64700 + return 0;
64701 +}
64702 +
64703 +int
64704 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64705 +{
64706 + return 0;
64707 +}
64708 +
64709 +int gr_acl_enable_at_secure(void)
64710 +{
64711 + return 0;
64712 +}
64713 +
64714 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64715 +{
64716 + return dentry->d_inode->i_sb->s_dev;
64717 +}
64718 +
64719 +void gr_put_exec_file(struct task_struct *task)
64720 +{
64721 + return;
64722 +}
64723 +
64724 +EXPORT_SYMBOL(gr_set_kernel_label);
64725 +#ifdef CONFIG_SECURITY
64726 +EXPORT_SYMBOL(gr_check_user_change);
64727 +EXPORT_SYMBOL(gr_check_group_change);
64728 +#endif
64729 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64730 new file mode 100644
64731 index 0000000..387032b
64732 --- /dev/null
64733 +++ b/grsecurity/grsec_exec.c
64734 @@ -0,0 +1,187 @@
64735 +#include <linux/kernel.h>
64736 +#include <linux/sched.h>
64737 +#include <linux/file.h>
64738 +#include <linux/binfmts.h>
64739 +#include <linux/fs.h>
64740 +#include <linux/types.h>
64741 +#include <linux/grdefs.h>
64742 +#include <linux/grsecurity.h>
64743 +#include <linux/grinternal.h>
64744 +#include <linux/capability.h>
64745 +#include <linux/module.h>
64746 +#include <linux/compat.h>
64747 +
64748 +#include <asm/uaccess.h>
64749 +
64750 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64751 +static char gr_exec_arg_buf[132];
64752 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64753 +#endif
64754 +
64755 +struct user_arg_ptr {
64756 +#ifdef CONFIG_COMPAT
64757 + bool is_compat;
64758 +#endif
64759 + union {
64760 + const char __user *const __user *native;
64761 +#ifdef CONFIG_COMPAT
64762 + const compat_uptr_t __user *compat;
64763 +#endif
64764 + } ptr;
64765 +};
64766 +
64767 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64768 +
64769 +void
64770 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64771 +{
64772 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64773 + char *grarg = gr_exec_arg_buf;
64774 + unsigned int i, x, execlen = 0;
64775 + char c;
64776 +
64777 + if (!((grsec_enable_execlog && grsec_enable_group &&
64778 + in_group_p(grsec_audit_gid))
64779 + || (grsec_enable_execlog && !grsec_enable_group)))
64780 + return;
64781 +
64782 + mutex_lock(&gr_exec_arg_mutex);
64783 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64784 +
64785 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64786 + const char __user *p;
64787 + unsigned int len;
64788 +
64789 + p = get_user_arg_ptr(argv, i);
64790 + if (IS_ERR(p))
64791 + goto log;
64792 +
64793 + len = strnlen_user(p, 128 - execlen);
64794 + if (len > 128 - execlen)
64795 + len = 128 - execlen;
64796 + else if (len > 0)
64797 + len--;
64798 + if (copy_from_user(grarg + execlen, p, len))
64799 + goto log;
64800 +
64801 + /* rewrite unprintable characters */
64802 + for (x = 0; x < len; x++) {
64803 + c = *(grarg + execlen + x);
64804 + if (c < 32 || c > 126)
64805 + *(grarg + execlen + x) = ' ';
64806 + }
64807 +
64808 + execlen += len;
64809 + *(grarg + execlen) = ' ';
64810 + *(grarg + execlen + 1) = '\0';
64811 + execlen++;
64812 + }
64813 +
64814 + log:
64815 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64816 + bprm->file->f_path.mnt, grarg);
64817 + mutex_unlock(&gr_exec_arg_mutex);
64818 +#endif
64819 + return;
64820 +}
64821 +
64822 +#ifdef CONFIG_GRKERNSEC
64823 +extern int gr_acl_is_capable(const int cap);
64824 +extern int gr_acl_is_capable_nolog(const int cap);
64825 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64826 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64827 +extern int gr_chroot_is_capable(const int cap);
64828 +extern int gr_chroot_is_capable_nolog(const int cap);
64829 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64830 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64831 +#endif
64832 +
64833 +const char *captab_log[] = {
64834 + "CAP_CHOWN",
64835 + "CAP_DAC_OVERRIDE",
64836 + "CAP_DAC_READ_SEARCH",
64837 + "CAP_FOWNER",
64838 + "CAP_FSETID",
64839 + "CAP_KILL",
64840 + "CAP_SETGID",
64841 + "CAP_SETUID",
64842 + "CAP_SETPCAP",
64843 + "CAP_LINUX_IMMUTABLE",
64844 + "CAP_NET_BIND_SERVICE",
64845 + "CAP_NET_BROADCAST",
64846 + "CAP_NET_ADMIN",
64847 + "CAP_NET_RAW",
64848 + "CAP_IPC_LOCK",
64849 + "CAP_IPC_OWNER",
64850 + "CAP_SYS_MODULE",
64851 + "CAP_SYS_RAWIO",
64852 + "CAP_SYS_CHROOT",
64853 + "CAP_SYS_PTRACE",
64854 + "CAP_SYS_PACCT",
64855 + "CAP_SYS_ADMIN",
64856 + "CAP_SYS_BOOT",
64857 + "CAP_SYS_NICE",
64858 + "CAP_SYS_RESOURCE",
64859 + "CAP_SYS_TIME",
64860 + "CAP_SYS_TTY_CONFIG",
64861 + "CAP_MKNOD",
64862 + "CAP_LEASE",
64863 + "CAP_AUDIT_WRITE",
64864 + "CAP_AUDIT_CONTROL",
64865 + "CAP_SETFCAP",
64866 + "CAP_MAC_OVERRIDE",
64867 + "CAP_MAC_ADMIN",
64868 + "CAP_SYSLOG",
64869 + "CAP_WAKE_ALARM"
64870 +};
64871 +
64872 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64873 +
64874 +int gr_is_capable(const int cap)
64875 +{
64876 +#ifdef CONFIG_GRKERNSEC
64877 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64878 + return 1;
64879 + return 0;
64880 +#else
64881 + return 1;
64882 +#endif
64883 +}
64884 +
64885 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64886 +{
64887 +#ifdef CONFIG_GRKERNSEC
64888 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64889 + return 1;
64890 + return 0;
64891 +#else
64892 + return 1;
64893 +#endif
64894 +}
64895 +
64896 +int gr_is_capable_nolog(const int cap)
64897 +{
64898 +#ifdef CONFIG_GRKERNSEC
64899 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64900 + return 1;
64901 + return 0;
64902 +#else
64903 + return 1;
64904 +#endif
64905 +}
64906 +
64907 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64908 +{
64909 +#ifdef CONFIG_GRKERNSEC
64910 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64911 + return 1;
64912 + return 0;
64913 +#else
64914 + return 1;
64915 +#endif
64916 +}
64917 +
64918 +EXPORT_SYMBOL(gr_is_capable);
64919 +EXPORT_SYMBOL(gr_is_capable_nolog);
64920 +EXPORT_SYMBOL(gr_task_is_capable);
64921 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64922 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64923 new file mode 100644
64924 index 0000000..06cc6ea
64925 --- /dev/null
64926 +++ b/grsecurity/grsec_fifo.c
64927 @@ -0,0 +1,24 @@
64928 +#include <linux/kernel.h>
64929 +#include <linux/sched.h>
64930 +#include <linux/fs.h>
64931 +#include <linux/file.h>
64932 +#include <linux/grinternal.h>
64933 +
64934 +int
64935 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64936 + const struct dentry *dir, const int flag, const int acc_mode)
64937 +{
64938 +#ifdef CONFIG_GRKERNSEC_FIFO
64939 + const struct cred *cred = current_cred();
64940 +
64941 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64942 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64943 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64944 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64945 + if (!inode_permission(dentry->d_inode, acc_mode))
64946 + 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));
64947 + return -EACCES;
64948 + }
64949 +#endif
64950 + return 0;
64951 +}
64952 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64953 new file mode 100644
64954 index 0000000..8ca18bf
64955 --- /dev/null
64956 +++ b/grsecurity/grsec_fork.c
64957 @@ -0,0 +1,23 @@
64958 +#include <linux/kernel.h>
64959 +#include <linux/sched.h>
64960 +#include <linux/grsecurity.h>
64961 +#include <linux/grinternal.h>
64962 +#include <linux/errno.h>
64963 +
64964 +void
64965 +gr_log_forkfail(const int retval)
64966 +{
64967 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64968 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64969 + switch (retval) {
64970 + case -EAGAIN:
64971 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64972 + break;
64973 + case -ENOMEM:
64974 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64975 + break;
64976 + }
64977 + }
64978 +#endif
64979 + return;
64980 +}
64981 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64982 new file mode 100644
64983 index 0000000..a862e9f
64984 --- /dev/null
64985 +++ b/grsecurity/grsec_init.c
64986 @@ -0,0 +1,283 @@
64987 +#include <linux/kernel.h>
64988 +#include <linux/sched.h>
64989 +#include <linux/mm.h>
64990 +#include <linux/gracl.h>
64991 +#include <linux/slab.h>
64992 +#include <linux/vmalloc.h>
64993 +#include <linux/percpu.h>
64994 +#include <linux/module.h>
64995 +
64996 +int grsec_enable_ptrace_readexec;
64997 +int grsec_enable_setxid;
64998 +int grsec_enable_symlinkown;
64999 +kgid_t grsec_symlinkown_gid;
65000 +int grsec_enable_brute;
65001 +int grsec_enable_link;
65002 +int grsec_enable_dmesg;
65003 +int grsec_enable_harden_ptrace;
65004 +int grsec_enable_fifo;
65005 +int grsec_enable_execlog;
65006 +int grsec_enable_signal;
65007 +int grsec_enable_forkfail;
65008 +int grsec_enable_audit_ptrace;
65009 +int grsec_enable_time;
65010 +int grsec_enable_audit_textrel;
65011 +int grsec_enable_group;
65012 +kgid_t grsec_audit_gid;
65013 +int grsec_enable_chdir;
65014 +int grsec_enable_mount;
65015 +int grsec_enable_rofs;
65016 +int grsec_enable_chroot_findtask;
65017 +int grsec_enable_chroot_mount;
65018 +int grsec_enable_chroot_shmat;
65019 +int grsec_enable_chroot_fchdir;
65020 +int grsec_enable_chroot_double;
65021 +int grsec_enable_chroot_pivot;
65022 +int grsec_enable_chroot_chdir;
65023 +int grsec_enable_chroot_chmod;
65024 +int grsec_enable_chroot_mknod;
65025 +int grsec_enable_chroot_nice;
65026 +int grsec_enable_chroot_execlog;
65027 +int grsec_enable_chroot_caps;
65028 +int grsec_enable_chroot_sysctl;
65029 +int grsec_enable_chroot_unix;
65030 +int grsec_enable_tpe;
65031 +kgid_t grsec_tpe_gid;
65032 +int grsec_enable_blackhole;
65033 +#ifdef CONFIG_IPV6_MODULE
65034 +EXPORT_SYMBOL(grsec_enable_blackhole);
65035 +#endif
65036 +int grsec_lastack_retries;
65037 +int grsec_enable_tpe_all;
65038 +int grsec_enable_tpe_invert;
65039 +int grsec_enable_socket_all;
65040 +kgid_t grsec_socket_all_gid;
65041 +int grsec_enable_socket_client;
65042 +kgid_t grsec_socket_client_gid;
65043 +int grsec_enable_socket_server;
65044 +kgid_t grsec_socket_server_gid;
65045 +int grsec_resource_logging;
65046 +int grsec_disable_privio;
65047 +int grsec_enable_log_rwxmaps;
65048 +int grsec_lock;
65049 +
65050 +DEFINE_SPINLOCK(grsec_alert_lock);
65051 +unsigned long grsec_alert_wtime = 0;
65052 +unsigned long grsec_alert_fyet = 0;
65053 +
65054 +DEFINE_SPINLOCK(grsec_audit_lock);
65055 +
65056 +DEFINE_RWLOCK(grsec_exec_file_lock);
65057 +
65058 +char *gr_shared_page[4];
65059 +
65060 +char *gr_alert_log_fmt;
65061 +char *gr_audit_log_fmt;
65062 +char *gr_alert_log_buf;
65063 +char *gr_audit_log_buf;
65064 +
65065 +extern struct gr_arg *gr_usermode;
65066 +extern unsigned char *gr_system_salt;
65067 +extern unsigned char *gr_system_sum;
65068 +
65069 +void __init
65070 +grsecurity_init(void)
65071 +{
65072 + int j;
65073 + /* create the per-cpu shared pages */
65074 +
65075 +#ifdef CONFIG_X86
65076 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65077 +#endif
65078 +
65079 + for (j = 0; j < 4; j++) {
65080 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65081 + if (gr_shared_page[j] == NULL) {
65082 + panic("Unable to allocate grsecurity shared page");
65083 + return;
65084 + }
65085 + }
65086 +
65087 + /* allocate log buffers */
65088 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65089 + if (!gr_alert_log_fmt) {
65090 + panic("Unable to allocate grsecurity alert log format buffer");
65091 + return;
65092 + }
65093 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65094 + if (!gr_audit_log_fmt) {
65095 + panic("Unable to allocate grsecurity audit log format buffer");
65096 + return;
65097 + }
65098 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65099 + if (!gr_alert_log_buf) {
65100 + panic("Unable to allocate grsecurity alert log buffer");
65101 + return;
65102 + }
65103 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65104 + if (!gr_audit_log_buf) {
65105 + panic("Unable to allocate grsecurity audit log buffer");
65106 + return;
65107 + }
65108 +
65109 + /* allocate memory for authentication structure */
65110 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65111 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65112 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65113 +
65114 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65115 + panic("Unable to allocate grsecurity authentication structure");
65116 + return;
65117 + }
65118 +
65119 +
65120 +#ifdef CONFIG_GRKERNSEC_IO
65121 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65122 + grsec_disable_privio = 1;
65123 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65124 + grsec_disable_privio = 1;
65125 +#else
65126 + grsec_disable_privio = 0;
65127 +#endif
65128 +#endif
65129 +
65130 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65131 + /* for backward compatibility, tpe_invert always defaults to on if
65132 + enabled in the kernel
65133 + */
65134 + grsec_enable_tpe_invert = 1;
65135 +#endif
65136 +
65137 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65138 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65139 + grsec_lock = 1;
65140 +#endif
65141 +
65142 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65143 + grsec_enable_audit_textrel = 1;
65144 +#endif
65145 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65146 + grsec_enable_log_rwxmaps = 1;
65147 +#endif
65148 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65149 + grsec_enable_group = 1;
65150 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65151 +#endif
65152 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65153 + grsec_enable_ptrace_readexec = 1;
65154 +#endif
65155 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65156 + grsec_enable_chdir = 1;
65157 +#endif
65158 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65159 + grsec_enable_harden_ptrace = 1;
65160 +#endif
65161 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65162 + grsec_enable_mount = 1;
65163 +#endif
65164 +#ifdef CONFIG_GRKERNSEC_LINK
65165 + grsec_enable_link = 1;
65166 +#endif
65167 +#ifdef CONFIG_GRKERNSEC_BRUTE
65168 + grsec_enable_brute = 1;
65169 +#endif
65170 +#ifdef CONFIG_GRKERNSEC_DMESG
65171 + grsec_enable_dmesg = 1;
65172 +#endif
65173 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65174 + grsec_enable_blackhole = 1;
65175 + grsec_lastack_retries = 4;
65176 +#endif
65177 +#ifdef CONFIG_GRKERNSEC_FIFO
65178 + grsec_enable_fifo = 1;
65179 +#endif
65180 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65181 + grsec_enable_execlog = 1;
65182 +#endif
65183 +#ifdef CONFIG_GRKERNSEC_SETXID
65184 + grsec_enable_setxid = 1;
65185 +#endif
65186 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65187 + grsec_enable_signal = 1;
65188 +#endif
65189 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65190 + grsec_enable_forkfail = 1;
65191 +#endif
65192 +#ifdef CONFIG_GRKERNSEC_TIME
65193 + grsec_enable_time = 1;
65194 +#endif
65195 +#ifdef CONFIG_GRKERNSEC_RESLOG
65196 + grsec_resource_logging = 1;
65197 +#endif
65198 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65199 + grsec_enable_chroot_findtask = 1;
65200 +#endif
65201 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65202 + grsec_enable_chroot_unix = 1;
65203 +#endif
65204 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65205 + grsec_enable_chroot_mount = 1;
65206 +#endif
65207 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65208 + grsec_enable_chroot_fchdir = 1;
65209 +#endif
65210 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65211 + grsec_enable_chroot_shmat = 1;
65212 +#endif
65213 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65214 + grsec_enable_audit_ptrace = 1;
65215 +#endif
65216 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65217 + grsec_enable_chroot_double = 1;
65218 +#endif
65219 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65220 + grsec_enable_chroot_pivot = 1;
65221 +#endif
65222 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65223 + grsec_enable_chroot_chdir = 1;
65224 +#endif
65225 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65226 + grsec_enable_chroot_chmod = 1;
65227 +#endif
65228 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65229 + grsec_enable_chroot_mknod = 1;
65230 +#endif
65231 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65232 + grsec_enable_chroot_nice = 1;
65233 +#endif
65234 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65235 + grsec_enable_chroot_execlog = 1;
65236 +#endif
65237 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65238 + grsec_enable_chroot_caps = 1;
65239 +#endif
65240 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65241 + grsec_enable_chroot_sysctl = 1;
65242 +#endif
65243 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65244 + grsec_enable_symlinkown = 1;
65245 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65246 +#endif
65247 +#ifdef CONFIG_GRKERNSEC_TPE
65248 + grsec_enable_tpe = 1;
65249 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65250 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65251 + grsec_enable_tpe_all = 1;
65252 +#endif
65253 +#endif
65254 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65255 + grsec_enable_socket_all = 1;
65256 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65257 +#endif
65258 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65259 + grsec_enable_socket_client = 1;
65260 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65261 +#endif
65262 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65263 + grsec_enable_socket_server = 1;
65264 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65265 +#endif
65266 +#endif
65267 +
65268 + return;
65269 +}
65270 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65271 new file mode 100644
65272 index 0000000..5e05e20
65273 --- /dev/null
65274 +++ b/grsecurity/grsec_link.c
65275 @@ -0,0 +1,58 @@
65276 +#include <linux/kernel.h>
65277 +#include <linux/sched.h>
65278 +#include <linux/fs.h>
65279 +#include <linux/file.h>
65280 +#include <linux/grinternal.h>
65281 +
65282 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65283 +{
65284 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65285 + const struct inode *link_inode = link->dentry->d_inode;
65286 +
65287 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65288 + /* ignore root-owned links, e.g. /proc/self */
65289 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65290 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65291 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65292 + return 1;
65293 + }
65294 +#endif
65295 + return 0;
65296 +}
65297 +
65298 +int
65299 +gr_handle_follow_link(const struct inode *parent,
65300 + const struct inode *inode,
65301 + const struct dentry *dentry, const struct vfsmount *mnt)
65302 +{
65303 +#ifdef CONFIG_GRKERNSEC_LINK
65304 + const struct cred *cred = current_cred();
65305 +
65306 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65307 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65308 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65309 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65310 + return -EACCES;
65311 + }
65312 +#endif
65313 + return 0;
65314 +}
65315 +
65316 +int
65317 +gr_handle_hardlink(const struct dentry *dentry,
65318 + const struct vfsmount *mnt,
65319 + struct inode *inode, const int mode, const struct filename *to)
65320 +{
65321 +#ifdef CONFIG_GRKERNSEC_LINK
65322 + const struct cred *cred = current_cred();
65323 +
65324 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65325 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65326 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65327 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65328 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65329 + return -EPERM;
65330 + }
65331 +#endif
65332 + return 0;
65333 +}
65334 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65335 new file mode 100644
65336 index 0000000..7c06085
65337 --- /dev/null
65338 +++ b/grsecurity/grsec_log.c
65339 @@ -0,0 +1,326 @@
65340 +#include <linux/kernel.h>
65341 +#include <linux/sched.h>
65342 +#include <linux/file.h>
65343 +#include <linux/tty.h>
65344 +#include <linux/fs.h>
65345 +#include <linux/grinternal.h>
65346 +
65347 +#ifdef CONFIG_TREE_PREEMPT_RCU
65348 +#define DISABLE_PREEMPT() preempt_disable()
65349 +#define ENABLE_PREEMPT() preempt_enable()
65350 +#else
65351 +#define DISABLE_PREEMPT()
65352 +#define ENABLE_PREEMPT()
65353 +#endif
65354 +
65355 +#define BEGIN_LOCKS(x) \
65356 + DISABLE_PREEMPT(); \
65357 + rcu_read_lock(); \
65358 + read_lock(&tasklist_lock); \
65359 + read_lock(&grsec_exec_file_lock); \
65360 + if (x != GR_DO_AUDIT) \
65361 + spin_lock(&grsec_alert_lock); \
65362 + else \
65363 + spin_lock(&grsec_audit_lock)
65364 +
65365 +#define END_LOCKS(x) \
65366 + if (x != GR_DO_AUDIT) \
65367 + spin_unlock(&grsec_alert_lock); \
65368 + else \
65369 + spin_unlock(&grsec_audit_lock); \
65370 + read_unlock(&grsec_exec_file_lock); \
65371 + read_unlock(&tasklist_lock); \
65372 + rcu_read_unlock(); \
65373 + ENABLE_PREEMPT(); \
65374 + if (x == GR_DONT_AUDIT) \
65375 + gr_handle_alertkill(current)
65376 +
65377 +enum {
65378 + FLOODING,
65379 + NO_FLOODING
65380 +};
65381 +
65382 +extern char *gr_alert_log_fmt;
65383 +extern char *gr_audit_log_fmt;
65384 +extern char *gr_alert_log_buf;
65385 +extern char *gr_audit_log_buf;
65386 +
65387 +static int gr_log_start(int audit)
65388 +{
65389 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65390 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65391 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65392 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65393 + unsigned long curr_secs = get_seconds();
65394 +
65395 + if (audit == GR_DO_AUDIT)
65396 + goto set_fmt;
65397 +
65398 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65399 + grsec_alert_wtime = curr_secs;
65400 + grsec_alert_fyet = 0;
65401 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65402 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65403 + grsec_alert_fyet++;
65404 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65405 + grsec_alert_wtime = curr_secs;
65406 + grsec_alert_fyet++;
65407 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65408 + return FLOODING;
65409 + }
65410 + else return FLOODING;
65411 +
65412 +set_fmt:
65413 +#endif
65414 + memset(buf, 0, PAGE_SIZE);
65415 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65416 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65417 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65418 + } else if (current->signal->curr_ip) {
65419 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65420 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65421 + } else if (gr_acl_is_enabled()) {
65422 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65423 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65424 + } else {
65425 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65426 + strcpy(buf, fmt);
65427 + }
65428 +
65429 + return NO_FLOODING;
65430 +}
65431 +
65432 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65433 + __attribute__ ((format (printf, 2, 0)));
65434 +
65435 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65436 +{
65437 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65438 + unsigned int len = strlen(buf);
65439 +
65440 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65441 +
65442 + return;
65443 +}
65444 +
65445 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65446 + __attribute__ ((format (printf, 2, 3)));
65447 +
65448 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65449 +{
65450 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65451 + unsigned int len = strlen(buf);
65452 + va_list ap;
65453 +
65454 + va_start(ap, msg);
65455 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65456 + va_end(ap);
65457 +
65458 + return;
65459 +}
65460 +
65461 +static void gr_log_end(int audit, int append_default)
65462 +{
65463 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65464 + if (append_default) {
65465 + struct task_struct *task = current;
65466 + struct task_struct *parent = task->real_parent;
65467 + const struct cred *cred = __task_cred(task);
65468 + const struct cred *pcred = __task_cred(parent);
65469 + unsigned int len = strlen(buf);
65470 +
65471 + 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));
65472 + }
65473 +
65474 + printk("%s\n", buf);
65475 +
65476 + return;
65477 +}
65478 +
65479 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65480 +{
65481 + int logtype;
65482 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65483 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65484 + void *voidptr = NULL;
65485 + int num1 = 0, num2 = 0;
65486 + unsigned long ulong1 = 0, ulong2 = 0;
65487 + struct dentry *dentry = NULL;
65488 + struct vfsmount *mnt = NULL;
65489 + struct file *file = NULL;
65490 + struct task_struct *task = NULL;
65491 + const struct cred *cred, *pcred;
65492 + va_list ap;
65493 +
65494 + BEGIN_LOCKS(audit);
65495 + logtype = gr_log_start(audit);
65496 + if (logtype == FLOODING) {
65497 + END_LOCKS(audit);
65498 + return;
65499 + }
65500 + va_start(ap, argtypes);
65501 + switch (argtypes) {
65502 + case GR_TTYSNIFF:
65503 + task = va_arg(ap, struct task_struct *);
65504 + 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));
65505 + break;
65506 + case GR_SYSCTL_HIDDEN:
65507 + str1 = va_arg(ap, char *);
65508 + gr_log_middle_varargs(audit, msg, result, str1);
65509 + break;
65510 + case GR_RBAC:
65511 + dentry = va_arg(ap, struct dentry *);
65512 + mnt = va_arg(ap, struct vfsmount *);
65513 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65514 + break;
65515 + case GR_RBAC_STR:
65516 + dentry = va_arg(ap, struct dentry *);
65517 + mnt = va_arg(ap, struct vfsmount *);
65518 + str1 = va_arg(ap, char *);
65519 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65520 + break;
65521 + case GR_STR_RBAC:
65522 + str1 = va_arg(ap, char *);
65523 + dentry = va_arg(ap, struct dentry *);
65524 + mnt = va_arg(ap, struct vfsmount *);
65525 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65526 + break;
65527 + case GR_RBAC_MODE2:
65528 + dentry = va_arg(ap, struct dentry *);
65529 + mnt = va_arg(ap, struct vfsmount *);
65530 + str1 = va_arg(ap, char *);
65531 + str2 = va_arg(ap, char *);
65532 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65533 + break;
65534 + case GR_RBAC_MODE3:
65535 + dentry = va_arg(ap, struct dentry *);
65536 + mnt = va_arg(ap, struct vfsmount *);
65537 + str1 = va_arg(ap, char *);
65538 + str2 = va_arg(ap, char *);
65539 + str3 = va_arg(ap, char *);
65540 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65541 + break;
65542 + case GR_FILENAME:
65543 + dentry = va_arg(ap, struct dentry *);
65544 + mnt = va_arg(ap, struct vfsmount *);
65545 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65546 + break;
65547 + case GR_STR_FILENAME:
65548 + str1 = va_arg(ap, char *);
65549 + dentry = va_arg(ap, struct dentry *);
65550 + mnt = va_arg(ap, struct vfsmount *);
65551 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65552 + break;
65553 + case GR_FILENAME_STR:
65554 + dentry = va_arg(ap, struct dentry *);
65555 + mnt = va_arg(ap, struct vfsmount *);
65556 + str1 = va_arg(ap, char *);
65557 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65558 + break;
65559 + case GR_FILENAME_TWO_INT:
65560 + dentry = va_arg(ap, struct dentry *);
65561 + mnt = va_arg(ap, struct vfsmount *);
65562 + num1 = va_arg(ap, int);
65563 + num2 = va_arg(ap, int);
65564 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65565 + break;
65566 + case GR_FILENAME_TWO_INT_STR:
65567 + dentry = va_arg(ap, struct dentry *);
65568 + mnt = va_arg(ap, struct vfsmount *);
65569 + num1 = va_arg(ap, int);
65570 + num2 = va_arg(ap, int);
65571 + str1 = va_arg(ap, char *);
65572 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65573 + break;
65574 + case GR_TEXTREL:
65575 + file = va_arg(ap, struct file *);
65576 + ulong1 = va_arg(ap, unsigned long);
65577 + ulong2 = va_arg(ap, unsigned long);
65578 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65579 + break;
65580 + case GR_PTRACE:
65581 + task = va_arg(ap, struct task_struct *);
65582 + 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));
65583 + break;
65584 + case GR_RESOURCE:
65585 + task = va_arg(ap, struct task_struct *);
65586 + cred = __task_cred(task);
65587 + pcred = __task_cred(task->real_parent);
65588 + ulong1 = va_arg(ap, unsigned long);
65589 + str1 = va_arg(ap, char *);
65590 + ulong2 = va_arg(ap, unsigned long);
65591 + 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));
65592 + break;
65593 + case GR_CAP:
65594 + task = va_arg(ap, struct task_struct *);
65595 + cred = __task_cred(task);
65596 + pcred = __task_cred(task->real_parent);
65597 + str1 = va_arg(ap, char *);
65598 + 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));
65599 + break;
65600 + case GR_SIG:
65601 + str1 = va_arg(ap, char *);
65602 + voidptr = va_arg(ap, void *);
65603 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65604 + break;
65605 + case GR_SIG2:
65606 + task = va_arg(ap, struct task_struct *);
65607 + cred = __task_cred(task);
65608 + pcred = __task_cred(task->real_parent);
65609 + num1 = va_arg(ap, int);
65610 + 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));
65611 + break;
65612 + case GR_CRASH1:
65613 + task = va_arg(ap, struct task_struct *);
65614 + cred = __task_cred(task);
65615 + pcred = __task_cred(task->real_parent);
65616 + ulong1 = va_arg(ap, unsigned long);
65617 + 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);
65618 + break;
65619 + case GR_CRASH2:
65620 + task = va_arg(ap, struct task_struct *);
65621 + cred = __task_cred(task);
65622 + pcred = __task_cred(task->real_parent);
65623 + ulong1 = va_arg(ap, unsigned long);
65624 + 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);
65625 + break;
65626 + case GR_RWXMAP:
65627 + file = va_arg(ap, struct file *);
65628 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65629 + break;
65630 + case GR_PSACCT:
65631 + {
65632 + unsigned int wday, cday;
65633 + __u8 whr, chr;
65634 + __u8 wmin, cmin;
65635 + __u8 wsec, csec;
65636 + char cur_tty[64] = { 0 };
65637 + char parent_tty[64] = { 0 };
65638 +
65639 + task = va_arg(ap, struct task_struct *);
65640 + wday = va_arg(ap, unsigned int);
65641 + cday = va_arg(ap, unsigned int);
65642 + whr = va_arg(ap, int);
65643 + chr = va_arg(ap, int);
65644 + wmin = va_arg(ap, int);
65645 + cmin = va_arg(ap, int);
65646 + wsec = va_arg(ap, int);
65647 + csec = va_arg(ap, int);
65648 + ulong1 = va_arg(ap, unsigned long);
65649 + cred = __task_cred(task);
65650 + pcred = __task_cred(task->real_parent);
65651 +
65652 + 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));
65653 + }
65654 + break;
65655 + default:
65656 + gr_log_middle(audit, msg, ap);
65657 + }
65658 + va_end(ap);
65659 + // these don't need DEFAULTSECARGS printed on the end
65660 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65661 + gr_log_end(audit, 0);
65662 + else
65663 + gr_log_end(audit, 1);
65664 + END_LOCKS(audit);
65665 +}
65666 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65667 new file mode 100644
65668 index 0000000..f536303
65669 --- /dev/null
65670 +++ b/grsecurity/grsec_mem.c
65671 @@ -0,0 +1,40 @@
65672 +#include <linux/kernel.h>
65673 +#include <linux/sched.h>
65674 +#include <linux/mm.h>
65675 +#include <linux/mman.h>
65676 +#include <linux/grinternal.h>
65677 +
65678 +void
65679 +gr_handle_ioperm(void)
65680 +{
65681 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65682 + return;
65683 +}
65684 +
65685 +void
65686 +gr_handle_iopl(void)
65687 +{
65688 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65689 + return;
65690 +}
65691 +
65692 +void
65693 +gr_handle_mem_readwrite(u64 from, u64 to)
65694 +{
65695 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65696 + return;
65697 +}
65698 +
65699 +void
65700 +gr_handle_vm86(void)
65701 +{
65702 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65703 + return;
65704 +}
65705 +
65706 +void
65707 +gr_log_badprocpid(const char *entry)
65708 +{
65709 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65710 + return;
65711 +}
65712 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65713 new file mode 100644
65714 index 0000000..2131422
65715 --- /dev/null
65716 +++ b/grsecurity/grsec_mount.c
65717 @@ -0,0 +1,62 @@
65718 +#include <linux/kernel.h>
65719 +#include <linux/sched.h>
65720 +#include <linux/mount.h>
65721 +#include <linux/grsecurity.h>
65722 +#include <linux/grinternal.h>
65723 +
65724 +void
65725 +gr_log_remount(const char *devname, const int retval)
65726 +{
65727 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65728 + if (grsec_enable_mount && (retval >= 0))
65729 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65730 +#endif
65731 + return;
65732 +}
65733 +
65734 +void
65735 +gr_log_unmount(const char *devname, const int retval)
65736 +{
65737 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65738 + if (grsec_enable_mount && (retval >= 0))
65739 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65740 +#endif
65741 + return;
65742 +}
65743 +
65744 +void
65745 +gr_log_mount(const char *from, const char *to, const int retval)
65746 +{
65747 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65748 + if (grsec_enable_mount && (retval >= 0))
65749 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65750 +#endif
65751 + return;
65752 +}
65753 +
65754 +int
65755 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65756 +{
65757 +#ifdef CONFIG_GRKERNSEC_ROFS
65758 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65759 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65760 + return -EPERM;
65761 + } else
65762 + return 0;
65763 +#endif
65764 + return 0;
65765 +}
65766 +
65767 +int
65768 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65769 +{
65770 +#ifdef CONFIG_GRKERNSEC_ROFS
65771 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65772 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65773 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65774 + return -EPERM;
65775 + } else
65776 + return 0;
65777 +#endif
65778 + return 0;
65779 +}
65780 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65781 new file mode 100644
65782 index 0000000..a3b12a0
65783 --- /dev/null
65784 +++ b/grsecurity/grsec_pax.c
65785 @@ -0,0 +1,36 @@
65786 +#include <linux/kernel.h>
65787 +#include <linux/sched.h>
65788 +#include <linux/mm.h>
65789 +#include <linux/file.h>
65790 +#include <linux/grinternal.h>
65791 +#include <linux/grsecurity.h>
65792 +
65793 +void
65794 +gr_log_textrel(struct vm_area_struct * vma)
65795 +{
65796 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65797 + if (grsec_enable_audit_textrel)
65798 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65799 +#endif
65800 + return;
65801 +}
65802 +
65803 +void
65804 +gr_log_rwxmmap(struct file *file)
65805 +{
65806 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65807 + if (grsec_enable_log_rwxmaps)
65808 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65809 +#endif
65810 + return;
65811 +}
65812 +
65813 +void
65814 +gr_log_rwxmprotect(struct file *file)
65815 +{
65816 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65817 + if (grsec_enable_log_rwxmaps)
65818 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65819 +#endif
65820 + return;
65821 +}
65822 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65823 new file mode 100644
65824 index 0000000..f7f29aa
65825 --- /dev/null
65826 +++ b/grsecurity/grsec_ptrace.c
65827 @@ -0,0 +1,30 @@
65828 +#include <linux/kernel.h>
65829 +#include <linux/sched.h>
65830 +#include <linux/grinternal.h>
65831 +#include <linux/security.h>
65832 +
65833 +void
65834 +gr_audit_ptrace(struct task_struct *task)
65835 +{
65836 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65837 + if (grsec_enable_audit_ptrace)
65838 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65839 +#endif
65840 + return;
65841 +}
65842 +
65843 +int
65844 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65845 +{
65846 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65847 + const struct dentry *dentry = file->f_path.dentry;
65848 + const struct vfsmount *mnt = file->f_path.mnt;
65849 +
65850 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65851 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65852 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65853 + return -EACCES;
65854 + }
65855 +#endif
65856 + return 0;
65857 +}
65858 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65859 new file mode 100644
65860 index 0000000..e09715a
65861 --- /dev/null
65862 +++ b/grsecurity/grsec_sig.c
65863 @@ -0,0 +1,222 @@
65864 +#include <linux/kernel.h>
65865 +#include <linux/sched.h>
65866 +#include <linux/delay.h>
65867 +#include <linux/grsecurity.h>
65868 +#include <linux/grinternal.h>
65869 +#include <linux/hardirq.h>
65870 +
65871 +char *signames[] = {
65872 + [SIGSEGV] = "Segmentation fault",
65873 + [SIGILL] = "Illegal instruction",
65874 + [SIGABRT] = "Abort",
65875 + [SIGBUS] = "Invalid alignment/Bus error"
65876 +};
65877 +
65878 +void
65879 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65880 +{
65881 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65882 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65883 + (sig == SIGABRT) || (sig == SIGBUS))) {
65884 + if (task_pid_nr(t) == task_pid_nr(current)) {
65885 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65886 + } else {
65887 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65888 + }
65889 + }
65890 +#endif
65891 + return;
65892 +}
65893 +
65894 +int
65895 +gr_handle_signal(const struct task_struct *p, const int sig)
65896 +{
65897 +#ifdef CONFIG_GRKERNSEC
65898 + /* ignore the 0 signal for protected task checks */
65899 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65900 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65901 + return -EPERM;
65902 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65903 + return -EPERM;
65904 + }
65905 +#endif
65906 + return 0;
65907 +}
65908 +
65909 +#ifdef CONFIG_GRKERNSEC
65910 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65911 +
65912 +int gr_fake_force_sig(int sig, struct task_struct *t)
65913 +{
65914 + unsigned long int flags;
65915 + int ret, blocked, ignored;
65916 + struct k_sigaction *action;
65917 +
65918 + spin_lock_irqsave(&t->sighand->siglock, flags);
65919 + action = &t->sighand->action[sig-1];
65920 + ignored = action->sa.sa_handler == SIG_IGN;
65921 + blocked = sigismember(&t->blocked, sig);
65922 + if (blocked || ignored) {
65923 + action->sa.sa_handler = SIG_DFL;
65924 + if (blocked) {
65925 + sigdelset(&t->blocked, sig);
65926 + recalc_sigpending_and_wake(t);
65927 + }
65928 + }
65929 + if (action->sa.sa_handler == SIG_DFL)
65930 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65931 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65932 +
65933 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65934 +
65935 + return ret;
65936 +}
65937 +#endif
65938 +
65939 +#ifdef CONFIG_GRKERNSEC_BRUTE
65940 +#define GR_USER_BAN_TIME (15 * 60)
65941 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65942 +
65943 +static int __get_dumpable(unsigned long mm_flags)
65944 +{
65945 + int ret;
65946 +
65947 + ret = mm_flags & MMF_DUMPABLE_MASK;
65948 + return (ret >= 2) ? 2 : ret;
65949 +}
65950 +#endif
65951 +
65952 +void gr_handle_brute_attach(unsigned long mm_flags)
65953 +{
65954 +#ifdef CONFIG_GRKERNSEC_BRUTE
65955 + struct task_struct *p = current;
65956 + kuid_t uid = GLOBAL_ROOT_UID;
65957 + int daemon = 0;
65958 +
65959 + if (!grsec_enable_brute)
65960 + return;
65961 +
65962 + rcu_read_lock();
65963 + read_lock(&tasklist_lock);
65964 + read_lock(&grsec_exec_file_lock);
65965 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65966 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65967 + p->real_parent->brute = 1;
65968 + daemon = 1;
65969 + } else {
65970 + const struct cred *cred = __task_cred(p), *cred2;
65971 + struct task_struct *tsk, *tsk2;
65972 +
65973 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65974 + struct user_struct *user;
65975 +
65976 + uid = cred->uid;
65977 +
65978 + /* this is put upon execution past expiration */
65979 + user = find_user(uid);
65980 + if (user == NULL)
65981 + goto unlock;
65982 + user->banned = 1;
65983 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65984 + if (user->ban_expires == ~0UL)
65985 + user->ban_expires--;
65986 +
65987 + do_each_thread(tsk2, tsk) {
65988 + cred2 = __task_cred(tsk);
65989 + if (tsk != p && uid_eq(cred2->uid, uid))
65990 + gr_fake_force_sig(SIGKILL, tsk);
65991 + } while_each_thread(tsk2, tsk);
65992 + }
65993 + }
65994 +unlock:
65995 + read_unlock(&grsec_exec_file_lock);
65996 + read_unlock(&tasklist_lock);
65997 + rcu_read_unlock();
65998 +
65999 + if (gr_is_global_nonroot(uid))
66000 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
66001 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
66002 + else if (daemon)
66003 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66004 +
66005 +#endif
66006 + return;
66007 +}
66008 +
66009 +void gr_handle_brute_check(void)
66010 +{
66011 +#ifdef CONFIG_GRKERNSEC_BRUTE
66012 + struct task_struct *p = current;
66013 +
66014 + if (unlikely(p->brute)) {
66015 + if (!grsec_enable_brute)
66016 + p->brute = 0;
66017 + else if (time_before(get_seconds(), p->brute_expires))
66018 + msleep(30 * 1000);
66019 + }
66020 +#endif
66021 + return;
66022 +}
66023 +
66024 +void gr_handle_kernel_exploit(void)
66025 +{
66026 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66027 + const struct cred *cred;
66028 + struct task_struct *tsk, *tsk2;
66029 + struct user_struct *user;
66030 + kuid_t uid;
66031 +
66032 + if (in_irq() || in_serving_softirq() || in_nmi())
66033 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66034 +
66035 + uid = current_uid();
66036 +
66037 + if (gr_is_global_root(uid))
66038 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66039 + else {
66040 + /* kill all the processes of this user, hold a reference
66041 + to their creds struct, and prevent them from creating
66042 + another process until system reset
66043 + */
66044 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66045 + GR_GLOBAL_UID(uid));
66046 + /* we intentionally leak this ref */
66047 + user = get_uid(current->cred->user);
66048 + if (user) {
66049 + user->banned = 1;
66050 + user->ban_expires = ~0UL;
66051 + }
66052 +
66053 + read_lock(&tasklist_lock);
66054 + do_each_thread(tsk2, tsk) {
66055 + cred = __task_cred(tsk);
66056 + if (uid_eq(cred->uid, uid))
66057 + gr_fake_force_sig(SIGKILL, tsk);
66058 + } while_each_thread(tsk2, tsk);
66059 + read_unlock(&tasklist_lock);
66060 + }
66061 +#endif
66062 +}
66063 +
66064 +int __gr_process_user_ban(struct user_struct *user)
66065 +{
66066 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66067 + if (unlikely(user->banned)) {
66068 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
66069 + user->banned = 0;
66070 + user->ban_expires = 0;
66071 + free_uid(user);
66072 + } else
66073 + return -EPERM;
66074 + }
66075 +#endif
66076 + return 0;
66077 +}
66078 +
66079 +int gr_process_user_ban(void)
66080 +{
66081 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66082 + return __gr_process_user_ban(current->cred->user);
66083 +#endif
66084 + return 0;
66085 +}
66086 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66087 new file mode 100644
66088 index 0000000..4030d57
66089 --- /dev/null
66090 +++ b/grsecurity/grsec_sock.c
66091 @@ -0,0 +1,244 @@
66092 +#include <linux/kernel.h>
66093 +#include <linux/module.h>
66094 +#include <linux/sched.h>
66095 +#include <linux/file.h>
66096 +#include <linux/net.h>
66097 +#include <linux/in.h>
66098 +#include <linux/ip.h>
66099 +#include <net/sock.h>
66100 +#include <net/inet_sock.h>
66101 +#include <linux/grsecurity.h>
66102 +#include <linux/grinternal.h>
66103 +#include <linux/gracl.h>
66104 +
66105 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66106 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66107 +
66108 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66109 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66110 +
66111 +#ifdef CONFIG_UNIX_MODULE
66112 +EXPORT_SYMBOL(gr_acl_handle_unix);
66113 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66114 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66115 +EXPORT_SYMBOL(gr_handle_create);
66116 +#endif
66117 +
66118 +#ifdef CONFIG_GRKERNSEC
66119 +#define gr_conn_table_size 32749
66120 +struct conn_table_entry {
66121 + struct conn_table_entry *next;
66122 + struct signal_struct *sig;
66123 +};
66124 +
66125 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66126 +DEFINE_SPINLOCK(gr_conn_table_lock);
66127 +
66128 +extern const char * gr_socktype_to_name(unsigned char type);
66129 +extern const char * gr_proto_to_name(unsigned char proto);
66130 +extern const char * gr_sockfamily_to_name(unsigned char family);
66131 +
66132 +static __inline__ int
66133 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66134 +{
66135 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66136 +}
66137 +
66138 +static __inline__ int
66139 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66140 + __u16 sport, __u16 dport)
66141 +{
66142 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66143 + sig->gr_sport == sport && sig->gr_dport == dport))
66144 + return 1;
66145 + else
66146 + return 0;
66147 +}
66148 +
66149 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66150 +{
66151 + struct conn_table_entry **match;
66152 + unsigned int index;
66153 +
66154 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66155 + sig->gr_sport, sig->gr_dport,
66156 + gr_conn_table_size);
66157 +
66158 + newent->sig = sig;
66159 +
66160 + match = &gr_conn_table[index];
66161 + newent->next = *match;
66162 + *match = newent;
66163 +
66164 + return;
66165 +}
66166 +
66167 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66168 +{
66169 + struct conn_table_entry *match, *last = NULL;
66170 + unsigned int index;
66171 +
66172 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66173 + sig->gr_sport, sig->gr_dport,
66174 + gr_conn_table_size);
66175 +
66176 + match = gr_conn_table[index];
66177 + while (match && !conn_match(match->sig,
66178 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66179 + sig->gr_dport)) {
66180 + last = match;
66181 + match = match->next;
66182 + }
66183 +
66184 + if (match) {
66185 + if (last)
66186 + last->next = match->next;
66187 + else
66188 + gr_conn_table[index] = NULL;
66189 + kfree(match);
66190 + }
66191 +
66192 + return;
66193 +}
66194 +
66195 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66196 + __u16 sport, __u16 dport)
66197 +{
66198 + struct conn_table_entry *match;
66199 + unsigned int index;
66200 +
66201 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66202 +
66203 + match = gr_conn_table[index];
66204 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66205 + match = match->next;
66206 +
66207 + if (match)
66208 + return match->sig;
66209 + else
66210 + return NULL;
66211 +}
66212 +
66213 +#endif
66214 +
66215 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66216 +{
66217 +#ifdef CONFIG_GRKERNSEC
66218 + struct signal_struct *sig = task->signal;
66219 + struct conn_table_entry *newent;
66220 +
66221 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66222 + if (newent == NULL)
66223 + return;
66224 + /* no bh lock needed since we are called with bh disabled */
66225 + spin_lock(&gr_conn_table_lock);
66226 + gr_del_task_from_ip_table_nolock(sig);
66227 + sig->gr_saddr = inet->inet_rcv_saddr;
66228 + sig->gr_daddr = inet->inet_daddr;
66229 + sig->gr_sport = inet->inet_sport;
66230 + sig->gr_dport = inet->inet_dport;
66231 + gr_add_to_task_ip_table_nolock(sig, newent);
66232 + spin_unlock(&gr_conn_table_lock);
66233 +#endif
66234 + return;
66235 +}
66236 +
66237 +void gr_del_task_from_ip_table(struct task_struct *task)
66238 +{
66239 +#ifdef CONFIG_GRKERNSEC
66240 + spin_lock_bh(&gr_conn_table_lock);
66241 + gr_del_task_from_ip_table_nolock(task->signal);
66242 + spin_unlock_bh(&gr_conn_table_lock);
66243 +#endif
66244 + return;
66245 +}
66246 +
66247 +void
66248 +gr_attach_curr_ip(const struct sock *sk)
66249 +{
66250 +#ifdef CONFIG_GRKERNSEC
66251 + struct signal_struct *p, *set;
66252 + const struct inet_sock *inet = inet_sk(sk);
66253 +
66254 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66255 + return;
66256 +
66257 + set = current->signal;
66258 +
66259 + spin_lock_bh(&gr_conn_table_lock);
66260 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66261 + inet->inet_dport, inet->inet_sport);
66262 + if (unlikely(p != NULL)) {
66263 + set->curr_ip = p->curr_ip;
66264 + set->used_accept = 1;
66265 + gr_del_task_from_ip_table_nolock(p);
66266 + spin_unlock_bh(&gr_conn_table_lock);
66267 + return;
66268 + }
66269 + spin_unlock_bh(&gr_conn_table_lock);
66270 +
66271 + set->curr_ip = inet->inet_daddr;
66272 + set->used_accept = 1;
66273 +#endif
66274 + return;
66275 +}
66276 +
66277 +int
66278 +gr_handle_sock_all(const int family, const int type, const int protocol)
66279 +{
66280 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66281 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66282 + (family != AF_UNIX)) {
66283 + if (family == AF_INET)
66284 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66285 + else
66286 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66287 + return -EACCES;
66288 + }
66289 +#endif
66290 + return 0;
66291 +}
66292 +
66293 +int
66294 +gr_handle_sock_server(const struct sockaddr *sck)
66295 +{
66296 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66297 + if (grsec_enable_socket_server &&
66298 + in_group_p(grsec_socket_server_gid) &&
66299 + sck && (sck->sa_family != AF_UNIX) &&
66300 + (sck->sa_family != AF_LOCAL)) {
66301 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66302 + return -EACCES;
66303 + }
66304 +#endif
66305 + return 0;
66306 +}
66307 +
66308 +int
66309 +gr_handle_sock_server_other(const struct sock *sck)
66310 +{
66311 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66312 + if (grsec_enable_socket_server &&
66313 + in_group_p(grsec_socket_server_gid) &&
66314 + sck && (sck->sk_family != AF_UNIX) &&
66315 + (sck->sk_family != AF_LOCAL)) {
66316 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66317 + return -EACCES;
66318 + }
66319 +#endif
66320 + return 0;
66321 +}
66322 +
66323 +int
66324 +gr_handle_sock_client(const struct sockaddr *sck)
66325 +{
66326 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66327 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66328 + sck && (sck->sa_family != AF_UNIX) &&
66329 + (sck->sa_family != AF_LOCAL)) {
66330 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66331 + return -EACCES;
66332 + }
66333 +#endif
66334 + return 0;
66335 +}
66336 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66337 new file mode 100644
66338 index 0000000..f55ef0f
66339 --- /dev/null
66340 +++ b/grsecurity/grsec_sysctl.c
66341 @@ -0,0 +1,469 @@
66342 +#include <linux/kernel.h>
66343 +#include <linux/sched.h>
66344 +#include <linux/sysctl.h>
66345 +#include <linux/grsecurity.h>
66346 +#include <linux/grinternal.h>
66347 +
66348 +int
66349 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66350 +{
66351 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66352 + if (dirname == NULL || name == NULL)
66353 + return 0;
66354 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66355 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66356 + return -EACCES;
66357 + }
66358 +#endif
66359 + return 0;
66360 +}
66361 +
66362 +#ifdef CONFIG_GRKERNSEC_ROFS
66363 +static int __maybe_unused one = 1;
66364 +#endif
66365 +
66366 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66367 +struct ctl_table grsecurity_table[] = {
66368 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66369 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66370 +#ifdef CONFIG_GRKERNSEC_IO
66371 + {
66372 + .procname = "disable_priv_io",
66373 + .data = &grsec_disable_privio,
66374 + .maxlen = sizeof(int),
66375 + .mode = 0600,
66376 + .proc_handler = &proc_dointvec,
66377 + },
66378 +#endif
66379 +#endif
66380 +#ifdef CONFIG_GRKERNSEC_LINK
66381 + {
66382 + .procname = "linking_restrictions",
66383 + .data = &grsec_enable_link,
66384 + .maxlen = sizeof(int),
66385 + .mode = 0600,
66386 + .proc_handler = &proc_dointvec,
66387 + },
66388 +#endif
66389 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66390 + {
66391 + .procname = "enforce_symlinksifowner",
66392 + .data = &grsec_enable_symlinkown,
66393 + .maxlen = sizeof(int),
66394 + .mode = 0600,
66395 + .proc_handler = &proc_dointvec,
66396 + },
66397 + {
66398 + .procname = "symlinkown_gid",
66399 + .data = &grsec_symlinkown_gid,
66400 + .maxlen = sizeof(int),
66401 + .mode = 0600,
66402 + .proc_handler = &proc_dointvec,
66403 + },
66404 +#endif
66405 +#ifdef CONFIG_GRKERNSEC_BRUTE
66406 + {
66407 + .procname = "deter_bruteforce",
66408 + .data = &grsec_enable_brute,
66409 + .maxlen = sizeof(int),
66410 + .mode = 0600,
66411 + .proc_handler = &proc_dointvec,
66412 + },
66413 +#endif
66414 +#ifdef CONFIG_GRKERNSEC_FIFO
66415 + {
66416 + .procname = "fifo_restrictions",
66417 + .data = &grsec_enable_fifo,
66418 + .maxlen = sizeof(int),
66419 + .mode = 0600,
66420 + .proc_handler = &proc_dointvec,
66421 + },
66422 +#endif
66423 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66424 + {
66425 + .procname = "ptrace_readexec",
66426 + .data = &grsec_enable_ptrace_readexec,
66427 + .maxlen = sizeof(int),
66428 + .mode = 0600,
66429 + .proc_handler = &proc_dointvec,
66430 + },
66431 +#endif
66432 +#ifdef CONFIG_GRKERNSEC_SETXID
66433 + {
66434 + .procname = "consistent_setxid",
66435 + .data = &grsec_enable_setxid,
66436 + .maxlen = sizeof(int),
66437 + .mode = 0600,
66438 + .proc_handler = &proc_dointvec,
66439 + },
66440 +#endif
66441 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66442 + {
66443 + .procname = "ip_blackhole",
66444 + .data = &grsec_enable_blackhole,
66445 + .maxlen = sizeof(int),
66446 + .mode = 0600,
66447 + .proc_handler = &proc_dointvec,
66448 + },
66449 + {
66450 + .procname = "lastack_retries",
66451 + .data = &grsec_lastack_retries,
66452 + .maxlen = sizeof(int),
66453 + .mode = 0600,
66454 + .proc_handler = &proc_dointvec,
66455 + },
66456 +#endif
66457 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66458 + {
66459 + .procname = "exec_logging",
66460 + .data = &grsec_enable_execlog,
66461 + .maxlen = sizeof(int),
66462 + .mode = 0600,
66463 + .proc_handler = &proc_dointvec,
66464 + },
66465 +#endif
66466 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66467 + {
66468 + .procname = "rwxmap_logging",
66469 + .data = &grsec_enable_log_rwxmaps,
66470 + .maxlen = sizeof(int),
66471 + .mode = 0600,
66472 + .proc_handler = &proc_dointvec,
66473 + },
66474 +#endif
66475 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66476 + {
66477 + .procname = "signal_logging",
66478 + .data = &grsec_enable_signal,
66479 + .maxlen = sizeof(int),
66480 + .mode = 0600,
66481 + .proc_handler = &proc_dointvec,
66482 + },
66483 +#endif
66484 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66485 + {
66486 + .procname = "forkfail_logging",
66487 + .data = &grsec_enable_forkfail,
66488 + .maxlen = sizeof(int),
66489 + .mode = 0600,
66490 + .proc_handler = &proc_dointvec,
66491 + },
66492 +#endif
66493 +#ifdef CONFIG_GRKERNSEC_TIME
66494 + {
66495 + .procname = "timechange_logging",
66496 + .data = &grsec_enable_time,
66497 + .maxlen = sizeof(int),
66498 + .mode = 0600,
66499 + .proc_handler = &proc_dointvec,
66500 + },
66501 +#endif
66502 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66503 + {
66504 + .procname = "chroot_deny_shmat",
66505 + .data = &grsec_enable_chroot_shmat,
66506 + .maxlen = sizeof(int),
66507 + .mode = 0600,
66508 + .proc_handler = &proc_dointvec,
66509 + },
66510 +#endif
66511 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66512 + {
66513 + .procname = "chroot_deny_unix",
66514 + .data = &grsec_enable_chroot_unix,
66515 + .maxlen = sizeof(int),
66516 + .mode = 0600,
66517 + .proc_handler = &proc_dointvec,
66518 + },
66519 +#endif
66520 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66521 + {
66522 + .procname = "chroot_deny_mount",
66523 + .data = &grsec_enable_chroot_mount,
66524 + .maxlen = sizeof(int),
66525 + .mode = 0600,
66526 + .proc_handler = &proc_dointvec,
66527 + },
66528 +#endif
66529 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66530 + {
66531 + .procname = "chroot_deny_fchdir",
66532 + .data = &grsec_enable_chroot_fchdir,
66533 + .maxlen = sizeof(int),
66534 + .mode = 0600,
66535 + .proc_handler = &proc_dointvec,
66536 + },
66537 +#endif
66538 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66539 + {
66540 + .procname = "chroot_deny_chroot",
66541 + .data = &grsec_enable_chroot_double,
66542 + .maxlen = sizeof(int),
66543 + .mode = 0600,
66544 + .proc_handler = &proc_dointvec,
66545 + },
66546 +#endif
66547 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66548 + {
66549 + .procname = "chroot_deny_pivot",
66550 + .data = &grsec_enable_chroot_pivot,
66551 + .maxlen = sizeof(int),
66552 + .mode = 0600,
66553 + .proc_handler = &proc_dointvec,
66554 + },
66555 +#endif
66556 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66557 + {
66558 + .procname = "chroot_enforce_chdir",
66559 + .data = &grsec_enable_chroot_chdir,
66560 + .maxlen = sizeof(int),
66561 + .mode = 0600,
66562 + .proc_handler = &proc_dointvec,
66563 + },
66564 +#endif
66565 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66566 + {
66567 + .procname = "chroot_deny_chmod",
66568 + .data = &grsec_enable_chroot_chmod,
66569 + .maxlen = sizeof(int),
66570 + .mode = 0600,
66571 + .proc_handler = &proc_dointvec,
66572 + },
66573 +#endif
66574 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66575 + {
66576 + .procname = "chroot_deny_mknod",
66577 + .data = &grsec_enable_chroot_mknod,
66578 + .maxlen = sizeof(int),
66579 + .mode = 0600,
66580 + .proc_handler = &proc_dointvec,
66581 + },
66582 +#endif
66583 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66584 + {
66585 + .procname = "chroot_restrict_nice",
66586 + .data = &grsec_enable_chroot_nice,
66587 + .maxlen = sizeof(int),
66588 + .mode = 0600,
66589 + .proc_handler = &proc_dointvec,
66590 + },
66591 +#endif
66592 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66593 + {
66594 + .procname = "chroot_execlog",
66595 + .data = &grsec_enable_chroot_execlog,
66596 + .maxlen = sizeof(int),
66597 + .mode = 0600,
66598 + .proc_handler = &proc_dointvec,
66599 + },
66600 +#endif
66601 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66602 + {
66603 + .procname = "chroot_caps",
66604 + .data = &grsec_enable_chroot_caps,
66605 + .maxlen = sizeof(int),
66606 + .mode = 0600,
66607 + .proc_handler = &proc_dointvec,
66608 + },
66609 +#endif
66610 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66611 + {
66612 + .procname = "chroot_deny_sysctl",
66613 + .data = &grsec_enable_chroot_sysctl,
66614 + .maxlen = sizeof(int),
66615 + .mode = 0600,
66616 + .proc_handler = &proc_dointvec,
66617 + },
66618 +#endif
66619 +#ifdef CONFIG_GRKERNSEC_TPE
66620 + {
66621 + .procname = "tpe",
66622 + .data = &grsec_enable_tpe,
66623 + .maxlen = sizeof(int),
66624 + .mode = 0600,
66625 + .proc_handler = &proc_dointvec,
66626 + },
66627 + {
66628 + .procname = "tpe_gid",
66629 + .data = &grsec_tpe_gid,
66630 + .maxlen = sizeof(int),
66631 + .mode = 0600,
66632 + .proc_handler = &proc_dointvec,
66633 + },
66634 +#endif
66635 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66636 + {
66637 + .procname = "tpe_invert",
66638 + .data = &grsec_enable_tpe_invert,
66639 + .maxlen = sizeof(int),
66640 + .mode = 0600,
66641 + .proc_handler = &proc_dointvec,
66642 + },
66643 +#endif
66644 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66645 + {
66646 + .procname = "tpe_restrict_all",
66647 + .data = &grsec_enable_tpe_all,
66648 + .maxlen = sizeof(int),
66649 + .mode = 0600,
66650 + .proc_handler = &proc_dointvec,
66651 + },
66652 +#endif
66653 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66654 + {
66655 + .procname = "socket_all",
66656 + .data = &grsec_enable_socket_all,
66657 + .maxlen = sizeof(int),
66658 + .mode = 0600,
66659 + .proc_handler = &proc_dointvec,
66660 + },
66661 + {
66662 + .procname = "socket_all_gid",
66663 + .data = &grsec_socket_all_gid,
66664 + .maxlen = sizeof(int),
66665 + .mode = 0600,
66666 + .proc_handler = &proc_dointvec,
66667 + },
66668 +#endif
66669 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66670 + {
66671 + .procname = "socket_client",
66672 + .data = &grsec_enable_socket_client,
66673 + .maxlen = sizeof(int),
66674 + .mode = 0600,
66675 + .proc_handler = &proc_dointvec,
66676 + },
66677 + {
66678 + .procname = "socket_client_gid",
66679 + .data = &grsec_socket_client_gid,
66680 + .maxlen = sizeof(int),
66681 + .mode = 0600,
66682 + .proc_handler = &proc_dointvec,
66683 + },
66684 +#endif
66685 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66686 + {
66687 + .procname = "socket_server",
66688 + .data = &grsec_enable_socket_server,
66689 + .maxlen = sizeof(int),
66690 + .mode = 0600,
66691 + .proc_handler = &proc_dointvec,
66692 + },
66693 + {
66694 + .procname = "socket_server_gid",
66695 + .data = &grsec_socket_server_gid,
66696 + .maxlen = sizeof(int),
66697 + .mode = 0600,
66698 + .proc_handler = &proc_dointvec,
66699 + },
66700 +#endif
66701 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66702 + {
66703 + .procname = "audit_group",
66704 + .data = &grsec_enable_group,
66705 + .maxlen = sizeof(int),
66706 + .mode = 0600,
66707 + .proc_handler = &proc_dointvec,
66708 + },
66709 + {
66710 + .procname = "audit_gid",
66711 + .data = &grsec_audit_gid,
66712 + .maxlen = sizeof(int),
66713 + .mode = 0600,
66714 + .proc_handler = &proc_dointvec,
66715 + },
66716 +#endif
66717 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66718 + {
66719 + .procname = "audit_chdir",
66720 + .data = &grsec_enable_chdir,
66721 + .maxlen = sizeof(int),
66722 + .mode = 0600,
66723 + .proc_handler = &proc_dointvec,
66724 + },
66725 +#endif
66726 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66727 + {
66728 + .procname = "audit_mount",
66729 + .data = &grsec_enable_mount,
66730 + .maxlen = sizeof(int),
66731 + .mode = 0600,
66732 + .proc_handler = &proc_dointvec,
66733 + },
66734 +#endif
66735 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66736 + {
66737 + .procname = "audit_textrel",
66738 + .data = &grsec_enable_audit_textrel,
66739 + .maxlen = sizeof(int),
66740 + .mode = 0600,
66741 + .proc_handler = &proc_dointvec,
66742 + },
66743 +#endif
66744 +#ifdef CONFIG_GRKERNSEC_DMESG
66745 + {
66746 + .procname = "dmesg",
66747 + .data = &grsec_enable_dmesg,
66748 + .maxlen = sizeof(int),
66749 + .mode = 0600,
66750 + .proc_handler = &proc_dointvec,
66751 + },
66752 +#endif
66753 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66754 + {
66755 + .procname = "chroot_findtask",
66756 + .data = &grsec_enable_chroot_findtask,
66757 + .maxlen = sizeof(int),
66758 + .mode = 0600,
66759 + .proc_handler = &proc_dointvec,
66760 + },
66761 +#endif
66762 +#ifdef CONFIG_GRKERNSEC_RESLOG
66763 + {
66764 + .procname = "resource_logging",
66765 + .data = &grsec_resource_logging,
66766 + .maxlen = sizeof(int),
66767 + .mode = 0600,
66768 + .proc_handler = &proc_dointvec,
66769 + },
66770 +#endif
66771 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66772 + {
66773 + .procname = "audit_ptrace",
66774 + .data = &grsec_enable_audit_ptrace,
66775 + .maxlen = sizeof(int),
66776 + .mode = 0600,
66777 + .proc_handler = &proc_dointvec,
66778 + },
66779 +#endif
66780 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66781 + {
66782 + .procname = "harden_ptrace",
66783 + .data = &grsec_enable_harden_ptrace,
66784 + .maxlen = sizeof(int),
66785 + .mode = 0600,
66786 + .proc_handler = &proc_dointvec,
66787 + },
66788 +#endif
66789 + {
66790 + .procname = "grsec_lock",
66791 + .data = &grsec_lock,
66792 + .maxlen = sizeof(int),
66793 + .mode = 0600,
66794 + .proc_handler = &proc_dointvec,
66795 + },
66796 +#endif
66797 +#ifdef CONFIG_GRKERNSEC_ROFS
66798 + {
66799 + .procname = "romount_protect",
66800 + .data = &grsec_enable_rofs,
66801 + .maxlen = sizeof(int),
66802 + .mode = 0600,
66803 + .proc_handler = &proc_dointvec_minmax,
66804 + .extra1 = &one,
66805 + .extra2 = &one,
66806 + },
66807 +#endif
66808 + { }
66809 +};
66810 +#endif
66811 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66812 new file mode 100644
66813 index 0000000..0dc13c3
66814 --- /dev/null
66815 +++ b/grsecurity/grsec_time.c
66816 @@ -0,0 +1,16 @@
66817 +#include <linux/kernel.h>
66818 +#include <linux/sched.h>
66819 +#include <linux/grinternal.h>
66820 +#include <linux/module.h>
66821 +
66822 +void
66823 +gr_log_timechange(void)
66824 +{
66825 +#ifdef CONFIG_GRKERNSEC_TIME
66826 + if (grsec_enable_time)
66827 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66828 +#endif
66829 + return;
66830 +}
66831 +
66832 +EXPORT_SYMBOL(gr_log_timechange);
66833 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66834 new file mode 100644
66835 index 0000000..ee57dcf
66836 --- /dev/null
66837 +++ b/grsecurity/grsec_tpe.c
66838 @@ -0,0 +1,73 @@
66839 +#include <linux/kernel.h>
66840 +#include <linux/sched.h>
66841 +#include <linux/file.h>
66842 +#include <linux/fs.h>
66843 +#include <linux/grinternal.h>
66844 +
66845 +extern int gr_acl_tpe_check(void);
66846 +
66847 +int
66848 +gr_tpe_allow(const struct file *file)
66849 +{
66850 +#ifdef CONFIG_GRKERNSEC
66851 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66852 + const struct cred *cred = current_cred();
66853 + char *msg = NULL;
66854 + char *msg2 = NULL;
66855 +
66856 + // never restrict root
66857 + if (gr_is_global_root(cred->uid))
66858 + return 1;
66859 +
66860 + if (grsec_enable_tpe) {
66861 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66862 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66863 + msg = "not being in trusted group";
66864 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66865 + msg = "being in untrusted group";
66866 +#else
66867 + if (in_group_p(grsec_tpe_gid))
66868 + msg = "being in untrusted group";
66869 +#endif
66870 + }
66871 + if (!msg && gr_acl_tpe_check())
66872 + msg = "being in untrusted role";
66873 +
66874 + // not in any affected group/role
66875 + if (!msg)
66876 + goto next_check;
66877 +
66878 + if (gr_is_global_nonroot(inode->i_uid))
66879 + msg2 = "file in non-root-owned directory";
66880 + else if (inode->i_mode & S_IWOTH)
66881 + msg2 = "file in world-writable directory";
66882 + else if (inode->i_mode & S_IWGRP)
66883 + msg2 = "file in group-writable directory";
66884 +
66885 + if (msg && msg2) {
66886 + char fullmsg[70] = {0};
66887 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66888 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66889 + return 0;
66890 + }
66891 + msg = NULL;
66892 +next_check:
66893 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66894 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66895 + return 1;
66896 +
66897 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66898 + msg = "directory not owned by user";
66899 + else if (inode->i_mode & S_IWOTH)
66900 + msg = "file in world-writable directory";
66901 + else if (inode->i_mode & S_IWGRP)
66902 + msg = "file in group-writable directory";
66903 +
66904 + if (msg) {
66905 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66906 + return 0;
66907 + }
66908 +#endif
66909 +#endif
66910 + return 1;
66911 +}
66912 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66913 new file mode 100644
66914 index 0000000..9f7b1ac
66915 --- /dev/null
66916 +++ b/grsecurity/grsum.c
66917 @@ -0,0 +1,61 @@
66918 +#include <linux/err.h>
66919 +#include <linux/kernel.h>
66920 +#include <linux/sched.h>
66921 +#include <linux/mm.h>
66922 +#include <linux/scatterlist.h>
66923 +#include <linux/crypto.h>
66924 +#include <linux/gracl.h>
66925 +
66926 +
66927 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66928 +#error "crypto and sha256 must be built into the kernel"
66929 +#endif
66930 +
66931 +int
66932 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66933 +{
66934 + char *p;
66935 + struct crypto_hash *tfm;
66936 + struct hash_desc desc;
66937 + struct scatterlist sg;
66938 + unsigned char temp_sum[GR_SHA_LEN];
66939 + volatile int retval = 0;
66940 + volatile int dummy = 0;
66941 + unsigned int i;
66942 +
66943 + sg_init_table(&sg, 1);
66944 +
66945 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66946 + if (IS_ERR(tfm)) {
66947 + /* should never happen, since sha256 should be built in */
66948 + return 1;
66949 + }
66950 +
66951 + desc.tfm = tfm;
66952 + desc.flags = 0;
66953 +
66954 + crypto_hash_init(&desc);
66955 +
66956 + p = salt;
66957 + sg_set_buf(&sg, p, GR_SALT_LEN);
66958 + crypto_hash_update(&desc, &sg, sg.length);
66959 +
66960 + p = entry->pw;
66961 + sg_set_buf(&sg, p, strlen(p));
66962 +
66963 + crypto_hash_update(&desc, &sg, sg.length);
66964 +
66965 + crypto_hash_final(&desc, temp_sum);
66966 +
66967 + memset(entry->pw, 0, GR_PW_LEN);
66968 +
66969 + for (i = 0; i < GR_SHA_LEN; i++)
66970 + if (sum[i] != temp_sum[i])
66971 + retval = 1;
66972 + else
66973 + dummy = 1; // waste a cycle
66974 +
66975 + crypto_free_hash(tfm);
66976 +
66977 + return retval;
66978 +}
66979 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66980 index 77ff547..181834f 100644
66981 --- a/include/asm-generic/4level-fixup.h
66982 +++ b/include/asm-generic/4level-fixup.h
66983 @@ -13,8 +13,10 @@
66984 #define pmd_alloc(mm, pud, address) \
66985 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66986 NULL: pmd_offset(pud, address))
66987 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66988
66989 #define pud_alloc(mm, pgd, address) (pgd)
66990 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66991 #define pud_offset(pgd, start) (pgd)
66992 #define pud_none(pud) 0
66993 #define pud_bad(pud) 0
66994 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66995 index b7babf0..04ad282 100644
66996 --- a/include/asm-generic/atomic-long.h
66997 +++ b/include/asm-generic/atomic-long.h
66998 @@ -22,6 +22,12 @@
66999
67000 typedef atomic64_t atomic_long_t;
67001
67002 +#ifdef CONFIG_PAX_REFCOUNT
67003 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67004 +#else
67005 +typedef atomic64_t atomic_long_unchecked_t;
67006 +#endif
67007 +
67008 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67009
67010 static inline long atomic_long_read(atomic_long_t *l)
67011 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67012 return (long)atomic64_read(v);
67013 }
67014
67015 +#ifdef CONFIG_PAX_REFCOUNT
67016 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67017 +{
67018 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67019 +
67020 + return (long)atomic64_read_unchecked(v);
67021 +}
67022 +#endif
67023 +
67024 static inline void atomic_long_set(atomic_long_t *l, long i)
67025 {
67026 atomic64_t *v = (atomic64_t *)l;
67027 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67028 atomic64_set(v, i);
67029 }
67030
67031 +#ifdef CONFIG_PAX_REFCOUNT
67032 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67033 +{
67034 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67035 +
67036 + atomic64_set_unchecked(v, i);
67037 +}
67038 +#endif
67039 +
67040 static inline void atomic_long_inc(atomic_long_t *l)
67041 {
67042 atomic64_t *v = (atomic64_t *)l;
67043 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67044 atomic64_inc(v);
67045 }
67046
67047 +#ifdef CONFIG_PAX_REFCOUNT
67048 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67049 +{
67050 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67051 +
67052 + atomic64_inc_unchecked(v);
67053 +}
67054 +#endif
67055 +
67056 static inline void atomic_long_dec(atomic_long_t *l)
67057 {
67058 atomic64_t *v = (atomic64_t *)l;
67059 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67060 atomic64_dec(v);
67061 }
67062
67063 +#ifdef CONFIG_PAX_REFCOUNT
67064 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67065 +{
67066 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67067 +
67068 + atomic64_dec_unchecked(v);
67069 +}
67070 +#endif
67071 +
67072 static inline void atomic_long_add(long i, atomic_long_t *l)
67073 {
67074 atomic64_t *v = (atomic64_t *)l;
67075 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67076 atomic64_add(i, v);
67077 }
67078
67079 +#ifdef CONFIG_PAX_REFCOUNT
67080 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67081 +{
67082 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67083 +
67084 + atomic64_add_unchecked(i, v);
67085 +}
67086 +#endif
67087 +
67088 static inline void atomic_long_sub(long i, atomic_long_t *l)
67089 {
67090 atomic64_t *v = (atomic64_t *)l;
67091 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67092 atomic64_sub(i, v);
67093 }
67094
67095 +#ifdef CONFIG_PAX_REFCOUNT
67096 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67097 +{
67098 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67099 +
67100 + atomic64_sub_unchecked(i, v);
67101 +}
67102 +#endif
67103 +
67104 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67105 {
67106 atomic64_t *v = (atomic64_t *)l;
67107 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67108 return (long)atomic64_add_return(i, v);
67109 }
67110
67111 +#ifdef CONFIG_PAX_REFCOUNT
67112 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67113 +{
67114 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67115 +
67116 + return (long)atomic64_add_return_unchecked(i, v);
67117 +}
67118 +#endif
67119 +
67120 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67121 {
67122 atomic64_t *v = (atomic64_t *)l;
67123 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67124 return (long)atomic64_inc_return(v);
67125 }
67126
67127 +#ifdef CONFIG_PAX_REFCOUNT
67128 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67129 +{
67130 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67131 +
67132 + return (long)atomic64_inc_return_unchecked(v);
67133 +}
67134 +#endif
67135 +
67136 static inline long atomic_long_dec_return(atomic_long_t *l)
67137 {
67138 atomic64_t *v = (atomic64_t *)l;
67139 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67140
67141 typedef atomic_t atomic_long_t;
67142
67143 +#ifdef CONFIG_PAX_REFCOUNT
67144 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67145 +#else
67146 +typedef atomic_t atomic_long_unchecked_t;
67147 +#endif
67148 +
67149 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67150 static inline long atomic_long_read(atomic_long_t *l)
67151 {
67152 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67153 return (long)atomic_read(v);
67154 }
67155
67156 +#ifdef CONFIG_PAX_REFCOUNT
67157 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67158 +{
67159 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67160 +
67161 + return (long)atomic_read_unchecked(v);
67162 +}
67163 +#endif
67164 +
67165 static inline void atomic_long_set(atomic_long_t *l, long i)
67166 {
67167 atomic_t *v = (atomic_t *)l;
67168 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67169 atomic_set(v, i);
67170 }
67171
67172 +#ifdef CONFIG_PAX_REFCOUNT
67173 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67174 +{
67175 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67176 +
67177 + atomic_set_unchecked(v, i);
67178 +}
67179 +#endif
67180 +
67181 static inline void atomic_long_inc(atomic_long_t *l)
67182 {
67183 atomic_t *v = (atomic_t *)l;
67184 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67185 atomic_inc(v);
67186 }
67187
67188 +#ifdef CONFIG_PAX_REFCOUNT
67189 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67190 +{
67191 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67192 +
67193 + atomic_inc_unchecked(v);
67194 +}
67195 +#endif
67196 +
67197 static inline void atomic_long_dec(atomic_long_t *l)
67198 {
67199 atomic_t *v = (atomic_t *)l;
67200 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67201 atomic_dec(v);
67202 }
67203
67204 +#ifdef CONFIG_PAX_REFCOUNT
67205 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67206 +{
67207 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67208 +
67209 + atomic_dec_unchecked(v);
67210 +}
67211 +#endif
67212 +
67213 static inline void atomic_long_add(long i, atomic_long_t *l)
67214 {
67215 atomic_t *v = (atomic_t *)l;
67216 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67217 atomic_add(i, v);
67218 }
67219
67220 +#ifdef CONFIG_PAX_REFCOUNT
67221 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67222 +{
67223 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67224 +
67225 + atomic_add_unchecked(i, v);
67226 +}
67227 +#endif
67228 +
67229 static inline void atomic_long_sub(long i, atomic_long_t *l)
67230 {
67231 atomic_t *v = (atomic_t *)l;
67232 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67233 atomic_sub(i, v);
67234 }
67235
67236 +#ifdef CONFIG_PAX_REFCOUNT
67237 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67238 +{
67239 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67240 +
67241 + atomic_sub_unchecked(i, v);
67242 +}
67243 +#endif
67244 +
67245 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67246 {
67247 atomic_t *v = (atomic_t *)l;
67248 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67249 return (long)atomic_add_return(i, v);
67250 }
67251
67252 +#ifdef CONFIG_PAX_REFCOUNT
67253 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67254 +{
67255 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67256 +
67257 + return (long)atomic_add_return_unchecked(i, v);
67258 +}
67259 +
67260 +#endif
67261 +
67262 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67263 {
67264 atomic_t *v = (atomic_t *)l;
67265 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67266 return (long)atomic_inc_return(v);
67267 }
67268
67269 +#ifdef CONFIG_PAX_REFCOUNT
67270 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67271 +{
67272 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67273 +
67274 + return (long)atomic_inc_return_unchecked(v);
67275 +}
67276 +#endif
67277 +
67278 static inline long atomic_long_dec_return(atomic_long_t *l)
67279 {
67280 atomic_t *v = (atomic_t *)l;
67281 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67282
67283 #endif /* BITS_PER_LONG == 64 */
67284
67285 +#ifdef CONFIG_PAX_REFCOUNT
67286 +static inline void pax_refcount_needs_these_functions(void)
67287 +{
67288 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67289 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67290 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67291 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67292 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67293 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67294 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67295 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67296 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67297 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67298 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67299 +#ifdef CONFIG_X86
67300 + atomic_clear_mask_unchecked(0, NULL);
67301 + atomic_set_mask_unchecked(0, NULL);
67302 +#endif
67303 +
67304 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67305 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67306 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67307 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67308 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67309 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67310 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67311 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67312 +}
67313 +#else
67314 +#define atomic_read_unchecked(v) atomic_read(v)
67315 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67316 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67317 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67318 +#define atomic_inc_unchecked(v) atomic_inc(v)
67319 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67320 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67321 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67322 +#define atomic_dec_unchecked(v) atomic_dec(v)
67323 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67324 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67325 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67326 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67327 +
67328 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67329 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67330 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67331 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67332 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67333 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67334 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67335 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67336 +#endif
67337 +
67338 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67339 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67340 index 1ced641..c896ee8 100644
67341 --- a/include/asm-generic/atomic.h
67342 +++ b/include/asm-generic/atomic.h
67343 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67344 * Atomically clears the bits set in @mask from @v
67345 */
67346 #ifndef atomic_clear_mask
67347 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67348 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67349 {
67350 unsigned long flags;
67351
67352 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67353 index b18ce4f..2ee2843 100644
67354 --- a/include/asm-generic/atomic64.h
67355 +++ b/include/asm-generic/atomic64.h
67356 @@ -16,6 +16,8 @@ typedef struct {
67357 long long counter;
67358 } atomic64_t;
67359
67360 +typedef atomic64_t atomic64_unchecked_t;
67361 +
67362 #define ATOMIC64_INIT(i) { (i) }
67363
67364 extern long long atomic64_read(const atomic64_t *v);
67365 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67366 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67367 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67368
67369 +#define atomic64_read_unchecked(v) atomic64_read(v)
67370 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67371 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67372 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67373 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67374 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67375 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67376 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67377 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67378 +
67379 #endif /* _ASM_GENERIC_ATOMIC64_H */
67380 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67381 index 1bfcfe5..e04c5c9 100644
67382 --- a/include/asm-generic/cache.h
67383 +++ b/include/asm-generic/cache.h
67384 @@ -6,7 +6,7 @@
67385 * cache lines need to provide their own cache.h.
67386 */
67387
67388 -#define L1_CACHE_SHIFT 5
67389 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67390 +#define L1_CACHE_SHIFT 5UL
67391 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67392
67393 #endif /* __ASM_GENERIC_CACHE_H */
67394 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67395 index 0d68a1e..b74a761 100644
67396 --- a/include/asm-generic/emergency-restart.h
67397 +++ b/include/asm-generic/emergency-restart.h
67398 @@ -1,7 +1,7 @@
67399 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67400 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67401
67402 -static inline void machine_emergency_restart(void)
67403 +static inline __noreturn void machine_emergency_restart(void)
67404 {
67405 machine_restart(NULL);
67406 }
67407 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67408 index 90f99c7..00ce236 100644
67409 --- a/include/asm-generic/kmap_types.h
67410 +++ b/include/asm-generic/kmap_types.h
67411 @@ -2,9 +2,9 @@
67412 #define _ASM_GENERIC_KMAP_TYPES_H
67413
67414 #ifdef __WITH_KM_FENCE
67415 -# define KM_TYPE_NR 41
67416 +# define KM_TYPE_NR 42
67417 #else
67418 -# define KM_TYPE_NR 20
67419 +# define KM_TYPE_NR 21
67420 #endif
67421
67422 #endif
67423 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67424 index 9ceb03b..62b0b8f 100644
67425 --- a/include/asm-generic/local.h
67426 +++ b/include/asm-generic/local.h
67427 @@ -23,24 +23,37 @@ typedef struct
67428 atomic_long_t a;
67429 } local_t;
67430
67431 +typedef struct {
67432 + atomic_long_unchecked_t a;
67433 +} local_unchecked_t;
67434 +
67435 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67436
67437 #define local_read(l) atomic_long_read(&(l)->a)
67438 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67439 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67440 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67441 #define local_inc(l) atomic_long_inc(&(l)->a)
67442 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67443 #define local_dec(l) atomic_long_dec(&(l)->a)
67444 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67445 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67446 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67447 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67448 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67449
67450 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67451 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67452 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67453 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67454 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67455 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67456 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67457 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67458 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67459
67460 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67461 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67462 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67463 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67464 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67465 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67466 index 725612b..9cc513a 100644
67467 --- a/include/asm-generic/pgtable-nopmd.h
67468 +++ b/include/asm-generic/pgtable-nopmd.h
67469 @@ -1,14 +1,19 @@
67470 #ifndef _PGTABLE_NOPMD_H
67471 #define _PGTABLE_NOPMD_H
67472
67473 -#ifndef __ASSEMBLY__
67474 -
67475 #include <asm-generic/pgtable-nopud.h>
67476
67477 -struct mm_struct;
67478 -
67479 #define __PAGETABLE_PMD_FOLDED
67480
67481 +#define PMD_SHIFT PUD_SHIFT
67482 +#define PTRS_PER_PMD 1
67483 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67484 +#define PMD_MASK (~(PMD_SIZE-1))
67485 +
67486 +#ifndef __ASSEMBLY__
67487 +
67488 +struct mm_struct;
67489 +
67490 /*
67491 * Having the pmd type consist of a pud gets the size right, and allows
67492 * us to conceptually access the pud entry that this pmd is folded into
67493 @@ -16,11 +21,6 @@ struct mm_struct;
67494 */
67495 typedef struct { pud_t pud; } pmd_t;
67496
67497 -#define PMD_SHIFT PUD_SHIFT
67498 -#define PTRS_PER_PMD 1
67499 -#define PMD_SIZE (1UL << PMD_SHIFT)
67500 -#define PMD_MASK (~(PMD_SIZE-1))
67501 -
67502 /*
67503 * The "pud_xxx()" functions here are trivial for a folded two-level
67504 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67505 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67506 index 810431d..0ec4804f 100644
67507 --- a/include/asm-generic/pgtable-nopud.h
67508 +++ b/include/asm-generic/pgtable-nopud.h
67509 @@ -1,10 +1,15 @@
67510 #ifndef _PGTABLE_NOPUD_H
67511 #define _PGTABLE_NOPUD_H
67512
67513 -#ifndef __ASSEMBLY__
67514 -
67515 #define __PAGETABLE_PUD_FOLDED
67516
67517 +#define PUD_SHIFT PGDIR_SHIFT
67518 +#define PTRS_PER_PUD 1
67519 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67520 +#define PUD_MASK (~(PUD_SIZE-1))
67521 +
67522 +#ifndef __ASSEMBLY__
67523 +
67524 /*
67525 * Having the pud type consist of a pgd gets the size right, and allows
67526 * us to conceptually access the pgd entry that this pud is folded into
67527 @@ -12,11 +17,6 @@
67528 */
67529 typedef struct { pgd_t pgd; } pud_t;
67530
67531 -#define PUD_SHIFT PGDIR_SHIFT
67532 -#define PTRS_PER_PUD 1
67533 -#define PUD_SIZE (1UL << PUD_SHIFT)
67534 -#define PUD_MASK (~(PUD_SIZE-1))
67535 -
67536 /*
67537 * The "pgd_xxx()" functions here are trivial for a folded two-level
67538 * setup: the pud is never bad, and a pud always exists (as it's folded
67539 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67540 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67541
67542 #define pgd_populate(mm, pgd, pud) do { } while (0)
67543 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67544 /*
67545 * (puds are folded into pgds so this doesn't get actually called,
67546 * but the define is needed for a generic inline function.)
67547 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67548 index 5cf680a..4b74d62 100644
67549 --- a/include/asm-generic/pgtable.h
67550 +++ b/include/asm-generic/pgtable.h
67551 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67552 }
67553 #endif /* CONFIG_NUMA_BALANCING */
67554
67555 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67556 +static inline unsigned long pax_open_kernel(void) { return 0; }
67557 +#endif
67558 +
67559 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67560 +static inline unsigned long pax_close_kernel(void) { return 0; }
67561 +#endif
67562 +
67563 #endif /* CONFIG_MMU */
67564
67565 #endif /* !__ASSEMBLY__ */
67566 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67567 index d1ea7ce..b1ebf2a 100644
67568 --- a/include/asm-generic/vmlinux.lds.h
67569 +++ b/include/asm-generic/vmlinux.lds.h
67570 @@ -218,6 +218,7 @@
67571 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67572 VMLINUX_SYMBOL(__start_rodata) = .; \
67573 *(.rodata) *(.rodata.*) \
67574 + *(.data..read_only) \
67575 *(__vermagic) /* Kernel version magic */ \
67576 . = ALIGN(8); \
67577 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67578 @@ -725,17 +726,18 @@
67579 * section in the linker script will go there too. @phdr should have
67580 * a leading colon.
67581 *
67582 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67583 + * Note that this macros defines per_cpu_load as an absolute symbol.
67584 * If there is no need to put the percpu section at a predetermined
67585 * address, use PERCPU_SECTION.
67586 */
67587 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67588 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67589 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67590 + per_cpu_load = .; \
67591 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67592 - LOAD_OFFSET) { \
67593 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67594 PERCPU_INPUT(cacheline) \
67595 } phdr \
67596 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67597 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67598
67599 /**
67600 * PERCPU_SECTION - define output section for percpu area, simple version
67601 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67602 index 418d270..bfd2794 100644
67603 --- a/include/crypto/algapi.h
67604 +++ b/include/crypto/algapi.h
67605 @@ -34,7 +34,7 @@ struct crypto_type {
67606 unsigned int maskclear;
67607 unsigned int maskset;
67608 unsigned int tfmsize;
67609 -};
67610 +} __do_const;
67611
67612 struct crypto_instance {
67613 struct crypto_alg alg;
67614 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67615 index fad21c9..ab858bc 100644
67616 --- a/include/drm/drmP.h
67617 +++ b/include/drm/drmP.h
67618 @@ -72,6 +72,7 @@
67619 #include <linux/workqueue.h>
67620 #include <linux/poll.h>
67621 #include <asm/pgalloc.h>
67622 +#include <asm/local.h>
67623 #include <drm/drm.h>
67624 #include <drm/drm_sarea.h>
67625
67626 @@ -293,10 +294,12 @@ do { \
67627 * \param cmd command.
67628 * \param arg argument.
67629 */
67630 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67631 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67632 + struct drm_file *file_priv);
67633 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67634 struct drm_file *file_priv);
67635
67636 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67637 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67638 unsigned long arg);
67639
67640 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67641 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67642 struct drm_ioctl_desc {
67643 unsigned int cmd;
67644 int flags;
67645 - drm_ioctl_t *func;
67646 + drm_ioctl_t func;
67647 unsigned int cmd_drv;
67648 -};
67649 +} __do_const;
67650
67651 /**
67652 * Creates a driver or general drm_ioctl_desc array entry for the given
67653 @@ -995,7 +998,7 @@ struct drm_info_list {
67654 int (*show)(struct seq_file*, void*); /** show callback */
67655 u32 driver_features; /**< Required driver features for this entry */
67656 void *data;
67657 -};
67658 +} __do_const;
67659
67660 /**
67661 * debugfs node structure. This structure represents a debugfs file.
67662 @@ -1068,7 +1071,7 @@ struct drm_device {
67663
67664 /** \name Usage Counters */
67665 /*@{ */
67666 - int open_count; /**< Outstanding files open */
67667 + local_t open_count; /**< Outstanding files open */
67668 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67669 atomic_t vma_count; /**< Outstanding vma areas open */
67670 int buf_use; /**< Buffers in use -- cannot alloc */
67671 @@ -1079,7 +1082,7 @@ struct drm_device {
67672 /*@{ */
67673 unsigned long counters;
67674 enum drm_stat_type types[15];
67675 - atomic_t counts[15];
67676 + atomic_unchecked_t counts[15];
67677 /*@} */
67678
67679 struct list_head filelist;
67680 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67681 index f43d556..94d9343 100644
67682 --- a/include/drm/drm_crtc_helper.h
67683 +++ b/include/drm/drm_crtc_helper.h
67684 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67685 struct drm_connector *connector);
67686 /* disable encoder when not in use - more explicit than dpms off */
67687 void (*disable)(struct drm_encoder *encoder);
67688 -};
67689 +} __no_const;
67690
67691 /**
67692 * drm_connector_helper_funcs - helper operations for connectors
67693 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67694 index 72dcbe8..8db58d7 100644
67695 --- a/include/drm/ttm/ttm_memory.h
67696 +++ b/include/drm/ttm/ttm_memory.h
67697 @@ -48,7 +48,7 @@
67698
67699 struct ttm_mem_shrink {
67700 int (*do_shrink) (struct ttm_mem_shrink *);
67701 -};
67702 +} __no_const;
67703
67704 /**
67705 * struct ttm_mem_global - Global memory accounting structure.
67706 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67707 index 4b840e8..155d235 100644
67708 --- a/include/keys/asymmetric-subtype.h
67709 +++ b/include/keys/asymmetric-subtype.h
67710 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67711 /* Verify the signature on a key of this subtype (optional) */
67712 int (*verify_signature)(const struct key *key,
67713 const struct public_key_signature *sig);
67714 -};
67715 +} __do_const;
67716
67717 /**
67718 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67719 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67720 index c1da539..1dcec55 100644
67721 --- a/include/linux/atmdev.h
67722 +++ b/include/linux/atmdev.h
67723 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67724 #endif
67725
67726 struct k_atm_aal_stats {
67727 -#define __HANDLE_ITEM(i) atomic_t i
67728 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67729 __AAL_STAT_ITEMS
67730 #undef __HANDLE_ITEM
67731 };
67732 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67733 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67734 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67735 struct module *owner;
67736 -};
67737 +} __do_const ;
67738
67739 struct atmphy_ops {
67740 int (*start)(struct atm_dev *dev);
67741 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67742 index 0530b98..96a8ac0 100644
67743 --- a/include/linux/binfmts.h
67744 +++ b/include/linux/binfmts.h
67745 @@ -73,8 +73,9 @@ struct linux_binfmt {
67746 int (*load_binary)(struct linux_binprm *);
67747 int (*load_shlib)(struct file *);
67748 int (*core_dump)(struct coredump_params *cprm);
67749 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67750 unsigned long min_coredump; /* minimal dump size */
67751 -};
67752 +} __do_const;
67753
67754 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67755
67756 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67757 index f94bc83..62b9cfe 100644
67758 --- a/include/linux/blkdev.h
67759 +++ b/include/linux/blkdev.h
67760 @@ -1498,7 +1498,7 @@ struct block_device_operations {
67761 /* this callback is with swap_lock and sometimes page table lock held */
67762 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67763 struct module *owner;
67764 -};
67765 +} __do_const;
67766
67767 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67768 unsigned long);
67769 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67770 index 7c2e030..b72475d 100644
67771 --- a/include/linux/blktrace_api.h
67772 +++ b/include/linux/blktrace_api.h
67773 @@ -23,7 +23,7 @@ struct blk_trace {
67774 struct dentry *dir;
67775 struct dentry *dropped_file;
67776 struct dentry *msg_file;
67777 - atomic_t dropped;
67778 + atomic_unchecked_t dropped;
67779 };
67780
67781 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67782 diff --git a/include/linux/cache.h b/include/linux/cache.h
67783 index 4c57065..4307975 100644
67784 --- a/include/linux/cache.h
67785 +++ b/include/linux/cache.h
67786 @@ -16,6 +16,10 @@
67787 #define __read_mostly
67788 #endif
67789
67790 +#ifndef __read_only
67791 +#define __read_only __read_mostly
67792 +#endif
67793 +
67794 #ifndef ____cacheline_aligned
67795 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67796 #endif
67797 diff --git a/include/linux/capability.h b/include/linux/capability.h
67798 index d9a4f7f4..19f77d6 100644
67799 --- a/include/linux/capability.h
67800 +++ b/include/linux/capability.h
67801 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
67802 extern bool nsown_capable(int cap);
67803 extern bool inode_capable(const struct inode *inode, int cap);
67804 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
67805 +extern bool capable_nolog(int cap);
67806 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67807 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67808
67809 /* audit system wants to get cap info from files as well */
67810 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67811
67812 +extern int is_privileged_binary(const struct dentry *dentry);
67813 +
67814 #endif /* !_LINUX_CAPABILITY_H */
67815 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67816 index 8609d57..86e4d79 100644
67817 --- a/include/linux/cdrom.h
67818 +++ b/include/linux/cdrom.h
67819 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67820
67821 /* driver specifications */
67822 const int capability; /* capability flags */
67823 - int n_minors; /* number of active minor devices */
67824 /* handle uniform packets for scsi type devices (scsi,atapi) */
67825 int (*generic_packet) (struct cdrom_device_info *,
67826 struct packet_command *);
67827 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67828 index 42e55de..1cd0e66 100644
67829 --- a/include/linux/cleancache.h
67830 +++ b/include/linux/cleancache.h
67831 @@ -31,7 +31,7 @@ struct cleancache_ops {
67832 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67833 void (*invalidate_inode)(int, struct cleancache_filekey);
67834 void (*invalidate_fs)(int);
67835 -};
67836 +} __no_const;
67837
67838 extern struct cleancache_ops
67839 cleancache_register_ops(struct cleancache_ops *ops);
67840 diff --git a/include/linux/compat.h b/include/linux/compat.h
67841 index dec7e2d..45db13f 100644
67842 --- a/include/linux/compat.h
67843 +++ b/include/linux/compat.h
67844 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67845 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67846 int version, void __user *uptr);
67847 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67848 - void __user *uptr);
67849 + void __user *uptr) __intentional_overflow(0);
67850 #else
67851 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67852 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67853 compat_ssize_t msgsz, int msgflg);
67854 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67855 compat_ssize_t msgsz, long msgtyp, int msgflg);
67856 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67857 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67858 #endif
67859 long compat_sys_msgctl(int first, int second, void __user *uptr);
67860 long compat_sys_shmctl(int first, int second, void __user *uptr);
67861 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67862 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67863 compat_ulong_t addr, compat_ulong_t data);
67864 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67865 - compat_long_t addr, compat_long_t data);
67866 + compat_ulong_t addr, compat_ulong_t data);
67867
67868 /*
67869 * epoll (fs/eventpoll.c) compat bits follow ...
67870 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67871 index 662fd1b..e801992 100644
67872 --- a/include/linux/compiler-gcc4.h
67873 +++ b/include/linux/compiler-gcc4.h
67874 @@ -34,6 +34,21 @@
67875 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
67876
67877 #if __GNUC_MINOR__ >= 5
67878 +
67879 +#ifdef CONSTIFY_PLUGIN
67880 +#define __no_const __attribute__((no_const))
67881 +#define __do_const __attribute__((do_const))
67882 +#endif
67883 +
67884 +#ifdef SIZE_OVERFLOW_PLUGIN
67885 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67886 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67887 +#endif
67888 +
67889 +#ifdef LATENT_ENTROPY_PLUGIN
67890 +#define __latent_entropy __attribute__((latent_entropy))
67891 +#endif
67892 +
67893 /*
67894 * Mark a position in code as unreachable. This can be used to
67895 * suppress control flow warnings after asm blocks that transfer
67896 @@ -49,6 +64,11 @@
67897 #define __noclone __attribute__((__noclone__))
67898
67899 #endif
67900 +
67901 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67902 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67903 +#define __bos0(ptr) __bos((ptr), 0)
67904 +#define __bos1(ptr) __bos((ptr), 1)
67905 #endif
67906
67907 #if __GNUC_MINOR__ >= 6
67908 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67909 index dd852b7..1ad5fba 100644
67910 --- a/include/linux/compiler.h
67911 +++ b/include/linux/compiler.h
67912 @@ -5,11 +5,14 @@
67913
67914 #ifdef __CHECKER__
67915 # define __user __attribute__((noderef, address_space(1)))
67916 +# define __force_user __force __user
67917 # define __kernel __attribute__((address_space(0)))
67918 +# define __force_kernel __force __kernel
67919 # define __safe __attribute__((safe))
67920 # define __force __attribute__((force))
67921 # define __nocast __attribute__((nocast))
67922 # define __iomem __attribute__((noderef, address_space(2)))
67923 +# define __force_iomem __force __iomem
67924 # define __must_hold(x) __attribute__((context(x,1,1)))
67925 # define __acquires(x) __attribute__((context(x,0,1)))
67926 # define __releases(x) __attribute__((context(x,1,0)))
67927 @@ -17,20 +20,37 @@
67928 # define __release(x) __context__(x,-1)
67929 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67930 # define __percpu __attribute__((noderef, address_space(3)))
67931 +# define __force_percpu __force __percpu
67932 #ifdef CONFIG_SPARSE_RCU_POINTER
67933 # define __rcu __attribute__((noderef, address_space(4)))
67934 +# define __force_rcu __force __rcu
67935 #else
67936 # define __rcu
67937 +# define __force_rcu
67938 #endif
67939 extern void __chk_user_ptr(const volatile void __user *);
67940 extern void __chk_io_ptr(const volatile void __iomem *);
67941 #else
67942 -# define __user
67943 -# define __kernel
67944 +# ifdef CHECKER_PLUGIN
67945 +//# define __user
67946 +//# define __force_user
67947 +//# define __kernel
67948 +//# define __force_kernel
67949 +# else
67950 +# ifdef STRUCTLEAK_PLUGIN
67951 +# define __user __attribute__((user))
67952 +# else
67953 +# define __user
67954 +# endif
67955 +# define __force_user
67956 +# define __kernel
67957 +# define __force_kernel
67958 +# endif
67959 # define __safe
67960 # define __force
67961 # define __nocast
67962 # define __iomem
67963 +# define __force_iomem
67964 # define __chk_user_ptr(x) (void)0
67965 # define __chk_io_ptr(x) (void)0
67966 # define __builtin_warning(x, y...) (1)
67967 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67968 # define __release(x) (void)0
67969 # define __cond_lock(x,c) (c)
67970 # define __percpu
67971 +# define __force_percpu
67972 # define __rcu
67973 +# define __force_rcu
67974 #endif
67975
67976 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67977 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67978 # define __attribute_const__ /* unimplemented */
67979 #endif
67980
67981 +#ifndef __no_const
67982 +# define __no_const
67983 +#endif
67984 +
67985 +#ifndef __do_const
67986 +# define __do_const
67987 +#endif
67988 +
67989 +#ifndef __size_overflow
67990 +# define __size_overflow(...)
67991 +#endif
67992 +
67993 +#ifndef __intentional_overflow
67994 +# define __intentional_overflow(...)
67995 +#endif
67996 +
67997 +#ifndef __latent_entropy
67998 +# define __latent_entropy
67999 +#endif
68000 +
68001 /*
68002 * Tell gcc if a function is cold. The compiler will assume any path
68003 * directly leading to the call is unlikely.
68004 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68005 #define __cold
68006 #endif
68007
68008 +#ifndef __alloc_size
68009 +#define __alloc_size(...)
68010 +#endif
68011 +
68012 +#ifndef __bos
68013 +#define __bos(ptr, arg)
68014 +#endif
68015 +
68016 +#ifndef __bos0
68017 +#define __bos0(ptr)
68018 +#endif
68019 +
68020 +#ifndef __bos1
68021 +#define __bos1(ptr)
68022 +#endif
68023 +
68024 /* Simple shorthand for a section definition */
68025 #ifndef __section
68026 # define __section(S) __attribute__ ((__section__(#S)))
68027 @@ -323,6 +381,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68028 * use is to mediate communication between process-level code and irq/NMI
68029 * handlers, all running on the same CPU.
68030 */
68031 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68032 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68033 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68034
68035 #endif /* __LINUX_COMPILER_H */
68036 diff --git a/include/linux/completion.h b/include/linux/completion.h
68037 index 51494e6..0fd1b61 100644
68038 --- a/include/linux/completion.h
68039 +++ b/include/linux/completion.h
68040 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
68041
68042 extern void wait_for_completion(struct completion *);
68043 extern int wait_for_completion_interruptible(struct completion *x);
68044 -extern int wait_for_completion_killable(struct completion *x);
68045 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68046 extern unsigned long wait_for_completion_timeout(struct completion *x,
68047 unsigned long timeout);
68048 extern long wait_for_completion_interruptible_timeout(
68049 - struct completion *x, unsigned long timeout);
68050 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68051 extern long wait_for_completion_killable_timeout(
68052 - struct completion *x, unsigned long timeout);
68053 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68054 extern bool try_wait_for_completion(struct completion *x);
68055 extern bool completion_done(struct completion *x);
68056
68057 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68058 index 34025df..d94bbbc 100644
68059 --- a/include/linux/configfs.h
68060 +++ b/include/linux/configfs.h
68061 @@ -125,7 +125,7 @@ struct configfs_attribute {
68062 const char *ca_name;
68063 struct module *ca_owner;
68064 umode_t ca_mode;
68065 -};
68066 +} __do_const;
68067
68068 /*
68069 * Users often need to create attribute structures for their configurable
68070 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68071 index ce7a074..01ab8ac 100644
68072 --- a/include/linux/cpu.h
68073 +++ b/include/linux/cpu.h
68074 @@ -115,7 +115,7 @@ enum {
68075 /* Need to know about CPUs going up/down? */
68076 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68077 #define cpu_notifier(fn, pri) { \
68078 - static struct notifier_block fn##_nb __cpuinitdata = \
68079 + static struct notifier_block fn##_nb = \
68080 { .notifier_call = fn, .priority = pri }; \
68081 register_cpu_notifier(&fn##_nb); \
68082 }
68083 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68084 index a55b88e..fba90c5 100644
68085 --- a/include/linux/cpufreq.h
68086 +++ b/include/linux/cpufreq.h
68087 @@ -240,7 +240,7 @@ struct cpufreq_driver {
68088 int (*suspend) (struct cpufreq_policy *policy);
68089 int (*resume) (struct cpufreq_policy *policy);
68090 struct freq_attr **attr;
68091 -};
68092 +} __do_const;
68093
68094 /* flags */
68095
68096 @@ -299,6 +299,7 @@ struct global_attr {
68097 ssize_t (*store)(struct kobject *a, struct attribute *b,
68098 const char *c, size_t count);
68099 };
68100 +typedef struct global_attr __no_const global_attr_no_const;
68101
68102 #define define_one_global_ro(_name) \
68103 static struct global_attr _name = \
68104 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68105 index 24cd1037..20a63aae 100644
68106 --- a/include/linux/cpuidle.h
68107 +++ b/include/linux/cpuidle.h
68108 @@ -54,7 +54,8 @@ struct cpuidle_state {
68109 int index);
68110
68111 int (*enter_dead) (struct cpuidle_device *dev, int index);
68112 -};
68113 +} __do_const;
68114 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68115
68116 /* Idle State Flags */
68117 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68118 @@ -216,7 +217,7 @@ struct cpuidle_governor {
68119 void (*reflect) (struct cpuidle_device *dev, int index);
68120
68121 struct module *owner;
68122 -};
68123 +} __do_const;
68124
68125 #ifdef CONFIG_CPU_IDLE
68126
68127 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68128 index 0325602..5e9feff 100644
68129 --- a/include/linux/cpumask.h
68130 +++ b/include/linux/cpumask.h
68131 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68132 }
68133
68134 /* Valid inputs for n are -1 and 0. */
68135 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68136 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68137 {
68138 return n+1;
68139 }
68140
68141 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68142 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68143 {
68144 return n+1;
68145 }
68146
68147 -static inline unsigned int cpumask_next_and(int n,
68148 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68149 const struct cpumask *srcp,
68150 const struct cpumask *andp)
68151 {
68152 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68153 *
68154 * Returns >= nr_cpu_ids if no further cpus set.
68155 */
68156 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68157 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68158 {
68159 /* -1 is a legal arg here. */
68160 if (n != -1)
68161 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68162 *
68163 * Returns >= nr_cpu_ids if no further cpus unset.
68164 */
68165 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68166 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68167 {
68168 /* -1 is a legal arg here. */
68169 if (n != -1)
68170 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68171 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68172 }
68173
68174 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68175 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68176 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68177
68178 /**
68179 diff --git a/include/linux/cred.h b/include/linux/cred.h
68180 index 04421e8..6bce4ef 100644
68181 --- a/include/linux/cred.h
68182 +++ b/include/linux/cred.h
68183 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68184 static inline void validate_process_creds(void)
68185 {
68186 }
68187 +static inline void validate_task_creds(struct task_struct *task)
68188 +{
68189 +}
68190 #endif
68191
68192 /**
68193 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68194 index b92eadf..b4ecdc1 100644
68195 --- a/include/linux/crypto.h
68196 +++ b/include/linux/crypto.h
68197 @@ -373,7 +373,7 @@ struct cipher_tfm {
68198 const u8 *key, unsigned int keylen);
68199 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68200 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68201 -};
68202 +} __no_const;
68203
68204 struct hash_tfm {
68205 int (*init)(struct hash_desc *desc);
68206 @@ -394,13 +394,13 @@ struct compress_tfm {
68207 int (*cot_decompress)(struct crypto_tfm *tfm,
68208 const u8 *src, unsigned int slen,
68209 u8 *dst, unsigned int *dlen);
68210 -};
68211 +} __no_const;
68212
68213 struct rng_tfm {
68214 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68215 unsigned int dlen);
68216 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68217 -};
68218 +} __no_const;
68219
68220 #define crt_ablkcipher crt_u.ablkcipher
68221 #define crt_aead crt_u.aead
68222 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68223 index 8acfe31..6ffccd63 100644
68224 --- a/include/linux/ctype.h
68225 +++ b/include/linux/ctype.h
68226 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68227 * Fast implementation of tolower() for internal usage. Do not use in your
68228 * code.
68229 */
68230 -static inline char _tolower(const char c)
68231 +static inline unsigned char _tolower(const unsigned char c)
68232 {
68233 return c | 0x20;
68234 }
68235 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68236 index 7925bf0..d5143d2 100644
68237 --- a/include/linux/decompress/mm.h
68238 +++ b/include/linux/decompress/mm.h
68239 @@ -77,7 +77,7 @@ static void free(void *where)
68240 * warnings when not needed (indeed large_malloc / large_free are not
68241 * needed by inflate */
68242
68243 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68244 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68245 #define free(a) kfree(a)
68246
68247 #define large_malloc(a) vmalloc(a)
68248 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68249 index e83ef39..33e0eb3 100644
68250 --- a/include/linux/devfreq.h
68251 +++ b/include/linux/devfreq.h
68252 @@ -114,7 +114,7 @@ struct devfreq_governor {
68253 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68254 int (*event_handler)(struct devfreq *devfreq,
68255 unsigned int event, void *data);
68256 -};
68257 +} __do_const;
68258
68259 /**
68260 * struct devfreq - Device devfreq structure
68261 diff --git a/include/linux/device.h b/include/linux/device.h
68262 index 43dcda9..7a1fb65 100644
68263 --- a/include/linux/device.h
68264 +++ b/include/linux/device.h
68265 @@ -294,7 +294,7 @@ struct subsys_interface {
68266 struct list_head node;
68267 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68268 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68269 -};
68270 +} __do_const;
68271
68272 int subsys_interface_register(struct subsys_interface *sif);
68273 void subsys_interface_unregister(struct subsys_interface *sif);
68274 @@ -474,7 +474,7 @@ struct device_type {
68275 void (*release)(struct device *dev);
68276
68277 const struct dev_pm_ops *pm;
68278 -};
68279 +} __do_const;
68280
68281 /* interface for exporting device attributes */
68282 struct device_attribute {
68283 @@ -484,11 +484,12 @@ struct device_attribute {
68284 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68285 const char *buf, size_t count);
68286 };
68287 +typedef struct device_attribute __no_const device_attribute_no_const;
68288
68289 struct dev_ext_attribute {
68290 struct device_attribute attr;
68291 void *var;
68292 -};
68293 +} __do_const;
68294
68295 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68296 char *buf);
68297 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68298 index 94af418..b1ca7a2 100644
68299 --- a/include/linux/dma-mapping.h
68300 +++ b/include/linux/dma-mapping.h
68301 @@ -54,7 +54,7 @@ struct dma_map_ops {
68302 u64 (*get_required_mask)(struct device *dev);
68303 #endif
68304 int is_phys;
68305 -};
68306 +} __do_const;
68307
68308 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68309
68310 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68311 index d3201e4..8281e63 100644
68312 --- a/include/linux/dmaengine.h
68313 +++ b/include/linux/dmaengine.h
68314 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
68315 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68316 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68317
68318 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68319 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68320 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68321 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68322 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68323 struct dma_pinned_list *pinned_list, struct page *page,
68324 unsigned int offset, size_t len);
68325
68326 diff --git a/include/linux/efi.h b/include/linux/efi.h
68327 index 7a9498a..155713d 100644
68328 --- a/include/linux/efi.h
68329 +++ b/include/linux/efi.h
68330 @@ -733,6 +733,7 @@ struct efivar_operations {
68331 efi_set_variable_t *set_variable;
68332 efi_query_variable_info_t *query_variable_info;
68333 };
68334 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68335
68336 struct efivars {
68337 /*
68338 diff --git a/include/linux/elf.h b/include/linux/elf.h
68339 index 8c9048e..16a4665 100644
68340 --- a/include/linux/elf.h
68341 +++ b/include/linux/elf.h
68342 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
68343 #define elf_note elf32_note
68344 #define elf_addr_t Elf32_Off
68345 #define Elf_Half Elf32_Half
68346 +#define elf_dyn Elf32_Dyn
68347
68348 #else
68349
68350 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
68351 #define elf_note elf64_note
68352 #define elf_addr_t Elf64_Off
68353 #define Elf_Half Elf64_Half
68354 +#define elf_dyn Elf64_Dyn
68355
68356 #endif
68357
68358 diff --git a/include/linux/err.h b/include/linux/err.h
68359 index f2edce2..cc2082c 100644
68360 --- a/include/linux/err.h
68361 +++ b/include/linux/err.h
68362 @@ -19,12 +19,12 @@
68363
68364 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68365
68366 -static inline void * __must_check ERR_PTR(long error)
68367 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68368 {
68369 return (void *) error;
68370 }
68371
68372 -static inline long __must_check PTR_ERR(const void *ptr)
68373 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68374 {
68375 return (long) ptr;
68376 }
68377 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68378 index fcb51c8..bdafcf6 100644
68379 --- a/include/linux/extcon.h
68380 +++ b/include/linux/extcon.h
68381 @@ -134,7 +134,7 @@ struct extcon_dev {
68382 /* /sys/class/extcon/.../mutually_exclusive/... */
68383 struct attribute_group attr_g_muex;
68384 struct attribute **attrs_muex;
68385 - struct device_attribute *d_attrs_muex;
68386 + device_attribute_no_const *d_attrs_muex;
68387 };
68388
68389 /**
68390 diff --git a/include/linux/fb.h b/include/linux/fb.h
68391 index c7a9571..02eeffe 100644
68392 --- a/include/linux/fb.h
68393 +++ b/include/linux/fb.h
68394 @@ -302,7 +302,7 @@ struct fb_ops {
68395 /* called at KDB enter and leave time to prepare the console */
68396 int (*fb_debug_enter)(struct fb_info *info);
68397 int (*fb_debug_leave)(struct fb_info *info);
68398 -};
68399 +} __do_const;
68400
68401 #ifdef CONFIG_FB_TILEBLITTING
68402 #define FB_TILE_CURSOR_NONE 0
68403 diff --git a/include/linux/filter.h b/include/linux/filter.h
68404 index c45eabc..baa0be5 100644
68405 --- a/include/linux/filter.h
68406 +++ b/include/linux/filter.h
68407 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68408
68409 struct sk_buff;
68410 struct sock;
68411 +struct bpf_jit_work;
68412
68413 struct sk_filter
68414 {
68415 @@ -27,6 +28,9 @@ struct sk_filter
68416 unsigned int len; /* Number of filter blocks */
68417 unsigned int (*bpf_func)(const struct sk_buff *skb,
68418 const struct sock_filter *filter);
68419 +#ifdef CONFIG_BPF_JIT
68420 + struct bpf_jit_work *work;
68421 +#endif
68422 struct rcu_head rcu;
68423 struct sock_filter insns[0];
68424 };
68425 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68426 index 3044254..9767f41 100644
68427 --- a/include/linux/frontswap.h
68428 +++ b/include/linux/frontswap.h
68429 @@ -11,7 +11,7 @@ struct frontswap_ops {
68430 int (*load)(unsigned, pgoff_t, struct page *);
68431 void (*invalidate_page)(unsigned, pgoff_t);
68432 void (*invalidate_area)(unsigned);
68433 -};
68434 +} __no_const;
68435
68436 extern bool frontswap_enabled;
68437 extern struct frontswap_ops
68438 diff --git a/include/linux/fs.h b/include/linux/fs.h
68439 index 7617ee0..b575199 100644
68440 --- a/include/linux/fs.h
68441 +++ b/include/linux/fs.h
68442 @@ -1541,7 +1541,8 @@ struct file_operations {
68443 long (*fallocate)(struct file *file, int mode, loff_t offset,
68444 loff_t len);
68445 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68446 -};
68447 +} __do_const;
68448 +typedef struct file_operations __no_const file_operations_no_const;
68449
68450 struct inode_operations {
68451 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68452 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68453 inode->i_flags |= S_NOSEC;
68454 }
68455
68456 +static inline bool is_sidechannel_device(const struct inode *inode)
68457 +{
68458 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68459 + umode_t mode = inode->i_mode;
68460 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68461 +#else
68462 + return false;
68463 +#endif
68464 +}
68465 +
68466 #endif /* _LINUX_FS_H */
68467 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68468 index 324f931..f292b65 100644
68469 --- a/include/linux/fs_struct.h
68470 +++ b/include/linux/fs_struct.h
68471 @@ -6,7 +6,7 @@
68472 #include <linux/seqlock.h>
68473
68474 struct fs_struct {
68475 - int users;
68476 + atomic_t users;
68477 spinlock_t lock;
68478 seqcount_t seq;
68479 int umask;
68480 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68481 index 5dfa0aa..6acf322 100644
68482 --- a/include/linux/fscache-cache.h
68483 +++ b/include/linux/fscache-cache.h
68484 @@ -112,7 +112,7 @@ struct fscache_operation {
68485 fscache_operation_release_t release;
68486 };
68487
68488 -extern atomic_t fscache_op_debug_id;
68489 +extern atomic_unchecked_t fscache_op_debug_id;
68490 extern void fscache_op_work_func(struct work_struct *work);
68491
68492 extern void fscache_enqueue_operation(struct fscache_operation *);
68493 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68494 INIT_WORK(&op->work, fscache_op_work_func);
68495 atomic_set(&op->usage, 1);
68496 op->state = FSCACHE_OP_ST_INITIALISED;
68497 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68498 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68499 op->processor = processor;
68500 op->release = release;
68501 INIT_LIST_HEAD(&op->pend_link);
68502 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68503 index 7a08623..4c07b0f 100644
68504 --- a/include/linux/fscache.h
68505 +++ b/include/linux/fscache.h
68506 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68507 * - this is mandatory for any object that may have data
68508 */
68509 void (*now_uncached)(void *cookie_netfs_data);
68510 -};
68511 +} __do_const;
68512
68513 /*
68514 * fscache cached network filesystem type
68515 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68516 index 0fbfb46..508eb0d 100644
68517 --- a/include/linux/fsnotify.h
68518 +++ b/include/linux/fsnotify.h
68519 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68520 struct inode *inode = path->dentry->d_inode;
68521 __u32 mask = FS_ACCESS;
68522
68523 + if (is_sidechannel_device(inode))
68524 + return;
68525 +
68526 if (S_ISDIR(inode->i_mode))
68527 mask |= FS_ISDIR;
68528
68529 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68530 struct inode *inode = path->dentry->d_inode;
68531 __u32 mask = FS_MODIFY;
68532
68533 + if (is_sidechannel_device(inode))
68534 + return;
68535 +
68536 if (S_ISDIR(inode->i_mode))
68537 mask |= FS_ISDIR;
68538
68539 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68540 */
68541 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68542 {
68543 - return kstrdup(name, GFP_KERNEL);
68544 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68545 }
68546
68547 /*
68548 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68549 index a3d4895..ddd2a50 100644
68550 --- a/include/linux/ftrace_event.h
68551 +++ b/include/linux/ftrace_event.h
68552 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68553 extern int trace_add_event_call(struct ftrace_event_call *call);
68554 extern void trace_remove_event_call(struct ftrace_event_call *call);
68555
68556 -#define is_signed_type(type) (((type)(-1)) < 0)
68557 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68558
68559 int trace_set_clr_event(const char *system, const char *event, int set);
68560
68561 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68562 index 79b8bba..86b539e 100644
68563 --- a/include/linux/genhd.h
68564 +++ b/include/linux/genhd.h
68565 @@ -194,7 +194,7 @@ struct gendisk {
68566 struct kobject *slave_dir;
68567
68568 struct timer_rand_state *random;
68569 - atomic_t sync_io; /* RAID */
68570 + atomic_unchecked_t sync_io; /* RAID */
68571 struct disk_events *ev;
68572 #ifdef CONFIG_BLK_DEV_INTEGRITY
68573 struct blk_integrity *integrity;
68574 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68575 index 023bc34..b02b46a 100644
68576 --- a/include/linux/genl_magic_func.h
68577 +++ b/include/linux/genl_magic_func.h
68578 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68579 },
68580
68581 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68582 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68583 +static struct genl_ops ZZZ_genl_ops[] = {
68584 #include GENL_MAGIC_INCLUDE_FILE
68585 };
68586
68587 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68588 index 0f615eb..5c3832f 100644
68589 --- a/include/linux/gfp.h
68590 +++ b/include/linux/gfp.h
68591 @@ -35,6 +35,13 @@ struct vm_area_struct;
68592 #define ___GFP_NO_KSWAPD 0x400000u
68593 #define ___GFP_OTHER_NODE 0x800000u
68594 #define ___GFP_WRITE 0x1000000u
68595 +
68596 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68597 +#define ___GFP_USERCOPY 0x2000000u
68598 +#else
68599 +#define ___GFP_USERCOPY 0
68600 +#endif
68601 +
68602 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68603
68604 /*
68605 @@ -92,6 +99,7 @@ struct vm_area_struct;
68606 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68607 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68608 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68609 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68610
68611 /*
68612 * This may seem redundant, but it's a way of annotating false positives vs.
68613 @@ -99,7 +107,7 @@ struct vm_area_struct;
68614 */
68615 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68616
68617 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68618 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68619 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68620
68621 /* This equals 0, but use constants in case they ever change */
68622 @@ -153,6 +161,8 @@ struct vm_area_struct;
68623 /* 4GB DMA on some platforms */
68624 #define GFP_DMA32 __GFP_DMA32
68625
68626 +#define GFP_USERCOPY __GFP_USERCOPY
68627 +
68628 /* Convert GFP flags to their corresponding migrate type */
68629 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68630 {
68631 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68632 new file mode 100644
68633 index 0000000..ebe6d72
68634 --- /dev/null
68635 +++ b/include/linux/gracl.h
68636 @@ -0,0 +1,319 @@
68637 +#ifndef GR_ACL_H
68638 +#define GR_ACL_H
68639 +
68640 +#include <linux/grdefs.h>
68641 +#include <linux/resource.h>
68642 +#include <linux/capability.h>
68643 +#include <linux/dcache.h>
68644 +#include <asm/resource.h>
68645 +
68646 +/* Major status information */
68647 +
68648 +#define GR_VERSION "grsecurity 2.9.1"
68649 +#define GRSECURITY_VERSION 0x2901
68650 +
68651 +enum {
68652 + GR_SHUTDOWN = 0,
68653 + GR_ENABLE = 1,
68654 + GR_SPROLE = 2,
68655 + GR_RELOAD = 3,
68656 + GR_SEGVMOD = 4,
68657 + GR_STATUS = 5,
68658 + GR_UNSPROLE = 6,
68659 + GR_PASSSET = 7,
68660 + GR_SPROLEPAM = 8,
68661 +};
68662 +
68663 +/* Password setup definitions
68664 + * kernel/grhash.c */
68665 +enum {
68666 + GR_PW_LEN = 128,
68667 + GR_SALT_LEN = 16,
68668 + GR_SHA_LEN = 32,
68669 +};
68670 +
68671 +enum {
68672 + GR_SPROLE_LEN = 64,
68673 +};
68674 +
68675 +enum {
68676 + GR_NO_GLOB = 0,
68677 + GR_REG_GLOB,
68678 + GR_CREATE_GLOB
68679 +};
68680 +
68681 +#define GR_NLIMITS 32
68682 +
68683 +/* Begin Data Structures */
68684 +
68685 +struct sprole_pw {
68686 + unsigned char *rolename;
68687 + unsigned char salt[GR_SALT_LEN];
68688 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68689 +};
68690 +
68691 +struct name_entry {
68692 + __u32 key;
68693 + ino_t inode;
68694 + dev_t device;
68695 + char *name;
68696 + __u16 len;
68697 + __u8 deleted;
68698 + struct name_entry *prev;
68699 + struct name_entry *next;
68700 +};
68701 +
68702 +struct inodev_entry {
68703 + struct name_entry *nentry;
68704 + struct inodev_entry *prev;
68705 + struct inodev_entry *next;
68706 +};
68707 +
68708 +struct acl_role_db {
68709 + struct acl_role_label **r_hash;
68710 + __u32 r_size;
68711 +};
68712 +
68713 +struct inodev_db {
68714 + struct inodev_entry **i_hash;
68715 + __u32 i_size;
68716 +};
68717 +
68718 +struct name_db {
68719 + struct name_entry **n_hash;
68720 + __u32 n_size;
68721 +};
68722 +
68723 +struct crash_uid {
68724 + uid_t uid;
68725 + unsigned long expires;
68726 +};
68727 +
68728 +struct gr_hash_struct {
68729 + void **table;
68730 + void **nametable;
68731 + void *first;
68732 + __u32 table_size;
68733 + __u32 used_size;
68734 + int type;
68735 +};
68736 +
68737 +/* Userspace Grsecurity ACL data structures */
68738 +
68739 +struct acl_subject_label {
68740 + char *filename;
68741 + ino_t inode;
68742 + dev_t device;
68743 + __u32 mode;
68744 + kernel_cap_t cap_mask;
68745 + kernel_cap_t cap_lower;
68746 + kernel_cap_t cap_invert_audit;
68747 +
68748 + struct rlimit res[GR_NLIMITS];
68749 + __u32 resmask;
68750 +
68751 + __u8 user_trans_type;
68752 + __u8 group_trans_type;
68753 + uid_t *user_transitions;
68754 + gid_t *group_transitions;
68755 + __u16 user_trans_num;
68756 + __u16 group_trans_num;
68757 +
68758 + __u32 sock_families[2];
68759 + __u32 ip_proto[8];
68760 + __u32 ip_type;
68761 + struct acl_ip_label **ips;
68762 + __u32 ip_num;
68763 + __u32 inaddr_any_override;
68764 +
68765 + __u32 crashes;
68766 + unsigned long expires;
68767 +
68768 + struct acl_subject_label *parent_subject;
68769 + struct gr_hash_struct *hash;
68770 + struct acl_subject_label *prev;
68771 + struct acl_subject_label *next;
68772 +
68773 + struct acl_object_label **obj_hash;
68774 + __u32 obj_hash_size;
68775 + __u16 pax_flags;
68776 +};
68777 +
68778 +struct role_allowed_ip {
68779 + __u32 addr;
68780 + __u32 netmask;
68781 +
68782 + struct role_allowed_ip *prev;
68783 + struct role_allowed_ip *next;
68784 +};
68785 +
68786 +struct role_transition {
68787 + char *rolename;
68788 +
68789 + struct role_transition *prev;
68790 + struct role_transition *next;
68791 +};
68792 +
68793 +struct acl_role_label {
68794 + char *rolename;
68795 + uid_t uidgid;
68796 + __u16 roletype;
68797 +
68798 + __u16 auth_attempts;
68799 + unsigned long expires;
68800 +
68801 + struct acl_subject_label *root_label;
68802 + struct gr_hash_struct *hash;
68803 +
68804 + struct acl_role_label *prev;
68805 + struct acl_role_label *next;
68806 +
68807 + struct role_transition *transitions;
68808 + struct role_allowed_ip *allowed_ips;
68809 + uid_t *domain_children;
68810 + __u16 domain_child_num;
68811 +
68812 + umode_t umask;
68813 +
68814 + struct acl_subject_label **subj_hash;
68815 + __u32 subj_hash_size;
68816 +};
68817 +
68818 +struct user_acl_role_db {
68819 + struct acl_role_label **r_table;
68820 + __u32 num_pointers; /* Number of allocations to track */
68821 + __u32 num_roles; /* Number of roles */
68822 + __u32 num_domain_children; /* Number of domain children */
68823 + __u32 num_subjects; /* Number of subjects */
68824 + __u32 num_objects; /* Number of objects */
68825 +};
68826 +
68827 +struct acl_object_label {
68828 + char *filename;
68829 + ino_t inode;
68830 + dev_t device;
68831 + __u32 mode;
68832 +
68833 + struct acl_subject_label *nested;
68834 + struct acl_object_label *globbed;
68835 +
68836 + /* next two structures not used */
68837 +
68838 + struct acl_object_label *prev;
68839 + struct acl_object_label *next;
68840 +};
68841 +
68842 +struct acl_ip_label {
68843 + char *iface;
68844 + __u32 addr;
68845 + __u32 netmask;
68846 + __u16 low, high;
68847 + __u8 mode;
68848 + __u32 type;
68849 + __u32 proto[8];
68850 +
68851 + /* next two structures not used */
68852 +
68853 + struct acl_ip_label *prev;
68854 + struct acl_ip_label *next;
68855 +};
68856 +
68857 +struct gr_arg {
68858 + struct user_acl_role_db role_db;
68859 + unsigned char pw[GR_PW_LEN];
68860 + unsigned char salt[GR_SALT_LEN];
68861 + unsigned char sum[GR_SHA_LEN];
68862 + unsigned char sp_role[GR_SPROLE_LEN];
68863 + struct sprole_pw *sprole_pws;
68864 + dev_t segv_device;
68865 + ino_t segv_inode;
68866 + uid_t segv_uid;
68867 + __u16 num_sprole_pws;
68868 + __u16 mode;
68869 +};
68870 +
68871 +struct gr_arg_wrapper {
68872 + struct gr_arg *arg;
68873 + __u32 version;
68874 + __u32 size;
68875 +};
68876 +
68877 +struct subject_map {
68878 + struct acl_subject_label *user;
68879 + struct acl_subject_label *kernel;
68880 + struct subject_map *prev;
68881 + struct subject_map *next;
68882 +};
68883 +
68884 +struct acl_subj_map_db {
68885 + struct subject_map **s_hash;
68886 + __u32 s_size;
68887 +};
68888 +
68889 +/* End Data Structures Section */
68890 +
68891 +/* Hash functions generated by empirical testing by Brad Spengler
68892 + Makes good use of the low bits of the inode. Generally 0-1 times
68893 + in loop for successful match. 0-3 for unsuccessful match.
68894 + Shift/add algorithm with modulus of table size and an XOR*/
68895 +
68896 +static __inline__ unsigned int
68897 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68898 +{
68899 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68900 +}
68901 +
68902 + static __inline__ unsigned int
68903 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68904 +{
68905 + return ((const unsigned long)userp % sz);
68906 +}
68907 +
68908 +static __inline__ unsigned int
68909 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68910 +{
68911 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68912 +}
68913 +
68914 +static __inline__ unsigned int
68915 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68916 +{
68917 + return full_name_hash((const unsigned char *)name, len) % sz;
68918 +}
68919 +
68920 +#define FOR_EACH_ROLE_START(role) \
68921 + role = role_list; \
68922 + while (role) {
68923 +
68924 +#define FOR_EACH_ROLE_END(role) \
68925 + role = role->prev; \
68926 + }
68927 +
68928 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68929 + subj = NULL; \
68930 + iter = 0; \
68931 + while (iter < role->subj_hash_size) { \
68932 + if (subj == NULL) \
68933 + subj = role->subj_hash[iter]; \
68934 + if (subj == NULL) { \
68935 + iter++; \
68936 + continue; \
68937 + }
68938 +
68939 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68940 + subj = subj->next; \
68941 + if (subj == NULL) \
68942 + iter++; \
68943 + }
68944 +
68945 +
68946 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68947 + subj = role->hash->first; \
68948 + while (subj != NULL) {
68949 +
68950 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68951 + subj = subj->next; \
68952 + }
68953 +
68954 +#endif
68955 +
68956 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68957 new file mode 100644
68958 index 0000000..323ecf2
68959 --- /dev/null
68960 +++ b/include/linux/gralloc.h
68961 @@ -0,0 +1,9 @@
68962 +#ifndef __GRALLOC_H
68963 +#define __GRALLOC_H
68964 +
68965 +void acl_free_all(void);
68966 +int acl_alloc_stack_init(unsigned long size);
68967 +void *acl_alloc(unsigned long len);
68968 +void *acl_alloc_num(unsigned long num, unsigned long len);
68969 +
68970 +#endif
68971 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68972 new file mode 100644
68973 index 0000000..be66033
68974 --- /dev/null
68975 +++ b/include/linux/grdefs.h
68976 @@ -0,0 +1,140 @@
68977 +#ifndef GRDEFS_H
68978 +#define GRDEFS_H
68979 +
68980 +/* Begin grsecurity status declarations */
68981 +
68982 +enum {
68983 + GR_READY = 0x01,
68984 + GR_STATUS_INIT = 0x00 // disabled state
68985 +};
68986 +
68987 +/* Begin ACL declarations */
68988 +
68989 +/* Role flags */
68990 +
68991 +enum {
68992 + GR_ROLE_USER = 0x0001,
68993 + GR_ROLE_GROUP = 0x0002,
68994 + GR_ROLE_DEFAULT = 0x0004,
68995 + GR_ROLE_SPECIAL = 0x0008,
68996 + GR_ROLE_AUTH = 0x0010,
68997 + GR_ROLE_NOPW = 0x0020,
68998 + GR_ROLE_GOD = 0x0040,
68999 + GR_ROLE_LEARN = 0x0080,
69000 + GR_ROLE_TPE = 0x0100,
69001 + GR_ROLE_DOMAIN = 0x0200,
69002 + GR_ROLE_PAM = 0x0400,
69003 + GR_ROLE_PERSIST = 0x0800
69004 +};
69005 +
69006 +/* ACL Subject and Object mode flags */
69007 +enum {
69008 + GR_DELETED = 0x80000000
69009 +};
69010 +
69011 +/* ACL Object-only mode flags */
69012 +enum {
69013 + GR_READ = 0x00000001,
69014 + GR_APPEND = 0x00000002,
69015 + GR_WRITE = 0x00000004,
69016 + GR_EXEC = 0x00000008,
69017 + GR_FIND = 0x00000010,
69018 + GR_INHERIT = 0x00000020,
69019 + GR_SETID = 0x00000040,
69020 + GR_CREATE = 0x00000080,
69021 + GR_DELETE = 0x00000100,
69022 + GR_LINK = 0x00000200,
69023 + GR_AUDIT_READ = 0x00000400,
69024 + GR_AUDIT_APPEND = 0x00000800,
69025 + GR_AUDIT_WRITE = 0x00001000,
69026 + GR_AUDIT_EXEC = 0x00002000,
69027 + GR_AUDIT_FIND = 0x00004000,
69028 + GR_AUDIT_INHERIT= 0x00008000,
69029 + GR_AUDIT_SETID = 0x00010000,
69030 + GR_AUDIT_CREATE = 0x00020000,
69031 + GR_AUDIT_DELETE = 0x00040000,
69032 + GR_AUDIT_LINK = 0x00080000,
69033 + GR_PTRACERD = 0x00100000,
69034 + GR_NOPTRACE = 0x00200000,
69035 + GR_SUPPRESS = 0x00400000,
69036 + GR_NOLEARN = 0x00800000,
69037 + GR_INIT_TRANSFER= 0x01000000
69038 +};
69039 +
69040 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69041 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69042 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69043 +
69044 +/* ACL subject-only mode flags */
69045 +enum {
69046 + GR_KILL = 0x00000001,
69047 + GR_VIEW = 0x00000002,
69048 + GR_PROTECTED = 0x00000004,
69049 + GR_LEARN = 0x00000008,
69050 + GR_OVERRIDE = 0x00000010,
69051 + /* just a placeholder, this mode is only used in userspace */
69052 + GR_DUMMY = 0x00000020,
69053 + GR_PROTSHM = 0x00000040,
69054 + GR_KILLPROC = 0x00000080,
69055 + GR_KILLIPPROC = 0x00000100,
69056 + /* just a placeholder, this mode is only used in userspace */
69057 + GR_NOTROJAN = 0x00000200,
69058 + GR_PROTPROCFD = 0x00000400,
69059 + GR_PROCACCT = 0x00000800,
69060 + GR_RELAXPTRACE = 0x00001000,
69061 + //GR_NESTED = 0x00002000,
69062 + GR_INHERITLEARN = 0x00004000,
69063 + GR_PROCFIND = 0x00008000,
69064 + GR_POVERRIDE = 0x00010000,
69065 + GR_KERNELAUTH = 0x00020000,
69066 + GR_ATSECURE = 0x00040000,
69067 + GR_SHMEXEC = 0x00080000
69068 +};
69069 +
69070 +enum {
69071 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69072 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69073 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69074 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69075 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69076 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69077 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69078 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69079 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69080 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69081 +};
69082 +
69083 +enum {
69084 + GR_ID_USER = 0x01,
69085 + GR_ID_GROUP = 0x02,
69086 +};
69087 +
69088 +enum {
69089 + GR_ID_ALLOW = 0x01,
69090 + GR_ID_DENY = 0x02,
69091 +};
69092 +
69093 +#define GR_CRASH_RES 31
69094 +#define GR_UIDTABLE_MAX 500
69095 +
69096 +/* begin resource learning section */
69097 +enum {
69098 + GR_RLIM_CPU_BUMP = 60,
69099 + GR_RLIM_FSIZE_BUMP = 50000,
69100 + GR_RLIM_DATA_BUMP = 10000,
69101 + GR_RLIM_STACK_BUMP = 1000,
69102 + GR_RLIM_CORE_BUMP = 10000,
69103 + GR_RLIM_RSS_BUMP = 500000,
69104 + GR_RLIM_NPROC_BUMP = 1,
69105 + GR_RLIM_NOFILE_BUMP = 5,
69106 + GR_RLIM_MEMLOCK_BUMP = 50000,
69107 + GR_RLIM_AS_BUMP = 500000,
69108 + GR_RLIM_LOCKS_BUMP = 2,
69109 + GR_RLIM_SIGPENDING_BUMP = 5,
69110 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69111 + GR_RLIM_NICE_BUMP = 1,
69112 + GR_RLIM_RTPRIO_BUMP = 1,
69113 + GR_RLIM_RTTIME_BUMP = 1000000
69114 +};
69115 +
69116 +#endif
69117 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69118 new file mode 100644
69119 index 0000000..9bb6662
69120 --- /dev/null
69121 +++ b/include/linux/grinternal.h
69122 @@ -0,0 +1,215 @@
69123 +#ifndef __GRINTERNAL_H
69124 +#define __GRINTERNAL_H
69125 +
69126 +#ifdef CONFIG_GRKERNSEC
69127 +
69128 +#include <linux/fs.h>
69129 +#include <linux/mnt_namespace.h>
69130 +#include <linux/nsproxy.h>
69131 +#include <linux/gracl.h>
69132 +#include <linux/grdefs.h>
69133 +#include <linux/grmsg.h>
69134 +
69135 +void gr_add_learn_entry(const char *fmt, ...)
69136 + __attribute__ ((format (printf, 1, 2)));
69137 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69138 + const struct vfsmount *mnt);
69139 +__u32 gr_check_create(const struct dentry *new_dentry,
69140 + const struct dentry *parent,
69141 + const struct vfsmount *mnt, const __u32 mode);
69142 +int gr_check_protected_task(const struct task_struct *task);
69143 +__u32 to_gr_audit(const __u32 reqmode);
69144 +int gr_set_acls(const int type);
69145 +int gr_apply_subject_to_task(struct task_struct *task);
69146 +int gr_acl_is_enabled(void);
69147 +char gr_roletype_to_char(void);
69148 +
69149 +void gr_handle_alertkill(struct task_struct *task);
69150 +char *gr_to_filename(const struct dentry *dentry,
69151 + const struct vfsmount *mnt);
69152 +char *gr_to_filename1(const struct dentry *dentry,
69153 + const struct vfsmount *mnt);
69154 +char *gr_to_filename2(const struct dentry *dentry,
69155 + const struct vfsmount *mnt);
69156 +char *gr_to_filename3(const struct dentry *dentry,
69157 + const struct vfsmount *mnt);
69158 +
69159 +extern int grsec_enable_ptrace_readexec;
69160 +extern int grsec_enable_harden_ptrace;
69161 +extern int grsec_enable_link;
69162 +extern int grsec_enable_fifo;
69163 +extern int grsec_enable_execve;
69164 +extern int grsec_enable_shm;
69165 +extern int grsec_enable_execlog;
69166 +extern int grsec_enable_signal;
69167 +extern int grsec_enable_audit_ptrace;
69168 +extern int grsec_enable_forkfail;
69169 +extern int grsec_enable_time;
69170 +extern int grsec_enable_rofs;
69171 +extern int grsec_enable_chroot_shmat;
69172 +extern int grsec_enable_chroot_mount;
69173 +extern int grsec_enable_chroot_double;
69174 +extern int grsec_enable_chroot_pivot;
69175 +extern int grsec_enable_chroot_chdir;
69176 +extern int grsec_enable_chroot_chmod;
69177 +extern int grsec_enable_chroot_mknod;
69178 +extern int grsec_enable_chroot_fchdir;
69179 +extern int grsec_enable_chroot_nice;
69180 +extern int grsec_enable_chroot_execlog;
69181 +extern int grsec_enable_chroot_caps;
69182 +extern int grsec_enable_chroot_sysctl;
69183 +extern int grsec_enable_chroot_unix;
69184 +extern int grsec_enable_symlinkown;
69185 +extern kgid_t grsec_symlinkown_gid;
69186 +extern int grsec_enable_tpe;
69187 +extern kgid_t grsec_tpe_gid;
69188 +extern int grsec_enable_tpe_all;
69189 +extern int grsec_enable_tpe_invert;
69190 +extern int grsec_enable_socket_all;
69191 +extern kgid_t grsec_socket_all_gid;
69192 +extern int grsec_enable_socket_client;
69193 +extern kgid_t grsec_socket_client_gid;
69194 +extern int grsec_enable_socket_server;
69195 +extern kgid_t grsec_socket_server_gid;
69196 +extern kgid_t grsec_audit_gid;
69197 +extern int grsec_enable_group;
69198 +extern int grsec_enable_audit_textrel;
69199 +extern int grsec_enable_log_rwxmaps;
69200 +extern int grsec_enable_mount;
69201 +extern int grsec_enable_chdir;
69202 +extern int grsec_resource_logging;
69203 +extern int grsec_enable_blackhole;
69204 +extern int grsec_lastack_retries;
69205 +extern int grsec_enable_brute;
69206 +extern int grsec_lock;
69207 +
69208 +extern spinlock_t grsec_alert_lock;
69209 +extern unsigned long grsec_alert_wtime;
69210 +extern unsigned long grsec_alert_fyet;
69211 +
69212 +extern spinlock_t grsec_audit_lock;
69213 +
69214 +extern rwlock_t grsec_exec_file_lock;
69215 +
69216 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69217 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69218 + (tsk)->exec_file->f_vfsmnt) : "/")
69219 +
69220 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69221 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69222 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69223 +
69224 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69225 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69226 + (tsk)->exec_file->f_vfsmnt) : "/")
69227 +
69228 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69229 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69230 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69231 +
69232 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69233 +
69234 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69235 +
69236 +#define GR_CHROOT_CAPS {{ \
69237 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69238 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69239 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69240 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69241 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69242 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69243 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69244 +
69245 +#define security_learn(normal_msg,args...) \
69246 +({ \
69247 + read_lock(&grsec_exec_file_lock); \
69248 + gr_add_learn_entry(normal_msg "\n", ## args); \
69249 + read_unlock(&grsec_exec_file_lock); \
69250 +})
69251 +
69252 +enum {
69253 + GR_DO_AUDIT,
69254 + GR_DONT_AUDIT,
69255 + /* used for non-audit messages that we shouldn't kill the task on */
69256 + GR_DONT_AUDIT_GOOD
69257 +};
69258 +
69259 +enum {
69260 + GR_TTYSNIFF,
69261 + GR_RBAC,
69262 + GR_RBAC_STR,
69263 + GR_STR_RBAC,
69264 + GR_RBAC_MODE2,
69265 + GR_RBAC_MODE3,
69266 + GR_FILENAME,
69267 + GR_SYSCTL_HIDDEN,
69268 + GR_NOARGS,
69269 + GR_ONE_INT,
69270 + GR_ONE_INT_TWO_STR,
69271 + GR_ONE_STR,
69272 + GR_STR_INT,
69273 + GR_TWO_STR_INT,
69274 + GR_TWO_INT,
69275 + GR_TWO_U64,
69276 + GR_THREE_INT,
69277 + GR_FIVE_INT_TWO_STR,
69278 + GR_TWO_STR,
69279 + GR_THREE_STR,
69280 + GR_FOUR_STR,
69281 + GR_STR_FILENAME,
69282 + GR_FILENAME_STR,
69283 + GR_FILENAME_TWO_INT,
69284 + GR_FILENAME_TWO_INT_STR,
69285 + GR_TEXTREL,
69286 + GR_PTRACE,
69287 + GR_RESOURCE,
69288 + GR_CAP,
69289 + GR_SIG,
69290 + GR_SIG2,
69291 + GR_CRASH1,
69292 + GR_CRASH2,
69293 + GR_PSACCT,
69294 + GR_RWXMAP
69295 +};
69296 +
69297 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69298 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69299 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69300 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69301 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69302 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69303 +#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)
69304 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69305 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69306 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69307 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69308 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69309 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69310 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69311 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69312 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69313 +#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)
69314 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69315 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69316 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69317 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69318 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69319 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69320 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69321 +#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)
69322 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69323 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69324 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69325 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69326 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69327 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69328 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69329 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69330 +#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)
69331 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69332 +
69333 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69334 +
69335 +#endif
69336 +
69337 +#endif
69338 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69339 new file mode 100644
69340 index 0000000..2bd4c8d
69341 --- /dev/null
69342 +++ b/include/linux/grmsg.h
69343 @@ -0,0 +1,111 @@
69344 +#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"
69345 +#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"
69346 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69347 +#define GR_STOPMOD_MSG "denied modification of module state by "
69348 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69349 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69350 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69351 +#define GR_IOPL_MSG "denied use of iopl() by "
69352 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69353 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69354 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69355 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69356 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69357 +#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"
69358 +#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"
69359 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69360 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69361 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69362 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69363 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69364 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69365 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69366 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69367 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69368 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69369 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69370 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69371 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69372 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69373 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69374 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69375 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69376 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69377 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69378 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69379 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69380 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69381 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69382 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69383 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69384 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69385 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69386 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69387 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69388 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69389 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69390 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69391 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69392 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69393 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69394 +#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"
69395 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69396 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69397 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69398 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69399 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69400 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69401 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69402 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69403 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69404 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69405 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69406 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69407 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69408 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69409 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69410 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69411 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69412 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69413 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69414 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69415 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69416 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69417 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69418 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69419 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69420 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69421 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69422 +#define GR_TIME_MSG "time set by "
69423 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69424 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69425 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69426 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69427 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69428 +#define GR_BIND_MSG "denied bind() by "
69429 +#define GR_CONNECT_MSG "denied connect() by "
69430 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69431 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69432 +#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"
69433 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69434 +#define GR_CAP_ACL_MSG "use of %s denied for "
69435 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69436 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69437 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69438 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69439 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69440 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69441 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69442 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69443 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69444 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69445 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69446 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69447 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69448 +#define GR_VM86_MSG "denied use of vm86 by "
69449 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69450 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69451 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69452 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69453 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69454 +#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 "
69455 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69456 new file mode 100644
69457 index 0000000..8da63a4
69458 --- /dev/null
69459 +++ b/include/linux/grsecurity.h
69460 @@ -0,0 +1,242 @@
69461 +#ifndef GR_SECURITY_H
69462 +#define GR_SECURITY_H
69463 +#include <linux/fs.h>
69464 +#include <linux/fs_struct.h>
69465 +#include <linux/binfmts.h>
69466 +#include <linux/gracl.h>
69467 +
69468 +/* notify of brain-dead configs */
69469 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69470 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69471 +#endif
69472 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69473 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69474 +#endif
69475 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69476 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69477 +#endif
69478 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69479 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69480 +#endif
69481 +
69482 +void gr_handle_brute_attach(unsigned long mm_flags);
69483 +void gr_handle_brute_check(void);
69484 +void gr_handle_kernel_exploit(void);
69485 +int gr_process_user_ban(void);
69486 +
69487 +char gr_roletype_to_char(void);
69488 +
69489 +int gr_acl_enable_at_secure(void);
69490 +
69491 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69492 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69493 +
69494 +void gr_del_task_from_ip_table(struct task_struct *p);
69495 +
69496 +int gr_pid_is_chrooted(struct task_struct *p);
69497 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69498 +int gr_handle_chroot_nice(void);
69499 +int gr_handle_chroot_sysctl(const int op);
69500 +int gr_handle_chroot_setpriority(struct task_struct *p,
69501 + const int niceval);
69502 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69503 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69504 + const struct vfsmount *mnt);
69505 +void gr_handle_chroot_chdir(struct path *path);
69506 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69507 + const struct vfsmount *mnt, const int mode);
69508 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69509 + const struct vfsmount *mnt, const int mode);
69510 +int gr_handle_chroot_mount(const struct dentry *dentry,
69511 + const struct vfsmount *mnt,
69512 + const char *dev_name);
69513 +int gr_handle_chroot_pivot(void);
69514 +int gr_handle_chroot_unix(const pid_t pid);
69515 +
69516 +int gr_handle_rawio(const struct inode *inode);
69517 +
69518 +void gr_handle_ioperm(void);
69519 +void gr_handle_iopl(void);
69520 +
69521 +umode_t gr_acl_umask(void);
69522 +
69523 +int gr_tpe_allow(const struct file *file);
69524 +
69525 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
69526 +void gr_clear_chroot_entries(struct task_struct *task);
69527 +
69528 +void gr_log_forkfail(const int retval);
69529 +void gr_log_timechange(void);
69530 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69531 +void gr_log_chdir(const struct dentry *dentry,
69532 + const struct vfsmount *mnt);
69533 +void gr_log_chroot_exec(const struct dentry *dentry,
69534 + const struct vfsmount *mnt);
69535 +void gr_log_remount(const char *devname, const int retval);
69536 +void gr_log_unmount(const char *devname, const int retval);
69537 +void gr_log_mount(const char *from, const char *to, const int retval);
69538 +void gr_log_textrel(struct vm_area_struct *vma);
69539 +void gr_log_rwxmmap(struct file *file);
69540 +void gr_log_rwxmprotect(struct file *file);
69541 +
69542 +int gr_handle_follow_link(const struct inode *parent,
69543 + const struct inode *inode,
69544 + const struct dentry *dentry,
69545 + const struct vfsmount *mnt);
69546 +int gr_handle_fifo(const struct dentry *dentry,
69547 + const struct vfsmount *mnt,
69548 + const struct dentry *dir, const int flag,
69549 + const int acc_mode);
69550 +int gr_handle_hardlink(const struct dentry *dentry,
69551 + const struct vfsmount *mnt,
69552 + struct inode *inode,
69553 + const int mode, const struct filename *to);
69554 +
69555 +int gr_is_capable(const int cap);
69556 +int gr_is_capable_nolog(const int cap);
69557 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69558 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69559 +
69560 +void gr_copy_label(struct task_struct *tsk);
69561 +void gr_handle_crash(struct task_struct *task, const int sig);
69562 +int gr_handle_signal(const struct task_struct *p, const int sig);
69563 +int gr_check_crash_uid(const kuid_t uid);
69564 +int gr_check_protected_task(const struct task_struct *task);
69565 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69566 +int gr_acl_handle_mmap(const struct file *file,
69567 + const unsigned long prot);
69568 +int gr_acl_handle_mprotect(const struct file *file,
69569 + const unsigned long prot);
69570 +int gr_check_hidden_task(const struct task_struct *tsk);
69571 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69572 + const struct vfsmount *mnt);
69573 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69574 + const struct vfsmount *mnt);
69575 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69576 + const struct vfsmount *mnt, const int fmode);
69577 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69578 + const struct vfsmount *mnt, umode_t *mode);
69579 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69580 + const struct vfsmount *mnt);
69581 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69582 + const struct vfsmount *mnt);
69583 +int gr_handle_ptrace(struct task_struct *task, const long request);
69584 +int gr_handle_proc_ptrace(struct task_struct *task);
69585 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69586 + const struct vfsmount *mnt);
69587 +int gr_check_crash_exec(const struct file *filp);
69588 +int gr_acl_is_enabled(void);
69589 +void gr_set_kernel_label(struct task_struct *task);
69590 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69591 + const kgid_t gid);
69592 +int gr_set_proc_label(const struct dentry *dentry,
69593 + const struct vfsmount *mnt,
69594 + const int unsafe_flags);
69595 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69596 + const struct vfsmount *mnt);
69597 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69598 + const struct vfsmount *mnt, int acc_mode);
69599 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69600 + const struct dentry *p_dentry,
69601 + const struct vfsmount *p_mnt,
69602 + int open_flags, int acc_mode, const int imode);
69603 +void gr_handle_create(const struct dentry *dentry,
69604 + const struct vfsmount *mnt);
69605 +void gr_handle_proc_create(const struct dentry *dentry,
69606 + const struct inode *inode);
69607 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69608 + const struct dentry *parent_dentry,
69609 + const struct vfsmount *parent_mnt,
69610 + const int mode);
69611 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69612 + const struct dentry *parent_dentry,
69613 + const struct vfsmount *parent_mnt);
69614 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69615 + const struct vfsmount *mnt);
69616 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69617 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69618 + const struct vfsmount *mnt);
69619 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69620 + const struct dentry *parent_dentry,
69621 + const struct vfsmount *parent_mnt,
69622 + const struct filename *from);
69623 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69624 + const struct dentry *parent_dentry,
69625 + const struct vfsmount *parent_mnt,
69626 + const struct dentry *old_dentry,
69627 + const struct vfsmount *old_mnt, const struct filename *to);
69628 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69629 +int gr_acl_handle_rename(struct dentry *new_dentry,
69630 + struct dentry *parent_dentry,
69631 + const struct vfsmount *parent_mnt,
69632 + struct dentry *old_dentry,
69633 + struct inode *old_parent_inode,
69634 + struct vfsmount *old_mnt, const struct filename *newname);
69635 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69636 + struct dentry *old_dentry,
69637 + struct dentry *new_dentry,
69638 + struct vfsmount *mnt, const __u8 replace);
69639 +__u32 gr_check_link(const struct dentry *new_dentry,
69640 + const struct dentry *parent_dentry,
69641 + const struct vfsmount *parent_mnt,
69642 + const struct dentry *old_dentry,
69643 + const struct vfsmount *old_mnt);
69644 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69645 + const unsigned int namelen, const ino_t ino);
69646 +
69647 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69648 + const struct vfsmount *mnt);
69649 +void gr_acl_handle_exit(void);
69650 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69651 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69652 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69653 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69654 +void gr_audit_ptrace(struct task_struct *task);
69655 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69656 +void gr_put_exec_file(struct task_struct *task);
69657 +
69658 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69659 +
69660 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69661 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69662 + const unsigned long wanted, const int gt);
69663 +#else
69664 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69665 + const unsigned long wanted, const int gt)
69666 +{
69667 +}
69668 +#endif
69669 +
69670 +#ifdef CONFIG_GRKERNSEC_RESLOG
69671 +extern void gr_log_resource(const struct task_struct *task, const int res,
69672 + const unsigned long wanted, const int gt);
69673 +#else
69674 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69675 + const unsigned long wanted, const int gt)
69676 +{
69677 +}
69678 +#endif
69679 +
69680 +#ifdef CONFIG_GRKERNSEC
69681 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69682 +void gr_handle_vm86(void);
69683 +void gr_handle_mem_readwrite(u64 from, u64 to);
69684 +
69685 +void gr_log_badprocpid(const char *entry);
69686 +
69687 +extern int grsec_enable_dmesg;
69688 +extern int grsec_disable_privio;
69689 +
69690 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69691 +extern kgid_t grsec_proc_gid;
69692 +#endif
69693 +
69694 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69695 +extern int grsec_enable_chroot_findtask;
69696 +#endif
69697 +#ifdef CONFIG_GRKERNSEC_SETXID
69698 +extern int grsec_enable_setxid;
69699 +#endif
69700 +#endif
69701 +
69702 +#endif
69703 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69704 new file mode 100644
69705 index 0000000..e7ffaaf
69706 --- /dev/null
69707 +++ b/include/linux/grsock.h
69708 @@ -0,0 +1,19 @@
69709 +#ifndef __GRSOCK_H
69710 +#define __GRSOCK_H
69711 +
69712 +extern void gr_attach_curr_ip(const struct sock *sk);
69713 +extern int gr_handle_sock_all(const int family, const int type,
69714 + const int protocol);
69715 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69716 +extern int gr_handle_sock_server_other(const struct sock *sck);
69717 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69718 +extern int gr_search_connect(struct socket * sock,
69719 + struct sockaddr_in * addr);
69720 +extern int gr_search_bind(struct socket * sock,
69721 + struct sockaddr_in * addr);
69722 +extern int gr_search_listen(struct socket * sock);
69723 +extern int gr_search_accept(struct socket * sock);
69724 +extern int gr_search_socket(const int domain, const int type,
69725 + const int protocol);
69726 +
69727 +#endif
69728 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69729 index ef788b5..ac41b7b 100644
69730 --- a/include/linux/highmem.h
69731 +++ b/include/linux/highmem.h
69732 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69733 kunmap_atomic(kaddr);
69734 }
69735
69736 +static inline void sanitize_highpage(struct page *page)
69737 +{
69738 + void *kaddr;
69739 + unsigned long flags;
69740 +
69741 + local_irq_save(flags);
69742 + kaddr = kmap_atomic(page);
69743 + clear_page(kaddr);
69744 + kunmap_atomic(kaddr);
69745 + local_irq_restore(flags);
69746 +}
69747 +
69748 static inline void zero_user_segments(struct page *page,
69749 unsigned start1, unsigned end1,
69750 unsigned start2, unsigned end2)
69751 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69752 index 1c7b89a..7f52502 100644
69753 --- a/include/linux/hwmon-sysfs.h
69754 +++ b/include/linux/hwmon-sysfs.h
69755 @@ -25,7 +25,8 @@
69756 struct sensor_device_attribute{
69757 struct device_attribute dev_attr;
69758 int index;
69759 -};
69760 +} __do_const;
69761 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69762 #define to_sensor_dev_attr(_dev_attr) \
69763 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69764
69765 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69766 struct device_attribute dev_attr;
69767 u8 index;
69768 u8 nr;
69769 -};
69770 +} __do_const;
69771 #define to_sensor_dev_attr_2(_dev_attr) \
69772 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69773
69774 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69775 index d0c4db7..61b3577 100644
69776 --- a/include/linux/i2c.h
69777 +++ b/include/linux/i2c.h
69778 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69779 /* To determine what the adapter supports */
69780 u32 (*functionality) (struct i2c_adapter *);
69781 };
69782 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69783
69784 /*
69785 * i2c_adapter is the structure used to identify a physical i2c bus along
69786 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69787 index d23c3c2..eb63c81 100644
69788 --- a/include/linux/i2o.h
69789 +++ b/include/linux/i2o.h
69790 @@ -565,7 +565,7 @@ struct i2o_controller {
69791 struct i2o_device *exec; /* Executive */
69792 #if BITS_PER_LONG == 64
69793 spinlock_t context_list_lock; /* lock for context_list */
69794 - atomic_t context_list_counter; /* needed for unique contexts */
69795 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69796 struct list_head context_list; /* list of context id's
69797 and pointers */
69798 #endif
69799 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69800 index aff7ad8..3942bbd 100644
69801 --- a/include/linux/if_pppox.h
69802 +++ b/include/linux/if_pppox.h
69803 @@ -76,7 +76,7 @@ struct pppox_proto {
69804 int (*ioctl)(struct socket *sock, unsigned int cmd,
69805 unsigned long arg);
69806 struct module *owner;
69807 -};
69808 +} __do_const;
69809
69810 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69811 extern void unregister_pppox_proto(int proto_num);
69812 diff --git a/include/linux/init.h b/include/linux/init.h
69813 index 10ed4f4..8e8490d 100644
69814 --- a/include/linux/init.h
69815 +++ b/include/linux/init.h
69816 @@ -39,9 +39,36 @@
69817 * Also note, that this data cannot be "const".
69818 */
69819
69820 +#ifdef MODULE
69821 +#define add_init_latent_entropy
69822 +#define add_devinit_latent_entropy
69823 +#define add_cpuinit_latent_entropy
69824 +#define add_meminit_latent_entropy
69825 +#else
69826 +#define add_init_latent_entropy __latent_entropy
69827 +
69828 +#ifdef CONFIG_HOTPLUG
69829 +#define add_devinit_latent_entropy
69830 +#else
69831 +#define add_devinit_latent_entropy __latent_entropy
69832 +#endif
69833 +
69834 +#ifdef CONFIG_HOTPLUG_CPU
69835 +#define add_cpuinit_latent_entropy
69836 +#else
69837 +#define add_cpuinit_latent_entropy __latent_entropy
69838 +#endif
69839 +
69840 +#ifdef CONFIG_MEMORY_HOTPLUG
69841 +#define add_meminit_latent_entropy
69842 +#else
69843 +#define add_meminit_latent_entropy __latent_entropy
69844 +#endif
69845 +#endif
69846 +
69847 /* These are for everybody (although not all archs will actually
69848 discard it in modules) */
69849 -#define __init __section(.init.text) __cold notrace
69850 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69851 #define __initdata __section(.init.data)
69852 #define __initconst __constsection(.init.rodata)
69853 #define __exitdata __section(.exit.data)
69854 @@ -94,7 +121,7 @@
69855 #define __exit __section(.exit.text) __exitused __cold notrace
69856
69857 /* Used for HOTPLUG_CPU */
69858 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69859 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69860 #define __cpuinitdata __section(.cpuinit.data)
69861 #define __cpuinitconst __constsection(.cpuinit.rodata)
69862 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69863 @@ -102,7 +129,7 @@
69864 #define __cpuexitconst __constsection(.cpuexit.rodata)
69865
69866 /* Used for MEMORY_HOTPLUG */
69867 -#define __meminit __section(.meminit.text) __cold notrace
69868 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69869 #define __meminitdata __section(.meminit.data)
69870 #define __meminitconst __constsection(.meminit.rodata)
69871 #define __memexit __section(.memexit.text) __exitused __cold notrace
69872 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69873 index 6d087c5..401cab8 100644
69874 --- a/include/linux/init_task.h
69875 +++ b/include/linux/init_task.h
69876 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
69877
69878 #define INIT_TASK_COMM "swapper"
69879
69880 +#ifdef CONFIG_X86
69881 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69882 +#else
69883 +#define INIT_TASK_THREAD_INFO
69884 +#endif
69885 +
69886 /*
69887 * INIT_TASK is used to set up the first task table, touch at
69888 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69889 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
69890 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69891 .comm = INIT_TASK_COMM, \
69892 .thread = INIT_THREAD, \
69893 + INIT_TASK_THREAD_INFO \
69894 .fs = &init_fs, \
69895 .files = &init_files, \
69896 .signal = &init_signals, \
69897 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69898 index 5fa5afe..ac55b25 100644
69899 --- a/include/linux/interrupt.h
69900 +++ b/include/linux/interrupt.h
69901 @@ -430,7 +430,7 @@ enum
69902 /* map softirq index to softirq name. update 'softirq_to_name' in
69903 * kernel/softirq.c when adding a new softirq.
69904 */
69905 -extern char *softirq_to_name[NR_SOFTIRQS];
69906 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69907
69908 /* softirq mask and active fields moved to irq_cpustat_t in
69909 * asm/hardirq.h to get better cache usage. KAO
69910 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69911
69912 struct softirq_action
69913 {
69914 - void (*action)(struct softirq_action *);
69915 -};
69916 + void (*action)(void);
69917 +} __no_const;
69918
69919 asmlinkage void do_softirq(void);
69920 asmlinkage void __do_softirq(void);
69921 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69922 +extern void open_softirq(int nr, void (*action)(void));
69923 extern void softirq_init(void);
69924 extern void __raise_softirq_irqoff(unsigned int nr);
69925
69926 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69927 index f3b99e1..9b73cee 100644
69928 --- a/include/linux/iommu.h
69929 +++ b/include/linux/iommu.h
69930 @@ -101,7 +101,7 @@ struct iommu_ops {
69931 int (*domain_set_attr)(struct iommu_domain *domain,
69932 enum iommu_attr attr, void *data);
69933 unsigned long pgsize_bitmap;
69934 -};
69935 +} __do_const;
69936
69937 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69938 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69939 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
69940 index 85ac9b9b..e5759ab 100644
69941 --- a/include/linux/ioport.h
69942 +++ b/include/linux/ioport.h
69943 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
69944 int adjust_resource(struct resource *res, resource_size_t start,
69945 resource_size_t size);
69946 resource_size_t resource_alignment(struct resource *res);
69947 -static inline resource_size_t resource_size(const struct resource *res)
69948 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
69949 {
69950 return res->end - res->start + 1;
69951 }
69952 diff --git a/include/linux/irq.h b/include/linux/irq.h
69953 index fdf2c4a..5332486 100644
69954 --- a/include/linux/irq.h
69955 +++ b/include/linux/irq.h
69956 @@ -328,7 +328,8 @@ struct irq_chip {
69957 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69958
69959 unsigned long flags;
69960 -};
69961 +} __do_const;
69962 +typedef struct irq_chip __no_const irq_chip_no_const;
69963
69964 /*
69965 * irq_chip specific flags
69966 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69967 index 6883e19..06992b1 100644
69968 --- a/include/linux/kallsyms.h
69969 +++ b/include/linux/kallsyms.h
69970 @@ -15,7 +15,8 @@
69971
69972 struct module;
69973
69974 -#ifdef CONFIG_KALLSYMS
69975 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69976 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69977 /* Lookup the address for a symbol. Returns 0 if not found. */
69978 unsigned long kallsyms_lookup_name(const char *name);
69979
69980 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69981 /* Stupid that this does nothing, but I didn't create this mess. */
69982 #define __print_symbol(fmt, addr)
69983 #endif /*CONFIG_KALLSYMS*/
69984 +#else /* when included by kallsyms.c, vsnprintf.c, or
69985 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69986 +extern void __print_symbol(const char *fmt, unsigned long address);
69987 +extern int sprint_backtrace(char *buffer, unsigned long address);
69988 +extern int sprint_symbol(char *buffer, unsigned long address);
69989 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69990 +const char *kallsyms_lookup(unsigned long addr,
69991 + unsigned long *symbolsize,
69992 + unsigned long *offset,
69993 + char **modname, char *namebuf);
69994 +#endif
69995
69996 /* This macro allows us to keep printk typechecking */
69997 static __printf(1, 2)
69998 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69999 index 518a53a..5e28358 100644
70000 --- a/include/linux/key-type.h
70001 +++ b/include/linux/key-type.h
70002 @@ -125,7 +125,7 @@ struct key_type {
70003 /* internal fields */
70004 struct list_head link; /* link in types list */
70005 struct lock_class_key lock_class; /* key->sem lock class */
70006 -};
70007 +} __do_const;
70008
70009 extern struct key_type key_type_keyring;
70010
70011 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
70012 index 4dff0c6..1ca9b72 100644
70013 --- a/include/linux/kgdb.h
70014 +++ b/include/linux/kgdb.h
70015 @@ -53,7 +53,7 @@ extern int kgdb_connected;
70016 extern int kgdb_io_module_registered;
70017
70018 extern atomic_t kgdb_setting_breakpoint;
70019 -extern atomic_t kgdb_cpu_doing_single_step;
70020 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70021
70022 extern struct task_struct *kgdb_usethread;
70023 extern struct task_struct *kgdb_contthread;
70024 @@ -255,7 +255,7 @@ struct kgdb_arch {
70025 void (*correct_hw_break)(void);
70026
70027 void (*enable_nmi)(bool on);
70028 -};
70029 +} __do_const;
70030
70031 /**
70032 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
70033 @@ -280,7 +280,7 @@ struct kgdb_io {
70034 void (*pre_exception) (void);
70035 void (*post_exception) (void);
70036 int is_console;
70037 -};
70038 +} __do_const;
70039
70040 extern struct kgdb_arch arch_kgdb_ops;
70041
70042 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70043 index 5398d58..5883a34 100644
70044 --- a/include/linux/kmod.h
70045 +++ b/include/linux/kmod.h
70046 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70047 * usually useless though. */
70048 extern __printf(2, 3)
70049 int __request_module(bool wait, const char *name, ...);
70050 +extern __printf(3, 4)
70051 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70052 #define request_module(mod...) __request_module(true, mod)
70053 #define request_module_nowait(mod...) __request_module(false, mod)
70054 #define try_then_request_module(x, mod...) \
70055 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70056 index 939b112..ed6ed51 100644
70057 --- a/include/linux/kobject.h
70058 +++ b/include/linux/kobject.h
70059 @@ -111,7 +111,7 @@ struct kobj_type {
70060 struct attribute **default_attrs;
70061 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70062 const void *(*namespace)(struct kobject *kobj);
70063 -};
70064 +} __do_const;
70065
70066 struct kobj_uevent_env {
70067 char *envp[UEVENT_NUM_ENVP];
70068 @@ -134,6 +134,7 @@ struct kobj_attribute {
70069 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70070 const char *buf, size_t count);
70071 };
70072 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70073
70074 extern const struct sysfs_ops kobj_sysfs_ops;
70075
70076 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70077 index f66b065..c2c29b4 100644
70078 --- a/include/linux/kobject_ns.h
70079 +++ b/include/linux/kobject_ns.h
70080 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70081 const void *(*netlink_ns)(struct sock *sk);
70082 const void *(*initial_ns)(void);
70083 void (*drop_ns)(void *);
70084 -};
70085 +} __do_const;
70086
70087 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70088 int kobj_ns_type_registered(enum kobj_ns_type type);
70089 diff --git a/include/linux/kref.h b/include/linux/kref.h
70090 index 4972e6e..de4d19b 100644
70091 --- a/include/linux/kref.h
70092 +++ b/include/linux/kref.h
70093 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
70094 static inline int kref_sub(struct kref *kref, unsigned int count,
70095 void (*release)(struct kref *kref))
70096 {
70097 - WARN_ON(release == NULL);
70098 + BUG_ON(release == NULL);
70099
70100 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70101 release(kref);
70102 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70103 index ffdf8b7..1f91d0e 100644
70104 --- a/include/linux/kvm_host.h
70105 +++ b/include/linux/kvm_host.h
70106 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
70107 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
70108 void vcpu_put(struct kvm_vcpu *vcpu);
70109
70110 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70111 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70112 struct module *module);
70113 void kvm_exit(void);
70114
70115 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70116 struct kvm_guest_debug *dbg);
70117 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70118
70119 -int kvm_arch_init(void *opaque);
70120 +int kvm_arch_init(const void *opaque);
70121 void kvm_arch_exit(void);
70122
70123 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70124 diff --git a/include/linux/libata.h b/include/linux/libata.h
70125 index 0621bca..24d6851 100644
70126 --- a/include/linux/libata.h
70127 +++ b/include/linux/libata.h
70128 @@ -916,7 +916,7 @@ struct ata_port_operations {
70129 * fields must be pointers.
70130 */
70131 const struct ata_port_operations *inherits;
70132 -};
70133 +} __do_const;
70134
70135 struct ata_port_info {
70136 unsigned long flags;
70137 diff --git a/include/linux/list.h b/include/linux/list.h
70138 index cc6d2aa..c10ee83 100644
70139 --- a/include/linux/list.h
70140 +++ b/include/linux/list.h
70141 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70142 extern void list_del(struct list_head *entry);
70143 #endif
70144
70145 +extern void __pax_list_add(struct list_head *new,
70146 + struct list_head *prev,
70147 + struct list_head *next);
70148 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70149 +{
70150 + __pax_list_add(new, head, head->next);
70151 +}
70152 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70153 +{
70154 + __pax_list_add(new, head->prev, head);
70155 +}
70156 +extern void pax_list_del(struct list_head *entry);
70157 +
70158 /**
70159 * list_replace - replace old entry by new one
70160 * @old : the element to be replaced
70161 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70162 INIT_LIST_HEAD(entry);
70163 }
70164
70165 +extern void pax_list_del_init(struct list_head *entry);
70166 +
70167 /**
70168 * list_move - delete from one list and add as another's head
70169 * @list: the entry to move
70170 diff --git a/include/linux/math64.h b/include/linux/math64.h
70171 index b8ba855..0148090 100644
70172 --- a/include/linux/math64.h
70173 +++ b/include/linux/math64.h
70174 @@ -14,7 +14,7 @@
70175 * This is commonly provided by 32bit archs to provide an optimized 64bit
70176 * divide.
70177 */
70178 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70179 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70180 {
70181 *remainder = dividend % divisor;
70182 return dividend / divisor;
70183 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70184 #define div64_long(x,y) div_s64((x),(y))
70185
70186 #ifndef div_u64_rem
70187 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70188 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70189 {
70190 *remainder = do_div(dividend, divisor);
70191 return dividend;
70192 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70193 * divide.
70194 */
70195 #ifndef div_u64
70196 -static inline u64 div_u64(u64 dividend, u32 divisor)
70197 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70198 {
70199 u32 remainder;
70200 return div_u64_rem(dividend, divisor, &remainder);
70201 diff --git a/include/linux/mm.h b/include/linux/mm.h
70202 index 9568b90..6cc79f9 100644
70203 --- a/include/linux/mm.h
70204 +++ b/include/linux/mm.h
70205 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
70206 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70207 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70208 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70209 +
70210 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70211 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70212 +#endif
70213 +
70214 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70215
70216 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70217 @@ -200,8 +205,8 @@ struct vm_operations_struct {
70218 /* called by access_process_vm when get_user_pages() fails, typically
70219 * for use by special VMAs that can switch between memory and hardware
70220 */
70221 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70222 - void *buf, int len, int write);
70223 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70224 + void *buf, size_t len, int write);
70225 #ifdef CONFIG_NUMA
70226 /*
70227 * set_policy() op must add a reference to any non-NULL @new mempolicy
70228 @@ -231,6 +236,7 @@ struct vm_operations_struct {
70229 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70230 unsigned long size, pgoff_t pgoff);
70231 };
70232 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70233
70234 struct mmu_gather;
70235 struct inode;
70236 @@ -995,8 +1001,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70237 unsigned long *pfn);
70238 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70239 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70240 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70241 - void *buf, int len, int write);
70242 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70243 + void *buf, size_t len, int write);
70244
70245 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70246 loff_t const holebegin, loff_t const holelen)
70247 @@ -1035,10 +1041,10 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70248 }
70249 #endif
70250
70251 -extern int make_pages_present(unsigned long addr, unsigned long end);
70252 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70253 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70254 - void *buf, int len, int write);
70255 +extern ssize_t make_pages_present(unsigned long addr, unsigned long end);
70256 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70257 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70258 + void *buf, size_t len, int write);
70259
70260 int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70261 unsigned long start, int len, unsigned int foll_flags,
70262 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
70263 int set_page_dirty_lock(struct page *page);
70264 int clear_page_dirty_for_io(struct page *page);
70265
70266 -/* Is the vma a continuation of the stack vma above it? */
70267 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70268 -{
70269 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70270 -}
70271 -
70272 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70273 - unsigned long addr)
70274 -{
70275 - return (vma->vm_flags & VM_GROWSDOWN) &&
70276 - (vma->vm_start == addr) &&
70277 - !vma_growsdown(vma->vm_prev, addr);
70278 -}
70279 -
70280 -/* Is the vma a continuation of the stack vma below it? */
70281 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70282 -{
70283 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70284 -}
70285 -
70286 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70287 - unsigned long addr)
70288 -{
70289 - return (vma->vm_flags & VM_GROWSUP) &&
70290 - (vma->vm_end == addr) &&
70291 - !vma_growsup(vma->vm_next, addr);
70292 -}
70293 -
70294 extern pid_t
70295 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70296
70297 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70298 }
70299 #endif
70300
70301 +#ifdef CONFIG_MMU
70302 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70303 +#else
70304 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70305 +{
70306 + return __pgprot(0);
70307 +}
70308 +#endif
70309 +
70310 int vma_wants_writenotify(struct vm_area_struct *vma);
70311
70312 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70313 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70314 {
70315 return 0;
70316 }
70317 +
70318 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70319 + unsigned long address)
70320 +{
70321 + return 0;
70322 +}
70323 #else
70324 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70325 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70326 #endif
70327
70328 #ifdef __PAGETABLE_PMD_FOLDED
70329 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70330 {
70331 return 0;
70332 }
70333 +
70334 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70335 + unsigned long address)
70336 +{
70337 + return 0;
70338 +}
70339 #else
70340 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70341 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70342 #endif
70343
70344 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70345 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70346 NULL: pud_offset(pgd, address);
70347 }
70348
70349 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70350 +{
70351 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70352 + NULL: pud_offset(pgd, address);
70353 +}
70354 +
70355 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70356 {
70357 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70358 NULL: pmd_offset(pud, address);
70359 }
70360 +
70361 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70362 +{
70363 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70364 + NULL: pmd_offset(pud, address);
70365 +}
70366 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70367
70368 #if USE_SPLIT_PTLOCKS
70369 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
70370 unsigned long, unsigned long,
70371 unsigned long, unsigned long);
70372 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70373 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70374
70375 /* These take the mm semaphore themselves */
70376 extern unsigned long vm_brk(unsigned long, unsigned long);
70377 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70378 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70379 struct vm_area_struct **pprev);
70380
70381 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70382 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70383 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70384 +
70385 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70386 NULL if none. Assume start_addr < end_addr. */
70387 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70388 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70389 return vma;
70390 }
70391
70392 -#ifdef CONFIG_MMU
70393 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70394 -#else
70395 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70396 -{
70397 - return __pgprot(0);
70398 -}
70399 -#endif
70400 -
70401 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70402 unsigned long change_prot_numa(struct vm_area_struct *vma,
70403 unsigned long start, unsigned long end);
70404 @@ -1651,6 +1660,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70405 static inline void vm_stat_account(struct mm_struct *mm,
70406 unsigned long flags, struct file *file, long pages)
70407 {
70408 +
70409 +#ifdef CONFIG_PAX_RANDMMAP
70410 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70411 +#endif
70412 +
70413 mm->total_vm += pages;
70414 }
70415 #endif /* CONFIG_PROC_FS */
70416 @@ -1723,7 +1737,7 @@ extern int unpoison_memory(unsigned long pfn);
70417 extern int sysctl_memory_failure_early_kill;
70418 extern int sysctl_memory_failure_recovery;
70419 extern void shake_page(struct page *p, int access);
70420 -extern atomic_long_t mce_bad_pages;
70421 +extern atomic_long_unchecked_t mce_bad_pages;
70422 extern int soft_offline_page(struct page *page, int flags);
70423
70424 extern void dump_page(struct page *page);
70425 @@ -1754,5 +1768,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70426 static inline bool page_is_guard(struct page *page) { return false; }
70427 #endif /* CONFIG_DEBUG_PAGEALLOC */
70428
70429 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70430 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70431 +#else
70432 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70433 +#endif
70434 +
70435 #endif /* __KERNEL__ */
70436 #endif /* _LINUX_MM_H */
70437 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70438 index f8f5162..3aaf20f 100644
70439 --- a/include/linux/mm_types.h
70440 +++ b/include/linux/mm_types.h
70441 @@ -288,6 +288,8 @@ struct vm_area_struct {
70442 #ifdef CONFIG_NUMA
70443 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70444 #endif
70445 +
70446 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70447 };
70448
70449 struct core_thread {
70450 @@ -436,6 +438,24 @@ struct mm_struct {
70451 int first_nid;
70452 #endif
70453 struct uprobes_state uprobes_state;
70454 +
70455 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70456 + unsigned long pax_flags;
70457 +#endif
70458 +
70459 +#ifdef CONFIG_PAX_DLRESOLVE
70460 + unsigned long call_dl_resolve;
70461 +#endif
70462 +
70463 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70464 + unsigned long call_syscall;
70465 +#endif
70466 +
70467 +#ifdef CONFIG_PAX_ASLR
70468 + unsigned long delta_mmap; /* randomized offset */
70469 + unsigned long delta_stack; /* randomized offset */
70470 +#endif
70471 +
70472 };
70473
70474 /* first nid will either be a valid NID or one of these values */
70475 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70476 index c5d5278..f0b68c8 100644
70477 --- a/include/linux/mmiotrace.h
70478 +++ b/include/linux/mmiotrace.h
70479 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70480 /* Called from ioremap.c */
70481 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70482 void __iomem *addr);
70483 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70484 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70485
70486 /* For anyone to insert markers. Remember trailing newline. */
70487 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70488 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70489 {
70490 }
70491
70492 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70493 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70494 {
70495 }
70496
70497 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70498 index 73b64a3..6562925 100644
70499 --- a/include/linux/mmzone.h
70500 +++ b/include/linux/mmzone.h
70501 @@ -412,7 +412,7 @@ struct zone {
70502 unsigned long flags; /* zone flags, see below */
70503
70504 /* Zone statistics */
70505 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70506 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70507
70508 /*
70509 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70510 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70511 index fed3def..c933f99 100644
70512 --- a/include/linux/mod_devicetable.h
70513 +++ b/include/linux/mod_devicetable.h
70514 @@ -12,7 +12,7 @@
70515 typedef unsigned long kernel_ulong_t;
70516 #endif
70517
70518 -#define PCI_ANY_ID (~0)
70519 +#define PCI_ANY_ID ((__u16)~0)
70520
70521 struct pci_device_id {
70522 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70523 @@ -139,7 +139,7 @@ struct usb_device_id {
70524 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70525 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70526
70527 -#define HID_ANY_ID (~0)
70528 +#define HID_ANY_ID (~0U)
70529 #define HID_BUS_ANY 0xffff
70530 #define HID_GROUP_ANY 0x0000
70531
70532 @@ -498,7 +498,7 @@ struct dmi_system_id {
70533 const char *ident;
70534 struct dmi_strmatch matches[4];
70535 void *driver_data;
70536 -};
70537 +} __do_const;
70538 /*
70539 * struct dmi_device_id appears during expansion of
70540 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70541 diff --git a/include/linux/module.h b/include/linux/module.h
70542 index 1375ee3..ced8177 100644
70543 --- a/include/linux/module.h
70544 +++ b/include/linux/module.h
70545 @@ -17,9 +17,11 @@
70546 #include <linux/moduleparam.h>
70547 #include <linux/tracepoint.h>
70548 #include <linux/export.h>
70549 +#include <linux/fs.h>
70550
70551 #include <linux/percpu.h>
70552 #include <asm/module.h>
70553 +#include <asm/pgtable.h>
70554
70555 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70556 #define MODULE_SIG_STRING "~Module signature appended~\n"
70557 @@ -54,12 +56,13 @@ struct module_attribute {
70558 int (*test)(struct module *);
70559 void (*free)(struct module *);
70560 };
70561 +typedef struct module_attribute __no_const module_attribute_no_const;
70562
70563 struct module_version_attribute {
70564 struct module_attribute mattr;
70565 const char *module_name;
70566 const char *version;
70567 -} __attribute__ ((__aligned__(sizeof(void *))));
70568 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70569
70570 extern ssize_t __modver_version_show(struct module_attribute *,
70571 struct module_kobject *, char *);
70572 @@ -232,7 +235,7 @@ struct module
70573
70574 /* Sysfs stuff. */
70575 struct module_kobject mkobj;
70576 - struct module_attribute *modinfo_attrs;
70577 + module_attribute_no_const *modinfo_attrs;
70578 const char *version;
70579 const char *srcversion;
70580 struct kobject *holders_dir;
70581 @@ -281,19 +284,16 @@ struct module
70582 int (*init)(void);
70583
70584 /* If this is non-NULL, vfree after init() returns */
70585 - void *module_init;
70586 + void *module_init_rx, *module_init_rw;
70587
70588 /* Here is the actual code + data, vfree'd on unload. */
70589 - void *module_core;
70590 + void *module_core_rx, *module_core_rw;
70591
70592 /* Here are the sizes of the init and core sections */
70593 - unsigned int init_size, core_size;
70594 + unsigned int init_size_rw, core_size_rw;
70595
70596 /* The size of the executable code in each section. */
70597 - unsigned int init_text_size, core_text_size;
70598 -
70599 - /* Size of RO sections of the module (text+rodata) */
70600 - unsigned int init_ro_size, core_ro_size;
70601 + unsigned int init_size_rx, core_size_rx;
70602
70603 /* Arch-specific module values */
70604 struct mod_arch_specific arch;
70605 @@ -349,6 +349,10 @@ struct module
70606 #ifdef CONFIG_EVENT_TRACING
70607 struct ftrace_event_call **trace_events;
70608 unsigned int num_trace_events;
70609 + struct file_operations trace_id;
70610 + struct file_operations trace_enable;
70611 + struct file_operations trace_format;
70612 + struct file_operations trace_filter;
70613 #endif
70614 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70615 unsigned int num_ftrace_callsites;
70616 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70617 bool is_module_percpu_address(unsigned long addr);
70618 bool is_module_text_address(unsigned long addr);
70619
70620 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70621 +{
70622 +
70623 +#ifdef CONFIG_PAX_KERNEXEC
70624 + if (ktla_ktva(addr) >= (unsigned long)start &&
70625 + ktla_ktva(addr) < (unsigned long)start + size)
70626 + return 1;
70627 +#endif
70628 +
70629 + return ((void *)addr >= start && (void *)addr < start + size);
70630 +}
70631 +
70632 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
70633 +{
70634 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70635 +}
70636 +
70637 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
70638 +{
70639 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70640 +}
70641 +
70642 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
70643 +{
70644 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70645 +}
70646 +
70647 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
70648 +{
70649 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70650 +}
70651 +
70652 static inline int within_module_core(unsigned long addr, struct module *mod)
70653 {
70654 - return (unsigned long)mod->module_core <= addr &&
70655 - addr < (unsigned long)mod->module_core + mod->core_size;
70656 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70657 }
70658
70659 static inline int within_module_init(unsigned long addr, struct module *mod)
70660 {
70661 - return (unsigned long)mod->module_init <= addr &&
70662 - addr < (unsigned long)mod->module_init + mod->init_size;
70663 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70664 }
70665
70666 /* Search for module by name: must hold module_mutex. */
70667 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70668 index 560ca53..ef621ef 100644
70669 --- a/include/linux/moduleloader.h
70670 +++ b/include/linux/moduleloader.h
70671 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70672 sections. Returns NULL on failure. */
70673 void *module_alloc(unsigned long size);
70674
70675 +#ifdef CONFIG_PAX_KERNEXEC
70676 +void *module_alloc_exec(unsigned long size);
70677 +#else
70678 +#define module_alloc_exec(x) module_alloc(x)
70679 +#endif
70680 +
70681 /* Free memory returned from module_alloc. */
70682 void module_free(struct module *mod, void *module_region);
70683
70684 +#ifdef CONFIG_PAX_KERNEXEC
70685 +void module_free_exec(struct module *mod, void *module_region);
70686 +#else
70687 +#define module_free_exec(x, y) module_free((x), (y))
70688 +#endif
70689 +
70690 /*
70691 * Apply the given relocation to the (simplified) ELF. Return -error
70692 * or 0.
70693 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70694 unsigned int relsec,
70695 struct module *me)
70696 {
70697 +#ifdef CONFIG_MODULES
70698 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70699 +#endif
70700 return -ENOEXEC;
70701 }
70702 #endif
70703 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70704 unsigned int relsec,
70705 struct module *me)
70706 {
70707 +#ifdef CONFIG_MODULES
70708 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70709 +#endif
70710 return -ENOEXEC;
70711 }
70712 #endif
70713 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70714 index 137b419..fe663ec 100644
70715 --- a/include/linux/moduleparam.h
70716 +++ b/include/linux/moduleparam.h
70717 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70718 * @len is usually just sizeof(string).
70719 */
70720 #define module_param_string(name, string, len, perm) \
70721 - static const struct kparam_string __param_string_##name \
70722 + static const struct kparam_string __param_string_##name __used \
70723 = { len, string }; \
70724 __module_param_call(MODULE_PARAM_PREFIX, name, \
70725 &param_ops_string, \
70726 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70727 */
70728 #define module_param_array_named(name, array, type, nump, perm) \
70729 param_check_##type(name, &(array)[0]); \
70730 - static const struct kparam_array __param_arr_##name \
70731 + static const struct kparam_array __param_arr_##name __used \
70732 = { .max = ARRAY_SIZE(array), .num = nump, \
70733 .ops = &param_ops_##type, \
70734 .elemsize = sizeof(array[0]), .elem = array }; \
70735 diff --git a/include/linux/namei.h b/include/linux/namei.h
70736 index 5a5ff57..5ae5070 100644
70737 --- a/include/linux/namei.h
70738 +++ b/include/linux/namei.h
70739 @@ -19,7 +19,7 @@ struct nameidata {
70740 unsigned seq;
70741 int last_type;
70742 unsigned depth;
70743 - char *saved_names[MAX_NESTED_LINKS + 1];
70744 + const char *saved_names[MAX_NESTED_LINKS + 1];
70745 };
70746
70747 /*
70748 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70749
70750 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70751
70752 -static inline void nd_set_link(struct nameidata *nd, char *path)
70753 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70754 {
70755 nd->saved_names[nd->depth] = path;
70756 }
70757
70758 -static inline char *nd_get_link(struct nameidata *nd)
70759 +static inline const char *nd_get_link(const struct nameidata *nd)
70760 {
70761 return nd->saved_names[nd->depth];
70762 }
70763 diff --git a/include/linux/net.h b/include/linux/net.h
70764 index aa16731..514b875 100644
70765 --- a/include/linux/net.h
70766 +++ b/include/linux/net.h
70767 @@ -183,7 +183,7 @@ struct net_proto_family {
70768 int (*create)(struct net *net, struct socket *sock,
70769 int protocol, int kern);
70770 struct module *owner;
70771 -};
70772 +} __do_const;
70773
70774 struct iovec;
70775 struct kvec;
70776 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70777 index 0e182f9..bd5d452 100644
70778 --- a/include/linux/netdevice.h
70779 +++ b/include/linux/netdevice.h
70780 @@ -1012,6 +1012,7 @@ struct net_device_ops {
70781 u32 pid, u32 seq,
70782 struct net_device *dev);
70783 };
70784 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70785
70786 /*
70787 * The DEVICE structure.
70788 @@ -1078,7 +1079,7 @@ struct net_device {
70789 int iflink;
70790
70791 struct net_device_stats stats;
70792 - atomic_long_t rx_dropped; /* dropped packets by core network
70793 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70794 * Do not use this in drivers.
70795 */
70796
70797 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70798 index ee14284..bc65d63 100644
70799 --- a/include/linux/netfilter.h
70800 +++ b/include/linux/netfilter.h
70801 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70802 #endif
70803 /* Use the module struct to lock set/get code in place */
70804 struct module *owner;
70805 -};
70806 +} __do_const;
70807
70808 /* Function to register/unregister hook points. */
70809 int nf_register_hook(struct nf_hook_ops *reg);
70810 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70811 index 7958e84..ed74d7a 100644
70812 --- a/include/linux/netfilter/ipset/ip_set.h
70813 +++ b/include/linux/netfilter/ipset/ip_set.h
70814 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70815 /* Return true if "b" set is the same as "a"
70816 * according to the create set parameters */
70817 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70818 -};
70819 +} __do_const;
70820
70821 /* The core set type structure */
70822 struct ip_set_type {
70823 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70824 index 4966dde..7d8ce06 100644
70825 --- a/include/linux/netfilter/nfnetlink.h
70826 +++ b/include/linux/netfilter/nfnetlink.h
70827 @@ -16,7 +16,7 @@ struct nfnl_callback {
70828 const struct nlattr * const cda[]);
70829 const struct nla_policy *policy; /* netlink attribute policy */
70830 const u_int16_t attr_count; /* number of nlattr's */
70831 -};
70832 +} __do_const;
70833
70834 struct nfnetlink_subsystem {
70835 const char *name;
70836 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70837 new file mode 100644
70838 index 0000000..33f4af8
70839 --- /dev/null
70840 +++ b/include/linux/netfilter/xt_gradm.h
70841 @@ -0,0 +1,9 @@
70842 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70843 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70844 +
70845 +struct xt_gradm_mtinfo {
70846 + __u16 flags;
70847 + __u16 invflags;
70848 +};
70849 +
70850 +#endif
70851 diff --git a/include/linux/nls.h b/include/linux/nls.h
70852 index 5dc635f..35f5e11 100644
70853 --- a/include/linux/nls.h
70854 +++ b/include/linux/nls.h
70855 @@ -31,7 +31,7 @@ struct nls_table {
70856 const unsigned char *charset2upper;
70857 struct module *owner;
70858 struct nls_table *next;
70859 -};
70860 +} __do_const;
70861
70862 /* this value hold the maximum octet of charset */
70863 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70864 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70865 index d65746e..62e72c2 100644
70866 --- a/include/linux/notifier.h
70867 +++ b/include/linux/notifier.h
70868 @@ -51,7 +51,8 @@ struct notifier_block {
70869 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70870 struct notifier_block __rcu *next;
70871 int priority;
70872 -};
70873 +} __do_const;
70874 +typedef struct notifier_block __no_const notifier_block_no_const;
70875
70876 struct atomic_notifier_head {
70877 spinlock_t lock;
70878 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70879 index a4c5624..79d6d88 100644
70880 --- a/include/linux/oprofile.h
70881 +++ b/include/linux/oprofile.h
70882 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70883 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70884 char const * name, ulong * val);
70885
70886 -/** Create a file for read-only access to an atomic_t. */
70887 +/** Create a file for read-only access to an atomic_unchecked_t. */
70888 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70889 - char const * name, atomic_t * val);
70890 + char const * name, atomic_unchecked_t * val);
70891
70892 /** create a directory */
70893 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70894 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70895 index 45fc162..01a4068 100644
70896 --- a/include/linux/pci_hotplug.h
70897 +++ b/include/linux/pci_hotplug.h
70898 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70899 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70900 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70901 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70902 -};
70903 +} __do_const;
70904 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70905
70906 /**
70907 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70908 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70909 index a280650..2b67b91 100644
70910 --- a/include/linux/perf_event.h
70911 +++ b/include/linux/perf_event.h
70912 @@ -328,8 +328,8 @@ struct perf_event {
70913
70914 enum perf_event_active_state state;
70915 unsigned int attach_state;
70916 - local64_t count;
70917 - atomic64_t child_count;
70918 + local64_t count; /* PaX: fix it one day */
70919 + atomic64_unchecked_t child_count;
70920
70921 /*
70922 * These are the total time in nanoseconds that the event
70923 @@ -380,8 +380,8 @@ struct perf_event {
70924 * These accumulate total time (in nanoseconds) that children
70925 * events have been enabled and running, respectively.
70926 */
70927 - atomic64_t child_total_time_enabled;
70928 - atomic64_t child_total_time_running;
70929 + atomic64_unchecked_t child_total_time_enabled;
70930 + atomic64_unchecked_t child_total_time_running;
70931
70932 /*
70933 * Protect attach/detach and child_list:
70934 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
70935 */
70936 #define perf_cpu_notifier(fn) \
70937 do { \
70938 - static struct notifier_block fn##_nb __cpuinitdata = \
70939 + static struct notifier_block fn##_nb = \
70940 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70941 unsigned long cpu = smp_processor_id(); \
70942 unsigned long flags; \
70943 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70944 index ad1a427..6419649 100644
70945 --- a/include/linux/pipe_fs_i.h
70946 +++ b/include/linux/pipe_fs_i.h
70947 @@ -45,9 +45,9 @@ struct pipe_buffer {
70948 struct pipe_inode_info {
70949 wait_queue_head_t wait;
70950 unsigned int nrbufs, curbuf, buffers;
70951 - unsigned int readers;
70952 - unsigned int writers;
70953 - unsigned int waiting_writers;
70954 + atomic_t readers;
70955 + atomic_t writers;
70956 + atomic_t waiting_writers;
70957 unsigned int r_counter;
70958 unsigned int w_counter;
70959 struct page *tmp_page;
70960 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70961 index 5f28cae..3d23723 100644
70962 --- a/include/linux/platform_data/usb-ehci-s5p.h
70963 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70964 @@ -14,7 +14,7 @@
70965 struct s5p_ehci_platdata {
70966 int (*phy_init)(struct platform_device *pdev, int type);
70967 int (*phy_exit)(struct platform_device *pdev, int type);
70968 -};
70969 +} __no_const;
70970
70971 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70972
70973 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70974 index c256c59..8ea94c7 100644
70975 --- a/include/linux/platform_data/usb-exynos.h
70976 +++ b/include/linux/platform_data/usb-exynos.h
70977 @@ -14,7 +14,7 @@
70978 struct exynos4_ohci_platdata {
70979 int (*phy_init)(struct platform_device *pdev, int type);
70980 int (*phy_exit)(struct platform_device *pdev, int type);
70981 -};
70982 +} __no_const;
70983
70984 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70985
70986 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70987 index 7c1d252..c5c773e 100644
70988 --- a/include/linux/pm_domain.h
70989 +++ b/include/linux/pm_domain.h
70990 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70991
70992 struct gpd_cpu_data {
70993 unsigned int saved_exit_latency;
70994 - struct cpuidle_state *idle_state;
70995 + cpuidle_state_no_const *idle_state;
70996 };
70997
70998 struct generic_pm_domain {
70999 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
71000 index f271860..6b3bec5 100644
71001 --- a/include/linux/pm_runtime.h
71002 +++ b/include/linux/pm_runtime.h
71003 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
71004
71005 static inline void pm_runtime_mark_last_busy(struct device *dev)
71006 {
71007 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
71008 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
71009 }
71010
71011 #else /* !CONFIG_PM_RUNTIME */
71012 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
71013 index 195aafc..49a7bc2 100644
71014 --- a/include/linux/pnp.h
71015 +++ b/include/linux/pnp.h
71016 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
71017 struct pnp_fixup {
71018 char id[7];
71019 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
71020 -};
71021 +} __do_const;
71022
71023 /* config parameters */
71024 #define PNP_CONFIG_NORMAL 0x0001
71025 diff --git a/include/linux/poison.h b/include/linux/poison.h
71026 index 2110a81..13a11bb 100644
71027 --- a/include/linux/poison.h
71028 +++ b/include/linux/poison.h
71029 @@ -19,8 +19,8 @@
71030 * under normal circumstances, used to verify that nobody uses
71031 * non-initialized list entries.
71032 */
71033 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
71034 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
71035 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
71036 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
71037
71038 /********** include/linux/timer.h **********/
71039 /*
71040 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71041 index c0f44c2..1572583 100644
71042 --- a/include/linux/power/smartreflex.h
71043 +++ b/include/linux/power/smartreflex.h
71044 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71045 int (*notify)(struct omap_sr *sr, u32 status);
71046 u8 notify_flags;
71047 u8 class_type;
71048 -};
71049 +} __do_const;
71050
71051 /**
71052 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71053 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71054 index 4ea1d37..80f4b33 100644
71055 --- a/include/linux/ppp-comp.h
71056 +++ b/include/linux/ppp-comp.h
71057 @@ -84,7 +84,7 @@ struct compressor {
71058 struct module *owner;
71059 /* Extra skb space needed by the compressor algorithm */
71060 unsigned int comp_extra;
71061 -};
71062 +} __do_const;
71063
71064 /*
71065 * The return value from decompress routine is the length of the
71066 diff --git a/include/linux/printk.h b/include/linux/printk.h
71067 index 9afc01e..92c32e8 100644
71068 --- a/include/linux/printk.h
71069 +++ b/include/linux/printk.h
71070 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
71071 extern int printk_needs_cpu(int cpu);
71072 extern void printk_tick(void);
71073
71074 +extern int kptr_restrict;
71075 +
71076 #ifdef CONFIG_PRINTK
71077 asmlinkage __printf(5, 0)
71078 int vprintk_emit(int facility, int level,
71079 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71080
71081 extern int printk_delay_msec;
71082 extern int dmesg_restrict;
71083 -extern int kptr_restrict;
71084
71085 void log_buf_kexec_setup(void);
71086 void __init setup_log_buf(int early);
71087 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71088 index 32676b3..e46f2c0 100644
71089 --- a/include/linux/proc_fs.h
71090 +++ b/include/linux/proc_fs.h
71091 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
71092 return proc_create_data(name, mode, parent, proc_fops, NULL);
71093 }
71094
71095 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71096 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71097 +{
71098 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71099 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71100 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71101 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71102 +#else
71103 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71104 +#endif
71105 +}
71106 +
71107 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
71108 umode_t mode, struct proc_dir_entry *base,
71109 read_proc_t *read_proc, void * data)
71110 @@ -268,7 +280,7 @@ struct proc_ns_operations {
71111 void (*put)(void *ns);
71112 int (*install)(struct nsproxy *nsproxy, void *ns);
71113 unsigned int (*inum)(void *ns);
71114 -};
71115 +} __do_const;
71116 extern const struct proc_ns_operations netns_operations;
71117 extern const struct proc_ns_operations utsns_operations;
71118 extern const struct proc_ns_operations ipcns_operations;
71119 diff --git a/include/linux/random.h b/include/linux/random.h
71120 index d984608..d6f0042 100644
71121 --- a/include/linux/random.h
71122 +++ b/include/linux/random.h
71123 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
71124 u32 prandom_u32_state(struct rnd_state *);
71125 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71126
71127 +static inline unsigned long pax_get_random_long(void)
71128 +{
71129 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71130 +}
71131 +
71132 /*
71133 * Handle minimum values for seeds
71134 */
71135 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71136 index c92dd28..08f4eab 100644
71137 --- a/include/linux/rculist.h
71138 +++ b/include/linux/rculist.h
71139 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71140 struct list_head *prev, struct list_head *next);
71141 #endif
71142
71143 +extern void __pax_list_add_rcu(struct list_head *new,
71144 + struct list_head *prev, struct list_head *next);
71145 +
71146 /**
71147 * list_add_rcu - add a new entry to rcu-protected list
71148 * @new: new entry to be added
71149 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71150 __list_add_rcu(new, head, head->next);
71151 }
71152
71153 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71154 +{
71155 + __pax_list_add_rcu(new, head, head->next);
71156 +}
71157 +
71158 /**
71159 * list_add_tail_rcu - add a new entry to rcu-protected list
71160 * @new: new entry to be added
71161 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71162 __list_add_rcu(new, head->prev, head);
71163 }
71164
71165 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71166 + struct list_head *head)
71167 +{
71168 + __pax_list_add_rcu(new, head->prev, head);
71169 +}
71170 +
71171 /**
71172 * list_del_rcu - deletes entry from list without re-initialization
71173 * @entry: the element to delete from the list.
71174 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71175 entry->prev = LIST_POISON2;
71176 }
71177
71178 +extern void pax_list_del_rcu(struct list_head *entry);
71179 +
71180 /**
71181 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71182 * @n: the element to delete from the hash list.
71183 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71184 index 23b3630..e1bc12b 100644
71185 --- a/include/linux/reboot.h
71186 +++ b/include/linux/reboot.h
71187 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71188 * Architecture-specific implementations of sys_reboot commands.
71189 */
71190
71191 -extern void machine_restart(char *cmd);
71192 -extern void machine_halt(void);
71193 -extern void machine_power_off(void);
71194 +extern void machine_restart(char *cmd) __noreturn;
71195 +extern void machine_halt(void) __noreturn;
71196 +extern void machine_power_off(void) __noreturn;
71197
71198 extern void machine_shutdown(void);
71199 struct pt_regs;
71200 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71201 */
71202
71203 extern void kernel_restart_prepare(char *cmd);
71204 -extern void kernel_restart(char *cmd);
71205 -extern void kernel_halt(void);
71206 -extern void kernel_power_off(void);
71207 +extern void kernel_restart(char *cmd) __noreturn;
71208 +extern void kernel_halt(void) __noreturn;
71209 +extern void kernel_power_off(void) __noreturn;
71210
71211 extern int C_A_D; /* for sysctl */
71212 void ctrl_alt_del(void);
71213 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71214 * Emergency restart, callable from an interrupt handler.
71215 */
71216
71217 -extern void emergency_restart(void);
71218 +extern void emergency_restart(void) __noreturn;
71219 #include <asm/emergency-restart.h>
71220
71221 #endif /* _LINUX_REBOOT_H */
71222 diff --git a/include/linux/regset.h b/include/linux/regset.h
71223 index 8e0c9fe..ac4d221 100644
71224 --- a/include/linux/regset.h
71225 +++ b/include/linux/regset.h
71226 @@ -161,7 +161,8 @@ struct user_regset {
71227 unsigned int align;
71228 unsigned int bias;
71229 unsigned int core_note_type;
71230 -};
71231 +} __do_const;
71232 +typedef struct user_regset __no_const user_regset_no_const;
71233
71234 /**
71235 * struct user_regset_view - available regsets
71236 diff --git a/include/linux/relay.h b/include/linux/relay.h
71237 index 91cacc3..b55ff74 100644
71238 --- a/include/linux/relay.h
71239 +++ b/include/linux/relay.h
71240 @@ -160,7 +160,7 @@ struct rchan_callbacks
71241 * The callback should return 0 if successful, negative if not.
71242 */
71243 int (*remove_buf_file)(struct dentry *dentry);
71244 -};
71245 +} __no_const;
71246
71247 /*
71248 * CONFIG_RELAY kernel API, kernel/relay.c
71249 diff --git a/include/linux/rio.h b/include/linux/rio.h
71250 index a3e7842..d973ca6 100644
71251 --- a/include/linux/rio.h
71252 +++ b/include/linux/rio.h
71253 @@ -339,7 +339,7 @@ struct rio_ops {
71254 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71255 u64 rstart, u32 size, u32 flags);
71256 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71257 -};
71258 +} __no_const;
71259
71260 #define RIO_RESOURCE_MEM 0x00000100
71261 #define RIO_RESOURCE_DOORBELL 0x00000200
71262 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71263 index c20635c..2f5def4 100644
71264 --- a/include/linux/rmap.h
71265 +++ b/include/linux/rmap.h
71266 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71267 void anon_vma_init(void); /* create anon_vma_cachep */
71268 int anon_vma_prepare(struct vm_area_struct *);
71269 void unlink_anon_vmas(struct vm_area_struct *);
71270 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71271 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71272 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71273 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71274
71275 static inline void anon_vma_merge(struct vm_area_struct *vma,
71276 struct vm_area_struct *next)
71277 diff --git a/include/linux/sched.h b/include/linux/sched.h
71278 index 7e49270..835d8d9 100644
71279 --- a/include/linux/sched.h
71280 +++ b/include/linux/sched.h
71281 @@ -61,6 +61,7 @@ struct bio_list;
71282 struct fs_struct;
71283 struct perf_event_context;
71284 struct blk_plug;
71285 +struct linux_binprm;
71286
71287 /*
71288 * List of flags we want to share for kernel threads,
71289 @@ -328,7 +329,7 @@ extern char __sched_text_start[], __sched_text_end[];
71290 extern int in_sched_functions(unsigned long addr);
71291
71292 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71293 -extern signed long schedule_timeout(signed long timeout);
71294 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71295 extern signed long schedule_timeout_interruptible(signed long timeout);
71296 extern signed long schedule_timeout_killable(signed long timeout);
71297 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71298 @@ -355,10 +356,23 @@ struct user_namespace;
71299 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71300
71301 extern int sysctl_max_map_count;
71302 +extern unsigned long sysctl_heap_stack_gap;
71303
71304 #include <linux/aio.h>
71305
71306 #ifdef CONFIG_MMU
71307 +
71308 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71309 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71310 +#else
71311 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71312 +{
71313 + return 0;
71314 +}
71315 +#endif
71316 +
71317 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71318 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71319 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71320 extern unsigned long
71321 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71322 @@ -640,6 +654,17 @@ struct signal_struct {
71323 #ifdef CONFIG_TASKSTATS
71324 struct taskstats *stats;
71325 #endif
71326 +
71327 +#ifdef CONFIG_GRKERNSEC
71328 + u32 curr_ip;
71329 + u32 saved_ip;
71330 + u32 gr_saddr;
71331 + u32 gr_daddr;
71332 + u16 gr_sport;
71333 + u16 gr_dport;
71334 + u8 used_accept:1;
71335 +#endif
71336 +
71337 #ifdef CONFIG_AUDIT
71338 unsigned audit_tty;
71339 struct tty_audit_buf *tty_audit_buf;
71340 @@ -718,6 +743,11 @@ struct user_struct {
71341 struct key *session_keyring; /* UID's default session keyring */
71342 #endif
71343
71344 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71345 + unsigned int banned;
71346 + unsigned long ban_expires;
71347 +#endif
71348 +
71349 /* Hash table maintenance information */
71350 struct hlist_node uidhash_node;
71351 kuid_t uid;
71352 @@ -1117,7 +1147,7 @@ struct sched_class {
71353 #ifdef CONFIG_FAIR_GROUP_SCHED
71354 void (*task_move_group) (struct task_struct *p, int on_rq);
71355 #endif
71356 -};
71357 +} __do_const;
71358
71359 struct load_weight {
71360 unsigned long weight, inv_weight;
71361 @@ -1361,8 +1391,8 @@ struct task_struct {
71362 struct list_head thread_group;
71363
71364 struct completion *vfork_done; /* for vfork() */
71365 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71366 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71367 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71368 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71369
71370 cputime_t utime, stime, utimescaled, stimescaled;
71371 cputime_t gtime;
71372 @@ -1378,11 +1408,6 @@ struct task_struct {
71373 struct task_cputime cputime_expires;
71374 struct list_head cpu_timers[3];
71375
71376 -/* process credentials */
71377 - const struct cred __rcu *real_cred; /* objective and real subjective task
71378 - * credentials (COW) */
71379 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71380 - * credentials (COW) */
71381 char comm[TASK_COMM_LEN]; /* executable name excluding path
71382 - access with [gs]et_task_comm (which lock
71383 it with task_lock())
71384 @@ -1399,6 +1424,10 @@ struct task_struct {
71385 #endif
71386 /* CPU-specific state of this task */
71387 struct thread_struct thread;
71388 +/* thread_info moved to task_struct */
71389 +#ifdef CONFIG_X86
71390 + struct thread_info tinfo;
71391 +#endif
71392 /* filesystem information */
71393 struct fs_struct *fs;
71394 /* open file information */
71395 @@ -1472,6 +1501,10 @@ struct task_struct {
71396 gfp_t lockdep_reclaim_gfp;
71397 #endif
71398
71399 +/* process credentials */
71400 + const struct cred __rcu *real_cred; /* objective and real subjective task
71401 + * credentials (COW) */
71402 +
71403 /* journalling filesystem info */
71404 void *journal_info;
71405
71406 @@ -1510,6 +1543,10 @@ struct task_struct {
71407 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71408 struct list_head cg_list;
71409 #endif
71410 +
71411 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71412 + * credentials (COW) */
71413 +
71414 #ifdef CONFIG_FUTEX
71415 struct robust_list_head __user *robust_list;
71416 #ifdef CONFIG_COMPAT
71417 @@ -1606,8 +1643,74 @@ struct task_struct {
71418 #ifdef CONFIG_UPROBES
71419 struct uprobe_task *utask;
71420 #endif
71421 +
71422 +#ifdef CONFIG_GRKERNSEC
71423 + /* grsecurity */
71424 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71425 + u64 exec_id;
71426 +#endif
71427 +#ifdef CONFIG_GRKERNSEC_SETXID
71428 + const struct cred *delayed_cred;
71429 +#endif
71430 + struct dentry *gr_chroot_dentry;
71431 + struct acl_subject_label *acl;
71432 + struct acl_role_label *role;
71433 + struct file *exec_file;
71434 + unsigned long brute_expires;
71435 + u16 acl_role_id;
71436 + /* is this the task that authenticated to the special role */
71437 + u8 acl_sp_role;
71438 + u8 is_writable;
71439 + u8 brute;
71440 + u8 gr_is_chrooted;
71441 +#endif
71442 +
71443 };
71444
71445 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71446 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71447 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71448 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71449 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71450 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71451 +
71452 +#ifdef CONFIG_PAX_SOFTMODE
71453 +extern int pax_softmode;
71454 +#endif
71455 +
71456 +extern int pax_check_flags(unsigned long *);
71457 +
71458 +/* if tsk != current then task_lock must be held on it */
71459 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71460 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71461 +{
71462 + if (likely(tsk->mm))
71463 + return tsk->mm->pax_flags;
71464 + else
71465 + return 0UL;
71466 +}
71467 +
71468 +/* if tsk != current then task_lock must be held on it */
71469 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71470 +{
71471 + if (likely(tsk->mm)) {
71472 + tsk->mm->pax_flags = flags;
71473 + return 0;
71474 + }
71475 + return -EINVAL;
71476 +}
71477 +#endif
71478 +
71479 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71480 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71481 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71482 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71483 +#endif
71484 +
71485 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71486 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71487 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71488 +
71489 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71490 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71491
71492 @@ -1697,7 +1800,7 @@ struct pid_namespace;
71493 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71494 struct pid_namespace *ns);
71495
71496 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71497 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71498 {
71499 return tsk->pid;
71500 }
71501 @@ -2156,7 +2259,9 @@ void yield(void);
71502 extern struct exec_domain default_exec_domain;
71503
71504 union thread_union {
71505 +#ifndef CONFIG_X86
71506 struct thread_info thread_info;
71507 +#endif
71508 unsigned long stack[THREAD_SIZE/sizeof(long)];
71509 };
71510
71511 @@ -2189,6 +2294,7 @@ extern struct pid_namespace init_pid_ns;
71512 */
71513
71514 extern struct task_struct *find_task_by_vpid(pid_t nr);
71515 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71516 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71517 struct pid_namespace *ns);
71518
71519 @@ -2345,7 +2451,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71520 extern void exit_itimers(struct signal_struct *);
71521 extern void flush_itimer_signals(void);
71522
71523 -extern void do_group_exit(int);
71524 +extern __noreturn void do_group_exit(int);
71525
71526 extern int allow_signal(int);
71527 extern int disallow_signal(int);
71528 @@ -2546,9 +2652,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71529
71530 #endif
71531
71532 -static inline int object_is_on_stack(void *obj)
71533 +static inline int object_starts_on_stack(void *obj)
71534 {
71535 - void *stack = task_stack_page(current);
71536 + const void *stack = task_stack_page(current);
71537
71538 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71539 }
71540 diff --git a/include/linux/security.h b/include/linux/security.h
71541 index eee7478..290f7ba 100644
71542 --- a/include/linux/security.h
71543 +++ b/include/linux/security.h
71544 @@ -26,6 +26,7 @@
71545 #include <linux/capability.h>
71546 #include <linux/slab.h>
71547 #include <linux/err.h>
71548 +#include <linux/grsecurity.h>
71549
71550 struct linux_binprm;
71551 struct cred;
71552 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71553 index 68a04a3..866e6a1 100644
71554 --- a/include/linux/seq_file.h
71555 +++ b/include/linux/seq_file.h
71556 @@ -26,6 +26,9 @@ struct seq_file {
71557 struct mutex lock;
71558 const struct seq_operations *op;
71559 int poll_event;
71560 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71561 + u64 exec_id;
71562 +#endif
71563 #ifdef CONFIG_USER_NS
71564 struct user_namespace *user_ns;
71565 #endif
71566 @@ -38,6 +41,7 @@ struct seq_operations {
71567 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71568 int (*show) (struct seq_file *m, void *v);
71569 };
71570 +typedef struct seq_operations __no_const seq_operations_no_const;
71571
71572 #define SEQ_SKIP 1
71573
71574 diff --git a/include/linux/shm.h b/include/linux/shm.h
71575 index 429c199..4d42e38 100644
71576 --- a/include/linux/shm.h
71577 +++ b/include/linux/shm.h
71578 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71579
71580 /* The task created the shm object. NULL if the task is dead. */
71581 struct task_struct *shm_creator;
71582 +#ifdef CONFIG_GRKERNSEC
71583 + time_t shm_createtime;
71584 + pid_t shm_lapid;
71585 +#endif
71586 };
71587
71588 /* shm_mode upper byte flags */
71589 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71590 index 9fe54b6..a9de68d 100644
71591 --- a/include/linux/skbuff.h
71592 +++ b/include/linux/skbuff.h
71593 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71594 extern struct sk_buff *__alloc_skb(unsigned int size,
71595 gfp_t priority, int flags, int node);
71596 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71597 -static inline struct sk_buff *alloc_skb(unsigned int size,
71598 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71599 gfp_t priority)
71600 {
71601 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71602 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71603 */
71604 static inline int skb_queue_empty(const struct sk_buff_head *list)
71605 {
71606 - return list->next == (struct sk_buff *)list;
71607 + return list->next == (const struct sk_buff *)list;
71608 }
71609
71610 /**
71611 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71612 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71613 const struct sk_buff *skb)
71614 {
71615 - return skb->next == (struct sk_buff *)list;
71616 + return skb->next == (const struct sk_buff *)list;
71617 }
71618
71619 /**
71620 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71621 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71622 const struct sk_buff *skb)
71623 {
71624 - return skb->prev == (struct sk_buff *)list;
71625 + return skb->prev == (const struct sk_buff *)list;
71626 }
71627
71628 /**
71629 @@ -1727,7 +1727,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71630 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71631 */
71632 #ifndef NET_SKB_PAD
71633 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71634 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71635 #endif
71636
71637 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71638 @@ -2305,7 +2305,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71639 int noblock, int *err);
71640 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71641 struct poll_table_struct *wait);
71642 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71643 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71644 int offset, struct iovec *to,
71645 int size);
71646 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71647 @@ -2595,6 +2595,9 @@ static inline void nf_reset(struct sk_buff *skb)
71648 nf_bridge_put(skb->nf_bridge);
71649 skb->nf_bridge = NULL;
71650 #endif
71651 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71652 + skb->nf_trace = 0;
71653 +#endif
71654 }
71655
71656 static inline void nf_reset_trace(struct sk_buff *skb)
71657 diff --git a/include/linux/slab.h b/include/linux/slab.h
71658 index 5d168d7..720bff3 100644
71659 --- a/include/linux/slab.h
71660 +++ b/include/linux/slab.h
71661 @@ -12,13 +12,20 @@
71662 #include <linux/gfp.h>
71663 #include <linux/types.h>
71664 #include <linux/workqueue.h>
71665 -
71666 +#include <linux/err.h>
71667
71668 /*
71669 * Flags to pass to kmem_cache_create().
71670 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71671 */
71672 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71673 +
71674 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71675 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71676 +#else
71677 +#define SLAB_USERCOPY 0x00000000UL
71678 +#endif
71679 +
71680 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71681 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71682 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71683 @@ -89,10 +96,13 @@
71684 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71685 * Both make kfree a no-op.
71686 */
71687 -#define ZERO_SIZE_PTR ((void *)16)
71688 +#define ZERO_SIZE_PTR \
71689 +({ \
71690 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71691 + (void *)(-MAX_ERRNO-1L); \
71692 +})
71693
71694 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71695 - (unsigned long)ZERO_SIZE_PTR)
71696 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71697
71698 /*
71699 * Common fields provided in kmem_cache by all slab allocators
71700 @@ -112,7 +122,7 @@ struct kmem_cache {
71701 unsigned int align; /* Alignment as calculated */
71702 unsigned long flags; /* Active flags on the slab */
71703 const char *name; /* Slab name for sysfs */
71704 - int refcount; /* Use counter */
71705 + atomic_t refcount; /* Use counter */
71706 void (*ctor)(void *); /* Called on object slot creation */
71707 struct list_head list; /* List of all slab caches on the system */
71708 };
71709 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71710 void kfree(const void *);
71711 void kzfree(const void *);
71712 size_t ksize(const void *);
71713 +const char *check_heap_object(const void *ptr, unsigned long n);
71714 +bool is_usercopy_object(const void *ptr);
71715
71716 /*
71717 * Allocator specific definitions. These are mainly used to establish optimized
71718 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71719 * for general use, and so are not documented here. For a full list of
71720 * potential flags, always refer to linux/gfp.h.
71721 */
71722 +
71723 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71724 {
71725 if (size != 0 && n > SIZE_MAX / size)
71726 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71727 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71728 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71729 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71730 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71731 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71732 #define kmalloc_track_caller(size, flags) \
71733 __kmalloc_track_caller(size, flags, _RET_IP_)
71734 #else
71735 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71736 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71737 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71738 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71739 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71740 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71741 #define kmalloc_node_track_caller(size, flags, node) \
71742 __kmalloc_node_track_caller(size, flags, node, \
71743 _RET_IP_)
71744 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71745 index 8bb6e0e..8eb0dbe 100644
71746 --- a/include/linux/slab_def.h
71747 +++ b/include/linux/slab_def.h
71748 @@ -52,7 +52,7 @@ struct kmem_cache {
71749 /* 4) cache creation/removal */
71750 const char *name;
71751 struct list_head list;
71752 - int refcount;
71753 + atomic_t refcount;
71754 int object_size;
71755 int align;
71756
71757 @@ -68,10 +68,10 @@ struct kmem_cache {
71758 unsigned long node_allocs;
71759 unsigned long node_frees;
71760 unsigned long node_overflow;
71761 - atomic_t allochit;
71762 - atomic_t allocmiss;
71763 - atomic_t freehit;
71764 - atomic_t freemiss;
71765 + atomic_unchecked_t allochit;
71766 + atomic_unchecked_t allocmiss;
71767 + atomic_unchecked_t freehit;
71768 + atomic_unchecked_t freemiss;
71769
71770 /*
71771 * If debugging is enabled, then the allocator can add additional
71772 @@ -111,11 +111,16 @@ struct cache_sizes {
71773 #ifdef CONFIG_ZONE_DMA
71774 struct kmem_cache *cs_dmacachep;
71775 #endif
71776 +
71777 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71778 + struct kmem_cache *cs_usercopycachep;
71779 +#endif
71780 +
71781 };
71782 extern struct cache_sizes malloc_sizes[];
71783
71784 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71785 -void *__kmalloc(size_t size, gfp_t flags);
71786 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71787
71788 #ifdef CONFIG_TRACING
71789 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71790 @@ -152,6 +157,13 @@ found:
71791 cachep = malloc_sizes[i].cs_dmacachep;
71792 else
71793 #endif
71794 +
71795 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71796 + if (flags & GFP_USERCOPY)
71797 + cachep = malloc_sizes[i].cs_usercopycachep;
71798 + else
71799 +#endif
71800 +
71801 cachep = malloc_sizes[i].cs_cachep;
71802
71803 ret = kmem_cache_alloc_trace(cachep, flags, size);
71804 @@ -162,7 +174,7 @@ found:
71805 }
71806
71807 #ifdef CONFIG_NUMA
71808 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71809 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71810 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71811
71812 #ifdef CONFIG_TRACING
71813 @@ -205,6 +217,13 @@ found:
71814 cachep = malloc_sizes[i].cs_dmacachep;
71815 else
71816 #endif
71817 +
71818 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71819 + if (flags & GFP_USERCOPY)
71820 + cachep = malloc_sizes[i].cs_usercopycachep;
71821 + else
71822 +#endif
71823 +
71824 cachep = malloc_sizes[i].cs_cachep;
71825
71826 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71827 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71828 index f28e14a..7831211 100644
71829 --- a/include/linux/slob_def.h
71830 +++ b/include/linux/slob_def.h
71831 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71832 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71833 }
71834
71835 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71836 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71837
71838 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71839 {
71840 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71841 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71842 }
71843
71844 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71845 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71846 {
71847 return kmalloc(size, flags);
71848 }
71849 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71850 index 9db4825..ed42fb5 100644
71851 --- a/include/linux/slub_def.h
71852 +++ b/include/linux/slub_def.h
71853 @@ -91,7 +91,7 @@ struct kmem_cache {
71854 struct kmem_cache_order_objects max;
71855 struct kmem_cache_order_objects min;
71856 gfp_t allocflags; /* gfp flags to use on each alloc */
71857 - int refcount; /* Refcount for slab cache destroy */
71858 + atomic_t refcount; /* Refcount for slab cache destroy */
71859 void (*ctor)(void *);
71860 int inuse; /* Offset to metadata */
71861 int align; /* Alignment */
71862 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71863 * Sorry that the following has to be that ugly but some versions of GCC
71864 * have trouble with constant propagation and loops.
71865 */
71866 -static __always_inline int kmalloc_index(size_t size)
71867 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71868 {
71869 if (!size)
71870 return 0;
71871 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71872 }
71873
71874 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71875 -void *__kmalloc(size_t size, gfp_t flags);
71876 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71877
71878 static __always_inline void *
71879 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71880 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71881 }
71882 #endif
71883
71884 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71885 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71886 {
71887 unsigned int order = get_order(size);
71888 return kmalloc_order_trace(size, flags, order);
71889 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71890 }
71891
71892 #ifdef CONFIG_NUMA
71893 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71894 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71895 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71896
71897 #ifdef CONFIG_TRACING
71898 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71899 index e8d702e..0a56eb4 100644
71900 --- a/include/linux/sock_diag.h
71901 +++ b/include/linux/sock_diag.h
71902 @@ -10,7 +10,7 @@ struct sock;
71903 struct sock_diag_handler {
71904 __u8 family;
71905 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71906 -};
71907 +} __do_const;
71908
71909 int sock_diag_register(const struct sock_diag_handler *h);
71910 void sock_diag_unregister(const struct sock_diag_handler *h);
71911 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71912 index 680f9a3..f13aeb0 100644
71913 --- a/include/linux/sonet.h
71914 +++ b/include/linux/sonet.h
71915 @@ -7,7 +7,7 @@
71916 #include <uapi/linux/sonet.h>
71917
71918 struct k_sonet_stats {
71919 -#define __HANDLE_ITEM(i) atomic_t i
71920 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71921 __SONET_ITEMS
71922 #undef __HANDLE_ITEM
71923 };
71924 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71925 index 34206b8..3db7f1c 100644
71926 --- a/include/linux/sunrpc/clnt.h
71927 +++ b/include/linux/sunrpc/clnt.h
71928 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71929 unsigned int p_timer; /* Which RTT timer to use */
71930 u32 p_statidx; /* Which procedure to account */
71931 const char * p_name; /* name of procedure */
71932 -};
71933 +} __do_const;
71934
71935 #ifdef __KERNEL__
71936
71937 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71938 {
71939 switch (sap->sa_family) {
71940 case AF_INET:
71941 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71942 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71943 case AF_INET6:
71944 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71945 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71946 }
71947 return 0;
71948 }
71949 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71950 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71951 const struct sockaddr *src)
71952 {
71953 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71954 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71955 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71956
71957 dsin->sin_family = ssin->sin_family;
71958 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71959 if (sa->sa_family != AF_INET6)
71960 return 0;
71961
71962 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71963 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71964 }
71965
71966 #endif /* __KERNEL__ */
71967 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71968 index 676ddf5..4c519a1 100644
71969 --- a/include/linux/sunrpc/svc.h
71970 +++ b/include/linux/sunrpc/svc.h
71971 @@ -410,7 +410,7 @@ struct svc_procedure {
71972 unsigned int pc_count; /* call count */
71973 unsigned int pc_cachetype; /* cache info (NFS) */
71974 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71975 -};
71976 +} __do_const;
71977
71978 /*
71979 * Function prototypes.
71980 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71981 index 0b8e3e6..33e0a01 100644
71982 --- a/include/linux/sunrpc/svc_rdma.h
71983 +++ b/include/linux/sunrpc/svc_rdma.h
71984 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71985 extern unsigned int svcrdma_max_requests;
71986 extern unsigned int svcrdma_max_req_size;
71987
71988 -extern atomic_t rdma_stat_recv;
71989 -extern atomic_t rdma_stat_read;
71990 -extern atomic_t rdma_stat_write;
71991 -extern atomic_t rdma_stat_sq_starve;
71992 -extern atomic_t rdma_stat_rq_starve;
71993 -extern atomic_t rdma_stat_rq_poll;
71994 -extern atomic_t rdma_stat_rq_prod;
71995 -extern atomic_t rdma_stat_sq_poll;
71996 -extern atomic_t rdma_stat_sq_prod;
71997 +extern atomic_unchecked_t rdma_stat_recv;
71998 +extern atomic_unchecked_t rdma_stat_read;
71999 +extern atomic_unchecked_t rdma_stat_write;
72000 +extern atomic_unchecked_t rdma_stat_sq_starve;
72001 +extern atomic_unchecked_t rdma_stat_rq_starve;
72002 +extern atomic_unchecked_t rdma_stat_rq_poll;
72003 +extern atomic_unchecked_t rdma_stat_rq_prod;
72004 +extern atomic_unchecked_t rdma_stat_sq_poll;
72005 +extern atomic_unchecked_t rdma_stat_sq_prod;
72006
72007 #define RPCRDMA_VERSION 1
72008
72009 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
72010 index dd74084a..7f509d5 100644
72011 --- a/include/linux/sunrpc/svcauth.h
72012 +++ b/include/linux/sunrpc/svcauth.h
72013 @@ -109,7 +109,7 @@ struct auth_ops {
72014 int (*release)(struct svc_rqst *rq);
72015 void (*domain_release)(struct auth_domain *);
72016 int (*set_client)(struct svc_rqst *rq);
72017 -};
72018 +} __do_const;
72019
72020 #define SVC_GARBAGE 1
72021 #define SVC_SYSERR 2
72022 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
72023 index 071d62c..4ccc7ac 100644
72024 --- a/include/linux/swiotlb.h
72025 +++ b/include/linux/swiotlb.h
72026 @@ -59,7 +59,8 @@ extern void
72027
72028 extern void
72029 swiotlb_free_coherent(struct device *hwdev, size_t size,
72030 - void *vaddr, dma_addr_t dma_handle);
72031 + void *vaddr, dma_addr_t dma_handle,
72032 + struct dma_attrs *attrs);
72033
72034 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
72035 unsigned long offset, size_t size,
72036 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
72037 index 45e2db2..1635156a 100644
72038 --- a/include/linux/syscalls.h
72039 +++ b/include/linux/syscalls.h
72040 @@ -615,7 +615,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72041 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72042 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72043 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72044 - struct sockaddr __user *, int);
72045 + struct sockaddr __user *, int) __intentional_overflow(0);
72046 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72047 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72048 unsigned int vlen, unsigned flags);
72049 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72050 index 27b3b0b..e093dd9 100644
72051 --- a/include/linux/syscore_ops.h
72052 +++ b/include/linux/syscore_ops.h
72053 @@ -16,7 +16,7 @@ struct syscore_ops {
72054 int (*suspend)(void);
72055 void (*resume)(void);
72056 void (*shutdown)(void);
72057 -};
72058 +} __do_const;
72059
72060 extern void register_syscore_ops(struct syscore_ops *ops);
72061 extern void unregister_syscore_ops(struct syscore_ops *ops);
72062 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72063 index 14a8ff2..af52bad 100644
72064 --- a/include/linux/sysctl.h
72065 +++ b/include/linux/sysctl.h
72066 @@ -34,13 +34,13 @@ struct ctl_table_root;
72067 struct ctl_table_header;
72068 struct ctl_dir;
72069
72070 -typedef struct ctl_table ctl_table;
72071 -
72072 typedef int proc_handler (struct ctl_table *ctl, int write,
72073 void __user *buffer, size_t *lenp, loff_t *ppos);
72074
72075 extern int proc_dostring(struct ctl_table *, int,
72076 void __user *, size_t *, loff_t *);
72077 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72078 + void __user *, size_t *, loff_t *);
72079 extern int proc_dointvec(struct ctl_table *, int,
72080 void __user *, size_t *, loff_t *);
72081 extern int proc_dointvec_minmax(struct ctl_table *, int,
72082 @@ -115,7 +115,9 @@ struct ctl_table
72083 struct ctl_table_poll *poll;
72084 void *extra1;
72085 void *extra2;
72086 -};
72087 +} __do_const;
72088 +typedef struct ctl_table __no_const ctl_table_no_const;
72089 +typedef struct ctl_table ctl_table;
72090
72091 struct ctl_node {
72092 struct rb_node node;
72093 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72094 index 381f06d..dc16cc7 100644
72095 --- a/include/linux/sysfs.h
72096 +++ b/include/linux/sysfs.h
72097 @@ -31,7 +31,8 @@ struct attribute {
72098 struct lock_class_key *key;
72099 struct lock_class_key skey;
72100 #endif
72101 -};
72102 +} __do_const;
72103 +typedef struct attribute __no_const attribute_no_const;
72104
72105 /**
72106 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72107 @@ -59,8 +60,8 @@ struct attribute_group {
72108 umode_t (*is_visible)(struct kobject *,
72109 struct attribute *, int);
72110 struct attribute **attrs;
72111 -};
72112 -
72113 +} __do_const;
72114 +typedef struct attribute_group __no_const attribute_group_no_const;
72115
72116
72117 /**
72118 @@ -107,7 +108,8 @@ struct bin_attribute {
72119 char *, loff_t, size_t);
72120 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72121 struct vm_area_struct *vma);
72122 -};
72123 +} __do_const;
72124 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72125
72126 /**
72127 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72128 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72129 index 7faf933..9b85a0c 100644
72130 --- a/include/linux/sysrq.h
72131 +++ b/include/linux/sysrq.h
72132 @@ -16,6 +16,7 @@
72133
72134 #include <linux/errno.h>
72135 #include <linux/types.h>
72136 +#include <linux/compiler.h>
72137
72138 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72139 #define SYSRQ_DEFAULT_ENABLE 1
72140 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72141 char *help_msg;
72142 char *action_msg;
72143 int enable_mask;
72144 -};
72145 +} __do_const;
72146
72147 #ifdef CONFIG_MAGIC_SYSRQ
72148
72149 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72150 index e7e0473..7989295 100644
72151 --- a/include/linux/thread_info.h
72152 +++ b/include/linux/thread_info.h
72153 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72154 #error "no set_restore_sigmask() provided and default one won't work"
72155 #endif
72156
72157 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72158 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72159 +{
72160 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72161 + if (!__builtin_constant_p(n))
72162 +#endif
72163 + __check_object_size(ptr, n, to_user);
72164 +}
72165 +
72166 #endif /* __KERNEL__ */
72167
72168 #endif /* _LINUX_THREAD_INFO_H */
72169 diff --git a/include/linux/tty.h b/include/linux/tty.h
72170 index 8db1b56..c16a040 100644
72171 --- a/include/linux/tty.h
72172 +++ b/include/linux/tty.h
72173 @@ -194,7 +194,7 @@ struct tty_port {
72174 const struct tty_port_operations *ops; /* Port operations */
72175 spinlock_t lock; /* Lock protecting tty field */
72176 int blocked_open; /* Waiting to open */
72177 - int count; /* Usage count */
72178 + atomic_t count; /* Usage count */
72179 wait_queue_head_t open_wait; /* Open waiters */
72180 wait_queue_head_t close_wait; /* Close waiters */
72181 wait_queue_head_t delta_msr_wait; /* Modem status change */
72182 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
72183 struct tty_struct *tty, struct file *filp);
72184 static inline int tty_port_users(struct tty_port *port)
72185 {
72186 - return port->count + port->blocked_open;
72187 + return atomic_read(&port->count) + port->blocked_open;
72188 }
72189
72190 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72191 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72192 index dd976cf..e272742 100644
72193 --- a/include/linux/tty_driver.h
72194 +++ b/include/linux/tty_driver.h
72195 @@ -284,7 +284,7 @@ struct tty_operations {
72196 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72197 #endif
72198 const struct file_operations *proc_fops;
72199 -};
72200 +} __do_const;
72201
72202 struct tty_driver {
72203 int magic; /* magic number for this structure */
72204 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72205 index fb79dd8d..07d4773 100644
72206 --- a/include/linux/tty_ldisc.h
72207 +++ b/include/linux/tty_ldisc.h
72208 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
72209
72210 struct module *owner;
72211
72212 - int refcount;
72213 + atomic_t refcount;
72214 };
72215
72216 struct tty_ldisc {
72217 diff --git a/include/linux/types.h b/include/linux/types.h
72218 index 4d118ba..c3ee9bf 100644
72219 --- a/include/linux/types.h
72220 +++ b/include/linux/types.h
72221 @@ -176,10 +176,26 @@ typedef struct {
72222 int counter;
72223 } atomic_t;
72224
72225 +#ifdef CONFIG_PAX_REFCOUNT
72226 +typedef struct {
72227 + int counter;
72228 +} atomic_unchecked_t;
72229 +#else
72230 +typedef atomic_t atomic_unchecked_t;
72231 +#endif
72232 +
72233 #ifdef CONFIG_64BIT
72234 typedef struct {
72235 long counter;
72236 } atomic64_t;
72237 +
72238 +#ifdef CONFIG_PAX_REFCOUNT
72239 +typedef struct {
72240 + long counter;
72241 +} atomic64_unchecked_t;
72242 +#else
72243 +typedef atomic64_t atomic64_unchecked_t;
72244 +#endif
72245 #endif
72246
72247 struct list_head {
72248 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72249 index 5ca0951..ab496a5 100644
72250 --- a/include/linux/uaccess.h
72251 +++ b/include/linux/uaccess.h
72252 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72253 long ret; \
72254 mm_segment_t old_fs = get_fs(); \
72255 \
72256 - set_fs(KERNEL_DS); \
72257 pagefault_disable(); \
72258 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72259 - pagefault_enable(); \
72260 + set_fs(KERNEL_DS); \
72261 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72262 set_fs(old_fs); \
72263 + pagefault_enable(); \
72264 ret; \
72265 })
72266
72267 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72268 index 8e522cbc..aa8572d 100644
72269 --- a/include/linux/uidgid.h
72270 +++ b/include/linux/uidgid.h
72271 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72272
72273 #endif /* CONFIG_USER_NS */
72274
72275 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72276 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72277 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72278 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72279 +
72280 #endif /* _LINUX_UIDGID_H */
72281 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72282 index 99c1b4d..562e6f3 100644
72283 --- a/include/linux/unaligned/access_ok.h
72284 +++ b/include/linux/unaligned/access_ok.h
72285 @@ -4,34 +4,34 @@
72286 #include <linux/kernel.h>
72287 #include <asm/byteorder.h>
72288
72289 -static inline u16 get_unaligned_le16(const void *p)
72290 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72291 {
72292 - return le16_to_cpup((__le16 *)p);
72293 + return le16_to_cpup((const __le16 *)p);
72294 }
72295
72296 -static inline u32 get_unaligned_le32(const void *p)
72297 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72298 {
72299 - return le32_to_cpup((__le32 *)p);
72300 + return le32_to_cpup((const __le32 *)p);
72301 }
72302
72303 -static inline u64 get_unaligned_le64(const void *p)
72304 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72305 {
72306 - return le64_to_cpup((__le64 *)p);
72307 + return le64_to_cpup((const __le64 *)p);
72308 }
72309
72310 -static inline u16 get_unaligned_be16(const void *p)
72311 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72312 {
72313 - return be16_to_cpup((__be16 *)p);
72314 + return be16_to_cpup((const __be16 *)p);
72315 }
72316
72317 -static inline u32 get_unaligned_be32(const void *p)
72318 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72319 {
72320 - return be32_to_cpup((__be32 *)p);
72321 + return be32_to_cpup((const __be32 *)p);
72322 }
72323
72324 -static inline u64 get_unaligned_be64(const void *p)
72325 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72326 {
72327 - return be64_to_cpup((__be64 *)p);
72328 + return be64_to_cpup((const __be64 *)p);
72329 }
72330
72331 static inline void put_unaligned_le16(u16 val, void *p)
72332 diff --git a/include/linux/usb.h b/include/linux/usb.h
72333 index 4d22d0f..8d0e8f8 100644
72334 --- a/include/linux/usb.h
72335 +++ b/include/linux/usb.h
72336 @@ -554,7 +554,7 @@ struct usb_device {
72337 int maxchild;
72338
72339 u32 quirks;
72340 - atomic_t urbnum;
72341 + atomic_unchecked_t urbnum;
72342
72343 unsigned long active_duration;
72344
72345 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72346
72347 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72348 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72349 - void *data, __u16 size, int timeout);
72350 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72351 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72352 void *data, int len, int *actual_length, int timeout);
72353 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72354 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72355 index c5d36c6..108f4f9 100644
72356 --- a/include/linux/usb/renesas_usbhs.h
72357 +++ b/include/linux/usb/renesas_usbhs.h
72358 @@ -39,7 +39,7 @@ enum {
72359 */
72360 struct renesas_usbhs_driver_callback {
72361 int (*notify_hotplug)(struct platform_device *pdev);
72362 -};
72363 +} __no_const;
72364
72365 /*
72366 * callback functions for platform
72367 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
72368 index 5209cfe..b6b215f 100644
72369 --- a/include/linux/user_namespace.h
72370 +++ b/include/linux/user_namespace.h
72371 @@ -21,7 +21,7 @@ struct user_namespace {
72372 struct uid_gid_map uid_map;
72373 struct uid_gid_map gid_map;
72374 struct uid_gid_map projid_map;
72375 - struct kref kref;
72376 + atomic_t count;
72377 struct user_namespace *parent;
72378 kuid_t owner;
72379 kgid_t group;
72380 @@ -37,18 +37,18 @@ extern struct user_namespace init_user_ns;
72381 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
72382 {
72383 if (ns)
72384 - kref_get(&ns->kref);
72385 + atomic_inc(&ns->count);
72386 return ns;
72387 }
72388
72389 extern int create_user_ns(struct cred *new);
72390 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
72391 -extern void free_user_ns(struct kref *kref);
72392 +extern void free_user_ns(struct user_namespace *ns);
72393
72394 static inline void put_user_ns(struct user_namespace *ns)
72395 {
72396 - if (ns)
72397 - kref_put(&ns->kref, free_user_ns);
72398 + if (ns && atomic_dec_and_test(&ns->count))
72399 + free_user_ns(ns);
72400 }
72401
72402 struct seq_operations;
72403 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72404 index 6f8fbcf..8259001 100644
72405 --- a/include/linux/vermagic.h
72406 +++ b/include/linux/vermagic.h
72407 @@ -25,9 +25,35 @@
72408 #define MODULE_ARCH_VERMAGIC ""
72409 #endif
72410
72411 +#ifdef CONFIG_PAX_REFCOUNT
72412 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72413 +#else
72414 +#define MODULE_PAX_REFCOUNT ""
72415 +#endif
72416 +
72417 +#ifdef CONSTIFY_PLUGIN
72418 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72419 +#else
72420 +#define MODULE_CONSTIFY_PLUGIN ""
72421 +#endif
72422 +
72423 +#ifdef STACKLEAK_PLUGIN
72424 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72425 +#else
72426 +#define MODULE_STACKLEAK_PLUGIN ""
72427 +#endif
72428 +
72429 +#ifdef CONFIG_GRKERNSEC
72430 +#define MODULE_GRSEC "GRSEC "
72431 +#else
72432 +#define MODULE_GRSEC ""
72433 +#endif
72434 +
72435 #define VERMAGIC_STRING \
72436 UTS_RELEASE " " \
72437 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72438 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72439 - MODULE_ARCH_VERMAGIC
72440 + MODULE_ARCH_VERMAGIC \
72441 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72442 + MODULE_GRSEC
72443
72444 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72445 index 6071e91..ca6a489 100644
72446 --- a/include/linux/vmalloc.h
72447 +++ b/include/linux/vmalloc.h
72448 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72449 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72450 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72451 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72452 +
72453 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72454 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72455 +#endif
72456 +
72457 /* bits [20..32] reserved for arch specific ioremap internals */
72458
72459 /*
72460 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72461 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72462 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72463 unsigned long start, unsigned long end, gfp_t gfp_mask,
72464 - pgprot_t prot, int node, const void *caller);
72465 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72466 extern void vfree(const void *addr);
72467
72468 extern void *vmap(struct page **pages, unsigned int count,
72469 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72470 extern void free_vm_area(struct vm_struct *area);
72471
72472 /* for /dev/kmem */
72473 -extern long vread(char *buf, char *addr, unsigned long count);
72474 -extern long vwrite(char *buf, char *addr, unsigned long count);
72475 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72476 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72477
72478 /*
72479 * Internals. Dont't use..
72480 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72481 index a13291f..af51fa3 100644
72482 --- a/include/linux/vmstat.h
72483 +++ b/include/linux/vmstat.h
72484 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72485 /*
72486 * Zone based page accounting with per cpu differentials.
72487 */
72488 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72489 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72490
72491 static inline void zone_page_state_add(long x, struct zone *zone,
72492 enum zone_stat_item item)
72493 {
72494 - atomic_long_add(x, &zone->vm_stat[item]);
72495 - atomic_long_add(x, &vm_stat[item]);
72496 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72497 + atomic_long_add_unchecked(x, &vm_stat[item]);
72498 }
72499
72500 static inline unsigned long global_page_state(enum zone_stat_item item)
72501 {
72502 - long x = atomic_long_read(&vm_stat[item]);
72503 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72504 #ifdef CONFIG_SMP
72505 if (x < 0)
72506 x = 0;
72507 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72508 static inline unsigned long zone_page_state(struct zone *zone,
72509 enum zone_stat_item item)
72510 {
72511 - long x = atomic_long_read(&zone->vm_stat[item]);
72512 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72513 #ifdef CONFIG_SMP
72514 if (x < 0)
72515 x = 0;
72516 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72517 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72518 enum zone_stat_item item)
72519 {
72520 - long x = atomic_long_read(&zone->vm_stat[item]);
72521 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72522
72523 #ifdef CONFIG_SMP
72524 int cpu;
72525 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72526
72527 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72528 {
72529 - atomic_long_inc(&zone->vm_stat[item]);
72530 - atomic_long_inc(&vm_stat[item]);
72531 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72532 + atomic_long_inc_unchecked(&vm_stat[item]);
72533 }
72534
72535 static inline void __inc_zone_page_state(struct page *page,
72536 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72537
72538 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72539 {
72540 - atomic_long_dec(&zone->vm_stat[item]);
72541 - atomic_long_dec(&vm_stat[item]);
72542 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72543 + atomic_long_dec_unchecked(&vm_stat[item]);
72544 }
72545
72546 static inline void __dec_zone_page_state(struct page *page,
72547 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72548 index fdbafc6..b7ffd47 100644
72549 --- a/include/linux/xattr.h
72550 +++ b/include/linux/xattr.h
72551 @@ -28,7 +28,7 @@ struct xattr_handler {
72552 size_t size, int handler_flags);
72553 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72554 size_t size, int flags, int handler_flags);
72555 -};
72556 +} __do_const;
72557
72558 struct xattr {
72559 char *name;
72560 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72561 index 9c5a6b4..09c9438 100644
72562 --- a/include/linux/zlib.h
72563 +++ b/include/linux/zlib.h
72564 @@ -31,6 +31,7 @@
72565 #define _ZLIB_H
72566
72567 #include <linux/zconf.h>
72568 +#include <linux/compiler.h>
72569
72570 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72571 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72572 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72573
72574 /* basic functions */
72575
72576 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72577 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72578 /*
72579 Returns the number of bytes that needs to be allocated for a per-
72580 stream workspace with the specified parameters. A pointer to this
72581 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72582 index 95d1c91..6798cca 100644
72583 --- a/include/media/v4l2-dev.h
72584 +++ b/include/media/v4l2-dev.h
72585 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72586 int (*mmap) (struct file *, struct vm_area_struct *);
72587 int (*open) (struct file *);
72588 int (*release) (struct file *);
72589 -};
72590 +} __do_const;
72591
72592 /*
72593 * Newer version of video_device, handled by videodev2.c
72594 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72595 index 4118ad1..cb7e25f 100644
72596 --- a/include/media/v4l2-ioctl.h
72597 +++ b/include/media/v4l2-ioctl.h
72598 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72599 bool valid_prio, int cmd, void *arg);
72600 };
72601
72602 -
72603 /* v4l debugging and diagnostics */
72604
72605 /* Debug bitmask flags to be used on V4L2 */
72606 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72607 index adcbb20..62c2559 100644
72608 --- a/include/net/9p/transport.h
72609 +++ b/include/net/9p/transport.h
72610 @@ -57,7 +57,7 @@ struct p9_trans_module {
72611 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72612 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72613 char *, char *, int , int, int, int);
72614 -};
72615 +} __do_const;
72616
72617 void v9fs_register_trans(struct p9_trans_module *m);
72618 void v9fs_unregister_trans(struct p9_trans_module *m);
72619 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72620 index 7588ef4..e62d35f 100644
72621 --- a/include/net/bluetooth/l2cap.h
72622 +++ b/include/net/bluetooth/l2cap.h
72623 @@ -552,7 +552,7 @@ struct l2cap_ops {
72624 void (*defer) (struct l2cap_chan *chan);
72625 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72626 unsigned long len, int nb);
72627 -};
72628 +} __do_const;
72629
72630 struct l2cap_conn {
72631 struct hci_conn *hcon;
72632 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72633 index 9e5425b..8136ffc 100644
72634 --- a/include/net/caif/cfctrl.h
72635 +++ b/include/net/caif/cfctrl.h
72636 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72637 void (*radioset_rsp)(void);
72638 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72639 struct cflayer *client_layer);
72640 -};
72641 +} __no_const;
72642
72643 /* Link Setup Parameters for CAIF-Links. */
72644 struct cfctrl_link_param {
72645 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72646 struct cfctrl {
72647 struct cfsrvl serv;
72648 struct cfctrl_rsp res;
72649 - atomic_t req_seq_no;
72650 - atomic_t rsp_seq_no;
72651 + atomic_unchecked_t req_seq_no;
72652 + atomic_unchecked_t rsp_seq_no;
72653 struct list_head list;
72654 /* Protects from simultaneous access to first_req list */
72655 spinlock_t info_list_lock;
72656 diff --git a/include/net/flow.h b/include/net/flow.h
72657 index 628e11b..4c475df 100644
72658 --- a/include/net/flow.h
72659 +++ b/include/net/flow.h
72660 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72661
72662 extern void flow_cache_flush(void);
72663 extern void flow_cache_flush_deferred(void);
72664 -extern atomic_t flow_cache_genid;
72665 +extern atomic_unchecked_t flow_cache_genid;
72666
72667 #endif
72668 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72669 index bdfbe68..4402ebe 100644
72670 --- a/include/net/genetlink.h
72671 +++ b/include/net/genetlink.h
72672 @@ -118,7 +118,7 @@ struct genl_ops {
72673 struct netlink_callback *cb);
72674 int (*done)(struct netlink_callback *cb);
72675 struct list_head ops_list;
72676 -};
72677 +} __do_const;
72678
72679 extern int genl_register_family(struct genl_family *family);
72680 extern int genl_register_family_with_ops(struct genl_family *family,
72681 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72682 index e5062c9..48a9a4b 100644
72683 --- a/include/net/gro_cells.h
72684 +++ b/include/net/gro_cells.h
72685 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72686 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72687
72688 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72689 - atomic_long_inc(&dev->rx_dropped);
72690 + atomic_long_inc_unchecked(&dev->rx_dropped);
72691 kfree_skb(skb);
72692 return;
72693 }
72694 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
72695 int i;
72696
72697 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
72698 - gcells->cells = kcalloc(sizeof(struct gro_cell),
72699 - gcells->gro_cells_mask + 1,
72700 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
72701 + sizeof(struct gro_cell),
72702 GFP_KERNEL);
72703 if (!gcells->cells)
72704 return -ENOMEM;
72705 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72706 index 1832927..ce39aea 100644
72707 --- a/include/net/inet_connection_sock.h
72708 +++ b/include/net/inet_connection_sock.h
72709 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72710 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72711 int (*bind_conflict)(const struct sock *sk,
72712 const struct inet_bind_bucket *tb, bool relax);
72713 -};
72714 +} __do_const;
72715
72716 /** inet_connection_sock - INET connection oriented sock
72717 *
72718 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72719 index 53f464d..ba76aaa 100644
72720 --- a/include/net/inetpeer.h
72721 +++ b/include/net/inetpeer.h
72722 @@ -47,8 +47,8 @@ struct inet_peer {
72723 */
72724 union {
72725 struct {
72726 - atomic_t rid; /* Frag reception counter */
72727 - atomic_t ip_id_count; /* IP ID for the next packet */
72728 + atomic_unchecked_t rid; /* Frag reception counter */
72729 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72730 };
72731 struct rcu_head rcu;
72732 struct inet_peer *gc_next;
72733 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72734 more++;
72735 inet_peer_refcheck(p);
72736 do {
72737 - old = atomic_read(&p->ip_id_count);
72738 + old = atomic_read_unchecked(&p->ip_id_count);
72739 new = old + more;
72740 if (!new)
72741 new = 1;
72742 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72743 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72744 return new;
72745 }
72746
72747 diff --git a/include/net/ip.h b/include/net/ip.h
72748 index a68f838..74518ab 100644
72749 --- a/include/net/ip.h
72750 +++ b/include/net/ip.h
72751 @@ -202,7 +202,7 @@ extern struct local_ports {
72752 } sysctl_local_ports;
72753 extern void inet_get_local_port_range(int *low, int *high);
72754
72755 -extern unsigned long *sysctl_local_reserved_ports;
72756 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72757 static inline int inet_is_reserved_local_port(int port)
72758 {
72759 return test_bit(port, sysctl_local_reserved_ports);
72760 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72761 index e49db91..76a81de 100644
72762 --- a/include/net/ip_fib.h
72763 +++ b/include/net/ip_fib.h
72764 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72765
72766 #define FIB_RES_SADDR(net, res) \
72767 ((FIB_RES_NH(res).nh_saddr_genid == \
72768 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72769 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72770 FIB_RES_NH(res).nh_saddr : \
72771 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72772 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72773 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72774 index 68c69d5..bdab192 100644
72775 --- a/include/net/ip_vs.h
72776 +++ b/include/net/ip_vs.h
72777 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72778 struct ip_vs_conn *control; /* Master control connection */
72779 atomic_t n_control; /* Number of controlled ones */
72780 struct ip_vs_dest *dest; /* real server */
72781 - atomic_t in_pkts; /* incoming packet counter */
72782 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72783
72784 /* packet transmitter for different forwarding methods. If it
72785 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72786 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72787 __be16 port; /* port number of the server */
72788 union nf_inet_addr addr; /* IP address of the server */
72789 volatile unsigned int flags; /* dest status flags */
72790 - atomic_t conn_flags; /* flags to copy to conn */
72791 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72792 atomic_t weight; /* server weight */
72793
72794 atomic_t refcnt; /* reference counter */
72795 @@ -980,11 +980,11 @@ struct netns_ipvs {
72796 /* ip_vs_lblc */
72797 int sysctl_lblc_expiration;
72798 struct ctl_table_header *lblc_ctl_header;
72799 - struct ctl_table *lblc_ctl_table;
72800 + ctl_table_no_const *lblc_ctl_table;
72801 /* ip_vs_lblcr */
72802 int sysctl_lblcr_expiration;
72803 struct ctl_table_header *lblcr_ctl_header;
72804 - struct ctl_table *lblcr_ctl_table;
72805 + ctl_table_no_const *lblcr_ctl_table;
72806 /* ip_vs_est */
72807 struct list_head est_list; /* estimator list */
72808 spinlock_t est_lock;
72809 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72810 index 80ffde3..968b0f4 100644
72811 --- a/include/net/irda/ircomm_tty.h
72812 +++ b/include/net/irda/ircomm_tty.h
72813 @@ -35,6 +35,7 @@
72814 #include <linux/termios.h>
72815 #include <linux/timer.h>
72816 #include <linux/tty.h> /* struct tty_struct */
72817 +#include <asm/local.h>
72818
72819 #include <net/irda/irias_object.h>
72820 #include <net/irda/ircomm_core.h>
72821 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72822 index cc7c197..9f2da2a 100644
72823 --- a/include/net/iucv/af_iucv.h
72824 +++ b/include/net/iucv/af_iucv.h
72825 @@ -141,7 +141,7 @@ struct iucv_sock {
72826 struct iucv_sock_list {
72827 struct hlist_head head;
72828 rwlock_t lock;
72829 - atomic_t autobind_name;
72830 + atomic_unchecked_t autobind_name;
72831 };
72832
72833 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72834 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72835 index df83f69..9b640b8 100644
72836 --- a/include/net/llc_c_ac.h
72837 +++ b/include/net/llc_c_ac.h
72838 @@ -87,7 +87,7 @@
72839 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72840 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72841
72842 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72843 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72844
72845 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72846 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72847 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72848 index 6ca3113..f8026dd 100644
72849 --- a/include/net/llc_c_ev.h
72850 +++ b/include/net/llc_c_ev.h
72851 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72852 return (struct llc_conn_state_ev *)skb->cb;
72853 }
72854
72855 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72856 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72857 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72858 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72859
72860 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72861 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72862 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72863 index 0e79cfb..f46db31 100644
72864 --- a/include/net/llc_c_st.h
72865 +++ b/include/net/llc_c_st.h
72866 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72867 u8 next_state;
72868 llc_conn_ev_qfyr_t *ev_qualifiers;
72869 llc_conn_action_t *ev_actions;
72870 -};
72871 +} __do_const;
72872
72873 struct llc_conn_state {
72874 u8 current_state;
72875 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72876 index 37a3bbd..55a4241 100644
72877 --- a/include/net/llc_s_ac.h
72878 +++ b/include/net/llc_s_ac.h
72879 @@ -23,7 +23,7 @@
72880 #define SAP_ACT_TEST_IND 9
72881
72882 /* All action functions must look like this */
72883 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72884 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72885
72886 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72887 struct sk_buff *skb);
72888 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72889 index 567c681..cd73ac0 100644
72890 --- a/include/net/llc_s_st.h
72891 +++ b/include/net/llc_s_st.h
72892 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72893 llc_sap_ev_t ev;
72894 u8 next_state;
72895 llc_sap_action_t *ev_actions;
72896 -};
72897 +} __do_const;
72898
72899 struct llc_sap_state {
72900 u8 curr_state;
72901 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72902 index ee50c5e..1bc3b1a 100644
72903 --- a/include/net/mac80211.h
72904 +++ b/include/net/mac80211.h
72905 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
72906 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72907 struct dentry *dir);
72908 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72909 -};
72910 +} __do_const;
72911
72912 static inline int rate_supported(struct ieee80211_sta *sta,
72913 enum ieee80211_band band,
72914 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72915 index 0dab173..1b76af0 100644
72916 --- a/include/net/neighbour.h
72917 +++ b/include/net/neighbour.h
72918 @@ -123,7 +123,7 @@ struct neigh_ops {
72919 void (*error_report)(struct neighbour *, struct sk_buff *);
72920 int (*output)(struct neighbour *, struct sk_buff *);
72921 int (*connected_output)(struct neighbour *, struct sk_buff *);
72922 -};
72923 +} __do_const;
72924
72925 struct pneigh_entry {
72926 struct pneigh_entry *next;
72927 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72928 index de644bc..dfbcc4c 100644
72929 --- a/include/net/net_namespace.h
72930 +++ b/include/net/net_namespace.h
72931 @@ -115,7 +115,7 @@ struct net {
72932 #endif
72933 struct netns_ipvs *ipvs;
72934 struct sock *diag_nlsk;
72935 - atomic_t rt_genid;
72936 + atomic_unchecked_t rt_genid;
72937 };
72938
72939 /*
72940 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72941 #define __net_init __init
72942 #define __net_exit __exit_refok
72943 #define __net_initdata __initdata
72944 +#ifdef CONSTIFY_PLUGIN
72945 #define __net_initconst __initconst
72946 +#else
72947 +#define __net_initconst __initdata
72948 +#endif
72949 #endif
72950
72951 struct pernet_operations {
72952 @@ -282,7 +286,7 @@ struct pernet_operations {
72953 void (*exit_batch)(struct list_head *net_exit_list);
72954 int *id;
72955 size_t size;
72956 -};
72957 +} __do_const;
72958
72959 /*
72960 * Use these carefully. If you implement a network device and it
72961 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72962
72963 static inline int rt_genid(struct net *net)
72964 {
72965 - return atomic_read(&net->rt_genid);
72966 + return atomic_read_unchecked(&net->rt_genid);
72967 }
72968
72969 static inline void rt_genid_bump(struct net *net)
72970 {
72971 - atomic_inc(&net->rt_genid);
72972 + atomic_inc_unchecked(&net->rt_genid);
72973 }
72974
72975 #endif /* __NET_NET_NAMESPACE_H */
72976 diff --git a/include/net/netdma.h b/include/net/netdma.h
72977 index 8ba8ce2..99b7fff 100644
72978 --- a/include/net/netdma.h
72979 +++ b/include/net/netdma.h
72980 @@ -24,7 +24,7 @@
72981 #include <linux/dmaengine.h>
72982 #include <linux/skbuff.h>
72983
72984 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72985 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72986 struct sk_buff *skb, int offset, struct iovec *to,
72987 size_t len, struct dma_pinned_list *pinned_list);
72988
72989 diff --git a/include/net/netlink.h b/include/net/netlink.h
72990 index 9690b0f..87aded7 100644
72991 --- a/include/net/netlink.h
72992 +++ b/include/net/netlink.h
72993 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72994 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72995 {
72996 if (mark)
72997 - skb_trim(skb, (unsigned char *) mark - skb->data);
72998 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72999 }
73000
73001 /**
73002 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
73003 index 923cb20..deae816 100644
73004 --- a/include/net/netns/conntrack.h
73005 +++ b/include/net/netns/conntrack.h
73006 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
73007 struct nf_proto_net {
73008 #ifdef CONFIG_SYSCTL
73009 struct ctl_table_header *ctl_table_header;
73010 - struct ctl_table *ctl_table;
73011 + ctl_table_no_const *ctl_table;
73012 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
73013 struct ctl_table_header *ctl_compat_header;
73014 - struct ctl_table *ctl_compat_table;
73015 + ctl_table_no_const *ctl_compat_table;
73016 #endif
73017 #endif
73018 unsigned int users;
73019 @@ -58,7 +58,7 @@ struct nf_ip_net {
73020 struct nf_icmp_net icmpv6;
73021 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
73022 struct ctl_table_header *ctl_table_header;
73023 - struct ctl_table *ctl_table;
73024 + ctl_table_no_const *ctl_table;
73025 #endif
73026 };
73027
73028 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
73029 index 2ae2b83..dbdc85e 100644
73030 --- a/include/net/netns/ipv4.h
73031 +++ b/include/net/netns/ipv4.h
73032 @@ -64,7 +64,7 @@ struct netns_ipv4 {
73033 kgid_t sysctl_ping_group_range[2];
73034 long sysctl_tcp_mem[3];
73035
73036 - atomic_t dev_addr_genid;
73037 + atomic_unchecked_t dev_addr_genid;
73038
73039 #ifdef CONFIG_IP_MROUTE
73040 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73041 diff --git a/include/net/protocol.h b/include/net/protocol.h
73042 index 047c047..b9dad15 100644
73043 --- a/include/net/protocol.h
73044 +++ b/include/net/protocol.h
73045 @@ -44,7 +44,7 @@ struct net_protocol {
73046 void (*err_handler)(struct sk_buff *skb, u32 info);
73047 unsigned int no_policy:1,
73048 netns_ok:1;
73049 -};
73050 +} __do_const;
73051
73052 #if IS_ENABLED(CONFIG_IPV6)
73053 struct inet6_protocol {
73054 @@ -57,7 +57,7 @@ struct inet6_protocol {
73055 u8 type, u8 code, int offset,
73056 __be32 info);
73057 unsigned int flags; /* INET6_PROTO_xxx */
73058 -};
73059 +} __do_const;
73060
73061 #define INET6_PROTO_NOPOLICY 0x1
73062 #define INET6_PROTO_FINAL 0x2
73063 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73064 index 5a15fab..d799ea7 100644
73065 --- a/include/net/rtnetlink.h
73066 +++ b/include/net/rtnetlink.h
73067 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73068 const struct net_device *dev);
73069 unsigned int (*get_num_tx_queues)(void);
73070 unsigned int (*get_num_rx_queues)(void);
73071 -};
73072 +} __do_const;
73073
73074 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73075 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73076 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73077 index 7fdf298..197e9f7 100644
73078 --- a/include/net/sctp/sctp.h
73079 +++ b/include/net/sctp/sctp.h
73080 @@ -330,9 +330,9 @@ do { \
73081
73082 #else /* SCTP_DEBUG */
73083
73084 -#define SCTP_DEBUG_PRINTK(whatever...)
73085 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73086 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73087 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73088 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73089 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73090 #define SCTP_ENABLE_DEBUG
73091 #define SCTP_DISABLE_DEBUG
73092 #define SCTP_ASSERT(expr, str, func)
73093 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73094 index 2a82d13..62a31c2 100644
73095 --- a/include/net/sctp/sm.h
73096 +++ b/include/net/sctp/sm.h
73097 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73098 typedef struct {
73099 sctp_state_fn_t *fn;
73100 const char *name;
73101 -} sctp_sm_table_entry_t;
73102 +} __do_const sctp_sm_table_entry_t;
73103
73104 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73105 * currently in use.
73106 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73107 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73108
73109 /* Extern declarations for major data structures. */
73110 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73111 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73112
73113
73114 /* Get the size of a DATA chunk payload. */
73115 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73116 index fdeb85a..1329d95 100644
73117 --- a/include/net/sctp/structs.h
73118 +++ b/include/net/sctp/structs.h
73119 @@ -517,7 +517,7 @@ struct sctp_pf {
73120 struct sctp_association *asoc);
73121 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73122 struct sctp_af *af;
73123 -};
73124 +} __do_const;
73125
73126
73127 /* Structure to track chunk fragments that have been acked, but peer
73128 diff --git a/include/net/sock.h b/include/net/sock.h
73129 index 25afaa0..8bb0070 100644
73130 --- a/include/net/sock.h
73131 +++ b/include/net/sock.h
73132 @@ -322,7 +322,7 @@ struct sock {
73133 #ifdef CONFIG_RPS
73134 __u32 sk_rxhash;
73135 #endif
73136 - atomic_t sk_drops;
73137 + atomic_unchecked_t sk_drops;
73138 int sk_rcvbuf;
73139
73140 struct sk_filter __rcu *sk_filter;
73141 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73142 }
73143
73144 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73145 - char __user *from, char *to,
73146 + char __user *from, unsigned char *to,
73147 int copy, int offset)
73148 {
73149 if (skb->ip_summed == CHECKSUM_NONE) {
73150 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73151 }
73152 }
73153
73154 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73155 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73156
73157 /**
73158 * sk_page_frag - return an appropriate page_frag
73159 diff --git a/include/net/tcp.h b/include/net/tcp.h
73160 index aed42c7..43890c6 100644
73161 --- a/include/net/tcp.h
73162 +++ b/include/net/tcp.h
73163 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73164 extern void tcp_xmit_retransmit_queue(struct sock *);
73165 extern void tcp_simple_retransmit(struct sock *);
73166 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73167 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73168 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73169
73170 extern void tcp_send_probe0(struct sock *);
73171 extern void tcp_send_partial(struct sock *);
73172 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
73173 struct inet6_skb_parm h6;
73174 #endif
73175 } header; /* For incoming frames */
73176 - __u32 seq; /* Starting sequence number */
73177 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73178 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73179 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73180 __u32 when; /* used to compute rtt's */
73181 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73182
73183 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
73184
73185 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73186 /* 1 byte hole */
73187 - __u32 ack_seq; /* Sequence number ACK'd */
73188 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73189 };
73190
73191 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73192 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73193 index 63445ed..d6fc34f 100644
73194 --- a/include/net/xfrm.h
73195 +++ b/include/net/xfrm.h
73196 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73197 struct net_device *dev,
73198 const struct flowi *fl);
73199 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73200 -};
73201 +} __do_const;
73202
73203 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73204 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73205 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73206 struct sk_buff *skb);
73207 int (*transport_finish)(struct sk_buff *skb,
73208 int async);
73209 -};
73210 +} __do_const;
73211
73212 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73213 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73214 @@ -423,7 +423,7 @@ struct xfrm_mode {
73215 struct module *owner;
73216 unsigned int encap;
73217 int flags;
73218 -};
73219 +} __do_const;
73220
73221 /* Flags for xfrm_mode. */
73222 enum {
73223 @@ -514,7 +514,7 @@ struct xfrm_policy {
73224 struct timer_list timer;
73225
73226 struct flow_cache_object flo;
73227 - atomic_t genid;
73228 + atomic_unchecked_t genid;
73229 u32 priority;
73230 u32 index;
73231 struct xfrm_mark mark;
73232 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73233 index 1a046b1..ee0bef0 100644
73234 --- a/include/rdma/iw_cm.h
73235 +++ b/include/rdma/iw_cm.h
73236 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73237 int backlog);
73238
73239 int (*destroy_listen)(struct iw_cm_id *cm_id);
73240 -};
73241 +} __no_const;
73242
73243 /**
73244 * iw_create_cm_id - Create an IW CM identifier.
73245 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73246 index 399162b..b337f1a 100644
73247 --- a/include/scsi/libfc.h
73248 +++ b/include/scsi/libfc.h
73249 @@ -762,6 +762,7 @@ struct libfc_function_template {
73250 */
73251 void (*disc_stop_final) (struct fc_lport *);
73252 };
73253 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73254
73255 /**
73256 * struct fc_disc - Discovery context
73257 @@ -866,7 +867,7 @@ struct fc_lport {
73258 struct fc_vport *vport;
73259
73260 /* Operational Information */
73261 - struct libfc_function_template tt;
73262 + libfc_function_template_no_const tt;
73263 u8 link_up;
73264 u8 qfull;
73265 enum fc_lport_state state;
73266 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73267 index e65c62e..aa2e5a2 100644
73268 --- a/include/scsi/scsi_device.h
73269 +++ b/include/scsi/scsi_device.h
73270 @@ -170,9 +170,9 @@ struct scsi_device {
73271 unsigned int max_device_blocked; /* what device_blocked counts down from */
73272 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73273
73274 - atomic_t iorequest_cnt;
73275 - atomic_t iodone_cnt;
73276 - atomic_t ioerr_cnt;
73277 + atomic_unchecked_t iorequest_cnt;
73278 + atomic_unchecked_t iodone_cnt;
73279 + atomic_unchecked_t ioerr_cnt;
73280
73281 struct device sdev_gendev,
73282 sdev_dev;
73283 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73284 index b797e8f..8e2c3aa 100644
73285 --- a/include/scsi/scsi_transport_fc.h
73286 +++ b/include/scsi/scsi_transport_fc.h
73287 @@ -751,7 +751,8 @@ struct fc_function_template {
73288 unsigned long show_host_system_hostname:1;
73289
73290 unsigned long disable_target_scan:1;
73291 -};
73292 +} __do_const;
73293 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73294
73295
73296 /**
73297 diff --git a/include/sound/soc.h b/include/sound/soc.h
73298 index bc56738..a4be132 100644
73299 --- a/include/sound/soc.h
73300 +++ b/include/sound/soc.h
73301 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73302 /* probe ordering - for components with runtime dependencies */
73303 int probe_order;
73304 int remove_order;
73305 -};
73306 +} __do_const;
73307
73308 /* SoC platform interface */
73309 struct snd_soc_platform_driver {
73310 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73311 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73312 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73313 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73314 -};
73315 +} __do_const;
73316
73317 struct snd_soc_platform {
73318 const char *name;
73319 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73320 index 663e34a..91b306a 100644
73321 --- a/include/target/target_core_base.h
73322 +++ b/include/target/target_core_base.h
73323 @@ -654,7 +654,7 @@ struct se_device {
73324 spinlock_t stats_lock;
73325 /* Active commands on this virtual SE device */
73326 atomic_t simple_cmds;
73327 - atomic_t dev_ordered_id;
73328 + atomic_unchecked_t dev_ordered_id;
73329 atomic_t dev_ordered_sync;
73330 atomic_t dev_qf_count;
73331 int export_count;
73332 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73333 new file mode 100644
73334 index 0000000..fb634b7
73335 --- /dev/null
73336 +++ b/include/trace/events/fs.h
73337 @@ -0,0 +1,53 @@
73338 +#undef TRACE_SYSTEM
73339 +#define TRACE_SYSTEM fs
73340 +
73341 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73342 +#define _TRACE_FS_H
73343 +
73344 +#include <linux/fs.h>
73345 +#include <linux/tracepoint.h>
73346 +
73347 +TRACE_EVENT(do_sys_open,
73348 +
73349 + TP_PROTO(const char *filename, int flags, int mode),
73350 +
73351 + TP_ARGS(filename, flags, mode),
73352 +
73353 + TP_STRUCT__entry(
73354 + __string( filename, filename )
73355 + __field( int, flags )
73356 + __field( int, mode )
73357 + ),
73358 +
73359 + TP_fast_assign(
73360 + __assign_str(filename, filename);
73361 + __entry->flags = flags;
73362 + __entry->mode = mode;
73363 + ),
73364 +
73365 + TP_printk("\"%s\" %x %o",
73366 + __get_str(filename), __entry->flags, __entry->mode)
73367 +);
73368 +
73369 +TRACE_EVENT(open_exec,
73370 +
73371 + TP_PROTO(const char *filename),
73372 +
73373 + TP_ARGS(filename),
73374 +
73375 + TP_STRUCT__entry(
73376 + __string( filename, filename )
73377 + ),
73378 +
73379 + TP_fast_assign(
73380 + __assign_str(filename, filename);
73381 + ),
73382 +
73383 + TP_printk("\"%s\"",
73384 + __get_str(filename))
73385 +);
73386 +
73387 +#endif /* _TRACE_FS_H */
73388 +
73389 +/* This part must be outside protection */
73390 +#include <trace/define_trace.h>
73391 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73392 index 1c09820..7f5ec79 100644
73393 --- a/include/trace/events/irq.h
73394 +++ b/include/trace/events/irq.h
73395 @@ -36,7 +36,7 @@ struct softirq_action;
73396 */
73397 TRACE_EVENT(irq_handler_entry,
73398
73399 - TP_PROTO(int irq, struct irqaction *action),
73400 + TP_PROTO(int irq, const struct irqaction *action),
73401
73402 TP_ARGS(irq, action),
73403
73404 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73405 */
73406 TRACE_EVENT(irq_handler_exit,
73407
73408 - TP_PROTO(int irq, struct irqaction *action, int ret),
73409 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73410
73411 TP_ARGS(irq, action, ret),
73412
73413 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73414 index 7caf44c..23c6f27 100644
73415 --- a/include/uapi/linux/a.out.h
73416 +++ b/include/uapi/linux/a.out.h
73417 @@ -39,6 +39,14 @@ enum machine_type {
73418 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73419 };
73420
73421 +/* Constants for the N_FLAGS field */
73422 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73423 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73424 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73425 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73426 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73427 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73428 +
73429 #if !defined (N_MAGIC)
73430 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73431 #endif
73432 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73433 index d876736..ccce5c0 100644
73434 --- a/include/uapi/linux/byteorder/little_endian.h
73435 +++ b/include/uapi/linux/byteorder/little_endian.h
73436 @@ -42,51 +42,51 @@
73437
73438 static inline __le64 __cpu_to_le64p(const __u64 *p)
73439 {
73440 - return (__force __le64)*p;
73441 + return (__force const __le64)*p;
73442 }
73443 -static inline __u64 __le64_to_cpup(const __le64 *p)
73444 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73445 {
73446 - return (__force __u64)*p;
73447 + return (__force const __u64)*p;
73448 }
73449 static inline __le32 __cpu_to_le32p(const __u32 *p)
73450 {
73451 - return (__force __le32)*p;
73452 + return (__force const __le32)*p;
73453 }
73454 static inline __u32 __le32_to_cpup(const __le32 *p)
73455 {
73456 - return (__force __u32)*p;
73457 + return (__force const __u32)*p;
73458 }
73459 static inline __le16 __cpu_to_le16p(const __u16 *p)
73460 {
73461 - return (__force __le16)*p;
73462 + return (__force const __le16)*p;
73463 }
73464 static inline __u16 __le16_to_cpup(const __le16 *p)
73465 {
73466 - return (__force __u16)*p;
73467 + return (__force const __u16)*p;
73468 }
73469 static inline __be64 __cpu_to_be64p(const __u64 *p)
73470 {
73471 - return (__force __be64)__swab64p(p);
73472 + return (__force const __be64)__swab64p(p);
73473 }
73474 static inline __u64 __be64_to_cpup(const __be64 *p)
73475 {
73476 - return __swab64p((__u64 *)p);
73477 + return __swab64p((const __u64 *)p);
73478 }
73479 static inline __be32 __cpu_to_be32p(const __u32 *p)
73480 {
73481 - return (__force __be32)__swab32p(p);
73482 + return (__force const __be32)__swab32p(p);
73483 }
73484 -static inline __u32 __be32_to_cpup(const __be32 *p)
73485 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73486 {
73487 - return __swab32p((__u32 *)p);
73488 + return __swab32p((const __u32 *)p);
73489 }
73490 static inline __be16 __cpu_to_be16p(const __u16 *p)
73491 {
73492 - return (__force __be16)__swab16p(p);
73493 + return (__force const __be16)__swab16p(p);
73494 }
73495 static inline __u16 __be16_to_cpup(const __be16 *p)
73496 {
73497 - return __swab16p((__u16 *)p);
73498 + return __swab16p((const __u16 *)p);
73499 }
73500 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73501 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73502 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73503 index 126a817..d522bd1 100644
73504 --- a/include/uapi/linux/elf.h
73505 +++ b/include/uapi/linux/elf.h
73506 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73507 #define PT_GNU_EH_FRAME 0x6474e550
73508
73509 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73510 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73511 +
73512 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73513 +
73514 +/* Constants for the e_flags field */
73515 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73516 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73517 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73518 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73519 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73520 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73521
73522 /*
73523 * Extended Numbering
73524 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73525 #define DT_DEBUG 21
73526 #define DT_TEXTREL 22
73527 #define DT_JMPREL 23
73528 +#define DT_FLAGS 30
73529 + #define DF_TEXTREL 0x00000004
73530 #define DT_ENCODING 32
73531 #define OLD_DT_LOOS 0x60000000
73532 #define DT_LOOS 0x6000000d
73533 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73534 #define PF_W 0x2
73535 #define PF_X 0x1
73536
73537 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73538 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73539 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73540 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73541 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73542 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73543 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73544 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73545 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73546 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73547 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73548 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73549 +
73550 typedef struct elf32_phdr{
73551 Elf32_Word p_type;
73552 Elf32_Off p_offset;
73553 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73554 #define EI_OSABI 7
73555 #define EI_PAD 8
73556
73557 +#define EI_PAX 14
73558 +
73559 #define ELFMAG0 0x7f /* EI_MAG */
73560 #define ELFMAG1 'E'
73561 #define ELFMAG2 'L'
73562 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73563 index aa169c4..6a2771d 100644
73564 --- a/include/uapi/linux/personality.h
73565 +++ b/include/uapi/linux/personality.h
73566 @@ -30,6 +30,7 @@ enum {
73567 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73568 ADDR_NO_RANDOMIZE | \
73569 ADDR_COMPAT_LAYOUT | \
73570 + ADDR_LIMIT_3GB | \
73571 MMAP_PAGE_ZERO)
73572
73573 /*
73574 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73575 index 7530e74..e714828 100644
73576 --- a/include/uapi/linux/screen_info.h
73577 +++ b/include/uapi/linux/screen_info.h
73578 @@ -43,7 +43,8 @@ struct screen_info {
73579 __u16 pages; /* 0x32 */
73580 __u16 vesa_attributes; /* 0x34 */
73581 __u32 capabilities; /* 0x36 */
73582 - __u8 _reserved[6]; /* 0x3a */
73583 + __u16 vesapm_size; /* 0x3a */
73584 + __u8 _reserved[4]; /* 0x3c */
73585 } __attribute__((packed));
73586
73587 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73588 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73589 index 0e011eb..82681b1 100644
73590 --- a/include/uapi/linux/swab.h
73591 +++ b/include/uapi/linux/swab.h
73592 @@ -43,7 +43,7 @@
73593 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73594 */
73595
73596 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73597 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73598 {
73599 #ifdef __HAVE_BUILTIN_BSWAP16__
73600 return __builtin_bswap16(val);
73601 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73602 #endif
73603 }
73604
73605 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73606 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73607 {
73608 #ifdef __HAVE_BUILTIN_BSWAP32__
73609 return __builtin_bswap32(val);
73610 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73611 #endif
73612 }
73613
73614 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73615 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73616 {
73617 #ifdef __HAVE_BUILTIN_BSWAP64__
73618 return __builtin_bswap64(val);
73619 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73620 index 6d67213..8dab561 100644
73621 --- a/include/uapi/linux/sysctl.h
73622 +++ b/include/uapi/linux/sysctl.h
73623 @@ -155,7 +155,11 @@ enum
73624 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73625 };
73626
73627 -
73628 +#ifdef CONFIG_PAX_SOFTMODE
73629 +enum {
73630 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73631 +};
73632 +#endif
73633
73634 /* CTL_VM names: */
73635 enum
73636 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73637 index 26607bd..588b65f 100644
73638 --- a/include/uapi/linux/xattr.h
73639 +++ b/include/uapi/linux/xattr.h
73640 @@ -60,5 +60,9 @@
73641 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73642 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73643
73644 +/* User namespace */
73645 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73646 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73647 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73648
73649 #endif /* _UAPI_LINUX_XATTR_H */
73650 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73651 index f9466fa..f4e2b81 100644
73652 --- a/include/video/udlfb.h
73653 +++ b/include/video/udlfb.h
73654 @@ -53,10 +53,10 @@ struct dlfb_data {
73655 u32 pseudo_palette[256];
73656 int blank_mode; /*one of FB_BLANK_ */
73657 /* blit-only rendering path metrics, exposed through sysfs */
73658 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73659 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73660 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73661 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73662 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73663 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73664 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73665 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73666 };
73667
73668 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73669 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73670 index 0993a22..32ba2fe 100644
73671 --- a/include/video/uvesafb.h
73672 +++ b/include/video/uvesafb.h
73673 @@ -177,6 +177,7 @@ struct uvesafb_par {
73674 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73675 u8 pmi_setpal; /* PMI for palette changes */
73676 u16 *pmi_base; /* protected mode interface location */
73677 + u8 *pmi_code; /* protected mode code location */
73678 void *pmi_start;
73679 void *pmi_pal;
73680 u8 *vbe_state_orig; /*
73681 diff --git a/init/Kconfig b/init/Kconfig
73682 index be8b7f5..1eeca9b 100644
73683 --- a/init/Kconfig
73684 +++ b/init/Kconfig
73685 @@ -990,6 +990,7 @@ endif # CGROUPS
73686
73687 config CHECKPOINT_RESTORE
73688 bool "Checkpoint/restore support" if EXPERT
73689 + depends on !GRKERNSEC
73690 default n
73691 help
73692 Enables additional kernel features in a sake of checkpoint/restore.
73693 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
73694
73695 config COMPAT_BRK
73696 bool "Disable heap randomization"
73697 - default y
73698 + default n
73699 help
73700 Randomizing heap placement makes heap exploits harder, but it
73701 also breaks ancient binaries (including anything libc5 based).
73702 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
73703 config STOP_MACHINE
73704 bool
73705 default y
73706 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73707 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73708 help
73709 Need stop_machine() primitive.
73710
73711 diff --git a/init/Makefile b/init/Makefile
73712 index 7bc47ee..6da2dc7 100644
73713 --- a/init/Makefile
73714 +++ b/init/Makefile
73715 @@ -2,6 +2,9 @@
73716 # Makefile for the linux kernel.
73717 #
73718
73719 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73720 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73721 +
73722 obj-y := main.o version.o mounts.o
73723 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73724 obj-y += noinitramfs.o
73725 diff --git a/init/do_mounts.c b/init/do_mounts.c
73726 index 1d1b634..a1c810f 100644
73727 --- a/init/do_mounts.c
73728 +++ b/init/do_mounts.c
73729 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73730 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73731 {
73732 struct super_block *s;
73733 - int err = sys_mount(name, "/root", fs, flags, data);
73734 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73735 if (err)
73736 return err;
73737
73738 - sys_chdir("/root");
73739 + sys_chdir((const char __force_user *)"/root");
73740 s = current->fs->pwd.dentry->d_sb;
73741 ROOT_DEV = s->s_dev;
73742 printk(KERN_INFO
73743 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73744 va_start(args, fmt);
73745 vsprintf(buf, fmt, args);
73746 va_end(args);
73747 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73748 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73749 if (fd >= 0) {
73750 sys_ioctl(fd, FDEJECT, 0);
73751 sys_close(fd);
73752 }
73753 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73754 - fd = sys_open("/dev/console", O_RDWR, 0);
73755 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73756 if (fd >= 0) {
73757 sys_ioctl(fd, TCGETS, (long)&termios);
73758 termios.c_lflag &= ~ICANON;
73759 sys_ioctl(fd, TCSETSF, (long)&termios);
73760 - sys_read(fd, &c, 1);
73761 + sys_read(fd, (char __user *)&c, 1);
73762 termios.c_lflag |= ICANON;
73763 sys_ioctl(fd, TCSETSF, (long)&termios);
73764 sys_close(fd);
73765 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73766 mount_root();
73767 out:
73768 devtmpfs_mount("dev");
73769 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73770 - sys_chroot(".");
73771 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73772 + sys_chroot((const char __force_user *)".");
73773 }
73774 diff --git a/init/do_mounts.h b/init/do_mounts.h
73775 index f5b978a..69dbfe8 100644
73776 --- a/init/do_mounts.h
73777 +++ b/init/do_mounts.h
73778 @@ -15,15 +15,15 @@ extern int root_mountflags;
73779
73780 static inline int create_dev(char *name, dev_t dev)
73781 {
73782 - sys_unlink(name);
73783 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73784 + sys_unlink((char __force_user *)name);
73785 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73786 }
73787
73788 #if BITS_PER_LONG == 32
73789 static inline u32 bstat(char *name)
73790 {
73791 struct stat64 stat;
73792 - if (sys_stat64(name, &stat) != 0)
73793 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73794 return 0;
73795 if (!S_ISBLK(stat.st_mode))
73796 return 0;
73797 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73798 static inline u32 bstat(char *name)
73799 {
73800 struct stat stat;
73801 - if (sys_newstat(name, &stat) != 0)
73802 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73803 return 0;
73804 if (!S_ISBLK(stat.st_mode))
73805 return 0;
73806 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73807 index f9acf71..1e19144 100644
73808 --- a/init/do_mounts_initrd.c
73809 +++ b/init/do_mounts_initrd.c
73810 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73811 create_dev("/dev/root.old", Root_RAM0);
73812 /* mount initrd on rootfs' /root */
73813 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73814 - sys_mkdir("/old", 0700);
73815 - sys_chdir("/old");
73816 + sys_mkdir((const char __force_user *)"/old", 0700);
73817 + sys_chdir((const char __force_user *)"/old");
73818
73819 /*
73820 * In case that a resume from disk is carried out by linuxrc or one of
73821 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
73822 current->flags &= ~PF_FREEZER_SKIP;
73823
73824 /* move initrd to rootfs' /old */
73825 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73826 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73827 /* switch root and cwd back to / of rootfs */
73828 - sys_chroot("..");
73829 + sys_chroot((const char __force_user *)"..");
73830
73831 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73832 - sys_chdir("/old");
73833 + sys_chdir((const char __force_user *)"/old");
73834 return;
73835 }
73836
73837 - sys_chdir("/");
73838 + sys_chdir((const char __force_user *)"/");
73839 ROOT_DEV = new_decode_dev(real_root_dev);
73840 mount_root();
73841
73842 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73843 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73844 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73845 if (!error)
73846 printk("okay\n");
73847 else {
73848 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73849 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73850 if (error == -ENOENT)
73851 printk("/initrd does not exist. Ignored.\n");
73852 else
73853 printk("failed\n");
73854 printk(KERN_NOTICE "Unmounting old root\n");
73855 - sys_umount("/old", MNT_DETACH);
73856 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73857 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73858 if (fd < 0) {
73859 error = fd;
73860 @@ -120,11 +120,11 @@ int __init initrd_load(void)
73861 * mounted in the normal path.
73862 */
73863 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73864 - sys_unlink("/initrd.image");
73865 + sys_unlink((const char __force_user *)"/initrd.image");
73866 handle_initrd();
73867 return 1;
73868 }
73869 }
73870 - sys_unlink("/initrd.image");
73871 + sys_unlink((const char __force_user *)"/initrd.image");
73872 return 0;
73873 }
73874 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73875 index 8cb6db5..d729f50 100644
73876 --- a/init/do_mounts_md.c
73877 +++ b/init/do_mounts_md.c
73878 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73879 partitioned ? "_d" : "", minor,
73880 md_setup_args[ent].device_names);
73881
73882 - fd = sys_open(name, 0, 0);
73883 + fd = sys_open((char __force_user *)name, 0, 0);
73884 if (fd < 0) {
73885 printk(KERN_ERR "md: open failed - cannot start "
73886 "array %s\n", name);
73887 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73888 * array without it
73889 */
73890 sys_close(fd);
73891 - fd = sys_open(name, 0, 0);
73892 + fd = sys_open((char __force_user *)name, 0, 0);
73893 sys_ioctl(fd, BLKRRPART, 0);
73894 }
73895 sys_close(fd);
73896 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73897
73898 wait_for_device_probe();
73899
73900 - fd = sys_open("/dev/md0", 0, 0);
73901 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73902 if (fd >= 0) {
73903 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73904 sys_close(fd);
73905 diff --git a/init/init_task.c b/init/init_task.c
73906 index 8b2f399..f0797c9 100644
73907 --- a/init/init_task.c
73908 +++ b/init/init_task.c
73909 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
73910 * Initial thread structure. Alignment of this is handled by a special
73911 * linker map entry.
73912 */
73913 +#ifdef CONFIG_X86
73914 +union thread_union init_thread_union __init_task_data;
73915 +#else
73916 union thread_union init_thread_union __init_task_data =
73917 { INIT_THREAD_INFO(init_task) };
73918 +#endif
73919 diff --git a/init/initramfs.c b/init/initramfs.c
73920 index 84c6bf1..8899338 100644
73921 --- a/init/initramfs.c
73922 +++ b/init/initramfs.c
73923 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73924 }
73925 }
73926
73927 -static long __init do_utime(char *filename, time_t mtime)
73928 +static long __init do_utime(char __force_user *filename, time_t mtime)
73929 {
73930 struct timespec t[2];
73931
73932 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73933 struct dir_entry *de, *tmp;
73934 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73935 list_del(&de->list);
73936 - do_utime(de->name, de->mtime);
73937 + do_utime((char __force_user *)de->name, de->mtime);
73938 kfree(de->name);
73939 kfree(de);
73940 }
73941 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73942 if (nlink >= 2) {
73943 char *old = find_link(major, minor, ino, mode, collected);
73944 if (old)
73945 - return (sys_link(old, collected) < 0) ? -1 : 1;
73946 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73947 }
73948 return 0;
73949 }
73950 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73951 {
73952 struct stat st;
73953
73954 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73955 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73956 if (S_ISDIR(st.st_mode))
73957 - sys_rmdir(path);
73958 + sys_rmdir((char __force_user *)path);
73959 else
73960 - sys_unlink(path);
73961 + sys_unlink((char __force_user *)path);
73962 }
73963 }
73964
73965 @@ -315,7 +315,7 @@ static int __init do_name(void)
73966 int openflags = O_WRONLY|O_CREAT;
73967 if (ml != 1)
73968 openflags |= O_TRUNC;
73969 - wfd = sys_open(collected, openflags, mode);
73970 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73971
73972 if (wfd >= 0) {
73973 sys_fchown(wfd, uid, gid);
73974 @@ -327,17 +327,17 @@ static int __init do_name(void)
73975 }
73976 }
73977 } else if (S_ISDIR(mode)) {
73978 - sys_mkdir(collected, mode);
73979 - sys_chown(collected, uid, gid);
73980 - sys_chmod(collected, mode);
73981 + sys_mkdir((char __force_user *)collected, mode);
73982 + sys_chown((char __force_user *)collected, uid, gid);
73983 + sys_chmod((char __force_user *)collected, mode);
73984 dir_add(collected, mtime);
73985 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73986 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73987 if (maybe_link() == 0) {
73988 - sys_mknod(collected, mode, rdev);
73989 - sys_chown(collected, uid, gid);
73990 - sys_chmod(collected, mode);
73991 - do_utime(collected, mtime);
73992 + sys_mknod((char __force_user *)collected, mode, rdev);
73993 + sys_chown((char __force_user *)collected, uid, gid);
73994 + sys_chmod((char __force_user *)collected, mode);
73995 + do_utime((char __force_user *)collected, mtime);
73996 }
73997 }
73998 return 0;
73999 @@ -346,15 +346,15 @@ static int __init do_name(void)
74000 static int __init do_copy(void)
74001 {
74002 if (count >= body_len) {
74003 - sys_write(wfd, victim, body_len);
74004 + sys_write(wfd, (char __force_user *)victim, body_len);
74005 sys_close(wfd);
74006 - do_utime(vcollected, mtime);
74007 + do_utime((char __force_user *)vcollected, mtime);
74008 kfree(vcollected);
74009 eat(body_len);
74010 state = SkipIt;
74011 return 0;
74012 } else {
74013 - sys_write(wfd, victim, count);
74014 + sys_write(wfd, (char __force_user *)victim, count);
74015 body_len -= count;
74016 eat(count);
74017 return 1;
74018 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
74019 {
74020 collected[N_ALIGN(name_len) + body_len] = '\0';
74021 clean_path(collected, 0);
74022 - sys_symlink(collected + N_ALIGN(name_len), collected);
74023 - sys_lchown(collected, uid, gid);
74024 - do_utime(collected, mtime);
74025 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
74026 + sys_lchown((char __force_user *)collected, uid, gid);
74027 + do_utime((char __force_user *)collected, mtime);
74028 state = SkipIt;
74029 next_state = Reset;
74030 return 0;
74031 diff --git a/init/main.c b/init/main.c
74032 index cee4b5c..360e10a 100644
74033 --- a/init/main.c
74034 +++ b/init/main.c
74035 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
74036 extern void tc_init(void);
74037 #endif
74038
74039 +extern void grsecurity_init(void);
74040 +
74041 /*
74042 * Debug helper: via this flag we know that we are in 'early bootup code'
74043 * where only the boot processor is running with IRQ disabled. This means
74044 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
74045
74046 __setup("reset_devices", set_reset_devices);
74047
74048 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74049 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74050 +static int __init setup_grsec_proc_gid(char *str)
74051 +{
74052 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74053 + return 1;
74054 +}
74055 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74056 +#endif
74057 +
74058 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74059 +extern char pax_enter_kernel_user[];
74060 +extern char pax_exit_kernel_user[];
74061 +extern pgdval_t clone_pgd_mask;
74062 +#endif
74063 +
74064 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74065 +static int __init setup_pax_nouderef(char *str)
74066 +{
74067 +#ifdef CONFIG_X86_32
74068 + unsigned int cpu;
74069 + struct desc_struct *gdt;
74070 +
74071 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74072 + gdt = get_cpu_gdt_table(cpu);
74073 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74074 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74075 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74076 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74077 + }
74078 + loadsegment(ds, __KERNEL_DS);
74079 + loadsegment(es, __KERNEL_DS);
74080 + loadsegment(ss, __KERNEL_DS);
74081 +#else
74082 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74083 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74084 + clone_pgd_mask = ~(pgdval_t)0UL;
74085 +#endif
74086 +
74087 + return 0;
74088 +}
74089 +early_param("pax_nouderef", setup_pax_nouderef);
74090 +#endif
74091 +
74092 +#ifdef CONFIG_PAX_SOFTMODE
74093 +int pax_softmode;
74094 +
74095 +static int __init setup_pax_softmode(char *str)
74096 +{
74097 + get_option(&str, &pax_softmode);
74098 + return 1;
74099 +}
74100 +__setup("pax_softmode=", setup_pax_softmode);
74101 +#endif
74102 +
74103 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74104 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74105 static const char *panic_later, *panic_param;
74106 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
74107 {
74108 int count = preempt_count();
74109 int ret;
74110 + const char *msg1 = "", *msg2 = "";
74111
74112 if (initcall_debug)
74113 ret = do_one_initcall_debug(fn);
74114 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
74115 sprintf(msgbuf, "error code %d ", ret);
74116
74117 if (preempt_count() != count) {
74118 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
74119 + msg1 = " preemption imbalance";
74120 preempt_count() = count;
74121 }
74122 if (irqs_disabled()) {
74123 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74124 + msg2 = " disabled interrupts";
74125 local_irq_enable();
74126 }
74127 - if (msgbuf[0]) {
74128 - printk("initcall %pF returned with %s\n", fn, msgbuf);
74129 + if (msgbuf[0] || *msg1 || *msg2) {
74130 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
74131 }
74132
74133 return ret;
74134 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
74135 level, level,
74136 &repair_env_string);
74137
74138 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74139 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74140 do_one_initcall(*fn);
74141 +
74142 +#ifdef LATENT_ENTROPY_PLUGIN
74143 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74144 +#endif
74145 +
74146 + }
74147 }
74148
74149 static void __init do_initcalls(void)
74150 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
74151 {
74152 initcall_t *fn;
74153
74154 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74155 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74156 do_one_initcall(*fn);
74157 +
74158 +#ifdef LATENT_ENTROPY_PLUGIN
74159 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74160 +#endif
74161 +
74162 + }
74163 }
74164
74165 static int run_init_process(const char *init_filename)
74166 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
74167 do_basic_setup();
74168
74169 /* Open the /dev/console on the rootfs, this should never fail */
74170 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74171 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74172 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74173
74174 (void) sys_dup(0);
74175 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
74176 if (!ramdisk_execute_command)
74177 ramdisk_execute_command = "/init";
74178
74179 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74180 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74181 ramdisk_execute_command = NULL;
74182 prepare_namespace();
74183 }
74184
74185 + grsecurity_init();
74186 +
74187 /*
74188 * Ok, we have completed the initial bootup, and
74189 * we're essentially up and running. Get rid of the
74190 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74191 index 130dfec..cc88451 100644
74192 --- a/ipc/ipc_sysctl.c
74193 +++ b/ipc/ipc_sysctl.c
74194 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74195 static int proc_ipc_dointvec(ctl_table *table, int write,
74196 void __user *buffer, size_t *lenp, loff_t *ppos)
74197 {
74198 - struct ctl_table ipc_table;
74199 + ctl_table_no_const ipc_table;
74200
74201 memcpy(&ipc_table, table, sizeof(ipc_table));
74202 ipc_table.data = get_ipc(table);
74203 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74204 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74205 void __user *buffer, size_t *lenp, loff_t *ppos)
74206 {
74207 - struct ctl_table ipc_table;
74208 + ctl_table_no_const ipc_table;
74209
74210 memcpy(&ipc_table, table, sizeof(ipc_table));
74211 ipc_table.data = get_ipc(table);
74212 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74213 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74214 void __user *buffer, size_t *lenp, loff_t *ppos)
74215 {
74216 - struct ctl_table ipc_table;
74217 + ctl_table_no_const ipc_table;
74218 size_t lenp_bef = *lenp;
74219 int rc;
74220
74221 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74222 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74223 void __user *buffer, size_t *lenp, loff_t *ppos)
74224 {
74225 - struct ctl_table ipc_table;
74226 + ctl_table_no_const ipc_table;
74227 memcpy(&ipc_table, table, sizeof(ipc_table));
74228 ipc_table.data = get_ipc(table);
74229
74230 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74231 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74232 void __user *buffer, size_t *lenp, loff_t *ppos)
74233 {
74234 - struct ctl_table ipc_table;
74235 + ctl_table_no_const ipc_table;
74236 size_t lenp_bef = *lenp;
74237 int oldval;
74238 int rc;
74239 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74240 index 383d638..943fdbb 100644
74241 --- a/ipc/mq_sysctl.c
74242 +++ b/ipc/mq_sysctl.c
74243 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74244 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74245 void __user *buffer, size_t *lenp, loff_t *ppos)
74246 {
74247 - struct ctl_table mq_table;
74248 + ctl_table_no_const mq_table;
74249 memcpy(&mq_table, table, sizeof(mq_table));
74250 mq_table.data = get_mq(table);
74251
74252 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74253 index f3f40dc..ffe5a3a 100644
74254 --- a/ipc/mqueue.c
74255 +++ b/ipc/mqueue.c
74256 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74257 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74258 info->attr.mq_msgsize);
74259
74260 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74261 spin_lock(&mq_lock);
74262 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74263 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74264 diff --git a/ipc/msg.c b/ipc/msg.c
74265 index fede1d0..9778e0f8 100644
74266 --- a/ipc/msg.c
74267 +++ b/ipc/msg.c
74268 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74269 return security_msg_queue_associate(msq, msgflg);
74270 }
74271
74272 +static struct ipc_ops msg_ops = {
74273 + .getnew = newque,
74274 + .associate = msg_security,
74275 + .more_checks = NULL
74276 +};
74277 +
74278 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74279 {
74280 struct ipc_namespace *ns;
74281 - struct ipc_ops msg_ops;
74282 struct ipc_params msg_params;
74283
74284 ns = current->nsproxy->ipc_ns;
74285
74286 - msg_ops.getnew = newque;
74287 - msg_ops.associate = msg_security;
74288 - msg_ops.more_checks = NULL;
74289 -
74290 msg_params.key = key;
74291 msg_params.flg = msgflg;
74292
74293 diff --git a/ipc/sem.c b/ipc/sem.c
74294 index 58d31f1..cce7a55 100644
74295 --- a/ipc/sem.c
74296 +++ b/ipc/sem.c
74297 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74298 return 0;
74299 }
74300
74301 +static struct ipc_ops sem_ops = {
74302 + .getnew = newary,
74303 + .associate = sem_security,
74304 + .more_checks = sem_more_checks
74305 +};
74306 +
74307 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74308 {
74309 struct ipc_namespace *ns;
74310 - struct ipc_ops sem_ops;
74311 struct ipc_params sem_params;
74312
74313 ns = current->nsproxy->ipc_ns;
74314 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74315 if (nsems < 0 || nsems > ns->sc_semmsl)
74316 return -EINVAL;
74317
74318 - sem_ops.getnew = newary;
74319 - sem_ops.associate = sem_security;
74320 - sem_ops.more_checks = sem_more_checks;
74321 -
74322 sem_params.key = key;
74323 sem_params.flg = semflg;
74324 sem_params.u.nsems = nsems;
74325 diff --git a/ipc/shm.c b/ipc/shm.c
74326 index 4fa6d8f..55cff14 100644
74327 --- a/ipc/shm.c
74328 +++ b/ipc/shm.c
74329 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74330 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74331 #endif
74332
74333 +#ifdef CONFIG_GRKERNSEC
74334 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74335 + const time_t shm_createtime, const kuid_t cuid,
74336 + const int shmid);
74337 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74338 + const time_t shm_createtime);
74339 +#endif
74340 +
74341 void shm_init_ns(struct ipc_namespace *ns)
74342 {
74343 ns->shm_ctlmax = SHMMAX;
74344 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74345 shp->shm_lprid = 0;
74346 shp->shm_atim = shp->shm_dtim = 0;
74347 shp->shm_ctim = get_seconds();
74348 +#ifdef CONFIG_GRKERNSEC
74349 + {
74350 + struct timespec timeval;
74351 + do_posix_clock_monotonic_gettime(&timeval);
74352 +
74353 + shp->shm_createtime = timeval.tv_sec;
74354 + }
74355 +#endif
74356 shp->shm_segsz = size;
74357 shp->shm_nattch = 0;
74358 shp->shm_file = file;
74359 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74360 return 0;
74361 }
74362
74363 +static struct ipc_ops shm_ops = {
74364 + .getnew = newseg,
74365 + .associate = shm_security,
74366 + .more_checks = shm_more_checks
74367 +};
74368 +
74369 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74370 {
74371 struct ipc_namespace *ns;
74372 - struct ipc_ops shm_ops;
74373 struct ipc_params shm_params;
74374
74375 ns = current->nsproxy->ipc_ns;
74376
74377 - shm_ops.getnew = newseg;
74378 - shm_ops.associate = shm_security;
74379 - shm_ops.more_checks = shm_more_checks;
74380 -
74381 shm_params.key = key;
74382 shm_params.flg = shmflg;
74383 shm_params.u.size = size;
74384 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74385 f_mode = FMODE_READ | FMODE_WRITE;
74386 }
74387 if (shmflg & SHM_EXEC) {
74388 +
74389 +#ifdef CONFIG_PAX_MPROTECT
74390 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74391 + goto out;
74392 +#endif
74393 +
74394 prot |= PROT_EXEC;
74395 acc_mode |= S_IXUGO;
74396 }
74397 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74398 if (err)
74399 goto out_unlock;
74400
74401 +#ifdef CONFIG_GRKERNSEC
74402 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74403 + shp->shm_perm.cuid, shmid) ||
74404 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74405 + err = -EACCES;
74406 + goto out_unlock;
74407 + }
74408 +#endif
74409 +
74410 path = shp->shm_file->f_path;
74411 path_get(&path);
74412 shp->shm_nattch++;
74413 +#ifdef CONFIG_GRKERNSEC
74414 + shp->shm_lapid = current->pid;
74415 +#endif
74416 size = i_size_read(path.dentry->d_inode);
74417 shm_unlock(shp);
74418
74419 diff --git a/kernel/acct.c b/kernel/acct.c
74420 index 051e071..15e0920 100644
74421 --- a/kernel/acct.c
74422 +++ b/kernel/acct.c
74423 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74424 */
74425 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74426 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74427 - file->f_op->write(file, (char *)&ac,
74428 + file->f_op->write(file, (char __force_user *)&ac,
74429 sizeof(acct_t), &file->f_pos);
74430 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74431 set_fs(fs);
74432 diff --git a/kernel/audit.c b/kernel/audit.c
74433 index d596e53..dbef3c3 100644
74434 --- a/kernel/audit.c
74435 +++ b/kernel/audit.c
74436 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74437 3) suppressed due to audit_rate_limit
74438 4) suppressed due to audit_backlog_limit
74439 */
74440 -static atomic_t audit_lost = ATOMIC_INIT(0);
74441 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74442
74443 /* The netlink socket. */
74444 static struct sock *audit_sock;
74445 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74446 unsigned long now;
74447 int print;
74448
74449 - atomic_inc(&audit_lost);
74450 + atomic_inc_unchecked(&audit_lost);
74451
74452 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74453
74454 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74455 printk(KERN_WARNING
74456 "audit: audit_lost=%d audit_rate_limit=%d "
74457 "audit_backlog_limit=%d\n",
74458 - atomic_read(&audit_lost),
74459 + atomic_read_unchecked(&audit_lost),
74460 audit_rate_limit,
74461 audit_backlog_limit);
74462 audit_panic(message);
74463 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74464 status_set.pid = audit_pid;
74465 status_set.rate_limit = audit_rate_limit;
74466 status_set.backlog_limit = audit_backlog_limit;
74467 - status_set.lost = atomic_read(&audit_lost);
74468 + status_set.lost = atomic_read_unchecked(&audit_lost);
74469 status_set.backlog = skb_queue_len(&audit_skb_queue);
74470 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74471 &status_set, sizeof(status_set));
74472 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74473 index a371f85..da826c1 100644
74474 --- a/kernel/auditsc.c
74475 +++ b/kernel/auditsc.c
74476 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74477 }
74478
74479 /* global counter which is incremented every time something logs in */
74480 -static atomic_t session_id = ATOMIC_INIT(0);
74481 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74482
74483 /**
74484 * audit_set_loginuid - set current task's audit_context loginuid
74485 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
74486 return -EPERM;
74487 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74488
74489 - sessionid = atomic_inc_return(&session_id);
74490 + sessionid = atomic_inc_return_unchecked(&session_id);
74491 if (context && context->in_syscall) {
74492 struct audit_buffer *ab;
74493
74494 diff --git a/kernel/capability.c b/kernel/capability.c
74495 index f6c2ce5..982c0f9 100644
74496 --- a/kernel/capability.c
74497 +++ b/kernel/capability.c
74498 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74499 * before modification is attempted and the application
74500 * fails.
74501 */
74502 + if (tocopy > ARRAY_SIZE(kdata))
74503 + return -EFAULT;
74504 +
74505 if (copy_to_user(dataptr, kdata, tocopy
74506 * sizeof(struct __user_cap_data_struct))) {
74507 return -EFAULT;
74508 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74509 int ret;
74510
74511 rcu_read_lock();
74512 - ret = security_capable(__task_cred(t), ns, cap);
74513 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74514 + gr_task_is_capable(t, __task_cred(t), cap);
74515 rcu_read_unlock();
74516
74517 - return (ret == 0);
74518 + return ret;
74519 }
74520
74521 /**
74522 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74523 int ret;
74524
74525 rcu_read_lock();
74526 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74527 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74528 rcu_read_unlock();
74529
74530 - return (ret == 0);
74531 + return ret;
74532 }
74533
74534 /**
74535 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74536 BUG();
74537 }
74538
74539 - if (security_capable(current_cred(), ns, cap) == 0) {
74540 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74541 current->flags |= PF_SUPERPRIV;
74542 return true;
74543 }
74544 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74545 }
74546 EXPORT_SYMBOL(ns_capable);
74547
74548 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74549 +{
74550 + if (unlikely(!cap_valid(cap))) {
74551 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74552 + BUG();
74553 + }
74554 +
74555 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74556 + current->flags |= PF_SUPERPRIV;
74557 + return true;
74558 + }
74559 + return false;
74560 +}
74561 +EXPORT_SYMBOL(ns_capable_nolog);
74562 +
74563 /**
74564 * file_ns_capable - Determine if the file's opener had a capability in effect
74565 * @file: The file we want to check
74566 @@ -432,6 +451,12 @@ bool capable(int cap)
74567 }
74568 EXPORT_SYMBOL(capable);
74569
74570 +bool capable_nolog(int cap)
74571 +{
74572 + return ns_capable_nolog(&init_user_ns, cap);
74573 +}
74574 +EXPORT_SYMBOL(capable_nolog);
74575 +
74576 /**
74577 * nsown_capable - Check superior capability to one's own user_ns
74578 * @cap: The capability in question
74579 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74580
74581 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74582 }
74583 +
74584 +bool inode_capable_nolog(const struct inode *inode, int cap)
74585 +{
74586 + struct user_namespace *ns = current_user_ns();
74587 +
74588 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74589 +}
74590 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74591 index 1e23664..570a83d 100644
74592 --- a/kernel/cgroup.c
74593 +++ b/kernel/cgroup.c
74594 @@ -5543,7 +5543,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74595 struct css_set *cg = link->cg;
74596 struct task_struct *task;
74597 int count = 0;
74598 - seq_printf(seq, "css_set %p\n", cg);
74599 + seq_printf(seq, "css_set %pK\n", cg);
74600 list_for_each_entry(task, &cg->tasks, cg_list) {
74601 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74602 seq_puts(seq, " ...\n");
74603 diff --git a/kernel/compat.c b/kernel/compat.c
74604 index 36700e9..73d770c 100644
74605 --- a/kernel/compat.c
74606 +++ b/kernel/compat.c
74607 @@ -13,6 +13,7 @@
74608
74609 #include <linux/linkage.h>
74610 #include <linux/compat.h>
74611 +#include <linux/module.h>
74612 #include <linux/errno.h>
74613 #include <linux/time.h>
74614 #include <linux/signal.h>
74615 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74616 mm_segment_t oldfs;
74617 long ret;
74618
74619 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74620 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74621 oldfs = get_fs();
74622 set_fs(KERNEL_DS);
74623 ret = hrtimer_nanosleep_restart(restart);
74624 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74625 oldfs = get_fs();
74626 set_fs(KERNEL_DS);
74627 ret = hrtimer_nanosleep(&tu,
74628 - rmtp ? (struct timespec __user *)&rmt : NULL,
74629 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74630 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74631 set_fs(oldfs);
74632
74633 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74634 mm_segment_t old_fs = get_fs();
74635
74636 set_fs(KERNEL_DS);
74637 - ret = sys_sigpending((old_sigset_t __user *) &s);
74638 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74639 set_fs(old_fs);
74640 if (ret == 0)
74641 ret = put_user(s, set);
74642 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74643 mm_segment_t old_fs = get_fs();
74644
74645 set_fs(KERNEL_DS);
74646 - ret = sys_old_getrlimit(resource, &r);
74647 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74648 set_fs(old_fs);
74649
74650 if (!ret) {
74651 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74652 mm_segment_t old_fs = get_fs();
74653
74654 set_fs(KERNEL_DS);
74655 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74656 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74657 set_fs(old_fs);
74658
74659 if (ret)
74660 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74661 set_fs (KERNEL_DS);
74662 ret = sys_wait4(pid,
74663 (stat_addr ?
74664 - (unsigned int __user *) &status : NULL),
74665 - options, (struct rusage __user *) &r);
74666 + (unsigned int __force_user *) &status : NULL),
74667 + options, (struct rusage __force_user *) &r);
74668 set_fs (old_fs);
74669
74670 if (ret > 0) {
74671 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74672 memset(&info, 0, sizeof(info));
74673
74674 set_fs(KERNEL_DS);
74675 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74676 - uru ? (struct rusage __user *)&ru : NULL);
74677 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74678 + uru ? (struct rusage __force_user *)&ru : NULL);
74679 set_fs(old_fs);
74680
74681 if ((ret < 0) || (info.si_signo == 0))
74682 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74683 oldfs = get_fs();
74684 set_fs(KERNEL_DS);
74685 err = sys_timer_settime(timer_id, flags,
74686 - (struct itimerspec __user *) &newts,
74687 - (struct itimerspec __user *) &oldts);
74688 + (struct itimerspec __force_user *) &newts,
74689 + (struct itimerspec __force_user *) &oldts);
74690 set_fs(oldfs);
74691 if (!err && old && put_compat_itimerspec(old, &oldts))
74692 return -EFAULT;
74693 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74694 oldfs = get_fs();
74695 set_fs(KERNEL_DS);
74696 err = sys_timer_gettime(timer_id,
74697 - (struct itimerspec __user *) &ts);
74698 + (struct itimerspec __force_user *) &ts);
74699 set_fs(oldfs);
74700 if (!err && put_compat_itimerspec(setting, &ts))
74701 return -EFAULT;
74702 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74703 oldfs = get_fs();
74704 set_fs(KERNEL_DS);
74705 err = sys_clock_settime(which_clock,
74706 - (struct timespec __user *) &ts);
74707 + (struct timespec __force_user *) &ts);
74708 set_fs(oldfs);
74709 return err;
74710 }
74711 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74712 oldfs = get_fs();
74713 set_fs(KERNEL_DS);
74714 err = sys_clock_gettime(which_clock,
74715 - (struct timespec __user *) &ts);
74716 + (struct timespec __force_user *) &ts);
74717 set_fs(oldfs);
74718 if (!err && put_compat_timespec(&ts, tp))
74719 return -EFAULT;
74720 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74721
74722 oldfs = get_fs();
74723 set_fs(KERNEL_DS);
74724 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74725 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74726 set_fs(oldfs);
74727
74728 err = compat_put_timex(utp, &txc);
74729 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74730 oldfs = get_fs();
74731 set_fs(KERNEL_DS);
74732 err = sys_clock_getres(which_clock,
74733 - (struct timespec __user *) &ts);
74734 + (struct timespec __force_user *) &ts);
74735 set_fs(oldfs);
74736 if (!err && tp && put_compat_timespec(&ts, tp))
74737 return -EFAULT;
74738 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74739 long err;
74740 mm_segment_t oldfs;
74741 struct timespec tu;
74742 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74743 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74744
74745 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74746 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74747 oldfs = get_fs();
74748 set_fs(KERNEL_DS);
74749 err = clock_nanosleep_restart(restart);
74750 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74751 oldfs = get_fs();
74752 set_fs(KERNEL_DS);
74753 err = sys_clock_nanosleep(which_clock, flags,
74754 - (struct timespec __user *) &in,
74755 - (struct timespec __user *) &out);
74756 + (struct timespec __force_user *) &in,
74757 + (struct timespec __force_user *) &out);
74758 set_fs(oldfs);
74759
74760 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74761 diff --git a/kernel/configs.c b/kernel/configs.c
74762 index 42e8fa0..9e7406b 100644
74763 --- a/kernel/configs.c
74764 +++ b/kernel/configs.c
74765 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74766 struct proc_dir_entry *entry;
74767
74768 /* create the current config file */
74769 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74770 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74771 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74772 + &ikconfig_file_ops);
74773 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74774 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74775 + &ikconfig_file_ops);
74776 +#endif
74777 +#else
74778 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74779 &ikconfig_file_ops);
74780 +#endif
74781 +
74782 if (!entry)
74783 return -ENOMEM;
74784
74785 diff --git a/kernel/cred.c b/kernel/cred.c
74786 index e0573a4..3874e41 100644
74787 --- a/kernel/cred.c
74788 +++ b/kernel/cred.c
74789 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74790 validate_creds(cred);
74791 alter_cred_subscribers(cred, -1);
74792 put_cred(cred);
74793 +
74794 +#ifdef CONFIG_GRKERNSEC_SETXID
74795 + cred = (struct cred *) tsk->delayed_cred;
74796 + if (cred != NULL) {
74797 + tsk->delayed_cred = NULL;
74798 + validate_creds(cred);
74799 + alter_cred_subscribers(cred, -1);
74800 + put_cred(cred);
74801 + }
74802 +#endif
74803 }
74804
74805 /**
74806 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74807 * Always returns 0 thus allowing this function to be tail-called at the end
74808 * of, say, sys_setgid().
74809 */
74810 -int commit_creds(struct cred *new)
74811 +static int __commit_creds(struct cred *new)
74812 {
74813 struct task_struct *task = current;
74814 const struct cred *old = task->real_cred;
74815 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74816
74817 get_cred(new); /* we will require a ref for the subj creds too */
74818
74819 + gr_set_role_label(task, new->uid, new->gid);
74820 +
74821 /* dumpability changes */
74822 if (!uid_eq(old->euid, new->euid) ||
74823 !gid_eq(old->egid, new->egid) ||
74824 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74825 put_cred(old);
74826 return 0;
74827 }
74828 +#ifdef CONFIG_GRKERNSEC_SETXID
74829 +extern int set_user(struct cred *new);
74830 +
74831 +void gr_delayed_cred_worker(void)
74832 +{
74833 + const struct cred *new = current->delayed_cred;
74834 + struct cred *ncred;
74835 +
74836 + current->delayed_cred = NULL;
74837 +
74838 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74839 + // from doing get_cred on it when queueing this
74840 + put_cred(new);
74841 + return;
74842 + } else if (new == NULL)
74843 + return;
74844 +
74845 + ncred = prepare_creds();
74846 + if (!ncred)
74847 + goto die;
74848 + // uids
74849 + ncred->uid = new->uid;
74850 + ncred->euid = new->euid;
74851 + ncred->suid = new->suid;
74852 + ncred->fsuid = new->fsuid;
74853 + // gids
74854 + ncred->gid = new->gid;
74855 + ncred->egid = new->egid;
74856 + ncred->sgid = new->sgid;
74857 + ncred->fsgid = new->fsgid;
74858 + // groups
74859 + if (set_groups(ncred, new->group_info) < 0) {
74860 + abort_creds(ncred);
74861 + goto die;
74862 + }
74863 + // caps
74864 + ncred->securebits = new->securebits;
74865 + ncred->cap_inheritable = new->cap_inheritable;
74866 + ncred->cap_permitted = new->cap_permitted;
74867 + ncred->cap_effective = new->cap_effective;
74868 + ncred->cap_bset = new->cap_bset;
74869 +
74870 + if (set_user(ncred)) {
74871 + abort_creds(ncred);
74872 + goto die;
74873 + }
74874 +
74875 + // from doing get_cred on it when queueing this
74876 + put_cred(new);
74877 +
74878 + __commit_creds(ncred);
74879 + return;
74880 +die:
74881 + // from doing get_cred on it when queueing this
74882 + put_cred(new);
74883 + do_group_exit(SIGKILL);
74884 +}
74885 +#endif
74886 +
74887 +int commit_creds(struct cred *new)
74888 +{
74889 +#ifdef CONFIG_GRKERNSEC_SETXID
74890 + int ret;
74891 + int schedule_it = 0;
74892 + struct task_struct *t;
74893 +
74894 + /* we won't get called with tasklist_lock held for writing
74895 + and interrupts disabled as the cred struct in that case is
74896 + init_cred
74897 + */
74898 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74899 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74900 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74901 + schedule_it = 1;
74902 + }
74903 + ret = __commit_creds(new);
74904 + if (schedule_it) {
74905 + rcu_read_lock();
74906 + read_lock(&tasklist_lock);
74907 + for (t = next_thread(current); t != current;
74908 + t = next_thread(t)) {
74909 + if (t->delayed_cred == NULL) {
74910 + t->delayed_cred = get_cred(new);
74911 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74912 + set_tsk_need_resched(t);
74913 + }
74914 + }
74915 + read_unlock(&tasklist_lock);
74916 + rcu_read_unlock();
74917 + }
74918 + return ret;
74919 +#else
74920 + return __commit_creds(new);
74921 +#endif
74922 +}
74923 +
74924 EXPORT_SYMBOL(commit_creds);
74925
74926 /**
74927 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74928 index 9a61738..c5c8f3a 100644
74929 --- a/kernel/debug/debug_core.c
74930 +++ b/kernel/debug/debug_core.c
74931 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74932 */
74933 static atomic_t masters_in_kgdb;
74934 static atomic_t slaves_in_kgdb;
74935 -static atomic_t kgdb_break_tasklet_var;
74936 +static atomic_unchecked_t kgdb_break_tasklet_var;
74937 atomic_t kgdb_setting_breakpoint;
74938
74939 struct task_struct *kgdb_usethread;
74940 @@ -132,7 +132,7 @@ int kgdb_single_step;
74941 static pid_t kgdb_sstep_pid;
74942
74943 /* to keep track of the CPU which is doing the single stepping*/
74944 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74945 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74946
74947 /*
74948 * If you are debugging a problem where roundup (the collection of
74949 @@ -540,7 +540,7 @@ return_normal:
74950 * kernel will only try for the value of sstep_tries before
74951 * giving up and continuing on.
74952 */
74953 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74954 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74955 (kgdb_info[cpu].task &&
74956 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74957 atomic_set(&kgdb_active, -1);
74958 @@ -634,8 +634,8 @@ cpu_master_loop:
74959 }
74960
74961 kgdb_restore:
74962 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74963 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74964 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74965 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74966 if (kgdb_info[sstep_cpu].task)
74967 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74968 else
74969 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
74970 static void kgdb_tasklet_bpt(unsigned long ing)
74971 {
74972 kgdb_breakpoint();
74973 - atomic_set(&kgdb_break_tasklet_var, 0);
74974 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74975 }
74976
74977 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74978
74979 void kgdb_schedule_breakpoint(void)
74980 {
74981 - if (atomic_read(&kgdb_break_tasklet_var) ||
74982 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74983 atomic_read(&kgdb_active) != -1 ||
74984 atomic_read(&kgdb_setting_breakpoint))
74985 return;
74986 - atomic_inc(&kgdb_break_tasklet_var);
74987 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74988 tasklet_schedule(&kgdb_tasklet_breakpoint);
74989 }
74990 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74991 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74992 index 8875254..7cf4928 100644
74993 --- a/kernel/debug/kdb/kdb_main.c
74994 +++ b/kernel/debug/kdb/kdb_main.c
74995 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74996 continue;
74997
74998 kdb_printf("%-20s%8u 0x%p ", mod->name,
74999 - mod->core_size, (void *)mod);
75000 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
75001 #ifdef CONFIG_MODULE_UNLOAD
75002 kdb_printf("%4ld ", module_refcount(mod));
75003 #endif
75004 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
75005 kdb_printf(" (Loading)");
75006 else
75007 kdb_printf(" (Live)");
75008 - kdb_printf(" 0x%p", mod->module_core);
75009 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
75010
75011 #ifdef CONFIG_MODULE_UNLOAD
75012 {
75013 diff --git a/kernel/events/core.c b/kernel/events/core.c
75014 index 0600d3b..742ab1b 100644
75015 --- a/kernel/events/core.c
75016 +++ b/kernel/events/core.c
75017 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
75018 return 0;
75019 }
75020
75021 -static atomic64_t perf_event_id;
75022 +static atomic64_unchecked_t perf_event_id;
75023
75024 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
75025 enum event_type_t event_type);
75026 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
75027
75028 static inline u64 perf_event_count(struct perf_event *event)
75029 {
75030 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75031 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75032 }
75033
75034 static u64 perf_event_read(struct perf_event *event)
75035 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75036 mutex_lock(&event->child_mutex);
75037 total += perf_event_read(event);
75038 *enabled += event->total_time_enabled +
75039 - atomic64_read(&event->child_total_time_enabled);
75040 + atomic64_read_unchecked(&event->child_total_time_enabled);
75041 *running += event->total_time_running +
75042 - atomic64_read(&event->child_total_time_running);
75043 + atomic64_read_unchecked(&event->child_total_time_running);
75044
75045 list_for_each_entry(child, &event->child_list, child_list) {
75046 total += perf_event_read(child);
75047 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
75048 userpg->offset -= local64_read(&event->hw.prev_count);
75049
75050 userpg->time_enabled = enabled +
75051 - atomic64_read(&event->child_total_time_enabled);
75052 + atomic64_read_unchecked(&event->child_total_time_enabled);
75053
75054 userpg->time_running = running +
75055 - atomic64_read(&event->child_total_time_running);
75056 + atomic64_read_unchecked(&event->child_total_time_running);
75057
75058 arch_perf_update_userpage(userpg, now);
75059
75060 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75061 values[n++] = perf_event_count(event);
75062 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75063 values[n++] = enabled +
75064 - atomic64_read(&event->child_total_time_enabled);
75065 + atomic64_read_unchecked(&event->child_total_time_enabled);
75066 }
75067 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75068 values[n++] = running +
75069 - atomic64_read(&event->child_total_time_running);
75070 + atomic64_read_unchecked(&event->child_total_time_running);
75071 }
75072 if (read_format & PERF_FORMAT_ID)
75073 values[n++] = primary_event_id(event);
75074 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75075 * need to add enough zero bytes after the string to handle
75076 * the 64bit alignment we do later.
75077 */
75078 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75079 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75080 if (!buf) {
75081 name = strncpy(tmp, "//enomem", sizeof(tmp));
75082 goto got_name;
75083 }
75084 - name = d_path(&file->f_path, buf, PATH_MAX);
75085 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75086 if (IS_ERR(name)) {
75087 name = strncpy(tmp, "//toolong", sizeof(tmp));
75088 goto got_name;
75089 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75090 event->parent = parent_event;
75091
75092 event->ns = get_pid_ns(task_active_pid_ns(current));
75093 - event->id = atomic64_inc_return(&perf_event_id);
75094 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75095
75096 event->state = PERF_EVENT_STATE_INACTIVE;
75097
75098 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
75099 /*
75100 * Add back the child's count to the parent's count:
75101 */
75102 - atomic64_add(child_val, &parent_event->child_count);
75103 - atomic64_add(child_event->total_time_enabled,
75104 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75105 + atomic64_add_unchecked(child_event->total_time_enabled,
75106 &parent_event->child_total_time_enabled);
75107 - atomic64_add(child_event->total_time_running,
75108 + atomic64_add_unchecked(child_event->total_time_running,
75109 &parent_event->child_total_time_running);
75110
75111 /*
75112 diff --git a/kernel/exit.c b/kernel/exit.c
75113 index b4df219..f13c02d 100644
75114 --- a/kernel/exit.c
75115 +++ b/kernel/exit.c
75116 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
75117 struct task_struct *leader;
75118 int zap_leader;
75119 repeat:
75120 +#ifdef CONFIG_NET
75121 + gr_del_task_from_ip_table(p);
75122 +#endif
75123 +
75124 /* don't need to get the RCU readlock here - the process is dead and
75125 * can't be modifying its own credentials. But shut RCU-lockdep up */
75126 rcu_read_lock();
75127 @@ -338,7 +342,7 @@ int allow_signal(int sig)
75128 * know it'll be handled, so that they don't get converted to
75129 * SIGKILL or just silently dropped.
75130 */
75131 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75132 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75133 recalc_sigpending();
75134 spin_unlock_irq(&current->sighand->siglock);
75135 return 0;
75136 @@ -708,6 +712,8 @@ void do_exit(long code)
75137 struct task_struct *tsk = current;
75138 int group_dead;
75139
75140 + set_fs(USER_DS);
75141 +
75142 profile_task_exit(tsk);
75143
75144 WARN_ON(blk_needs_flush_plug(tsk));
75145 @@ -724,7 +730,6 @@ void do_exit(long code)
75146 * mm_release()->clear_child_tid() from writing to a user-controlled
75147 * kernel address.
75148 */
75149 - set_fs(USER_DS);
75150
75151 ptrace_event(PTRACE_EVENT_EXIT, code);
75152
75153 @@ -783,6 +788,9 @@ void do_exit(long code)
75154 tsk->exit_code = code;
75155 taskstats_exit(tsk, group_dead);
75156
75157 + gr_acl_handle_psacct(tsk, code);
75158 + gr_acl_handle_exit();
75159 +
75160 exit_mm(tsk);
75161
75162 if (group_dead)
75163 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75164 * Take down every thread in the group. This is called by fatal signals
75165 * as well as by sys_exit_group (below).
75166 */
75167 -void
75168 +__noreturn void
75169 do_group_exit(int exit_code)
75170 {
75171 struct signal_struct *sig = current->signal;
75172 diff --git a/kernel/fork.c b/kernel/fork.c
75173 index 5630e52..0cee608 100644
75174 --- a/kernel/fork.c
75175 +++ b/kernel/fork.c
75176 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75177 *stackend = STACK_END_MAGIC; /* for overflow detection */
75178
75179 #ifdef CONFIG_CC_STACKPROTECTOR
75180 - tsk->stack_canary = get_random_int();
75181 + tsk->stack_canary = pax_get_random_long();
75182 #endif
75183
75184 /*
75185 @@ -344,13 +344,81 @@ free_tsk:
75186 }
75187
75188 #ifdef CONFIG_MMU
75189 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75190 +{
75191 + struct vm_area_struct *tmp;
75192 + unsigned long charge;
75193 + struct mempolicy *pol;
75194 + struct file *file;
75195 +
75196 + charge = 0;
75197 + if (mpnt->vm_flags & VM_ACCOUNT) {
75198 + unsigned long len = vma_pages(mpnt);
75199 +
75200 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75201 + goto fail_nomem;
75202 + charge = len;
75203 + }
75204 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75205 + if (!tmp)
75206 + goto fail_nomem;
75207 + *tmp = *mpnt;
75208 + tmp->vm_mm = mm;
75209 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75210 + pol = mpol_dup(vma_policy(mpnt));
75211 + if (IS_ERR(pol))
75212 + goto fail_nomem_policy;
75213 + vma_set_policy(tmp, pol);
75214 + if (anon_vma_fork(tmp, mpnt))
75215 + goto fail_nomem_anon_vma_fork;
75216 + tmp->vm_flags &= ~VM_LOCKED;
75217 + tmp->vm_next = tmp->vm_prev = NULL;
75218 + tmp->vm_mirror = NULL;
75219 + file = tmp->vm_file;
75220 + if (file) {
75221 + struct inode *inode = file->f_path.dentry->d_inode;
75222 + struct address_space *mapping = file->f_mapping;
75223 +
75224 + get_file(file);
75225 + if (tmp->vm_flags & VM_DENYWRITE)
75226 + atomic_dec(&inode->i_writecount);
75227 + mutex_lock(&mapping->i_mmap_mutex);
75228 + if (tmp->vm_flags & VM_SHARED)
75229 + mapping->i_mmap_writable++;
75230 + flush_dcache_mmap_lock(mapping);
75231 + /* insert tmp into the share list, just after mpnt */
75232 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75233 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75234 + else
75235 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75236 + flush_dcache_mmap_unlock(mapping);
75237 + mutex_unlock(&mapping->i_mmap_mutex);
75238 + }
75239 +
75240 + /*
75241 + * Clear hugetlb-related page reserves for children. This only
75242 + * affects MAP_PRIVATE mappings. Faults generated by the child
75243 + * are not guaranteed to succeed, even if read-only
75244 + */
75245 + if (is_vm_hugetlb_page(tmp))
75246 + reset_vma_resv_huge_pages(tmp);
75247 +
75248 + return tmp;
75249 +
75250 +fail_nomem_anon_vma_fork:
75251 + mpol_put(pol);
75252 +fail_nomem_policy:
75253 + kmem_cache_free(vm_area_cachep, tmp);
75254 +fail_nomem:
75255 + vm_unacct_memory(charge);
75256 + return NULL;
75257 +}
75258 +
75259 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75260 {
75261 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75262 struct rb_node **rb_link, *rb_parent;
75263 int retval;
75264 - unsigned long charge;
75265 - struct mempolicy *pol;
75266
75267 uprobe_start_dup_mmap();
75268 down_write(&oldmm->mmap_sem);
75269 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75270 mm->locked_vm = 0;
75271 mm->mmap = NULL;
75272 mm->mmap_cache = NULL;
75273 - mm->free_area_cache = oldmm->mmap_base;
75274 - mm->cached_hole_size = ~0UL;
75275 + mm->free_area_cache = oldmm->free_area_cache;
75276 + mm->cached_hole_size = oldmm->cached_hole_size;
75277 mm->map_count = 0;
75278 cpumask_clear(mm_cpumask(mm));
75279 mm->mm_rb = RB_ROOT;
75280 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75281
75282 prev = NULL;
75283 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75284 - struct file *file;
75285 -
75286 if (mpnt->vm_flags & VM_DONTCOPY) {
75287 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75288 -vma_pages(mpnt));
75289 continue;
75290 }
75291 - charge = 0;
75292 - if (mpnt->vm_flags & VM_ACCOUNT) {
75293 - unsigned long len = vma_pages(mpnt);
75294 -
75295 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75296 - goto fail_nomem;
75297 - charge = len;
75298 - }
75299 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75300 - if (!tmp)
75301 - goto fail_nomem;
75302 - *tmp = *mpnt;
75303 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75304 - pol = mpol_dup(vma_policy(mpnt));
75305 - retval = PTR_ERR(pol);
75306 - if (IS_ERR(pol))
75307 - goto fail_nomem_policy;
75308 - vma_set_policy(tmp, pol);
75309 - tmp->vm_mm = mm;
75310 - if (anon_vma_fork(tmp, mpnt))
75311 - goto fail_nomem_anon_vma_fork;
75312 - tmp->vm_flags &= ~VM_LOCKED;
75313 - tmp->vm_next = tmp->vm_prev = NULL;
75314 - file = tmp->vm_file;
75315 - if (file) {
75316 - struct inode *inode = file->f_path.dentry->d_inode;
75317 - struct address_space *mapping = file->f_mapping;
75318 -
75319 - get_file(file);
75320 - if (tmp->vm_flags & VM_DENYWRITE)
75321 - atomic_dec(&inode->i_writecount);
75322 - mutex_lock(&mapping->i_mmap_mutex);
75323 - if (tmp->vm_flags & VM_SHARED)
75324 - mapping->i_mmap_writable++;
75325 - flush_dcache_mmap_lock(mapping);
75326 - /* insert tmp into the share list, just after mpnt */
75327 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75328 - vma_nonlinear_insert(tmp,
75329 - &mapping->i_mmap_nonlinear);
75330 - else
75331 - vma_interval_tree_insert_after(tmp, mpnt,
75332 - &mapping->i_mmap);
75333 - flush_dcache_mmap_unlock(mapping);
75334 - mutex_unlock(&mapping->i_mmap_mutex);
75335 + tmp = dup_vma(mm, oldmm, mpnt);
75336 + if (!tmp) {
75337 + retval = -ENOMEM;
75338 + goto out;
75339 }
75340
75341 /*
75342 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75343 if (retval)
75344 goto out;
75345 }
75346 +
75347 +#ifdef CONFIG_PAX_SEGMEXEC
75348 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75349 + struct vm_area_struct *mpnt_m;
75350 +
75351 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75352 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75353 +
75354 + if (!mpnt->vm_mirror)
75355 + continue;
75356 +
75357 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75358 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75359 + mpnt->vm_mirror = mpnt_m;
75360 + } else {
75361 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75362 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75363 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75364 + mpnt->vm_mirror->vm_mirror = mpnt;
75365 + }
75366 + }
75367 + BUG_ON(mpnt_m);
75368 + }
75369 +#endif
75370 +
75371 /* a new mm has just been created */
75372 arch_dup_mmap(oldmm, mm);
75373 retval = 0;
75374 @@ -472,14 +523,6 @@ out:
75375 up_write(&oldmm->mmap_sem);
75376 uprobe_end_dup_mmap();
75377 return retval;
75378 -fail_nomem_anon_vma_fork:
75379 - mpol_put(pol);
75380 -fail_nomem_policy:
75381 - kmem_cache_free(vm_area_cachep, tmp);
75382 -fail_nomem:
75383 - retval = -ENOMEM;
75384 - vm_unacct_memory(charge);
75385 - goto out;
75386 }
75387
75388 static inline int mm_alloc_pgd(struct mm_struct *mm)
75389 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75390 return ERR_PTR(err);
75391
75392 mm = get_task_mm(task);
75393 - if (mm && mm != current->mm &&
75394 - !ptrace_may_access(task, mode)) {
75395 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75396 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75397 mmput(mm);
75398 mm = ERR_PTR(-EACCES);
75399 }
75400 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75401 spin_unlock(&fs->lock);
75402 return -EAGAIN;
75403 }
75404 - fs->users++;
75405 + atomic_inc(&fs->users);
75406 spin_unlock(&fs->lock);
75407 return 0;
75408 }
75409 tsk->fs = copy_fs_struct(fs);
75410 if (!tsk->fs)
75411 return -ENOMEM;
75412 + /* Carry through gr_chroot_dentry and is_chrooted instead
75413 + of recomputing it here. Already copied when the task struct
75414 + is duplicated. This allows pivot_root to not be treated as
75415 + a chroot
75416 + */
75417 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75418 +
75419 return 0;
75420 }
75421
75422 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75423 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75424 #endif
75425 retval = -EAGAIN;
75426 +
75427 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75428 +
75429 if (atomic_read(&p->real_cred->user->processes) >=
75430 task_rlimit(p, RLIMIT_NPROC)) {
75431 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75432 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75433 goto bad_fork_free_pid;
75434 }
75435
75436 + /* synchronizes with gr_set_acls()
75437 + we need to call this past the point of no return for fork()
75438 + */
75439 + gr_copy_label(p);
75440 +
75441 if (clone_flags & CLONE_THREAD) {
75442 current->signal->nr_threads++;
75443 atomic_inc(&current->signal->live);
75444 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
75445 bad_fork_free:
75446 free_task(p);
75447 fork_out:
75448 + gr_log_forkfail(retval);
75449 +
75450 return ERR_PTR(retval);
75451 }
75452
75453 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
75454 return -EINVAL;
75455 }
75456
75457 +#ifdef CONFIG_GRKERNSEC
75458 + if (clone_flags & CLONE_NEWUSER) {
75459 + /*
75460 + * This doesn't really inspire confidence:
75461 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75462 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75463 + * Increases kernel attack surface in areas developers
75464 + * previously cared little about ("low importance due
75465 + * to requiring "root" capability")
75466 + * To be removed when this code receives *proper* review
75467 + */
75468 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75469 + !capable(CAP_SETGID))
75470 + return -EPERM;
75471 + }
75472 +#endif
75473 +
75474 /*
75475 * Determine whether and which event to report to ptracer. When
75476 * called from kernel_thread or CLONE_UNTRACED is explicitly
75477 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
75478 if (clone_flags & CLONE_PARENT_SETTID)
75479 put_user(nr, parent_tidptr);
75480
75481 + gr_handle_brute_check();
75482 +
75483 if (clone_flags & CLONE_VFORK) {
75484 p->vfork_done = &vfork;
75485 init_completion(&vfork);
75486 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75487 return 0;
75488
75489 /* don't need lock here; in the worst case we'll do useless copy */
75490 - if (fs->users == 1)
75491 + if (atomic_read(&fs->users) == 1)
75492 return 0;
75493
75494 *new_fsp = copy_fs_struct(fs);
75495 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75496 fs = current->fs;
75497 spin_lock(&fs->lock);
75498 current->fs = new_fs;
75499 - if (--fs->users)
75500 + gr_set_chroot_entries(current, &current->fs->root);
75501 + if (atomic_dec_return(&fs->users))
75502 new_fs = NULL;
75503 else
75504 new_fs = fs;
75505 diff --git a/kernel/futex.c b/kernel/futex.c
75506 index 8879430..31696f1 100644
75507 --- a/kernel/futex.c
75508 +++ b/kernel/futex.c
75509 @@ -54,6 +54,7 @@
75510 #include <linux/mount.h>
75511 #include <linux/pagemap.h>
75512 #include <linux/syscalls.h>
75513 +#include <linux/ptrace.h>
75514 #include <linux/signal.h>
75515 #include <linux/export.h>
75516 #include <linux/magic.h>
75517 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75518 struct page *page, *page_head;
75519 int err, ro = 0;
75520
75521 +#ifdef CONFIG_PAX_SEGMEXEC
75522 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75523 + return -EFAULT;
75524 +#endif
75525 +
75526 /*
75527 * The futex address must be "naturally" aligned.
75528 */
75529 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
75530 {
75531 u32 curval;
75532 int i;
75533 + mm_segment_t oldfs;
75534
75535 /*
75536 * This will fail and we want it. Some arch implementations do
75537 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
75538 * implementation, the non-functional ones will return
75539 * -ENOSYS.
75540 */
75541 + oldfs = get_fs();
75542 + set_fs(USER_DS);
75543 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75544 futex_cmpxchg_enabled = 1;
75545 + set_fs(oldfs);
75546
75547 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75548 plist_head_init(&futex_queues[i].chain);
75549 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75550 index a9642d5..51eb98c 100644
75551 --- a/kernel/futex_compat.c
75552 +++ b/kernel/futex_compat.c
75553 @@ -31,7 +31,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75554 return 0;
75555 }
75556
75557 -static void __user *futex_uaddr(struct robust_list __user *entry,
75558 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75559 compat_long_t futex_offset)
75560 {
75561 compat_uptr_t base = ptr_to_compat(entry);
75562 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75563 index 9b22d03..6295b62 100644
75564 --- a/kernel/gcov/base.c
75565 +++ b/kernel/gcov/base.c
75566 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75567 }
75568
75569 #ifdef CONFIG_MODULES
75570 -static inline int within(void *addr, void *start, unsigned long size)
75571 -{
75572 - return ((addr >= start) && (addr < start + size));
75573 -}
75574 -
75575 /* Update list and generate events when modules are unloaded. */
75576 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75577 void *data)
75578 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75579 prev = NULL;
75580 /* Remove entries located in module from linked list. */
75581 for (info = gcov_info_head; info; info = info->next) {
75582 - if (within(info, mod->module_core, mod->core_size)) {
75583 + if (within_module_core_rw((unsigned long)info, mod)) {
75584 if (prev)
75585 prev->next = info->next;
75586 else
75587 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75588 index e4cee8d..f31f503 100644
75589 --- a/kernel/hrtimer.c
75590 +++ b/kernel/hrtimer.c
75591 @@ -1408,7 +1408,7 @@ void hrtimer_peek_ahead_timers(void)
75592 local_irq_restore(flags);
75593 }
75594
75595 -static void run_hrtimer_softirq(struct softirq_action *h)
75596 +static void run_hrtimer_softirq(void)
75597 {
75598 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75599
75600 @@ -1750,7 +1750,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75601 return NOTIFY_OK;
75602 }
75603
75604 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75605 +static struct notifier_block hrtimers_nb = {
75606 .notifier_call = hrtimer_cpu_notify,
75607 };
75608
75609 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75610 index 60f48fa..7f3a770 100644
75611 --- a/kernel/jump_label.c
75612 +++ b/kernel/jump_label.c
75613 @@ -13,6 +13,7 @@
75614 #include <linux/sort.h>
75615 #include <linux/err.h>
75616 #include <linux/static_key.h>
75617 +#include <linux/mm.h>
75618
75619 #ifdef HAVE_JUMP_LABEL
75620
75621 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75622
75623 size = (((unsigned long)stop - (unsigned long)start)
75624 / sizeof(struct jump_entry));
75625 + pax_open_kernel();
75626 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75627 + pax_close_kernel();
75628 }
75629
75630 static void jump_label_update(struct static_key *key, int enable);
75631 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75632 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75633 struct jump_entry *iter;
75634
75635 + pax_open_kernel();
75636 for (iter = iter_start; iter < iter_stop; iter++) {
75637 if (within_module_init(iter->code, mod))
75638 iter->code = 0;
75639 }
75640 + pax_close_kernel();
75641 }
75642
75643 static int
75644 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75645 index 2169fee..706ccca 100644
75646 --- a/kernel/kallsyms.c
75647 +++ b/kernel/kallsyms.c
75648 @@ -11,6 +11,9 @@
75649 * Changed the compression method from stem compression to "table lookup"
75650 * compression (see scripts/kallsyms.c for a more complete description)
75651 */
75652 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75653 +#define __INCLUDED_BY_HIDESYM 1
75654 +#endif
75655 #include <linux/kallsyms.h>
75656 #include <linux/module.h>
75657 #include <linux/init.h>
75658 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75659
75660 static inline int is_kernel_inittext(unsigned long addr)
75661 {
75662 + if (system_state != SYSTEM_BOOTING)
75663 + return 0;
75664 +
75665 if (addr >= (unsigned long)_sinittext
75666 && addr <= (unsigned long)_einittext)
75667 return 1;
75668 return 0;
75669 }
75670
75671 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75672 +#ifdef CONFIG_MODULES
75673 +static inline int is_module_text(unsigned long addr)
75674 +{
75675 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75676 + return 1;
75677 +
75678 + addr = ktla_ktva(addr);
75679 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75680 +}
75681 +#else
75682 +static inline int is_module_text(unsigned long addr)
75683 +{
75684 + return 0;
75685 +}
75686 +#endif
75687 +#endif
75688 +
75689 static inline int is_kernel_text(unsigned long addr)
75690 {
75691 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75692 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75693
75694 static inline int is_kernel(unsigned long addr)
75695 {
75696 +
75697 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75698 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75699 + return 1;
75700 +
75701 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75702 +#else
75703 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75704 +#endif
75705 +
75706 return 1;
75707 return in_gate_area_no_mm(addr);
75708 }
75709
75710 static int is_ksym_addr(unsigned long addr)
75711 {
75712 +
75713 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75714 + if (is_module_text(addr))
75715 + return 0;
75716 +#endif
75717 +
75718 if (all_var)
75719 return is_kernel(addr);
75720
75721 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75722
75723 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75724 {
75725 - iter->name[0] = '\0';
75726 iter->nameoff = get_symbol_offset(new_pos);
75727 iter->pos = new_pos;
75728 }
75729 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75730 {
75731 struct kallsym_iter *iter = m->private;
75732
75733 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75734 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75735 + return 0;
75736 +#endif
75737 +
75738 /* Some debugging symbols have no name. Ignore them. */
75739 if (!iter->name[0])
75740 return 0;
75741 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75742 */
75743 type = iter->exported ? toupper(iter->type) :
75744 tolower(iter->type);
75745 +
75746 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75747 type, iter->name, iter->module_name);
75748 } else
75749 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75750 struct kallsym_iter *iter;
75751 int ret;
75752
75753 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75754 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75755 if (!iter)
75756 return -ENOMEM;
75757 reset_iter(iter, 0);
75758 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75759 index e30ac0f..3528cac 100644
75760 --- a/kernel/kcmp.c
75761 +++ b/kernel/kcmp.c
75762 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75763 struct task_struct *task1, *task2;
75764 int ret;
75765
75766 +#ifdef CONFIG_GRKERNSEC
75767 + return -ENOSYS;
75768 +#endif
75769 +
75770 rcu_read_lock();
75771
75772 /*
75773 diff --git a/kernel/kexec.c b/kernel/kexec.c
75774 index 5e4bd78..00c5b91 100644
75775 --- a/kernel/kexec.c
75776 +++ b/kernel/kexec.c
75777 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75778 unsigned long flags)
75779 {
75780 struct compat_kexec_segment in;
75781 - struct kexec_segment out, __user *ksegments;
75782 + struct kexec_segment out;
75783 + struct kexec_segment __user *ksegments;
75784 unsigned long i, result;
75785
75786 /* Don't allow clients that don't understand the native
75787 diff --git a/kernel/kmod.c b/kernel/kmod.c
75788 index 0023a87..9c0c068 100644
75789 --- a/kernel/kmod.c
75790 +++ b/kernel/kmod.c
75791 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75792 kfree(info->argv);
75793 }
75794
75795 -static int call_modprobe(char *module_name, int wait)
75796 +static int call_modprobe(char *module_name, char *module_param, int wait)
75797 {
75798 static char *envp[] = {
75799 "HOME=/",
75800 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
75801 NULL
75802 };
75803
75804 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75805 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75806 if (!argv)
75807 goto out;
75808
75809 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
75810 argv[1] = "-q";
75811 argv[2] = "--";
75812 argv[3] = module_name; /* check free_modprobe_argv() */
75813 - argv[4] = NULL;
75814 + argv[4] = module_param;
75815 + argv[5] = NULL;
75816
75817 return call_usermodehelper_fns(modprobe_path, argv, envp,
75818 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75819 @@ -120,9 +121,8 @@ out:
75820 * If module auto-loading support is disabled then this function
75821 * becomes a no-operation.
75822 */
75823 -int __request_module(bool wait, const char *fmt, ...)
75824 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75825 {
75826 - va_list args;
75827 char module_name[MODULE_NAME_LEN];
75828 unsigned int max_modprobes;
75829 int ret;
75830 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
75831 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
75832 static int kmod_loop_msg;
75833
75834 - va_start(args, fmt);
75835 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75836 - va_end(args);
75837 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75838 if (ret >= MODULE_NAME_LEN)
75839 return -ENAMETOOLONG;
75840
75841 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
75842 if (ret)
75843 return ret;
75844
75845 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75846 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75847 + /* hack to workaround consolekit/udisks stupidity */
75848 + read_lock(&tasklist_lock);
75849 + if (!strcmp(current->comm, "mount") &&
75850 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75851 + read_unlock(&tasklist_lock);
75852 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75853 + return -EPERM;
75854 + }
75855 + read_unlock(&tasklist_lock);
75856 + }
75857 +#endif
75858 +
75859 /* If modprobe needs a service that is in a module, we get a recursive
75860 * loop. Limit the number of running kmod threads to max_threads/2 or
75861 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75862 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
75863
75864 trace_module_request(module_name, wait, _RET_IP_);
75865
75866 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75867 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75868
75869 atomic_dec(&kmod_concurrent);
75870 return ret;
75871 }
75872 +
75873 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75874 +{
75875 + va_list args;
75876 + int ret;
75877 +
75878 + va_start(args, fmt);
75879 + ret = ____request_module(wait, module_param, fmt, args);
75880 + va_end(args);
75881 +
75882 + return ret;
75883 +}
75884 +
75885 +int __request_module(bool wait, const char *fmt, ...)
75886 +{
75887 + va_list args;
75888 + int ret;
75889 +
75890 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75891 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75892 + char module_param[MODULE_NAME_LEN];
75893 +
75894 + memset(module_param, 0, sizeof(module_param));
75895 +
75896 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75897 +
75898 + va_start(args, fmt);
75899 + ret = ____request_module(wait, module_param, fmt, args);
75900 + va_end(args);
75901 +
75902 + return ret;
75903 + }
75904 +#endif
75905 +
75906 + va_start(args, fmt);
75907 + ret = ____request_module(wait, NULL, fmt, args);
75908 + va_end(args);
75909 +
75910 + return ret;
75911 +}
75912 +
75913 EXPORT_SYMBOL(__request_module);
75914 #endif /* CONFIG_MODULES */
75915
75916 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
75917 *
75918 * Thus the __user pointer cast is valid here.
75919 */
75920 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75921 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75922
75923 /*
75924 * If ret is 0, either ____call_usermodehelper failed and the
75925 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75926 static int proc_cap_handler(struct ctl_table *table, int write,
75927 void __user *buffer, size_t *lenp, loff_t *ppos)
75928 {
75929 - struct ctl_table t;
75930 + ctl_table_no_const t;
75931 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75932 kernel_cap_t new_cap;
75933 int err, i;
75934 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75935 index 098f396..fe85ff1 100644
75936 --- a/kernel/kprobes.c
75937 +++ b/kernel/kprobes.c
75938 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75939 * kernel image and loaded module images reside. This is required
75940 * so x86_64 can correctly handle the %rip-relative fixups.
75941 */
75942 - kip->insns = module_alloc(PAGE_SIZE);
75943 + kip->insns = module_alloc_exec(PAGE_SIZE);
75944 if (!kip->insns) {
75945 kfree(kip);
75946 return NULL;
75947 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75948 */
75949 if (!list_is_singular(&kip->list)) {
75950 list_del(&kip->list);
75951 - module_free(NULL, kip->insns);
75952 + module_free_exec(NULL, kip->insns);
75953 kfree(kip);
75954 }
75955 return 1;
75956 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
75957 {
75958 int i, err = 0;
75959 unsigned long offset = 0, size = 0;
75960 - char *modname, namebuf[128];
75961 + char *modname, namebuf[KSYM_NAME_LEN];
75962 const char *symbol_name;
75963 void *addr;
75964 struct kprobe_blackpoint *kb;
75965 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75966 kprobe_type = "k";
75967
75968 if (sym)
75969 - seq_printf(pi, "%p %s %s+0x%x %s ",
75970 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75971 p->addr, kprobe_type, sym, offset,
75972 (modname ? modname : " "));
75973 else
75974 - seq_printf(pi, "%p %s %p ",
75975 + seq_printf(pi, "%pK %s %pK ",
75976 p->addr, kprobe_type, p->addr);
75977
75978 if (!pp)
75979 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75980 const char *sym = NULL;
75981 unsigned int i = *(loff_t *) v;
75982 unsigned long offset = 0;
75983 - char *modname, namebuf[128];
75984 + char *modname, namebuf[KSYM_NAME_LEN];
75985
75986 head = &kprobe_table[i];
75987 preempt_disable();
75988 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75989 index 6ada93c..dce7d5d 100644
75990 --- a/kernel/ksysfs.c
75991 +++ b/kernel/ksysfs.c
75992 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75993 {
75994 if (count+1 > UEVENT_HELPER_PATH_LEN)
75995 return -ENOENT;
75996 + if (!capable(CAP_SYS_ADMIN))
75997 + return -EPERM;
75998 memcpy(uevent_helper, buf, count);
75999 uevent_helper[count] = '\0';
76000 if (count && uevent_helper[count-1] == '\n')
76001 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
76002 return count;
76003 }
76004
76005 -static struct bin_attribute notes_attr = {
76006 +static bin_attribute_no_const notes_attr __read_only = {
76007 .attr = {
76008 .name = "notes",
76009 .mode = S_IRUGO,
76010 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
76011 index 7981e5b..7f2105c 100644
76012 --- a/kernel/lockdep.c
76013 +++ b/kernel/lockdep.c
76014 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
76015 end = (unsigned long) &_end,
76016 addr = (unsigned long) obj;
76017
76018 +#ifdef CONFIG_PAX_KERNEXEC
76019 + start = ktla_ktva(start);
76020 +#endif
76021 +
76022 /*
76023 * static variable?
76024 */
76025 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
76026 if (!static_obj(lock->key)) {
76027 debug_locks_off();
76028 printk("INFO: trying to register non-static key.\n");
76029 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76030 printk("the code is fine but needs lockdep annotation.\n");
76031 printk("turning off the locking correctness validator.\n");
76032 dump_stack();
76033 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76034 if (!class)
76035 return 0;
76036 }
76037 - atomic_inc((atomic_t *)&class->ops);
76038 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76039 if (very_verbose(class)) {
76040 printk("\nacquire class [%p] %s", class->key, class->name);
76041 if (class->name_version > 1)
76042 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76043 index b2c71c5..7b88d63 100644
76044 --- a/kernel/lockdep_proc.c
76045 +++ b/kernel/lockdep_proc.c
76046 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76047 return 0;
76048 }
76049
76050 - seq_printf(m, "%p", class->key);
76051 + seq_printf(m, "%pK", class->key);
76052 #ifdef CONFIG_DEBUG_LOCKDEP
76053 seq_printf(m, " OPS:%8ld", class->ops);
76054 #endif
76055 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76056
76057 list_for_each_entry(entry, &class->locks_after, entry) {
76058 if (entry->distance == 1) {
76059 - seq_printf(m, " -> [%p] ", entry->class->key);
76060 + seq_printf(m, " -> [%pK] ", entry->class->key);
76061 print_name(m, entry->class);
76062 seq_puts(m, "\n");
76063 }
76064 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76065 if (!class->key)
76066 continue;
76067
76068 - seq_printf(m, "[%p] ", class->key);
76069 + seq_printf(m, "[%pK] ", class->key);
76070 print_name(m, class);
76071 seq_puts(m, "\n");
76072 }
76073 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76074 if (!i)
76075 seq_line(m, '-', 40-namelen, namelen);
76076
76077 - snprintf(ip, sizeof(ip), "[<%p>]",
76078 + snprintf(ip, sizeof(ip), "[<%pK>]",
76079 (void *)class->contention_point[i]);
76080 seq_printf(m, "%40s %14lu %29s %pS\n",
76081 name, stats->contention_point[i],
76082 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76083 if (!i)
76084 seq_line(m, '-', 40-namelen, namelen);
76085
76086 - snprintf(ip, sizeof(ip), "[<%p>]",
76087 + snprintf(ip, sizeof(ip), "[<%pK>]",
76088 (void *)class->contending_point[i]);
76089 seq_printf(m, "%40s %14lu %29s %pS\n",
76090 name, stats->contending_point[i],
76091 diff --git a/kernel/module.c b/kernel/module.c
76092 index eab0827..f488603 100644
76093 --- a/kernel/module.c
76094 +++ b/kernel/module.c
76095 @@ -61,6 +61,7 @@
76096 #include <linux/pfn.h>
76097 #include <linux/bsearch.h>
76098 #include <linux/fips.h>
76099 +#include <linux/grsecurity.h>
76100 #include <uapi/linux/module.h>
76101 #include "module-internal.h"
76102
76103 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76104
76105 /* Bounds of module allocation, for speeding __module_address.
76106 * Protected by module_mutex. */
76107 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76108 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76109 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76110
76111 int register_module_notifier(struct notifier_block * nb)
76112 {
76113 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76114 return true;
76115
76116 list_for_each_entry_rcu(mod, &modules, list) {
76117 - struct symsearch arr[] = {
76118 + struct symsearch modarr[] = {
76119 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76120 NOT_GPL_ONLY, false },
76121 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76122 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76123 if (mod->state == MODULE_STATE_UNFORMED)
76124 continue;
76125
76126 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76127 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76128 return true;
76129 }
76130 return false;
76131 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76132 static int percpu_modalloc(struct module *mod,
76133 unsigned long size, unsigned long align)
76134 {
76135 - if (align > PAGE_SIZE) {
76136 + if (align-1 >= PAGE_SIZE) {
76137 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76138 mod->name, align, PAGE_SIZE);
76139 align = PAGE_SIZE;
76140 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
76141 static ssize_t show_coresize(struct module_attribute *mattr,
76142 struct module_kobject *mk, char *buffer)
76143 {
76144 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76145 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76146 }
76147
76148 static struct module_attribute modinfo_coresize =
76149 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
76150 static ssize_t show_initsize(struct module_attribute *mattr,
76151 struct module_kobject *mk, char *buffer)
76152 {
76153 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76154 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76155 }
76156
76157 static struct module_attribute modinfo_initsize =
76158 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
76159 */
76160 #ifdef CONFIG_SYSFS
76161
76162 -#ifdef CONFIG_KALLSYMS
76163 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76164 static inline bool sect_empty(const Elf_Shdr *sect)
76165 {
76166 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76167 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76168 {
76169 unsigned int notes, loaded, i;
76170 struct module_notes_attrs *notes_attrs;
76171 - struct bin_attribute *nattr;
76172 + bin_attribute_no_const *nattr;
76173
76174 /* failed to create section attributes, so can't create notes */
76175 if (!mod->sect_attrs)
76176 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
76177 static int module_add_modinfo_attrs(struct module *mod)
76178 {
76179 struct module_attribute *attr;
76180 - struct module_attribute *temp_attr;
76181 + module_attribute_no_const *temp_attr;
76182 int error = 0;
76183 int i;
76184
76185 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
76186
76187 static void unset_module_core_ro_nx(struct module *mod)
76188 {
76189 - set_page_attributes(mod->module_core + mod->core_text_size,
76190 - mod->module_core + mod->core_size,
76191 + set_page_attributes(mod->module_core_rw,
76192 + mod->module_core_rw + mod->core_size_rw,
76193 set_memory_x);
76194 - set_page_attributes(mod->module_core,
76195 - mod->module_core + mod->core_ro_size,
76196 + set_page_attributes(mod->module_core_rx,
76197 + mod->module_core_rx + mod->core_size_rx,
76198 set_memory_rw);
76199 }
76200
76201 static void unset_module_init_ro_nx(struct module *mod)
76202 {
76203 - set_page_attributes(mod->module_init + mod->init_text_size,
76204 - mod->module_init + mod->init_size,
76205 + set_page_attributes(mod->module_init_rw,
76206 + mod->module_init_rw + mod->init_size_rw,
76207 set_memory_x);
76208 - set_page_attributes(mod->module_init,
76209 - mod->module_init + mod->init_ro_size,
76210 + set_page_attributes(mod->module_init_rx,
76211 + mod->module_init_rx + mod->init_size_rx,
76212 set_memory_rw);
76213 }
76214
76215 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
76216 list_for_each_entry_rcu(mod, &modules, list) {
76217 if (mod->state == MODULE_STATE_UNFORMED)
76218 continue;
76219 - if ((mod->module_core) && (mod->core_text_size)) {
76220 - set_page_attributes(mod->module_core,
76221 - mod->module_core + mod->core_text_size,
76222 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76223 + set_page_attributes(mod->module_core_rx,
76224 + mod->module_core_rx + mod->core_size_rx,
76225 set_memory_rw);
76226 }
76227 - if ((mod->module_init) && (mod->init_text_size)) {
76228 - set_page_attributes(mod->module_init,
76229 - mod->module_init + mod->init_text_size,
76230 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76231 + set_page_attributes(mod->module_init_rx,
76232 + mod->module_init_rx + mod->init_size_rx,
76233 set_memory_rw);
76234 }
76235 }
76236 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
76237 list_for_each_entry_rcu(mod, &modules, list) {
76238 if (mod->state == MODULE_STATE_UNFORMED)
76239 continue;
76240 - if ((mod->module_core) && (mod->core_text_size)) {
76241 - set_page_attributes(mod->module_core,
76242 - mod->module_core + mod->core_text_size,
76243 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76244 + set_page_attributes(mod->module_core_rx,
76245 + mod->module_core_rx + mod->core_size_rx,
76246 set_memory_ro);
76247 }
76248 - if ((mod->module_init) && (mod->init_text_size)) {
76249 - set_page_attributes(mod->module_init,
76250 - mod->module_init + mod->init_text_size,
76251 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76252 + set_page_attributes(mod->module_init_rx,
76253 + mod->module_init_rx + mod->init_size_rx,
76254 set_memory_ro);
76255 }
76256 }
76257 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
76258
76259 /* This may be NULL, but that's OK */
76260 unset_module_init_ro_nx(mod);
76261 - module_free(mod, mod->module_init);
76262 + module_free(mod, mod->module_init_rw);
76263 + module_free_exec(mod, mod->module_init_rx);
76264 kfree(mod->args);
76265 percpu_modfree(mod);
76266
76267 /* Free lock-classes: */
76268 - lockdep_free_key_range(mod->module_core, mod->core_size);
76269 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76270 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76271
76272 /* Finally, free the core (containing the module structure) */
76273 unset_module_core_ro_nx(mod);
76274 - module_free(mod, mod->module_core);
76275 + module_free_exec(mod, mod->module_core_rx);
76276 + module_free(mod, mod->module_core_rw);
76277
76278 #ifdef CONFIG_MPU
76279 update_protections(current->mm);
76280 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76281 int ret = 0;
76282 const struct kernel_symbol *ksym;
76283
76284 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76285 + int is_fs_load = 0;
76286 + int register_filesystem_found = 0;
76287 + char *p;
76288 +
76289 + p = strstr(mod->args, "grsec_modharden_fs");
76290 + if (p) {
76291 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76292 + /* copy \0 as well */
76293 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76294 + is_fs_load = 1;
76295 + }
76296 +#endif
76297 +
76298 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76299 const char *name = info->strtab + sym[i].st_name;
76300
76301 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76302 + /* it's a real shame this will never get ripped and copied
76303 + upstream! ;(
76304 + */
76305 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76306 + register_filesystem_found = 1;
76307 +#endif
76308 +
76309 switch (sym[i].st_shndx) {
76310 case SHN_COMMON:
76311 /* We compiled with -fno-common. These are not
76312 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76313 ksym = resolve_symbol_wait(mod, info, name);
76314 /* Ok if resolved. */
76315 if (ksym && !IS_ERR(ksym)) {
76316 + pax_open_kernel();
76317 sym[i].st_value = ksym->value;
76318 + pax_close_kernel();
76319 break;
76320 }
76321
76322 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76323 secbase = (unsigned long)mod_percpu(mod);
76324 else
76325 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76326 + pax_open_kernel();
76327 sym[i].st_value += secbase;
76328 + pax_close_kernel();
76329 break;
76330 }
76331 }
76332
76333 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76334 + if (is_fs_load && !register_filesystem_found) {
76335 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76336 + ret = -EPERM;
76337 + }
76338 +#endif
76339 +
76340 return ret;
76341 }
76342
76343 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76344 || s->sh_entsize != ~0UL
76345 || strstarts(sname, ".init"))
76346 continue;
76347 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76348 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76349 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76350 + else
76351 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76352 pr_debug("\t%s\n", sname);
76353 }
76354 - switch (m) {
76355 - case 0: /* executable */
76356 - mod->core_size = debug_align(mod->core_size);
76357 - mod->core_text_size = mod->core_size;
76358 - break;
76359 - case 1: /* RO: text and ro-data */
76360 - mod->core_size = debug_align(mod->core_size);
76361 - mod->core_ro_size = mod->core_size;
76362 - break;
76363 - case 3: /* whole core */
76364 - mod->core_size = debug_align(mod->core_size);
76365 - break;
76366 - }
76367 }
76368
76369 pr_debug("Init section allocation order:\n");
76370 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76371 || s->sh_entsize != ~0UL
76372 || !strstarts(sname, ".init"))
76373 continue;
76374 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76375 - | INIT_OFFSET_MASK);
76376 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76377 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76378 + else
76379 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76380 + s->sh_entsize |= INIT_OFFSET_MASK;
76381 pr_debug("\t%s\n", sname);
76382 }
76383 - switch (m) {
76384 - case 0: /* executable */
76385 - mod->init_size = debug_align(mod->init_size);
76386 - mod->init_text_size = mod->init_size;
76387 - break;
76388 - case 1: /* RO: text and ro-data */
76389 - mod->init_size = debug_align(mod->init_size);
76390 - mod->init_ro_size = mod->init_size;
76391 - break;
76392 - case 3: /* whole init */
76393 - mod->init_size = debug_align(mod->init_size);
76394 - break;
76395 - }
76396 }
76397 }
76398
76399 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76400
76401 /* Put symbol section at end of init part of module. */
76402 symsect->sh_flags |= SHF_ALLOC;
76403 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76404 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76405 info->index.sym) | INIT_OFFSET_MASK;
76406 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76407
76408 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76409 }
76410
76411 /* Append room for core symbols at end of core part. */
76412 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76413 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76414 - mod->core_size += strtab_size;
76415 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76416 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76417 + mod->core_size_rx += strtab_size;
76418
76419 /* Put string table section at end of init part of module. */
76420 strsect->sh_flags |= SHF_ALLOC;
76421 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76422 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76423 info->index.str) | INIT_OFFSET_MASK;
76424 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76425 }
76426 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76427 /* Make sure we get permanent strtab: don't use info->strtab. */
76428 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76429
76430 + pax_open_kernel();
76431 +
76432 /* Set types up while we still have access to sections. */
76433 for (i = 0; i < mod->num_symtab; i++)
76434 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76435
76436 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76437 - mod->core_strtab = s = mod->module_core + info->stroffs;
76438 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76439 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76440 src = mod->symtab;
76441 for (ndst = i = 0; i < mod->num_symtab; i++) {
76442 if (i == 0 ||
76443 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76444 }
76445 }
76446 mod->core_num_syms = ndst;
76447 +
76448 + pax_close_kernel();
76449 }
76450 #else
76451 static inline void layout_symtab(struct module *mod, struct load_info *info)
76452 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
76453 return vmalloc_exec(size);
76454 }
76455
76456 -static void *module_alloc_update_bounds(unsigned long size)
76457 +static void *module_alloc_update_bounds_rw(unsigned long size)
76458 {
76459 void *ret = module_alloc(size);
76460
76461 if (ret) {
76462 mutex_lock(&module_mutex);
76463 /* Update module bounds. */
76464 - if ((unsigned long)ret < module_addr_min)
76465 - module_addr_min = (unsigned long)ret;
76466 - if ((unsigned long)ret + size > module_addr_max)
76467 - module_addr_max = (unsigned long)ret + size;
76468 + if ((unsigned long)ret < module_addr_min_rw)
76469 + module_addr_min_rw = (unsigned long)ret;
76470 + if ((unsigned long)ret + size > module_addr_max_rw)
76471 + module_addr_max_rw = (unsigned long)ret + size;
76472 + mutex_unlock(&module_mutex);
76473 + }
76474 + return ret;
76475 +}
76476 +
76477 +static void *module_alloc_update_bounds_rx(unsigned long size)
76478 +{
76479 + void *ret = module_alloc_exec(size);
76480 +
76481 + if (ret) {
76482 + mutex_lock(&module_mutex);
76483 + /* Update module bounds. */
76484 + if ((unsigned long)ret < module_addr_min_rx)
76485 + module_addr_min_rx = (unsigned long)ret;
76486 + if ((unsigned long)ret + size > module_addr_max_rx)
76487 + module_addr_max_rx = (unsigned long)ret + size;
76488 mutex_unlock(&module_mutex);
76489 }
76490 return ret;
76491 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76492 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76493 {
76494 const char *modmagic = get_modinfo(info, "vermagic");
76495 + const char *license = get_modinfo(info, "license");
76496 int err;
76497
76498 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76499 + if (!license || !license_is_gpl_compatible(license))
76500 + return -ENOEXEC;
76501 +#endif
76502 +
76503 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76504 modmagic = NULL;
76505
76506 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76507 }
76508
76509 /* Set up license info based on the info section */
76510 - set_license(mod, get_modinfo(info, "license"));
76511 + set_license(mod, license);
76512
76513 return 0;
76514 }
76515 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
76516 void *ptr;
76517
76518 /* Do the allocs. */
76519 - ptr = module_alloc_update_bounds(mod->core_size);
76520 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76521 /*
76522 * The pointer to this block is stored in the module structure
76523 * which is inside the block. Just mark it as not being a
76524 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
76525 if (!ptr)
76526 return -ENOMEM;
76527
76528 - memset(ptr, 0, mod->core_size);
76529 - mod->module_core = ptr;
76530 + memset(ptr, 0, mod->core_size_rw);
76531 + mod->module_core_rw = ptr;
76532
76533 - if (mod->init_size) {
76534 - ptr = module_alloc_update_bounds(mod->init_size);
76535 + if (mod->init_size_rw) {
76536 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76537 /*
76538 * The pointer to this block is stored in the module structure
76539 * which is inside the block. This block doesn't need to be
76540 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
76541 */
76542 kmemleak_ignore(ptr);
76543 if (!ptr) {
76544 - module_free(mod, mod->module_core);
76545 + module_free(mod, mod->module_core_rw);
76546 return -ENOMEM;
76547 }
76548 - memset(ptr, 0, mod->init_size);
76549 - mod->module_init = ptr;
76550 + memset(ptr, 0, mod->init_size_rw);
76551 + mod->module_init_rw = ptr;
76552 } else
76553 - mod->module_init = NULL;
76554 + mod->module_init_rw = NULL;
76555 +
76556 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76557 + kmemleak_not_leak(ptr);
76558 + if (!ptr) {
76559 + if (mod->module_init_rw)
76560 + module_free(mod, mod->module_init_rw);
76561 + module_free(mod, mod->module_core_rw);
76562 + return -ENOMEM;
76563 + }
76564 +
76565 + pax_open_kernel();
76566 + memset(ptr, 0, mod->core_size_rx);
76567 + pax_close_kernel();
76568 + mod->module_core_rx = ptr;
76569 +
76570 + if (mod->init_size_rx) {
76571 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76572 + kmemleak_ignore(ptr);
76573 + if (!ptr && mod->init_size_rx) {
76574 + module_free_exec(mod, mod->module_core_rx);
76575 + if (mod->module_init_rw)
76576 + module_free(mod, mod->module_init_rw);
76577 + module_free(mod, mod->module_core_rw);
76578 + return -ENOMEM;
76579 + }
76580 +
76581 + pax_open_kernel();
76582 + memset(ptr, 0, mod->init_size_rx);
76583 + pax_close_kernel();
76584 + mod->module_init_rx = ptr;
76585 + } else
76586 + mod->module_init_rx = NULL;
76587
76588 /* Transfer each section which specifies SHF_ALLOC */
76589 pr_debug("final section addresses:\n");
76590 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
76591 if (!(shdr->sh_flags & SHF_ALLOC))
76592 continue;
76593
76594 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76595 - dest = mod->module_init
76596 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76597 - else
76598 - dest = mod->module_core + shdr->sh_entsize;
76599 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76600 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76601 + dest = mod->module_init_rw
76602 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76603 + else
76604 + dest = mod->module_init_rx
76605 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76606 + } else {
76607 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76608 + dest = mod->module_core_rw + shdr->sh_entsize;
76609 + else
76610 + dest = mod->module_core_rx + shdr->sh_entsize;
76611 + }
76612 +
76613 + if (shdr->sh_type != SHT_NOBITS) {
76614 +
76615 +#ifdef CONFIG_PAX_KERNEXEC
76616 +#ifdef CONFIG_X86_64
76617 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76618 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76619 +#endif
76620 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76621 + pax_open_kernel();
76622 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76623 + pax_close_kernel();
76624 + } else
76625 +#endif
76626
76627 - if (shdr->sh_type != SHT_NOBITS)
76628 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76629 + }
76630 /* Update sh_addr to point to copy in image. */
76631 - shdr->sh_addr = (unsigned long)dest;
76632 +
76633 +#ifdef CONFIG_PAX_KERNEXEC
76634 + if (shdr->sh_flags & SHF_EXECINSTR)
76635 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76636 + else
76637 +#endif
76638 +
76639 + shdr->sh_addr = (unsigned long)dest;
76640 pr_debug("\t0x%lx %s\n",
76641 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76642 }
76643 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
76644 * Do it before processing of module parameters, so the module
76645 * can provide parameter accessor functions of its own.
76646 */
76647 - if (mod->module_init)
76648 - flush_icache_range((unsigned long)mod->module_init,
76649 - (unsigned long)mod->module_init
76650 - + mod->init_size);
76651 - flush_icache_range((unsigned long)mod->module_core,
76652 - (unsigned long)mod->module_core + mod->core_size);
76653 + if (mod->module_init_rx)
76654 + flush_icache_range((unsigned long)mod->module_init_rx,
76655 + (unsigned long)mod->module_init_rx
76656 + + mod->init_size_rx);
76657 + flush_icache_range((unsigned long)mod->module_core_rx,
76658 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76659
76660 set_fs(old_fs);
76661 }
76662 @@ -2983,8 +3088,10 @@ out:
76663 static void module_deallocate(struct module *mod, struct load_info *info)
76664 {
76665 percpu_modfree(mod);
76666 - module_free(mod, mod->module_init);
76667 - module_free(mod, mod->module_core);
76668 + module_free_exec(mod, mod->module_init_rx);
76669 + module_free_exec(mod, mod->module_core_rx);
76670 + module_free(mod, mod->module_init_rw);
76671 + module_free(mod, mod->module_core_rw);
76672 }
76673
76674 int __weak module_finalize(const Elf_Ehdr *hdr,
76675 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76676 static int post_relocation(struct module *mod, const struct load_info *info)
76677 {
76678 /* Sort exception table now relocations are done. */
76679 + pax_open_kernel();
76680 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76681 + pax_close_kernel();
76682
76683 /* Copy relocated percpu area over. */
76684 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76685 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
76686 MODULE_STATE_COMING, mod);
76687
76688 /* Set RO and NX regions for core */
76689 - set_section_ro_nx(mod->module_core,
76690 - mod->core_text_size,
76691 - mod->core_ro_size,
76692 - mod->core_size);
76693 + set_section_ro_nx(mod->module_core_rx,
76694 + mod->core_size_rx,
76695 + mod->core_size_rx,
76696 + mod->core_size_rx);
76697
76698 /* Set RO and NX regions for init */
76699 - set_section_ro_nx(mod->module_init,
76700 - mod->init_text_size,
76701 - mod->init_ro_size,
76702 - mod->init_size);
76703 + set_section_ro_nx(mod->module_init_rx,
76704 + mod->init_size_rx,
76705 + mod->init_size_rx,
76706 + mod->init_size_rx);
76707
76708 do_mod_ctors(mod);
76709 /* Start the module */
76710 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
76711 mod->strtab = mod->core_strtab;
76712 #endif
76713 unset_module_init_ro_nx(mod);
76714 - module_free(mod, mod->module_init);
76715 - mod->module_init = NULL;
76716 - mod->init_size = 0;
76717 - mod->init_ro_size = 0;
76718 - mod->init_text_size = 0;
76719 + module_free(mod, mod->module_init_rw);
76720 + module_free_exec(mod, mod->module_init_rx);
76721 + mod->module_init_rw = NULL;
76722 + mod->module_init_rx = NULL;
76723 + mod->init_size_rw = 0;
76724 + mod->init_size_rx = 0;
76725 mutex_unlock(&module_mutex);
76726 wake_up_all(&module_wq);
76727
76728 @@ -3209,9 +3319,38 @@ again:
76729 if (err)
76730 goto free_unload;
76731
76732 + /* Now copy in args */
76733 + mod->args = strndup_user(uargs, ~0UL >> 1);
76734 + if (IS_ERR(mod->args)) {
76735 + err = PTR_ERR(mod->args);
76736 + goto free_unload;
76737 + }
76738 +
76739 /* Set up MODINFO_ATTR fields */
76740 setup_modinfo(mod, info);
76741
76742 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76743 + {
76744 + char *p, *p2;
76745 +
76746 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76747 + 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);
76748 + err = -EPERM;
76749 + goto free_modinfo;
76750 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76751 + p += sizeof("grsec_modharden_normal") - 1;
76752 + p2 = strstr(p, "_");
76753 + if (p2) {
76754 + *p2 = '\0';
76755 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76756 + *p2 = '_';
76757 + }
76758 + err = -EPERM;
76759 + goto free_modinfo;
76760 + }
76761 + }
76762 +#endif
76763 +
76764 /* Fix up syms, so that st_value is a pointer to location. */
76765 err = simplify_symbols(mod, info);
76766 if (err < 0)
76767 @@ -3227,13 +3366,6 @@ again:
76768
76769 flush_module_icache(mod);
76770
76771 - /* Now copy in args */
76772 - mod->args = strndup_user(uargs, ~0UL >> 1);
76773 - if (IS_ERR(mod->args)) {
76774 - err = PTR_ERR(mod->args);
76775 - goto free_arch_cleanup;
76776 - }
76777 -
76778 dynamic_debug_setup(info->debug, info->num_debug);
76779
76780 mutex_lock(&module_mutex);
76781 @@ -3278,11 +3410,10 @@ again:
76782 mutex_unlock(&module_mutex);
76783 dynamic_debug_remove(info->debug);
76784 synchronize_sched();
76785 - kfree(mod->args);
76786 - free_arch_cleanup:
76787 module_arch_cleanup(mod);
76788 free_modinfo:
76789 free_modinfo(mod);
76790 + kfree(mod->args);
76791 free_unload:
76792 module_unload_free(mod);
76793 unlink_mod:
76794 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
76795 unsigned long nextval;
76796
76797 /* At worse, next value is at end of module */
76798 - if (within_module_init(addr, mod))
76799 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76800 + if (within_module_init_rx(addr, mod))
76801 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76802 + else if (within_module_init_rw(addr, mod))
76803 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76804 + else if (within_module_core_rx(addr, mod))
76805 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76806 + else if (within_module_core_rw(addr, mod))
76807 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76808 else
76809 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76810 + return NULL;
76811
76812 /* Scan for closest preceding symbol, and next symbol. (ELF
76813 starts real symbols at 1). */
76814 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
76815 return 0;
76816
76817 seq_printf(m, "%s %u",
76818 - mod->name, mod->init_size + mod->core_size);
76819 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76820 print_unload_info(m, mod);
76821
76822 /* Informative for users. */
76823 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
76824 mod->state == MODULE_STATE_COMING ? "Loading":
76825 "Live");
76826 /* Used by oprofile and other similar tools. */
76827 - seq_printf(m, " 0x%pK", mod->module_core);
76828 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76829
76830 /* Taints info */
76831 if (mod->taints)
76832 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
76833
76834 static int __init proc_modules_init(void)
76835 {
76836 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76837 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76838 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76839 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76840 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76841 +#else
76842 proc_create("modules", 0, NULL, &proc_modules_operations);
76843 +#endif
76844 +#else
76845 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76846 +#endif
76847 return 0;
76848 }
76849 module_init(proc_modules_init);
76850 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
76851 {
76852 struct module *mod;
76853
76854 - if (addr < module_addr_min || addr > module_addr_max)
76855 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76856 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76857 return NULL;
76858
76859 list_for_each_entry_rcu(mod, &modules, list) {
76860 if (mod->state == MODULE_STATE_UNFORMED)
76861 continue;
76862 - if (within_module_core(addr, mod)
76863 - || within_module_init(addr, mod))
76864 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76865 return mod;
76866 }
76867 return NULL;
76868 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
76869 */
76870 struct module *__module_text_address(unsigned long addr)
76871 {
76872 - struct module *mod = __module_address(addr);
76873 + struct module *mod;
76874 +
76875 +#ifdef CONFIG_X86_32
76876 + addr = ktla_ktva(addr);
76877 +#endif
76878 +
76879 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76880 + return NULL;
76881 +
76882 + mod = __module_address(addr);
76883 +
76884 if (mod) {
76885 /* Make sure it's within the text section. */
76886 - if (!within(addr, mod->module_init, mod->init_text_size)
76887 - && !within(addr, mod->module_core, mod->core_text_size))
76888 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76889 mod = NULL;
76890 }
76891 return mod;
76892 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76893 index 7e3443f..b2a1e6b 100644
76894 --- a/kernel/mutex-debug.c
76895 +++ b/kernel/mutex-debug.c
76896 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76897 }
76898
76899 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76900 - struct thread_info *ti)
76901 + struct task_struct *task)
76902 {
76903 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76904
76905 /* Mark the current thread as blocked on the lock: */
76906 - ti->task->blocked_on = waiter;
76907 + task->blocked_on = waiter;
76908 }
76909
76910 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76911 - struct thread_info *ti)
76912 + struct task_struct *task)
76913 {
76914 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76915 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76916 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76917 - ti->task->blocked_on = NULL;
76918 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76919 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76920 + task->blocked_on = NULL;
76921
76922 list_del_init(&waiter->list);
76923 waiter->task = NULL;
76924 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76925 index 0799fd3..d06ae3b 100644
76926 --- a/kernel/mutex-debug.h
76927 +++ b/kernel/mutex-debug.h
76928 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76929 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76930 extern void debug_mutex_add_waiter(struct mutex *lock,
76931 struct mutex_waiter *waiter,
76932 - struct thread_info *ti);
76933 + struct task_struct *task);
76934 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76935 - struct thread_info *ti);
76936 + struct task_struct *task);
76937 extern void debug_mutex_unlock(struct mutex *lock);
76938 extern void debug_mutex_init(struct mutex *lock, const char *name,
76939 struct lock_class_key *key);
76940 diff --git a/kernel/mutex.c b/kernel/mutex.c
76941 index a307cc9..27fd2e9 100644
76942 --- a/kernel/mutex.c
76943 +++ b/kernel/mutex.c
76944 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76945 spin_lock_mutex(&lock->wait_lock, flags);
76946
76947 debug_mutex_lock_common(lock, &waiter);
76948 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76949 + debug_mutex_add_waiter(lock, &waiter, task);
76950
76951 /* add waiting tasks to the end of the waitqueue (FIFO): */
76952 list_add_tail(&waiter.list, &lock->wait_list);
76953 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76954 * TASK_UNINTERRUPTIBLE case.)
76955 */
76956 if (unlikely(signal_pending_state(state, task))) {
76957 - mutex_remove_waiter(lock, &waiter,
76958 - task_thread_info(task));
76959 + mutex_remove_waiter(lock, &waiter, task);
76960 mutex_release(&lock->dep_map, 1, ip);
76961 spin_unlock_mutex(&lock->wait_lock, flags);
76962
76963 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76964 done:
76965 lock_acquired(&lock->dep_map, ip);
76966 /* got the lock - rejoice! */
76967 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76968 + mutex_remove_waiter(lock, &waiter, task);
76969 mutex_set_owner(lock);
76970
76971 /* set it to 0 if there are no waiters left: */
76972 diff --git a/kernel/notifier.c b/kernel/notifier.c
76973 index 2d5cc4c..d9ea600 100644
76974 --- a/kernel/notifier.c
76975 +++ b/kernel/notifier.c
76976 @@ -5,6 +5,7 @@
76977 #include <linux/rcupdate.h>
76978 #include <linux/vmalloc.h>
76979 #include <linux/reboot.h>
76980 +#include <linux/mm.h>
76981
76982 /*
76983 * Notifier list for kernel code which wants to be called
76984 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76985 while ((*nl) != NULL) {
76986 if (n->priority > (*nl)->priority)
76987 break;
76988 - nl = &((*nl)->next);
76989 + nl = (struct notifier_block **)&((*nl)->next);
76990 }
76991 - n->next = *nl;
76992 + pax_open_kernel();
76993 + *(const void **)&n->next = *nl;
76994 rcu_assign_pointer(*nl, n);
76995 + pax_close_kernel();
76996 return 0;
76997 }
76998
76999 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
77000 return 0;
77001 if (n->priority > (*nl)->priority)
77002 break;
77003 - nl = &((*nl)->next);
77004 + nl = (struct notifier_block **)&((*nl)->next);
77005 }
77006 - n->next = *nl;
77007 + pax_open_kernel();
77008 + *(const void **)&n->next = *nl;
77009 rcu_assign_pointer(*nl, n);
77010 + pax_close_kernel();
77011 return 0;
77012 }
77013
77014 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
77015 {
77016 while ((*nl) != NULL) {
77017 if ((*nl) == n) {
77018 + pax_open_kernel();
77019 rcu_assign_pointer(*nl, n->next);
77020 + pax_close_kernel();
77021 return 0;
77022 }
77023 - nl = &((*nl)->next);
77024 + nl = (struct notifier_block **)&((*nl)->next);
77025 }
77026 return -ENOENT;
77027 }
77028 diff --git a/kernel/panic.c b/kernel/panic.c
77029 index e1b2822..5edc1d9 100644
77030 --- a/kernel/panic.c
77031 +++ b/kernel/panic.c
77032 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77033 const char *board;
77034
77035 printk(KERN_WARNING "------------[ cut here ]------------\n");
77036 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77037 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77038 board = dmi_get_system_info(DMI_PRODUCT_NAME);
77039 if (board)
77040 printk(KERN_WARNING "Hardware name: %s\n", board);
77041 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77042 */
77043 void __stack_chk_fail(void)
77044 {
77045 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77046 + dump_stack();
77047 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77048 __builtin_return_address(0));
77049 }
77050 EXPORT_SYMBOL(__stack_chk_fail);
77051 diff --git a/kernel/pid.c b/kernel/pid.c
77052 index f2c6a68..4922d97 100644
77053 --- a/kernel/pid.c
77054 +++ b/kernel/pid.c
77055 @@ -33,6 +33,7 @@
77056 #include <linux/rculist.h>
77057 #include <linux/bootmem.h>
77058 #include <linux/hash.h>
77059 +#include <linux/security.h>
77060 #include <linux/pid_namespace.h>
77061 #include <linux/init_task.h>
77062 #include <linux/syscalls.h>
77063 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77064
77065 int pid_max = PID_MAX_DEFAULT;
77066
77067 -#define RESERVED_PIDS 300
77068 +#define RESERVED_PIDS 500
77069
77070 int pid_max_min = RESERVED_PIDS + 1;
77071 int pid_max_max = PID_MAX_LIMIT;
77072 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
77073 */
77074 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77075 {
77076 + struct task_struct *task;
77077 +
77078 rcu_lockdep_assert(rcu_read_lock_held(),
77079 "find_task_by_pid_ns() needs rcu_read_lock()"
77080 " protection");
77081 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77082 +
77083 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77084 +
77085 + if (gr_pid_is_chrooted(task))
77086 + return NULL;
77087 +
77088 + return task;
77089 }
77090
77091 struct task_struct *find_task_by_vpid(pid_t vnr)
77092 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77093 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77094 }
77095
77096 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77097 +{
77098 + rcu_lockdep_assert(rcu_read_lock_held(),
77099 + "find_task_by_pid_ns() needs rcu_read_lock()"
77100 + " protection");
77101 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77102 +}
77103 +
77104 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77105 {
77106 struct pid *pid;
77107 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77108 index bea15bd..789f3d0 100644
77109 --- a/kernel/pid_namespace.c
77110 +++ b/kernel/pid_namespace.c
77111 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77112 void __user *buffer, size_t *lenp, loff_t *ppos)
77113 {
77114 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77115 - struct ctl_table tmp = *table;
77116 + ctl_table_no_const tmp = *table;
77117
77118 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77119 return -EPERM;
77120 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77121 index 942ca27..111e609 100644
77122 --- a/kernel/posix-cpu-timers.c
77123 +++ b/kernel/posix-cpu-timers.c
77124 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
77125
77126 static __init int init_posix_cpu_timers(void)
77127 {
77128 - struct k_clock process = {
77129 + static struct k_clock process = {
77130 .clock_getres = process_cpu_clock_getres,
77131 .clock_get = process_cpu_clock_get,
77132 .timer_create = process_cpu_timer_create,
77133 .nsleep = process_cpu_nsleep,
77134 .nsleep_restart = process_cpu_nsleep_restart,
77135 };
77136 - struct k_clock thread = {
77137 + static struct k_clock thread = {
77138 .clock_getres = thread_cpu_clock_getres,
77139 .clock_get = thread_cpu_clock_get,
77140 .timer_create = thread_cpu_timer_create,
77141 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77142 index e885be1..380fe76 100644
77143 --- a/kernel/posix-timers.c
77144 +++ b/kernel/posix-timers.c
77145 @@ -43,6 +43,7 @@
77146 #include <linux/idr.h>
77147 #include <linux/posix-clock.h>
77148 #include <linux/posix-timers.h>
77149 +#include <linux/grsecurity.h>
77150 #include <linux/syscalls.h>
77151 #include <linux/wait.h>
77152 #include <linux/workqueue.h>
77153 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77154 * which we beg off on and pass to do_sys_settimeofday().
77155 */
77156
77157 -static struct k_clock posix_clocks[MAX_CLOCKS];
77158 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77159
77160 /*
77161 * These ones are defined below.
77162 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77163 */
77164 static __init int init_posix_timers(void)
77165 {
77166 - struct k_clock clock_realtime = {
77167 + static struct k_clock clock_realtime = {
77168 .clock_getres = hrtimer_get_res,
77169 .clock_get = posix_clock_realtime_get,
77170 .clock_set = posix_clock_realtime_set,
77171 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
77172 .timer_get = common_timer_get,
77173 .timer_del = common_timer_del,
77174 };
77175 - struct k_clock clock_monotonic = {
77176 + static struct k_clock clock_monotonic = {
77177 .clock_getres = hrtimer_get_res,
77178 .clock_get = posix_ktime_get_ts,
77179 .nsleep = common_nsleep,
77180 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77181 .timer_get = common_timer_get,
77182 .timer_del = common_timer_del,
77183 };
77184 - struct k_clock clock_monotonic_raw = {
77185 + static struct k_clock clock_monotonic_raw = {
77186 .clock_getres = hrtimer_get_res,
77187 .clock_get = posix_get_monotonic_raw,
77188 };
77189 - struct k_clock clock_realtime_coarse = {
77190 + static struct k_clock clock_realtime_coarse = {
77191 .clock_getres = posix_get_coarse_res,
77192 .clock_get = posix_get_realtime_coarse,
77193 };
77194 - struct k_clock clock_monotonic_coarse = {
77195 + static struct k_clock clock_monotonic_coarse = {
77196 .clock_getres = posix_get_coarse_res,
77197 .clock_get = posix_get_monotonic_coarse,
77198 };
77199 - struct k_clock clock_boottime = {
77200 + static struct k_clock clock_boottime = {
77201 .clock_getres = hrtimer_get_res,
77202 .clock_get = posix_get_boottime,
77203 .nsleep = common_nsleep,
77204 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77205 return;
77206 }
77207
77208 - posix_clocks[clock_id] = *new_clock;
77209 + posix_clocks[clock_id] = new_clock;
77210 }
77211 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77212
77213 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77214 return (id & CLOCKFD_MASK) == CLOCKFD ?
77215 &clock_posix_dynamic : &clock_posix_cpu;
77216
77217 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77218 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77219 return NULL;
77220 - return &posix_clocks[id];
77221 + return posix_clocks[id];
77222 }
77223
77224 static int common_timer_create(struct k_itimer *new_timer)
77225 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77226 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77227 return -EFAULT;
77228
77229 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77230 + have their clock_set fptr set to a nosettime dummy function
77231 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77232 + call common_clock_set, which calls do_sys_settimeofday, which
77233 + we hook
77234 + */
77235 +
77236 return kc->clock_set(which_clock, &new_tp);
77237 }
77238
77239 diff --git a/kernel/power/process.c b/kernel/power/process.c
77240 index d5a258b..4271191 100644
77241 --- a/kernel/power/process.c
77242 +++ b/kernel/power/process.c
77243 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77244 u64 elapsed_csecs64;
77245 unsigned int elapsed_csecs;
77246 bool wakeup = false;
77247 + bool timedout = false;
77248
77249 do_gettimeofday(&start);
77250
77251 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77252
77253 while (true) {
77254 todo = 0;
77255 + if (time_after(jiffies, end_time))
77256 + timedout = true;
77257 read_lock(&tasklist_lock);
77258 do_each_thread(g, p) {
77259 if (p == current || !freeze_task(p))
77260 continue;
77261
77262 - if (!freezer_should_skip(p))
77263 + if (!freezer_should_skip(p)) {
77264 todo++;
77265 + if (timedout) {
77266 + printk(KERN_ERR "Task refusing to freeze:\n");
77267 + sched_show_task(p);
77268 + }
77269 + }
77270 } while_each_thread(g, p);
77271 read_unlock(&tasklist_lock);
77272
77273 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77274 todo += wq_busy;
77275 }
77276
77277 - if (!todo || time_after(jiffies, end_time))
77278 + if (!todo || timedout)
77279 break;
77280
77281 if (pm_wakeup_pending()) {
77282 diff --git a/kernel/printk.c b/kernel/printk.c
77283 index 267ce78..2487112 100644
77284 --- a/kernel/printk.c
77285 +++ b/kernel/printk.c
77286 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
77287 return ret;
77288 }
77289
77290 +static int check_syslog_permissions(int type, bool from_file);
77291 +
77292 static int devkmsg_open(struct inode *inode, struct file *file)
77293 {
77294 struct devkmsg_user *user;
77295 int err;
77296
77297 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
77298 + if (err)
77299 + return err;
77300 +
77301 /* write-only does not need any file context */
77302 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
77303 return 0;
77304 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
77305 if (dmesg_restrict)
77306 return 1;
77307 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
77308 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77309 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77310 }
77311
77312 static int check_syslog_permissions(int type, bool from_file)
77313 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
77314 if (from_file && type != SYSLOG_ACTION_OPEN)
77315 return 0;
77316
77317 +#ifdef CONFIG_GRKERNSEC_DMESG
77318 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77319 + return -EPERM;
77320 +#endif
77321 +
77322 if (syslog_action_restricted(type)) {
77323 if (capable(CAP_SYSLOG))
77324 return 0;
77325 diff --git a/kernel/profile.c b/kernel/profile.c
77326 index 1f39181..86093471 100644
77327 --- a/kernel/profile.c
77328 +++ b/kernel/profile.c
77329 @@ -40,7 +40,7 @@ struct profile_hit {
77330 /* Oprofile timer tick hook */
77331 static int (*timer_hook)(struct pt_regs *) __read_mostly;
77332
77333 -static atomic_t *prof_buffer;
77334 +static atomic_unchecked_t *prof_buffer;
77335 static unsigned long prof_len, prof_shift;
77336
77337 int prof_on __read_mostly;
77338 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
77339 hits[i].pc = 0;
77340 continue;
77341 }
77342 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77343 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77344 hits[i].hits = hits[i].pc = 0;
77345 }
77346 }
77347 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77348 * Add the current hit(s) and flush the write-queue out
77349 * to the global buffer:
77350 */
77351 - atomic_add(nr_hits, &prof_buffer[pc]);
77352 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77353 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77354 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77355 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77356 hits[i].pc = hits[i].hits = 0;
77357 }
77358 out:
77359 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77360 {
77361 unsigned long pc;
77362 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77363 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77364 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77365 }
77366 #endif /* !CONFIG_SMP */
77367
77368 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77369 return -EFAULT;
77370 buf++; p++; count--; read++;
77371 }
77372 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77373 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77374 if (copy_to_user(buf, (void *)pnt, count))
77375 return -EFAULT;
77376 read += count;
77377 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77378 }
77379 #endif
77380 profile_discard_flip_buffers();
77381 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77382 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77383 return count;
77384 }
77385
77386 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77387 index 6cbeaae..cfe7ff0 100644
77388 --- a/kernel/ptrace.c
77389 +++ b/kernel/ptrace.c
77390 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77391 if (seize)
77392 flags |= PT_SEIZED;
77393 rcu_read_lock();
77394 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77395 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77396 flags |= PT_PTRACE_CAP;
77397 rcu_read_unlock();
77398 task->ptrace = flags;
77399 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77400 break;
77401 return -EIO;
77402 }
77403 - if (copy_to_user(dst, buf, retval))
77404 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77405 return -EFAULT;
77406 copied += retval;
77407 src += retval;
77408 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
77409 bool seized = child->ptrace & PT_SEIZED;
77410 int ret = -EIO;
77411 siginfo_t siginfo, *si;
77412 - void __user *datavp = (void __user *) data;
77413 + void __user *datavp = (__force void __user *) data;
77414 unsigned long __user *datalp = datavp;
77415 unsigned long flags;
77416
77417 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77418 goto out;
77419 }
77420
77421 + if (gr_handle_ptrace(child, request)) {
77422 + ret = -EPERM;
77423 + goto out_put_task_struct;
77424 + }
77425 +
77426 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77427 ret = ptrace_attach(child, request, addr, data);
77428 /*
77429 * Some architectures need to do book-keeping after
77430 * a ptrace attach.
77431 */
77432 - if (!ret)
77433 + if (!ret) {
77434 arch_ptrace_attach(child);
77435 + gr_audit_ptrace(child);
77436 + }
77437 goto out_put_task_struct;
77438 }
77439
77440 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77441 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77442 if (copied != sizeof(tmp))
77443 return -EIO;
77444 - return put_user(tmp, (unsigned long __user *)data);
77445 + return put_user(tmp, (__force unsigned long __user *)data);
77446 }
77447
77448 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77449 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77450 }
77451
77452 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77453 - compat_long_t addr, compat_long_t data)
77454 + compat_ulong_t addr, compat_ulong_t data)
77455 {
77456 struct task_struct *child;
77457 long ret;
77458 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77459 goto out;
77460 }
77461
77462 + if (gr_handle_ptrace(child, request)) {
77463 + ret = -EPERM;
77464 + goto out_put_task_struct;
77465 + }
77466 +
77467 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77468 ret = ptrace_attach(child, request, addr, data);
77469 /*
77470 * Some architectures need to do book-keeping after
77471 * a ptrace attach.
77472 */
77473 - if (!ret)
77474 + if (!ret) {
77475 arch_ptrace_attach(child);
77476 + gr_audit_ptrace(child);
77477 + }
77478 goto out_put_task_struct;
77479 }
77480
77481 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77482 index e7dce58..ad0d7b7 100644
77483 --- a/kernel/rcutiny.c
77484 +++ b/kernel/rcutiny.c
77485 @@ -46,7 +46,7 @@
77486 struct rcu_ctrlblk;
77487 static void invoke_rcu_callbacks(void);
77488 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77489 -static void rcu_process_callbacks(struct softirq_action *unused);
77490 +static void rcu_process_callbacks(void);
77491 static void __call_rcu(struct rcu_head *head,
77492 void (*func)(struct rcu_head *rcu),
77493 struct rcu_ctrlblk *rcp);
77494 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77495 rcu_is_callbacks_kthread()));
77496 }
77497
77498 -static void rcu_process_callbacks(struct softirq_action *unused)
77499 +static void rcu_process_callbacks(void)
77500 {
77501 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77502 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77503 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77504 index f85016a..91cb03b 100644
77505 --- a/kernel/rcutiny_plugin.h
77506 +++ b/kernel/rcutiny_plugin.h
77507 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
77508 have_rcu_kthread_work = morework;
77509 local_irq_restore(flags);
77510 if (work)
77511 - rcu_process_callbacks(NULL);
77512 + rcu_process_callbacks();
77513 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77514 }
77515
77516 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77517 index 31dea01..ad91ffb 100644
77518 --- a/kernel/rcutorture.c
77519 +++ b/kernel/rcutorture.c
77520 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77521 { 0 };
77522 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77523 { 0 };
77524 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77525 -static atomic_t n_rcu_torture_alloc;
77526 -static atomic_t n_rcu_torture_alloc_fail;
77527 -static atomic_t n_rcu_torture_free;
77528 -static atomic_t n_rcu_torture_mberror;
77529 -static atomic_t n_rcu_torture_error;
77530 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77531 +static atomic_unchecked_t n_rcu_torture_alloc;
77532 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77533 +static atomic_unchecked_t n_rcu_torture_free;
77534 +static atomic_unchecked_t n_rcu_torture_mberror;
77535 +static atomic_unchecked_t n_rcu_torture_error;
77536 static long n_rcu_torture_barrier_error;
77537 static long n_rcu_torture_boost_ktrerror;
77538 static long n_rcu_torture_boost_rterror;
77539 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
77540
77541 spin_lock_bh(&rcu_torture_lock);
77542 if (list_empty(&rcu_torture_freelist)) {
77543 - atomic_inc(&n_rcu_torture_alloc_fail);
77544 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77545 spin_unlock_bh(&rcu_torture_lock);
77546 return NULL;
77547 }
77548 - atomic_inc(&n_rcu_torture_alloc);
77549 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77550 p = rcu_torture_freelist.next;
77551 list_del_init(p);
77552 spin_unlock_bh(&rcu_torture_lock);
77553 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
77554 static void
77555 rcu_torture_free(struct rcu_torture *p)
77556 {
77557 - atomic_inc(&n_rcu_torture_free);
77558 + atomic_inc_unchecked(&n_rcu_torture_free);
77559 spin_lock_bh(&rcu_torture_lock);
77560 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77561 spin_unlock_bh(&rcu_torture_lock);
77562 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
77563 i = rp->rtort_pipe_count;
77564 if (i > RCU_TORTURE_PIPE_LEN)
77565 i = RCU_TORTURE_PIPE_LEN;
77566 - atomic_inc(&rcu_torture_wcount[i]);
77567 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77568 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77569 rp->rtort_mbtest = 0;
77570 rcu_torture_free(rp);
77571 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77572 i = rp->rtort_pipe_count;
77573 if (i > RCU_TORTURE_PIPE_LEN)
77574 i = RCU_TORTURE_PIPE_LEN;
77575 - atomic_inc(&rcu_torture_wcount[i]);
77576 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77577 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77578 rp->rtort_mbtest = 0;
77579 list_del(&rp->rtort_free);
77580 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
77581 i = old_rp->rtort_pipe_count;
77582 if (i > RCU_TORTURE_PIPE_LEN)
77583 i = RCU_TORTURE_PIPE_LEN;
77584 - atomic_inc(&rcu_torture_wcount[i]);
77585 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77586 old_rp->rtort_pipe_count++;
77587 cur_ops->deferred_free(old_rp);
77588 }
77589 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
77590 }
77591 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77592 if (p->rtort_mbtest == 0)
77593 - atomic_inc(&n_rcu_torture_mberror);
77594 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77595 spin_lock(&rand_lock);
77596 cur_ops->read_delay(&rand);
77597 n_rcu_torture_timers++;
77598 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
77599 }
77600 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77601 if (p->rtort_mbtest == 0)
77602 - atomic_inc(&n_rcu_torture_mberror);
77603 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77604 cur_ops->read_delay(&rand);
77605 preempt_disable();
77606 pipe_count = p->rtort_pipe_count;
77607 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
77608 rcu_torture_current,
77609 rcu_torture_current_version,
77610 list_empty(&rcu_torture_freelist),
77611 - atomic_read(&n_rcu_torture_alloc),
77612 - atomic_read(&n_rcu_torture_alloc_fail),
77613 - atomic_read(&n_rcu_torture_free));
77614 + atomic_read_unchecked(&n_rcu_torture_alloc),
77615 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77616 + atomic_read_unchecked(&n_rcu_torture_free));
77617 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77618 - atomic_read(&n_rcu_torture_mberror),
77619 + atomic_read_unchecked(&n_rcu_torture_mberror),
77620 n_rcu_torture_boost_ktrerror,
77621 n_rcu_torture_boost_rterror);
77622 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77623 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
77624 n_barrier_attempts,
77625 n_rcu_torture_barrier_error);
77626 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77627 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77628 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77629 n_rcu_torture_barrier_error != 0 ||
77630 n_rcu_torture_boost_ktrerror != 0 ||
77631 n_rcu_torture_boost_rterror != 0 ||
77632 n_rcu_torture_boost_failure != 0 ||
77633 i > 1) {
77634 cnt += sprintf(&page[cnt], "!!! ");
77635 - atomic_inc(&n_rcu_torture_error);
77636 + atomic_inc_unchecked(&n_rcu_torture_error);
77637 WARN_ON_ONCE(1);
77638 }
77639 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77640 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
77641 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77642 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77643 cnt += sprintf(&page[cnt], " %d",
77644 - atomic_read(&rcu_torture_wcount[i]));
77645 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77646 }
77647 cnt += sprintf(&page[cnt], "\n");
77648 if (cur_ops->stats)
77649 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
77650
77651 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77652
77653 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77654 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77655 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77656 else if (n_online_successes != n_online_attempts ||
77657 n_offline_successes != n_offline_attempts)
77658 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
77659
77660 rcu_torture_current = NULL;
77661 rcu_torture_current_version = 0;
77662 - atomic_set(&n_rcu_torture_alloc, 0);
77663 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77664 - atomic_set(&n_rcu_torture_free, 0);
77665 - atomic_set(&n_rcu_torture_mberror, 0);
77666 - atomic_set(&n_rcu_torture_error, 0);
77667 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77668 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77669 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77670 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77671 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77672 n_rcu_torture_barrier_error = 0;
77673 n_rcu_torture_boost_ktrerror = 0;
77674 n_rcu_torture_boost_rterror = 0;
77675 n_rcu_torture_boost_failure = 0;
77676 n_rcu_torture_boosts = 0;
77677 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77678 - atomic_set(&rcu_torture_wcount[i], 0);
77679 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77680 for_each_possible_cpu(cpu) {
77681 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77682 per_cpu(rcu_torture_count, cpu)[i] = 0;
77683 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77684 index e441b77..dd54f17 100644
77685 --- a/kernel/rcutree.c
77686 +++ b/kernel/rcutree.c
77687 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77688 rcu_prepare_for_idle(smp_processor_id());
77689 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77690 smp_mb__before_atomic_inc(); /* See above. */
77691 - atomic_inc(&rdtp->dynticks);
77692 + atomic_inc_unchecked(&rdtp->dynticks);
77693 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77694 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77695 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77696
77697 /*
77698 * It is illegal to enter an extended quiescent state while
77699 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77700 int user)
77701 {
77702 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77703 - atomic_inc(&rdtp->dynticks);
77704 + atomic_inc_unchecked(&rdtp->dynticks);
77705 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77706 smp_mb__after_atomic_inc(); /* See above. */
77707 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77708 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77709 rcu_cleanup_after_idle(smp_processor_id());
77710 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77711 if (!user && !is_idle_task(current)) {
77712 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
77713 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77714
77715 if (rdtp->dynticks_nmi_nesting == 0 &&
77716 - (atomic_read(&rdtp->dynticks) & 0x1))
77717 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77718 return;
77719 rdtp->dynticks_nmi_nesting++;
77720 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77721 - atomic_inc(&rdtp->dynticks);
77722 + atomic_inc_unchecked(&rdtp->dynticks);
77723 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77724 smp_mb__after_atomic_inc(); /* See above. */
77725 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77726 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77727 }
77728
77729 /**
77730 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
77731 return;
77732 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77733 smp_mb__before_atomic_inc(); /* See above. */
77734 - atomic_inc(&rdtp->dynticks);
77735 + atomic_inc_unchecked(&rdtp->dynticks);
77736 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77737 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77738 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77739 }
77740
77741 /**
77742 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
77743 int ret;
77744
77745 preempt_disable();
77746 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77747 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77748 preempt_enable();
77749 return ret;
77750 }
77751 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
77752 */
77753 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77754 {
77755 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77756 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77757 return (rdp->dynticks_snap & 0x1) == 0;
77758 }
77759
77760 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77761 unsigned int curr;
77762 unsigned int snap;
77763
77764 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77765 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77766 snap = (unsigned int)rdp->dynticks_snap;
77767
77768 /*
77769 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
77770 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77771 */
77772 if (till_stall_check < 3) {
77773 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77774 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77775 till_stall_check = 3;
77776 } else if (till_stall_check > 300) {
77777 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77778 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77779 till_stall_check = 300;
77780 }
77781 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77782 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77783 rsp->qlen += rdp->qlen;
77784 rdp->n_cbs_orphaned += rdp->qlen;
77785 rdp->qlen_lazy = 0;
77786 - ACCESS_ONCE(rdp->qlen) = 0;
77787 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77788 }
77789
77790 /*
77791 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77792 }
77793 smp_mb(); /* List handling before counting for rcu_barrier(). */
77794 rdp->qlen_lazy -= count_lazy;
77795 - ACCESS_ONCE(rdp->qlen) -= count;
77796 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77797 rdp->n_cbs_invoked += count;
77798
77799 /* Reinstate batch limit if we have worked down the excess. */
77800 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77801 /*
77802 * Do RCU core processing for the current CPU.
77803 */
77804 -static void rcu_process_callbacks(struct softirq_action *unused)
77805 +static void rcu_process_callbacks(void)
77806 {
77807 struct rcu_state *rsp;
77808
77809 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77810 local_irq_restore(flags);
77811 return;
77812 }
77813 - ACCESS_ONCE(rdp->qlen)++;
77814 + ACCESS_ONCE_RW(rdp->qlen)++;
77815 if (lazy)
77816 rdp->qlen_lazy++;
77817 else
77818 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
77819 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77820 * course be required on a 64-bit system.
77821 */
77822 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77823 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77824 (ulong)atomic_long_read(&rsp->expedited_done) +
77825 ULONG_MAX / 8)) {
77826 synchronize_sched();
77827 - atomic_long_inc(&rsp->expedited_wrap);
77828 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77829 return;
77830 }
77831
77832 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
77833 * Take a ticket. Note that atomic_inc_return() implies a
77834 * full memory barrier.
77835 */
77836 - snap = atomic_long_inc_return(&rsp->expedited_start);
77837 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77838 firstsnap = snap;
77839 get_online_cpus();
77840 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77841 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
77842 synchronize_sched_expedited_cpu_stop,
77843 NULL) == -EAGAIN) {
77844 put_online_cpus();
77845 - atomic_long_inc(&rsp->expedited_tryfail);
77846 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77847
77848 /* Check to see if someone else did our work for us. */
77849 s = atomic_long_read(&rsp->expedited_done);
77850 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77851 /* ensure test happens before caller kfree */
77852 smp_mb__before_atomic_inc(); /* ^^^ */
77853 - atomic_long_inc(&rsp->expedited_workdone1);
77854 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77855 return;
77856 }
77857
77858 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
77859 udelay(trycount * num_online_cpus());
77860 } else {
77861 wait_rcu_gp(call_rcu_sched);
77862 - atomic_long_inc(&rsp->expedited_normal);
77863 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77864 return;
77865 }
77866
77867 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
77868 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77869 /* ensure test happens before caller kfree */
77870 smp_mb__before_atomic_inc(); /* ^^^ */
77871 - atomic_long_inc(&rsp->expedited_workdone2);
77872 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77873 return;
77874 }
77875
77876 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
77877 * period works for us.
77878 */
77879 get_online_cpus();
77880 - snap = atomic_long_read(&rsp->expedited_start);
77881 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77882 smp_mb(); /* ensure read is before try_stop_cpus(). */
77883 }
77884 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77885 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77886
77887 /*
77888 * Everyone up to our most recent fetch is covered by our grace
77889 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
77890 * than we did already did their update.
77891 */
77892 do {
77893 - atomic_long_inc(&rsp->expedited_done_tries);
77894 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77895 s = atomic_long_read(&rsp->expedited_done);
77896 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77897 /* ensure test happens before caller kfree */
77898 smp_mb__before_atomic_inc(); /* ^^^ */
77899 - atomic_long_inc(&rsp->expedited_done_lost);
77900 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77901 break;
77902 }
77903 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77904 - atomic_long_inc(&rsp->expedited_done_exit);
77905 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77906
77907 put_online_cpus();
77908 }
77909 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77910 * ACCESS_ONCE() to prevent the compiler from speculating
77911 * the increment to precede the early-exit check.
77912 */
77913 - ACCESS_ONCE(rsp->n_barrier_done)++;
77914 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77915 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77916 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77917 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77918 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77919
77920 /* Increment ->n_barrier_done to prevent duplicate work. */
77921 smp_mb(); /* Keep increment after above mechanism. */
77922 - ACCESS_ONCE(rsp->n_barrier_done)++;
77923 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77924 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77925 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77926 smp_mb(); /* Keep increment before caller's subsequent code. */
77927 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77928 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77929 init_callback_list(rdp);
77930 rdp->qlen_lazy = 0;
77931 - ACCESS_ONCE(rdp->qlen) = 0;
77932 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77933 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77934 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77935 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77936 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77937 #ifdef CONFIG_RCU_USER_QS
77938 WARN_ON_ONCE(rdp->dynticks->in_user);
77939 #endif
77940 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77941 rdp->blimit = blimit;
77942 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77943 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77944 - atomic_set(&rdp->dynticks->dynticks,
77945 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77946 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77947 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77948 rcu_prepare_for_idle_init(cpu);
77949 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77950
77951 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77952 index 4b69291..704c92e 100644
77953 --- a/kernel/rcutree.h
77954 +++ b/kernel/rcutree.h
77955 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77956 long long dynticks_nesting; /* Track irq/process nesting level. */
77957 /* Process level is worth LLONG_MAX/2. */
77958 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77959 - atomic_t dynticks; /* Even value for idle, else odd. */
77960 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77961 #ifdef CONFIG_RCU_FAST_NO_HZ
77962 int dyntick_drain; /* Prepare-for-idle state variable. */
77963 unsigned long dyntick_holdoff;
77964 @@ -423,17 +423,17 @@ struct rcu_state {
77965 /* _rcu_barrier(). */
77966 /* End of fields guarded by barrier_mutex. */
77967
77968 - atomic_long_t expedited_start; /* Starting ticket. */
77969 - atomic_long_t expedited_done; /* Done ticket. */
77970 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77971 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77972 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77973 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77974 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77975 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77976 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77977 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77978 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77979 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77980 + atomic_long_t expedited_done; /* Done ticket. */
77981 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77982 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77983 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77984 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77985 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77986 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77987 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77988 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77989 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77990
77991 unsigned long jiffies_force_qs; /* Time at which to invoke */
77992 /* force_quiescent_state(). */
77993 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77994 index c1cc7e1..f62e436 100644
77995 --- a/kernel/rcutree_plugin.h
77996 +++ b/kernel/rcutree_plugin.h
77997 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77998
77999 /* Clean up and exit. */
78000 smp_mb(); /* ensure expedited GP seen before counter increment. */
78001 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
78002 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
78003 unlock_mb_ret:
78004 mutex_unlock(&sync_rcu_preempt_exp_mutex);
78005 mb_ret:
78006 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
78007 free_cpumask_var(cm);
78008 }
78009
78010 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
78011 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
78012 .store = &rcu_cpu_kthread_task,
78013 .thread_should_run = rcu_cpu_kthread_should_run,
78014 .thread_fn = rcu_cpu_kthread,
78015 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
78016 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
78017 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
78018 cpu, ticks_value, ticks_title,
78019 - atomic_read(&rdtp->dynticks) & 0xfff,
78020 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
78021 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
78022 fast_no_hz);
78023 }
78024 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
78025
78026 /* Enqueue the callback on the nocb list and update counts. */
78027 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78028 - ACCESS_ONCE(*old_rhpp) = rhp;
78029 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78030 atomic_long_add(rhcount, &rdp->nocb_q_count);
78031 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78032
78033 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
78034 * Extract queued callbacks, update counts, and wait
78035 * for a grace period to elapse.
78036 */
78037 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78038 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78039 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78040 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78041 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78042 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78043 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78044 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78045 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78046 wait_rcu_gp(rdp->rsp->call_remote);
78047
78048 /* Each pass through the following loop invokes a callback. */
78049 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
78050 list = next;
78051 }
78052 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78053 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78054 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78055 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78056 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78057 rdp->n_nocbs_invoked += c;
78058 }
78059 return 0;
78060 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78061 rdp = per_cpu_ptr(rsp->rda, cpu);
78062 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
78063 BUG_ON(IS_ERR(t));
78064 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78065 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78066 }
78067 }
78068
78069 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78070 index 0d095dc..1985b19 100644
78071 --- a/kernel/rcutree_trace.c
78072 +++ b/kernel/rcutree_trace.c
78073 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78074 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78075 rdp->passed_quiesce, rdp->qs_pending);
78076 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78077 - atomic_read(&rdp->dynticks->dynticks),
78078 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78079 rdp->dynticks->dynticks_nesting,
78080 rdp->dynticks->dynticks_nmi_nesting,
78081 rdp->dynticks_fqs);
78082 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78083 struct rcu_state *rsp = (struct rcu_state *)m->private;
78084
78085 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",
78086 - atomic_long_read(&rsp->expedited_start),
78087 + atomic_long_read_unchecked(&rsp->expedited_start),
78088 atomic_long_read(&rsp->expedited_done),
78089 - atomic_long_read(&rsp->expedited_wrap),
78090 - atomic_long_read(&rsp->expedited_tryfail),
78091 - atomic_long_read(&rsp->expedited_workdone1),
78092 - atomic_long_read(&rsp->expedited_workdone2),
78093 - atomic_long_read(&rsp->expedited_normal),
78094 - atomic_long_read(&rsp->expedited_stoppedcpus),
78095 - atomic_long_read(&rsp->expedited_done_tries),
78096 - atomic_long_read(&rsp->expedited_done_lost),
78097 - atomic_long_read(&rsp->expedited_done_exit));
78098 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78099 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78100 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78101 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78102 + atomic_long_read_unchecked(&rsp->expedited_normal),
78103 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78104 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78105 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78106 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78107 return 0;
78108 }
78109
78110 diff --git a/kernel/resource.c b/kernel/resource.c
78111 index 73f35d4..4684fc4 100644
78112 --- a/kernel/resource.c
78113 +++ b/kernel/resource.c
78114 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78115
78116 static int __init ioresources_init(void)
78117 {
78118 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78119 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78120 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78121 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78122 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78123 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78124 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78125 +#endif
78126 +#else
78127 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78128 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78129 +#endif
78130 return 0;
78131 }
78132 __initcall(ioresources_init);
78133 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78134 index 98ec494..4241d6d 100644
78135 --- a/kernel/rtmutex-tester.c
78136 +++ b/kernel/rtmutex-tester.c
78137 @@ -20,7 +20,7 @@
78138 #define MAX_RT_TEST_MUTEXES 8
78139
78140 static spinlock_t rttest_lock;
78141 -static atomic_t rttest_event;
78142 +static atomic_unchecked_t rttest_event;
78143
78144 struct test_thread_data {
78145 int opcode;
78146 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78147
78148 case RTTEST_LOCKCONT:
78149 td->mutexes[td->opdata] = 1;
78150 - td->event = atomic_add_return(1, &rttest_event);
78151 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78152 return 0;
78153
78154 case RTTEST_RESET:
78155 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78156 return 0;
78157
78158 case RTTEST_RESETEVENT:
78159 - atomic_set(&rttest_event, 0);
78160 + atomic_set_unchecked(&rttest_event, 0);
78161 return 0;
78162
78163 default:
78164 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78165 return ret;
78166
78167 td->mutexes[id] = 1;
78168 - td->event = atomic_add_return(1, &rttest_event);
78169 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78170 rt_mutex_lock(&mutexes[id]);
78171 - td->event = atomic_add_return(1, &rttest_event);
78172 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78173 td->mutexes[id] = 4;
78174 return 0;
78175
78176 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78177 return ret;
78178
78179 td->mutexes[id] = 1;
78180 - td->event = atomic_add_return(1, &rttest_event);
78181 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78182 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78183 - td->event = atomic_add_return(1, &rttest_event);
78184 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78185 td->mutexes[id] = ret ? 0 : 4;
78186 return ret ? -EINTR : 0;
78187
78188 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78189 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78190 return ret;
78191
78192 - td->event = atomic_add_return(1, &rttest_event);
78193 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78194 rt_mutex_unlock(&mutexes[id]);
78195 - td->event = atomic_add_return(1, &rttest_event);
78196 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78197 td->mutexes[id] = 0;
78198 return 0;
78199
78200 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78201 break;
78202
78203 td->mutexes[dat] = 2;
78204 - td->event = atomic_add_return(1, &rttest_event);
78205 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78206 break;
78207
78208 default:
78209 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78210 return;
78211
78212 td->mutexes[dat] = 3;
78213 - td->event = atomic_add_return(1, &rttest_event);
78214 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78215 break;
78216
78217 case RTTEST_LOCKNOWAIT:
78218 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78219 return;
78220
78221 td->mutexes[dat] = 1;
78222 - td->event = atomic_add_return(1, &rttest_event);
78223 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78224 return;
78225
78226 default:
78227 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78228 index 0984a21..939f183 100644
78229 --- a/kernel/sched/auto_group.c
78230 +++ b/kernel/sched/auto_group.c
78231 @@ -11,7 +11,7 @@
78232
78233 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78234 static struct autogroup autogroup_default;
78235 -static atomic_t autogroup_seq_nr;
78236 +static atomic_unchecked_t autogroup_seq_nr;
78237
78238 void __init autogroup_init(struct task_struct *init_task)
78239 {
78240 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
78241
78242 kref_init(&ag->kref);
78243 init_rwsem(&ag->lock);
78244 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78245 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78246 ag->tg = tg;
78247 #ifdef CONFIG_RT_GROUP_SCHED
78248 /*
78249 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78250 index 5e2f7c3..4002d41 100644
78251 --- a/kernel/sched/core.c
78252 +++ b/kernel/sched/core.c
78253 @@ -3369,7 +3369,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78254 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78255 * positive (at least 1, or number of jiffies left till timeout) if completed.
78256 */
78257 -long __sched
78258 +long __sched __intentional_overflow(-1)
78259 wait_for_completion_interruptible_timeout(struct completion *x,
78260 unsigned long timeout)
78261 {
78262 @@ -3386,7 +3386,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78263 *
78264 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78265 */
78266 -int __sched wait_for_completion_killable(struct completion *x)
78267 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78268 {
78269 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78270 if (t == -ERESTARTSYS)
78271 @@ -3407,7 +3407,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78272 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78273 * positive (at least 1, or number of jiffies left till timeout) if completed.
78274 */
78275 -long __sched
78276 +long __sched __intentional_overflow(-1)
78277 wait_for_completion_killable_timeout(struct completion *x,
78278 unsigned long timeout)
78279 {
78280 @@ -3633,6 +3633,8 @@ int can_nice(const struct task_struct *p, const int nice)
78281 /* convert nice value [19,-20] to rlimit style value [1,40] */
78282 int nice_rlim = 20 - nice;
78283
78284 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78285 +
78286 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78287 capable(CAP_SYS_NICE));
78288 }
78289 @@ -3666,7 +3668,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78290 if (nice > 19)
78291 nice = 19;
78292
78293 - if (increment < 0 && !can_nice(current, nice))
78294 + if (increment < 0 && (!can_nice(current, nice) ||
78295 + gr_handle_chroot_nice()))
78296 return -EPERM;
78297
78298 retval = security_task_setnice(current, nice);
78299 @@ -3820,6 +3823,7 @@ recheck:
78300 unsigned long rlim_rtprio =
78301 task_rlimit(p, RLIMIT_RTPRIO);
78302
78303 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78304 /* can't set/change the rt policy */
78305 if (policy != p->policy && !rlim_rtprio)
78306 return -EPERM;
78307 @@ -4903,7 +4907,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78308
78309 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78310
78311 -static struct ctl_table sd_ctl_dir[] = {
78312 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78313 {
78314 .procname = "sched_domain",
78315 .mode = 0555,
78316 @@ -4920,17 +4924,17 @@ static struct ctl_table sd_ctl_root[] = {
78317 {}
78318 };
78319
78320 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78321 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78322 {
78323 - struct ctl_table *entry =
78324 + ctl_table_no_const *entry =
78325 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78326
78327 return entry;
78328 }
78329
78330 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78331 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78332 {
78333 - struct ctl_table *entry;
78334 + ctl_table_no_const *entry;
78335
78336 /*
78337 * In the intermediate directories, both the child directory and
78338 @@ -4938,22 +4942,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78339 * will always be set. In the lowest directory the names are
78340 * static strings and all have proc handlers.
78341 */
78342 - for (entry = *tablep; entry->mode; entry++) {
78343 - if (entry->child)
78344 - sd_free_ctl_entry(&entry->child);
78345 + for (entry = tablep; entry->mode; entry++) {
78346 + if (entry->child) {
78347 + sd_free_ctl_entry(entry->child);
78348 + pax_open_kernel();
78349 + entry->child = NULL;
78350 + pax_close_kernel();
78351 + }
78352 if (entry->proc_handler == NULL)
78353 kfree(entry->procname);
78354 }
78355
78356 - kfree(*tablep);
78357 - *tablep = NULL;
78358 + kfree(tablep);
78359 }
78360
78361 static int min_load_idx = 0;
78362 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78363
78364 static void
78365 -set_table_entry(struct ctl_table *entry,
78366 +set_table_entry(ctl_table_no_const *entry,
78367 const char *procname, void *data, int maxlen,
78368 umode_t mode, proc_handler *proc_handler,
78369 bool load_idx)
78370 @@ -4973,7 +4980,7 @@ set_table_entry(struct ctl_table *entry,
78371 static struct ctl_table *
78372 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78373 {
78374 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78375 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78376
78377 if (table == NULL)
78378 return NULL;
78379 @@ -5008,9 +5015,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78380 return table;
78381 }
78382
78383 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78384 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78385 {
78386 - struct ctl_table *entry, *table;
78387 + ctl_table_no_const *entry, *table;
78388 struct sched_domain *sd;
78389 int domain_num = 0, i;
78390 char buf[32];
78391 @@ -5037,11 +5044,13 @@ static struct ctl_table_header *sd_sysctl_header;
78392 static void register_sched_domain_sysctl(void)
78393 {
78394 int i, cpu_num = num_possible_cpus();
78395 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78396 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78397 char buf[32];
78398
78399 WARN_ON(sd_ctl_dir[0].child);
78400 + pax_open_kernel();
78401 sd_ctl_dir[0].child = entry;
78402 + pax_close_kernel();
78403
78404 if (entry == NULL)
78405 return;
78406 @@ -5064,8 +5073,12 @@ static void unregister_sched_domain_sysctl(void)
78407 if (sd_sysctl_header)
78408 unregister_sysctl_table(sd_sysctl_header);
78409 sd_sysctl_header = NULL;
78410 - if (sd_ctl_dir[0].child)
78411 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78412 + if (sd_ctl_dir[0].child) {
78413 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78414 + pax_open_kernel();
78415 + sd_ctl_dir[0].child = NULL;
78416 + pax_close_kernel();
78417 + }
78418 }
78419 #else
78420 static void register_sched_domain_sysctl(void)
78421 @@ -5164,7 +5177,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78422 * happens before everything else. This has to be lower priority than
78423 * the notifier in the perf_event subsystem, though.
78424 */
78425 -static struct notifier_block __cpuinitdata migration_notifier = {
78426 +static struct notifier_block migration_notifier = {
78427 .notifier_call = migration_call,
78428 .priority = CPU_PRI_MIGRATION,
78429 };
78430 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78431 index 81fa536..6ccf96a 100644
78432 --- a/kernel/sched/fair.c
78433 +++ b/kernel/sched/fair.c
78434 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78435
78436 static void reset_ptenuma_scan(struct task_struct *p)
78437 {
78438 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78439 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78440 p->mm->numa_scan_offset = 0;
78441 }
78442
78443 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
78444 */
78445 static int select_idle_sibling(struct task_struct *p, int target)
78446 {
78447 - int cpu = smp_processor_id();
78448 - int prev_cpu = task_cpu(p);
78449 struct sched_domain *sd;
78450 struct sched_group *sg;
78451 - int i;
78452 + int i = task_cpu(p);
78453
78454 - /*
78455 - * If the task is going to be woken-up on this cpu and if it is
78456 - * already idle, then it is the right target.
78457 - */
78458 - if (target == cpu && idle_cpu(cpu))
78459 - return cpu;
78460 + if (idle_cpu(target))
78461 + return target;
78462
78463 /*
78464 - * If the task is going to be woken-up on the cpu where it previously
78465 - * ran and if it is currently idle, then it the right target.
78466 + * If the prevous cpu is cache affine and idle, don't be stupid.
78467 */
78468 - if (target == prev_cpu && idle_cpu(prev_cpu))
78469 - return prev_cpu;
78470 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
78471 + return i;
78472
78473 /*
78474 * Otherwise, iterate the domains and find an elegible idle cpu.
78475 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
78476 goto next;
78477
78478 for_each_cpu(i, sched_group_cpus(sg)) {
78479 - if (!idle_cpu(i))
78480 + if (i == target || !idle_cpu(i))
78481 goto next;
78482 }
78483
78484 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78485 * run_rebalance_domains is triggered when needed from the scheduler tick.
78486 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78487 */
78488 -static void run_rebalance_domains(struct softirq_action *h)
78489 +static void run_rebalance_domains(void)
78490 {
78491 int this_cpu = smp_processor_id();
78492 struct rq *this_rq = cpu_rq(this_cpu);
78493 diff --git a/kernel/signal.c b/kernel/signal.c
78494 index 50e425c..92c8f65 100644
78495 --- a/kernel/signal.c
78496 +++ b/kernel/signal.c
78497 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78498
78499 int print_fatal_signals __read_mostly;
78500
78501 -static void __user *sig_handler(struct task_struct *t, int sig)
78502 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78503 {
78504 return t->sighand->action[sig - 1].sa.sa_handler;
78505 }
78506
78507 -static int sig_handler_ignored(void __user *handler, int sig)
78508 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78509 {
78510 /* Is it explicitly or implicitly ignored? */
78511 return handler == SIG_IGN ||
78512 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78513
78514 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78515 {
78516 - void __user *handler;
78517 + __sighandler_t handler;
78518
78519 handler = sig_handler(t, sig);
78520
78521 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78522 atomic_inc(&user->sigpending);
78523 rcu_read_unlock();
78524
78525 + if (!override_rlimit)
78526 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78527 +
78528 if (override_rlimit ||
78529 atomic_read(&user->sigpending) <=
78530 task_rlimit(t, RLIMIT_SIGPENDING)) {
78531 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78532
78533 int unhandled_signal(struct task_struct *tsk, int sig)
78534 {
78535 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78536 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78537 if (is_global_init(tsk))
78538 return 1;
78539 if (handler != SIG_IGN && handler != SIG_DFL)
78540 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78541 }
78542 }
78543
78544 + /* allow glibc communication via tgkill to other threads in our
78545 + thread group */
78546 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78547 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78548 + && gr_handle_signal(t, sig))
78549 + return -EPERM;
78550 +
78551 return security_task_kill(t, info, sig, 0);
78552 }
78553
78554 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78555 return send_signal(sig, info, p, 1);
78556 }
78557
78558 -static int
78559 +int
78560 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78561 {
78562 return send_signal(sig, info, t, 0);
78563 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78564 unsigned long int flags;
78565 int ret, blocked, ignored;
78566 struct k_sigaction *action;
78567 + int is_unhandled = 0;
78568
78569 spin_lock_irqsave(&t->sighand->siglock, flags);
78570 action = &t->sighand->action[sig-1];
78571 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78572 }
78573 if (action->sa.sa_handler == SIG_DFL)
78574 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78575 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78576 + is_unhandled = 1;
78577 ret = specific_send_sig_info(sig, info, t);
78578 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78579
78580 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78581 + normal operation */
78582 + if (is_unhandled) {
78583 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78584 + gr_handle_crash(t, sig);
78585 + }
78586 +
78587 return ret;
78588 }
78589
78590 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78591 ret = check_kill_permission(sig, info, p);
78592 rcu_read_unlock();
78593
78594 - if (!ret && sig)
78595 + if (!ret && sig) {
78596 ret = do_send_sig_info(sig, info, p, true);
78597 + if (!ret)
78598 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78599 + }
78600
78601 return ret;
78602 }
78603 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78604 int error = -ESRCH;
78605
78606 rcu_read_lock();
78607 - p = find_task_by_vpid(pid);
78608 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78609 + /* allow glibc communication via tgkill to other threads in our
78610 + thread group */
78611 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78612 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78613 + p = find_task_by_vpid_unrestricted(pid);
78614 + else
78615 +#endif
78616 + p = find_task_by_vpid(pid);
78617 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78618 error = check_kill_permission(sig, info, p);
78619 /*
78620 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78621 }
78622 seg = get_fs();
78623 set_fs(KERNEL_DS);
78624 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78625 - (stack_t __force __user *) &uoss,
78626 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78627 + (stack_t __force_user *) &uoss,
78628 compat_user_stack_pointer());
78629 set_fs(seg);
78630 if (ret >= 0 && uoss_ptr) {
78631 diff --git a/kernel/smp.c b/kernel/smp.c
78632 index 69f38bd..77bbf12 100644
78633 --- a/kernel/smp.c
78634 +++ b/kernel/smp.c
78635 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78636 return NOTIFY_OK;
78637 }
78638
78639 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78640 +static struct notifier_block hotplug_cfd_notifier = {
78641 .notifier_call = hotplug_cfd,
78642 };
78643
78644 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78645 index d6c5fc0..530560c 100644
78646 --- a/kernel/smpboot.c
78647 +++ b/kernel/smpboot.c
78648 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78649 }
78650 smpboot_unpark_thread(plug_thread, cpu);
78651 }
78652 - list_add(&plug_thread->list, &hotplug_threads);
78653 + pax_list_add(&plug_thread->list, &hotplug_threads);
78654 out:
78655 mutex_unlock(&smpboot_threads_lock);
78656 return ret;
78657 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78658 {
78659 get_online_cpus();
78660 mutex_lock(&smpboot_threads_lock);
78661 - list_del(&plug_thread->list);
78662 + pax_list_del(&plug_thread->list);
78663 smpboot_destroy_threads(plug_thread);
78664 mutex_unlock(&smpboot_threads_lock);
78665 put_online_cpus();
78666 diff --git a/kernel/softirq.c b/kernel/softirq.c
78667 index ed567ba..e71dabf 100644
78668 --- a/kernel/softirq.c
78669 +++ b/kernel/softirq.c
78670 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78671 EXPORT_SYMBOL(irq_stat);
78672 #endif
78673
78674 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78675 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78676
78677 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78678
78679 -char *softirq_to_name[NR_SOFTIRQS] = {
78680 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78681 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78682 "TASKLET", "SCHED", "HRTIMER", "RCU"
78683 };
78684 @@ -244,7 +244,7 @@ restart:
78685 kstat_incr_softirqs_this_cpu(vec_nr);
78686
78687 trace_softirq_entry(vec_nr);
78688 - h->action(h);
78689 + h->action();
78690 trace_softirq_exit(vec_nr);
78691 if (unlikely(prev_count != preempt_count())) {
78692 printk(KERN_ERR "huh, entered softirq %u %s %p"
78693 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78694 or_softirq_pending(1UL << nr);
78695 }
78696
78697 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78698 +void __init open_softirq(int nr, void (*action)(void))
78699 {
78700 softirq_vec[nr].action = action;
78701 }
78702 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78703
78704 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78705
78706 -static void tasklet_action(struct softirq_action *a)
78707 +static void tasklet_action(void)
78708 {
78709 struct tasklet_struct *list;
78710
78711 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
78712 }
78713 }
78714
78715 -static void tasklet_hi_action(struct softirq_action *a)
78716 +static void tasklet_hi_action(void)
78717 {
78718 struct tasklet_struct *list;
78719
78720 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78721 return NOTIFY_OK;
78722 }
78723
78724 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78725 +static struct notifier_block remote_softirq_cpu_notifier = {
78726 .notifier_call = remote_softirq_cpu_notify,
78727 };
78728
78729 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78730 return NOTIFY_OK;
78731 }
78732
78733 -static struct notifier_block __cpuinitdata cpu_nfb = {
78734 +static struct notifier_block cpu_nfb = {
78735 .notifier_call = cpu_callback
78736 };
78737
78738 -static struct smp_hotplug_thread softirq_threads = {
78739 +static struct smp_hotplug_thread softirq_threads __read_only = {
78740 .store = &ksoftirqd,
78741 .thread_should_run = ksoftirqd_should_run,
78742 .thread_fn = run_ksoftirqd,
78743 diff --git a/kernel/srcu.c b/kernel/srcu.c
78744 index 2b85982..d52ab26 100644
78745 --- a/kernel/srcu.c
78746 +++ b/kernel/srcu.c
78747 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78748 preempt_disable();
78749 idx = rcu_dereference_index_check(sp->completed,
78750 rcu_read_lock_sched_held()) & 0x1;
78751 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78752 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78753 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78754 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78755 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78756 preempt_enable();
78757 return idx;
78758 }
78759 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
78760 {
78761 preempt_disable();
78762 smp_mb(); /* C */ /* Avoid leaking the critical section. */
78763 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78764 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78765 preempt_enable();
78766 }
78767 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
78768 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
78769 index 2f194e9..2c05ea9 100644
78770 --- a/kernel/stop_machine.c
78771 +++ b/kernel/stop_machine.c
78772 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
78773 * cpu notifiers. It currently shares the same priority as sched
78774 * migration_notifier.
78775 */
78776 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
78777 +static struct notifier_block cpu_stop_cpu_notifier = {
78778 .notifier_call = cpu_stop_cpu_callback,
78779 .priority = 10,
78780 };
78781 diff --git a/kernel/sys.c b/kernel/sys.c
78782 index 47f1d1b..04c769e 100644
78783 --- a/kernel/sys.c
78784 +++ b/kernel/sys.c
78785 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78786 error = -EACCES;
78787 goto out;
78788 }
78789 +
78790 + if (gr_handle_chroot_setpriority(p, niceval)) {
78791 + error = -EACCES;
78792 + goto out;
78793 + }
78794 +
78795 no_nice = security_task_setnice(p, niceval);
78796 if (no_nice) {
78797 error = no_nice;
78798 @@ -596,6 +602,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78799 goto error;
78800 }
78801
78802 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78803 + goto error;
78804 +
78805 if (rgid != (gid_t) -1 ||
78806 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78807 new->sgid = new->egid;
78808 @@ -631,6 +640,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78809 old = current_cred();
78810
78811 retval = -EPERM;
78812 +
78813 + if (gr_check_group_change(kgid, kgid, kgid))
78814 + goto error;
78815 +
78816 if (nsown_capable(CAP_SETGID))
78817 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78818 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78819 @@ -648,7 +661,7 @@ error:
78820 /*
78821 * change the user struct in a credentials set to match the new UID
78822 */
78823 -static int set_user(struct cred *new)
78824 +int set_user(struct cred *new)
78825 {
78826 struct user_struct *new_user;
78827
78828 @@ -728,6 +741,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78829 goto error;
78830 }
78831
78832 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78833 + goto error;
78834 +
78835 if (!uid_eq(new->uid, old->uid)) {
78836 retval = set_user(new);
78837 if (retval < 0)
78838 @@ -778,6 +794,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78839 old = current_cred();
78840
78841 retval = -EPERM;
78842 +
78843 + if (gr_check_crash_uid(kuid))
78844 + goto error;
78845 + if (gr_check_user_change(kuid, kuid, kuid))
78846 + goto error;
78847 +
78848 if (nsown_capable(CAP_SETUID)) {
78849 new->suid = new->uid = kuid;
78850 if (!uid_eq(kuid, old->uid)) {
78851 @@ -847,6 +869,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78852 goto error;
78853 }
78854
78855 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78856 + goto error;
78857 +
78858 if (ruid != (uid_t) -1) {
78859 new->uid = kruid;
78860 if (!uid_eq(kruid, old->uid)) {
78861 @@ -929,6 +954,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78862 goto error;
78863 }
78864
78865 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78866 + goto error;
78867 +
78868 if (rgid != (gid_t) -1)
78869 new->gid = krgid;
78870 if (egid != (gid_t) -1)
78871 @@ -990,12 +1018,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78872 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
78873 nsown_capable(CAP_SETUID)) {
78874 if (!uid_eq(kuid, old->fsuid)) {
78875 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78876 + goto error;
78877 +
78878 new->fsuid = kuid;
78879 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
78880 goto change_okay;
78881 }
78882 }
78883
78884 +error:
78885 abort_creds(new);
78886 return old_fsuid;
78887
78888 @@ -1028,12 +1060,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78889 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78890 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78891 nsown_capable(CAP_SETGID)) {
78892 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78893 + goto error;
78894 +
78895 if (!gid_eq(kgid, old->fsgid)) {
78896 new->fsgid = kgid;
78897 goto change_okay;
78898 }
78899 }
78900
78901 +error:
78902 abort_creds(new);
78903 return old_fsgid;
78904
78905 @@ -1341,19 +1377,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78906 return -EFAULT;
78907
78908 down_read(&uts_sem);
78909 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78910 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78911 __OLD_UTS_LEN);
78912 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78913 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78914 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78915 __OLD_UTS_LEN);
78916 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78917 - error |= __copy_to_user(&name->release, &utsname()->release,
78918 + error |= __copy_to_user(name->release, &utsname()->release,
78919 __OLD_UTS_LEN);
78920 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78921 - error |= __copy_to_user(&name->version, &utsname()->version,
78922 + error |= __copy_to_user(name->version, &utsname()->version,
78923 __OLD_UTS_LEN);
78924 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78925 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78926 + error |= __copy_to_user(name->machine, &utsname()->machine,
78927 __OLD_UTS_LEN);
78928 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78929 up_read(&uts_sem);
78930 @@ -2027,7 +2063,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
78931 error = get_dumpable(me->mm);
78932 break;
78933 case PR_SET_DUMPABLE:
78934 - if (arg2 < 0 || arg2 > 1) {
78935 + if (arg2 > 1) {
78936 error = -EINVAL;
78937 break;
78938 }
78939 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78940 index c88878d..e4fa5d1 100644
78941 --- a/kernel/sysctl.c
78942 +++ b/kernel/sysctl.c
78943 @@ -92,7 +92,6 @@
78944
78945
78946 #if defined(CONFIG_SYSCTL)
78947 -
78948 /* External variables not in a header file. */
78949 extern int sysctl_overcommit_memory;
78950 extern int sysctl_overcommit_ratio;
78951 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
78952 void __user *buffer, size_t *lenp, loff_t *ppos);
78953 #endif
78954
78955 -#ifdef CONFIG_PRINTK
78956 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78957 void __user *buffer, size_t *lenp, loff_t *ppos);
78958 -#endif
78959
78960 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78961 void __user *buffer, size_t *lenp, loff_t *ppos);
78962 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78963
78964 #endif
78965
78966 +extern struct ctl_table grsecurity_table[];
78967 +
78968 static struct ctl_table kern_table[];
78969 static struct ctl_table vm_table[];
78970 static struct ctl_table fs_table[];
78971 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
78972 int sysctl_legacy_va_layout;
78973 #endif
78974
78975 +#ifdef CONFIG_PAX_SOFTMODE
78976 +static ctl_table pax_table[] = {
78977 + {
78978 + .procname = "softmode",
78979 + .data = &pax_softmode,
78980 + .maxlen = sizeof(unsigned int),
78981 + .mode = 0600,
78982 + .proc_handler = &proc_dointvec,
78983 + },
78984 +
78985 + { }
78986 +};
78987 +#endif
78988 +
78989 /* The default sysctl tables: */
78990
78991 static struct ctl_table sysctl_base_table[] = {
78992 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
78993 #endif
78994
78995 static struct ctl_table kern_table[] = {
78996 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78997 + {
78998 + .procname = "grsecurity",
78999 + .mode = 0500,
79000 + .child = grsecurity_table,
79001 + },
79002 +#endif
79003 +
79004 +#ifdef CONFIG_PAX_SOFTMODE
79005 + {
79006 + .procname = "pax",
79007 + .mode = 0500,
79008 + .child = pax_table,
79009 + },
79010 +#endif
79011 +
79012 {
79013 .procname = "sched_child_runs_first",
79014 .data = &sysctl_sched_child_runs_first,
79015 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
79016 .data = &modprobe_path,
79017 .maxlen = KMOD_PATH_LEN,
79018 .mode = 0644,
79019 - .proc_handler = proc_dostring,
79020 + .proc_handler = proc_dostring_modpriv,
79021 },
79022 {
79023 .procname = "modules_disabled",
79024 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
79025 .extra1 = &zero,
79026 .extra2 = &one,
79027 },
79028 +#endif
79029 {
79030 .procname = "kptr_restrict",
79031 .data = &kptr_restrict,
79032 .maxlen = sizeof(int),
79033 .mode = 0644,
79034 .proc_handler = proc_dointvec_minmax_sysadmin,
79035 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79036 + .extra1 = &two,
79037 +#else
79038 .extra1 = &zero,
79039 +#endif
79040 .extra2 = &two,
79041 },
79042 -#endif
79043 {
79044 .procname = "ngroups_max",
79045 .data = &ngroups_max,
79046 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
79047 .proc_handler = proc_dointvec_minmax,
79048 .extra1 = &zero,
79049 },
79050 + {
79051 + .procname = "heap_stack_gap",
79052 + .data = &sysctl_heap_stack_gap,
79053 + .maxlen = sizeof(sysctl_heap_stack_gap),
79054 + .mode = 0644,
79055 + .proc_handler = proc_doulongvec_minmax,
79056 + },
79057 #else
79058 {
79059 .procname = "nr_trim_pages",
79060 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
79061 buffer, lenp, ppos);
79062 }
79063
79064 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79065 + void __user *buffer, size_t *lenp, loff_t *ppos)
79066 +{
79067 + if (write && !capable(CAP_SYS_MODULE))
79068 + return -EPERM;
79069 +
79070 + return _proc_do_string(table->data, table->maxlen, write,
79071 + buffer, lenp, ppos);
79072 +}
79073 +
79074 static size_t proc_skip_spaces(char **buf)
79075 {
79076 size_t ret;
79077 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79078 len = strlen(tmp);
79079 if (len > *size)
79080 len = *size;
79081 + if (len > sizeof(tmp))
79082 + len = sizeof(tmp);
79083 if (copy_to_user(*buf, tmp, len))
79084 return -EFAULT;
79085 *size -= len;
79086 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79087 static int proc_taint(struct ctl_table *table, int write,
79088 void __user *buffer, size_t *lenp, loff_t *ppos)
79089 {
79090 - struct ctl_table t;
79091 + ctl_table_no_const t;
79092 unsigned long tmptaint = get_taint();
79093 int err;
79094
79095 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
79096 return err;
79097 }
79098
79099 -#ifdef CONFIG_PRINTK
79100 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79101 void __user *buffer, size_t *lenp, loff_t *ppos)
79102 {
79103 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79104
79105 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79106 }
79107 -#endif
79108
79109 struct do_proc_dointvec_minmax_conv_param {
79110 int *min;
79111 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79112 *i = val;
79113 } else {
79114 val = convdiv * (*i) / convmul;
79115 - if (!first)
79116 + if (!first) {
79117 err = proc_put_char(&buffer, &left, '\t');
79118 + if (err)
79119 + break;
79120 + }
79121 err = proc_put_long(&buffer, &left, val, false);
79122 if (err)
79123 break;
79124 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
79125 return -ENOSYS;
79126 }
79127
79128 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79129 + void __user *buffer, size_t *lenp, loff_t *ppos)
79130 +{
79131 + return -ENOSYS;
79132 +}
79133 +
79134 int proc_dointvec(struct ctl_table *table, int write,
79135 void __user *buffer, size_t *lenp, loff_t *ppos)
79136 {
79137 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79138 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79139 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79140 EXPORT_SYMBOL(proc_dostring);
79141 +EXPORT_SYMBOL(proc_dostring_modpriv);
79142 EXPORT_SYMBOL(proc_doulongvec_minmax);
79143 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79144 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
79145 index 0ddf3a0..a199f50 100644
79146 --- a/kernel/sysctl_binary.c
79147 +++ b/kernel/sysctl_binary.c
79148 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
79149 int i;
79150
79151 set_fs(KERNEL_DS);
79152 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79153 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79154 set_fs(old_fs);
79155 if (result < 0)
79156 goto out_kfree;
79157 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
79158 }
79159
79160 set_fs(KERNEL_DS);
79161 - result = vfs_write(file, buffer, str - buffer, &pos);
79162 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79163 set_fs(old_fs);
79164 if (result < 0)
79165 goto out_kfree;
79166 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
79167 int i;
79168
79169 set_fs(KERNEL_DS);
79170 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79171 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79172 set_fs(old_fs);
79173 if (result < 0)
79174 goto out_kfree;
79175 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
79176 }
79177
79178 set_fs(KERNEL_DS);
79179 - result = vfs_write(file, buffer, str - buffer, &pos);
79180 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79181 set_fs(old_fs);
79182 if (result < 0)
79183 goto out_kfree;
79184 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
79185 int i;
79186
79187 set_fs(KERNEL_DS);
79188 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79189 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79190 set_fs(old_fs);
79191 if (result < 0)
79192 goto out;
79193 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79194 __le16 dnaddr;
79195
79196 set_fs(KERNEL_DS);
79197 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79198 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79199 set_fs(old_fs);
79200 if (result < 0)
79201 goto out;
79202 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79203 le16_to_cpu(dnaddr) & 0x3ff);
79204
79205 set_fs(KERNEL_DS);
79206 - result = vfs_write(file, buf, len, &pos);
79207 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
79208 set_fs(old_fs);
79209 if (result < 0)
79210 goto out;
79211 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79212 index 145bb4d..b2aa969 100644
79213 --- a/kernel/taskstats.c
79214 +++ b/kernel/taskstats.c
79215 @@ -28,9 +28,12 @@
79216 #include <linux/fs.h>
79217 #include <linux/file.h>
79218 #include <linux/pid_namespace.h>
79219 +#include <linux/grsecurity.h>
79220 #include <net/genetlink.h>
79221 #include <linux/atomic.h>
79222
79223 +extern int gr_is_taskstats_denied(int pid);
79224 +
79225 /*
79226 * Maximum length of a cpumask that can be specified in
79227 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79228 @@ -570,6 +573,9 @@ err:
79229
79230 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79231 {
79232 + if (gr_is_taskstats_denied(current->pid))
79233 + return -EACCES;
79234 +
79235 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79236 return cmd_attr_register_cpumask(info);
79237 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79238 diff --git a/kernel/time.c b/kernel/time.c
79239 index d226c6a..2f0d217 100644
79240 --- a/kernel/time.c
79241 +++ b/kernel/time.c
79242 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79243 return error;
79244
79245 if (tz) {
79246 + /* we log in do_settimeofday called below, so don't log twice
79247 + */
79248 + if (!tv)
79249 + gr_log_timechange();
79250 +
79251 sys_tz = *tz;
79252 update_vsyscall_tz();
79253 if (firsttime) {
79254 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79255 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79256 * value to a scaled second value.
79257 */
79258 -unsigned long
79259 +unsigned long __intentional_overflow(-1)
79260 timespec_to_jiffies(const struct timespec *value)
79261 {
79262 unsigned long sec = value->tv_sec;
79263 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79264 index f11d83b..d016d91 100644
79265 --- a/kernel/time/alarmtimer.c
79266 +++ b/kernel/time/alarmtimer.c
79267 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79268 struct platform_device *pdev;
79269 int error = 0;
79270 int i;
79271 - struct k_clock alarm_clock = {
79272 + static struct k_clock alarm_clock = {
79273 .clock_getres = alarm_clock_getres,
79274 .clock_get = alarm_clock_get,
79275 .timer_create = alarm_timer_create,
79276 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79277 index a13987a..36cd791 100644
79278 --- a/kernel/time/tick-broadcast.c
79279 +++ b/kernel/time/tick-broadcast.c
79280 @@ -116,7 +116,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79281 * then clear the broadcast bit.
79282 */
79283 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79284 - int cpu = smp_processor_id();
79285 + cpu = smp_processor_id();
79286
79287 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79288 tick_broadcast_clear_oneshot(cpu);
79289 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79290 index cbc6acb..3a77191 100644
79291 --- a/kernel/time/timekeeping.c
79292 +++ b/kernel/time/timekeeping.c
79293 @@ -15,6 +15,7 @@
79294 #include <linux/init.h>
79295 #include <linux/mm.h>
79296 #include <linux/sched.h>
79297 +#include <linux/grsecurity.h>
79298 #include <linux/syscore_ops.h>
79299 #include <linux/clocksource.h>
79300 #include <linux/jiffies.h>
79301 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
79302 if (!timespec_valid_strict(tv))
79303 return -EINVAL;
79304
79305 + gr_log_timechange();
79306 +
79307 write_seqlock_irqsave(&tk->lock, flags);
79308
79309 timekeeping_forward_now(tk);
79310 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79311 index af5a7e9..715611a 100644
79312 --- a/kernel/time/timer_list.c
79313 +++ b/kernel/time/timer_list.c
79314 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79315
79316 static void print_name_offset(struct seq_file *m, void *sym)
79317 {
79318 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79319 + SEQ_printf(m, "<%p>", NULL);
79320 +#else
79321 char symname[KSYM_NAME_LEN];
79322
79323 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79324 SEQ_printf(m, "<%pK>", sym);
79325 else
79326 SEQ_printf(m, "%s", symname);
79327 +#endif
79328 }
79329
79330 static void
79331 @@ -112,7 +116,11 @@ next_one:
79332 static void
79333 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79334 {
79335 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79336 + SEQ_printf(m, " .base: %p\n", NULL);
79337 +#else
79338 SEQ_printf(m, " .base: %pK\n", base);
79339 +#endif
79340 SEQ_printf(m, " .index: %d\n",
79341 base->index);
79342 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79343 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79344 {
79345 struct proc_dir_entry *pe;
79346
79347 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79348 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79349 +#else
79350 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79351 +#endif
79352 if (!pe)
79353 return -ENOMEM;
79354 return 0;
79355 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79356 index 0b537f2..40d6c20 100644
79357 --- a/kernel/time/timer_stats.c
79358 +++ b/kernel/time/timer_stats.c
79359 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79360 static unsigned long nr_entries;
79361 static struct entry entries[MAX_ENTRIES];
79362
79363 -static atomic_t overflow_count;
79364 +static atomic_unchecked_t overflow_count;
79365
79366 /*
79367 * The entries are in a hash-table, for fast lookup:
79368 @@ -140,7 +140,7 @@ static void reset_entries(void)
79369 nr_entries = 0;
79370 memset(entries, 0, sizeof(entries));
79371 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79372 - atomic_set(&overflow_count, 0);
79373 + atomic_set_unchecked(&overflow_count, 0);
79374 }
79375
79376 static struct entry *alloc_entry(void)
79377 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79378 if (likely(entry))
79379 entry->count++;
79380 else
79381 - atomic_inc(&overflow_count);
79382 + atomic_inc_unchecked(&overflow_count);
79383
79384 out_unlock:
79385 raw_spin_unlock_irqrestore(lock, flags);
79386 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79387
79388 static void print_name_offset(struct seq_file *m, unsigned long addr)
79389 {
79390 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79391 + seq_printf(m, "<%p>", NULL);
79392 +#else
79393 char symname[KSYM_NAME_LEN];
79394
79395 if (lookup_symbol_name(addr, symname) < 0)
79396 - seq_printf(m, "<%p>", (void *)addr);
79397 + seq_printf(m, "<%pK>", (void *)addr);
79398 else
79399 seq_printf(m, "%s", symname);
79400 +#endif
79401 }
79402
79403 static int tstats_show(struct seq_file *m, void *v)
79404 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79405
79406 seq_puts(m, "Timer Stats Version: v0.2\n");
79407 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79408 - if (atomic_read(&overflow_count))
79409 + if (atomic_read_unchecked(&overflow_count))
79410 seq_printf(m, "Overflow: %d entries\n",
79411 - atomic_read(&overflow_count));
79412 + atomic_read_unchecked(&overflow_count));
79413
79414 for (i = 0; i < nr_entries; i++) {
79415 entry = entries + i;
79416 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79417 {
79418 struct proc_dir_entry *pe;
79419
79420 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79421 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79422 +#else
79423 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79424 +#endif
79425 if (!pe)
79426 return -ENOMEM;
79427 return 0;
79428 diff --git a/kernel/timer.c b/kernel/timer.c
79429 index 367d008..5dee98f 100644
79430 --- a/kernel/timer.c
79431 +++ b/kernel/timer.c
79432 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79433 /*
79434 * This function runs timers and the timer-tq in bottom half context.
79435 */
79436 -static void run_timer_softirq(struct softirq_action *h)
79437 +static void run_timer_softirq(void)
79438 {
79439 struct tvec_base *base = __this_cpu_read(tvec_bases);
79440
79441 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79442 *
79443 * In all cases the return value is guaranteed to be non-negative.
79444 */
79445 -signed long __sched schedule_timeout(signed long timeout)
79446 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79447 {
79448 struct timer_list timer;
79449 unsigned long expire;
79450 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79451 return NOTIFY_OK;
79452 }
79453
79454 -static struct notifier_block __cpuinitdata timers_nb = {
79455 +static struct notifier_block timers_nb = {
79456 .notifier_call = timer_cpu_notify,
79457 };
79458
79459 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79460 index c0bd030..62a1927 100644
79461 --- a/kernel/trace/blktrace.c
79462 +++ b/kernel/trace/blktrace.c
79463 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79464 struct blk_trace *bt = filp->private_data;
79465 char buf[16];
79466
79467 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79468 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79469
79470 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79471 }
79472 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79473 return 1;
79474
79475 bt = buf->chan->private_data;
79476 - atomic_inc(&bt->dropped);
79477 + atomic_inc_unchecked(&bt->dropped);
79478 return 0;
79479 }
79480
79481 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79482
79483 bt->dir = dir;
79484 bt->dev = dev;
79485 - atomic_set(&bt->dropped, 0);
79486 + atomic_set_unchecked(&bt->dropped, 0);
79487
79488 ret = -EIO;
79489 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79490 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79491 index 35cc3a8..2a47da3 100644
79492 --- a/kernel/trace/ftrace.c
79493 +++ b/kernel/trace/ftrace.c
79494 @@ -1886,12 +1886,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79495 if (unlikely(ftrace_disabled))
79496 return 0;
79497
79498 + ret = ftrace_arch_code_modify_prepare();
79499 + FTRACE_WARN_ON(ret);
79500 + if (ret)
79501 + return 0;
79502 +
79503 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79504 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79505 if (ret) {
79506 ftrace_bug(ret, ip);
79507 - return 0;
79508 }
79509 - return 1;
79510 + return ret ? 0 : 1;
79511 }
79512
79513 /*
79514 @@ -2964,7 +2969,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79515
79516 int
79517 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79518 - void *data)
79519 + void *data)
79520 {
79521 struct ftrace_func_probe *entry;
79522 struct ftrace_page *pg;
79523 @@ -3831,8 +3836,10 @@ static int ftrace_process_locs(struct module *mod,
79524 if (!count)
79525 return 0;
79526
79527 + pax_open_kernel();
79528 sort(start, count, sizeof(*start),
79529 ftrace_cmp_ips, ftrace_swap_ips);
79530 + pax_close_kernel();
79531
79532 start_pg = ftrace_allocate_pages(count);
79533 if (!start_pg)
79534 @@ -4554,8 +4561,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79535 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79536
79537 static int ftrace_graph_active;
79538 -static struct notifier_block ftrace_suspend_notifier;
79539 -
79540 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79541 {
79542 return 0;
79543 @@ -4699,6 +4704,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79544 return NOTIFY_DONE;
79545 }
79546
79547 +static struct notifier_block ftrace_suspend_notifier = {
79548 + .notifier_call = ftrace_suspend_notifier_call
79549 +};
79550 +
79551 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79552 trace_func_graph_ent_t entryfunc)
79553 {
79554 @@ -4712,7 +4721,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79555 goto out;
79556 }
79557
79558 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79559 register_pm_notifier(&ftrace_suspend_notifier);
79560
79561 ftrace_graph_active++;
79562 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79563 index ce8514f..8233573 100644
79564 --- a/kernel/trace/ring_buffer.c
79565 +++ b/kernel/trace/ring_buffer.c
79566 @@ -346,9 +346,9 @@ struct buffer_data_page {
79567 */
79568 struct buffer_page {
79569 struct list_head list; /* list of buffer pages */
79570 - local_t write; /* index for next write */
79571 + local_unchecked_t write; /* index for next write */
79572 unsigned read; /* index for next read */
79573 - local_t entries; /* entries on this page */
79574 + local_unchecked_t entries; /* entries on this page */
79575 unsigned long real_end; /* real end of data */
79576 struct buffer_data_page *page; /* Actual data page */
79577 };
79578 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
79579 unsigned long last_overrun;
79580 local_t entries_bytes;
79581 local_t entries;
79582 - local_t overrun;
79583 - local_t commit_overrun;
79584 + local_unchecked_t overrun;
79585 + local_unchecked_t commit_overrun;
79586 local_t dropped_events;
79587 local_t committing;
79588 local_t commits;
79589 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79590 *
79591 * We add a counter to the write field to denote this.
79592 */
79593 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79594 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79595 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79596 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79597
79598 /*
79599 * Just make sure we have seen our old_write and synchronize
79600 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79601 * cmpxchg to only update if an interrupt did not already
79602 * do it for us. If the cmpxchg fails, we don't care.
79603 */
79604 - (void)local_cmpxchg(&next_page->write, old_write, val);
79605 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79606 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79607 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79608
79609 /*
79610 * No need to worry about races with clearing out the commit.
79611 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79612
79613 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79614 {
79615 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79616 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79617 }
79618
79619 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79620 {
79621 - return local_read(&bpage->write) & RB_WRITE_MASK;
79622 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79623 }
79624
79625 static int
79626 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79627 * bytes consumed in ring buffer from here.
79628 * Increment overrun to account for the lost events.
79629 */
79630 - local_add(page_entries, &cpu_buffer->overrun);
79631 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79632 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79633 }
79634
79635 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79636 * it is our responsibility to update
79637 * the counters.
79638 */
79639 - local_add(entries, &cpu_buffer->overrun);
79640 + local_add_unchecked(entries, &cpu_buffer->overrun);
79641 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79642
79643 /*
79644 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79645 if (tail == BUF_PAGE_SIZE)
79646 tail_page->real_end = 0;
79647
79648 - local_sub(length, &tail_page->write);
79649 + local_sub_unchecked(length, &tail_page->write);
79650 return;
79651 }
79652
79653 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79654 rb_event_set_padding(event);
79655
79656 /* Set the write back to the previous setting */
79657 - local_sub(length, &tail_page->write);
79658 + local_sub_unchecked(length, &tail_page->write);
79659 return;
79660 }
79661
79662 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79663
79664 /* Set write to end of buffer */
79665 length = (tail + length) - BUF_PAGE_SIZE;
79666 - local_sub(length, &tail_page->write);
79667 + local_sub_unchecked(length, &tail_page->write);
79668 }
79669
79670 /*
79671 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79672 * about it.
79673 */
79674 if (unlikely(next_page == commit_page)) {
79675 - local_inc(&cpu_buffer->commit_overrun);
79676 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79677 goto out_reset;
79678 }
79679
79680 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79681 cpu_buffer->tail_page) &&
79682 (cpu_buffer->commit_page ==
79683 cpu_buffer->reader_page))) {
79684 - local_inc(&cpu_buffer->commit_overrun);
79685 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79686 goto out_reset;
79687 }
79688 }
79689 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79690 length += RB_LEN_TIME_EXTEND;
79691
79692 tail_page = cpu_buffer->tail_page;
79693 - write = local_add_return(length, &tail_page->write);
79694 + write = local_add_return_unchecked(length, &tail_page->write);
79695
79696 /* set write to only the index of the write */
79697 write &= RB_WRITE_MASK;
79698 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79699 kmemcheck_annotate_bitfield(event, bitfield);
79700 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79701
79702 - local_inc(&tail_page->entries);
79703 + local_inc_unchecked(&tail_page->entries);
79704
79705 /*
79706 * If this is the first commit on the page, then update
79707 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79708
79709 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79710 unsigned long write_mask =
79711 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79712 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79713 unsigned long event_length = rb_event_length(event);
79714 /*
79715 * This is on the tail page. It is possible that
79716 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79717 */
79718 old_index += write_mask;
79719 new_index += write_mask;
79720 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79721 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79722 if (index == old_index) {
79723 /* update counters */
79724 local_sub(event_length, &cpu_buffer->entries_bytes);
79725 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79726
79727 /* Do the likely case first */
79728 if (likely(bpage->page == (void *)addr)) {
79729 - local_dec(&bpage->entries);
79730 + local_dec_unchecked(&bpage->entries);
79731 return;
79732 }
79733
79734 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79735 start = bpage;
79736 do {
79737 if (bpage->page == (void *)addr) {
79738 - local_dec(&bpage->entries);
79739 + local_dec_unchecked(&bpage->entries);
79740 return;
79741 }
79742 rb_inc_page(cpu_buffer, &bpage);
79743 @@ -2926,7 +2926,7 @@ static inline unsigned long
79744 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79745 {
79746 return local_read(&cpu_buffer->entries) -
79747 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79748 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79749 }
79750
79751 /**
79752 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79753 return 0;
79754
79755 cpu_buffer = buffer->buffers[cpu];
79756 - ret = local_read(&cpu_buffer->overrun);
79757 + ret = local_read_unchecked(&cpu_buffer->overrun);
79758
79759 return ret;
79760 }
79761 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79762 return 0;
79763
79764 cpu_buffer = buffer->buffers[cpu];
79765 - ret = local_read(&cpu_buffer->commit_overrun);
79766 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79767
79768 return ret;
79769 }
79770 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79771 /* if you care about this being correct, lock the buffer */
79772 for_each_buffer_cpu(buffer, cpu) {
79773 cpu_buffer = buffer->buffers[cpu];
79774 - overruns += local_read(&cpu_buffer->overrun);
79775 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79776 }
79777
79778 return overruns;
79779 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79780 /*
79781 * Reset the reader page to size zero.
79782 */
79783 - local_set(&cpu_buffer->reader_page->write, 0);
79784 - local_set(&cpu_buffer->reader_page->entries, 0);
79785 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79786 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79787 local_set(&cpu_buffer->reader_page->page->commit, 0);
79788 cpu_buffer->reader_page->real_end = 0;
79789
79790 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79791 * want to compare with the last_overrun.
79792 */
79793 smp_mb();
79794 - overwrite = local_read(&(cpu_buffer->overrun));
79795 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79796
79797 /*
79798 * Here's the tricky part.
79799 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79800
79801 cpu_buffer->head_page
79802 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79803 - local_set(&cpu_buffer->head_page->write, 0);
79804 - local_set(&cpu_buffer->head_page->entries, 0);
79805 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79806 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79807 local_set(&cpu_buffer->head_page->page->commit, 0);
79808
79809 cpu_buffer->head_page->read = 0;
79810 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79811
79812 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79813 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79814 - local_set(&cpu_buffer->reader_page->write, 0);
79815 - local_set(&cpu_buffer->reader_page->entries, 0);
79816 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79817 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79818 local_set(&cpu_buffer->reader_page->page->commit, 0);
79819 cpu_buffer->reader_page->read = 0;
79820
79821 local_set(&cpu_buffer->entries_bytes, 0);
79822 - local_set(&cpu_buffer->overrun, 0);
79823 - local_set(&cpu_buffer->commit_overrun, 0);
79824 + local_set_unchecked(&cpu_buffer->overrun, 0);
79825 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79826 local_set(&cpu_buffer->dropped_events, 0);
79827 local_set(&cpu_buffer->entries, 0);
79828 local_set(&cpu_buffer->committing, 0);
79829 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79830 rb_init_page(bpage);
79831 bpage = reader->page;
79832 reader->page = *data_page;
79833 - local_set(&reader->write, 0);
79834 - local_set(&reader->entries, 0);
79835 + local_set_unchecked(&reader->write, 0);
79836 + local_set_unchecked(&reader->entries, 0);
79837 reader->read = 0;
79838 *data_page = bpage;
79839
79840 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79841 index fe1d581..ea543f1b 100644
79842 --- a/kernel/trace/trace.c
79843 +++ b/kernel/trace/trace.c
79844 @@ -2845,7 +2845,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
79845 return 0;
79846 }
79847
79848 -int set_tracer_flag(unsigned int mask, int enabled)
79849 +int set_tracer_flag(unsigned long mask, int enabled)
79850 {
79851 /* do nothing if flag is already set */
79852 if (!!(trace_flags & mask) == !!enabled)
79853 @@ -4494,10 +4494,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79854 };
79855 #endif
79856
79857 -static struct dentry *d_tracer;
79858 -
79859 struct dentry *tracing_init_dentry(void)
79860 {
79861 + static struct dentry *d_tracer;
79862 static int once;
79863
79864 if (d_tracer)
79865 @@ -4517,10 +4516,9 @@ struct dentry *tracing_init_dentry(void)
79866 return d_tracer;
79867 }
79868
79869 -static struct dentry *d_percpu;
79870 -
79871 struct dentry *tracing_dentry_percpu(void)
79872 {
79873 + static struct dentry *d_percpu;
79874 static int once;
79875 struct dentry *d_tracer;
79876
79877 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
79878 index 23f1d2c..6ca7a9b 100644
79879 --- a/kernel/trace/trace.h
79880 +++ b/kernel/trace/trace.h
79881 @@ -840,7 +840,7 @@ extern const char *__stop___trace_bprintk_fmt[];
79882 void trace_printk_init_buffers(void);
79883 void trace_printk_start_comm(void);
79884 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
79885 -int set_tracer_flag(unsigned int mask, int enabled);
79886 +int set_tracer_flag(unsigned long mask, int enabled);
79887
79888 #undef FTRACE_ENTRY
79889 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
79890 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79891 index 880073d..42db7c3 100644
79892 --- a/kernel/trace/trace_events.c
79893 +++ b/kernel/trace/trace_events.c
79894 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
79895 struct ftrace_module_file_ops {
79896 struct list_head list;
79897 struct module *mod;
79898 - struct file_operations id;
79899 - struct file_operations enable;
79900 - struct file_operations format;
79901 - struct file_operations filter;
79902 };
79903
79904 static struct ftrace_module_file_ops *
79905 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
79906
79907 file_ops->mod = mod;
79908
79909 - file_ops->id = ftrace_event_id_fops;
79910 - file_ops->id.owner = mod;
79911 -
79912 - file_ops->enable = ftrace_enable_fops;
79913 - file_ops->enable.owner = mod;
79914 -
79915 - file_ops->filter = ftrace_event_filter_fops;
79916 - file_ops->filter.owner = mod;
79917 -
79918 - file_ops->format = ftrace_event_format_fops;
79919 - file_ops->format.owner = mod;
79920 + pax_open_kernel();
79921 + mod->trace_id.owner = mod;
79922 + mod->trace_enable.owner = mod;
79923 + mod->trace_filter.owner = mod;
79924 + mod->trace_format.owner = mod;
79925 + pax_close_kernel();
79926
79927 list_add(&file_ops->list, &ftrace_module_file_list);
79928
79929 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
79930
79931 for_each_event(call, start, end) {
79932 __trace_add_event_call(*call, mod,
79933 - &file_ops->id, &file_ops->enable,
79934 - &file_ops->filter, &file_ops->format);
79935 + &mod->trace_id, &mod->trace_enable,
79936 + &mod->trace_filter, &mod->trace_format);
79937 }
79938 }
79939
79940 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
79941 index fd3c8aa..5f324a6 100644
79942 --- a/kernel/trace/trace_mmiotrace.c
79943 +++ b/kernel/trace/trace_mmiotrace.c
79944 @@ -24,7 +24,7 @@ struct header_iter {
79945 static struct trace_array *mmio_trace_array;
79946 static bool overrun_detected;
79947 static unsigned long prev_overruns;
79948 -static atomic_t dropped_count;
79949 +static atomic_unchecked_t dropped_count;
79950
79951 static void mmio_reset_data(struct trace_array *tr)
79952 {
79953 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79954
79955 static unsigned long count_overruns(struct trace_iterator *iter)
79956 {
79957 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79958 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79959 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79960
79961 if (over > prev_overruns)
79962 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79963 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79964 sizeof(*entry), 0, pc);
79965 if (!event) {
79966 - atomic_inc(&dropped_count);
79967 + atomic_inc_unchecked(&dropped_count);
79968 return;
79969 }
79970 entry = ring_buffer_event_data(event);
79971 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79972 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79973 sizeof(*entry), 0, pc);
79974 if (!event) {
79975 - atomic_inc(&dropped_count);
79976 + atomic_inc_unchecked(&dropped_count);
79977 return;
79978 }
79979 entry = ring_buffer_event_data(event);
79980 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79981 index 194d796..76edb8f 100644
79982 --- a/kernel/trace/trace_output.c
79983 +++ b/kernel/trace/trace_output.c
79984 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79985
79986 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79987 if (!IS_ERR(p)) {
79988 - p = mangle_path(s->buffer + s->len, p, "\n");
79989 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79990 if (p) {
79991 s->len = p - s->buffer;
79992 return 1;
79993 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
79994 goto out;
79995 }
79996
79997 + pax_open_kernel();
79998 if (event->funcs->trace == NULL)
79999 - event->funcs->trace = trace_nop_print;
80000 + *(void **)&event->funcs->trace = trace_nop_print;
80001 if (event->funcs->raw == NULL)
80002 - event->funcs->raw = trace_nop_print;
80003 + *(void **)&event->funcs->raw = trace_nop_print;
80004 if (event->funcs->hex == NULL)
80005 - event->funcs->hex = trace_nop_print;
80006 + *(void **)&event->funcs->hex = trace_nop_print;
80007 if (event->funcs->binary == NULL)
80008 - event->funcs->binary = trace_nop_print;
80009 + *(void **)&event->funcs->binary = trace_nop_print;
80010 + pax_close_kernel();
80011
80012 key = event->type & (EVENT_HASHSIZE - 1);
80013
80014 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
80015 index 83a8b5b..0bf39a9 100644
80016 --- a/kernel/trace/trace_stack.c
80017 +++ b/kernel/trace/trace_stack.c
80018 @@ -52,7 +52,7 @@ static inline void check_stack(void)
80019 return;
80020
80021 /* we do not handle interrupt stacks yet */
80022 - if (!object_is_on_stack(&this_size))
80023 + if (!object_starts_on_stack(&this_size))
80024 return;
80025
80026 local_irq_save(flags);
80027 diff --git a/kernel/user.c b/kernel/user.c
80028 index 7f6ff2b..1ac8f18 100644
80029 --- a/kernel/user.c
80030 +++ b/kernel/user.c
80031 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
80032 .count = 4294967295U,
80033 },
80034 },
80035 - .kref = {
80036 - .refcount = ATOMIC_INIT(3),
80037 - },
80038 + .count = ATOMIC_INIT(3),
80039 .owner = GLOBAL_ROOT_UID,
80040 .group = GLOBAL_ROOT_GID,
80041 .proc_inum = PROC_USER_INIT_INO,
80042 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
80043 index f359dc7..ddc606a 100644
80044 --- a/kernel/user_namespace.c
80045 +++ b/kernel/user_namespace.c
80046 @@ -89,7 +89,7 @@ int create_user_ns(struct cred *new)
80047 return ret;
80048 }
80049
80050 - kref_init(&ns->kref);
80051 + atomic_set(&ns->count, 1);
80052 /* Leave the new->user_ns reference with the new user namespace. */
80053 ns->parent = parent_ns;
80054 ns->owner = owner;
80055 @@ -117,15 +117,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
80056 return create_user_ns(cred);
80057 }
80058
80059 -void free_user_ns(struct kref *kref)
80060 +void free_user_ns(struct user_namespace *ns)
80061 {
80062 - struct user_namespace *parent, *ns =
80063 - container_of(kref, struct user_namespace, kref);
80064 + struct user_namespace *parent;
80065
80066 - parent = ns->parent;
80067 - proc_free_inum(ns->proc_inum);
80068 - kmem_cache_free(user_ns_cachep, ns);
80069 - put_user_ns(parent);
80070 + do {
80071 + parent = ns->parent;
80072 + proc_free_inum(ns->proc_inum);
80073 + kmem_cache_free(user_ns_cachep, ns);
80074 + ns = parent;
80075 + } while (atomic_dec_and_test(&parent->count));
80076 }
80077 EXPORT_SYMBOL(free_user_ns);
80078
80079 @@ -819,7 +820,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80080 if (atomic_read(&current->mm->mm_users) > 1)
80081 return -EINVAL;
80082
80083 - if (current->fs->users != 1)
80084 + if (atomic_read(&current->fs->users) != 1)
80085 return -EINVAL;
80086
80087 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80088 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80089 index 63da38c..639904e 100644
80090 --- a/kernel/utsname_sysctl.c
80091 +++ b/kernel/utsname_sysctl.c
80092 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80093 static int proc_do_uts_string(ctl_table *table, int write,
80094 void __user *buffer, size_t *lenp, loff_t *ppos)
80095 {
80096 - struct ctl_table uts_table;
80097 + ctl_table_no_const uts_table;
80098 int r;
80099 memcpy(&uts_table, table, sizeof(uts_table));
80100 uts_table.data = get_uts(table, write);
80101 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80102 index 75a2ab3..5961da7 100644
80103 --- a/kernel/watchdog.c
80104 +++ b/kernel/watchdog.c
80105 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80106 }
80107 #endif /* CONFIG_SYSCTL */
80108
80109 -static struct smp_hotplug_thread watchdog_threads = {
80110 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80111 .store = &softlockup_watchdog,
80112 .thread_should_run = watchdog_should_run,
80113 .thread_fn = watchdog,
80114 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80115 index 67604e5..fe94fb1 100644
80116 --- a/lib/Kconfig.debug
80117 +++ b/lib/Kconfig.debug
80118 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
80119
80120 config DEBUG_LOCK_ALLOC
80121 bool "Lock debugging: detect incorrect freeing of live locks"
80122 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80123 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80124 select DEBUG_SPINLOCK
80125 select DEBUG_MUTEXES
80126 select LOCKDEP
80127 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
80128
80129 config PROVE_LOCKING
80130 bool "Lock debugging: prove locking correctness"
80131 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80132 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80133 select LOCKDEP
80134 select DEBUG_SPINLOCK
80135 select DEBUG_MUTEXES
80136 @@ -670,7 +670,7 @@ config LOCKDEP
80137
80138 config LOCK_STAT
80139 bool "Lock usage statistics"
80140 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80141 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80142 select LOCKDEP
80143 select DEBUG_SPINLOCK
80144 select DEBUG_MUTEXES
80145 @@ -1278,6 +1278,7 @@ config LATENCYTOP
80146 depends on DEBUG_KERNEL
80147 depends on STACKTRACE_SUPPORT
80148 depends on PROC_FS
80149 + depends on !GRKERNSEC_HIDESYM
80150 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80151 select KALLSYMS
80152 select KALLSYMS_ALL
80153 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
80154
80155 config PROVIDE_OHCI1394_DMA_INIT
80156 bool "Remote debugging over FireWire early on boot"
80157 - depends on PCI && X86
80158 + depends on PCI && X86 && !GRKERNSEC
80159 help
80160 If you want to debug problems which hang or crash the kernel early
80161 on boot and the crashing machine has a FireWire port, you can use
80162 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80163
80164 config FIREWIRE_OHCI_REMOTE_DMA
80165 bool "Remote debugging over FireWire with firewire-ohci"
80166 - depends on FIREWIRE_OHCI
80167 + depends on FIREWIRE_OHCI && !GRKERNSEC
80168 help
80169 This option lets you use the FireWire bus for remote debugging
80170 with help of the firewire-ohci driver. It enables unfiltered
80171 diff --git a/lib/Makefile b/lib/Makefile
80172 index 02ed6c0..bd243da 100644
80173 --- a/lib/Makefile
80174 +++ b/lib/Makefile
80175 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80176
80177 obj-$(CONFIG_BTREE) += btree.o
80178 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80179 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80180 +obj-y += list_debug.o
80181 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80182
80183 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80184 diff --git a/lib/bitmap.c b/lib/bitmap.c
80185 index 06f7e4f..f3cf2b0 100644
80186 --- a/lib/bitmap.c
80187 +++ b/lib/bitmap.c
80188 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80189 {
80190 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80191 u32 chunk;
80192 - const char __user __force *ubuf = (const char __user __force *)buf;
80193 + const char __user *ubuf = (const char __force_user *)buf;
80194
80195 bitmap_zero(maskp, nmaskbits);
80196
80197 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80198 {
80199 if (!access_ok(VERIFY_READ, ubuf, ulen))
80200 return -EFAULT;
80201 - return __bitmap_parse((const char __force *)ubuf,
80202 + return __bitmap_parse((const char __force_kernel *)ubuf,
80203 ulen, 1, maskp, nmaskbits);
80204
80205 }
80206 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80207 {
80208 unsigned a, b;
80209 int c, old_c, totaldigits;
80210 - const char __user __force *ubuf = (const char __user __force *)buf;
80211 + const char __user *ubuf = (const char __force_user *)buf;
80212 int exp_digit, in_range;
80213
80214 totaldigits = c = 0;
80215 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80216 {
80217 if (!access_ok(VERIFY_READ, ubuf, ulen))
80218 return -EFAULT;
80219 - return __bitmap_parselist((const char __force *)ubuf,
80220 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80221 ulen, 1, maskp, nmaskbits);
80222 }
80223 EXPORT_SYMBOL(bitmap_parselist_user);
80224 diff --git a/lib/bug.c b/lib/bug.c
80225 index d0cdf14..4d07bd2 100644
80226 --- a/lib/bug.c
80227 +++ b/lib/bug.c
80228 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80229 return BUG_TRAP_TYPE_NONE;
80230
80231 bug = find_bug(bugaddr);
80232 + if (!bug)
80233 + return BUG_TRAP_TYPE_NONE;
80234
80235 file = NULL;
80236 line = 0;
80237 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80238 index d11808c..dc2d6f8 100644
80239 --- a/lib/debugobjects.c
80240 +++ b/lib/debugobjects.c
80241 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80242 if (limit > 4)
80243 return;
80244
80245 - is_on_stack = object_is_on_stack(addr);
80246 + is_on_stack = object_starts_on_stack(addr);
80247 if (is_on_stack == onstack)
80248 return;
80249
80250 diff --git a/lib/devres.c b/lib/devres.c
80251 index 80b9c76..9e32279 100644
80252 --- a/lib/devres.c
80253 +++ b/lib/devres.c
80254 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80255 void devm_iounmap(struct device *dev, void __iomem *addr)
80256 {
80257 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80258 - (void *)addr));
80259 + (void __force *)addr));
80260 iounmap(addr);
80261 }
80262 EXPORT_SYMBOL(devm_iounmap);
80263 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80264 {
80265 ioport_unmap(addr);
80266 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80267 - devm_ioport_map_match, (void *)addr));
80268 + devm_ioport_map_match, (void __force *)addr));
80269 }
80270 EXPORT_SYMBOL(devm_ioport_unmap);
80271
80272 diff --git a/lib/div64.c b/lib/div64.c
80273 index a163b6c..9618fa5 100644
80274 --- a/lib/div64.c
80275 +++ b/lib/div64.c
80276 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80277 EXPORT_SYMBOL(__div64_32);
80278
80279 #ifndef div_s64_rem
80280 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80281 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80282 {
80283 u64 quotient;
80284
80285 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80286 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80287 */
80288 #ifndef div64_u64
80289 -u64 div64_u64(u64 dividend, u64 divisor)
80290 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80291 {
80292 u32 high = divisor >> 32;
80293 u64 quot;
80294 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80295 index 5e396ac..58d5de1 100644
80296 --- a/lib/dma-debug.c
80297 +++ b/lib/dma-debug.c
80298 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80299
80300 void dma_debug_add_bus(struct bus_type *bus)
80301 {
80302 - struct notifier_block *nb;
80303 + notifier_block_no_const *nb;
80304
80305 if (global_disable)
80306 return;
80307 @@ -942,7 +942,7 @@ out:
80308
80309 static void check_for_stack(struct device *dev, void *addr)
80310 {
80311 - if (object_is_on_stack(addr))
80312 + if (object_starts_on_stack(addr))
80313 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80314 "stack [addr=%p]\n", addr);
80315 }
80316 diff --git a/lib/inflate.c b/lib/inflate.c
80317 index 013a761..c28f3fc 100644
80318 --- a/lib/inflate.c
80319 +++ b/lib/inflate.c
80320 @@ -269,7 +269,7 @@ static void free(void *where)
80321 malloc_ptr = free_mem_ptr;
80322 }
80323 #else
80324 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80325 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80326 #define free(a) kfree(a)
80327 #endif
80328
80329 diff --git a/lib/ioremap.c b/lib/ioremap.c
80330 index 0c9216c..863bd89 100644
80331 --- a/lib/ioremap.c
80332 +++ b/lib/ioremap.c
80333 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80334 unsigned long next;
80335
80336 phys_addr -= addr;
80337 - pmd = pmd_alloc(&init_mm, pud, addr);
80338 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80339 if (!pmd)
80340 return -ENOMEM;
80341 do {
80342 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80343 unsigned long next;
80344
80345 phys_addr -= addr;
80346 - pud = pud_alloc(&init_mm, pgd, addr);
80347 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80348 if (!pud)
80349 return -ENOMEM;
80350 do {
80351 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80352 index bd2bea9..6b3c95e 100644
80353 --- a/lib/is_single_threaded.c
80354 +++ b/lib/is_single_threaded.c
80355 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80356 struct task_struct *p, *t;
80357 bool ret;
80358
80359 + if (!mm)
80360 + return true;
80361 +
80362 if (atomic_read(&task->signal->live) != 1)
80363 return false;
80364
80365 diff --git a/lib/kobject.c b/lib/kobject.c
80366 index a654866..a4fd13d 100644
80367 --- a/lib/kobject.c
80368 +++ b/lib/kobject.c
80369 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80370
80371
80372 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80373 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80374 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80375
80376 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80377 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80378 {
80379 enum kobj_ns_type type = ops->type;
80380 int error;
80381 diff --git a/lib/list_debug.c b/lib/list_debug.c
80382 index c24c2f7..06e070b 100644
80383 --- a/lib/list_debug.c
80384 +++ b/lib/list_debug.c
80385 @@ -11,7 +11,9 @@
80386 #include <linux/bug.h>
80387 #include <linux/kernel.h>
80388 #include <linux/rculist.h>
80389 +#include <linux/mm.h>
80390
80391 +#ifdef CONFIG_DEBUG_LIST
80392 /*
80393 * Insert a new entry between two known consecutive entries.
80394 *
80395 @@ -19,21 +21,32 @@
80396 * the prev/next entries already!
80397 */
80398
80399 -void __list_add(struct list_head *new,
80400 - struct list_head *prev,
80401 - struct list_head *next)
80402 +static bool __list_add_debug(struct list_head *new,
80403 + struct list_head *prev,
80404 + struct list_head *next)
80405 {
80406 - WARN(next->prev != prev,
80407 + if (WARN(next->prev != prev,
80408 "list_add corruption. next->prev should be "
80409 "prev (%p), but was %p. (next=%p).\n",
80410 - prev, next->prev, next);
80411 - WARN(prev->next != next,
80412 + prev, next->prev, next) ||
80413 + WARN(prev->next != next,
80414 "list_add corruption. prev->next should be "
80415 "next (%p), but was %p. (prev=%p).\n",
80416 - next, prev->next, prev);
80417 - WARN(new == prev || new == next,
80418 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80419 - new, prev, next);
80420 + next, prev->next, prev) ||
80421 + WARN(new == prev || new == next,
80422 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80423 + new, prev, next))
80424 + return false;
80425 + return true;
80426 +}
80427 +
80428 +void __list_add(struct list_head *new,
80429 + struct list_head *prev,
80430 + struct list_head *next)
80431 +{
80432 + if (!__list_add_debug(new, prev, next))
80433 + return;
80434 +
80435 next->prev = new;
80436 new->next = next;
80437 new->prev = prev;
80438 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80439 }
80440 EXPORT_SYMBOL(__list_add);
80441
80442 -void __list_del_entry(struct list_head *entry)
80443 +static bool __list_del_entry_debug(struct list_head *entry)
80444 {
80445 struct list_head *prev, *next;
80446
80447 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80448 WARN(next->prev != entry,
80449 "list_del corruption. next->prev should be %p, "
80450 "but was %p\n", entry, next->prev))
80451 + return false;
80452 + return true;
80453 +}
80454 +
80455 +void __list_del_entry(struct list_head *entry)
80456 +{
80457 + if (!__list_del_entry_debug(entry))
80458 return;
80459
80460 - __list_del(prev, next);
80461 + __list_del(entry->prev, entry->next);
80462 }
80463 EXPORT_SYMBOL(__list_del_entry);
80464
80465 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80466 void __list_add_rcu(struct list_head *new,
80467 struct list_head *prev, struct list_head *next)
80468 {
80469 - WARN(next->prev != prev,
80470 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80471 - prev, next->prev, next);
80472 - WARN(prev->next != next,
80473 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80474 - next, prev->next, prev);
80475 + if (!__list_add_debug(new, prev, next))
80476 + return;
80477 +
80478 new->next = next;
80479 new->prev = prev;
80480 rcu_assign_pointer(list_next_rcu(prev), new);
80481 next->prev = new;
80482 }
80483 EXPORT_SYMBOL(__list_add_rcu);
80484 +#endif
80485 +
80486 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80487 +{
80488 +#ifdef CONFIG_DEBUG_LIST
80489 + if (!__list_add_debug(new, prev, next))
80490 + return;
80491 +#endif
80492 +
80493 + pax_open_kernel();
80494 + next->prev = new;
80495 + new->next = next;
80496 + new->prev = prev;
80497 + prev->next = new;
80498 + pax_close_kernel();
80499 +}
80500 +EXPORT_SYMBOL(__pax_list_add);
80501 +
80502 +void pax_list_del(struct list_head *entry)
80503 +{
80504 +#ifdef CONFIG_DEBUG_LIST
80505 + if (!__list_del_entry_debug(entry))
80506 + return;
80507 +#endif
80508 +
80509 + pax_open_kernel();
80510 + __list_del(entry->prev, entry->next);
80511 + entry->next = LIST_POISON1;
80512 + entry->prev = LIST_POISON2;
80513 + pax_close_kernel();
80514 +}
80515 +EXPORT_SYMBOL(pax_list_del);
80516 +
80517 +void pax_list_del_init(struct list_head *entry)
80518 +{
80519 + pax_open_kernel();
80520 + __list_del(entry->prev, entry->next);
80521 + INIT_LIST_HEAD(entry);
80522 + pax_close_kernel();
80523 +}
80524 +EXPORT_SYMBOL(pax_list_del_init);
80525 +
80526 +void __pax_list_add_rcu(struct list_head *new,
80527 + struct list_head *prev, struct list_head *next)
80528 +{
80529 +#ifdef CONFIG_DEBUG_LIST
80530 + if (!__list_add_debug(new, prev, next))
80531 + return;
80532 +#endif
80533 +
80534 + pax_open_kernel();
80535 + new->next = next;
80536 + new->prev = prev;
80537 + rcu_assign_pointer(list_next_rcu(prev), new);
80538 + next->prev = new;
80539 + pax_close_kernel();
80540 +}
80541 +EXPORT_SYMBOL(__pax_list_add_rcu);
80542 +
80543 +void pax_list_del_rcu(struct list_head *entry)
80544 +{
80545 +#ifdef CONFIG_DEBUG_LIST
80546 + if (!__list_del_entry_debug(entry))
80547 + return;
80548 +#endif
80549 +
80550 + pax_open_kernel();
80551 + __list_del(entry->prev, entry->next);
80552 + entry->next = LIST_POISON1;
80553 + entry->prev = LIST_POISON2;
80554 + pax_close_kernel();
80555 +}
80556 +EXPORT_SYMBOL(pax_list_del_rcu);
80557 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80558 index e796429..6e38f9f 100644
80559 --- a/lib/radix-tree.c
80560 +++ b/lib/radix-tree.c
80561 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80562 int nr;
80563 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80564 };
80565 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80566 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80567
80568 static inline void *ptr_to_indirect(void *ptr)
80569 {
80570 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80571 index bb2b201..46abaf9 100644
80572 --- a/lib/strncpy_from_user.c
80573 +++ b/lib/strncpy_from_user.c
80574 @@ -21,7 +21,7 @@
80575 */
80576 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80577 {
80578 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80579 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80580 long res = 0;
80581
80582 /*
80583 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80584 index a28df52..3d55877 100644
80585 --- a/lib/strnlen_user.c
80586 +++ b/lib/strnlen_user.c
80587 @@ -26,7 +26,7 @@
80588 */
80589 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80590 {
80591 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80592 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80593 long align, res = 0;
80594 unsigned long c;
80595
80596 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80597 index 196b069..358f342 100644
80598 --- a/lib/swiotlb.c
80599 +++ b/lib/swiotlb.c
80600 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80601
80602 void
80603 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80604 - dma_addr_t dev_addr)
80605 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80606 {
80607 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80608
80609 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80610 index fab33a9..3b5fe68 100644
80611 --- a/lib/vsprintf.c
80612 +++ b/lib/vsprintf.c
80613 @@ -16,6 +16,9 @@
80614 * - scnprintf and vscnprintf
80615 */
80616
80617 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80618 +#define __INCLUDED_BY_HIDESYM 1
80619 +#endif
80620 #include <stdarg.h>
80621 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80622 #include <linux/types.h>
80623 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
80624 char sym[KSYM_SYMBOL_LEN];
80625 if (ext == 'B')
80626 sprint_backtrace(sym, value);
80627 - else if (ext != 'f' && ext != 's')
80628 + else if (ext != 'f' && ext != 's' && ext != 'a')
80629 sprint_symbol(sym, value);
80630 else
80631 sprint_symbol_no_offset(sym, value);
80632 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80633 return number(buf, end, *(const netdev_features_t *)addr, spec);
80634 }
80635
80636 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80637 +int kptr_restrict __read_mostly = 2;
80638 +#else
80639 int kptr_restrict __read_mostly;
80640 +#endif
80641
80642 /*
80643 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80644 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80645 * - 'S' For symbolic direct pointers with offset
80646 * - 's' For symbolic direct pointers without offset
80647 * - 'B' For backtraced symbolic direct pointers with offset
80648 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80649 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80650 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80651 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80652 * - 'M' For a 6-byte MAC address, it prints the address in the
80653 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80654
80655 if (!ptr && *fmt != 'K') {
80656 /*
80657 - * Print (null) with the same width as a pointer so it makes
80658 + * Print (nil) with the same width as a pointer so it makes
80659 * tabular output look nice.
80660 */
80661 if (spec.field_width == -1)
80662 spec.field_width = default_width;
80663 - return string(buf, end, "(null)", spec);
80664 + return string(buf, end, "(nil)", spec);
80665 }
80666
80667 switch (*fmt) {
80668 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80669 /* Fallthrough */
80670 case 'S':
80671 case 's':
80672 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80673 + break;
80674 +#else
80675 + return symbol_string(buf, end, ptr, spec, *fmt);
80676 +#endif
80677 + case 'A':
80678 + case 'a':
80679 case 'B':
80680 return symbol_string(buf, end, ptr, spec, *fmt);
80681 case 'R':
80682 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80683 va_end(va);
80684 return buf;
80685 }
80686 + case 'P':
80687 + break;
80688 case 'K':
80689 /*
80690 * %pK cannot be used in IRQ context because its test
80691 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80692 }
80693 break;
80694 }
80695 +
80696 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80697 + /* 'P' = approved pointers to copy to userland,
80698 + as in the /proc/kallsyms case, as we make it display nothing
80699 + for non-root users, and the real contents for root users
80700 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80701 + above
80702 + */
80703 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80704 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80705 + dump_stack();
80706 + ptr = NULL;
80707 + }
80708 +#endif
80709 +
80710 spec.flags |= SMALL;
80711 if (spec.field_width == -1) {
80712 spec.field_width = default_width;
80713 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80714 typeof(type) value; \
80715 if (sizeof(type) == 8) { \
80716 args = PTR_ALIGN(args, sizeof(u32)); \
80717 - *(u32 *)&value = *(u32 *)args; \
80718 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80719 + *(u32 *)&value = *(const u32 *)args; \
80720 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80721 } else { \
80722 args = PTR_ALIGN(args, sizeof(type)); \
80723 - value = *(typeof(type) *)args; \
80724 + value = *(const typeof(type) *)args; \
80725 } \
80726 args += sizeof(type); \
80727 value; \
80728 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80729 case FORMAT_TYPE_STR: {
80730 const char *str_arg = args;
80731 args += strlen(str_arg) + 1;
80732 - str = string(str, end, (char *)str_arg, spec);
80733 + str = string(str, end, str_arg, spec);
80734 break;
80735 }
80736
80737 diff --git a/localversion-grsec b/localversion-grsec
80738 new file mode 100644
80739 index 0000000..7cd6065
80740 --- /dev/null
80741 +++ b/localversion-grsec
80742 @@ -0,0 +1 @@
80743 +-grsec
80744 diff --git a/mm/Kconfig b/mm/Kconfig
80745 index 278e3ab..87c384d 100644
80746 --- a/mm/Kconfig
80747 +++ b/mm/Kconfig
80748 @@ -286,10 +286,10 @@ config KSM
80749 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80750
80751 config DEFAULT_MMAP_MIN_ADDR
80752 - int "Low address space to protect from user allocation"
80753 + int "Low address space to protect from user allocation"
80754 depends on MMU
80755 - default 4096
80756 - help
80757 + default 65536
80758 + help
80759 This is the portion of low virtual memory which should be protected
80760 from userspace allocation. Keeping a user from writing to low pages
80761 can help reduce the impact of kernel NULL pointer bugs.
80762 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
80763
80764 config HWPOISON_INJECT
80765 tristate "HWPoison pages injector"
80766 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80767 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80768 select PROC_PAGE_MONITOR
80769
80770 config NOMMU_INITIAL_TRIM_EXCESS
80771 diff --git a/mm/filemap.c b/mm/filemap.c
80772 index 83efee7..3f99381 100644
80773 --- a/mm/filemap.c
80774 +++ b/mm/filemap.c
80775 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80776 struct address_space *mapping = file->f_mapping;
80777
80778 if (!mapping->a_ops->readpage)
80779 - return -ENOEXEC;
80780 + return -ENODEV;
80781 file_accessed(file);
80782 vma->vm_ops = &generic_file_vm_ops;
80783 return 0;
80784 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80785 *pos = i_size_read(inode);
80786
80787 if (limit != RLIM_INFINITY) {
80788 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80789 if (*pos >= limit) {
80790 send_sig(SIGXFSZ, current, 0);
80791 return -EFBIG;
80792 diff --git a/mm/fremap.c b/mm/fremap.c
80793 index a0aaf0e..20325c3 100644
80794 --- a/mm/fremap.c
80795 +++ b/mm/fremap.c
80796 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80797 retry:
80798 vma = find_vma(mm, start);
80799
80800 +#ifdef CONFIG_PAX_SEGMEXEC
80801 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80802 + goto out;
80803 +#endif
80804 +
80805 /*
80806 * Make sure the vma is shared, that it supports prefaulting,
80807 * and that the remapped range is valid and fully within
80808 diff --git a/mm/highmem.c b/mm/highmem.c
80809 index b32b70c..e512eb0 100644
80810 --- a/mm/highmem.c
80811 +++ b/mm/highmem.c
80812 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80813 * So no dangers, even with speculative execution.
80814 */
80815 page = pte_page(pkmap_page_table[i]);
80816 + pax_open_kernel();
80817 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80818 -
80819 + pax_close_kernel();
80820 set_page_address(page, NULL);
80821 need_flush = 1;
80822 }
80823 @@ -198,9 +199,11 @@ start:
80824 }
80825 }
80826 vaddr = PKMAP_ADDR(last_pkmap_nr);
80827 +
80828 + pax_open_kernel();
80829 set_pte_at(&init_mm, vaddr,
80830 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80831 -
80832 + pax_close_kernel();
80833 pkmap_count[last_pkmap_nr] = 1;
80834 set_page_address(page, (void *)vaddr);
80835
80836 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80837 index 88eb939..0bd9e7d 100644
80838 --- a/mm/hugetlb.c
80839 +++ b/mm/hugetlb.c
80840 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80841 struct hstate *h = &default_hstate;
80842 unsigned long tmp;
80843 int ret;
80844 + ctl_table_no_const hugetlb_table;
80845
80846 tmp = h->max_huge_pages;
80847
80848 if (write && h->order >= MAX_ORDER)
80849 return -EINVAL;
80850
80851 - table->data = &tmp;
80852 - table->maxlen = sizeof(unsigned long);
80853 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80854 + hugetlb_table = *table;
80855 + hugetlb_table.data = &tmp;
80856 + hugetlb_table.maxlen = sizeof(unsigned long);
80857 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80858 if (ret)
80859 goto out;
80860
80861 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80862 struct hstate *h = &default_hstate;
80863 unsigned long tmp;
80864 int ret;
80865 + ctl_table_no_const hugetlb_table;
80866
80867 tmp = h->nr_overcommit_huge_pages;
80868
80869 if (write && h->order >= MAX_ORDER)
80870 return -EINVAL;
80871
80872 - table->data = &tmp;
80873 - table->maxlen = sizeof(unsigned long);
80874 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80875 + hugetlb_table = *table;
80876 + hugetlb_table.data = &tmp;
80877 + hugetlb_table.maxlen = sizeof(unsigned long);
80878 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80879 if (ret)
80880 goto out;
80881
80882 @@ -2515,6 +2519,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80883 return 1;
80884 }
80885
80886 +#ifdef CONFIG_PAX_SEGMEXEC
80887 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80888 +{
80889 + struct mm_struct *mm = vma->vm_mm;
80890 + struct vm_area_struct *vma_m;
80891 + unsigned long address_m;
80892 + pte_t *ptep_m;
80893 +
80894 + vma_m = pax_find_mirror_vma(vma);
80895 + if (!vma_m)
80896 + return;
80897 +
80898 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80899 + address_m = address + SEGMEXEC_TASK_SIZE;
80900 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80901 + get_page(page_m);
80902 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80903 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80904 +}
80905 +#endif
80906 +
80907 /*
80908 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80909 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80910 @@ -2633,6 +2658,11 @@ retry_avoidcopy:
80911 make_huge_pte(vma, new_page, 1));
80912 page_remove_rmap(old_page);
80913 hugepage_add_new_anon_rmap(new_page, vma, address);
80914 +
80915 +#ifdef CONFIG_PAX_SEGMEXEC
80916 + pax_mirror_huge_pte(vma, address, new_page);
80917 +#endif
80918 +
80919 /* Make the old page be freed below */
80920 new_page = old_page;
80921 }
80922 @@ -2792,6 +2822,10 @@ retry:
80923 && (vma->vm_flags & VM_SHARED)));
80924 set_huge_pte_at(mm, address, ptep, new_pte);
80925
80926 +#ifdef CONFIG_PAX_SEGMEXEC
80927 + pax_mirror_huge_pte(vma, address, page);
80928 +#endif
80929 +
80930 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
80931 /* Optimization, do the COW without a second fault */
80932 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
80933 @@ -2821,6 +2855,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80934 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
80935 struct hstate *h = hstate_vma(vma);
80936
80937 +#ifdef CONFIG_PAX_SEGMEXEC
80938 + struct vm_area_struct *vma_m;
80939 +#endif
80940 +
80941 address &= huge_page_mask(h);
80942
80943 ptep = huge_pte_offset(mm, address);
80944 @@ -2834,6 +2872,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80945 VM_FAULT_SET_HINDEX(hstate_index(h));
80946 }
80947
80948 +#ifdef CONFIG_PAX_SEGMEXEC
80949 + vma_m = pax_find_mirror_vma(vma);
80950 + if (vma_m) {
80951 + unsigned long address_m;
80952 +
80953 + if (vma->vm_start > vma_m->vm_start) {
80954 + address_m = address;
80955 + address -= SEGMEXEC_TASK_SIZE;
80956 + vma = vma_m;
80957 + h = hstate_vma(vma);
80958 + } else
80959 + address_m = address + SEGMEXEC_TASK_SIZE;
80960 +
80961 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
80962 + return VM_FAULT_OOM;
80963 + address_m &= HPAGE_MASK;
80964 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
80965 + }
80966 +#endif
80967 +
80968 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
80969 if (!ptep)
80970 return VM_FAULT_OOM;
80971 diff --git a/mm/internal.h b/mm/internal.h
80972 index 9ba2110..eaf0674 100644
80973 --- a/mm/internal.h
80974 +++ b/mm/internal.h
80975 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
80976 * in mm/page_alloc.c
80977 */
80978 extern void __free_pages_bootmem(struct page *page, unsigned int order);
80979 +extern void free_compound_page(struct page *page);
80980 extern void prep_compound_page(struct page *page, unsigned long order);
80981 #ifdef CONFIG_MEMORY_FAILURE
80982 extern bool is_free_buddy_page(struct page *page);
80983 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
80984 index 752a705..6c3102e 100644
80985 --- a/mm/kmemleak.c
80986 +++ b/mm/kmemleak.c
80987 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
80988
80989 for (i = 0; i < object->trace_len; i++) {
80990 void *ptr = (void *)object->trace[i];
80991 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
80992 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
80993 }
80994 }
80995
80996 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
80997 return -ENOMEM;
80998 }
80999
81000 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
81001 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
81002 &kmemleak_fops);
81003 if (!dentry)
81004 pr_warning("Failed to create the debugfs kmemleak file\n");
81005 diff --git a/mm/maccess.c b/mm/maccess.c
81006 index d53adf9..03a24bf 100644
81007 --- a/mm/maccess.c
81008 +++ b/mm/maccess.c
81009 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
81010 set_fs(KERNEL_DS);
81011 pagefault_disable();
81012 ret = __copy_from_user_inatomic(dst,
81013 - (__force const void __user *)src, size);
81014 + (const void __force_user *)src, size);
81015 pagefault_enable();
81016 set_fs(old_fs);
81017
81018 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
81019
81020 set_fs(KERNEL_DS);
81021 pagefault_disable();
81022 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81023 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81024 pagefault_enable();
81025 set_fs(old_fs);
81026
81027 diff --git a/mm/madvise.c b/mm/madvise.c
81028 index 03dfa5c..b032917 100644
81029 --- a/mm/madvise.c
81030 +++ b/mm/madvise.c
81031 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81032 pgoff_t pgoff;
81033 unsigned long new_flags = vma->vm_flags;
81034
81035 +#ifdef CONFIG_PAX_SEGMEXEC
81036 + struct vm_area_struct *vma_m;
81037 +#endif
81038 +
81039 switch (behavior) {
81040 case MADV_NORMAL:
81041 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81042 @@ -123,6 +127,13 @@ success:
81043 /*
81044 * vm_flags is protected by the mmap_sem held in write mode.
81045 */
81046 +
81047 +#ifdef CONFIG_PAX_SEGMEXEC
81048 + vma_m = pax_find_mirror_vma(vma);
81049 + if (vma_m)
81050 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81051 +#endif
81052 +
81053 vma->vm_flags = new_flags;
81054
81055 out:
81056 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81057 struct vm_area_struct ** prev,
81058 unsigned long start, unsigned long end)
81059 {
81060 +
81061 +#ifdef CONFIG_PAX_SEGMEXEC
81062 + struct vm_area_struct *vma_m;
81063 +#endif
81064 +
81065 *prev = vma;
81066 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81067 return -EINVAL;
81068 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81069 zap_page_range(vma, start, end - start, &details);
81070 } else
81071 zap_page_range(vma, start, end - start, NULL);
81072 +
81073 +#ifdef CONFIG_PAX_SEGMEXEC
81074 + vma_m = pax_find_mirror_vma(vma);
81075 + if (vma_m) {
81076 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81077 + struct zap_details details = {
81078 + .nonlinear_vma = vma_m,
81079 + .last_index = ULONG_MAX,
81080 + };
81081 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81082 + } else
81083 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81084 + }
81085 +#endif
81086 +
81087 return 0;
81088 }
81089
81090 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81091 if (end < start)
81092 goto out;
81093
81094 +#ifdef CONFIG_PAX_SEGMEXEC
81095 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81096 + if (end > SEGMEXEC_TASK_SIZE)
81097 + goto out;
81098 + } else
81099 +#endif
81100 +
81101 + if (end > TASK_SIZE)
81102 + goto out;
81103 +
81104 error = 0;
81105 if (end == start)
81106 goto out;
81107 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81108 index c6e4dd3..1f41988 100644
81109 --- a/mm/memory-failure.c
81110 +++ b/mm/memory-failure.c
81111 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81112
81113 int sysctl_memory_failure_recovery __read_mostly = 1;
81114
81115 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81116 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81117
81118 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81119
81120 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81121 pfn, t->comm, t->pid);
81122 si.si_signo = SIGBUS;
81123 si.si_errno = 0;
81124 - si.si_addr = (void *)addr;
81125 + si.si_addr = (void __user *)addr;
81126 #ifdef __ARCH_SI_TRAPNO
81127 si.si_trapno = trapno;
81128 #endif
81129 @@ -760,7 +760,7 @@ static struct page_state {
81130 unsigned long res;
81131 char *msg;
81132 int (*action)(struct page *p, unsigned long pfn);
81133 -} error_states[] = {
81134 +} __do_const error_states[] = {
81135 { reserved, reserved, "reserved kernel", me_kernel },
81136 /*
81137 * free pages are specially detected outside this table:
81138 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81139 }
81140
81141 nr_pages = 1 << compound_trans_order(hpage);
81142 - atomic_long_add(nr_pages, &mce_bad_pages);
81143 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
81144
81145 /*
81146 * We need/can do nothing about count=0 pages.
81147 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81148 if (!PageHWPoison(hpage)
81149 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81150 || (p != hpage && TestSetPageHWPoison(hpage))) {
81151 - atomic_long_sub(nr_pages, &mce_bad_pages);
81152 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81153 return 0;
81154 }
81155 set_page_hwpoison_huge_page(hpage);
81156 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81157 }
81158 if (hwpoison_filter(p)) {
81159 if (TestClearPageHWPoison(p))
81160 - atomic_long_sub(nr_pages, &mce_bad_pages);
81161 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81162 unlock_page(hpage);
81163 put_page(hpage);
81164 return 0;
81165 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
81166 return 0;
81167 }
81168 if (TestClearPageHWPoison(p))
81169 - atomic_long_sub(nr_pages, &mce_bad_pages);
81170 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81171 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81172 return 0;
81173 }
81174 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
81175 */
81176 if (TestClearPageHWPoison(page)) {
81177 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81178 - atomic_long_sub(nr_pages, &mce_bad_pages);
81179 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81180 freeit = 1;
81181 if (PageHuge(page))
81182 clear_page_hwpoison_huge_page(page);
81183 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81184 }
81185 done:
81186 if (!PageHWPoison(hpage))
81187 - atomic_long_add(1 << compound_trans_order(hpage),
81188 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81189 &mce_bad_pages);
81190 set_page_hwpoison_huge_page(hpage);
81191 dequeue_hwpoisoned_huge_page(hpage);
81192 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
81193 return ret;
81194
81195 done:
81196 - atomic_long_add(1, &mce_bad_pages);
81197 + atomic_long_add_unchecked(1, &mce_bad_pages);
81198 SetPageHWPoison(page);
81199 /* keep elevated page count for bad page */
81200 return ret;
81201 diff --git a/mm/memory.c b/mm/memory.c
81202 index 32a495a..8042dce 100644
81203 --- a/mm/memory.c
81204 +++ b/mm/memory.c
81205 @@ -434,6 +434,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81206 free_pte_range(tlb, pmd, addr);
81207 } while (pmd++, addr = next, addr != end);
81208
81209 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81210 start &= PUD_MASK;
81211 if (start < floor)
81212 return;
81213 @@ -448,6 +449,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81214 pmd = pmd_offset(pud, start);
81215 pud_clear(pud);
81216 pmd_free_tlb(tlb, pmd, start);
81217 +#endif
81218 +
81219 }
81220
81221 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81222 @@ -467,6 +470,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81223 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81224 } while (pud++, addr = next, addr != end);
81225
81226 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81227 start &= PGDIR_MASK;
81228 if (start < floor)
81229 return;
81230 @@ -481,6 +485,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81231 pud = pud_offset(pgd, start);
81232 pgd_clear(pgd);
81233 pud_free_tlb(tlb, pud, start);
81234 +#endif
81235 +
81236 }
81237
81238 /*
81239 @@ -1619,12 +1625,6 @@ no_page_table:
81240 return page;
81241 }
81242
81243 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81244 -{
81245 - return stack_guard_page_start(vma, addr) ||
81246 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81247 -}
81248 -
81249 /**
81250 * __get_user_pages() - pin user pages in memory
81251 * @tsk: task_struct of target task
81252 @@ -1710,10 +1710,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81253
81254 i = 0;
81255
81256 - do {
81257 + while (nr_pages) {
81258 struct vm_area_struct *vma;
81259
81260 - vma = find_extend_vma(mm, start);
81261 + vma = find_vma(mm, start);
81262 if (!vma && in_gate_area(mm, start)) {
81263 unsigned long pg = start & PAGE_MASK;
81264 pgd_t *pgd;
81265 @@ -1761,7 +1761,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81266 goto next_page;
81267 }
81268
81269 - if (!vma ||
81270 + if (!vma || start < vma->vm_start ||
81271 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81272 !(vm_flags & vma->vm_flags))
81273 return i ? : -EFAULT;
81274 @@ -1788,11 +1788,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81275 int ret;
81276 unsigned int fault_flags = 0;
81277
81278 - /* For mlock, just skip the stack guard page. */
81279 - if (foll_flags & FOLL_MLOCK) {
81280 - if (stack_guard_page(vma, start))
81281 - goto next_page;
81282 - }
81283 if (foll_flags & FOLL_WRITE)
81284 fault_flags |= FAULT_FLAG_WRITE;
81285 if (nonblocking)
81286 @@ -1866,7 +1861,7 @@ next_page:
81287 start += PAGE_SIZE;
81288 nr_pages--;
81289 } while (nr_pages && start < vma->vm_end);
81290 - } while (nr_pages);
81291 + }
81292 return i;
81293 }
81294 EXPORT_SYMBOL(__get_user_pages);
81295 @@ -2073,6 +2068,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81296 page_add_file_rmap(page);
81297 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81298
81299 +#ifdef CONFIG_PAX_SEGMEXEC
81300 + pax_mirror_file_pte(vma, addr, page, ptl);
81301 +#endif
81302 +
81303 retval = 0;
81304 pte_unmap_unlock(pte, ptl);
81305 return retval;
81306 @@ -2117,9 +2116,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81307 if (!page_count(page))
81308 return -EINVAL;
81309 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81310 +
81311 +#ifdef CONFIG_PAX_SEGMEXEC
81312 + struct vm_area_struct *vma_m;
81313 +#endif
81314 +
81315 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81316 BUG_ON(vma->vm_flags & VM_PFNMAP);
81317 vma->vm_flags |= VM_MIXEDMAP;
81318 +
81319 +#ifdef CONFIG_PAX_SEGMEXEC
81320 + vma_m = pax_find_mirror_vma(vma);
81321 + if (vma_m)
81322 + vma_m->vm_flags |= VM_MIXEDMAP;
81323 +#endif
81324 +
81325 }
81326 return insert_page(vma, addr, page, vma->vm_page_prot);
81327 }
81328 @@ -2202,6 +2213,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81329 unsigned long pfn)
81330 {
81331 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81332 + BUG_ON(vma->vm_mirror);
81333
81334 if (addr < vma->vm_start || addr >= vma->vm_end)
81335 return -EFAULT;
81336 @@ -2449,7 +2461,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81337
81338 BUG_ON(pud_huge(*pud));
81339
81340 - pmd = pmd_alloc(mm, pud, addr);
81341 + pmd = (mm == &init_mm) ?
81342 + pmd_alloc_kernel(mm, pud, addr) :
81343 + pmd_alloc(mm, pud, addr);
81344 if (!pmd)
81345 return -ENOMEM;
81346 do {
81347 @@ -2469,7 +2483,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81348 unsigned long next;
81349 int err;
81350
81351 - pud = pud_alloc(mm, pgd, addr);
81352 + pud = (mm == &init_mm) ?
81353 + pud_alloc_kernel(mm, pgd, addr) :
81354 + pud_alloc(mm, pgd, addr);
81355 if (!pud)
81356 return -ENOMEM;
81357 do {
81358 @@ -2557,6 +2573,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81359 copy_user_highpage(dst, src, va, vma);
81360 }
81361
81362 +#ifdef CONFIG_PAX_SEGMEXEC
81363 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81364 +{
81365 + struct mm_struct *mm = vma->vm_mm;
81366 + spinlock_t *ptl;
81367 + pte_t *pte, entry;
81368 +
81369 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81370 + entry = *pte;
81371 + if (!pte_present(entry)) {
81372 + if (!pte_none(entry)) {
81373 + BUG_ON(pte_file(entry));
81374 + free_swap_and_cache(pte_to_swp_entry(entry));
81375 + pte_clear_not_present_full(mm, address, pte, 0);
81376 + }
81377 + } else {
81378 + struct page *page;
81379 +
81380 + flush_cache_page(vma, address, pte_pfn(entry));
81381 + entry = ptep_clear_flush(vma, address, pte);
81382 + BUG_ON(pte_dirty(entry));
81383 + page = vm_normal_page(vma, address, entry);
81384 + if (page) {
81385 + update_hiwater_rss(mm);
81386 + if (PageAnon(page))
81387 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81388 + else
81389 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81390 + page_remove_rmap(page);
81391 + page_cache_release(page);
81392 + }
81393 + }
81394 + pte_unmap_unlock(pte, ptl);
81395 +}
81396 +
81397 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81398 + *
81399 + * the ptl of the lower mapped page is held on entry and is not released on exit
81400 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81401 + */
81402 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81403 +{
81404 + struct mm_struct *mm = vma->vm_mm;
81405 + unsigned long address_m;
81406 + spinlock_t *ptl_m;
81407 + struct vm_area_struct *vma_m;
81408 + pmd_t *pmd_m;
81409 + pte_t *pte_m, entry_m;
81410 +
81411 + BUG_ON(!page_m || !PageAnon(page_m));
81412 +
81413 + vma_m = pax_find_mirror_vma(vma);
81414 + if (!vma_m)
81415 + return;
81416 +
81417 + BUG_ON(!PageLocked(page_m));
81418 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81419 + address_m = address + SEGMEXEC_TASK_SIZE;
81420 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81421 + pte_m = pte_offset_map(pmd_m, address_m);
81422 + ptl_m = pte_lockptr(mm, pmd_m);
81423 + if (ptl != ptl_m) {
81424 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81425 + if (!pte_none(*pte_m))
81426 + goto out;
81427 + }
81428 +
81429 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81430 + page_cache_get(page_m);
81431 + page_add_anon_rmap(page_m, vma_m, address_m);
81432 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81433 + set_pte_at(mm, address_m, pte_m, entry_m);
81434 + update_mmu_cache(vma_m, address_m, entry_m);
81435 +out:
81436 + if (ptl != ptl_m)
81437 + spin_unlock(ptl_m);
81438 + pte_unmap(pte_m);
81439 + unlock_page(page_m);
81440 +}
81441 +
81442 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81443 +{
81444 + struct mm_struct *mm = vma->vm_mm;
81445 + unsigned long address_m;
81446 + spinlock_t *ptl_m;
81447 + struct vm_area_struct *vma_m;
81448 + pmd_t *pmd_m;
81449 + pte_t *pte_m, entry_m;
81450 +
81451 + BUG_ON(!page_m || PageAnon(page_m));
81452 +
81453 + vma_m = pax_find_mirror_vma(vma);
81454 + if (!vma_m)
81455 + return;
81456 +
81457 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81458 + address_m = address + SEGMEXEC_TASK_SIZE;
81459 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81460 + pte_m = pte_offset_map(pmd_m, address_m);
81461 + ptl_m = pte_lockptr(mm, pmd_m);
81462 + if (ptl != ptl_m) {
81463 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81464 + if (!pte_none(*pte_m))
81465 + goto out;
81466 + }
81467 +
81468 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81469 + page_cache_get(page_m);
81470 + page_add_file_rmap(page_m);
81471 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81472 + set_pte_at(mm, address_m, pte_m, entry_m);
81473 + update_mmu_cache(vma_m, address_m, entry_m);
81474 +out:
81475 + if (ptl != ptl_m)
81476 + spin_unlock(ptl_m);
81477 + pte_unmap(pte_m);
81478 +}
81479 +
81480 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81481 +{
81482 + struct mm_struct *mm = vma->vm_mm;
81483 + unsigned long address_m;
81484 + spinlock_t *ptl_m;
81485 + struct vm_area_struct *vma_m;
81486 + pmd_t *pmd_m;
81487 + pte_t *pte_m, entry_m;
81488 +
81489 + vma_m = pax_find_mirror_vma(vma);
81490 + if (!vma_m)
81491 + return;
81492 +
81493 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81494 + address_m = address + SEGMEXEC_TASK_SIZE;
81495 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81496 + pte_m = pte_offset_map(pmd_m, address_m);
81497 + ptl_m = pte_lockptr(mm, pmd_m);
81498 + if (ptl != ptl_m) {
81499 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81500 + if (!pte_none(*pte_m))
81501 + goto out;
81502 + }
81503 +
81504 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81505 + set_pte_at(mm, address_m, pte_m, entry_m);
81506 +out:
81507 + if (ptl != ptl_m)
81508 + spin_unlock(ptl_m);
81509 + pte_unmap(pte_m);
81510 +}
81511 +
81512 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81513 +{
81514 + struct page *page_m;
81515 + pte_t entry;
81516 +
81517 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81518 + goto out;
81519 +
81520 + entry = *pte;
81521 + page_m = vm_normal_page(vma, address, entry);
81522 + if (!page_m)
81523 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81524 + else if (PageAnon(page_m)) {
81525 + if (pax_find_mirror_vma(vma)) {
81526 + pte_unmap_unlock(pte, ptl);
81527 + lock_page(page_m);
81528 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81529 + if (pte_same(entry, *pte))
81530 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81531 + else
81532 + unlock_page(page_m);
81533 + }
81534 + } else
81535 + pax_mirror_file_pte(vma, address, page_m, ptl);
81536 +
81537 +out:
81538 + pte_unmap_unlock(pte, ptl);
81539 +}
81540 +#endif
81541 +
81542 /*
81543 * This routine handles present pages, when users try to write
81544 * to a shared page. It is done by copying the page to a new address
81545 @@ -2773,6 +2969,12 @@ gotten:
81546 */
81547 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81548 if (likely(pte_same(*page_table, orig_pte))) {
81549 +
81550 +#ifdef CONFIG_PAX_SEGMEXEC
81551 + if (pax_find_mirror_vma(vma))
81552 + BUG_ON(!trylock_page(new_page));
81553 +#endif
81554 +
81555 if (old_page) {
81556 if (!PageAnon(old_page)) {
81557 dec_mm_counter_fast(mm, MM_FILEPAGES);
81558 @@ -2824,6 +3026,10 @@ gotten:
81559 page_remove_rmap(old_page);
81560 }
81561
81562 +#ifdef CONFIG_PAX_SEGMEXEC
81563 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81564 +#endif
81565 +
81566 /* Free the old page.. */
81567 new_page = old_page;
81568 ret |= VM_FAULT_WRITE;
81569 @@ -3099,6 +3305,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81570 swap_free(entry);
81571 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81572 try_to_free_swap(page);
81573 +
81574 +#ifdef CONFIG_PAX_SEGMEXEC
81575 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81576 +#endif
81577 +
81578 unlock_page(page);
81579 if (swapcache) {
81580 /*
81581 @@ -3122,6 +3333,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81582
81583 /* No need to invalidate - it was non-present before */
81584 update_mmu_cache(vma, address, page_table);
81585 +
81586 +#ifdef CONFIG_PAX_SEGMEXEC
81587 + pax_mirror_anon_pte(vma, address, page, ptl);
81588 +#endif
81589 +
81590 unlock:
81591 pte_unmap_unlock(page_table, ptl);
81592 out:
81593 @@ -3141,40 +3357,6 @@ out_release:
81594 }
81595
81596 /*
81597 - * This is like a special single-page "expand_{down|up}wards()",
81598 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81599 - * doesn't hit another vma.
81600 - */
81601 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81602 -{
81603 - address &= PAGE_MASK;
81604 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81605 - struct vm_area_struct *prev = vma->vm_prev;
81606 -
81607 - /*
81608 - * Is there a mapping abutting this one below?
81609 - *
81610 - * That's only ok if it's the same stack mapping
81611 - * that has gotten split..
81612 - */
81613 - if (prev && prev->vm_end == address)
81614 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81615 -
81616 - expand_downwards(vma, address - PAGE_SIZE);
81617 - }
81618 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81619 - struct vm_area_struct *next = vma->vm_next;
81620 -
81621 - /* As VM_GROWSDOWN but s/below/above/ */
81622 - if (next && next->vm_start == address + PAGE_SIZE)
81623 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81624 -
81625 - expand_upwards(vma, address + PAGE_SIZE);
81626 - }
81627 - return 0;
81628 -}
81629 -
81630 -/*
81631 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81632 * but allow concurrent faults), and pte mapped but not yet locked.
81633 * We return with mmap_sem still held, but pte unmapped and unlocked.
81634 @@ -3183,27 +3365,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81635 unsigned long address, pte_t *page_table, pmd_t *pmd,
81636 unsigned int flags)
81637 {
81638 - struct page *page;
81639 + struct page *page = NULL;
81640 spinlock_t *ptl;
81641 pte_t entry;
81642
81643 - pte_unmap(page_table);
81644 -
81645 - /* Check if we need to add a guard page to the stack */
81646 - if (check_stack_guard_page(vma, address) < 0)
81647 - return VM_FAULT_SIGBUS;
81648 -
81649 - /* Use the zero-page for reads */
81650 if (!(flags & FAULT_FLAG_WRITE)) {
81651 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81652 vma->vm_page_prot));
81653 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81654 + ptl = pte_lockptr(mm, pmd);
81655 + spin_lock(ptl);
81656 if (!pte_none(*page_table))
81657 goto unlock;
81658 goto setpte;
81659 }
81660
81661 /* Allocate our own private page. */
81662 + pte_unmap(page_table);
81663 +
81664 if (unlikely(anon_vma_prepare(vma)))
81665 goto oom;
81666 page = alloc_zeroed_user_highpage_movable(vma, address);
81667 @@ -3222,6 +3400,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81668 if (!pte_none(*page_table))
81669 goto release;
81670
81671 +#ifdef CONFIG_PAX_SEGMEXEC
81672 + if (pax_find_mirror_vma(vma))
81673 + BUG_ON(!trylock_page(page));
81674 +#endif
81675 +
81676 inc_mm_counter_fast(mm, MM_ANONPAGES);
81677 page_add_new_anon_rmap(page, vma, address);
81678 setpte:
81679 @@ -3229,6 +3412,12 @@ setpte:
81680
81681 /* No need to invalidate - it was non-present before */
81682 update_mmu_cache(vma, address, page_table);
81683 +
81684 +#ifdef CONFIG_PAX_SEGMEXEC
81685 + if (page)
81686 + pax_mirror_anon_pte(vma, address, page, ptl);
81687 +#endif
81688 +
81689 unlock:
81690 pte_unmap_unlock(page_table, ptl);
81691 return 0;
81692 @@ -3372,6 +3561,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81693 */
81694 /* Only go through if we didn't race with anybody else... */
81695 if (likely(pte_same(*page_table, orig_pte))) {
81696 +
81697 +#ifdef CONFIG_PAX_SEGMEXEC
81698 + if (anon && pax_find_mirror_vma(vma))
81699 + BUG_ON(!trylock_page(page));
81700 +#endif
81701 +
81702 flush_icache_page(vma, page);
81703 entry = mk_pte(page, vma->vm_page_prot);
81704 if (flags & FAULT_FLAG_WRITE)
81705 @@ -3391,6 +3586,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81706
81707 /* no need to invalidate: a not-present page won't be cached */
81708 update_mmu_cache(vma, address, page_table);
81709 +
81710 +#ifdef CONFIG_PAX_SEGMEXEC
81711 + if (anon)
81712 + pax_mirror_anon_pte(vma, address, page, ptl);
81713 + else
81714 + pax_mirror_file_pte(vma, address, page, ptl);
81715 +#endif
81716 +
81717 } else {
81718 if (cow_page)
81719 mem_cgroup_uncharge_page(cow_page);
81720 @@ -3712,6 +3915,12 @@ int handle_pte_fault(struct mm_struct *mm,
81721 if (flags & FAULT_FLAG_WRITE)
81722 flush_tlb_fix_spurious_fault(vma, address);
81723 }
81724 +
81725 +#ifdef CONFIG_PAX_SEGMEXEC
81726 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81727 + return 0;
81728 +#endif
81729 +
81730 unlock:
81731 pte_unmap_unlock(pte, ptl);
81732 return 0;
81733 @@ -3728,6 +3937,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81734 pmd_t *pmd;
81735 pte_t *pte;
81736
81737 +#ifdef CONFIG_PAX_SEGMEXEC
81738 + struct vm_area_struct *vma_m;
81739 +#endif
81740 +
81741 __set_current_state(TASK_RUNNING);
81742
81743 count_vm_event(PGFAULT);
81744 @@ -3739,6 +3952,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81745 if (unlikely(is_vm_hugetlb_page(vma)))
81746 return hugetlb_fault(mm, vma, address, flags);
81747
81748 +#ifdef CONFIG_PAX_SEGMEXEC
81749 + vma_m = pax_find_mirror_vma(vma);
81750 + if (vma_m) {
81751 + unsigned long address_m;
81752 + pgd_t *pgd_m;
81753 + pud_t *pud_m;
81754 + pmd_t *pmd_m;
81755 +
81756 + if (vma->vm_start > vma_m->vm_start) {
81757 + address_m = address;
81758 + address -= SEGMEXEC_TASK_SIZE;
81759 + vma = vma_m;
81760 + } else
81761 + address_m = address + SEGMEXEC_TASK_SIZE;
81762 +
81763 + pgd_m = pgd_offset(mm, address_m);
81764 + pud_m = pud_alloc(mm, pgd_m, address_m);
81765 + if (!pud_m)
81766 + return VM_FAULT_OOM;
81767 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81768 + if (!pmd_m)
81769 + return VM_FAULT_OOM;
81770 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81771 + return VM_FAULT_OOM;
81772 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81773 + }
81774 +#endif
81775 +
81776 retry:
81777 pgd = pgd_offset(mm, address);
81778 pud = pud_alloc(mm, pgd, address);
81779 @@ -3837,6 +4078,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81780 spin_unlock(&mm->page_table_lock);
81781 return 0;
81782 }
81783 +
81784 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81785 +{
81786 + pud_t *new = pud_alloc_one(mm, address);
81787 + if (!new)
81788 + return -ENOMEM;
81789 +
81790 + smp_wmb(); /* See comment in __pte_alloc */
81791 +
81792 + spin_lock(&mm->page_table_lock);
81793 + if (pgd_present(*pgd)) /* Another has populated it */
81794 + pud_free(mm, new);
81795 + else
81796 + pgd_populate_kernel(mm, pgd, new);
81797 + spin_unlock(&mm->page_table_lock);
81798 + return 0;
81799 +}
81800 #endif /* __PAGETABLE_PUD_FOLDED */
81801
81802 #ifndef __PAGETABLE_PMD_FOLDED
81803 @@ -3867,11 +4125,35 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81804 spin_unlock(&mm->page_table_lock);
81805 return 0;
81806 }
81807 +
81808 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81809 +{
81810 + pmd_t *new = pmd_alloc_one(mm, address);
81811 + if (!new)
81812 + return -ENOMEM;
81813 +
81814 + smp_wmb(); /* See comment in __pte_alloc */
81815 +
81816 + spin_lock(&mm->page_table_lock);
81817 +#ifndef __ARCH_HAS_4LEVEL_HACK
81818 + if (pud_present(*pud)) /* Another has populated it */
81819 + pmd_free(mm, new);
81820 + else
81821 + pud_populate_kernel(mm, pud, new);
81822 +#else
81823 + if (pgd_present(*pud)) /* Another has populated it */
81824 + pmd_free(mm, new);
81825 + else
81826 + pgd_populate_kernel(mm, pud, new);
81827 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81828 + spin_unlock(&mm->page_table_lock);
81829 + return 0;
81830 +}
81831 #endif /* __PAGETABLE_PMD_FOLDED */
81832
81833 -int make_pages_present(unsigned long addr, unsigned long end)
81834 +ssize_t make_pages_present(unsigned long addr, unsigned long end)
81835 {
81836 - int ret, len, write;
81837 + ssize_t ret, len, write;
81838 struct vm_area_struct * vma;
81839
81840 vma = find_vma(current->mm, addr);
81841 @@ -3904,7 +4186,7 @@ static int __init gate_vma_init(void)
81842 gate_vma.vm_start = FIXADDR_USER_START;
81843 gate_vma.vm_end = FIXADDR_USER_END;
81844 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81845 - gate_vma.vm_page_prot = __P101;
81846 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81847
81848 return 0;
81849 }
81850 @@ -4038,8 +4320,8 @@ out:
81851 return ret;
81852 }
81853
81854 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81855 - void *buf, int len, int write)
81856 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81857 + void *buf, size_t len, int write)
81858 {
81859 resource_size_t phys_addr;
81860 unsigned long prot = 0;
81861 @@ -4064,8 +4346,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81862 * Access another process' address space as given in mm. If non-NULL, use the
81863 * given task for page fault accounting.
81864 */
81865 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81866 - unsigned long addr, void *buf, int len, int write)
81867 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81868 + unsigned long addr, void *buf, size_t len, int write)
81869 {
81870 struct vm_area_struct *vma;
81871 void *old_buf = buf;
81872 @@ -4073,7 +4355,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81873 down_read(&mm->mmap_sem);
81874 /* ignore errors, just check how much was successfully transferred */
81875 while (len) {
81876 - int bytes, ret, offset;
81877 + ssize_t bytes, ret, offset;
81878 void *maddr;
81879 struct page *page = NULL;
81880
81881 @@ -4132,8 +4414,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81882 *
81883 * The caller must hold a reference on @mm.
81884 */
81885 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81886 - void *buf, int len, int write)
81887 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81888 + void *buf, size_t len, int write)
81889 {
81890 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81891 }
81892 @@ -4143,11 +4425,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81893 * Source/target buffer must be kernel space,
81894 * Do not walk the page table directly, use get_user_pages
81895 */
81896 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81897 - void *buf, int len, int write)
81898 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81899 + void *buf, size_t len, int write)
81900 {
81901 struct mm_struct *mm;
81902 - int ret;
81903 + ssize_t ret;
81904
81905 mm = get_task_mm(tsk);
81906 if (!mm)
81907 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81908 index 3df6d12..a11056a 100644
81909 --- a/mm/mempolicy.c
81910 +++ b/mm/mempolicy.c
81911 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81912 unsigned long vmstart;
81913 unsigned long vmend;
81914
81915 +#ifdef CONFIG_PAX_SEGMEXEC
81916 + struct vm_area_struct *vma_m;
81917 +#endif
81918 +
81919 vma = find_vma(mm, start);
81920 if (!vma || vma->vm_start > start)
81921 return -EFAULT;
81922 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81923 if (err)
81924 goto out;
81925 }
81926 +
81927 err = vma_replace_policy(vma, new_pol);
81928 if (err)
81929 goto out;
81930 +
81931 +#ifdef CONFIG_PAX_SEGMEXEC
81932 + vma_m = pax_find_mirror_vma(vma);
81933 + if (vma_m) {
81934 + err = vma_replace_policy(vma_m, new_pol);
81935 + if (err)
81936 + goto out;
81937 + }
81938 +#endif
81939 +
81940 }
81941
81942 out:
81943 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
81944
81945 if (end < start)
81946 return -EINVAL;
81947 +
81948 +#ifdef CONFIG_PAX_SEGMEXEC
81949 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81950 + if (end > SEGMEXEC_TASK_SIZE)
81951 + return -EINVAL;
81952 + } else
81953 +#endif
81954 +
81955 + if (end > TASK_SIZE)
81956 + return -EINVAL;
81957 +
81958 if (end == start)
81959 return 0;
81960
81961 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81962 */
81963 tcred = __task_cred(task);
81964 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81965 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81966 - !capable(CAP_SYS_NICE)) {
81967 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81968 rcu_read_unlock();
81969 err = -EPERM;
81970 goto out_put;
81971 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81972 goto out;
81973 }
81974
81975 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81976 + if (mm != current->mm &&
81977 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
81978 + mmput(mm);
81979 + err = -EPERM;
81980 + goto out;
81981 + }
81982 +#endif
81983 +
81984 err = do_migrate_pages(mm, old, new,
81985 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
81986
81987 diff --git a/mm/migrate.c b/mm/migrate.c
81988 index 2fd8b4a..d70358f 100644
81989 --- a/mm/migrate.c
81990 +++ b/mm/migrate.c
81991 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
81992 */
81993 tcred = __task_cred(task);
81994 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81995 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81996 - !capable(CAP_SYS_NICE)) {
81997 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81998 rcu_read_unlock();
81999 err = -EPERM;
82000 goto out;
82001 diff --git a/mm/mlock.c b/mm/mlock.c
82002 index c9bd528..da8d069 100644
82003 --- a/mm/mlock.c
82004 +++ b/mm/mlock.c
82005 @@ -13,6 +13,7 @@
82006 #include <linux/pagemap.h>
82007 #include <linux/mempolicy.h>
82008 #include <linux/syscalls.h>
82009 +#include <linux/security.h>
82010 #include <linux/sched.h>
82011 #include <linux/export.h>
82012 #include <linux/rmap.h>
82013 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82014 {
82015 unsigned long nstart, end, tmp;
82016 struct vm_area_struct * vma, * prev;
82017 - int error;
82018 + int error = 0;
82019
82020 VM_BUG_ON(start & ~PAGE_MASK);
82021 VM_BUG_ON(len != PAGE_ALIGN(len));
82022 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82023 return -EINVAL;
82024 if (end == start)
82025 return 0;
82026 + if (end > TASK_SIZE)
82027 + return -EINVAL;
82028 +
82029 vma = find_vma(current->mm, start);
82030 if (!vma || vma->vm_start > start)
82031 return -ENOMEM;
82032 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82033 for (nstart = start ; ; ) {
82034 vm_flags_t newflags;
82035
82036 +#ifdef CONFIG_PAX_SEGMEXEC
82037 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82038 + break;
82039 +#endif
82040 +
82041 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82042
82043 newflags = vma->vm_flags | VM_LOCKED;
82044 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82045 lock_limit >>= PAGE_SHIFT;
82046
82047 /* check against resource limits */
82048 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82049 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82050 error = do_mlock(start, len, 1);
82051 up_write(&current->mm->mmap_sem);
82052 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
82053 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82054 vm_flags_t newflags;
82055
82056 +#ifdef CONFIG_PAX_SEGMEXEC
82057 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82058 + break;
82059 +#endif
82060 +
82061 + BUG_ON(vma->vm_end > TASK_SIZE);
82062 newflags = vma->vm_flags | VM_LOCKED;
82063 if (!(flags & MCL_CURRENT))
82064 newflags &= ~VM_LOCKED;
82065 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82066 lock_limit >>= PAGE_SHIFT;
82067
82068 ret = -ENOMEM;
82069 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82070 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82071 capable(CAP_IPC_LOCK))
82072 ret = do_mlockall(flags);
82073 diff --git a/mm/mmap.c b/mm/mmap.c
82074 index 90db251..04240d1 100644
82075 --- a/mm/mmap.c
82076 +++ b/mm/mmap.c
82077 @@ -32,6 +32,7 @@
82078 #include <linux/khugepaged.h>
82079 #include <linux/uprobes.h>
82080 #include <linux/rbtree_augmented.h>
82081 +#include <linux/random.h>
82082
82083 #include <asm/uaccess.h>
82084 #include <asm/cacheflush.h>
82085 @@ -48,6 +49,16 @@
82086 #define arch_rebalance_pgtables(addr, len) (addr)
82087 #endif
82088
82089 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82090 +{
82091 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82092 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82093 + up_read(&mm->mmap_sem);
82094 + BUG();
82095 + }
82096 +#endif
82097 +}
82098 +
82099 static void unmap_region(struct mm_struct *mm,
82100 struct vm_area_struct *vma, struct vm_area_struct *prev,
82101 unsigned long start, unsigned long end);
82102 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
82103 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82104 *
82105 */
82106 -pgprot_t protection_map[16] = {
82107 +pgprot_t protection_map[16] __read_only = {
82108 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82109 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82110 };
82111
82112 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82113 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82114 {
82115 - return __pgprot(pgprot_val(protection_map[vm_flags &
82116 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82117 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82118 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82119 +
82120 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82121 + if (!(__supported_pte_mask & _PAGE_NX) &&
82122 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82123 + (vm_flags & (VM_READ | VM_WRITE)))
82124 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82125 +#endif
82126 +
82127 + return prot;
82128 }
82129 EXPORT_SYMBOL(vm_get_page_prot);
82130
82131 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
82132 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82133 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82134 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82135 /*
82136 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82137 * other variables. It can be updated by several CPUs frequently.
82138 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82139 struct vm_area_struct *next = vma->vm_next;
82140
82141 might_sleep();
82142 + BUG_ON(vma->vm_mirror);
82143 if (vma->vm_ops && vma->vm_ops->close)
82144 vma->vm_ops->close(vma);
82145 if (vma->vm_file)
82146 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82147 * not page aligned -Ram Gupta
82148 */
82149 rlim = rlimit(RLIMIT_DATA);
82150 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82151 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82152 (mm->end_data - mm->start_data) > rlim)
82153 goto out;
82154 @@ -888,6 +911,12 @@ static int
82155 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82156 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82157 {
82158 +
82159 +#ifdef CONFIG_PAX_SEGMEXEC
82160 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82161 + return 0;
82162 +#endif
82163 +
82164 if (is_mergeable_vma(vma, file, vm_flags) &&
82165 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82166 if (vma->vm_pgoff == vm_pgoff)
82167 @@ -907,6 +936,12 @@ static int
82168 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82169 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82170 {
82171 +
82172 +#ifdef CONFIG_PAX_SEGMEXEC
82173 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82174 + return 0;
82175 +#endif
82176 +
82177 if (is_mergeable_vma(vma, file, vm_flags) &&
82178 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82179 pgoff_t vm_pglen;
82180 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82181 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82182 struct vm_area_struct *prev, unsigned long addr,
82183 unsigned long end, unsigned long vm_flags,
82184 - struct anon_vma *anon_vma, struct file *file,
82185 + struct anon_vma *anon_vma, struct file *file,
82186 pgoff_t pgoff, struct mempolicy *policy)
82187 {
82188 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82189 struct vm_area_struct *area, *next;
82190 int err;
82191
82192 +#ifdef CONFIG_PAX_SEGMEXEC
82193 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82194 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82195 +
82196 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82197 +#endif
82198 +
82199 /*
82200 * We later require that vma->vm_flags == vm_flags,
82201 * so this tests vma->vm_flags & VM_SPECIAL, too.
82202 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82203 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82204 next = next->vm_next;
82205
82206 +#ifdef CONFIG_PAX_SEGMEXEC
82207 + if (prev)
82208 + prev_m = pax_find_mirror_vma(prev);
82209 + if (area)
82210 + area_m = pax_find_mirror_vma(area);
82211 + if (next)
82212 + next_m = pax_find_mirror_vma(next);
82213 +#endif
82214 +
82215 /*
82216 * Can it merge with the predecessor?
82217 */
82218 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82219 /* cases 1, 6 */
82220 err = vma_adjust(prev, prev->vm_start,
82221 next->vm_end, prev->vm_pgoff, NULL);
82222 - } else /* cases 2, 5, 7 */
82223 +
82224 +#ifdef CONFIG_PAX_SEGMEXEC
82225 + if (!err && prev_m)
82226 + err = vma_adjust(prev_m, prev_m->vm_start,
82227 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82228 +#endif
82229 +
82230 + } else { /* cases 2, 5, 7 */
82231 err = vma_adjust(prev, prev->vm_start,
82232 end, prev->vm_pgoff, NULL);
82233 +
82234 +#ifdef CONFIG_PAX_SEGMEXEC
82235 + if (!err && prev_m)
82236 + err = vma_adjust(prev_m, prev_m->vm_start,
82237 + end_m, prev_m->vm_pgoff, NULL);
82238 +#endif
82239 +
82240 + }
82241 if (err)
82242 return NULL;
82243 khugepaged_enter_vma_merge(prev);
82244 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82245 mpol_equal(policy, vma_policy(next)) &&
82246 can_vma_merge_before(next, vm_flags,
82247 anon_vma, file, pgoff+pglen)) {
82248 - if (prev && addr < prev->vm_end) /* case 4 */
82249 + if (prev && addr < prev->vm_end) { /* case 4 */
82250 err = vma_adjust(prev, prev->vm_start,
82251 addr, prev->vm_pgoff, NULL);
82252 - else /* cases 3, 8 */
82253 +
82254 +#ifdef CONFIG_PAX_SEGMEXEC
82255 + if (!err && prev_m)
82256 + err = vma_adjust(prev_m, prev_m->vm_start,
82257 + addr_m, prev_m->vm_pgoff, NULL);
82258 +#endif
82259 +
82260 + } else { /* cases 3, 8 */
82261 err = vma_adjust(area, addr, next->vm_end,
82262 next->vm_pgoff - pglen, NULL);
82263 +
82264 +#ifdef CONFIG_PAX_SEGMEXEC
82265 + if (!err && area_m)
82266 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82267 + next_m->vm_pgoff - pglen, NULL);
82268 +#endif
82269 +
82270 + }
82271 if (err)
82272 return NULL;
82273 khugepaged_enter_vma_merge(area);
82274 @@ -1120,8 +1201,10 @@ none:
82275 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82276 struct file *file, long pages)
82277 {
82278 - const unsigned long stack_flags
82279 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82280 +
82281 +#ifdef CONFIG_PAX_RANDMMAP
82282 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82283 +#endif
82284
82285 mm->total_vm += pages;
82286
82287 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82288 mm->shared_vm += pages;
82289 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82290 mm->exec_vm += pages;
82291 - } else if (flags & stack_flags)
82292 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82293 mm->stack_vm += pages;
82294 }
82295 #endif /* CONFIG_PROC_FS */
82296 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82297 * (the exception is when the underlying filesystem is noexec
82298 * mounted, in which case we dont add PROT_EXEC.)
82299 */
82300 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82301 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82302 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82303 prot |= PROT_EXEC;
82304
82305 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82306 /* Obtain the address to map to. we verify (or select) it and ensure
82307 * that it represents a valid section of the address space.
82308 */
82309 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82310 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82311 if (addr & ~PAGE_MASK)
82312 return addr;
82313
82314 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82315 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82316 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82317
82318 +#ifdef CONFIG_PAX_MPROTECT
82319 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82320 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82321 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82322 + gr_log_rwxmmap(file);
82323 +
82324 +#ifdef CONFIG_PAX_EMUPLT
82325 + vm_flags &= ~VM_EXEC;
82326 +#else
82327 + return -EPERM;
82328 +#endif
82329 +
82330 + }
82331 +
82332 + if (!(vm_flags & VM_EXEC))
82333 + vm_flags &= ~VM_MAYEXEC;
82334 +#else
82335 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82336 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82337 +#endif
82338 + else
82339 + vm_flags &= ~VM_MAYWRITE;
82340 + }
82341 +#endif
82342 +
82343 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82344 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82345 + vm_flags &= ~VM_PAGEEXEC;
82346 +#endif
82347 +
82348 if (flags & MAP_LOCKED)
82349 if (!can_do_mlock())
82350 return -EPERM;
82351 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82352 locked += mm->locked_vm;
82353 lock_limit = rlimit(RLIMIT_MEMLOCK);
82354 lock_limit >>= PAGE_SHIFT;
82355 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82356 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82357 return -EAGAIN;
82358 }
82359 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82360 }
82361 }
82362
82363 + if (!gr_acl_handle_mmap(file, prot))
82364 + return -EACCES;
82365 +
82366 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
82367 }
82368
82369 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82370 vm_flags_t vm_flags = vma->vm_flags;
82371
82372 /* If it was private or non-writable, the write bit is already clear */
82373 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82374 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82375 return 0;
82376
82377 /* The backer wishes to know when pages are first written to? */
82378 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82379 unsigned long charged = 0;
82380 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
82381
82382 +#ifdef CONFIG_PAX_SEGMEXEC
82383 + struct vm_area_struct *vma_m = NULL;
82384 +#endif
82385 +
82386 + /*
82387 + * mm->mmap_sem is required to protect against another thread
82388 + * changing the mappings in case we sleep.
82389 + */
82390 + verify_mm_writelocked(mm);
82391 +
82392 /* Clear old maps */
82393 error = -ENOMEM;
82394 -munmap_back:
82395 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82396 if (do_munmap(mm, addr, len))
82397 return -ENOMEM;
82398 - goto munmap_back;
82399 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82400 }
82401
82402 /* Check against address space limit. */
82403 +
82404 +#ifdef CONFIG_PAX_RANDMMAP
82405 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82406 +#endif
82407 +
82408 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82409 return -ENOMEM;
82410
82411 @@ -1460,6 +1591,16 @@ munmap_back:
82412 goto unacct_error;
82413 }
82414
82415 +#ifdef CONFIG_PAX_SEGMEXEC
82416 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82417 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82418 + if (!vma_m) {
82419 + error = -ENOMEM;
82420 + goto free_vma;
82421 + }
82422 + }
82423 +#endif
82424 +
82425 vma->vm_mm = mm;
82426 vma->vm_start = addr;
82427 vma->vm_end = addr + len;
82428 @@ -1484,6 +1625,13 @@ munmap_back:
82429 if (error)
82430 goto unmap_and_free_vma;
82431
82432 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82433 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82434 + vma->vm_flags |= VM_PAGEEXEC;
82435 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82436 + }
82437 +#endif
82438 +
82439 /* Can addr have changed??
82440 *
82441 * Answer: Yes, several device drivers can do it in their
82442 @@ -1522,6 +1670,11 @@ munmap_back:
82443 vma_link(mm, vma, prev, rb_link, rb_parent);
82444 file = vma->vm_file;
82445
82446 +#ifdef CONFIG_PAX_SEGMEXEC
82447 + if (vma_m)
82448 + BUG_ON(pax_mirror_vma(vma_m, vma));
82449 +#endif
82450 +
82451 /* Once vma denies write, undo our temporary denial count */
82452 if (correct_wcount)
82453 atomic_inc(&inode->i_writecount);
82454 @@ -1529,6 +1682,7 @@ out:
82455 perf_event_mmap(vma);
82456
82457 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82458 + track_exec_limit(mm, addr, addr + len, vm_flags);
82459 if (vm_flags & VM_LOCKED) {
82460 if (!mlock_vma_pages_range(vma, addr, addr + len))
82461 mm->locked_vm += (len >> PAGE_SHIFT);
82462 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
82463 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82464 charged = 0;
82465 free_vma:
82466 +
82467 +#ifdef CONFIG_PAX_SEGMEXEC
82468 + if (vma_m)
82469 + kmem_cache_free(vm_area_cachep, vma_m);
82470 +#endif
82471 +
82472 kmem_cache_free(vm_area_cachep, vma);
82473 unacct_error:
82474 if (charged)
82475 @@ -1557,6 +1717,62 @@ unacct_error:
82476 return error;
82477 }
82478
82479 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82480 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82481 +{
82482 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82483 + return (random32() & 0xFF) << PAGE_SHIFT;
82484 +
82485 + return 0;
82486 +}
82487 +#endif
82488 +
82489 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82490 +{
82491 + if (!vma) {
82492 +#ifdef CONFIG_STACK_GROWSUP
82493 + if (addr > sysctl_heap_stack_gap)
82494 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82495 + else
82496 + vma = find_vma(current->mm, 0);
82497 + if (vma && (vma->vm_flags & VM_GROWSUP))
82498 + return false;
82499 +#endif
82500 + return true;
82501 + }
82502 +
82503 + if (addr + len > vma->vm_start)
82504 + return false;
82505 +
82506 + if (vma->vm_flags & VM_GROWSDOWN)
82507 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82508 +#ifdef CONFIG_STACK_GROWSUP
82509 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82510 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82511 +#endif
82512 + else if (offset)
82513 + return offset <= vma->vm_start - addr - len;
82514 +
82515 + return true;
82516 +}
82517 +
82518 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82519 +{
82520 + if (vma->vm_start < len)
82521 + return -ENOMEM;
82522 +
82523 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82524 + if (offset <= vma->vm_start - len)
82525 + return vma->vm_start - len - offset;
82526 + else
82527 + return -ENOMEM;
82528 + }
82529 +
82530 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82531 + return vma->vm_start - len - sysctl_heap_stack_gap;
82532 + return -ENOMEM;
82533 +}
82534 +
82535 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82536 {
82537 /*
82538 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82539 struct mm_struct *mm = current->mm;
82540 struct vm_area_struct *vma;
82541 struct vm_unmapped_area_info info;
82542 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82543
82544 if (len > TASK_SIZE)
82545 return -ENOMEM;
82546 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82547 if (flags & MAP_FIXED)
82548 return addr;
82549
82550 +#ifdef CONFIG_PAX_RANDMMAP
82551 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82552 +#endif
82553 +
82554 if (addr) {
82555 addr = PAGE_ALIGN(addr);
82556 vma = find_vma(mm, addr);
82557 - if (TASK_SIZE - len >= addr &&
82558 - (!vma || addr + len <= vma->vm_start))
82559 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82560 return addr;
82561 }
82562
82563 info.flags = 0;
82564 info.length = len;
82565 info.low_limit = TASK_UNMAPPED_BASE;
82566 +
82567 +#ifdef CONFIG_PAX_RANDMMAP
82568 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82569 + info.low_limit += mm->delta_mmap;
82570 +#endif
82571 +
82572 info.high_limit = TASK_SIZE;
82573 info.align_mask = 0;
82574 return vm_unmapped_area(&info);
82575 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82576
82577 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82578 {
82579 +
82580 +#ifdef CONFIG_PAX_SEGMEXEC
82581 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82582 + return;
82583 +#endif
82584 +
82585 /*
82586 * Is this a new hole at the lowest possible address?
82587 */
82588 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82589 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82590 mm->free_area_cache = addr;
82591 }
82592
82593 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82594 struct mm_struct *mm = current->mm;
82595 unsigned long addr = addr0;
82596 struct vm_unmapped_area_info info;
82597 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82598
82599 /* requested length too big for entire address space */
82600 if (len > TASK_SIZE)
82601 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82602 if (flags & MAP_FIXED)
82603 return addr;
82604
82605 +#ifdef CONFIG_PAX_RANDMMAP
82606 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82607 +#endif
82608 +
82609 /* requesting a specific address */
82610 if (addr) {
82611 addr = PAGE_ALIGN(addr);
82612 vma = find_vma(mm, addr);
82613 - if (TASK_SIZE - len >= addr &&
82614 - (!vma || addr + len <= vma->vm_start))
82615 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82616 return addr;
82617 }
82618
82619 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82620 VM_BUG_ON(addr != -ENOMEM);
82621 info.flags = 0;
82622 info.low_limit = TASK_UNMAPPED_BASE;
82623 +
82624 +#ifdef CONFIG_PAX_RANDMMAP
82625 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82626 + info.low_limit += mm->delta_mmap;
82627 +#endif
82628 +
82629 info.high_limit = TASK_SIZE;
82630 addr = vm_unmapped_area(&info);
82631 }
82632 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82633
82634 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82635 {
82636 +
82637 +#ifdef CONFIG_PAX_SEGMEXEC
82638 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82639 + return;
82640 +#endif
82641 +
82642 /*
82643 * Is this a new hole at the highest possible address?
82644 */
82645 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82646 mm->free_area_cache = addr;
82647
82648 /* dont allow allocations above current base */
82649 - if (mm->free_area_cache > mm->mmap_base)
82650 + if (mm->free_area_cache > mm->mmap_base) {
82651 mm->free_area_cache = mm->mmap_base;
82652 + mm->cached_hole_size = ~0UL;
82653 + }
82654 }
82655
82656 unsigned long
82657 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82658 return vma;
82659 }
82660
82661 +#ifdef CONFIG_PAX_SEGMEXEC
82662 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82663 +{
82664 + struct vm_area_struct *vma_m;
82665 +
82666 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82667 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82668 + BUG_ON(vma->vm_mirror);
82669 + return NULL;
82670 + }
82671 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82672 + vma_m = vma->vm_mirror;
82673 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82674 + BUG_ON(vma->vm_file != vma_m->vm_file);
82675 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82676 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82677 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82678 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82679 + return vma_m;
82680 +}
82681 +#endif
82682 +
82683 /*
82684 * Verify that the stack growth is acceptable and
82685 * update accounting. This is shared with both the
82686 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82687 return -ENOMEM;
82688
82689 /* Stack limit test */
82690 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82691 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82692 return -ENOMEM;
82693
82694 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82695 locked = mm->locked_vm + grow;
82696 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82697 limit >>= PAGE_SHIFT;
82698 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82699 if (locked > limit && !capable(CAP_IPC_LOCK))
82700 return -ENOMEM;
82701 }
82702 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82703 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82704 * vma is the last one with address > vma->vm_end. Have to extend vma.
82705 */
82706 +#ifndef CONFIG_IA64
82707 +static
82708 +#endif
82709 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82710 {
82711 int error;
82712 + bool locknext;
82713
82714 if (!(vma->vm_flags & VM_GROWSUP))
82715 return -EFAULT;
82716
82717 + /* Also guard against wrapping around to address 0. */
82718 + if (address < PAGE_ALIGN(address+1))
82719 + address = PAGE_ALIGN(address+1);
82720 + else
82721 + return -ENOMEM;
82722 +
82723 /*
82724 * We must make sure the anon_vma is allocated
82725 * so that the anon_vma locking is not a noop.
82726 */
82727 if (unlikely(anon_vma_prepare(vma)))
82728 return -ENOMEM;
82729 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82730 + if (locknext && anon_vma_prepare(vma->vm_next))
82731 + return -ENOMEM;
82732 vma_lock_anon_vma(vma);
82733 + if (locknext)
82734 + vma_lock_anon_vma(vma->vm_next);
82735
82736 /*
82737 * vma->vm_start/vm_end cannot change under us because the caller
82738 * is required to hold the mmap_sem in read mode. We need the
82739 - * anon_vma lock to serialize against concurrent expand_stacks.
82740 - * Also guard against wrapping around to address 0.
82741 + * anon_vma locks to serialize against concurrent expand_stacks
82742 + * and expand_upwards.
82743 */
82744 - if (address < PAGE_ALIGN(address+4))
82745 - address = PAGE_ALIGN(address+4);
82746 - else {
82747 - vma_unlock_anon_vma(vma);
82748 - return -ENOMEM;
82749 - }
82750 error = 0;
82751
82752 /* Somebody else might have raced and expanded it already */
82753 - if (address > vma->vm_end) {
82754 + 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)
82755 + error = -ENOMEM;
82756 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82757 unsigned long size, grow;
82758
82759 size = address - vma->vm_start;
82760 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82761 }
82762 }
82763 }
82764 + if (locknext)
82765 + vma_unlock_anon_vma(vma->vm_next);
82766 vma_unlock_anon_vma(vma);
82767 khugepaged_enter_vma_merge(vma);
82768 validate_mm(vma->vm_mm);
82769 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
82770 unsigned long address)
82771 {
82772 int error;
82773 + bool lockprev = false;
82774 + struct vm_area_struct *prev;
82775
82776 /*
82777 * We must make sure the anon_vma is allocated
82778 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
82779 if (error)
82780 return error;
82781
82782 + prev = vma->vm_prev;
82783 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82784 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82785 +#endif
82786 + if (lockprev && anon_vma_prepare(prev))
82787 + return -ENOMEM;
82788 + if (lockprev)
82789 + vma_lock_anon_vma(prev);
82790 +
82791 vma_lock_anon_vma(vma);
82792
82793 /*
82794 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
82795 */
82796
82797 /* Somebody else might have raced and expanded it already */
82798 - if (address < vma->vm_start) {
82799 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82800 + error = -ENOMEM;
82801 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82802 unsigned long size, grow;
82803
82804 +#ifdef CONFIG_PAX_SEGMEXEC
82805 + struct vm_area_struct *vma_m;
82806 +
82807 + vma_m = pax_find_mirror_vma(vma);
82808 +#endif
82809 +
82810 size = vma->vm_end - address;
82811 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82812
82813 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
82814 vma->vm_pgoff -= grow;
82815 anon_vma_interval_tree_post_update_vma(vma);
82816 vma_gap_update(vma);
82817 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82818 +
82819 +#ifdef CONFIG_PAX_SEGMEXEC
82820 + if (vma_m) {
82821 + anon_vma_interval_tree_pre_update_vma(vma_m);
82822 + vma_m->vm_start -= grow << PAGE_SHIFT;
82823 + vma_m->vm_pgoff -= grow;
82824 + anon_vma_interval_tree_post_update_vma(vma_m);
82825 + vma_gap_update(vma_m);
82826 + }
82827 +#endif
82828 +
82829 spin_unlock(&vma->vm_mm->page_table_lock);
82830
82831 perf_event_mmap(vma);
82832 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82833 do {
82834 long nrpages = vma_pages(vma);
82835
82836 +#ifdef CONFIG_PAX_SEGMEXEC
82837 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82838 + vma = remove_vma(vma);
82839 + continue;
82840 + }
82841 +#endif
82842 +
82843 if (vma->vm_flags & VM_ACCOUNT)
82844 nr_accounted += nrpages;
82845 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82846 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82847 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82848 vma->vm_prev = NULL;
82849 do {
82850 +
82851 +#ifdef CONFIG_PAX_SEGMEXEC
82852 + if (vma->vm_mirror) {
82853 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82854 + vma->vm_mirror->vm_mirror = NULL;
82855 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82856 + vma->vm_mirror = NULL;
82857 + }
82858 +#endif
82859 +
82860 vma_rb_erase(vma, &mm->mm_rb);
82861 mm->map_count--;
82862 tail_vma = vma;
82863 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82864 struct vm_area_struct *new;
82865 int err = -ENOMEM;
82866
82867 +#ifdef CONFIG_PAX_SEGMEXEC
82868 + struct vm_area_struct *vma_m, *new_m = NULL;
82869 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82870 +#endif
82871 +
82872 if (is_vm_hugetlb_page(vma) && (addr &
82873 ~(huge_page_mask(hstate_vma(vma)))))
82874 return -EINVAL;
82875
82876 +#ifdef CONFIG_PAX_SEGMEXEC
82877 + vma_m = pax_find_mirror_vma(vma);
82878 +#endif
82879 +
82880 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82881 if (!new)
82882 goto out_err;
82883
82884 +#ifdef CONFIG_PAX_SEGMEXEC
82885 + if (vma_m) {
82886 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82887 + if (!new_m) {
82888 + kmem_cache_free(vm_area_cachep, new);
82889 + goto out_err;
82890 + }
82891 + }
82892 +#endif
82893 +
82894 /* most fields are the same, copy all, and then fixup */
82895 *new = *vma;
82896
82897 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82898 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82899 }
82900
82901 +#ifdef CONFIG_PAX_SEGMEXEC
82902 + if (vma_m) {
82903 + *new_m = *vma_m;
82904 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82905 + new_m->vm_mirror = new;
82906 + new->vm_mirror = new_m;
82907 +
82908 + if (new_below)
82909 + new_m->vm_end = addr_m;
82910 + else {
82911 + new_m->vm_start = addr_m;
82912 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82913 + }
82914 + }
82915 +#endif
82916 +
82917 pol = mpol_dup(vma_policy(vma));
82918 if (IS_ERR(pol)) {
82919 err = PTR_ERR(pol);
82920 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82921 else
82922 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
82923
82924 +#ifdef CONFIG_PAX_SEGMEXEC
82925 + if (!err && vma_m) {
82926 + if (anon_vma_clone(new_m, vma_m))
82927 + goto out_free_mpol;
82928 +
82929 + mpol_get(pol);
82930 + vma_set_policy(new_m, pol);
82931 +
82932 + if (new_m->vm_file)
82933 + get_file(new_m->vm_file);
82934 +
82935 + if (new_m->vm_ops && new_m->vm_ops->open)
82936 + new_m->vm_ops->open(new_m);
82937 +
82938 + if (new_below)
82939 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
82940 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
82941 + else
82942 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
82943 +
82944 + if (err) {
82945 + if (new_m->vm_ops && new_m->vm_ops->close)
82946 + new_m->vm_ops->close(new_m);
82947 + if (new_m->vm_file)
82948 + fput(new_m->vm_file);
82949 + mpol_put(pol);
82950 + }
82951 + }
82952 +#endif
82953 +
82954 /* Success. */
82955 if (!err)
82956 return 0;
82957 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82958 new->vm_ops->close(new);
82959 if (new->vm_file)
82960 fput(new->vm_file);
82961 - unlink_anon_vmas(new);
82962 out_free_mpol:
82963 mpol_put(pol);
82964 out_free_vma:
82965 +
82966 +#ifdef CONFIG_PAX_SEGMEXEC
82967 + if (new_m) {
82968 + unlink_anon_vmas(new_m);
82969 + kmem_cache_free(vm_area_cachep, new_m);
82970 + }
82971 +#endif
82972 +
82973 + unlink_anon_vmas(new);
82974 kmem_cache_free(vm_area_cachep, new);
82975 out_err:
82976 return err;
82977 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82978 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82979 unsigned long addr, int new_below)
82980 {
82981 +
82982 +#ifdef CONFIG_PAX_SEGMEXEC
82983 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82984 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82985 + if (mm->map_count >= sysctl_max_map_count-1)
82986 + return -ENOMEM;
82987 + } else
82988 +#endif
82989 +
82990 if (mm->map_count >= sysctl_max_map_count)
82991 return -ENOMEM;
82992
82993 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82994 * work. This now handles partial unmappings.
82995 * Jeremy Fitzhardinge <jeremy@goop.org>
82996 */
82997 +#ifdef CONFIG_PAX_SEGMEXEC
82998 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82999 {
83000 + int ret = __do_munmap(mm, start, len);
83001 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
83002 + return ret;
83003 +
83004 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
83005 +}
83006 +
83007 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83008 +#else
83009 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83010 +#endif
83011 +{
83012 unsigned long end;
83013 struct vm_area_struct *vma, *prev, *last;
83014
83015 + /*
83016 + * mm->mmap_sem is required to protect against another thread
83017 + * changing the mappings in case we sleep.
83018 + */
83019 + verify_mm_writelocked(mm);
83020 +
83021 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83022 return -EINVAL;
83023
83024 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83025 /* Fix up all other VM information */
83026 remove_vma_list(mm, vma);
83027
83028 + track_exec_limit(mm, start, end, 0UL);
83029 +
83030 return 0;
83031 }
83032
83033 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
83034 int ret;
83035 struct mm_struct *mm = current->mm;
83036
83037 +
83038 +#ifdef CONFIG_PAX_SEGMEXEC
83039 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83040 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83041 + return -EINVAL;
83042 +#endif
83043 +
83044 down_write(&mm->mmap_sem);
83045 ret = do_munmap(mm, start, len);
83046 up_write(&mm->mmap_sem);
83047 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83048 return vm_munmap(addr, len);
83049 }
83050
83051 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83052 -{
83053 -#ifdef CONFIG_DEBUG_VM
83054 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83055 - WARN_ON(1);
83056 - up_read(&mm->mmap_sem);
83057 - }
83058 -#endif
83059 -}
83060 -
83061 /*
83062 * this is really a simplified "do_mmap". it only handles
83063 * anonymous maps. eventually we may be able to do some
83064 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83065 struct rb_node ** rb_link, * rb_parent;
83066 pgoff_t pgoff = addr >> PAGE_SHIFT;
83067 int error;
83068 + unsigned long charged;
83069
83070 len = PAGE_ALIGN(len);
83071 if (!len)
83072 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83073
83074 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83075
83076 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83077 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83078 + flags &= ~VM_EXEC;
83079 +
83080 +#ifdef CONFIG_PAX_MPROTECT
83081 + if (mm->pax_flags & MF_PAX_MPROTECT)
83082 + flags &= ~VM_MAYEXEC;
83083 +#endif
83084 +
83085 + }
83086 +#endif
83087 +
83088 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83089 if (error & ~PAGE_MASK)
83090 return error;
83091
83092 + charged = len >> PAGE_SHIFT;
83093 +
83094 /*
83095 * mlock MCL_FUTURE?
83096 */
83097 if (mm->def_flags & VM_LOCKED) {
83098 unsigned long locked, lock_limit;
83099 - locked = len >> PAGE_SHIFT;
83100 + locked = charged;
83101 locked += mm->locked_vm;
83102 lock_limit = rlimit(RLIMIT_MEMLOCK);
83103 lock_limit >>= PAGE_SHIFT;
83104 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83105 /*
83106 * Clear old maps. this also does some error checking for us
83107 */
83108 - munmap_back:
83109 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83110 if (do_munmap(mm, addr, len))
83111 return -ENOMEM;
83112 - goto munmap_back;
83113 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83114 }
83115
83116 /* Check against address space limits *after* clearing old maps... */
83117 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83118 + if (!may_expand_vm(mm, charged))
83119 return -ENOMEM;
83120
83121 if (mm->map_count > sysctl_max_map_count)
83122 return -ENOMEM;
83123
83124 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83125 + if (security_vm_enough_memory_mm(mm, charged))
83126 return -ENOMEM;
83127
83128 /* Can we just expand an old private anonymous mapping? */
83129 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83130 */
83131 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83132 if (!vma) {
83133 - vm_unacct_memory(len >> PAGE_SHIFT);
83134 + vm_unacct_memory(charged);
83135 return -ENOMEM;
83136 }
83137
83138 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83139 vma_link(mm, vma, prev, rb_link, rb_parent);
83140 out:
83141 perf_event_mmap(vma);
83142 - mm->total_vm += len >> PAGE_SHIFT;
83143 + mm->total_vm += charged;
83144 if (flags & VM_LOCKED) {
83145 if (!mlock_vma_pages_range(vma, addr, addr + len))
83146 - mm->locked_vm += (len >> PAGE_SHIFT);
83147 + mm->locked_vm += charged;
83148 }
83149 + track_exec_limit(mm, addr, addr + len, flags);
83150 return addr;
83151 }
83152
83153 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
83154 while (vma) {
83155 if (vma->vm_flags & VM_ACCOUNT)
83156 nr_accounted += vma_pages(vma);
83157 + vma->vm_mirror = NULL;
83158 vma = remove_vma(vma);
83159 }
83160 vm_unacct_memory(nr_accounted);
83161 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83162 struct vm_area_struct *prev;
83163 struct rb_node **rb_link, *rb_parent;
83164
83165 +#ifdef CONFIG_PAX_SEGMEXEC
83166 + struct vm_area_struct *vma_m = NULL;
83167 +#endif
83168 +
83169 + if (security_mmap_addr(vma->vm_start))
83170 + return -EPERM;
83171 +
83172 /*
83173 * The vm_pgoff of a purely anonymous vma should be irrelevant
83174 * until its first write fault, when page's anon_vma and index
83175 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83176 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83177 return -ENOMEM;
83178
83179 +#ifdef CONFIG_PAX_SEGMEXEC
83180 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83181 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83182 + if (!vma_m)
83183 + return -ENOMEM;
83184 + }
83185 +#endif
83186 +
83187 vma_link(mm, vma, prev, rb_link, rb_parent);
83188 +
83189 +#ifdef CONFIG_PAX_SEGMEXEC
83190 + if (vma_m)
83191 + BUG_ON(pax_mirror_vma(vma_m, vma));
83192 +#endif
83193 +
83194 return 0;
83195 }
83196
83197 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83198 struct mempolicy *pol;
83199 bool faulted_in_anon_vma = true;
83200
83201 + BUG_ON(vma->vm_mirror);
83202 +
83203 /*
83204 * If anonymous vma has not yet been faulted, update new pgoff
83205 * to match new location, to increase its chance of merging.
83206 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83207 return NULL;
83208 }
83209
83210 +#ifdef CONFIG_PAX_SEGMEXEC
83211 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83212 +{
83213 + struct vm_area_struct *prev_m;
83214 + struct rb_node **rb_link_m, *rb_parent_m;
83215 + struct mempolicy *pol_m;
83216 +
83217 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83218 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83219 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83220 + *vma_m = *vma;
83221 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83222 + if (anon_vma_clone(vma_m, vma))
83223 + return -ENOMEM;
83224 + pol_m = vma_policy(vma_m);
83225 + mpol_get(pol_m);
83226 + vma_set_policy(vma_m, pol_m);
83227 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83228 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83229 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83230 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83231 + if (vma_m->vm_file)
83232 + get_file(vma_m->vm_file);
83233 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83234 + vma_m->vm_ops->open(vma_m);
83235 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83236 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83237 + vma_m->vm_mirror = vma;
83238 + vma->vm_mirror = vma_m;
83239 + return 0;
83240 +}
83241 +#endif
83242 +
83243 /*
83244 * Return true if the calling process may expand its vm space by the passed
83245 * number of pages
83246 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83247
83248 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83249
83250 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83251 if (cur + npages > lim)
83252 return 0;
83253 return 1;
83254 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
83255 vma->vm_start = addr;
83256 vma->vm_end = addr + len;
83257
83258 +#ifdef CONFIG_PAX_MPROTECT
83259 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83260 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83261 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83262 + return -EPERM;
83263 + if (!(vm_flags & VM_EXEC))
83264 + vm_flags &= ~VM_MAYEXEC;
83265 +#else
83266 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83267 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83268 +#endif
83269 + else
83270 + vm_flags &= ~VM_MAYWRITE;
83271 + }
83272 +#endif
83273 +
83274 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83275 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83276
83277 diff --git a/mm/mprotect.c b/mm/mprotect.c
83278 index 94722a4..9837984 100644
83279 --- a/mm/mprotect.c
83280 +++ b/mm/mprotect.c
83281 @@ -23,10 +23,17 @@
83282 #include <linux/mmu_notifier.h>
83283 #include <linux/migrate.h>
83284 #include <linux/perf_event.h>
83285 +
83286 +#ifdef CONFIG_PAX_MPROTECT
83287 +#include <linux/elf.h>
83288 +#include <linux/binfmts.h>
83289 +#endif
83290 +
83291 #include <asm/uaccess.h>
83292 #include <asm/pgtable.h>
83293 #include <asm/cacheflush.h>
83294 #include <asm/tlbflush.h>
83295 +#include <asm/mmu_context.h>
83296
83297 #ifndef pgprot_modify
83298 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83299 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83300 return pages;
83301 }
83302
83303 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83304 +/* called while holding the mmap semaphor for writing except stack expansion */
83305 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83306 +{
83307 + unsigned long oldlimit, newlimit = 0UL;
83308 +
83309 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83310 + return;
83311 +
83312 + spin_lock(&mm->page_table_lock);
83313 + oldlimit = mm->context.user_cs_limit;
83314 + if ((prot & VM_EXEC) && oldlimit < end)
83315 + /* USER_CS limit moved up */
83316 + newlimit = end;
83317 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83318 + /* USER_CS limit moved down */
83319 + newlimit = start;
83320 +
83321 + if (newlimit) {
83322 + mm->context.user_cs_limit = newlimit;
83323 +
83324 +#ifdef CONFIG_SMP
83325 + wmb();
83326 + cpus_clear(mm->context.cpu_user_cs_mask);
83327 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83328 +#endif
83329 +
83330 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83331 + }
83332 + spin_unlock(&mm->page_table_lock);
83333 + if (newlimit == end) {
83334 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83335 +
83336 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83337 + if (is_vm_hugetlb_page(vma))
83338 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83339 + else
83340 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83341 + }
83342 +}
83343 +#endif
83344 +
83345 int
83346 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83347 unsigned long start, unsigned long end, unsigned long newflags)
83348 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83349 int error;
83350 int dirty_accountable = 0;
83351
83352 +#ifdef CONFIG_PAX_SEGMEXEC
83353 + struct vm_area_struct *vma_m = NULL;
83354 + unsigned long start_m, end_m;
83355 +
83356 + start_m = start + SEGMEXEC_TASK_SIZE;
83357 + end_m = end + SEGMEXEC_TASK_SIZE;
83358 +#endif
83359 +
83360 if (newflags == oldflags) {
83361 *pprev = vma;
83362 return 0;
83363 }
83364
83365 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83366 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83367 +
83368 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83369 + return -ENOMEM;
83370 +
83371 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83372 + return -ENOMEM;
83373 + }
83374 +
83375 /*
83376 * If we make a private mapping writable we increase our commit;
83377 * but (without finer accounting) cannot reduce our commit if we
83378 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83379 }
83380 }
83381
83382 +#ifdef CONFIG_PAX_SEGMEXEC
83383 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83384 + if (start != vma->vm_start) {
83385 + error = split_vma(mm, vma, start, 1);
83386 + if (error)
83387 + goto fail;
83388 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83389 + *pprev = (*pprev)->vm_next;
83390 + }
83391 +
83392 + if (end != vma->vm_end) {
83393 + error = split_vma(mm, vma, end, 0);
83394 + if (error)
83395 + goto fail;
83396 + }
83397 +
83398 + if (pax_find_mirror_vma(vma)) {
83399 + error = __do_munmap(mm, start_m, end_m - start_m);
83400 + if (error)
83401 + goto fail;
83402 + } else {
83403 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83404 + if (!vma_m) {
83405 + error = -ENOMEM;
83406 + goto fail;
83407 + }
83408 + vma->vm_flags = newflags;
83409 + error = pax_mirror_vma(vma_m, vma);
83410 + if (error) {
83411 + vma->vm_flags = oldflags;
83412 + goto fail;
83413 + }
83414 + }
83415 + }
83416 +#endif
83417 +
83418 /*
83419 * First try to merge with previous and/or next vma.
83420 */
83421 @@ -296,9 +399,21 @@ success:
83422 * vm_flags and vm_page_prot are protected by the mmap_sem
83423 * held in write mode.
83424 */
83425 +
83426 +#ifdef CONFIG_PAX_SEGMEXEC
83427 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83428 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83429 +#endif
83430 +
83431 vma->vm_flags = newflags;
83432 +
83433 +#ifdef CONFIG_PAX_MPROTECT
83434 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83435 + mm->binfmt->handle_mprotect(vma, newflags);
83436 +#endif
83437 +
83438 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83439 - vm_get_page_prot(newflags));
83440 + vm_get_page_prot(vma->vm_flags));
83441
83442 if (vma_wants_writenotify(vma)) {
83443 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83444 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83445 end = start + len;
83446 if (end <= start)
83447 return -ENOMEM;
83448 +
83449 +#ifdef CONFIG_PAX_SEGMEXEC
83450 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83451 + if (end > SEGMEXEC_TASK_SIZE)
83452 + return -EINVAL;
83453 + } else
83454 +#endif
83455 +
83456 + if (end > TASK_SIZE)
83457 + return -EINVAL;
83458 +
83459 if (!arch_validate_prot(prot))
83460 return -EINVAL;
83461
83462 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83463 /*
83464 * Does the application expect PROT_READ to imply PROT_EXEC:
83465 */
83466 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83467 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83468 prot |= PROT_EXEC;
83469
83470 vm_flags = calc_vm_prot_bits(prot);
83471 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83472 if (start > vma->vm_start)
83473 prev = vma;
83474
83475 +#ifdef CONFIG_PAX_MPROTECT
83476 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83477 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83478 +#endif
83479 +
83480 for (nstart = start ; ; ) {
83481 unsigned long newflags;
83482
83483 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83484
83485 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83486 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83487 + if (prot & (PROT_WRITE | PROT_EXEC))
83488 + gr_log_rwxmprotect(vma->vm_file);
83489 +
83490 + error = -EACCES;
83491 + goto out;
83492 + }
83493 +
83494 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83495 error = -EACCES;
83496 goto out;
83497 }
83498 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83499 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83500 if (error)
83501 goto out;
83502 +
83503 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83504 +
83505 nstart = tmp;
83506
83507 if (nstart < prev->vm_end)
83508 diff --git a/mm/mremap.c b/mm/mremap.c
83509 index e1031e1..1f2a0a1 100644
83510 --- a/mm/mremap.c
83511 +++ b/mm/mremap.c
83512 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83513 continue;
83514 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83515 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83516 +
83517 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83518 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83519 + pte = pte_exprotect(pte);
83520 +#endif
83521 +
83522 set_pte_at(mm, new_addr, new_pte, pte);
83523 }
83524
83525 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83526 if (is_vm_hugetlb_page(vma))
83527 goto Einval;
83528
83529 +#ifdef CONFIG_PAX_SEGMEXEC
83530 + if (pax_find_mirror_vma(vma))
83531 + goto Einval;
83532 +#endif
83533 +
83534 /* We can't remap across vm area boundaries */
83535 if (old_len > vma->vm_end - addr)
83536 goto Efault;
83537 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
83538 unsigned long ret = -EINVAL;
83539 unsigned long charged = 0;
83540 unsigned long map_flags;
83541 + unsigned long pax_task_size = TASK_SIZE;
83542
83543 if (new_addr & ~PAGE_MASK)
83544 goto out;
83545
83546 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83547 +#ifdef CONFIG_PAX_SEGMEXEC
83548 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83549 + pax_task_size = SEGMEXEC_TASK_SIZE;
83550 +#endif
83551 +
83552 + pax_task_size -= PAGE_SIZE;
83553 +
83554 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83555 goto out;
83556
83557 /* Check if the location we're moving into overlaps the
83558 * old location at all, and fail if it does.
83559 */
83560 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83561 - goto out;
83562 -
83563 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83564 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83565 goto out;
83566
83567 ret = do_munmap(mm, new_addr, new_len);
83568 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83569 struct vm_area_struct *vma;
83570 unsigned long ret = -EINVAL;
83571 unsigned long charged = 0;
83572 + unsigned long pax_task_size = TASK_SIZE;
83573
83574 down_write(&current->mm->mmap_sem);
83575
83576 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83577 if (!new_len)
83578 goto out;
83579
83580 +#ifdef CONFIG_PAX_SEGMEXEC
83581 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83582 + pax_task_size = SEGMEXEC_TASK_SIZE;
83583 +#endif
83584 +
83585 + pax_task_size -= PAGE_SIZE;
83586 +
83587 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83588 + old_len > pax_task_size || addr > pax_task_size-old_len)
83589 + goto out;
83590 +
83591 if (flags & MREMAP_FIXED) {
83592 if (flags & MREMAP_MAYMOVE)
83593 ret = mremap_to(addr, old_len, new_addr, new_len);
83594 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83595 addr + new_len);
83596 }
83597 ret = addr;
83598 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83599 goto out;
83600 }
83601 }
83602 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83603 goto out;
83604 }
83605
83606 + map_flags = vma->vm_flags;
83607 ret = move_vma(vma, addr, old_len, new_len, new_addr);
83608 + if (!(ret & ~PAGE_MASK)) {
83609 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83610 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83611 + }
83612 }
83613 out:
83614 if (ret & ~PAGE_MASK)
83615 diff --git a/mm/nommu.c b/mm/nommu.c
83616 index bbe1f3f..b2601ea 100644
83617 --- a/mm/nommu.c
83618 +++ b/mm/nommu.c
83619 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83620 int sysctl_overcommit_ratio = 50; /* default is 50% */
83621 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83622 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83623 -int heap_stack_gap = 0;
83624
83625 atomic_long_t mmap_pages_allocated;
83626
83627 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83628 EXPORT_SYMBOL(find_vma);
83629
83630 /*
83631 - * find a VMA
83632 - * - we don't extend stack VMAs under NOMMU conditions
83633 - */
83634 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83635 -{
83636 - return find_vma(mm, addr);
83637 -}
83638 -
83639 -/*
83640 * expand a stack to a given address
83641 * - not supported under NOMMU conditions
83642 */
83643 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83644
83645 /* most fields are the same, copy all, and then fixup */
83646 *new = *vma;
83647 + INIT_LIST_HEAD(&new->anon_vma_chain);
83648 *region = *vma->vm_region;
83649 new->vm_region = region;
83650
83651 @@ -1975,8 +1966,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83652 }
83653 EXPORT_SYMBOL(generic_file_remap_pages);
83654
83655 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83656 - unsigned long addr, void *buf, int len, int write)
83657 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83658 + unsigned long addr, void *buf, size_t len, int write)
83659 {
83660 struct vm_area_struct *vma;
83661
83662 @@ -2017,8 +2008,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83663 *
83664 * The caller must hold a reference on @mm.
83665 */
83666 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83667 - void *buf, int len, int write)
83668 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83669 + void *buf, size_t len, int write)
83670 {
83671 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83672 }
83673 @@ -2027,7 +2018,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83674 * Access another process' address space.
83675 * - source/target buffer must be kernel space
83676 */
83677 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83678 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83679 {
83680 struct mm_struct *mm;
83681
83682 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83683 index 0713bfb..b95bb87 100644
83684 --- a/mm/page-writeback.c
83685 +++ b/mm/page-writeback.c
83686 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83687 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83688 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83689 */
83690 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83691 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83692 unsigned long thresh,
83693 unsigned long bg_thresh,
83694 unsigned long dirty,
83695 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83696 }
83697 }
83698
83699 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83700 +static struct notifier_block ratelimit_nb = {
83701 .notifier_call = ratelimit_handler,
83702 .next = NULL,
83703 };
83704 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83705 index 6a83cd3..3ab04ef 100644
83706 --- a/mm/page_alloc.c
83707 +++ b/mm/page_alloc.c
83708 @@ -58,6 +58,7 @@
83709 #include <linux/prefetch.h>
83710 #include <linux/migrate.h>
83711 #include <linux/page-debug-flags.h>
83712 +#include <linux/random.h>
83713
83714 #include <asm/tlbflush.h>
83715 #include <asm/div64.h>
83716 @@ -338,7 +339,7 @@ out:
83717 * This usage means that zero-order pages may not be compound.
83718 */
83719
83720 -static void free_compound_page(struct page *page)
83721 +void free_compound_page(struct page *page)
83722 {
83723 __free_pages_ok(page, compound_order(page));
83724 }
83725 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83726 int i;
83727 int bad = 0;
83728
83729 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83730 + unsigned long index = 1UL << order;
83731 +#endif
83732 +
83733 trace_mm_page_free(page, order);
83734 kmemcheck_free_shadow(page, order);
83735
83736 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83737 debug_check_no_obj_freed(page_address(page),
83738 PAGE_SIZE << order);
83739 }
83740 +
83741 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83742 + for (; index; --index)
83743 + sanitize_highpage(page + index - 1);
83744 +#endif
83745 +
83746 arch_free_page(page, order);
83747 kernel_map_pages(page, 1 << order, 0);
83748
83749 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83750 local_irq_restore(flags);
83751 }
83752
83753 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83754 +bool __meminitdata extra_latent_entropy;
83755 +
83756 +static int __init setup_pax_extra_latent_entropy(char *str)
83757 +{
83758 + extra_latent_entropy = true;
83759 + return 0;
83760 +}
83761 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83762 +
83763 +volatile u64 latent_entropy;
83764 +#endif
83765 +
83766 /*
83767 * Read access to zone->managed_pages is safe because it's unsigned long,
83768 * but we still need to serialize writers. Currently all callers of
83769 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83770 set_page_count(p, 0);
83771 }
83772
83773 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83774 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83775 + u64 hash = 0;
83776 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83777 + const u64 *data = lowmem_page_address(page);
83778 +
83779 + for (index = 0; index < end; index++)
83780 + hash ^= hash + data[index];
83781 + latent_entropy ^= hash;
83782 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83783 + }
83784 +#endif
83785 +
83786 page_zone(page)->managed_pages += 1 << order;
83787 set_page_refcounted(page);
83788 __free_pages(page, order);
83789 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83790 arch_alloc_page(page, order);
83791 kernel_map_pages(page, 1 << order, 1);
83792
83793 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83794 if (gfp_flags & __GFP_ZERO)
83795 prep_zero_page(page, order, gfp_flags);
83796 +#endif
83797
83798 if (order && (gfp_flags & __GFP_COMP))
83799 prep_compound_page(page, order);
83800 @@ -3752,7 +3791,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
83801 unsigned long pfn;
83802
83803 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
83804 +#ifdef CONFIG_X86_32
83805 + /* boot failures in VMware 8 on 32bit vanilla since
83806 + this change */
83807 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
83808 +#else
83809 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
83810 +#endif
83811 return 1;
83812 }
83813 return 0;
83814 diff --git a/mm/percpu.c b/mm/percpu.c
83815 index 8c8e08f..73a5cda 100644
83816 --- a/mm/percpu.c
83817 +++ b/mm/percpu.c
83818 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83819 static unsigned int pcpu_high_unit_cpu __read_mostly;
83820
83821 /* the address of the first chunk which starts with the kernel static area */
83822 -void *pcpu_base_addr __read_mostly;
83823 +void *pcpu_base_addr __read_only;
83824 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83825
83826 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83827 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83828 index fd26d04..0cea1b0 100644
83829 --- a/mm/process_vm_access.c
83830 +++ b/mm/process_vm_access.c
83831 @@ -13,6 +13,7 @@
83832 #include <linux/uio.h>
83833 #include <linux/sched.h>
83834 #include <linux/highmem.h>
83835 +#include <linux/security.h>
83836 #include <linux/ptrace.h>
83837 #include <linux/slab.h>
83838 #include <linux/syscalls.h>
83839 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83840 size_t iov_l_curr_offset = 0;
83841 ssize_t iov_len;
83842
83843 + return -ENOSYS; // PaX: until properly audited
83844 +
83845 /*
83846 * Work out how many pages of struct pages we're going to need
83847 * when eventually calling get_user_pages
83848 */
83849 for (i = 0; i < riovcnt; i++) {
83850 iov_len = rvec[i].iov_len;
83851 - if (iov_len > 0) {
83852 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83853 - + iov_len)
83854 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83855 - / PAGE_SIZE + 1;
83856 - nr_pages = max(nr_pages, nr_pages_iov);
83857 - }
83858 + if (iov_len <= 0)
83859 + continue;
83860 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83861 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83862 + nr_pages = max(nr_pages, nr_pages_iov);
83863 }
83864
83865 if (nr_pages == 0)
83866 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83867 goto free_proc_pages;
83868 }
83869
83870 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83871 + rc = -EPERM;
83872 + goto put_task_struct;
83873 + }
83874 +
83875 mm = mm_access(task, PTRACE_MODE_ATTACH);
83876 if (!mm || IS_ERR(mm)) {
83877 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83878 diff --git a/mm/rmap.c b/mm/rmap.c
83879 index 2c78f8c..9e9c624 100644
83880 --- a/mm/rmap.c
83881 +++ b/mm/rmap.c
83882 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83883 struct anon_vma *anon_vma = vma->anon_vma;
83884 struct anon_vma_chain *avc;
83885
83886 +#ifdef CONFIG_PAX_SEGMEXEC
83887 + struct anon_vma_chain *avc_m = NULL;
83888 +#endif
83889 +
83890 might_sleep();
83891 if (unlikely(!anon_vma)) {
83892 struct mm_struct *mm = vma->vm_mm;
83893 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83894 if (!avc)
83895 goto out_enomem;
83896
83897 +#ifdef CONFIG_PAX_SEGMEXEC
83898 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83899 + if (!avc_m)
83900 + goto out_enomem_free_avc;
83901 +#endif
83902 +
83903 anon_vma = find_mergeable_anon_vma(vma);
83904 allocated = NULL;
83905 if (!anon_vma) {
83906 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83907 /* page_table_lock to protect against threads */
83908 spin_lock(&mm->page_table_lock);
83909 if (likely(!vma->anon_vma)) {
83910 +
83911 +#ifdef CONFIG_PAX_SEGMEXEC
83912 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83913 +
83914 + if (vma_m) {
83915 + BUG_ON(vma_m->anon_vma);
83916 + vma_m->anon_vma = anon_vma;
83917 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
83918 + avc_m = NULL;
83919 + }
83920 +#endif
83921 +
83922 vma->anon_vma = anon_vma;
83923 anon_vma_chain_link(vma, avc, anon_vma);
83924 allocated = NULL;
83925 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83926
83927 if (unlikely(allocated))
83928 put_anon_vma(allocated);
83929 +
83930 +#ifdef CONFIG_PAX_SEGMEXEC
83931 + if (unlikely(avc_m))
83932 + anon_vma_chain_free(avc_m);
83933 +#endif
83934 +
83935 if (unlikely(avc))
83936 anon_vma_chain_free(avc);
83937 }
83938 return 0;
83939
83940 out_enomem_free_avc:
83941 +
83942 +#ifdef CONFIG_PAX_SEGMEXEC
83943 + if (avc_m)
83944 + anon_vma_chain_free(avc_m);
83945 +#endif
83946 +
83947 anon_vma_chain_free(avc);
83948 out_enomem:
83949 return -ENOMEM;
83950 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
83951 * Attach the anon_vmas from src to dst.
83952 * Returns 0 on success, -ENOMEM on failure.
83953 */
83954 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83955 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
83956 {
83957 struct anon_vma_chain *avc, *pavc;
83958 struct anon_vma *root = NULL;
83959 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83960 * the corresponding VMA in the parent process is attached to.
83961 * Returns 0 on success, non-zero on failure.
83962 */
83963 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
83964 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
83965 {
83966 struct anon_vma_chain *avc;
83967 struct anon_vma *anon_vma;
83968 diff --git a/mm/shmem.c b/mm/shmem.c
83969 index efd0b3a..994b702 100644
83970 --- a/mm/shmem.c
83971 +++ b/mm/shmem.c
83972 @@ -31,7 +31,7 @@
83973 #include <linux/export.h>
83974 #include <linux/swap.h>
83975
83976 -static struct vfsmount *shm_mnt;
83977 +struct vfsmount *shm_mnt;
83978
83979 #ifdef CONFIG_SHMEM
83980 /*
83981 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
83982 #define BOGO_DIRENT_SIZE 20
83983
83984 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
83985 -#define SHORT_SYMLINK_LEN 128
83986 +#define SHORT_SYMLINK_LEN 64
83987
83988 /*
83989 * shmem_fallocate and shmem_writepage communicate via inode->i_private
83990 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
83991 static int shmem_xattr_validate(const char *name)
83992 {
83993 struct { const char *prefix; size_t len; } arr[] = {
83994 +
83995 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83996 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
83997 +#endif
83998 +
83999 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
84000 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
84001 };
84002 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
84003 if (err)
84004 return err;
84005
84006 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84007 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
84008 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
84009 + return -EOPNOTSUPP;
84010 + if (size > 8)
84011 + return -EINVAL;
84012 + }
84013 +#endif
84014 +
84015 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84016 }
84017
84018 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84019 int err = -ENOMEM;
84020
84021 /* Round up to L1_CACHE_BYTES to resist false sharing */
84022 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84023 - L1_CACHE_BYTES), GFP_KERNEL);
84024 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84025 if (!sbinfo)
84026 return -ENOMEM;
84027
84028 diff --git a/mm/slab.c b/mm/slab.c
84029 index e7667a3..a48e73b 100644
84030 --- a/mm/slab.c
84031 +++ b/mm/slab.c
84032 @@ -306,7 +306,7 @@ struct kmem_list3 {
84033 * Need this for bootstrapping a per node allocator.
84034 */
84035 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
84036 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
84037 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
84038 #define CACHE_CACHE 0
84039 #define SIZE_AC MAX_NUMNODES
84040 #define SIZE_L3 (2 * MAX_NUMNODES)
84041 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
84042 if ((x)->max_freeable < i) \
84043 (x)->max_freeable = i; \
84044 } while (0)
84045 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84046 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84047 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84048 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84049 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84050 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84051 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84052 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84053 #else
84054 #define STATS_INC_ACTIVE(x) do { } while (0)
84055 #define STATS_DEC_ACTIVE(x) do { } while (0)
84056 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84057 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84058 */
84059 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84060 - const struct slab *slab, void *obj)
84061 + const struct slab *slab, const void *obj)
84062 {
84063 u32 offset = (obj - slab->s_mem);
84064 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84065 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
84066 struct cache_names {
84067 char *name;
84068 char *name_dma;
84069 + char *name_usercopy;
84070 };
84071
84072 static struct cache_names __initdata cache_names[] = {
84073 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
84074 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
84075 #include <linux/kmalloc_sizes.h>
84076 - {NULL,}
84077 + {NULL}
84078 #undef CACHE
84079 };
84080
84081 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
84082 if (unlikely(gfpflags & GFP_DMA))
84083 return csizep->cs_dmacachep;
84084 #endif
84085 +
84086 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84087 + if (unlikely(gfpflags & GFP_USERCOPY))
84088 + return csizep->cs_usercopycachep;
84089 +#endif
84090 +
84091 return csizep->cs_cachep;
84092 }
84093
84094 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84095 return notifier_from_errno(err);
84096 }
84097
84098 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84099 +static struct notifier_block cpucache_notifier = {
84100 &cpuup_callback, NULL, 0
84101 };
84102
84103 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
84104 */
84105
84106 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
84107 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
84108 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84109
84110 if (INDEX_AC != INDEX_L3)
84111 sizes[INDEX_L3].cs_cachep =
84112 create_kmalloc_cache(names[INDEX_L3].name,
84113 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
84114 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84115
84116 slab_early_init = 0;
84117
84118 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
84119 */
84120 if (!sizes->cs_cachep)
84121 sizes->cs_cachep = create_kmalloc_cache(names->name,
84122 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
84123 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84124
84125 #ifdef CONFIG_ZONE_DMA
84126 sizes->cs_dmacachep = create_kmalloc_cache(
84127 names->name_dma, sizes->cs_size,
84128 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84129 #endif
84130 +
84131 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84132 + sizes->cs_usercopycachep = create_kmalloc_cache(
84133 + names->name_usercopy, sizes->cs_size,
84134 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84135 +#endif
84136 +
84137 sizes++;
84138 names++;
84139 }
84140 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84141
84142 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84143 return;
84144 + VM_BUG_ON(!virt_addr_valid(objp));
84145 local_irq_save(flags);
84146 kfree_debugcheck(objp);
84147 c = virt_to_cache(objp);
84148 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84149 }
84150 /* cpu stats */
84151 {
84152 - unsigned long allochit = atomic_read(&cachep->allochit);
84153 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84154 - unsigned long freehit = atomic_read(&cachep->freehit);
84155 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84156 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84157 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84158 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84159 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84160
84161 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84162 allochit, allocmiss, freehit, freemiss);
84163 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84164 static int __init slab_proc_init(void)
84165 {
84166 #ifdef CONFIG_DEBUG_SLAB_LEAK
84167 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84168 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84169 #endif
84170 return 0;
84171 }
84172 module_init(slab_proc_init);
84173 #endif
84174
84175 +bool is_usercopy_object(const void *ptr)
84176 +{
84177 + struct page *page;
84178 + struct kmem_cache *cachep;
84179 +
84180 + if (ZERO_OR_NULL_PTR(ptr))
84181 + return false;
84182 +
84183 + if (!slab_is_available())
84184 + return false;
84185 +
84186 + if (!virt_addr_valid(ptr))
84187 + return false;
84188 +
84189 + page = virt_to_head_page(ptr);
84190 +
84191 + if (!PageSlab(page))
84192 + return false;
84193 +
84194 + cachep = page->slab_cache;
84195 + return cachep->flags & SLAB_USERCOPY;
84196 +}
84197 +
84198 +#ifdef CONFIG_PAX_USERCOPY
84199 +const char *check_heap_object(const void *ptr, unsigned long n)
84200 +{
84201 + struct page *page;
84202 + struct kmem_cache *cachep;
84203 + struct slab *slabp;
84204 + unsigned int objnr;
84205 + unsigned long offset;
84206 +
84207 + if (ZERO_OR_NULL_PTR(ptr))
84208 + return "<null>";
84209 +
84210 + if (!virt_addr_valid(ptr))
84211 + return NULL;
84212 +
84213 + page = virt_to_head_page(ptr);
84214 +
84215 + if (!PageSlab(page))
84216 + return NULL;
84217 +
84218 + cachep = page->slab_cache;
84219 + if (!(cachep->flags & SLAB_USERCOPY))
84220 + return cachep->name;
84221 +
84222 + slabp = page->slab_page;
84223 + objnr = obj_to_index(cachep, slabp, ptr);
84224 + BUG_ON(objnr >= cachep->num);
84225 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84226 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84227 + return NULL;
84228 +
84229 + return cachep->name;
84230 +}
84231 +#endif
84232 +
84233 /**
84234 * ksize - get the actual amount of memory allocated for a given object
84235 * @objp: Pointer to the object
84236 diff --git a/mm/slab.h b/mm/slab.h
84237 index 34a98d6..73633d1 100644
84238 --- a/mm/slab.h
84239 +++ b/mm/slab.h
84240 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84241
84242 /* Legal flag mask for kmem_cache_create(), for various configurations */
84243 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84244 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84245 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84246
84247 #if defined(CONFIG_DEBUG_SLAB)
84248 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84249 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84250 return s;
84251
84252 page = virt_to_head_page(x);
84253 +
84254 + BUG_ON(!PageSlab(page));
84255 +
84256 cachep = page->slab_cache;
84257 if (slab_equal_or_root(cachep, s))
84258 return cachep;
84259 diff --git a/mm/slab_common.c b/mm/slab_common.c
84260 index 3f3cd97..93b0236 100644
84261 --- a/mm/slab_common.c
84262 +++ b/mm/slab_common.c
84263 @@ -22,7 +22,7 @@
84264
84265 #include "slab.h"
84266
84267 -enum slab_state slab_state;
84268 +enum slab_state slab_state __read_only;
84269 LIST_HEAD(slab_caches);
84270 DEFINE_MUTEX(slab_mutex);
84271 struct kmem_cache *kmem_cache;
84272 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84273
84274 err = __kmem_cache_create(s, flags);
84275 if (!err) {
84276 - s->refcount = 1;
84277 + atomic_set(&s->refcount, 1);
84278 list_add(&s->list, &slab_caches);
84279 memcg_cache_list_add(memcg, s);
84280 } else {
84281 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84282
84283 get_online_cpus();
84284 mutex_lock(&slab_mutex);
84285 - s->refcount--;
84286 - if (!s->refcount) {
84287 + if (atomic_dec_and_test(&s->refcount)) {
84288 list_del(&s->list);
84289
84290 if (!__kmem_cache_shutdown(s)) {
84291 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84292 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84293 name, size, err);
84294
84295 - s->refcount = -1; /* Exempt from merging for now */
84296 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84297 }
84298
84299 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84300 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84301
84302 create_boot_cache(s, name, size, flags);
84303 list_add(&s->list, &slab_caches);
84304 - s->refcount = 1;
84305 + atomic_set(&s->refcount, 1);
84306 return s;
84307 }
84308
84309 diff --git a/mm/slob.c b/mm/slob.c
84310 index a99fdf7..6ee34ec 100644
84311 --- a/mm/slob.c
84312 +++ b/mm/slob.c
84313 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84314 /*
84315 * Return the size of a slob block.
84316 */
84317 -static slobidx_t slob_units(slob_t *s)
84318 +static slobidx_t slob_units(const slob_t *s)
84319 {
84320 if (s->units > 0)
84321 return s->units;
84322 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84323 /*
84324 * Return the next free slob block pointer after this one.
84325 */
84326 -static slob_t *slob_next(slob_t *s)
84327 +static slob_t *slob_next(const slob_t *s)
84328 {
84329 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84330 slobidx_t next;
84331 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84332 /*
84333 * Returns true if s is the last free block in its page.
84334 */
84335 -static int slob_last(slob_t *s)
84336 +static int slob_last(const slob_t *s)
84337 {
84338 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84339 }
84340
84341 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84342 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84343 {
84344 - void *page;
84345 + struct page *page;
84346
84347 #ifdef CONFIG_NUMA
84348 if (node != NUMA_NO_NODE)
84349 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84350 if (!page)
84351 return NULL;
84352
84353 - return page_address(page);
84354 + __SetPageSlab(page);
84355 + return page;
84356 }
84357
84358 -static void slob_free_pages(void *b, int order)
84359 +static void slob_free_pages(struct page *sp, int order)
84360 {
84361 if (current->reclaim_state)
84362 current->reclaim_state->reclaimed_slab += 1 << order;
84363 - free_pages((unsigned long)b, order);
84364 + __ClearPageSlab(sp);
84365 + reset_page_mapcount(sp);
84366 + sp->private = 0;
84367 + __free_pages(sp, order);
84368 }
84369
84370 /*
84371 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84372
84373 /* Not enough space: must allocate a new page */
84374 if (!b) {
84375 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84376 - if (!b)
84377 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84378 + if (!sp)
84379 return NULL;
84380 - sp = virt_to_page(b);
84381 - __SetPageSlab(sp);
84382 + b = page_address(sp);
84383
84384 spin_lock_irqsave(&slob_lock, flags);
84385 sp->units = SLOB_UNITS(PAGE_SIZE);
84386 sp->freelist = b;
84387 + sp->private = 0;
84388 INIT_LIST_HEAD(&sp->list);
84389 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84390 set_slob_page_free(sp, slob_list);
84391 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84392 if (slob_page_free(sp))
84393 clear_slob_page_free(sp);
84394 spin_unlock_irqrestore(&slob_lock, flags);
84395 - __ClearPageSlab(sp);
84396 - reset_page_mapcount(sp);
84397 - slob_free_pages(b, 0);
84398 + slob_free_pages(sp, 0);
84399 return;
84400 }
84401
84402 @@ -424,11 +426,10 @@ out:
84403 */
84404
84405 static __always_inline void *
84406 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84407 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84408 {
84409 - unsigned int *m;
84410 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84411 - void *ret;
84412 + slob_t *m;
84413 + void *ret = NULL;
84414
84415 gfp &= gfp_allowed_mask;
84416
84417 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84418
84419 if (!m)
84420 return NULL;
84421 - *m = size;
84422 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84423 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84424 + m[0].units = size;
84425 + m[1].units = align;
84426 ret = (void *)m + align;
84427
84428 trace_kmalloc_node(caller, ret,
84429 size, size + align, gfp, node);
84430 } else {
84431 unsigned int order = get_order(size);
84432 + struct page *page;
84433
84434 if (likely(order))
84435 gfp |= __GFP_COMP;
84436 - ret = slob_new_pages(gfp, order, node);
84437 + page = slob_new_pages(gfp, order, node);
84438 + if (page) {
84439 + ret = page_address(page);
84440 + page->private = size;
84441 + }
84442
84443 trace_kmalloc_node(caller, ret,
84444 size, PAGE_SIZE << order, gfp, node);
84445 }
84446
84447 - kmemleak_alloc(ret, size, 1, gfp);
84448 + return ret;
84449 +}
84450 +
84451 +static __always_inline void *
84452 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84453 +{
84454 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84455 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84456 +
84457 + if (!ZERO_OR_NULL_PTR(ret))
84458 + kmemleak_alloc(ret, size, 1, gfp);
84459 return ret;
84460 }
84461
84462 @@ -493,34 +512,112 @@ void kfree(const void *block)
84463 return;
84464 kmemleak_free(block);
84465
84466 + VM_BUG_ON(!virt_addr_valid(block));
84467 sp = virt_to_page(block);
84468 - if (PageSlab(sp)) {
84469 + VM_BUG_ON(!PageSlab(sp));
84470 + if (!sp->private) {
84471 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84472 - unsigned int *m = (unsigned int *)(block - align);
84473 - slob_free(m, *m + align);
84474 - } else
84475 + slob_t *m = (slob_t *)(block - align);
84476 + slob_free(m, m[0].units + align);
84477 + } else {
84478 + __ClearPageSlab(sp);
84479 + reset_page_mapcount(sp);
84480 + sp->private = 0;
84481 __free_pages(sp, compound_order(sp));
84482 + }
84483 }
84484 EXPORT_SYMBOL(kfree);
84485
84486 +bool is_usercopy_object(const void *ptr)
84487 +{
84488 + if (!slab_is_available())
84489 + return false;
84490 +
84491 + // PAX: TODO
84492 +
84493 + return false;
84494 +}
84495 +
84496 +#ifdef CONFIG_PAX_USERCOPY
84497 +const char *check_heap_object(const void *ptr, unsigned long n)
84498 +{
84499 + struct page *page;
84500 + const slob_t *free;
84501 + const void *base;
84502 + unsigned long flags;
84503 +
84504 + if (ZERO_OR_NULL_PTR(ptr))
84505 + return "<null>";
84506 +
84507 + if (!virt_addr_valid(ptr))
84508 + return NULL;
84509 +
84510 + page = virt_to_head_page(ptr);
84511 + if (!PageSlab(page))
84512 + return NULL;
84513 +
84514 + if (page->private) {
84515 + base = page;
84516 + if (base <= ptr && n <= page->private - (ptr - base))
84517 + return NULL;
84518 + return "<slob>";
84519 + }
84520 +
84521 + /* some tricky double walking to find the chunk */
84522 + spin_lock_irqsave(&slob_lock, flags);
84523 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84524 + free = page->freelist;
84525 +
84526 + while (!slob_last(free) && (void *)free <= ptr) {
84527 + base = free + slob_units(free);
84528 + free = slob_next(free);
84529 + }
84530 +
84531 + while (base < (void *)free) {
84532 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84533 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84534 + int offset;
84535 +
84536 + if (ptr < base + align)
84537 + break;
84538 +
84539 + offset = ptr - base - align;
84540 + if (offset >= m) {
84541 + base += size;
84542 + continue;
84543 + }
84544 +
84545 + if (n > m - offset)
84546 + break;
84547 +
84548 + spin_unlock_irqrestore(&slob_lock, flags);
84549 + return NULL;
84550 + }
84551 +
84552 + spin_unlock_irqrestore(&slob_lock, flags);
84553 + return "<slob>";
84554 +}
84555 +#endif
84556 +
84557 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84558 size_t ksize(const void *block)
84559 {
84560 struct page *sp;
84561 int align;
84562 - unsigned int *m;
84563 + slob_t *m;
84564
84565 BUG_ON(!block);
84566 if (unlikely(block == ZERO_SIZE_PTR))
84567 return 0;
84568
84569 sp = virt_to_page(block);
84570 - if (unlikely(!PageSlab(sp)))
84571 - return PAGE_SIZE << compound_order(sp);
84572 + VM_BUG_ON(!PageSlab(sp));
84573 + if (sp->private)
84574 + return sp->private;
84575
84576 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84577 - m = (unsigned int *)(block - align);
84578 - return SLOB_UNITS(*m) * SLOB_UNIT;
84579 + m = (slob_t *)(block - align);
84580 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84581 }
84582 EXPORT_SYMBOL(ksize);
84583
84584 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84585
84586 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84587 {
84588 - void *b;
84589 + void *b = NULL;
84590
84591 flags &= gfp_allowed_mask;
84592
84593 lockdep_trace_alloc(flags);
84594
84595 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84596 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84597 +#else
84598 if (c->size < PAGE_SIZE) {
84599 b = slob_alloc(c->size, flags, c->align, node);
84600 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84601 SLOB_UNITS(c->size) * SLOB_UNIT,
84602 flags, node);
84603 } else {
84604 - b = slob_new_pages(flags, get_order(c->size), node);
84605 + struct page *sp;
84606 +
84607 + sp = slob_new_pages(flags, get_order(c->size), node);
84608 + if (sp) {
84609 + b = page_address(sp);
84610 + sp->private = c->size;
84611 + }
84612 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84613 PAGE_SIZE << get_order(c->size),
84614 flags, node);
84615 }
84616 +#endif
84617
84618 if (c->ctor)
84619 c->ctor(b);
84620 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84621
84622 static void __kmem_cache_free(void *b, int size)
84623 {
84624 - if (size < PAGE_SIZE)
84625 + struct page *sp;
84626 +
84627 + sp = virt_to_page(b);
84628 + BUG_ON(!PageSlab(sp));
84629 + if (!sp->private)
84630 slob_free(b, size);
84631 else
84632 - slob_free_pages(b, get_order(size));
84633 + slob_free_pages(sp, get_order(size));
84634 }
84635
84636 static void kmem_rcu_free(struct rcu_head *head)
84637 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84638
84639 void kmem_cache_free(struct kmem_cache *c, void *b)
84640 {
84641 + int size = c->size;
84642 +
84643 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84644 + if (size + c->align < PAGE_SIZE) {
84645 + size += c->align;
84646 + b -= c->align;
84647 + }
84648 +#endif
84649 +
84650 kmemleak_free_recursive(b, c->flags);
84651 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84652 struct slob_rcu *slob_rcu;
84653 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84654 - slob_rcu->size = c->size;
84655 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84656 + slob_rcu->size = size;
84657 call_rcu(&slob_rcu->head, kmem_rcu_free);
84658 } else {
84659 - __kmem_cache_free(b, c->size);
84660 + __kmem_cache_free(b, size);
84661 }
84662
84663 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84664 + trace_kfree(_RET_IP_, b);
84665 +#else
84666 trace_kmem_cache_free(_RET_IP_, b);
84667 +#endif
84668 +
84669 }
84670 EXPORT_SYMBOL(kmem_cache_free);
84671
84672 diff --git a/mm/slub.c b/mm/slub.c
84673 index ba2ca53..991c4f7 100644
84674 --- a/mm/slub.c
84675 +++ b/mm/slub.c
84676 @@ -197,7 +197,7 @@ struct track {
84677
84678 enum track_item { TRACK_ALLOC, TRACK_FREE };
84679
84680 -#ifdef CONFIG_SYSFS
84681 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84682 static int sysfs_slab_add(struct kmem_cache *);
84683 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84684 static void sysfs_slab_remove(struct kmem_cache *);
84685 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84686 if (!t->addr)
84687 return;
84688
84689 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84690 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84691 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84692 #ifdef CONFIG_STACKTRACE
84693 {
84694 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84695 * Merge control. If this is set then no merging of slab caches will occur.
84696 * (Could be removed. This was introduced to pacify the merge skeptics.)
84697 */
84698 -static int slub_nomerge;
84699 +static int slub_nomerge = 1;
84700
84701 /*
84702 * Calculate the order of allocation given an slab object size.
84703 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84704 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84705 #endif
84706
84707 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84708 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84709 +#endif
84710 +
84711 static int __init setup_slub_min_order(char *str)
84712 {
84713 get_option(&str, &slub_min_order);
84714 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84715 return kmalloc_dma_caches[index];
84716
84717 #endif
84718 +
84719 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84720 + if (flags & SLAB_USERCOPY)
84721 + return kmalloc_usercopy_caches[index];
84722 +
84723 +#endif
84724 +
84725 return kmalloc_caches[index];
84726 }
84727
84728 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84729 EXPORT_SYMBOL(__kmalloc_node);
84730 #endif
84731
84732 +bool is_usercopy_object(const void *ptr)
84733 +{
84734 + struct page *page;
84735 + struct kmem_cache *s;
84736 +
84737 + if (ZERO_OR_NULL_PTR(ptr))
84738 + return false;
84739 +
84740 + if (!slab_is_available())
84741 + return false;
84742 +
84743 + if (!virt_addr_valid(ptr))
84744 + return false;
84745 +
84746 + page = virt_to_head_page(ptr);
84747 +
84748 + if (!PageSlab(page))
84749 + return false;
84750 +
84751 + s = page->slab_cache;
84752 + return s->flags & SLAB_USERCOPY;
84753 +}
84754 +
84755 +#ifdef CONFIG_PAX_USERCOPY
84756 +const char *check_heap_object(const void *ptr, unsigned long n)
84757 +{
84758 + struct page *page;
84759 + struct kmem_cache *s;
84760 + unsigned long offset;
84761 +
84762 + if (ZERO_OR_NULL_PTR(ptr))
84763 + return "<null>";
84764 +
84765 + if (!virt_addr_valid(ptr))
84766 + return NULL;
84767 +
84768 + page = virt_to_head_page(ptr);
84769 +
84770 + if (!PageSlab(page))
84771 + return NULL;
84772 +
84773 + s = page->slab_cache;
84774 + if (!(s->flags & SLAB_USERCOPY))
84775 + return s->name;
84776 +
84777 + offset = (ptr - page_address(page)) % s->size;
84778 + if (offset <= s->object_size && n <= s->object_size - offset)
84779 + return NULL;
84780 +
84781 + return s->name;
84782 +}
84783 +#endif
84784 +
84785 size_t ksize(const void *object)
84786 {
84787 struct page *page;
84788 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84789 if (unlikely(ZERO_OR_NULL_PTR(x)))
84790 return;
84791
84792 + VM_BUG_ON(!virt_addr_valid(x));
84793 page = virt_to_head_page(x);
84794 if (unlikely(!PageSlab(page))) {
84795 BUG_ON(!PageCompound(page));
84796 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84797
84798 /* Caches that are not of the two-to-the-power-of size */
84799 if (KMALLOC_MIN_SIZE <= 32) {
84800 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84801 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84802 caches++;
84803 }
84804
84805 if (KMALLOC_MIN_SIZE <= 64) {
84806 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84807 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84808 caches++;
84809 }
84810
84811 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84812 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84813 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84814 caches++;
84815 }
84816
84817 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84818 }
84819 }
84820 #endif
84821 +
84822 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84823 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84824 + struct kmem_cache *s = kmalloc_caches[i];
84825 +
84826 + if (s && s->size) {
84827 + char *name = kasprintf(GFP_NOWAIT,
84828 + "usercopy-kmalloc-%d", s->object_size);
84829 +
84830 + BUG_ON(!name);
84831 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84832 + s->object_size, SLAB_USERCOPY);
84833 + }
84834 + }
84835 +#endif
84836 +
84837 printk(KERN_INFO
84838 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84839 " CPUs=%d, Nodes=%d\n",
84840 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84841 /*
84842 * We may have set a slab to be unmergeable during bootstrap.
84843 */
84844 - if (s->refcount < 0)
84845 + if (atomic_read(&s->refcount) < 0)
84846 return 1;
84847
84848 return 0;
84849 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84850
84851 s = find_mergeable(memcg, size, align, flags, name, ctor);
84852 if (s) {
84853 - s->refcount++;
84854 + atomic_inc(&s->refcount);
84855 /*
84856 * Adjust the object sizes so that we clear
84857 * the complete object on kzalloc.
84858 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84859 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84860
84861 if (sysfs_slab_alias(s, name)) {
84862 - s->refcount--;
84863 + atomic_dec(&s->refcount);
84864 s = NULL;
84865 }
84866 }
84867 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84868 return NOTIFY_OK;
84869 }
84870
84871 -static struct notifier_block __cpuinitdata slab_notifier = {
84872 +static struct notifier_block slab_notifier = {
84873 .notifier_call = slab_cpuup_callback
84874 };
84875
84876 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84877 }
84878 #endif
84879
84880 -#ifdef CONFIG_SYSFS
84881 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84882 static int count_inuse(struct page *page)
84883 {
84884 return page->inuse;
84885 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84886 validate_slab_cache(kmalloc_caches[9]);
84887 }
84888 #else
84889 -#ifdef CONFIG_SYSFS
84890 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84891 static void resiliency_test(void) {};
84892 #endif
84893 #endif
84894
84895 -#ifdef CONFIG_SYSFS
84896 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84897 enum slab_stat_type {
84898 SL_ALL, /* All slabs */
84899 SL_PARTIAL, /* Only partially allocated slabs */
84900 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84901
84902 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84903 {
84904 - return sprintf(buf, "%d\n", s->refcount - 1);
84905 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84906 }
84907 SLAB_ATTR_RO(aliases);
84908
84909 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84910 return name;
84911 }
84912
84913 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84914 static int sysfs_slab_add(struct kmem_cache *s)
84915 {
84916 int err;
84917 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
84918 kobject_del(&s->kobj);
84919 kobject_put(&s->kobj);
84920 }
84921 +#endif
84922
84923 /*
84924 * Need to buffer aliases during bootup until sysfs becomes
84925 @@ -5336,6 +5419,7 @@ struct saved_alias {
84926
84927 static struct saved_alias *alias_list;
84928
84929 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84930 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84931 {
84932 struct saved_alias *al;
84933 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84934 alias_list = al;
84935 return 0;
84936 }
84937 +#endif
84938
84939 static int __init slab_sysfs_init(void)
84940 {
84941 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
84942 index 1b7e22a..3fcd4f3 100644
84943 --- a/mm/sparse-vmemmap.c
84944 +++ b/mm/sparse-vmemmap.c
84945 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
84946 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84947 if (!p)
84948 return NULL;
84949 - pud_populate(&init_mm, pud, p);
84950 + pud_populate_kernel(&init_mm, pud, p);
84951 }
84952 return pud;
84953 }
84954 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
84955 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84956 if (!p)
84957 return NULL;
84958 - pgd_populate(&init_mm, pgd, p);
84959 + pgd_populate_kernel(&init_mm, pgd, p);
84960 }
84961 return pgd;
84962 }
84963 diff --git a/mm/sparse.c b/mm/sparse.c
84964 index 6b5fb76..db0c190 100644
84965 --- a/mm/sparse.c
84966 +++ b/mm/sparse.c
84967 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
84968
84969 for (i = 0; i < PAGES_PER_SECTION; i++) {
84970 if (PageHWPoison(&memmap[i])) {
84971 - atomic_long_sub(1, &mce_bad_pages);
84972 + atomic_long_sub_unchecked(1, &mce_bad_pages);
84973 ClearPageHWPoison(&memmap[i]);
84974 }
84975 }
84976 diff --git a/mm/swap.c b/mm/swap.c
84977 index 6310dc2..3662b3f 100644
84978 --- a/mm/swap.c
84979 +++ b/mm/swap.c
84980 @@ -30,6 +30,7 @@
84981 #include <linux/backing-dev.h>
84982 #include <linux/memcontrol.h>
84983 #include <linux/gfp.h>
84984 +#include <linux/hugetlb.h>
84985
84986 #include "internal.h"
84987
84988 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
84989
84990 __page_cache_release(page);
84991 dtor = get_compound_page_dtor(page);
84992 + if (!PageHuge(page))
84993 + BUG_ON(dtor != free_compound_page);
84994 (*dtor)(page);
84995 }
84996
84997 diff --git a/mm/swapfile.c b/mm/swapfile.c
84998 index e97a0e5..b50e796 100644
84999 --- a/mm/swapfile.c
85000 +++ b/mm/swapfile.c
85001 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
85002
85003 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
85004 /* Activity counter to indicate that a swapon or swapoff has occurred */
85005 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
85006 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
85007
85008 static inline unsigned char swap_count(unsigned char ent)
85009 {
85010 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
85011 }
85012 filp_close(swap_file, NULL);
85013 err = 0;
85014 - atomic_inc(&proc_poll_event);
85015 + atomic_inc_unchecked(&proc_poll_event);
85016 wake_up_interruptible(&proc_poll_wait);
85017
85018 out_dput:
85019 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85020
85021 poll_wait(file, &proc_poll_wait, wait);
85022
85023 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85024 - seq->poll_event = atomic_read(&proc_poll_event);
85025 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85026 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85027 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85028 }
85029
85030 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85031 return ret;
85032
85033 seq = file->private_data;
85034 - seq->poll_event = atomic_read(&proc_poll_event);
85035 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85036 return 0;
85037 }
85038
85039 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85040 (frontswap_map) ? "FS" : "");
85041
85042 mutex_unlock(&swapon_mutex);
85043 - atomic_inc(&proc_poll_event);
85044 + atomic_inc_unchecked(&proc_poll_event);
85045 wake_up_interruptible(&proc_poll_wait);
85046
85047 if (S_ISREG(inode->i_mode))
85048 diff --git a/mm/util.c b/mm/util.c
85049 index c55e26b..3f913a9 100644
85050 --- a/mm/util.c
85051 +++ b/mm/util.c
85052 @@ -292,6 +292,12 @@ done:
85053 void arch_pick_mmap_layout(struct mm_struct *mm)
85054 {
85055 mm->mmap_base = TASK_UNMAPPED_BASE;
85056 +
85057 +#ifdef CONFIG_PAX_RANDMMAP
85058 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85059 + mm->mmap_base += mm->delta_mmap;
85060 +#endif
85061 +
85062 mm->get_unmapped_area = arch_get_unmapped_area;
85063 mm->unmap_area = arch_unmap_area;
85064 }
85065 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85066 index 5123a16..f234a48 100644
85067 --- a/mm/vmalloc.c
85068 +++ b/mm/vmalloc.c
85069 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85070
85071 pte = pte_offset_kernel(pmd, addr);
85072 do {
85073 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85074 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85075 +
85076 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85077 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85078 + BUG_ON(!pte_exec(*pte));
85079 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85080 + continue;
85081 + }
85082 +#endif
85083 +
85084 + {
85085 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85086 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85087 + }
85088 } while (pte++, addr += PAGE_SIZE, addr != end);
85089 }
85090
85091 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85092 pte = pte_alloc_kernel(pmd, addr);
85093 if (!pte)
85094 return -ENOMEM;
85095 +
85096 + pax_open_kernel();
85097 do {
85098 struct page *page = pages[*nr];
85099
85100 - if (WARN_ON(!pte_none(*pte)))
85101 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85102 + if (pgprot_val(prot) & _PAGE_NX)
85103 +#endif
85104 +
85105 + if (!pte_none(*pte)) {
85106 + pax_close_kernel();
85107 + WARN_ON(1);
85108 return -EBUSY;
85109 - if (WARN_ON(!page))
85110 + }
85111 + if (!page) {
85112 + pax_close_kernel();
85113 + WARN_ON(1);
85114 return -ENOMEM;
85115 + }
85116 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85117 (*nr)++;
85118 } while (pte++, addr += PAGE_SIZE, addr != end);
85119 + pax_close_kernel();
85120 return 0;
85121 }
85122
85123 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85124 pmd_t *pmd;
85125 unsigned long next;
85126
85127 - pmd = pmd_alloc(&init_mm, pud, addr);
85128 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85129 if (!pmd)
85130 return -ENOMEM;
85131 do {
85132 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85133 pud_t *pud;
85134 unsigned long next;
85135
85136 - pud = pud_alloc(&init_mm, pgd, addr);
85137 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85138 if (!pud)
85139 return -ENOMEM;
85140 do {
85141 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
85142 * and fall back on vmalloc() if that fails. Others
85143 * just put it in the vmalloc space.
85144 */
85145 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
85146 +#ifdef CONFIG_MODULES
85147 +#ifdef MODULES_VADDR
85148 unsigned long addr = (unsigned long)x;
85149 if (addr >= MODULES_VADDR && addr < MODULES_END)
85150 return 1;
85151 #endif
85152 +
85153 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85154 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85155 + return 1;
85156 +#endif
85157 +
85158 +#endif
85159 +
85160 return is_vmalloc_addr(x);
85161 }
85162
85163 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85164
85165 if (!pgd_none(*pgd)) {
85166 pud_t *pud = pud_offset(pgd, addr);
85167 +#ifdef CONFIG_X86
85168 + if (!pud_large(*pud))
85169 +#endif
85170 if (!pud_none(*pud)) {
85171 pmd_t *pmd = pmd_offset(pud, addr);
85172 +#ifdef CONFIG_X86
85173 + if (!pmd_large(*pmd))
85174 +#endif
85175 if (!pmd_none(*pmd)) {
85176 pte_t *ptep, pte;
85177
85178 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
85179 * Allocate a region of KVA of the specified size and alignment, within the
85180 * vstart and vend.
85181 */
85182 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85183 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85184 unsigned long align,
85185 unsigned long vstart, unsigned long vend,
85186 int node, gfp_t gfp_mask)
85187 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85188 struct vm_struct *area;
85189
85190 BUG_ON(in_interrupt());
85191 +
85192 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85193 + if (flags & VM_KERNEXEC) {
85194 + if (start != VMALLOC_START || end != VMALLOC_END)
85195 + return NULL;
85196 + start = (unsigned long)MODULES_EXEC_VADDR;
85197 + end = (unsigned long)MODULES_EXEC_END;
85198 + }
85199 +#endif
85200 +
85201 if (flags & VM_IOREMAP) {
85202 int bit = fls(size);
85203
85204 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
85205 if (count > totalram_pages)
85206 return NULL;
85207
85208 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85209 + if (!(pgprot_val(prot) & _PAGE_NX))
85210 + flags |= VM_KERNEXEC;
85211 +#endif
85212 +
85213 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85214 __builtin_return_address(0));
85215 if (!area)
85216 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85217 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85218 goto fail;
85219
85220 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85221 + if (!(pgprot_val(prot) & _PAGE_NX))
85222 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85223 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85224 + else
85225 +#endif
85226 +
85227 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85228 start, end, node, gfp_mask, caller);
85229 if (!area)
85230 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
85231 * For tight control over page level allocator and protection flags
85232 * use __vmalloc() instead.
85233 */
85234 -
85235 void *vmalloc_exec(unsigned long size)
85236 {
85237 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85238 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85239 -1, __builtin_return_address(0));
85240 }
85241
85242 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85243 unsigned long uaddr = vma->vm_start;
85244 unsigned long usize = vma->vm_end - vma->vm_start;
85245
85246 + BUG_ON(vma->vm_mirror);
85247 +
85248 if ((PAGE_SIZE-1) & (unsigned long)addr)
85249 return -EINVAL;
85250
85251 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
85252 v->addr, v->addr + v->size, v->size);
85253
85254 if (v->caller)
85255 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85256 + seq_printf(m, " %pK", v->caller);
85257 +#else
85258 seq_printf(m, " %pS", v->caller);
85259 +#endif
85260
85261 if (v->nr_pages)
85262 seq_printf(m, " pages=%d", v->nr_pages);
85263 diff --git a/mm/vmstat.c b/mm/vmstat.c
85264 index 9800306..76b4b27 100644
85265 --- a/mm/vmstat.c
85266 +++ b/mm/vmstat.c
85267 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85268 *
85269 * vm_stat contains the global counters
85270 */
85271 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85272 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85273 EXPORT_SYMBOL(vm_stat);
85274
85275 #ifdef CONFIG_SMP
85276 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85277 v = p->vm_stat_diff[i];
85278 p->vm_stat_diff[i] = 0;
85279 local_irq_restore(flags);
85280 - atomic_long_add(v, &zone->vm_stat[i]);
85281 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85282 global_diff[i] += v;
85283 #ifdef CONFIG_NUMA
85284 /* 3 seconds idle till flush */
85285 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85286
85287 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85288 if (global_diff[i])
85289 - atomic_long_add(global_diff[i], &vm_stat[i]);
85290 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85291 }
85292
85293 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85294 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85295 if (pset->vm_stat_diff[i]) {
85296 int v = pset->vm_stat_diff[i];
85297 pset->vm_stat_diff[i] = 0;
85298 - atomic_long_add(v, &zone->vm_stat[i]);
85299 - atomic_long_add(v, &vm_stat[i]);
85300 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85301 + atomic_long_add_unchecked(v, &vm_stat[i]);
85302 }
85303 }
85304 #endif
85305 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85306 return NOTIFY_OK;
85307 }
85308
85309 -static struct notifier_block __cpuinitdata vmstat_notifier =
85310 +static struct notifier_block vmstat_notifier =
85311 { &vmstat_cpuup_callback, NULL, 0 };
85312 #endif
85313
85314 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
85315 start_cpu_timer(cpu);
85316 #endif
85317 #ifdef CONFIG_PROC_FS
85318 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85319 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85320 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85321 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85322 + {
85323 + mode_t gr_mode = S_IRUGO;
85324 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85325 + gr_mode = S_IRUSR;
85326 +#endif
85327 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85328 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85329 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85330 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85331 +#else
85332 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85333 +#endif
85334 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85335 + }
85336 #endif
85337 return 0;
85338 }
85339 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85340 index acc74ad..be02639 100644
85341 --- a/net/8021q/vlan.c
85342 +++ b/net/8021q/vlan.c
85343 @@ -108,6 +108,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85344 if (vlan_id)
85345 vlan_vid_del(real_dev, vlan_id);
85346
85347 + /* Take it out of our own structures, but be sure to interlock with
85348 + * HW accelerating devices or SW vlan input packet processing if
85349 + * VLAN is not 0 (leave it there for 802.1p).
85350 + */
85351 + if (vlan_id)
85352 + vlan_vid_del(real_dev, vlan_id);
85353 +
85354 /* Get rid of the vlan's reference to real_dev */
85355 dev_put(real_dev);
85356 }
85357 @@ -485,7 +492,7 @@ out:
85358 return NOTIFY_DONE;
85359 }
85360
85361 -static struct notifier_block vlan_notifier_block __read_mostly = {
85362 +static struct notifier_block vlan_notifier_block = {
85363 .notifier_call = vlan_device_event,
85364 };
85365
85366 @@ -560,8 +567,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85367 err = -EPERM;
85368 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85369 break;
85370 - if ((args.u.name_type >= 0) &&
85371 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85372 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85373 struct vlan_net *vn;
85374
85375 vn = net_generic(net, vlan_net_id);
85376 diff --git a/net/9p/mod.c b/net/9p/mod.c
85377 index 6ab36ae..6f1841b 100644
85378 --- a/net/9p/mod.c
85379 +++ b/net/9p/mod.c
85380 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85381 void v9fs_register_trans(struct p9_trans_module *m)
85382 {
85383 spin_lock(&v9fs_trans_lock);
85384 - list_add_tail(&m->list, &v9fs_trans_list);
85385 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85386 spin_unlock(&v9fs_trans_lock);
85387 }
85388 EXPORT_SYMBOL(v9fs_register_trans);
85389 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85390 void v9fs_unregister_trans(struct p9_trans_module *m)
85391 {
85392 spin_lock(&v9fs_trans_lock);
85393 - list_del_init(&m->list);
85394 + pax_list_del_init((struct list_head *)&m->list);
85395 spin_unlock(&v9fs_trans_lock);
85396 }
85397 EXPORT_SYMBOL(v9fs_unregister_trans);
85398 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85399 index 02efb25..41541a9 100644
85400 --- a/net/9p/trans_fd.c
85401 +++ b/net/9p/trans_fd.c
85402 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85403 oldfs = get_fs();
85404 set_fs(get_ds());
85405 /* The cast to a user pointer is valid due to the set_fs() */
85406 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85407 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85408 set_fs(oldfs);
85409
85410 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85411 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85412 index 876fbe8..8bbea9f 100644
85413 --- a/net/atm/atm_misc.c
85414 +++ b/net/atm/atm_misc.c
85415 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85416 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85417 return 1;
85418 atm_return(vcc, truesize);
85419 - atomic_inc(&vcc->stats->rx_drop);
85420 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85421 return 0;
85422 }
85423 EXPORT_SYMBOL(atm_charge);
85424 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85425 }
85426 }
85427 atm_return(vcc, guess);
85428 - atomic_inc(&vcc->stats->rx_drop);
85429 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85430 return NULL;
85431 }
85432 EXPORT_SYMBOL(atm_alloc_charge);
85433 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85434
85435 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85436 {
85437 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85438 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85439 __SONET_ITEMS
85440 #undef __HANDLE_ITEM
85441 }
85442 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85443
85444 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85445 {
85446 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85447 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85448 __SONET_ITEMS
85449 #undef __HANDLE_ITEM
85450 }
85451 diff --git a/net/atm/lec.h b/net/atm/lec.h
85452 index a86aff9..3a0d6f6 100644
85453 --- a/net/atm/lec.h
85454 +++ b/net/atm/lec.h
85455 @@ -48,7 +48,7 @@ struct lane2_ops {
85456 const u8 *tlvs, u32 sizeoftlvs);
85457 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85458 const u8 *tlvs, u32 sizeoftlvs);
85459 -};
85460 +} __no_const;
85461
85462 /*
85463 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85464 diff --git a/net/atm/proc.c b/net/atm/proc.c
85465 index 0d020de..011c7bb 100644
85466 --- a/net/atm/proc.c
85467 +++ b/net/atm/proc.c
85468 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85469 const struct k_atm_aal_stats *stats)
85470 {
85471 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85472 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85473 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85474 - atomic_read(&stats->rx_drop));
85475 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85476 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85477 + atomic_read_unchecked(&stats->rx_drop));
85478 }
85479
85480 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85481 diff --git a/net/atm/resources.c b/net/atm/resources.c
85482 index 0447d5d..3cf4728 100644
85483 --- a/net/atm/resources.c
85484 +++ b/net/atm/resources.c
85485 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85486 static void copy_aal_stats(struct k_atm_aal_stats *from,
85487 struct atm_aal_stats *to)
85488 {
85489 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85490 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85491 __AAL_STAT_ITEMS
85492 #undef __HANDLE_ITEM
85493 }
85494 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85495 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85496 struct atm_aal_stats *to)
85497 {
85498 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85499 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85500 __AAL_STAT_ITEMS
85501 #undef __HANDLE_ITEM
85502 }
85503 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85504 index d5744b7..506bae3 100644
85505 --- a/net/ax25/sysctl_net_ax25.c
85506 +++ b/net/ax25/sysctl_net_ax25.c
85507 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85508 {
85509 char path[sizeof("net/ax25/") + IFNAMSIZ];
85510 int k;
85511 - struct ctl_table *table;
85512 + ctl_table_no_const *table;
85513
85514 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85515 if (!table)
85516 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85517 index 1ee94d0..14beea2 100644
85518 --- a/net/batman-adv/bat_iv_ogm.c
85519 +++ b/net/batman-adv/bat_iv_ogm.c
85520 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85521
85522 /* randomize initial seqno to avoid collision */
85523 get_random_bytes(&random_seqno, sizeof(random_seqno));
85524 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85525 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85526
85527 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85528 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85529 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85530 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85531
85532 /* change sequence number to network order */
85533 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85534 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85535 batadv_ogm_packet->seqno = htonl(seqno);
85536 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85537 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85538
85539 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85540 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85541 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85542 return;
85543
85544 /* could be changed by schedule_own_packet() */
85545 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85546 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85547
85548 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85549 has_directlink_flag = 1;
85550 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85551 index f1d37cd..4190879 100644
85552 --- a/net/batman-adv/hard-interface.c
85553 +++ b/net/batman-adv/hard-interface.c
85554 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85555 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85556 dev_add_pack(&hard_iface->batman_adv_ptype);
85557
85558 - atomic_set(&hard_iface->frag_seqno, 1);
85559 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85560 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85561 hard_iface->net_dev->name);
85562
85563 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85564 /* This can't be called via a bat_priv callback because
85565 * we have no bat_priv yet.
85566 */
85567 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85568 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85569 hard_iface->bat_iv.ogm_buff = NULL;
85570
85571 return hard_iface;
85572 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85573 index 6b548fd..fc32c8d 100644
85574 --- a/net/batman-adv/soft-interface.c
85575 +++ b/net/batman-adv/soft-interface.c
85576 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85577 primary_if->net_dev->dev_addr, ETH_ALEN);
85578
85579 /* set broadcast sequence number */
85580 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85581 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85582 bcast_packet->seqno = htonl(seqno);
85583
85584 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85585 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
85586 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85587
85588 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85589 - atomic_set(&bat_priv->bcast_seqno, 1);
85590 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85591 atomic_set(&bat_priv->tt.vn, 0);
85592 atomic_set(&bat_priv->tt.local_changes, 0);
85593 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85594 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85595 index ae9ac9a..11e0fe7 100644
85596 --- a/net/batman-adv/types.h
85597 +++ b/net/batman-adv/types.h
85598 @@ -48,7 +48,7 @@
85599 struct batadv_hard_iface_bat_iv {
85600 unsigned char *ogm_buff;
85601 int ogm_buff_len;
85602 - atomic_t ogm_seqno;
85603 + atomic_unchecked_t ogm_seqno;
85604 };
85605
85606 struct batadv_hard_iface {
85607 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
85608 int16_t if_num;
85609 char if_status;
85610 struct net_device *net_dev;
85611 - atomic_t frag_seqno;
85612 + atomic_unchecked_t frag_seqno;
85613 struct kobject *hardif_obj;
85614 atomic_t refcount;
85615 struct packet_type batman_adv_ptype;
85616 @@ -284,7 +284,7 @@ struct batadv_priv {
85617 atomic_t orig_interval; /* uint */
85618 atomic_t hop_penalty; /* uint */
85619 atomic_t log_level; /* uint */
85620 - atomic_t bcast_seqno;
85621 + atomic_unchecked_t bcast_seqno;
85622 atomic_t bcast_queue_left;
85623 atomic_t batman_queue_left;
85624 char num_ifaces;
85625 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85626 index 10aff49..ea8e021 100644
85627 --- a/net/batman-adv/unicast.c
85628 +++ b/net/batman-adv/unicast.c
85629 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85630 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85631 frag2->flags = large_tail;
85632
85633 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85634 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85635 frag1->seqno = htons(seqno - 1);
85636 frag2->seqno = htons(seqno);
85637
85638 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85639 index 07f0739..3c42e34 100644
85640 --- a/net/bluetooth/hci_sock.c
85641 +++ b/net/bluetooth/hci_sock.c
85642 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85643 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85644 }
85645
85646 - len = min_t(unsigned int, len, sizeof(uf));
85647 + len = min((size_t)len, sizeof(uf));
85648 if (copy_from_user(&uf, optval, len)) {
85649 err = -EFAULT;
85650 break;
85651 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85652 index 22e6583..426e2f3 100644
85653 --- a/net/bluetooth/l2cap_core.c
85654 +++ b/net/bluetooth/l2cap_core.c
85655 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85656 break;
85657
85658 case L2CAP_CONF_RFC:
85659 - if (olen == sizeof(rfc))
85660 - memcpy(&rfc, (void *)val, olen);
85661 + if (olen != sizeof(rfc))
85662 + break;
85663 +
85664 + memcpy(&rfc, (void *)val, olen);
85665
85666 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85667 rfc.mode != chan->mode)
85668 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85669 index 1bcfb84..dad9f98 100644
85670 --- a/net/bluetooth/l2cap_sock.c
85671 +++ b/net/bluetooth/l2cap_sock.c
85672 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85673 struct sock *sk = sock->sk;
85674 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85675 struct l2cap_options opts;
85676 - int len, err = 0;
85677 + int err = 0;
85678 + size_t len = optlen;
85679 u32 opt;
85680
85681 BT_DBG("sk %p", sk);
85682 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85683 opts.max_tx = chan->max_tx;
85684 opts.txwin_size = chan->tx_win;
85685
85686 - len = min_t(unsigned int, sizeof(opts), optlen);
85687 + len = min(sizeof(opts), len);
85688 if (copy_from_user((char *) &opts, optval, len)) {
85689 err = -EFAULT;
85690 break;
85691 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85692 struct bt_security sec;
85693 struct bt_power pwr;
85694 struct l2cap_conn *conn;
85695 - int len, err = 0;
85696 + int err = 0;
85697 + size_t len = optlen;
85698 u32 opt;
85699
85700 BT_DBG("sk %p", sk);
85701 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85702
85703 sec.level = BT_SECURITY_LOW;
85704
85705 - len = min_t(unsigned int, sizeof(sec), optlen);
85706 + len = min(sizeof(sec), len);
85707 if (copy_from_user((char *) &sec, optval, len)) {
85708 err = -EFAULT;
85709 break;
85710 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85711
85712 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85713
85714 - len = min_t(unsigned int, sizeof(pwr), optlen);
85715 + len = min(sizeof(pwr), len);
85716 if (copy_from_user((char *) &pwr, optval, len)) {
85717 err = -EFAULT;
85718 break;
85719 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85720 index 970fc13..cf0161d 100644
85721 --- a/net/bluetooth/rfcomm/sock.c
85722 +++ b/net/bluetooth/rfcomm/sock.c
85723 @@ -668,7 +668,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85724 struct sock *sk = sock->sk;
85725 struct bt_security sec;
85726 int err = 0;
85727 - size_t len;
85728 + size_t len = optlen;
85729 u32 opt;
85730
85731 BT_DBG("sk %p", sk);
85732 @@ -690,7 +690,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85733
85734 sec.level = BT_SECURITY_LOW;
85735
85736 - len = min_t(unsigned int, sizeof(sec), optlen);
85737 + len = min(sizeof(sec), len);
85738 if (copy_from_user((char *) &sec, optval, len)) {
85739 err = -EFAULT;
85740 break;
85741 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85742 index bd6fd0f..6492cba 100644
85743 --- a/net/bluetooth/rfcomm/tty.c
85744 +++ b/net/bluetooth/rfcomm/tty.c
85745 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85746 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85747
85748 spin_lock_irqsave(&dev->port.lock, flags);
85749 - if (dev->port.count > 0) {
85750 + if (atomic_read(&dev->port.count) > 0) {
85751 spin_unlock_irqrestore(&dev->port.lock, flags);
85752 return;
85753 }
85754 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85755 return -ENODEV;
85756
85757 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85758 - dev->channel, dev->port.count);
85759 + dev->channel, atomic_read(&dev->port.count));
85760
85761 spin_lock_irqsave(&dev->port.lock, flags);
85762 - if (++dev->port.count > 1) {
85763 + if (atomic_inc_return(&dev->port.count) > 1) {
85764 spin_unlock_irqrestore(&dev->port.lock, flags);
85765 return 0;
85766 }
85767 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85768 return;
85769
85770 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85771 - dev->port.count);
85772 + atomic_read(&dev->port.count));
85773
85774 spin_lock_irqsave(&dev->port.lock, flags);
85775 - if (!--dev->port.count) {
85776 + if (!atomic_dec_return(&dev->port.count)) {
85777 spin_unlock_irqrestore(&dev->port.lock, flags);
85778 if (dev->tty_dev->parent)
85779 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85780 diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
85781 index d9576e6..85f4f4e 100644
85782 --- a/net/bridge/br_fdb.c
85783 +++ b/net/bridge/br_fdb.c
85784 @@ -386,7 +386,7 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
85785 return 0;
85786 br_warn(br, "adding interface %s with same address "
85787 "as a received packet\n",
85788 - source->dev->name);
85789 + source ? source->dev->name : br->dev->name);
85790 fdb_delete(br, fdb);
85791 }
85792
85793 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85794 index 5fe2ff3..121d696 100644
85795 --- a/net/bridge/netfilter/ebtables.c
85796 +++ b/net/bridge/netfilter/ebtables.c
85797 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85798 tmp.valid_hooks = t->table->valid_hooks;
85799 }
85800 mutex_unlock(&ebt_mutex);
85801 - if (copy_to_user(user, &tmp, *len) != 0){
85802 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85803 BUGPRINT("c2u Didn't work\n");
85804 ret = -EFAULT;
85805 break;
85806 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85807 goto out;
85808 tmp.valid_hooks = t->valid_hooks;
85809
85810 - if (copy_to_user(user, &tmp, *len) != 0) {
85811 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85812 ret = -EFAULT;
85813 break;
85814 }
85815 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85816 tmp.entries_size = t->table->entries_size;
85817 tmp.valid_hooks = t->table->valid_hooks;
85818
85819 - if (copy_to_user(user, &tmp, *len) != 0) {
85820 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85821 ret = -EFAULT;
85822 break;
85823 }
85824 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85825 index a376ec1..1fbd6be 100644
85826 --- a/net/caif/cfctrl.c
85827 +++ b/net/caif/cfctrl.c
85828 @@ -10,6 +10,7 @@
85829 #include <linux/spinlock.h>
85830 #include <linux/slab.h>
85831 #include <linux/pkt_sched.h>
85832 +#include <linux/sched.h>
85833 #include <net/caif/caif_layer.h>
85834 #include <net/caif/cfpkt.h>
85835 #include <net/caif/cfctrl.h>
85836 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85837 memset(&dev_info, 0, sizeof(dev_info));
85838 dev_info.id = 0xff;
85839 cfsrvl_init(&this->serv, 0, &dev_info, false);
85840 - atomic_set(&this->req_seq_no, 1);
85841 - atomic_set(&this->rsp_seq_no, 1);
85842 + atomic_set_unchecked(&this->req_seq_no, 1);
85843 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85844 this->serv.layer.receive = cfctrl_recv;
85845 sprintf(this->serv.layer.name, "ctrl");
85846 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85847 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85848 struct cfctrl_request_info *req)
85849 {
85850 spin_lock_bh(&ctrl->info_list_lock);
85851 - atomic_inc(&ctrl->req_seq_no);
85852 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85853 + atomic_inc_unchecked(&ctrl->req_seq_no);
85854 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85855 list_add_tail(&req->list, &ctrl->list);
85856 spin_unlock_bh(&ctrl->info_list_lock);
85857 }
85858 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85859 if (p != first)
85860 pr_warn("Requests are not received in order\n");
85861
85862 - atomic_set(&ctrl->rsp_seq_no,
85863 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85864 p->sequence_no);
85865 list_del(&p->list);
85866 goto out;
85867 diff --git a/net/can/af_can.c b/net/can/af_can.c
85868 index ddac1ee..3ee0a78 100644
85869 --- a/net/can/af_can.c
85870 +++ b/net/can/af_can.c
85871 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
85872 };
85873
85874 /* notifier block for netdevice event */
85875 -static struct notifier_block can_netdev_notifier __read_mostly = {
85876 +static struct notifier_block can_netdev_notifier = {
85877 .notifier_call = can_notifier,
85878 };
85879
85880 diff --git a/net/can/gw.c b/net/can/gw.c
85881 index 28e7bdc..d42c4cd 100644
85882 --- a/net/can/gw.c
85883 +++ b/net/can/gw.c
85884 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
85885 MODULE_ALIAS("can-gw");
85886
85887 static HLIST_HEAD(cgw_list);
85888 -static struct notifier_block notifier;
85889
85890 static struct kmem_cache *cgw_cache __read_mostly;
85891
85892 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85893 return err;
85894 }
85895
85896 +static struct notifier_block notifier = {
85897 + .notifier_call = cgw_notifier
85898 +};
85899 +
85900 static __init int cgw_module_init(void)
85901 {
85902 printk(banner);
85903 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
85904 return -ENOMEM;
85905
85906 /* set notifier */
85907 - notifier.notifier_call = cgw_notifier;
85908 register_netdevice_notifier(&notifier);
85909
85910 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85911 diff --git a/net/compat.c b/net/compat.c
85912 index 79ae884..17c5c09 100644
85913 --- a/net/compat.c
85914 +++ b/net/compat.c
85915 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85916 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85917 __get_user(kmsg->msg_flags, &umsg->msg_flags))
85918 return -EFAULT;
85919 - kmsg->msg_name = compat_ptr(tmp1);
85920 - kmsg->msg_iov = compat_ptr(tmp2);
85921 - kmsg->msg_control = compat_ptr(tmp3);
85922 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
85923 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
85924 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
85925 return 0;
85926 }
85927
85928 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85929
85930 if (kern_msg->msg_namelen) {
85931 if (mode == VERIFY_READ) {
85932 - int err = move_addr_to_kernel(kern_msg->msg_name,
85933 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
85934 kern_msg->msg_namelen,
85935 kern_address);
85936 if (err < 0)
85937 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85938 kern_msg->msg_name = NULL;
85939
85940 tot_len = iov_from_user_compat_to_kern(kern_iov,
85941 - (struct compat_iovec __user *)kern_msg->msg_iov,
85942 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
85943 kern_msg->msg_iovlen);
85944 if (tot_len >= 0)
85945 kern_msg->msg_iov = kern_iov;
85946 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85947
85948 #define CMSG_COMPAT_FIRSTHDR(msg) \
85949 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
85950 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
85951 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
85952 (struct compat_cmsghdr __user *)NULL)
85953
85954 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
85955 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
85956 (ucmlen) <= (unsigned long) \
85957 ((mhdr)->msg_controllen - \
85958 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
85959 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
85960
85961 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
85962 struct compat_cmsghdr __user *cmsg, int cmsg_len)
85963 {
85964 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
85965 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
85966 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
85967 msg->msg_controllen)
85968 return NULL;
85969 return (struct compat_cmsghdr __user *)ptr;
85970 @@ -219,7 +219,7 @@ Efault:
85971
85972 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
85973 {
85974 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85975 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85976 struct compat_cmsghdr cmhdr;
85977 struct compat_timeval ctv;
85978 struct compat_timespec cts[3];
85979 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
85980
85981 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
85982 {
85983 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85984 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85985 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
85986 int fdnum = scm->fp->count;
85987 struct file **fp = scm->fp->fp;
85988 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
85989 return -EFAULT;
85990 old_fs = get_fs();
85991 set_fs(KERNEL_DS);
85992 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
85993 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
85994 set_fs(old_fs);
85995
85996 return err;
85997 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
85998 len = sizeof(ktime);
85999 old_fs = get_fs();
86000 set_fs(KERNEL_DS);
86001 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
86002 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
86003 set_fs(old_fs);
86004
86005 if (!err) {
86006 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86007 case MCAST_JOIN_GROUP:
86008 case MCAST_LEAVE_GROUP:
86009 {
86010 - struct compat_group_req __user *gr32 = (void *)optval;
86011 + struct compat_group_req __user *gr32 = (void __user *)optval;
86012 struct group_req __user *kgr =
86013 compat_alloc_user_space(sizeof(struct group_req));
86014 u32 interface;
86015 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86016 case MCAST_BLOCK_SOURCE:
86017 case MCAST_UNBLOCK_SOURCE:
86018 {
86019 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86020 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86021 struct group_source_req __user *kgsr = compat_alloc_user_space(
86022 sizeof(struct group_source_req));
86023 u32 interface;
86024 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86025 }
86026 case MCAST_MSFILTER:
86027 {
86028 - struct compat_group_filter __user *gf32 = (void *)optval;
86029 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86030 struct group_filter __user *kgf;
86031 u32 interface, fmode, numsrc;
86032
86033 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86034 char __user *optval, int __user *optlen,
86035 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86036 {
86037 - struct compat_group_filter __user *gf32 = (void *)optval;
86038 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86039 struct group_filter __user *kgf;
86040 int __user *koptlen;
86041 u32 interface, fmode, numsrc;
86042 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86043
86044 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86045 return -EINVAL;
86046 - if (copy_from_user(a, args, nas[call]))
86047 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86048 return -EFAULT;
86049 a0 = a[0];
86050 a1 = a[1];
86051 diff --git a/net/core/datagram.c b/net/core/datagram.c
86052 index 368f9c3..f82d4a3 100644
86053 --- a/net/core/datagram.c
86054 +++ b/net/core/datagram.c
86055 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86056 }
86057
86058 kfree_skb(skb);
86059 - atomic_inc(&sk->sk_drops);
86060 + atomic_inc_unchecked(&sk->sk_drops);
86061 sk_mem_reclaim_partial(sk);
86062
86063 return err;
86064 diff --git a/net/core/dev.c b/net/core/dev.c
86065 index d592214..2764363 100644
86066 --- a/net/core/dev.c
86067 +++ b/net/core/dev.c
86068 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
86069 if (no_module && capable(CAP_NET_ADMIN))
86070 no_module = request_module("netdev-%s", name);
86071 if (no_module && capable(CAP_SYS_MODULE)) {
86072 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86073 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86074 +#else
86075 if (!request_module("%s", name))
86076 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86077 name);
86078 +#endif
86079 }
86080 }
86081 EXPORT_SYMBOL(dev_load);
86082 @@ -1714,7 +1718,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86083 {
86084 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86085 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86086 - atomic_long_inc(&dev->rx_dropped);
86087 + atomic_long_inc_unchecked(&dev->rx_dropped);
86088 kfree_skb(skb);
86089 return NET_RX_DROP;
86090 }
86091 @@ -1724,7 +1728,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86092 nf_reset(skb);
86093
86094 if (unlikely(!is_skb_forwardable(dev, skb))) {
86095 - atomic_long_inc(&dev->rx_dropped);
86096 + atomic_long_inc_unchecked(&dev->rx_dropped);
86097 kfree_skb(skb);
86098 return NET_RX_DROP;
86099 }
86100 @@ -2183,7 +2187,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86101
86102 struct dev_gso_cb {
86103 void (*destructor)(struct sk_buff *skb);
86104 -};
86105 +} __no_const;
86106
86107 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86108
86109 @@ -3056,7 +3060,7 @@ enqueue:
86110
86111 local_irq_restore(flags);
86112
86113 - atomic_long_inc(&skb->dev->rx_dropped);
86114 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86115 kfree_skb(skb);
86116 return NET_RX_DROP;
86117 }
86118 @@ -3128,7 +3132,7 @@ int netif_rx_ni(struct sk_buff *skb)
86119 }
86120 EXPORT_SYMBOL(netif_rx_ni);
86121
86122 -static void net_tx_action(struct softirq_action *h)
86123 +static void net_tx_action(void)
86124 {
86125 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86126
86127 @@ -3466,7 +3470,7 @@ ncls:
86128 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86129 } else {
86130 drop:
86131 - atomic_long_inc(&skb->dev->rx_dropped);
86132 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86133 kfree_skb(skb);
86134 /* Jamal, now you will not able to escape explaining
86135 * me how you were going to use this. :-)
86136 @@ -4049,7 +4053,7 @@ void netif_napi_del(struct napi_struct *napi)
86137 }
86138 EXPORT_SYMBOL(netif_napi_del);
86139
86140 -static void net_rx_action(struct softirq_action *h)
86141 +static void net_rx_action(void)
86142 {
86143 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86144 unsigned long time_limit = jiffies + 2;
86145 @@ -4533,8 +4537,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86146 else
86147 seq_printf(seq, "%04x", ntohs(pt->type));
86148
86149 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86150 + seq_printf(seq, " %-8s %p\n",
86151 + pt->dev ? pt->dev->name : "", NULL);
86152 +#else
86153 seq_printf(seq, " %-8s %pF\n",
86154 pt->dev ? pt->dev->name : "", pt->func);
86155 +#endif
86156 }
86157
86158 return 0;
86159 @@ -6106,7 +6115,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86160 } else {
86161 netdev_stats_to_stats64(storage, &dev->stats);
86162 }
86163 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86164 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86165 return storage;
86166 }
86167 EXPORT_SYMBOL(dev_get_stats);
86168 diff --git a/net/core/flow.c b/net/core/flow.c
86169 index 3bad824..2071a55 100644
86170 --- a/net/core/flow.c
86171 +++ b/net/core/flow.c
86172 @@ -61,7 +61,7 @@ struct flow_cache {
86173 struct timer_list rnd_timer;
86174 };
86175
86176 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86177 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86178 EXPORT_SYMBOL(flow_cache_genid);
86179 static struct flow_cache flow_cache_global;
86180 static struct kmem_cache *flow_cachep __read_mostly;
86181 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86182
86183 static int flow_entry_valid(struct flow_cache_entry *fle)
86184 {
86185 - if (atomic_read(&flow_cache_genid) != fle->genid)
86186 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86187 return 0;
86188 if (fle->object && !fle->object->ops->check(fle->object))
86189 return 0;
86190 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86191 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86192 fcp->hash_count++;
86193 }
86194 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86195 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86196 flo = fle->object;
86197 if (!flo)
86198 goto ret_object;
86199 @@ -280,7 +280,7 @@ nocache:
86200 }
86201 flo = resolver(net, key, family, dir, flo, ctx);
86202 if (fle) {
86203 - fle->genid = atomic_read(&flow_cache_genid);
86204 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86205 if (!IS_ERR(flo))
86206 fle->object = flo;
86207 else
86208 diff --git a/net/core/iovec.c b/net/core/iovec.c
86209 index 7e7aeb0..2a998cb 100644
86210 --- a/net/core/iovec.c
86211 +++ b/net/core/iovec.c
86212 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86213 if (m->msg_namelen) {
86214 if (mode == VERIFY_READ) {
86215 void __user *namep;
86216 - namep = (void __user __force *) m->msg_name;
86217 + namep = (void __force_user *) m->msg_name;
86218 err = move_addr_to_kernel(namep, m->msg_namelen,
86219 address);
86220 if (err < 0)
86221 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86222 }
86223
86224 size = m->msg_iovlen * sizeof(struct iovec);
86225 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86226 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86227 return -EFAULT;
86228
86229 m->msg_iov = iov;
86230 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86231 index c815f28..e6403f2 100644
86232 --- a/net/core/neighbour.c
86233 +++ b/net/core/neighbour.c
86234 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86235 size_t *lenp, loff_t *ppos)
86236 {
86237 int size, ret;
86238 - ctl_table tmp = *ctl;
86239 + ctl_table_no_const tmp = *ctl;
86240
86241 tmp.extra1 = &zero;
86242 tmp.extra2 = &unres_qlen_max;
86243 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86244 index 28c5f5a..7edf2e2 100644
86245 --- a/net/core/net-sysfs.c
86246 +++ b/net/core/net-sysfs.c
86247 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86248 }
86249 EXPORT_SYMBOL(netdev_class_remove_file);
86250
86251 -int netdev_kobject_init(void)
86252 +int __init netdev_kobject_init(void)
86253 {
86254 kobj_ns_type_register(&net_ns_type_operations);
86255 return class_register(&net_class);
86256 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86257 index 8acce01..2e306bb 100644
86258 --- a/net/core/net_namespace.c
86259 +++ b/net/core/net_namespace.c
86260 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86261 int error;
86262 LIST_HEAD(net_exit_list);
86263
86264 - list_add_tail(&ops->list, list);
86265 + pax_list_add_tail((struct list_head *)&ops->list, list);
86266 if (ops->init || (ops->id && ops->size)) {
86267 for_each_net(net) {
86268 error = ops_init(ops, net);
86269 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86270
86271 out_undo:
86272 /* If I have an error cleanup all namespaces I initialized */
86273 - list_del(&ops->list);
86274 + pax_list_del((struct list_head *)&ops->list);
86275 ops_exit_list(ops, &net_exit_list);
86276 ops_free_list(ops, &net_exit_list);
86277 return error;
86278 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86279 struct net *net;
86280 LIST_HEAD(net_exit_list);
86281
86282 - list_del(&ops->list);
86283 + pax_list_del((struct list_head *)&ops->list);
86284 for_each_net(net)
86285 list_add_tail(&net->exit_list, &net_exit_list);
86286 ops_exit_list(ops, &net_exit_list);
86287 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86288 mutex_lock(&net_mutex);
86289 error = register_pernet_operations(&pernet_list, ops);
86290 if (!error && (first_device == &pernet_list))
86291 - first_device = &ops->list;
86292 + first_device = (struct list_head *)&ops->list;
86293 mutex_unlock(&net_mutex);
86294 return error;
86295 }
86296 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86297 index 055fb13..5ee16b2 100644
86298 --- a/net/core/rtnetlink.c
86299 +++ b/net/core/rtnetlink.c
86300 @@ -58,7 +58,7 @@ struct rtnl_link {
86301 rtnl_doit_func doit;
86302 rtnl_dumpit_func dumpit;
86303 rtnl_calcit_func calcit;
86304 -};
86305 +} __no_const;
86306
86307 static DEFINE_MUTEX(rtnl_mutex);
86308
86309 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86310 if (rtnl_link_ops_get(ops->kind))
86311 return -EEXIST;
86312
86313 - if (!ops->dellink)
86314 - ops->dellink = unregister_netdevice_queue;
86315 + if (!ops->dellink) {
86316 + pax_open_kernel();
86317 + *(void **)&ops->dellink = unregister_netdevice_queue;
86318 + pax_close_kernel();
86319 + }
86320
86321 - list_add_tail(&ops->list, &link_ops);
86322 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86323 return 0;
86324 }
86325 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86326 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86327 for_each_net(net) {
86328 __rtnl_kill_links(net, ops);
86329 }
86330 - list_del(&ops->list);
86331 + pax_list_del((struct list_head *)&ops->list);
86332 }
86333 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86334
86335 diff --git a/net/core/scm.c b/net/core/scm.c
86336 index 2dc6cda..2159524 100644
86337 --- a/net/core/scm.c
86338 +++ b/net/core/scm.c
86339 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86340 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86341 {
86342 struct cmsghdr __user *cm
86343 - = (__force struct cmsghdr __user *)msg->msg_control;
86344 + = (struct cmsghdr __force_user *)msg->msg_control;
86345 struct cmsghdr cmhdr;
86346 int cmlen = CMSG_LEN(len);
86347 int err;
86348 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86349 err = -EFAULT;
86350 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86351 goto out;
86352 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86353 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86354 goto out;
86355 cmlen = CMSG_SPACE(len);
86356 if (msg->msg_controllen < cmlen)
86357 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86358 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86359 {
86360 struct cmsghdr __user *cm
86361 - = (__force struct cmsghdr __user*)msg->msg_control;
86362 + = (struct cmsghdr __force_user *)msg->msg_control;
86363
86364 int fdmax = 0;
86365 int fdnum = scm->fp->count;
86366 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86367 if (fdnum < fdmax)
86368 fdmax = fdnum;
86369
86370 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86371 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86372 i++, cmfptr++)
86373 {
86374 struct socket *sock;
86375 diff --git a/net/core/sock.c b/net/core/sock.c
86376 index bc131d4..029e378 100644
86377 --- a/net/core/sock.c
86378 +++ b/net/core/sock.c
86379 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86380 struct sk_buff_head *list = &sk->sk_receive_queue;
86381
86382 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86383 - atomic_inc(&sk->sk_drops);
86384 + atomic_inc_unchecked(&sk->sk_drops);
86385 trace_sock_rcvqueue_full(sk, skb);
86386 return -ENOMEM;
86387 }
86388 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86389 return err;
86390
86391 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86392 - atomic_inc(&sk->sk_drops);
86393 + atomic_inc_unchecked(&sk->sk_drops);
86394 return -ENOBUFS;
86395 }
86396
86397 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86398 skb_dst_force(skb);
86399
86400 spin_lock_irqsave(&list->lock, flags);
86401 - skb->dropcount = atomic_read(&sk->sk_drops);
86402 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86403 __skb_queue_tail(list, skb);
86404 spin_unlock_irqrestore(&list->lock, flags);
86405
86406 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86407 skb->dev = NULL;
86408
86409 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86410 - atomic_inc(&sk->sk_drops);
86411 + atomic_inc_unchecked(&sk->sk_drops);
86412 goto discard_and_relse;
86413 }
86414 if (nested)
86415 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86416 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86417 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86418 bh_unlock_sock(sk);
86419 - atomic_inc(&sk->sk_drops);
86420 + atomic_inc_unchecked(&sk->sk_drops);
86421 goto discard_and_relse;
86422 }
86423
86424 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86425 struct timeval tm;
86426 } v;
86427
86428 - int lv = sizeof(int);
86429 - int len;
86430 + unsigned int lv = sizeof(int);
86431 + unsigned int len;
86432
86433 if (get_user(len, optlen))
86434 return -EFAULT;
86435 - if (len < 0)
86436 + if (len > INT_MAX)
86437 return -EINVAL;
86438
86439 memset(&v, 0, sizeof(v));
86440 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86441
86442 case SO_PEERNAME:
86443 {
86444 - char address[128];
86445 + char address[_K_SS_MAXSIZE];
86446
86447 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86448 return -ENOTCONN;
86449 - if (lv < len)
86450 + if (lv < len || sizeof address < len)
86451 return -EINVAL;
86452 if (copy_to_user(optval, address, len))
86453 return -EFAULT;
86454 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86455
86456 if (len > lv)
86457 len = lv;
86458 - if (copy_to_user(optval, &v, len))
86459 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86460 return -EFAULT;
86461 lenout:
86462 if (put_user(len, optlen))
86463 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86464 */
86465 smp_wmb();
86466 atomic_set(&sk->sk_refcnt, 1);
86467 - atomic_set(&sk->sk_drops, 0);
86468 + atomic_set_unchecked(&sk->sk_drops, 0);
86469 }
86470 EXPORT_SYMBOL(sock_init_data);
86471
86472 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86473 index 750f44f..922399c 100644
86474 --- a/net/core/sock_diag.c
86475 +++ b/net/core/sock_diag.c
86476 @@ -9,26 +9,33 @@
86477 #include <linux/inet_diag.h>
86478 #include <linux/sock_diag.h>
86479
86480 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86481 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86482 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86483 static DEFINE_MUTEX(sock_diag_table_mutex);
86484
86485 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86486 {
86487 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86488 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86489 cookie[1] != INET_DIAG_NOCOOKIE) &&
86490 ((u32)(unsigned long)sk != cookie[0] ||
86491 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86492 return -ESTALE;
86493 else
86494 +#endif
86495 return 0;
86496 }
86497 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86498
86499 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86500 {
86501 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86502 + cookie[0] = 0;
86503 + cookie[1] = 0;
86504 +#else
86505 cookie[0] = (u32)(unsigned long)sk;
86506 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86507 +#endif
86508 }
86509 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86510
86511 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86512 mutex_lock(&sock_diag_table_mutex);
86513 if (sock_diag_handlers[hndl->family])
86514 err = -EBUSY;
86515 - else
86516 + else {
86517 + pax_open_kernel();
86518 sock_diag_handlers[hndl->family] = hndl;
86519 + pax_close_kernel();
86520 + }
86521 mutex_unlock(&sock_diag_table_mutex);
86522
86523 return err;
86524 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86525
86526 mutex_lock(&sock_diag_table_mutex);
86527 BUG_ON(sock_diag_handlers[family] != hnld);
86528 + pax_open_kernel();
86529 sock_diag_handlers[family] = NULL;
86530 + pax_close_kernel();
86531 mutex_unlock(&sock_diag_table_mutex);
86532 }
86533 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86534
86535 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
86536 -{
86537 - if (sock_diag_handlers[family] == NULL)
86538 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86539 - NETLINK_SOCK_DIAG, family);
86540 -
86541 - mutex_lock(&sock_diag_table_mutex);
86542 - return sock_diag_handlers[family];
86543 -}
86544 -
86545 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
86546 -{
86547 - mutex_unlock(&sock_diag_table_mutex);
86548 -}
86549 -
86550 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86551 {
86552 int err;
86553 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86554 if (req->sdiag_family >= AF_MAX)
86555 return -EINVAL;
86556
86557 - hndl = sock_diag_lock_handler(req->sdiag_family);
86558 + if (sock_diag_handlers[req->sdiag_family] == NULL)
86559 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86560 + NETLINK_SOCK_DIAG, req->sdiag_family);
86561 +
86562 + mutex_lock(&sock_diag_table_mutex);
86563 + hndl = sock_diag_handlers[req->sdiag_family];
86564 if (hndl == NULL)
86565 err = -ENOENT;
86566 else
86567 err = hndl->dump(skb, nlh);
86568 - sock_diag_unlock_handler(hndl);
86569 + mutex_unlock(&sock_diag_table_mutex);
86570
86571 return err;
86572 }
86573 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86574 index d1b0804..98cf5f7 100644
86575 --- a/net/core/sysctl_net_core.c
86576 +++ b/net/core/sysctl_net_core.c
86577 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86578 {
86579 unsigned int orig_size, size;
86580 int ret, i;
86581 - ctl_table tmp = {
86582 + ctl_table_no_const tmp = {
86583 .data = &size,
86584 .maxlen = sizeof(size),
86585 .mode = table->mode
86586 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
86587
86588 static __net_init int sysctl_core_net_init(struct net *net)
86589 {
86590 - struct ctl_table *tbl;
86591 + ctl_table_no_const *tbl = NULL;
86592
86593 net->core.sysctl_somaxconn = SOMAXCONN;
86594
86595 - tbl = netns_core_table;
86596 if (!net_eq(net, &init_net)) {
86597 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86598 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86599 if (tbl == NULL)
86600 goto err_dup;
86601
86602 @@ -221,17 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86603 if (net->user_ns != &init_user_ns) {
86604 tbl[0].procname = NULL;
86605 }
86606 - }
86607 -
86608 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86609 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86610 + } else
86611 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86612 if (net->core.sysctl_hdr == NULL)
86613 goto err_reg;
86614
86615 return 0;
86616
86617 err_reg:
86618 - if (tbl != netns_core_table)
86619 - kfree(tbl);
86620 + kfree(tbl);
86621 err_dup:
86622 return -ENOMEM;
86623 }
86624 @@ -246,7 +244,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86625 kfree(tbl);
86626 }
86627
86628 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86629 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86630 .init = sysctl_core_net_init,
86631 .exit = sysctl_core_net_exit,
86632 };
86633 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86634 index 307c322..78a4c6f 100644
86635 --- a/net/decnet/af_decnet.c
86636 +++ b/net/decnet/af_decnet.c
86637 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
86638 .sysctl_rmem = sysctl_decnet_rmem,
86639 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86640 .obj_size = sizeof(struct dn_sock),
86641 + .slab_flags = SLAB_USERCOPY,
86642 };
86643
86644 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86645 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86646 index a55eecc..dd8428c 100644
86647 --- a/net/decnet/sysctl_net_decnet.c
86648 +++ b/net/decnet/sysctl_net_decnet.c
86649 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86650
86651 if (len > *lenp) len = *lenp;
86652
86653 - if (copy_to_user(buffer, addr, len))
86654 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86655 return -EFAULT;
86656
86657 *lenp = len;
86658 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86659
86660 if (len > *lenp) len = *lenp;
86661
86662 - if (copy_to_user(buffer, devname, len))
86663 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86664 return -EFAULT;
86665
86666 *lenp = len;
86667 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86668 index fcf104e..95552d4 100644
86669 --- a/net/ipv4/af_inet.c
86670 +++ b/net/ipv4/af_inet.c
86671 @@ -1717,13 +1717,9 @@ static int __init inet_init(void)
86672
86673 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
86674
86675 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86676 - if (!sysctl_local_reserved_ports)
86677 - goto out;
86678 -
86679 rc = proto_register(&tcp_prot, 1);
86680 if (rc)
86681 - goto out_free_reserved_ports;
86682 + goto out;
86683
86684 rc = proto_register(&udp_prot, 1);
86685 if (rc)
86686 @@ -1832,8 +1828,6 @@ out_unregister_udp_proto:
86687 proto_unregister(&udp_prot);
86688 out_unregister_tcp_proto:
86689 proto_unregister(&tcp_prot);
86690 -out_free_reserved_ports:
86691 - kfree(sysctl_local_reserved_ports);
86692 goto out;
86693 }
86694
86695 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86696 index a69b4e4..dbccba5 100644
86697 --- a/net/ipv4/ah4.c
86698 +++ b/net/ipv4/ah4.c
86699 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86700 return;
86701
86702 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86703 - atomic_inc(&flow_cache_genid);
86704 + atomic_inc_unchecked(&flow_cache_genid);
86705 rt_genid_bump(net);
86706
86707 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86708 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86709 index a8e4f26..25e5f40 100644
86710 --- a/net/ipv4/devinet.c
86711 +++ b/net/ipv4/devinet.c
86712 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86713 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86714 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86715
86716 -static struct devinet_sysctl_table {
86717 +static const struct devinet_sysctl_table {
86718 struct ctl_table_header *sysctl_header;
86719 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86720 } devinet_sysctl = {
86721 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
86722 int err;
86723 struct ipv4_devconf *all, *dflt;
86724 #ifdef CONFIG_SYSCTL
86725 - struct ctl_table *tbl = ctl_forward_entry;
86726 + ctl_table_no_const *tbl = NULL;
86727 struct ctl_table_header *forw_hdr;
86728 #endif
86729
86730 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
86731 goto err_alloc_dflt;
86732
86733 #ifdef CONFIG_SYSCTL
86734 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86735 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86736 if (tbl == NULL)
86737 goto err_alloc_ctl;
86738
86739 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
86740 goto err_reg_dflt;
86741
86742 err = -ENOMEM;
86743 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86744 + if (!net_eq(net, &init_net))
86745 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86746 + else
86747 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86748 if (forw_hdr == NULL)
86749 goto err_reg_ctl;
86750 net->ipv4.forw_hdr = forw_hdr;
86751 @@ -1935,8 +1938,7 @@ err_reg_ctl:
86752 err_reg_dflt:
86753 __devinet_sysctl_unregister(all);
86754 err_reg_all:
86755 - if (tbl != ctl_forward_entry)
86756 - kfree(tbl);
86757 + kfree(tbl);
86758 err_alloc_ctl:
86759 #endif
86760 if (dflt != &ipv4_devconf_dflt)
86761 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86762 index 4cfe34d..a6ba66e 100644
86763 --- a/net/ipv4/esp4.c
86764 +++ b/net/ipv4/esp4.c
86765 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86766 return;
86767
86768 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86769 - atomic_inc(&flow_cache_genid);
86770 + atomic_inc_unchecked(&flow_cache_genid);
86771 rt_genid_bump(net);
86772
86773 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86774 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86775 index 5cd75e2..f57ef39 100644
86776 --- a/net/ipv4/fib_frontend.c
86777 +++ b/net/ipv4/fib_frontend.c
86778 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86779 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86780 fib_sync_up(dev);
86781 #endif
86782 - atomic_inc(&net->ipv4.dev_addr_genid);
86783 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86784 rt_cache_flush(dev_net(dev));
86785 break;
86786 case NETDEV_DOWN:
86787 fib_del_ifaddr(ifa, NULL);
86788 - atomic_inc(&net->ipv4.dev_addr_genid);
86789 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86790 if (ifa->ifa_dev->ifa_list == NULL) {
86791 /* Last address was deleted from this interface.
86792 * Disable IP.
86793 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86794 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86795 fib_sync_up(dev);
86796 #endif
86797 - atomic_inc(&net->ipv4.dev_addr_genid);
86798 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86799 rt_cache_flush(net);
86800 break;
86801 case NETDEV_DOWN:
86802 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86803 index 4797a80..2bd54e9 100644
86804 --- a/net/ipv4/fib_semantics.c
86805 +++ b/net/ipv4/fib_semantics.c
86806 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86807 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86808 nh->nh_gw,
86809 nh->nh_parent->fib_scope);
86810 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86811 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86812
86813 return nh->nh_saddr;
86814 }
86815 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86816 index d0670f0..744ac80 100644
86817 --- a/net/ipv4/inet_connection_sock.c
86818 +++ b/net/ipv4/inet_connection_sock.c
86819 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86820 .range = { 32768, 61000 },
86821 };
86822
86823 -unsigned long *sysctl_local_reserved_ports;
86824 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86825 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86826
86827 void inet_get_local_port_range(int *low, int *high)
86828 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86829 index fa3ae81..0dbe6b8 100644
86830 --- a/net/ipv4/inet_hashtables.c
86831 +++ b/net/ipv4/inet_hashtables.c
86832 @@ -18,12 +18,15 @@
86833 #include <linux/sched.h>
86834 #include <linux/slab.h>
86835 #include <linux/wait.h>
86836 +#include <linux/security.h>
86837
86838 #include <net/inet_connection_sock.h>
86839 #include <net/inet_hashtables.h>
86840 #include <net/secure_seq.h>
86841 #include <net/ip.h>
86842
86843 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86844 +
86845 /*
86846 * Allocate and initialize a new local port bind bucket.
86847 * The bindhash mutex for snum's hash chain must be held here.
86848 @@ -540,6 +543,8 @@ ok:
86849 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86850 spin_unlock(&head->lock);
86851
86852 + gr_update_task_in_ip_table(current, inet_sk(sk));
86853 +
86854 if (tw) {
86855 inet_twsk_deschedule(tw, death_row);
86856 while (twrefcnt) {
86857 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86858 index 000e3d2..5472da3 100644
86859 --- a/net/ipv4/inetpeer.c
86860 +++ b/net/ipv4/inetpeer.c
86861 @@ -503,8 +503,8 @@ relookup:
86862 if (p) {
86863 p->daddr = *daddr;
86864 atomic_set(&p->refcnt, 1);
86865 - atomic_set(&p->rid, 0);
86866 - atomic_set(&p->ip_id_count,
86867 + atomic_set_unchecked(&p->rid, 0);
86868 + atomic_set_unchecked(&p->ip_id_count,
86869 (daddr->family == AF_INET) ?
86870 secure_ip_id(daddr->addr.a4) :
86871 secure_ipv6_id(daddr->addr.a6));
86872 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86873 index 0fcfee3..66e86c9 100644
86874 --- a/net/ipv4/ip_fragment.c
86875 +++ b/net/ipv4/ip_fragment.c
86876 @@ -318,7 +318,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86877 return 0;
86878
86879 start = qp->rid;
86880 - end = atomic_inc_return(&peer->rid);
86881 + end = atomic_inc_return_unchecked(&peer->rid);
86882 qp->rid = end;
86883
86884 rc = qp->q.fragments && (end - start) > max;
86885 @@ -793,12 +793,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
86886
86887 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86888 {
86889 - struct ctl_table *table;
86890 + ctl_table_no_const *table = NULL;
86891 struct ctl_table_header *hdr;
86892
86893 - table = ip4_frags_ns_ctl_table;
86894 if (!net_eq(net, &init_net)) {
86895 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86896 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86897 if (table == NULL)
86898 goto err_alloc;
86899
86900 @@ -809,9 +808,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86901 /* Don't export sysctls to unprivileged users */
86902 if (net->user_ns != &init_user_ns)
86903 table[0].procname = NULL;
86904 - }
86905 + hdr = register_net_sysctl(net, "net/ipv4", table);
86906 + } else
86907 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
86908
86909 - hdr = register_net_sysctl(net, "net/ipv4", table);
86910 if (hdr == NULL)
86911 goto err_reg;
86912
86913 @@ -819,8 +819,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86914 return 0;
86915
86916 err_reg:
86917 - if (!net_eq(net, &init_net))
86918 - kfree(table);
86919 + kfree(table);
86920 err_alloc:
86921 return -ENOMEM;
86922 }
86923 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
86924 index a85062b..2958a9b 100644
86925 --- a/net/ipv4/ip_gre.c
86926 +++ b/net/ipv4/ip_gre.c
86927 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
86928 module_param(log_ecn_error, bool, 0644);
86929 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86930
86931 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
86932 +static struct rtnl_link_ops ipgre_link_ops;
86933 static int ipgre_tunnel_init(struct net_device *dev);
86934 static void ipgre_tunnel_setup(struct net_device *dev);
86935 static int ipgre_tunnel_bind_dev(struct net_device *dev);
86936 @@ -1753,7 +1753,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
86937 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
86938 };
86939
86940 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86941 +static struct rtnl_link_ops ipgre_link_ops = {
86942 .kind = "gre",
86943 .maxtype = IFLA_GRE_MAX,
86944 .policy = ipgre_policy,
86945 @@ -1766,7 +1766,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86946 .fill_info = ipgre_fill_info,
86947 };
86948
86949 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
86950 +static struct rtnl_link_ops ipgre_tap_ops = {
86951 .kind = "gretap",
86952 .maxtype = IFLA_GRE_MAX,
86953 .policy = ipgre_policy,
86954 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
86955 index d9c4f11..02b82dbc 100644
86956 --- a/net/ipv4/ip_sockglue.c
86957 +++ b/net/ipv4/ip_sockglue.c
86958 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86959 len = min_t(unsigned int, len, opt->optlen);
86960 if (put_user(len, optlen))
86961 return -EFAULT;
86962 - if (copy_to_user(optval, opt->__data, len))
86963 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
86964 + copy_to_user(optval, opt->__data, len))
86965 return -EFAULT;
86966 return 0;
86967 }
86968 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86969 if (sk->sk_type != SOCK_STREAM)
86970 return -ENOPROTOOPT;
86971
86972 - msg.msg_control = optval;
86973 + msg.msg_control = (void __force_kernel *)optval;
86974 msg.msg_controllen = len;
86975 msg.msg_flags = flags;
86976
86977 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
86978 index c3a4233..1412161 100644
86979 --- a/net/ipv4/ip_vti.c
86980 +++ b/net/ipv4/ip_vti.c
86981 @@ -47,7 +47,7 @@
86982 #define HASH_SIZE 16
86983 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
86984
86985 -static struct rtnl_link_ops vti_link_ops __read_mostly;
86986 +static struct rtnl_link_ops vti_link_ops;
86987
86988 static int vti_net_id __read_mostly;
86989 struct vti_net {
86990 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
86991 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
86992 };
86993
86994 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
86995 +static struct rtnl_link_ops vti_link_ops = {
86996 .kind = "vti",
86997 .maxtype = IFLA_VTI_MAX,
86998 .policy = vti_policy,
86999 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87000 index 9a46dae..5f793a0 100644
87001 --- a/net/ipv4/ipcomp.c
87002 +++ b/net/ipv4/ipcomp.c
87003 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87004 return;
87005
87006 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87007 - atomic_inc(&flow_cache_genid);
87008 + atomic_inc_unchecked(&flow_cache_genid);
87009 rt_genid_bump(net);
87010
87011 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87012 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87013 index a2e50ae..e152b7c 100644
87014 --- a/net/ipv4/ipconfig.c
87015 +++ b/net/ipv4/ipconfig.c
87016 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87017
87018 mm_segment_t oldfs = get_fs();
87019 set_fs(get_ds());
87020 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87021 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87022 set_fs(oldfs);
87023 return res;
87024 }
87025 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87026
87027 mm_segment_t oldfs = get_fs();
87028 set_fs(get_ds());
87029 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87030 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87031 set_fs(oldfs);
87032 return res;
87033 }
87034 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87035
87036 mm_segment_t oldfs = get_fs();
87037 set_fs(get_ds());
87038 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87039 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87040 set_fs(oldfs);
87041 return res;
87042 }
87043 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87044 index 191fc24..1b3b804 100644
87045 --- a/net/ipv4/ipip.c
87046 +++ b/net/ipv4/ipip.c
87047 @@ -138,7 +138,7 @@ struct ipip_net {
87048 static int ipip_tunnel_init(struct net_device *dev);
87049 static void ipip_tunnel_setup(struct net_device *dev);
87050 static void ipip_dev_free(struct net_device *dev);
87051 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87052 +static struct rtnl_link_ops ipip_link_ops;
87053
87054 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
87055 struct rtnl_link_stats64 *tot)
87056 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87057 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87058 };
87059
87060 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87061 +static struct rtnl_link_ops ipip_link_ops = {
87062 .kind = "ipip",
87063 .maxtype = IFLA_IPTUN_MAX,
87064 .policy = ipip_policy,
87065 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87066 index 3ea4127..849297b 100644
87067 --- a/net/ipv4/netfilter/arp_tables.c
87068 +++ b/net/ipv4/netfilter/arp_tables.c
87069 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
87070 #endif
87071
87072 static int get_info(struct net *net, void __user *user,
87073 - const int *len, int compat)
87074 + int len, int compat)
87075 {
87076 char name[XT_TABLE_MAXNAMELEN];
87077 struct xt_table *t;
87078 int ret;
87079
87080 - if (*len != sizeof(struct arpt_getinfo)) {
87081 - duprintf("length %u != %Zu\n", *len,
87082 + if (len != sizeof(struct arpt_getinfo)) {
87083 + duprintf("length %u != %Zu\n", len,
87084 sizeof(struct arpt_getinfo));
87085 return -EINVAL;
87086 }
87087 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
87088 info.size = private->size;
87089 strcpy(info.name, name);
87090
87091 - if (copy_to_user(user, &info, *len) != 0)
87092 + if (copy_to_user(user, &info, len) != 0)
87093 ret = -EFAULT;
87094 else
87095 ret = 0;
87096 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87097
87098 switch (cmd) {
87099 case ARPT_SO_GET_INFO:
87100 - ret = get_info(sock_net(sk), user, len, 1);
87101 + ret = get_info(sock_net(sk), user, *len, 1);
87102 break;
87103 case ARPT_SO_GET_ENTRIES:
87104 ret = compat_get_entries(sock_net(sk), user, len);
87105 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87106
87107 switch (cmd) {
87108 case ARPT_SO_GET_INFO:
87109 - ret = get_info(sock_net(sk), user, len, 0);
87110 + ret = get_info(sock_net(sk), user, *len, 0);
87111 break;
87112
87113 case ARPT_SO_GET_ENTRIES:
87114 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87115 index 17c5e06..1b91206 100644
87116 --- a/net/ipv4/netfilter/ip_tables.c
87117 +++ b/net/ipv4/netfilter/ip_tables.c
87118 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87119 #endif
87120
87121 static int get_info(struct net *net, void __user *user,
87122 - const int *len, int compat)
87123 + int len, int compat)
87124 {
87125 char name[XT_TABLE_MAXNAMELEN];
87126 struct xt_table *t;
87127 int ret;
87128
87129 - if (*len != sizeof(struct ipt_getinfo)) {
87130 - duprintf("length %u != %zu\n", *len,
87131 + if (len != sizeof(struct ipt_getinfo)) {
87132 + duprintf("length %u != %zu\n", len,
87133 sizeof(struct ipt_getinfo));
87134 return -EINVAL;
87135 }
87136 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87137 info.size = private->size;
87138 strcpy(info.name, name);
87139
87140 - if (copy_to_user(user, &info, *len) != 0)
87141 + if (copy_to_user(user, &info, len) != 0)
87142 ret = -EFAULT;
87143 else
87144 ret = 0;
87145 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87146
87147 switch (cmd) {
87148 case IPT_SO_GET_INFO:
87149 - ret = get_info(sock_net(sk), user, len, 1);
87150 + ret = get_info(sock_net(sk), user, *len, 1);
87151 break;
87152 case IPT_SO_GET_ENTRIES:
87153 ret = compat_get_entries(sock_net(sk), user, len);
87154 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87155
87156 switch (cmd) {
87157 case IPT_SO_GET_INFO:
87158 - ret = get_info(sock_net(sk), user, len, 0);
87159 + ret = get_info(sock_net(sk), user, *len, 0);
87160 break;
87161
87162 case IPT_SO_GET_ENTRIES:
87163 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87164 index dc454cc..5bb917f 100644
87165 --- a/net/ipv4/ping.c
87166 +++ b/net/ipv4/ping.c
87167 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87168 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87169 0, sock_i_ino(sp),
87170 atomic_read(&sp->sk_refcnt), sp,
87171 - atomic_read(&sp->sk_drops), len);
87172 + atomic_read_unchecked(&sp->sk_drops), len);
87173 }
87174
87175 static int ping_seq_show(struct seq_file *seq, void *v)
87176 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87177 index 6f08991..55867ad 100644
87178 --- a/net/ipv4/raw.c
87179 +++ b/net/ipv4/raw.c
87180 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87181 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87182 {
87183 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87184 - atomic_inc(&sk->sk_drops);
87185 + atomic_inc_unchecked(&sk->sk_drops);
87186 kfree_skb(skb);
87187 return NET_RX_DROP;
87188 }
87189 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
87190
87191 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87192 {
87193 + struct icmp_filter filter;
87194 +
87195 if (optlen > sizeof(struct icmp_filter))
87196 optlen = sizeof(struct icmp_filter);
87197 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87198 + if (copy_from_user(&filter, optval, optlen))
87199 return -EFAULT;
87200 + raw_sk(sk)->filter = filter;
87201 return 0;
87202 }
87203
87204 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87205 {
87206 int len, ret = -EFAULT;
87207 + struct icmp_filter filter;
87208
87209 if (get_user(len, optlen))
87210 goto out;
87211 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87212 if (len > sizeof(struct icmp_filter))
87213 len = sizeof(struct icmp_filter);
87214 ret = -EFAULT;
87215 - if (put_user(len, optlen) ||
87216 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87217 + filter = raw_sk(sk)->filter;
87218 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87219 goto out;
87220 ret = 0;
87221 out: return ret;
87222 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87223 0, 0L, 0,
87224 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87225 0, sock_i_ino(sp),
87226 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87227 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87228 }
87229
87230 static int raw_seq_show(struct seq_file *seq, void *v)
87231 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87232 index a0fcc47..32e2c89 100644
87233 --- a/net/ipv4/route.c
87234 +++ b/net/ipv4/route.c
87235 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87236 .maxlen = sizeof(int),
87237 .mode = 0200,
87238 .proc_handler = ipv4_sysctl_rtcache_flush,
87239 + .extra1 = &init_net,
87240 },
87241 { },
87242 };
87243
87244 static __net_init int sysctl_route_net_init(struct net *net)
87245 {
87246 - struct ctl_table *tbl;
87247 + ctl_table_no_const *tbl = NULL;
87248
87249 - tbl = ipv4_route_flush_table;
87250 if (!net_eq(net, &init_net)) {
87251 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87252 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87253 if (tbl == NULL)
87254 goto err_dup;
87255
87256 /* Don't export sysctls to unprivileged users */
87257 if (net->user_ns != &init_user_ns)
87258 tbl[0].procname = NULL;
87259 - }
87260 - tbl[0].extra1 = net;
87261 + tbl[0].extra1 = net;
87262 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87263 + } else
87264 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87265
87266 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87267 if (net->ipv4.route_hdr == NULL)
87268 goto err_reg;
87269 return 0;
87270
87271 err_reg:
87272 - if (tbl != ipv4_route_flush_table)
87273 - kfree(tbl);
87274 + kfree(tbl);
87275 err_dup:
87276 return -ENOMEM;
87277 }
87278 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87279
87280 static __net_init int rt_genid_init(struct net *net)
87281 {
87282 - atomic_set(&net->rt_genid, 0);
87283 + atomic_set_unchecked(&net->rt_genid, 0);
87284 get_random_bytes(&net->ipv4.dev_addr_genid,
87285 sizeof(net->ipv4.dev_addr_genid));
87286 return 0;
87287 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87288 index d84400b..62e066e 100644
87289 --- a/net/ipv4/sysctl_net_ipv4.c
87290 +++ b/net/ipv4/sysctl_net_ipv4.c
87291 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87292 {
87293 int ret;
87294 int range[2];
87295 - ctl_table tmp = {
87296 + ctl_table_no_const tmp = {
87297 .data = &range,
87298 .maxlen = sizeof(range),
87299 .mode = table->mode,
87300 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87301 int ret;
87302 gid_t urange[2];
87303 kgid_t low, high;
87304 - ctl_table tmp = {
87305 + ctl_table_no_const tmp = {
87306 .data = &urange,
87307 .maxlen = sizeof(urange),
87308 .mode = table->mode,
87309 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87310 void __user *buffer, size_t *lenp, loff_t *ppos)
87311 {
87312 char val[TCP_CA_NAME_MAX];
87313 - ctl_table tbl = {
87314 + ctl_table_no_const tbl = {
87315 .data = val,
87316 .maxlen = TCP_CA_NAME_MAX,
87317 };
87318 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87319 void __user *buffer, size_t *lenp,
87320 loff_t *ppos)
87321 {
87322 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87323 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87324 int ret;
87325
87326 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87327 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87328 void __user *buffer, size_t *lenp,
87329 loff_t *ppos)
87330 {
87331 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87332 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87333 int ret;
87334
87335 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87336 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87337 struct mem_cgroup *memcg;
87338 #endif
87339
87340 - ctl_table tmp = {
87341 + ctl_table_no_const tmp = {
87342 .data = &vec,
87343 .maxlen = sizeof(vec),
87344 .mode = ctl->mode,
87345 };
87346
87347 if (!write) {
87348 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87349 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87350 + ctl_table_no_const tcp_mem = *ctl;
87351 +
87352 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87353 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87354 }
87355
87356 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87357 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87358 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87359 size_t *lenp, loff_t *ppos)
87360 {
87361 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87362 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87363 struct tcp_fastopen_context *ctxt;
87364 int ret;
87365 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87366 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
87367 },
87368 {
87369 .procname = "ip_local_reserved_ports",
87370 - .data = NULL, /* initialized in sysctl_ipv4_init */
87371 + .data = sysctl_local_reserved_ports,
87372 .maxlen = 65536,
87373 .mode = 0644,
87374 .proc_handler = proc_do_large_bitmap,
87375 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
87376
87377 static __net_init int ipv4_sysctl_init_net(struct net *net)
87378 {
87379 - struct ctl_table *table;
87380 + ctl_table_no_const *table = NULL;
87381
87382 - table = ipv4_net_table;
87383 if (!net_eq(net, &init_net)) {
87384 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87385 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87386 if (table == NULL)
87387 goto err_alloc;
87388
87389 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87390
87391 tcp_init_mem(net);
87392
87393 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87394 + if (!net_eq(net, &init_net))
87395 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87396 + else
87397 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87398 if (net->ipv4.ipv4_hdr == NULL)
87399 goto err_reg;
87400
87401 return 0;
87402
87403 err_reg:
87404 - if (!net_eq(net, &init_net))
87405 - kfree(table);
87406 + kfree(table);
87407 err_alloc:
87408 return -ENOMEM;
87409 }
87410 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87411 static __init int sysctl_ipv4_init(void)
87412 {
87413 struct ctl_table_header *hdr;
87414 - struct ctl_table *i;
87415 -
87416 - for (i = ipv4_table; i->procname; i++) {
87417 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87418 - i->data = sysctl_local_reserved_ports;
87419 - break;
87420 - }
87421 - }
87422 - if (!i->procname)
87423 - return -EINVAL;
87424
87425 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87426 if (hdr == NULL)
87427 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87428 index b4e8b79..617d6aa 100644
87429 --- a/net/ipv4/tcp_input.c
87430 +++ b/net/ipv4/tcp_input.c
87431 @@ -4737,7 +4737,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87432 * simplifies code)
87433 */
87434 static void
87435 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87436 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87437 struct sk_buff *head, struct sk_buff *tail,
87438 u32 start, u32 end)
87439 {
87440 @@ -5849,6 +5849,7 @@ discard:
87441 tcp_paws_reject(&tp->rx_opt, 0))
87442 goto discard_and_undo;
87443
87444 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87445 if (th->syn) {
87446 /* We see SYN without ACK. It is attempt of
87447 * simultaneous connect with crossed SYNs.
87448 @@ -5899,6 +5900,7 @@ discard:
87449 goto discard;
87450 #endif
87451 }
87452 +#endif
87453 /* "fifth, if neither of the SYN or RST bits is set then
87454 * drop the segment and return."
87455 */
87456 @@ -5943,7 +5945,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87457 goto discard;
87458
87459 if (th->syn) {
87460 - if (th->fin)
87461 + if (th->fin || th->urg || th->psh)
87462 goto discard;
87463 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87464 return 1;
87465 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87466 index d9130a9..00328ff 100644
87467 --- a/net/ipv4/tcp_ipv4.c
87468 +++ b/net/ipv4/tcp_ipv4.c
87469 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87470 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87471
87472
87473 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87474 +extern int grsec_enable_blackhole;
87475 +#endif
87476 +
87477 #ifdef CONFIG_TCP_MD5SIG
87478 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87479 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87480 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87481 return 0;
87482
87483 reset:
87484 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87485 + if (!grsec_enable_blackhole)
87486 +#endif
87487 tcp_v4_send_reset(rsk, skb);
87488 discard:
87489 kfree_skb(skb);
87490 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87491 TCP_SKB_CB(skb)->sacked = 0;
87492
87493 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87494 - if (!sk)
87495 + if (!sk) {
87496 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87497 + ret = 1;
87498 +#endif
87499 goto no_tcp_socket;
87500 -
87501 + }
87502 process:
87503 - if (sk->sk_state == TCP_TIME_WAIT)
87504 + if (sk->sk_state == TCP_TIME_WAIT) {
87505 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87506 + ret = 2;
87507 +#endif
87508 goto do_time_wait;
87509 + }
87510
87511 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87512 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87513 @@ -2050,6 +2064,10 @@ no_tcp_socket:
87514 bad_packet:
87515 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87516 } else {
87517 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87518 + if (!grsec_enable_blackhole || (ret == 1 &&
87519 + (skb->dev->flags & IFF_LOOPBACK)))
87520 +#endif
87521 tcp_v4_send_reset(NULL, skb);
87522 }
87523
87524 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87525 index f35f2df..ccb5ca6 100644
87526 --- a/net/ipv4/tcp_minisocks.c
87527 +++ b/net/ipv4/tcp_minisocks.c
87528 @@ -27,6 +27,10 @@
87529 #include <net/inet_common.h>
87530 #include <net/xfrm.h>
87531
87532 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87533 +extern int grsec_enable_blackhole;
87534 +#endif
87535 +
87536 int sysctl_tcp_syncookies __read_mostly = 1;
87537 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87538
87539 @@ -742,7 +746,10 @@ embryonic_reset:
87540 * avoid becoming vulnerable to outside attack aiming at
87541 * resetting legit local connections.
87542 */
87543 - req->rsk_ops->send_reset(sk, skb);
87544 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87545 + if (!grsec_enable_blackhole)
87546 +#endif
87547 + req->rsk_ops->send_reset(sk, skb);
87548 } else if (fastopen) { /* received a valid RST pkt */
87549 reqsk_fastopen_remove(sk, req, true);
87550 tcp_reset(sk);
87551 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87552 index 4526fe6..1a34e43 100644
87553 --- a/net/ipv4/tcp_probe.c
87554 +++ b/net/ipv4/tcp_probe.c
87555 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87556 if (cnt + width >= len)
87557 break;
87558
87559 - if (copy_to_user(buf + cnt, tbuf, width))
87560 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87561 return -EFAULT;
87562 cnt += width;
87563 }
87564 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87565 index b78aac3..e18230b 100644
87566 --- a/net/ipv4/tcp_timer.c
87567 +++ b/net/ipv4/tcp_timer.c
87568 @@ -22,6 +22,10 @@
87569 #include <linux/gfp.h>
87570 #include <net/tcp.h>
87571
87572 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87573 +extern int grsec_lastack_retries;
87574 +#endif
87575 +
87576 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87577 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87578 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87579 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87580 }
87581 }
87582
87583 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87584 + if ((sk->sk_state == TCP_LAST_ACK) &&
87585 + (grsec_lastack_retries > 0) &&
87586 + (grsec_lastack_retries < retry_until))
87587 + retry_until = grsec_lastack_retries;
87588 +#endif
87589 +
87590 if (retransmits_timed_out(sk, retry_until,
87591 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87592 /* Has it gone just too far? */
87593 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87594 index 1f4d405..3524677 100644
87595 --- a/net/ipv4/udp.c
87596 +++ b/net/ipv4/udp.c
87597 @@ -87,6 +87,7 @@
87598 #include <linux/types.h>
87599 #include <linux/fcntl.h>
87600 #include <linux/module.h>
87601 +#include <linux/security.h>
87602 #include <linux/socket.h>
87603 #include <linux/sockios.h>
87604 #include <linux/igmp.h>
87605 @@ -111,6 +112,10 @@
87606 #include <trace/events/skb.h>
87607 #include "udp_impl.h"
87608
87609 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87610 +extern int grsec_enable_blackhole;
87611 +#endif
87612 +
87613 struct udp_table udp_table __read_mostly;
87614 EXPORT_SYMBOL(udp_table);
87615
87616 @@ -569,6 +574,9 @@ found:
87617 return s;
87618 }
87619
87620 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87621 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87622 +
87623 /*
87624 * This routine is called by the ICMP module when it gets some
87625 * sort of error condition. If err < 0 then the socket should
87626 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87627 dport = usin->sin_port;
87628 if (dport == 0)
87629 return -EINVAL;
87630 +
87631 + err = gr_search_udp_sendmsg(sk, usin);
87632 + if (err)
87633 + return err;
87634 } else {
87635 if (sk->sk_state != TCP_ESTABLISHED)
87636 return -EDESTADDRREQ;
87637 +
87638 + err = gr_search_udp_sendmsg(sk, NULL);
87639 + if (err)
87640 + return err;
87641 +
87642 daddr = inet->inet_daddr;
87643 dport = inet->inet_dport;
87644 /* Open fast path for connected socket.
87645 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
87646 udp_lib_checksum_complete(skb)) {
87647 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87648 IS_UDPLITE(sk));
87649 - atomic_inc(&sk->sk_drops);
87650 + atomic_inc_unchecked(&sk->sk_drops);
87651 __skb_unlink(skb, rcvq);
87652 __skb_queue_tail(&list_kill, skb);
87653 }
87654 @@ -1194,6 +1211,10 @@ try_again:
87655 if (!skb)
87656 goto out;
87657
87658 + err = gr_search_udp_recvmsg(sk, skb);
87659 + if (err)
87660 + goto out_free;
87661 +
87662 ulen = skb->len - sizeof(struct udphdr);
87663 copied = len;
87664 if (copied > ulen)
87665 @@ -1227,7 +1248,7 @@ try_again:
87666 if (unlikely(err)) {
87667 trace_kfree_skb(skb, udp_recvmsg);
87668 if (!peeked) {
87669 - atomic_inc(&sk->sk_drops);
87670 + atomic_inc_unchecked(&sk->sk_drops);
87671 UDP_INC_STATS_USER(sock_net(sk),
87672 UDP_MIB_INERRORS, is_udplite);
87673 }
87674 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87675
87676 drop:
87677 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87678 - atomic_inc(&sk->sk_drops);
87679 + atomic_inc_unchecked(&sk->sk_drops);
87680 kfree_skb(skb);
87681 return -1;
87682 }
87683 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87684 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87685
87686 if (!skb1) {
87687 - atomic_inc(&sk->sk_drops);
87688 + atomic_inc_unchecked(&sk->sk_drops);
87689 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87690 IS_UDPLITE(sk));
87691 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87692 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87693 goto csum_error;
87694
87695 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87696 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87697 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87698 +#endif
87699 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87700
87701 /*
87702 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87703 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87704 0, sock_i_ino(sp),
87705 atomic_read(&sp->sk_refcnt), sp,
87706 - atomic_read(&sp->sk_drops), len);
87707 + atomic_read_unchecked(&sp->sk_drops), len);
87708 }
87709
87710 int udp4_seq_show(struct seq_file *seq, void *v)
87711 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87712 index e8676c2..0a164f6 100644
87713 --- a/net/ipv6/addrconf.c
87714 +++ b/net/ipv6/addrconf.c
87715 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87716 p.iph.ihl = 5;
87717 p.iph.protocol = IPPROTO_IPV6;
87718 p.iph.ttl = 64;
87719 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87720 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87721
87722 if (ops->ndo_do_ioctl) {
87723 mm_segment_t oldfs = get_fs();
87724 @@ -4415,7 +4415,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87725 int *valp = ctl->data;
87726 int val = *valp;
87727 loff_t pos = *ppos;
87728 - ctl_table lctl;
87729 + ctl_table_no_const lctl;
87730 int ret;
87731
87732 /*
87733 @@ -4497,7 +4497,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87734 int *valp = ctl->data;
87735 int val = *valp;
87736 loff_t pos = *ppos;
87737 - ctl_table lctl;
87738 + ctl_table_no_const lctl;
87739 int ret;
87740
87741 /*
87742 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87743 index fff5bdd..15194fb 100644
87744 --- a/net/ipv6/icmp.c
87745 +++ b/net/ipv6/icmp.c
87746 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87747
87748 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87749 {
87750 - struct ctl_table *table;
87751 + ctl_table_no_const *table;
87752
87753 table = kmemdup(ipv6_icmp_table_template,
87754 sizeof(ipv6_icmp_table_template),
87755 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87756 index 131dd09..f7ed64f 100644
87757 --- a/net/ipv6/ip6_gre.c
87758 +++ b/net/ipv6/ip6_gre.c
87759 @@ -73,7 +73,7 @@ struct ip6gre_net {
87760 struct net_device *fb_tunnel_dev;
87761 };
87762
87763 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87764 +static struct rtnl_link_ops ip6gre_link_ops;
87765 static int ip6gre_tunnel_init(struct net_device *dev);
87766 static void ip6gre_tunnel_setup(struct net_device *dev);
87767 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87768 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87769 }
87770
87771
87772 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87773 +static struct inet6_protocol ip6gre_protocol = {
87774 .handler = ip6gre_rcv,
87775 .err_handler = ip6gre_err,
87776 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87777 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87778 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87779 };
87780
87781 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87782 +static struct rtnl_link_ops ip6gre_link_ops = {
87783 .kind = "ip6gre",
87784 .maxtype = IFLA_GRE_MAX,
87785 .policy = ip6gre_policy,
87786 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87787 .fill_info = ip6gre_fill_info,
87788 };
87789
87790 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87791 +static struct rtnl_link_ops ip6gre_tap_ops = {
87792 .kind = "ip6gretap",
87793 .maxtype = IFLA_GRE_MAX,
87794 .policy = ip6gre_policy,
87795 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87796 index a14f28b..b4b8956 100644
87797 --- a/net/ipv6/ip6_tunnel.c
87798 +++ b/net/ipv6/ip6_tunnel.c
87799 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87800
87801 static int ip6_tnl_dev_init(struct net_device *dev);
87802 static void ip6_tnl_dev_setup(struct net_device *dev);
87803 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87804 +static struct rtnl_link_ops ip6_link_ops;
87805
87806 static int ip6_tnl_net_id __read_mostly;
87807 struct ip6_tnl_net {
87808 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87809 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87810 };
87811
87812 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87813 +static struct rtnl_link_ops ip6_link_ops = {
87814 .kind = "ip6tnl",
87815 .maxtype = IFLA_IPTUN_MAX,
87816 .policy = ip6_tnl_policy,
87817 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87818 index d1e2e8e..51c19ae 100644
87819 --- a/net/ipv6/ipv6_sockglue.c
87820 +++ b/net/ipv6/ipv6_sockglue.c
87821 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87822 if (sk->sk_type != SOCK_STREAM)
87823 return -ENOPROTOOPT;
87824
87825 - msg.msg_control = optval;
87826 + msg.msg_control = (void __force_kernel *)optval;
87827 msg.msg_controllen = len;
87828 msg.msg_flags = flags;
87829
87830 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87831 index 125a90d..2a11f36 100644
87832 --- a/net/ipv6/netfilter/ip6_tables.c
87833 +++ b/net/ipv6/netfilter/ip6_tables.c
87834 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87835 #endif
87836
87837 static int get_info(struct net *net, void __user *user,
87838 - const int *len, int compat)
87839 + int len, int compat)
87840 {
87841 char name[XT_TABLE_MAXNAMELEN];
87842 struct xt_table *t;
87843 int ret;
87844
87845 - if (*len != sizeof(struct ip6t_getinfo)) {
87846 - duprintf("length %u != %zu\n", *len,
87847 + if (len != sizeof(struct ip6t_getinfo)) {
87848 + duprintf("length %u != %zu\n", len,
87849 sizeof(struct ip6t_getinfo));
87850 return -EINVAL;
87851 }
87852 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87853 info.size = private->size;
87854 strcpy(info.name, name);
87855
87856 - if (copy_to_user(user, &info, *len) != 0)
87857 + if (copy_to_user(user, &info, len) != 0)
87858 ret = -EFAULT;
87859 else
87860 ret = 0;
87861 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87862
87863 switch (cmd) {
87864 case IP6T_SO_GET_INFO:
87865 - ret = get_info(sock_net(sk), user, len, 1);
87866 + ret = get_info(sock_net(sk), user, *len, 1);
87867 break;
87868 case IP6T_SO_GET_ENTRIES:
87869 ret = compat_get_entries(sock_net(sk), user, len);
87870 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87871
87872 switch (cmd) {
87873 case IP6T_SO_GET_INFO:
87874 - ret = get_info(sock_net(sk), user, len, 0);
87875 + ret = get_info(sock_net(sk), user, *len, 0);
87876 break;
87877
87878 case IP6T_SO_GET_ENTRIES:
87879 diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
87880 index 83acc14..0ea43c7 100644
87881 --- a/net/ipv6/netfilter/ip6t_NPT.c
87882 +++ b/net/ipv6/netfilter/ip6t_NPT.c
87883 @@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
87884 if (pfx_len - i >= 32)
87885 mask = 0;
87886 else
87887 - mask = htonl(~((1 << (pfx_len - i)) - 1));
87888 + mask = htonl((1 << (i - pfx_len + 32)) - 1);
87889
87890 idx = i / 32;
87891 addr->s6_addr32[idx] &= mask;
87892 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
87893 index 2f3a018..8bca195 100644
87894 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
87895 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
87896 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
87897
87898 static int nf_ct_frag6_sysctl_register(struct net *net)
87899 {
87900 - struct ctl_table *table;
87901 + ctl_table_no_const *table = NULL;
87902 struct ctl_table_header *hdr;
87903
87904 - table = nf_ct_frag6_sysctl_table;
87905 if (!net_eq(net, &init_net)) {
87906 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
87907 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
87908 GFP_KERNEL);
87909 if (table == NULL)
87910 goto err_alloc;
87911 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87912 table[0].data = &net->ipv6.frags.high_thresh;
87913 table[1].data = &net->ipv6.frags.low_thresh;
87914 table[2].data = &net->ipv6.frags.timeout;
87915 - }
87916 -
87917 - hdr = register_net_sysctl(net, "net/netfilter", table);
87918 + hdr = register_net_sysctl(net, "net/netfilter", table);
87919 + } else
87920 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
87921 if (hdr == NULL)
87922 goto err_reg;
87923
87924 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87925 return 0;
87926
87927 err_reg:
87928 - if (!net_eq(net, &init_net))
87929 - kfree(table);
87930 + kfree(table);
87931 err_alloc:
87932 return -ENOMEM;
87933 }
87934 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
87935 index 70fa814..d70c28c 100644
87936 --- a/net/ipv6/raw.c
87937 +++ b/net/ipv6/raw.c
87938 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
87939 {
87940 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
87941 skb_checksum_complete(skb)) {
87942 - atomic_inc(&sk->sk_drops);
87943 + atomic_inc_unchecked(&sk->sk_drops);
87944 kfree_skb(skb);
87945 return NET_RX_DROP;
87946 }
87947 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87948 struct raw6_sock *rp = raw6_sk(sk);
87949
87950 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
87951 - atomic_inc(&sk->sk_drops);
87952 + atomic_inc_unchecked(&sk->sk_drops);
87953 kfree_skb(skb);
87954 return NET_RX_DROP;
87955 }
87956 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87957
87958 if (inet->hdrincl) {
87959 if (skb_checksum_complete(skb)) {
87960 - atomic_inc(&sk->sk_drops);
87961 + atomic_inc_unchecked(&sk->sk_drops);
87962 kfree_skb(skb);
87963 return NET_RX_DROP;
87964 }
87965 @@ -604,7 +604,7 @@ out:
87966 return err;
87967 }
87968
87969 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
87970 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
87971 struct flowi6 *fl6, struct dst_entry **dstp,
87972 unsigned int flags)
87973 {
87974 @@ -916,12 +916,15 @@ do_confirm:
87975 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
87976 char __user *optval, int optlen)
87977 {
87978 + struct icmp6_filter filter;
87979 +
87980 switch (optname) {
87981 case ICMPV6_FILTER:
87982 if (optlen > sizeof(struct icmp6_filter))
87983 optlen = sizeof(struct icmp6_filter);
87984 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
87985 + if (copy_from_user(&filter, optval, optlen))
87986 return -EFAULT;
87987 + raw6_sk(sk)->filter = filter;
87988 return 0;
87989 default:
87990 return -ENOPROTOOPT;
87991 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87992 char __user *optval, int __user *optlen)
87993 {
87994 int len;
87995 + struct icmp6_filter filter;
87996
87997 switch (optname) {
87998 case ICMPV6_FILTER:
87999 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88000 len = sizeof(struct icmp6_filter);
88001 if (put_user(len, optlen))
88002 return -EFAULT;
88003 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88004 + filter = raw6_sk(sk)->filter;
88005 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88006 return -EFAULT;
88007 return 0;
88008 default:
88009 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88010 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88011 0,
88012 sock_i_ino(sp),
88013 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88014 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88015 }
88016
88017 static int raw6_seq_show(struct seq_file *seq, void *v)
88018 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88019 index 7a610a6..202dff9 100644
88020 --- a/net/ipv6/reassembly.c
88021 +++ b/net/ipv6/reassembly.c
88022 @@ -617,12 +617,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88023
88024 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88025 {
88026 - struct ctl_table *table;
88027 + ctl_table_no_const *table = NULL;
88028 struct ctl_table_header *hdr;
88029
88030 - table = ip6_frags_ns_ctl_table;
88031 if (!net_eq(net, &init_net)) {
88032 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88033 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88034 if (table == NULL)
88035 goto err_alloc;
88036
88037 @@ -633,9 +632,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88038 /* Don't export sysctls to unprivileged users */
88039 if (net->user_ns != &init_user_ns)
88040 table[0].procname = NULL;
88041 - }
88042 + hdr = register_net_sysctl(net, "net/ipv6", table);
88043 + } else
88044 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88045
88046 - hdr = register_net_sysctl(net, "net/ipv6", table);
88047 if (hdr == NULL)
88048 goto err_reg;
88049
88050 @@ -643,8 +643,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88051 return 0;
88052
88053 err_reg:
88054 - if (!net_eq(net, &init_net))
88055 - kfree(table);
88056 + kfree(table);
88057 err_alloc:
88058 return -ENOMEM;
88059 }
88060 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88061 index 5845613..3af8fc7 100644
88062 --- a/net/ipv6/route.c
88063 +++ b/net/ipv6/route.c
88064 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
88065
88066 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88067 {
88068 - struct ctl_table *table;
88069 + ctl_table_no_const *table;
88070
88071 table = kmemdup(ipv6_route_table_template,
88072 sizeof(ipv6_route_table_template),
88073 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88074 index cfba99b..20ca511 100644
88075 --- a/net/ipv6/sit.c
88076 +++ b/net/ipv6/sit.c
88077 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88078 static int ipip6_tunnel_init(struct net_device *dev);
88079 static void ipip6_tunnel_setup(struct net_device *dev);
88080 static void ipip6_dev_free(struct net_device *dev);
88081 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88082 +static struct rtnl_link_ops sit_link_ops;
88083
88084 static int sit_net_id __read_mostly;
88085 struct sit_net {
88086 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88087 #endif
88088 };
88089
88090 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88091 +static struct rtnl_link_ops sit_link_ops = {
88092 .kind = "sit",
88093 .maxtype = IFLA_IPTUN_MAX,
88094 .policy = ipip6_policy,
88095 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88096 index e85c48b..b8268d3 100644
88097 --- a/net/ipv6/sysctl_net_ipv6.c
88098 +++ b/net/ipv6/sysctl_net_ipv6.c
88099 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88100
88101 static int __net_init ipv6_sysctl_net_init(struct net *net)
88102 {
88103 - struct ctl_table *ipv6_table;
88104 + ctl_table_no_const *ipv6_table;
88105 struct ctl_table *ipv6_route_table;
88106 struct ctl_table *ipv6_icmp_table;
88107 int err;
88108 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88109 index 89dfedd..f122ba5 100644
88110 --- a/net/ipv6/tcp_ipv6.c
88111 +++ b/net/ipv6/tcp_ipv6.c
88112 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88113 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88114 }
88115
88116 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88117 +extern int grsec_enable_blackhole;
88118 +#endif
88119 +
88120 static void tcp_v6_hash(struct sock *sk)
88121 {
88122 if (sk->sk_state != TCP_CLOSE) {
88123 @@ -1441,6 +1445,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88124 return 0;
88125
88126 reset:
88127 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88128 + if (!grsec_enable_blackhole)
88129 +#endif
88130 tcp_v6_send_reset(sk, skb);
88131 discard:
88132 if (opt_skb)
88133 @@ -1522,12 +1529,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88134 TCP_SKB_CB(skb)->sacked = 0;
88135
88136 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88137 - if (!sk)
88138 + if (!sk) {
88139 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88140 + ret = 1;
88141 +#endif
88142 goto no_tcp_socket;
88143 + }
88144
88145 process:
88146 - if (sk->sk_state == TCP_TIME_WAIT)
88147 + if (sk->sk_state == TCP_TIME_WAIT) {
88148 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88149 + ret = 2;
88150 +#endif
88151 goto do_time_wait;
88152 + }
88153
88154 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88155 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88156 @@ -1576,6 +1591,10 @@ no_tcp_socket:
88157 bad_packet:
88158 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88159 } else {
88160 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88161 + if (!grsec_enable_blackhole || (ret == 1 &&
88162 + (skb->dev->flags & IFF_LOOPBACK)))
88163 +#endif
88164 tcp_v6_send_reset(NULL, skb);
88165 }
88166
88167 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88168 index fb08329..2d6919e 100644
88169 --- a/net/ipv6/udp.c
88170 +++ b/net/ipv6/udp.c
88171 @@ -51,6 +51,10 @@
88172 #include <trace/events/skb.h>
88173 #include "udp_impl.h"
88174
88175 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88176 +extern int grsec_enable_blackhole;
88177 +#endif
88178 +
88179 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88180 {
88181 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88182 @@ -395,7 +399,7 @@ try_again:
88183 if (unlikely(err)) {
88184 trace_kfree_skb(skb, udpv6_recvmsg);
88185 if (!peeked) {
88186 - atomic_inc(&sk->sk_drops);
88187 + atomic_inc_unchecked(&sk->sk_drops);
88188 if (is_udp4)
88189 UDP_INC_STATS_USER(sock_net(sk),
88190 UDP_MIB_INERRORS,
88191 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88192 return rc;
88193 drop:
88194 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88195 - atomic_inc(&sk->sk_drops);
88196 + atomic_inc_unchecked(&sk->sk_drops);
88197 kfree_skb(skb);
88198 return -1;
88199 }
88200 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88201 if (likely(skb1 == NULL))
88202 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88203 if (!skb1) {
88204 - atomic_inc(&sk->sk_drops);
88205 + atomic_inc_unchecked(&sk->sk_drops);
88206 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88207 IS_UDPLITE(sk));
88208 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88209 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88210 goto discard;
88211
88212 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88213 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88214 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88215 +#endif
88216 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88217
88218 kfree_skb(skb);
88219 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88220 0,
88221 sock_i_ino(sp),
88222 atomic_read(&sp->sk_refcnt), sp,
88223 - atomic_read(&sp->sk_drops));
88224 + atomic_read_unchecked(&sp->sk_drops));
88225 }
88226
88227 int udp6_seq_show(struct seq_file *seq, void *v)
88228 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88229 index a68c88c..d55b0c5 100644
88230 --- a/net/irda/ircomm/ircomm_tty.c
88231 +++ b/net/irda/ircomm/ircomm_tty.c
88232 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88233 add_wait_queue(&port->open_wait, &wait);
88234
88235 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88236 - __FILE__, __LINE__, tty->driver->name, port->count);
88237 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88238
88239 spin_lock_irqsave(&port->lock, flags);
88240 if (!tty_hung_up_p(filp)) {
88241 extra_count = 1;
88242 - port->count--;
88243 + atomic_dec(&port->count);
88244 }
88245 spin_unlock_irqrestore(&port->lock, flags);
88246 port->blocked_open++;
88247 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88248 }
88249
88250 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88251 - __FILE__, __LINE__, tty->driver->name, port->count);
88252 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88253
88254 schedule();
88255 }
88256 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88257 if (extra_count) {
88258 /* ++ is not atomic, so this should be protected - Jean II */
88259 spin_lock_irqsave(&port->lock, flags);
88260 - port->count++;
88261 + atomic_inc(&port->count);
88262 spin_unlock_irqrestore(&port->lock, flags);
88263 }
88264 port->blocked_open--;
88265
88266 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88267 - __FILE__, __LINE__, tty->driver->name, port->count);
88268 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88269
88270 if (!retval)
88271 port->flags |= ASYNC_NORMAL_ACTIVE;
88272 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88273
88274 /* ++ is not atomic, so this should be protected - Jean II */
88275 spin_lock_irqsave(&self->port.lock, flags);
88276 - self->port.count++;
88277 + atomic_inc(&self->port.count);
88278 spin_unlock_irqrestore(&self->port.lock, flags);
88279 tty_port_tty_set(&self->port, tty);
88280
88281 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88282 - self->line, self->port.count);
88283 + self->line, atomic_read(&self->port.count));
88284
88285 /* Not really used by us, but lets do it anyway */
88286 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88287 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88288 tty_kref_put(port->tty);
88289 }
88290 port->tty = NULL;
88291 - port->count = 0;
88292 + atomic_set(&port->count, 0);
88293 spin_unlock_irqrestore(&port->lock, flags);
88294
88295 wake_up_interruptible(&port->open_wait);
88296 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88297 seq_putc(m, '\n');
88298
88299 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88300 - seq_printf(m, "Open count: %d\n", self->port.count);
88301 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88302 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88303 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88304
88305 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
88306 index e71e85b..29340a9 100644
88307 --- a/net/irda/iriap.c
88308 +++ b/net/irda/iriap.c
88309 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
88310 /* case CS_ISO_8859_9: */
88311 /* case CS_UNICODE: */
88312 default:
88313 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
88314 - __func__, ias_charset_types[charset]);
88315 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
88316 + __func__, charset,
88317 + charset < ARRAY_SIZE(ias_charset_types) ?
88318 + ias_charset_types[charset] :
88319 + "(unknown)");
88320
88321 /* Aborting, close connection! */
88322 iriap_disconnect_request(self);
88323 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88324 index 625bc50..ac6eef9 100644
88325 --- a/net/iucv/af_iucv.c
88326 +++ b/net/iucv/af_iucv.c
88327 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
88328
88329 write_lock_bh(&iucv_sk_list.lock);
88330
88331 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88332 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88333 while (__iucv_get_sock_by_name(name)) {
88334 sprintf(name, "%08x",
88335 - atomic_inc_return(&iucv_sk_list.autobind_name));
88336 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88337 }
88338
88339 write_unlock_bh(&iucv_sk_list.lock);
88340 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88341 index df08250..02021fe 100644
88342 --- a/net/iucv/iucv.c
88343 +++ b/net/iucv/iucv.c
88344 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88345 return NOTIFY_OK;
88346 }
88347
88348 -static struct notifier_block __refdata iucv_cpu_notifier = {
88349 +static struct notifier_block iucv_cpu_notifier = {
88350 .notifier_call = iucv_cpu_notify,
88351 };
88352
88353 diff --git a/net/key/af_key.c b/net/key/af_key.c
88354 index 5b426a6..970032b 100644
88355 --- a/net/key/af_key.c
88356 +++ b/net/key/af_key.c
88357 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88358 static u32 get_acqseq(void)
88359 {
88360 u32 res;
88361 - static atomic_t acqseq;
88362 + static atomic_unchecked_t acqseq;
88363
88364 do {
88365 - res = atomic_inc_return(&acqseq);
88366 + res = atomic_inc_return_unchecked(&acqseq);
88367 } while (!res);
88368 return res;
88369 }
88370 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88371 index 49c48c6..9e72ff4 100644
88372 --- a/net/mac80211/cfg.c
88373 +++ b/net/mac80211/cfg.c
88374 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88375 ret = ieee80211_vif_use_channel(sdata, chandef,
88376 IEEE80211_CHANCTX_EXCLUSIVE);
88377 }
88378 - } else if (local->open_count == local->monitors) {
88379 + } else if (local_read(&local->open_count) == local->monitors) {
88380 local->_oper_channel = chandef->chan;
88381 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88382 ieee80211_hw_config(local, 0);
88383 @@ -2718,7 +2718,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88384 else
88385 local->probe_req_reg--;
88386
88387 - if (!local->open_count)
88388 + if (!local_read(&local->open_count))
88389 break;
88390
88391 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88392 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88393 index 55d8f89..bec0c2b 100644
88394 --- a/net/mac80211/ieee80211_i.h
88395 +++ b/net/mac80211/ieee80211_i.h
88396 @@ -28,6 +28,7 @@
88397 #include <net/ieee80211_radiotap.h>
88398 #include <net/cfg80211.h>
88399 #include <net/mac80211.h>
88400 +#include <asm/local.h>
88401 #include "key.h"
88402 #include "sta_info.h"
88403 #include "debug.h"
88404 @@ -910,7 +911,7 @@ struct ieee80211_local {
88405 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88406 spinlock_t queue_stop_reason_lock;
88407
88408 - int open_count;
88409 + local_t open_count;
88410 int monitors, cooked_mntrs;
88411 /* number of interfaces with corresponding FIF_ flags */
88412 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88413 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88414 index 8be854e..ad72a69 100644
88415 --- a/net/mac80211/iface.c
88416 +++ b/net/mac80211/iface.c
88417 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88418 break;
88419 }
88420
88421 - if (local->open_count == 0) {
88422 + if (local_read(&local->open_count) == 0) {
88423 res = drv_start(local);
88424 if (res)
88425 goto err_del_bss;
88426 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88427 break;
88428 }
88429
88430 - if (local->monitors == 0 && local->open_count == 0) {
88431 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88432 res = ieee80211_add_virtual_monitor(local);
88433 if (res)
88434 goto err_stop;
88435 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88436 mutex_unlock(&local->mtx);
88437
88438 if (coming_up)
88439 - local->open_count++;
88440 + local_inc(&local->open_count);
88441
88442 if (hw_reconf_flags)
88443 ieee80211_hw_config(local, hw_reconf_flags);
88444 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88445 err_del_interface:
88446 drv_remove_interface(local, sdata);
88447 err_stop:
88448 - if (!local->open_count)
88449 + if (!local_read(&local->open_count))
88450 drv_stop(local);
88451 err_del_bss:
88452 sdata->bss = NULL;
88453 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88454 }
88455
88456 if (going_down)
88457 - local->open_count--;
88458 + local_dec(&local->open_count);
88459
88460 switch (sdata->vif.type) {
88461 case NL80211_IFTYPE_AP_VLAN:
88462 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88463
88464 ieee80211_recalc_ps(local, -1);
88465
88466 - if (local->open_count == 0) {
88467 + if (local_read(&local->open_count) == 0) {
88468 if (local->ops->napi_poll)
88469 napi_disable(&local->napi);
88470 ieee80211_clear_tx_pending(local);
88471 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88472 }
88473 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88474
88475 - if (local->monitors == local->open_count && local->monitors > 0)
88476 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88477 ieee80211_add_virtual_monitor(local);
88478 }
88479
88480 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88481 index 1b087ff..bf600e9 100644
88482 --- a/net/mac80211/main.c
88483 +++ b/net/mac80211/main.c
88484 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88485 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88486 IEEE80211_CONF_CHANGE_POWER);
88487
88488 - if (changed && local->open_count) {
88489 + if (changed && local_read(&local->open_count)) {
88490 ret = drv_config(local, changed);
88491 /*
88492 * Goal:
88493 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88494 index 79a48f3..5e185c9 100644
88495 --- a/net/mac80211/pm.c
88496 +++ b/net/mac80211/pm.c
88497 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88498 struct sta_info *sta;
88499 struct ieee80211_chanctx *ctx;
88500
88501 - if (!local->open_count)
88502 + if (!local_read(&local->open_count))
88503 goto suspend;
88504
88505 ieee80211_scan_cancel(local);
88506 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88507 cancel_work_sync(&local->dynamic_ps_enable_work);
88508 del_timer_sync(&local->dynamic_ps_timer);
88509
88510 - local->wowlan = wowlan && local->open_count;
88511 + local->wowlan = wowlan && local_read(&local->open_count);
88512 if (local->wowlan) {
88513 int err = drv_suspend(local, wowlan);
88514 if (err < 0) {
88515 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88516 mutex_unlock(&local->chanctx_mtx);
88517
88518 /* stop hardware - this must stop RX */
88519 - if (local->open_count)
88520 + if (local_read(&local->open_count))
88521 ieee80211_stop_device(local);
88522
88523 suspend:
88524 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88525 index dd88381..eef4dd6 100644
88526 --- a/net/mac80211/rate.c
88527 +++ b/net/mac80211/rate.c
88528 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88529
88530 ASSERT_RTNL();
88531
88532 - if (local->open_count)
88533 + if (local_read(&local->open_count))
88534 return -EBUSY;
88535
88536 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88537 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88538 index c97a065..ff61928 100644
88539 --- a/net/mac80211/rc80211_pid_debugfs.c
88540 +++ b/net/mac80211/rc80211_pid_debugfs.c
88541 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88542
88543 spin_unlock_irqrestore(&events->lock, status);
88544
88545 - if (copy_to_user(buf, pb, p))
88546 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88547 return -EFAULT;
88548
88549 return p;
88550 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88551 index f11e8c5..08d0013 100644
88552 --- a/net/mac80211/util.c
88553 +++ b/net/mac80211/util.c
88554 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88555 }
88556 #endif
88557 /* everything else happens only if HW was up & running */
88558 - if (!local->open_count)
88559 + if (!local_read(&local->open_count))
88560 goto wake_up;
88561
88562 /*
88563 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88564 index 49e96df..63a51c3 100644
88565 --- a/net/netfilter/Kconfig
88566 +++ b/net/netfilter/Kconfig
88567 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
88568
88569 To compile it as a module, choose M here. If unsure, say N.
88570
88571 +config NETFILTER_XT_MATCH_GRADM
88572 + tristate '"gradm" match support'
88573 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88574 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88575 + ---help---
88576 + The gradm match allows to match on grsecurity RBAC being enabled.
88577 + It is useful when iptables rules are applied early on bootup to
88578 + prevent connections to the machine (except from a trusted host)
88579 + while the RBAC system is disabled.
88580 +
88581 config NETFILTER_XT_MATCH_HASHLIMIT
88582 tristate '"hashlimit" match support'
88583 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88584 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88585 index 3259697..54d5393 100644
88586 --- a/net/netfilter/Makefile
88587 +++ b/net/netfilter/Makefile
88588 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88589 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88590 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88591 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88592 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88593 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88594 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88595 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88596 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88597 index 6d6d8f2..a676749 100644
88598 --- a/net/netfilter/ipset/ip_set_core.c
88599 +++ b/net/netfilter/ipset/ip_set_core.c
88600 @@ -1800,7 +1800,7 @@ done:
88601 return ret;
88602 }
88603
88604 -static struct nf_sockopt_ops so_set __read_mostly = {
88605 +static struct nf_sockopt_ops so_set = {
88606 .pf = PF_INET,
88607 .get_optmin = SO_IP_SET,
88608 .get_optmax = SO_IP_SET + 1,
88609 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88610 index 30e764a..c3b6a9d 100644
88611 --- a/net/netfilter/ipvs/ip_vs_conn.c
88612 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88613 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88614 /* Increase the refcnt counter of the dest */
88615 atomic_inc(&dest->refcnt);
88616
88617 - conn_flags = atomic_read(&dest->conn_flags);
88618 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88619 if (cp->protocol != IPPROTO_UDP)
88620 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88621 flags = cp->flags;
88622 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88623 atomic_set(&cp->refcnt, 1);
88624
88625 atomic_set(&cp->n_control, 0);
88626 - atomic_set(&cp->in_pkts, 0);
88627 + atomic_set_unchecked(&cp->in_pkts, 0);
88628
88629 atomic_inc(&ipvs->conn_count);
88630 if (flags & IP_VS_CONN_F_NO_CPORT)
88631 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88632
88633 /* Don't drop the entry if its number of incoming packets is not
88634 located in [0, 8] */
88635 - i = atomic_read(&cp->in_pkts);
88636 + i = atomic_read_unchecked(&cp->in_pkts);
88637 if (i > 8 || i < 0) return 0;
88638
88639 if (!todrop_rate[i]) return 0;
88640 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88641 index 47edf5a..235b07d 100644
88642 --- a/net/netfilter/ipvs/ip_vs_core.c
88643 +++ b/net/netfilter/ipvs/ip_vs_core.c
88644 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88645 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88646 /* do not touch skb anymore */
88647
88648 - atomic_inc(&cp->in_pkts);
88649 + atomic_inc_unchecked(&cp->in_pkts);
88650 ip_vs_conn_put(cp);
88651 return ret;
88652 }
88653 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88654 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88655 pkts = sysctl_sync_threshold(ipvs);
88656 else
88657 - pkts = atomic_add_return(1, &cp->in_pkts);
88658 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88659
88660 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88661 ip_vs_sync_conn(net, cp, pkts);
88662 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88663 index ec664cb..7f34a77 100644
88664 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88665 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88666 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88667 ip_vs_rs_hash(ipvs, dest);
88668 write_unlock_bh(&ipvs->rs_lock);
88669 }
88670 - atomic_set(&dest->conn_flags, conn_flags);
88671 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88672
88673 /* bind the service */
88674 if (!dest->svc) {
88675 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88676 * align with netns init in ip_vs_control_net_init()
88677 */
88678
88679 -static struct ctl_table vs_vars[] = {
88680 +static ctl_table_no_const vs_vars[] __read_only = {
88681 {
88682 .procname = "amemthresh",
88683 .maxlen = sizeof(int),
88684 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88685 " %-7s %-6d %-10d %-10d\n",
88686 &dest->addr.in6,
88687 ntohs(dest->port),
88688 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88689 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88690 atomic_read(&dest->weight),
88691 atomic_read(&dest->activeconns),
88692 atomic_read(&dest->inactconns));
88693 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88694 "%-7s %-6d %-10d %-10d\n",
88695 ntohl(dest->addr.ip),
88696 ntohs(dest->port),
88697 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88698 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88699 atomic_read(&dest->weight),
88700 atomic_read(&dest->activeconns),
88701 atomic_read(&dest->inactconns));
88702 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88703
88704 entry.addr = dest->addr.ip;
88705 entry.port = dest->port;
88706 - entry.conn_flags = atomic_read(&dest->conn_flags);
88707 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88708 entry.weight = atomic_read(&dest->weight);
88709 entry.u_threshold = dest->u_threshold;
88710 entry.l_threshold = dest->l_threshold;
88711 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88712 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88713 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88714 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88715 - (atomic_read(&dest->conn_flags) &
88716 + (atomic_read_unchecked(&dest->conn_flags) &
88717 IP_VS_CONN_F_FWD_MASK)) ||
88718 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88719 atomic_read(&dest->weight)) ||
88720 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88721 {
88722 int idx;
88723 struct netns_ipvs *ipvs = net_ipvs(net);
88724 - struct ctl_table *tbl;
88725 + ctl_table_no_const *tbl;
88726
88727 atomic_set(&ipvs->dropentry, 0);
88728 spin_lock_init(&ipvs->dropentry_lock);
88729 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88730 index fdd89b9..bd96aa9 100644
88731 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88732 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88733 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88734 * IPVS LBLC sysctl table
88735 */
88736 #ifdef CONFIG_SYSCTL
88737 -static ctl_table vs_vars_table[] = {
88738 +static ctl_table_no_const vs_vars_table[] __read_only = {
88739 {
88740 .procname = "lblc_expiration",
88741 .data = NULL,
88742 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88743 index c03b6a3..8ce3681 100644
88744 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88745 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88746 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88747 * IPVS LBLCR sysctl table
88748 */
88749
88750 -static ctl_table vs_vars_table[] = {
88751 +static ctl_table_no_const vs_vars_table[] __read_only = {
88752 {
88753 .procname = "lblcr_expiration",
88754 .data = NULL,
88755 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88756 index 44fd10c..2a163b3 100644
88757 --- a/net/netfilter/ipvs/ip_vs_sync.c
88758 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88759 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88760 cp = cp->control;
88761 if (cp) {
88762 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88763 - pkts = atomic_add_return(1, &cp->in_pkts);
88764 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88765 else
88766 pkts = sysctl_sync_threshold(ipvs);
88767 ip_vs_sync_conn(net, cp->control, pkts);
88768 @@ -758,7 +758,7 @@ control:
88769 if (!cp)
88770 return;
88771 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88772 - pkts = atomic_add_return(1, &cp->in_pkts);
88773 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88774 else
88775 pkts = sysctl_sync_threshold(ipvs);
88776 goto sloop;
88777 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88778
88779 if (opt)
88780 memcpy(&cp->in_seq, opt, sizeof(*opt));
88781 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88782 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88783 cp->state = state;
88784 cp->old_state = cp->state;
88785 /*
88786 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88787 index ee6b7a9..f9a89f6 100644
88788 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88789 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88790 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88791 else
88792 rc = NF_ACCEPT;
88793 /* do not touch skb anymore */
88794 - atomic_inc(&cp->in_pkts);
88795 + atomic_inc_unchecked(&cp->in_pkts);
88796 goto out;
88797 }
88798
88799 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88800 else
88801 rc = NF_ACCEPT;
88802 /* do not touch skb anymore */
88803 - atomic_inc(&cp->in_pkts);
88804 + atomic_inc_unchecked(&cp->in_pkts);
88805 goto out;
88806 }
88807
88808 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88809 index 7df424e..a527b02 100644
88810 --- a/net/netfilter/nf_conntrack_acct.c
88811 +++ b/net/netfilter/nf_conntrack_acct.c
88812 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88813 #ifdef CONFIG_SYSCTL
88814 static int nf_conntrack_acct_init_sysctl(struct net *net)
88815 {
88816 - struct ctl_table *table;
88817 + ctl_table_no_const *table;
88818
88819 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88820 GFP_KERNEL);
88821 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88822 index e4a0c4f..c263f28 100644
88823 --- a/net/netfilter/nf_conntrack_core.c
88824 +++ b/net/netfilter/nf_conntrack_core.c
88825 @@ -1529,6 +1529,10 @@ err_extend:
88826 #define DYING_NULLS_VAL ((1<<30)+1)
88827 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88828
88829 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88830 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88831 +#endif
88832 +
88833 static int nf_conntrack_init_net(struct net *net)
88834 {
88835 int ret;
88836 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
88837 goto err_stat;
88838 }
88839
88840 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88841 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88842 +#else
88843 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88844 +#endif
88845 if (!net->ct.slabname) {
88846 ret = -ENOMEM;
88847 goto err_slabname;
88848 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88849 index faa978f..1afb18f 100644
88850 --- a/net/netfilter/nf_conntrack_ecache.c
88851 +++ b/net/netfilter/nf_conntrack_ecache.c
88852 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88853 #ifdef CONFIG_SYSCTL
88854 static int nf_conntrack_event_init_sysctl(struct net *net)
88855 {
88856 - struct ctl_table *table;
88857 + ctl_table_no_const *table;
88858
88859 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88860 GFP_KERNEL);
88861 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88862 index 884f2b3..d53b33a 100644
88863 --- a/net/netfilter/nf_conntrack_helper.c
88864 +++ b/net/netfilter/nf_conntrack_helper.c
88865 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
88866
88867 static int nf_conntrack_helper_init_sysctl(struct net *net)
88868 {
88869 - struct ctl_table *table;
88870 + ctl_table_no_const *table;
88871
88872 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88873 GFP_KERNEL);
88874 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88875 index 51e928d..72a413a 100644
88876 --- a/net/netfilter/nf_conntrack_proto.c
88877 +++ b/net/netfilter/nf_conntrack_proto.c
88878 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88879
88880 static void
88881 nf_ct_unregister_sysctl(struct ctl_table_header **header,
88882 - struct ctl_table **table,
88883 + ctl_table_no_const **table,
88884 unsigned int users)
88885 {
88886 if (users > 0)
88887 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
88888 index e7185c6..4ad6c9c 100644
88889 --- a/net/netfilter/nf_conntrack_standalone.c
88890 +++ b/net/netfilter/nf_conntrack_standalone.c
88891 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
88892
88893 static int nf_conntrack_standalone_init_sysctl(struct net *net)
88894 {
88895 - struct ctl_table *table;
88896 + ctl_table_no_const *table;
88897
88898 if (net_eq(net, &init_net)) {
88899 nf_ct_netfilter_header =
88900 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
88901 index 7ea8026..bc9512d 100644
88902 --- a/net/netfilter/nf_conntrack_timestamp.c
88903 +++ b/net/netfilter/nf_conntrack_timestamp.c
88904 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
88905 #ifdef CONFIG_SYSCTL
88906 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
88907 {
88908 - struct ctl_table *table;
88909 + ctl_table_no_const *table;
88910
88911 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
88912 GFP_KERNEL);
88913 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
88914 index 9e31269..bc4c1b7 100644
88915 --- a/net/netfilter/nf_log.c
88916 +++ b/net/netfilter/nf_log.c
88917 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
88918
88919 #ifdef CONFIG_SYSCTL
88920 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
88921 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
88922 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
88923 static struct ctl_table_header *nf_log_dir_header;
88924
88925 static int nf_log_proc_dostring(ctl_table *table, int write,
88926 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
88927 rcu_assign_pointer(nf_loggers[tindex], logger);
88928 mutex_unlock(&nf_log_mutex);
88929 } else {
88930 + ctl_table_no_const nf_log_table = *table;
88931 +
88932 mutex_lock(&nf_log_mutex);
88933 logger = rcu_dereference_protected(nf_loggers[tindex],
88934 lockdep_is_held(&nf_log_mutex));
88935 if (!logger)
88936 - table->data = "NONE";
88937 + nf_log_table.data = "NONE";
88938 else
88939 - table->data = logger->name;
88940 - r = proc_dostring(table, write, buffer, lenp, ppos);
88941 + nf_log_table.data = logger->name;
88942 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
88943 mutex_unlock(&nf_log_mutex);
88944 }
88945
88946 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
88947 index f042ae5..30ea486 100644
88948 --- a/net/netfilter/nf_sockopt.c
88949 +++ b/net/netfilter/nf_sockopt.c
88950 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
88951 }
88952 }
88953
88954 - list_add(&reg->list, &nf_sockopts);
88955 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
88956 out:
88957 mutex_unlock(&nf_sockopt_mutex);
88958 return ret;
88959 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
88960 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
88961 {
88962 mutex_lock(&nf_sockopt_mutex);
88963 - list_del(&reg->list);
88964 + pax_list_del((struct list_head *)&reg->list);
88965 mutex_unlock(&nf_sockopt_mutex);
88966 }
88967 EXPORT_SYMBOL(nf_unregister_sockopt);
88968 diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
88969 index 589d686..dc3fd5d 100644
88970 --- a/net/netfilter/nfnetlink_acct.c
88971 +++ b/net/netfilter/nfnetlink_acct.c
88972 @@ -49,6 +49,8 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
88973 return -EINVAL;
88974
88975 acct_name = nla_data(tb[NFACCT_NAME]);
88976 + if (strlen(acct_name) == 0)
88977 + return -EINVAL;
88978
88979 list_for_each_entry(nfacct, &nfnl_acct_list, head) {
88980 if (strncmp(nfacct->name, acct_name, NFACCT_NAME_MAX) != 0)
88981 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
88982 index 92fd8ec..3f6ea4b 100644
88983 --- a/net/netfilter/nfnetlink_log.c
88984 +++ b/net/netfilter/nfnetlink_log.c
88985 @@ -72,7 +72,7 @@ struct nfulnl_instance {
88986 };
88987
88988 static DEFINE_SPINLOCK(instances_lock);
88989 -static atomic_t global_seq;
88990 +static atomic_unchecked_t global_seq;
88991
88992 #define INSTANCE_BUCKETS 16
88993 static struct hlist_head instance_table[INSTANCE_BUCKETS];
88994 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
88995 /* global sequence number */
88996 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
88997 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
88998 - htonl(atomic_inc_return(&global_seq))))
88999 + htonl(atomic_inc_return_unchecked(&global_seq))))
89000 goto nla_put_failure;
89001
89002 if (data_len) {
89003 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
89004 index 3158d87..39006c9 100644
89005 --- a/net/netfilter/nfnetlink_queue_core.c
89006 +++ b/net/netfilter/nfnetlink_queue_core.c
89007 @@ -1064,8 +1064,10 @@ static int __init nfnetlink_queue_init(void)
89008
89009 #ifdef CONFIG_PROC_FS
89010 if (!proc_create("nfnetlink_queue", 0440,
89011 - proc_net_netfilter, &nfqnl_file_ops))
89012 + proc_net_netfilter, &nfqnl_file_ops)) {
89013 + status = -ENOMEM;
89014 goto cleanup_subsys;
89015 + }
89016 #endif
89017
89018 register_netdevice_notifier(&nfqnl_dev_notifier);
89019 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89020 new file mode 100644
89021 index 0000000..c566332
89022 --- /dev/null
89023 +++ b/net/netfilter/xt_gradm.c
89024 @@ -0,0 +1,51 @@
89025 +/*
89026 + * gradm match for netfilter
89027 + * Copyright © Zbigniew Krzystolik, 2010
89028 + *
89029 + * This program is free software; you can redistribute it and/or modify
89030 + * it under the terms of the GNU General Public License; either version
89031 + * 2 or 3 as published by the Free Software Foundation.
89032 + */
89033 +#include <linux/module.h>
89034 +#include <linux/moduleparam.h>
89035 +#include <linux/skbuff.h>
89036 +#include <linux/netfilter/x_tables.h>
89037 +#include <linux/grsecurity.h>
89038 +#include <linux/netfilter/xt_gradm.h>
89039 +
89040 +static bool
89041 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89042 +{
89043 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89044 + bool retval = false;
89045 + if (gr_acl_is_enabled())
89046 + retval = true;
89047 + return retval ^ info->invflags;
89048 +}
89049 +
89050 +static struct xt_match gradm_mt_reg __read_mostly = {
89051 + .name = "gradm",
89052 + .revision = 0,
89053 + .family = NFPROTO_UNSPEC,
89054 + .match = gradm_mt,
89055 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89056 + .me = THIS_MODULE,
89057 +};
89058 +
89059 +static int __init gradm_mt_init(void)
89060 +{
89061 + return xt_register_match(&gradm_mt_reg);
89062 +}
89063 +
89064 +static void __exit gradm_mt_exit(void)
89065 +{
89066 + xt_unregister_match(&gradm_mt_reg);
89067 +}
89068 +
89069 +module_init(gradm_mt_init);
89070 +module_exit(gradm_mt_exit);
89071 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89072 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89073 +MODULE_LICENSE("GPL");
89074 +MODULE_ALIAS("ipt_gradm");
89075 +MODULE_ALIAS("ip6t_gradm");
89076 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89077 index 4fe4fb4..87a89e5 100644
89078 --- a/net/netfilter/xt_statistic.c
89079 +++ b/net/netfilter/xt_statistic.c
89080 @@ -19,7 +19,7 @@
89081 #include <linux/module.h>
89082
89083 struct xt_statistic_priv {
89084 - atomic_t count;
89085 + atomic_unchecked_t count;
89086 } ____cacheline_aligned_in_smp;
89087
89088 MODULE_LICENSE("GPL");
89089 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89090 break;
89091 case XT_STATISTIC_MODE_NTH:
89092 do {
89093 - oval = atomic_read(&info->master->count);
89094 + oval = atomic_read_unchecked(&info->master->count);
89095 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89096 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89097 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89098 if (nval == 0)
89099 ret = !ret;
89100 break;
89101 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89102 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89103 if (info->master == NULL)
89104 return -ENOMEM;
89105 - atomic_set(&info->master->count, info->u.nth.count);
89106 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89107
89108 return 0;
89109 }
89110 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89111 index c0353d5..fcb0270 100644
89112 --- a/net/netlink/af_netlink.c
89113 +++ b/net/netlink/af_netlink.c
89114 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
89115 sk->sk_error_report(sk);
89116 }
89117 }
89118 - atomic_inc(&sk->sk_drops);
89119 + atomic_inc_unchecked(&sk->sk_drops);
89120 }
89121
89122 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89123 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89124 sk_wmem_alloc_get(s),
89125 nlk->cb,
89126 atomic_read(&s->sk_refcnt),
89127 - atomic_read(&s->sk_drops),
89128 + atomic_read_unchecked(&s->sk_drops),
89129 sock_i_ino(s)
89130 );
89131
89132 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89133 index 5a55be3..7630745 100644
89134 --- a/net/netlink/genetlink.c
89135 +++ b/net/netlink/genetlink.c
89136 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89137 goto errout;
89138 }
89139
89140 + pax_open_kernel();
89141 if (ops->dumpit)
89142 - ops->flags |= GENL_CMD_CAP_DUMP;
89143 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89144 if (ops->doit)
89145 - ops->flags |= GENL_CMD_CAP_DO;
89146 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89147 if (ops->policy)
89148 - ops->flags |= GENL_CMD_CAP_HASPOL;
89149 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89150 + pax_close_kernel();
89151
89152 genl_lock();
89153 - list_add_tail(&ops->ops_list, &family->ops_list);
89154 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89155 genl_unlock();
89156
89157 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89158 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89159 err = 0;
89160 errout:
89161 return err;
89162 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89163 genl_lock();
89164 list_for_each_entry(rc, &family->ops_list, ops_list) {
89165 if (rc == ops) {
89166 - list_del(&ops->ops_list);
89167 + pax_list_del((struct list_head *)&ops->ops_list);
89168 genl_unlock();
89169 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89170 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89171 return 0;
89172 }
89173 }
89174 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89175 index 14c106b..2d58b38 100644
89176 --- a/net/netrom/af_netrom.c
89177 +++ b/net/netrom/af_netrom.c
89178 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89179 struct sock *sk = sock->sk;
89180 struct nr_sock *nr = nr_sk(sk);
89181
89182 + memset(sax, 0, sizeof(*sax));
89183 lock_sock(sk);
89184 if (peer != 0) {
89185 if (sk->sk_state != TCP_ESTABLISHED) {
89186 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89187 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89188 } else {
89189 sax->fsa_ax25.sax25_family = AF_NETROM;
89190 - sax->fsa_ax25.sax25_ndigis = 0;
89191 sax->fsa_ax25.sax25_call = nr->source_addr;
89192 *uaddr_len = sizeof(struct sockaddr_ax25);
89193 }
89194 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89195 index c111bd0..7788ff7 100644
89196 --- a/net/packet/af_packet.c
89197 +++ b/net/packet/af_packet.c
89198 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89199
89200 spin_lock(&sk->sk_receive_queue.lock);
89201 po->stats.tp_packets++;
89202 - skb->dropcount = atomic_read(&sk->sk_drops);
89203 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89204 __skb_queue_tail(&sk->sk_receive_queue, skb);
89205 spin_unlock(&sk->sk_receive_queue.lock);
89206 sk->sk_data_ready(sk, skb->len);
89207 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89208 drop_n_acct:
89209 spin_lock(&sk->sk_receive_queue.lock);
89210 po->stats.tp_drops++;
89211 - atomic_inc(&sk->sk_drops);
89212 + atomic_inc_unchecked(&sk->sk_drops);
89213 spin_unlock(&sk->sk_receive_queue.lock);
89214
89215 drop_n_restore:
89216 @@ -2565,6 +2565,7 @@ out:
89217
89218 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89219 {
89220 + struct sock_extended_err ee;
89221 struct sock_exterr_skb *serr;
89222 struct sk_buff *skb, *skb2;
89223 int copied, err;
89224 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89225 sock_recv_timestamp(msg, sk, skb);
89226
89227 serr = SKB_EXT_ERR(skb);
89228 + ee = serr->ee;
89229 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89230 - sizeof(serr->ee), &serr->ee);
89231 + sizeof ee, &ee);
89232
89233 msg->msg_flags |= MSG_ERRQUEUE;
89234 err = copied;
89235 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89236 case PACKET_HDRLEN:
89237 if (len > sizeof(int))
89238 len = sizeof(int);
89239 - if (copy_from_user(&val, optval, len))
89240 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89241 return -EFAULT;
89242 switch (val) {
89243 case TPACKET_V1:
89244 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89245 len = lv;
89246 if (put_user(len, optlen))
89247 return -EFAULT;
89248 - if (copy_to_user(optval, data, len))
89249 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89250 return -EFAULT;
89251 return 0;
89252 }
89253 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89254 index 5a940db..f0b9c12 100644
89255 --- a/net/phonet/af_phonet.c
89256 +++ b/net/phonet/af_phonet.c
89257 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
89258 {
89259 struct phonet_protocol *pp;
89260
89261 - if (protocol >= PHONET_NPROTO)
89262 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89263 return NULL;
89264
89265 rcu_read_lock();
89266 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89267 {
89268 int err = 0;
89269
89270 - if (protocol >= PHONET_NPROTO)
89271 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89272 return -EINVAL;
89273
89274 err = proto_register(pp->prot, 1);
89275 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89276 index 576f22c..bc7a71b 100644
89277 --- a/net/phonet/pep.c
89278 +++ b/net/phonet/pep.c
89279 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89280
89281 case PNS_PEP_CTRL_REQ:
89282 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89283 - atomic_inc(&sk->sk_drops);
89284 + atomic_inc_unchecked(&sk->sk_drops);
89285 break;
89286 }
89287 __skb_pull(skb, 4);
89288 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89289 }
89290
89291 if (pn->rx_credits == 0) {
89292 - atomic_inc(&sk->sk_drops);
89293 + atomic_inc_unchecked(&sk->sk_drops);
89294 err = -ENOBUFS;
89295 break;
89296 }
89297 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89298 }
89299
89300 if (pn->rx_credits == 0) {
89301 - atomic_inc(&sk->sk_drops);
89302 + atomic_inc_unchecked(&sk->sk_drops);
89303 err = NET_RX_DROP;
89304 break;
89305 }
89306 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89307 index b7e9827..c264c85 100644
89308 --- a/net/phonet/socket.c
89309 +++ b/net/phonet/socket.c
89310 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89311 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89312 sock_i_ino(sk),
89313 atomic_read(&sk->sk_refcnt), sk,
89314 - atomic_read(&sk->sk_drops), &len);
89315 + atomic_read_unchecked(&sk->sk_drops), &len);
89316 }
89317 seq_printf(seq, "%*s\n", 127 - len, "");
89318 return 0;
89319 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89320 index d6bbbbd..61561e4 100644
89321 --- a/net/phonet/sysctl.c
89322 +++ b/net/phonet/sysctl.c
89323 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89324 {
89325 int ret;
89326 int range[2] = {local_port_range[0], local_port_range[1]};
89327 - ctl_table tmp = {
89328 + ctl_table_no_const tmp = {
89329 .data = &range,
89330 .maxlen = sizeof(range),
89331 .mode = table->mode,
89332 diff --git a/net/rds/cong.c b/net/rds/cong.c
89333 index e5b65ac..f3b6fb7 100644
89334 --- a/net/rds/cong.c
89335 +++ b/net/rds/cong.c
89336 @@ -78,7 +78,7 @@
89337 * finds that the saved generation number is smaller than the global generation
89338 * number, it wakes up the process.
89339 */
89340 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89341 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89342
89343 /*
89344 * Congestion monitoring
89345 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89346 rdsdebug("waking map %p for %pI4\n",
89347 map, &map->m_addr);
89348 rds_stats_inc(s_cong_update_received);
89349 - atomic_inc(&rds_cong_generation);
89350 + atomic_inc_unchecked(&rds_cong_generation);
89351 if (waitqueue_active(&map->m_waitq))
89352 wake_up(&map->m_waitq);
89353 if (waitqueue_active(&rds_poll_waitq))
89354 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89355
89356 int rds_cong_updated_since(unsigned long *recent)
89357 {
89358 - unsigned long gen = atomic_read(&rds_cong_generation);
89359 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89360
89361 if (likely(*recent == gen))
89362 return 0;
89363 diff --git a/net/rds/ib.h b/net/rds/ib.h
89364 index 7280ab8..e04f4ea 100644
89365 --- a/net/rds/ib.h
89366 +++ b/net/rds/ib.h
89367 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89368 /* sending acks */
89369 unsigned long i_ack_flags;
89370 #ifdef KERNEL_HAS_ATOMIC64
89371 - atomic64_t i_ack_next; /* next ACK to send */
89372 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89373 #else
89374 spinlock_t i_ack_lock; /* protect i_ack_next */
89375 u64 i_ack_next; /* next ACK to send */
89376 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89377 index 31b74f5..dc1fbfa 100644
89378 --- a/net/rds/ib_cm.c
89379 +++ b/net/rds/ib_cm.c
89380 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89381 /* Clear the ACK state */
89382 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89383 #ifdef KERNEL_HAS_ATOMIC64
89384 - atomic64_set(&ic->i_ack_next, 0);
89385 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89386 #else
89387 ic->i_ack_next = 0;
89388 #endif
89389 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89390 index 8eb9501..0c386ff 100644
89391 --- a/net/rds/ib_recv.c
89392 +++ b/net/rds/ib_recv.c
89393 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89394 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89395 int ack_required)
89396 {
89397 - atomic64_set(&ic->i_ack_next, seq);
89398 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89399 if (ack_required) {
89400 smp_mb__before_clear_bit();
89401 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89402 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89403 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89404 smp_mb__after_clear_bit();
89405
89406 - return atomic64_read(&ic->i_ack_next);
89407 + return atomic64_read_unchecked(&ic->i_ack_next);
89408 }
89409 #endif
89410
89411 diff --git a/net/rds/iw.h b/net/rds/iw.h
89412 index 04ce3b1..48119a6 100644
89413 --- a/net/rds/iw.h
89414 +++ b/net/rds/iw.h
89415 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89416 /* sending acks */
89417 unsigned long i_ack_flags;
89418 #ifdef KERNEL_HAS_ATOMIC64
89419 - atomic64_t i_ack_next; /* next ACK to send */
89420 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89421 #else
89422 spinlock_t i_ack_lock; /* protect i_ack_next */
89423 u64 i_ack_next; /* next ACK to send */
89424 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89425 index a91e1db..cf3053f 100644
89426 --- a/net/rds/iw_cm.c
89427 +++ b/net/rds/iw_cm.c
89428 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89429 /* Clear the ACK state */
89430 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89431 #ifdef KERNEL_HAS_ATOMIC64
89432 - atomic64_set(&ic->i_ack_next, 0);
89433 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89434 #else
89435 ic->i_ack_next = 0;
89436 #endif
89437 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89438 index 4503335..db566b4 100644
89439 --- a/net/rds/iw_recv.c
89440 +++ b/net/rds/iw_recv.c
89441 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89442 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89443 int ack_required)
89444 {
89445 - atomic64_set(&ic->i_ack_next, seq);
89446 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89447 if (ack_required) {
89448 smp_mb__before_clear_bit();
89449 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89450 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89451 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89452 smp_mb__after_clear_bit();
89453
89454 - return atomic64_read(&ic->i_ack_next);
89455 + return atomic64_read_unchecked(&ic->i_ack_next);
89456 }
89457 #endif
89458
89459 diff --git a/net/rds/rds.h b/net/rds/rds.h
89460 index ec1d731..90a3a8d 100644
89461 --- a/net/rds/rds.h
89462 +++ b/net/rds/rds.h
89463 @@ -449,7 +449,7 @@ struct rds_transport {
89464 void (*sync_mr)(void *trans_private, int direction);
89465 void (*free_mr)(void *trans_private, int invalidate);
89466 void (*flush_mrs)(void);
89467 -};
89468 +} __do_const;
89469
89470 struct rds_sock {
89471 struct sock rs_sk;
89472 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89473 index edac9ef..16bcb98 100644
89474 --- a/net/rds/tcp.c
89475 +++ b/net/rds/tcp.c
89476 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89477 int val = 1;
89478
89479 set_fs(KERNEL_DS);
89480 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89481 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89482 sizeof(val));
89483 set_fs(oldfs);
89484 }
89485 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89486 index 81cf5a4..b5826ff 100644
89487 --- a/net/rds/tcp_send.c
89488 +++ b/net/rds/tcp_send.c
89489 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89490
89491 oldfs = get_fs();
89492 set_fs(KERNEL_DS);
89493 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89494 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89495 sizeof(val));
89496 set_fs(oldfs);
89497 }
89498 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89499 index 05996d0..5a1dfe0 100644
89500 --- a/net/rxrpc/af_rxrpc.c
89501 +++ b/net/rxrpc/af_rxrpc.c
89502 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89503 __be32 rxrpc_epoch;
89504
89505 /* current debugging ID */
89506 -atomic_t rxrpc_debug_id;
89507 +atomic_unchecked_t rxrpc_debug_id;
89508
89509 /* count of skbs currently in use */
89510 atomic_t rxrpc_n_skbs;
89511 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89512 index e4d9cbc..b229649 100644
89513 --- a/net/rxrpc/ar-ack.c
89514 +++ b/net/rxrpc/ar-ack.c
89515 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89516
89517 _enter("{%d,%d,%d,%d},",
89518 call->acks_hard, call->acks_unacked,
89519 - atomic_read(&call->sequence),
89520 + atomic_read_unchecked(&call->sequence),
89521 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89522
89523 stop = 0;
89524 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89525
89526 /* each Tx packet has a new serial number */
89527 sp->hdr.serial =
89528 - htonl(atomic_inc_return(&call->conn->serial));
89529 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89530
89531 hdr = (struct rxrpc_header *) txb->head;
89532 hdr->serial = sp->hdr.serial;
89533 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89534 */
89535 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89536 {
89537 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89538 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89539 }
89540
89541 /*
89542 @@ -629,7 +629,7 @@ process_further:
89543
89544 latest = ntohl(sp->hdr.serial);
89545 hard = ntohl(ack.firstPacket);
89546 - tx = atomic_read(&call->sequence);
89547 + tx = atomic_read_unchecked(&call->sequence);
89548
89549 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89550 latest,
89551 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89552 goto maybe_reschedule;
89553
89554 send_ACK_with_skew:
89555 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89556 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89557 ntohl(ack.serial));
89558 send_ACK:
89559 mtu = call->conn->trans->peer->if_mtu;
89560 @@ -1173,7 +1173,7 @@ send_ACK:
89561 ackinfo.rxMTU = htonl(5692);
89562 ackinfo.jumbo_max = htonl(4);
89563
89564 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89565 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89566 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89567 ntohl(hdr.serial),
89568 ntohs(ack.maxSkew),
89569 @@ -1191,7 +1191,7 @@ send_ACK:
89570 send_message:
89571 _debug("send message");
89572
89573 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89574 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89575 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89576 send_message_2:
89577
89578 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89579 index a3bbb36..3341fb9 100644
89580 --- a/net/rxrpc/ar-call.c
89581 +++ b/net/rxrpc/ar-call.c
89582 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89583 spin_lock_init(&call->lock);
89584 rwlock_init(&call->state_lock);
89585 atomic_set(&call->usage, 1);
89586 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89587 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89588 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89589
89590 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89591 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89592 index 4106ca9..a338d7a 100644
89593 --- a/net/rxrpc/ar-connection.c
89594 +++ b/net/rxrpc/ar-connection.c
89595 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89596 rwlock_init(&conn->lock);
89597 spin_lock_init(&conn->state_lock);
89598 atomic_set(&conn->usage, 1);
89599 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89600 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89601 conn->avail_calls = RXRPC_MAXCALLS;
89602 conn->size_align = 4;
89603 conn->header_size = sizeof(struct rxrpc_header);
89604 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89605 index e7ed43a..6afa140 100644
89606 --- a/net/rxrpc/ar-connevent.c
89607 +++ b/net/rxrpc/ar-connevent.c
89608 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89609
89610 len = iov[0].iov_len + iov[1].iov_len;
89611
89612 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89613 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89614 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89615
89616 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89617 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89618 index 529572f..c758ca7 100644
89619 --- a/net/rxrpc/ar-input.c
89620 +++ b/net/rxrpc/ar-input.c
89621 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89622 /* track the latest serial number on this connection for ACK packet
89623 * information */
89624 serial = ntohl(sp->hdr.serial);
89625 - hi_serial = atomic_read(&call->conn->hi_serial);
89626 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89627 while (serial > hi_serial)
89628 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89629 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89630 serial);
89631
89632 /* request ACK generation for any ACK or DATA packet that requests
89633 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89634 index a693aca..81e7293 100644
89635 --- a/net/rxrpc/ar-internal.h
89636 +++ b/net/rxrpc/ar-internal.h
89637 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89638 int error; /* error code for local abort */
89639 int debug_id; /* debug ID for printks */
89640 unsigned int call_counter; /* call ID counter */
89641 - atomic_t serial; /* packet serial number counter */
89642 - atomic_t hi_serial; /* highest serial number received */
89643 + atomic_unchecked_t serial; /* packet serial number counter */
89644 + atomic_unchecked_t hi_serial; /* highest serial number received */
89645 u8 avail_calls; /* number of calls available */
89646 u8 size_align; /* data size alignment (for security) */
89647 u8 header_size; /* rxrpc + security header size */
89648 @@ -346,7 +346,7 @@ struct rxrpc_call {
89649 spinlock_t lock;
89650 rwlock_t state_lock; /* lock for state transition */
89651 atomic_t usage;
89652 - atomic_t sequence; /* Tx data packet sequence counter */
89653 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89654 u32 abort_code; /* local/remote abort code */
89655 enum { /* current state of call */
89656 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89657 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89658 */
89659 extern atomic_t rxrpc_n_skbs;
89660 extern __be32 rxrpc_epoch;
89661 -extern atomic_t rxrpc_debug_id;
89662 +extern atomic_unchecked_t rxrpc_debug_id;
89663 extern struct workqueue_struct *rxrpc_workqueue;
89664
89665 /*
89666 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89667 index 87f7135..74d3703 100644
89668 --- a/net/rxrpc/ar-local.c
89669 +++ b/net/rxrpc/ar-local.c
89670 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89671 spin_lock_init(&local->lock);
89672 rwlock_init(&local->services_lock);
89673 atomic_set(&local->usage, 1);
89674 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89675 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89676 memcpy(&local->srx, srx, sizeof(*srx));
89677 }
89678
89679 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89680 index e1ac183..b43e10e 100644
89681 --- a/net/rxrpc/ar-output.c
89682 +++ b/net/rxrpc/ar-output.c
89683 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89684 sp->hdr.cid = call->cid;
89685 sp->hdr.callNumber = call->call_id;
89686 sp->hdr.seq =
89687 - htonl(atomic_inc_return(&call->sequence));
89688 + htonl(atomic_inc_return_unchecked(&call->sequence));
89689 sp->hdr.serial =
89690 - htonl(atomic_inc_return(&conn->serial));
89691 + htonl(atomic_inc_return_unchecked(&conn->serial));
89692 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89693 sp->hdr.userStatus = 0;
89694 sp->hdr.securityIndex = conn->security_ix;
89695 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89696 index bebaa43..2644591 100644
89697 --- a/net/rxrpc/ar-peer.c
89698 +++ b/net/rxrpc/ar-peer.c
89699 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89700 INIT_LIST_HEAD(&peer->error_targets);
89701 spin_lock_init(&peer->lock);
89702 atomic_set(&peer->usage, 1);
89703 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89704 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89705 memcpy(&peer->srx, srx, sizeof(*srx));
89706
89707 rxrpc_assess_MTU_size(peer);
89708 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89709 index 38047f7..9f48511 100644
89710 --- a/net/rxrpc/ar-proc.c
89711 +++ b/net/rxrpc/ar-proc.c
89712 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89713 atomic_read(&conn->usage),
89714 rxrpc_conn_states[conn->state],
89715 key_serial(conn->key),
89716 - atomic_read(&conn->serial),
89717 - atomic_read(&conn->hi_serial));
89718 + atomic_read_unchecked(&conn->serial),
89719 + atomic_read_unchecked(&conn->hi_serial));
89720
89721 return 0;
89722 }
89723 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89724 index 92df566..87ec1bf 100644
89725 --- a/net/rxrpc/ar-transport.c
89726 +++ b/net/rxrpc/ar-transport.c
89727 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89728 spin_lock_init(&trans->client_lock);
89729 rwlock_init(&trans->conn_lock);
89730 atomic_set(&trans->usage, 1);
89731 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89732 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89733
89734 if (peer->srx.transport.family == AF_INET) {
89735 switch (peer->srx.transport_type) {
89736 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89737 index f226709..0e735a8 100644
89738 --- a/net/rxrpc/rxkad.c
89739 +++ b/net/rxrpc/rxkad.c
89740 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89741
89742 len = iov[0].iov_len + iov[1].iov_len;
89743
89744 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89745 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89746 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89747
89748 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89749 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89750
89751 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89752
89753 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89754 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89755 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89756
89757 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89758 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89759 index 391a245..296b3d7 100644
89760 --- a/net/sctp/ipv6.c
89761 +++ b/net/sctp/ipv6.c
89762 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89763 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89764 };
89765
89766 -static struct sctp_af sctp_af_inet6 = {
89767 +static struct sctp_af sctp_af_inet6 __read_only = {
89768 .sa_family = AF_INET6,
89769 .sctp_xmit = sctp_v6_xmit,
89770 .setsockopt = ipv6_setsockopt,
89771 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89772 #endif
89773 };
89774
89775 -static struct sctp_pf sctp_pf_inet6 = {
89776 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89777 .event_msgname = sctp_inet6_event_msgname,
89778 .skb_msgname = sctp_inet6_skb_msgname,
89779 .af_supported = sctp_inet6_af_supported,
89780 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89781
89782 void sctp_v6_pf_exit(void)
89783 {
89784 - list_del(&sctp_af_inet6.list);
89785 + pax_list_del(&sctp_af_inet6.list);
89786 }
89787
89788 /* Initialize IPv6 support and register with socket layer. */
89789 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89790 index 8c19e97..16264b8 100644
89791 --- a/net/sctp/proc.c
89792 +++ b/net/sctp/proc.c
89793 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89794 seq_printf(seq,
89795 "%8pK %8pK %-3d %-3d %-2d %-4d "
89796 "%4d %8d %8d %7d %5lu %-5d %5d ",
89797 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89798 + assoc, sk,
89799 + sctp_sk(sk)->type, sk->sk_state,
89800 assoc->state, hash,
89801 assoc->assoc_id,
89802 assoc->sndbuf_used,
89803 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89804 index f898b1c..a2d0fe8 100644
89805 --- a/net/sctp/protocol.c
89806 +++ b/net/sctp/protocol.c
89807 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89808 return 0;
89809 }
89810
89811 + pax_open_kernel();
89812 INIT_LIST_HEAD(&af->list);
89813 - list_add_tail(&af->list, &sctp_address_families);
89814 + pax_close_kernel();
89815 + pax_list_add_tail(&af->list, &sctp_address_families);
89816 return 1;
89817 }
89818
89819 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89820
89821 static struct sctp_af sctp_af_inet;
89822
89823 -static struct sctp_pf sctp_pf_inet = {
89824 +static struct sctp_pf sctp_pf_inet __read_only = {
89825 .event_msgname = sctp_inet_event_msgname,
89826 .skb_msgname = sctp_inet_skb_msgname,
89827 .af_supported = sctp_inet_af_supported,
89828 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89829 };
89830
89831 /* IPv4 address related functions. */
89832 -static struct sctp_af sctp_af_inet = {
89833 +static struct sctp_af sctp_af_inet __read_only = {
89834 .sa_family = AF_INET,
89835 .sctp_xmit = sctp_v4_xmit,
89836 .setsockopt = ip_setsockopt,
89837 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89838
89839 static void sctp_v4_pf_exit(void)
89840 {
89841 - list_del(&sctp_af_inet.list);
89842 + pax_list_del(&sctp_af_inet.list);
89843 }
89844
89845 static int sctp_v4_protosw_init(void)
89846 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89847 index c957775..6d4593a 100644
89848 --- a/net/sctp/sm_sideeffect.c
89849 +++ b/net/sctp/sm_sideeffect.c
89850 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89851 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89852 }
89853
89854 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89855 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89856 NULL,
89857 sctp_generate_t1_cookie_event,
89858 sctp_generate_t1_init_event,
89859 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89860 index 9ef5c73..1e9a9a9 100644
89861 --- a/net/sctp/socket.c
89862 +++ b/net/sctp/socket.c
89863 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89864 {
89865 struct sctp_association *asoc;
89866 struct sctp_ulpevent *event;
89867 + struct sctp_event_subscribe subscribe;
89868
89869 if (optlen > sizeof(struct sctp_event_subscribe))
89870 return -EINVAL;
89871 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89872 + if (copy_from_user(&subscribe, optval, optlen))
89873 return -EFAULT;
89874 + sctp_sk(sk)->subscribe = subscribe;
89875
89876 /*
89877 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
89878 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
89879 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89880 int __user *optlen)
89881 {
89882 + struct sctp_event_subscribe subscribe;
89883 +
89884 if (len <= 0)
89885 return -EINVAL;
89886 if (len > sizeof(struct sctp_event_subscribe))
89887 len = sizeof(struct sctp_event_subscribe);
89888 if (put_user(len, optlen))
89889 return -EFAULT;
89890 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
89891 + subscribe = sctp_sk(sk)->subscribe;
89892 + if (copy_to_user(optval, &subscribe, len))
89893 return -EFAULT;
89894 return 0;
89895 }
89896 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89897 */
89898 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
89899 {
89900 + __u32 autoclose;
89901 +
89902 /* Applicable to UDP-style socket only */
89903 if (sctp_style(sk, TCP))
89904 return -EOPNOTSUPP;
89905 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
89906 len = sizeof(int);
89907 if (put_user(len, optlen))
89908 return -EFAULT;
89909 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
89910 + autoclose = sctp_sk(sk)->autoclose;
89911 + if (copy_to_user(optval, &autoclose, sizeof(int)))
89912 return -EFAULT;
89913 return 0;
89914 }
89915 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
89916 */
89917 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
89918 {
89919 + struct sctp_initmsg initmsg;
89920 +
89921 if (len < sizeof(struct sctp_initmsg))
89922 return -EINVAL;
89923 len = sizeof(struct sctp_initmsg);
89924 if (put_user(len, optlen))
89925 return -EFAULT;
89926 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
89927 + initmsg = sctp_sk(sk)->initmsg;
89928 + if (copy_to_user(optval, &initmsg, len))
89929 return -EFAULT;
89930 return 0;
89931 }
89932 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
89933 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
89934 if (space_left < addrlen)
89935 return -ENOMEM;
89936 + if (addrlen > sizeof(temp) || addrlen < 0)
89937 + return -EFAULT;
89938 if (copy_to_user(to, &temp, addrlen))
89939 return -EFAULT;
89940 to += addrlen;
89941 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
89942 index 442ad4e..825ea94 100644
89943 --- a/net/sctp/ssnmap.c
89944 +++ b/net/sctp/ssnmap.c
89945 @@ -41,8 +41,6 @@
89946 #include <net/sctp/sctp.h>
89947 #include <net/sctp/sm.h>
89948
89949 -#define MAX_KMALLOC_SIZE 131072
89950 -
89951 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
89952 __u16 out);
89953
89954 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
89955 int size;
89956
89957 size = sctp_ssnmap_size(in, out);
89958 - if (size <= MAX_KMALLOC_SIZE)
89959 + if (size <= KMALLOC_MAX_SIZE)
89960 retval = kmalloc(size, gfp);
89961 else
89962 retval = (struct sctp_ssnmap *)
89963 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
89964 return retval;
89965
89966 fail_map:
89967 - if (size <= MAX_KMALLOC_SIZE)
89968 + if (size <= KMALLOC_MAX_SIZE)
89969 kfree(retval);
89970 else
89971 free_pages((unsigned long)retval, get_order(size));
89972 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
89973 int size;
89974
89975 size = sctp_ssnmap_size(map->in.len, map->out.len);
89976 - if (size <= MAX_KMALLOC_SIZE)
89977 + if (size <= KMALLOC_MAX_SIZE)
89978 kfree(map);
89979 else
89980 free_pages((unsigned long)map, get_order(size));
89981 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
89982 index bf3c6e8..376d8d0 100644
89983 --- a/net/sctp/sysctl.c
89984 +++ b/net/sctp/sysctl.c
89985 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89986 {
89987 struct net *net = current->nsproxy->net_ns;
89988 char tmp[8];
89989 - ctl_table tbl;
89990 + ctl_table_no_const tbl;
89991 int ret;
89992 int changed = 0;
89993 char *none = "none";
89994 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89995
89996 int sctp_sysctl_net_register(struct net *net)
89997 {
89998 - struct ctl_table *table;
89999 + ctl_table_no_const *table;
90000 int i;
90001
90002 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90003 diff --git a/net/socket.c b/net/socket.c
90004 index 2ca51c7..ee5feb5 100644
90005 --- a/net/socket.c
90006 +++ b/net/socket.c
90007 @@ -89,6 +89,7 @@
90008 #include <linux/magic.h>
90009 #include <linux/slab.h>
90010 #include <linux/xattr.h>
90011 +#include <linux/in.h>
90012
90013 #include <asm/uaccess.h>
90014 #include <asm/unistd.h>
90015 @@ -106,6 +107,8 @@
90016 #include <linux/sockios.h>
90017 #include <linux/atalk.h>
90018
90019 +#include <linux/grsock.h>
90020 +
90021 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90022 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90023 unsigned long nr_segs, loff_t pos);
90024 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90025 &sockfs_dentry_operations, SOCKFS_MAGIC);
90026 }
90027
90028 -static struct vfsmount *sock_mnt __read_mostly;
90029 +struct vfsmount *sock_mnt __read_mostly;
90030
90031 static struct file_system_type sock_fs_type = {
90032 .name = "sockfs",
90033 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90034 return -EAFNOSUPPORT;
90035 if (type < 0 || type >= SOCK_MAX)
90036 return -EINVAL;
90037 + if (protocol < 0)
90038 + return -EINVAL;
90039
90040 /* Compatibility.
90041
90042 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90043 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90044 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90045
90046 + if(!gr_search_socket(family, type, protocol)) {
90047 + retval = -EACCES;
90048 + goto out;
90049 + }
90050 +
90051 + if (gr_handle_sock_all(family, type, protocol)) {
90052 + retval = -EACCES;
90053 + goto out;
90054 + }
90055 +
90056 retval = sock_create(family, type, protocol, &sock);
90057 if (retval < 0)
90058 goto out;
90059 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90060 if (sock) {
90061 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90062 if (err >= 0) {
90063 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90064 + err = -EACCES;
90065 + goto error;
90066 + }
90067 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90068 + if (err)
90069 + goto error;
90070 +
90071 err = security_socket_bind(sock,
90072 (struct sockaddr *)&address,
90073 addrlen);
90074 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90075 (struct sockaddr *)
90076 &address, addrlen);
90077 }
90078 +error:
90079 fput_light(sock->file, fput_needed);
90080 }
90081 return err;
90082 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90083 if ((unsigned int)backlog > somaxconn)
90084 backlog = somaxconn;
90085
90086 + if (gr_handle_sock_server_other(sock->sk)) {
90087 + err = -EPERM;
90088 + goto error;
90089 + }
90090 +
90091 + err = gr_search_listen(sock);
90092 + if (err)
90093 + goto error;
90094 +
90095 err = security_socket_listen(sock, backlog);
90096 if (!err)
90097 err = sock->ops->listen(sock, backlog);
90098
90099 +error:
90100 fput_light(sock->file, fput_needed);
90101 }
90102 return err;
90103 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90104 newsock->type = sock->type;
90105 newsock->ops = sock->ops;
90106
90107 + if (gr_handle_sock_server_other(sock->sk)) {
90108 + err = -EPERM;
90109 + sock_release(newsock);
90110 + goto out_put;
90111 + }
90112 +
90113 + err = gr_search_accept(sock);
90114 + if (err) {
90115 + sock_release(newsock);
90116 + goto out_put;
90117 + }
90118 +
90119 /*
90120 * We don't need try_module_get here, as the listening socket (sock)
90121 * has the protocol module (sock->ops->owner) held.
90122 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90123 fd_install(newfd, newfile);
90124 err = newfd;
90125
90126 + gr_attach_curr_ip(newsock->sk);
90127 +
90128 out_put:
90129 fput_light(sock->file, fput_needed);
90130 out:
90131 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90132 int, addrlen)
90133 {
90134 struct socket *sock;
90135 + struct sockaddr *sck;
90136 struct sockaddr_storage address;
90137 int err, fput_needed;
90138
90139 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90140 if (err < 0)
90141 goto out_put;
90142
90143 + sck = (struct sockaddr *)&address;
90144 +
90145 + if (gr_handle_sock_client(sck)) {
90146 + err = -EACCES;
90147 + goto out_put;
90148 + }
90149 +
90150 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90151 + if (err)
90152 + goto out_put;
90153 +
90154 err =
90155 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90156 if (err)
90157 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90158 * the protocol.
90159 */
90160
90161 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90162 +
90163 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90164 unsigned int, flags, struct sockaddr __user *, addr,
90165 int, addr_len)
90166 @@ -1840,7 +1902,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90167 struct socket *sock;
90168 struct iovec iov;
90169 struct msghdr msg;
90170 - struct sockaddr_storage address;
90171 + struct sockaddr_storage address = { };
90172 int err, err2;
90173 int fput_needed;
90174
90175 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90176 * checking falls down on this.
90177 */
90178 if (copy_from_user(ctl_buf,
90179 - (void __user __force *)msg_sys->msg_control,
90180 + (void __force_user *)msg_sys->msg_control,
90181 ctl_len))
90182 goto out_freectl;
90183 msg_sys->msg_control = ctl_buf;
90184 @@ -2187,7 +2249,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90185 int err, total_len, len;
90186
90187 /* kernel mode address */
90188 - struct sockaddr_storage addr;
90189 + struct sockaddr_storage addr = { };
90190
90191 /* user mode address pointers */
90192 struct sockaddr __user *uaddr;
90193 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90194 * kernel msghdr to use the kernel address space)
90195 */
90196
90197 - uaddr = (__force void __user *)msg_sys->msg_name;
90198 + uaddr = (void __force_user *)msg_sys->msg_name;
90199 uaddr_len = COMPAT_NAMELEN(msg);
90200 if (MSG_CMSG_COMPAT & flags) {
90201 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90202 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90203 }
90204
90205 ifr = compat_alloc_user_space(buf_size);
90206 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
90207 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
90208
90209 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
90210 return -EFAULT;
90211 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90212 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
90213
90214 if (copy_in_user(rxnfc, compat_rxnfc,
90215 - (void *)(&rxnfc->fs.m_ext + 1) -
90216 - (void *)rxnfc) ||
90217 + (void __user *)(&rxnfc->fs.m_ext + 1) -
90218 + (void __user *)rxnfc) ||
90219 copy_in_user(&rxnfc->fs.ring_cookie,
90220 &compat_rxnfc->fs.ring_cookie,
90221 - (void *)(&rxnfc->fs.location + 1) -
90222 - (void *)&rxnfc->fs.ring_cookie) ||
90223 + (void __user *)(&rxnfc->fs.location + 1) -
90224 + (void __user *)&rxnfc->fs.ring_cookie) ||
90225 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
90226 sizeof(rxnfc->rule_cnt)))
90227 return -EFAULT;
90228 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90229
90230 if (convert_out) {
90231 if (copy_in_user(compat_rxnfc, rxnfc,
90232 - (const void *)(&rxnfc->fs.m_ext + 1) -
90233 - (const void *)rxnfc) ||
90234 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
90235 + (const void __user *)rxnfc) ||
90236 copy_in_user(&compat_rxnfc->fs.ring_cookie,
90237 &rxnfc->fs.ring_cookie,
90238 - (const void *)(&rxnfc->fs.location + 1) -
90239 - (const void *)&rxnfc->fs.ring_cookie) ||
90240 + (const void __user *)(&rxnfc->fs.location + 1) -
90241 + (const void __user *)&rxnfc->fs.ring_cookie) ||
90242 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
90243 sizeof(rxnfc->rule_cnt)))
90244 return -EFAULT;
90245 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90246 old_fs = get_fs();
90247 set_fs(KERNEL_DS);
90248 err = dev_ioctl(net, cmd,
90249 - (struct ifreq __user __force *) &kifr);
90250 + (struct ifreq __force_user *) &kifr);
90251 set_fs(old_fs);
90252
90253 return err;
90254 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90255
90256 old_fs = get_fs();
90257 set_fs(KERNEL_DS);
90258 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90259 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90260 set_fs(old_fs);
90261
90262 if (cmd == SIOCGIFMAP && !err) {
90263 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90264 ret |= __get_user(rtdev, &(ur4->rt_dev));
90265 if (rtdev) {
90266 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90267 - r4.rt_dev = (char __user __force *)devname;
90268 + r4.rt_dev = (char __force_user *)devname;
90269 devname[15] = 0;
90270 } else
90271 r4.rt_dev = NULL;
90272 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90273 int __user *uoptlen;
90274 int err;
90275
90276 - uoptval = (char __user __force *) optval;
90277 - uoptlen = (int __user __force *) optlen;
90278 + uoptval = (char __force_user *) optval;
90279 + uoptlen = (int __force_user *) optlen;
90280
90281 set_fs(KERNEL_DS);
90282 if (level == SOL_SOCKET)
90283 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90284 char __user *uoptval;
90285 int err;
90286
90287 - uoptval = (char __user __force *) optval;
90288 + uoptval = (char __force_user *) optval;
90289
90290 set_fs(KERNEL_DS);
90291 if (level == SOL_SOCKET)
90292 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90293 index 716aa41..75e88ea 100644
90294 --- a/net/sunrpc/clnt.c
90295 +++ b/net/sunrpc/clnt.c
90296 @@ -303,10 +303,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
90297 err = rpciod_up();
90298 if (err)
90299 goto out_no_rpciod;
90300 +
90301 err = -EINVAL;
90302 - if (!xprt)
90303 - goto out_no_xprt;
90304 -
90305 if (args->version >= program->nrvers)
90306 goto out_err;
90307 version = program->version[args->version];
90308 @@ -381,10 +379,9 @@ out_no_principal:
90309 out_no_stats:
90310 kfree(clnt);
90311 out_err:
90312 - xprt_put(xprt);
90313 -out_no_xprt:
90314 rpciod_down();
90315 out_no_rpciod:
90316 + xprt_put(xprt);
90317 return ERR_PTR(err);
90318 }
90319
90320 @@ -1270,7 +1267,9 @@ call_start(struct rpc_task *task)
90321 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90322
90323 /* Increment call count */
90324 - task->tk_msg.rpc_proc->p_count++;
90325 + pax_open_kernel();
90326 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90327 + pax_close_kernel();
90328 clnt->cl_stats->rpccnt++;
90329 task->tk_action = call_reserve;
90330 }
90331 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90332 index f8529fc..ce8c643 100644
90333 --- a/net/sunrpc/sched.c
90334 +++ b/net/sunrpc/sched.c
90335 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90336 #ifdef RPC_DEBUG
90337 static void rpc_task_set_debuginfo(struct rpc_task *task)
90338 {
90339 - static atomic_t rpc_pid;
90340 + static atomic_unchecked_t rpc_pid;
90341
90342 - task->tk_pid = atomic_inc_return(&rpc_pid);
90343 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90344 }
90345 #else
90346 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90347 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90348 index 2d34b6b..e2d584d 100644
90349 --- a/net/sunrpc/svc.c
90350 +++ b/net/sunrpc/svc.c
90351 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90352 svc_putnl(resv, RPC_SUCCESS);
90353
90354 /* Bump per-procedure stats counter */
90355 - procp->pc_count++;
90356 + pax_open_kernel();
90357 + (*(unsigned int *)&procp->pc_count)++;
90358 + pax_close_kernel();
90359
90360 /* Initialize storage for argp and resp */
90361 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90362 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90363 index 8343737..677025e 100644
90364 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90365 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90366 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90367 static unsigned int min_max_inline = 4096;
90368 static unsigned int max_max_inline = 65536;
90369
90370 -atomic_t rdma_stat_recv;
90371 -atomic_t rdma_stat_read;
90372 -atomic_t rdma_stat_write;
90373 -atomic_t rdma_stat_sq_starve;
90374 -atomic_t rdma_stat_rq_starve;
90375 -atomic_t rdma_stat_rq_poll;
90376 -atomic_t rdma_stat_rq_prod;
90377 -atomic_t rdma_stat_sq_poll;
90378 -atomic_t rdma_stat_sq_prod;
90379 +atomic_unchecked_t rdma_stat_recv;
90380 +atomic_unchecked_t rdma_stat_read;
90381 +atomic_unchecked_t rdma_stat_write;
90382 +atomic_unchecked_t rdma_stat_sq_starve;
90383 +atomic_unchecked_t rdma_stat_rq_starve;
90384 +atomic_unchecked_t rdma_stat_rq_poll;
90385 +atomic_unchecked_t rdma_stat_rq_prod;
90386 +atomic_unchecked_t rdma_stat_sq_poll;
90387 +atomic_unchecked_t rdma_stat_sq_prod;
90388
90389 /* Temporary NFS request map and context caches */
90390 struct kmem_cache *svc_rdma_map_cachep;
90391 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90392 len -= *ppos;
90393 if (len > *lenp)
90394 len = *lenp;
90395 - if (len && copy_to_user(buffer, str_buf, len))
90396 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90397 return -EFAULT;
90398 *lenp = len;
90399 *ppos += len;
90400 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90401 {
90402 .procname = "rdma_stat_read",
90403 .data = &rdma_stat_read,
90404 - .maxlen = sizeof(atomic_t),
90405 + .maxlen = sizeof(atomic_unchecked_t),
90406 .mode = 0644,
90407 .proc_handler = read_reset_stat,
90408 },
90409 {
90410 .procname = "rdma_stat_recv",
90411 .data = &rdma_stat_recv,
90412 - .maxlen = sizeof(atomic_t),
90413 + .maxlen = sizeof(atomic_unchecked_t),
90414 .mode = 0644,
90415 .proc_handler = read_reset_stat,
90416 },
90417 {
90418 .procname = "rdma_stat_write",
90419 .data = &rdma_stat_write,
90420 - .maxlen = sizeof(atomic_t),
90421 + .maxlen = sizeof(atomic_unchecked_t),
90422 .mode = 0644,
90423 .proc_handler = read_reset_stat,
90424 },
90425 {
90426 .procname = "rdma_stat_sq_starve",
90427 .data = &rdma_stat_sq_starve,
90428 - .maxlen = sizeof(atomic_t),
90429 + .maxlen = sizeof(atomic_unchecked_t),
90430 .mode = 0644,
90431 .proc_handler = read_reset_stat,
90432 },
90433 {
90434 .procname = "rdma_stat_rq_starve",
90435 .data = &rdma_stat_rq_starve,
90436 - .maxlen = sizeof(atomic_t),
90437 + .maxlen = sizeof(atomic_unchecked_t),
90438 .mode = 0644,
90439 .proc_handler = read_reset_stat,
90440 },
90441 {
90442 .procname = "rdma_stat_rq_poll",
90443 .data = &rdma_stat_rq_poll,
90444 - .maxlen = sizeof(atomic_t),
90445 + .maxlen = sizeof(atomic_unchecked_t),
90446 .mode = 0644,
90447 .proc_handler = read_reset_stat,
90448 },
90449 {
90450 .procname = "rdma_stat_rq_prod",
90451 .data = &rdma_stat_rq_prod,
90452 - .maxlen = sizeof(atomic_t),
90453 + .maxlen = sizeof(atomic_unchecked_t),
90454 .mode = 0644,
90455 .proc_handler = read_reset_stat,
90456 },
90457 {
90458 .procname = "rdma_stat_sq_poll",
90459 .data = &rdma_stat_sq_poll,
90460 - .maxlen = sizeof(atomic_t),
90461 + .maxlen = sizeof(atomic_unchecked_t),
90462 .mode = 0644,
90463 .proc_handler = read_reset_stat,
90464 },
90465 {
90466 .procname = "rdma_stat_sq_prod",
90467 .data = &rdma_stat_sq_prod,
90468 - .maxlen = sizeof(atomic_t),
90469 + .maxlen = sizeof(atomic_unchecked_t),
90470 .mode = 0644,
90471 .proc_handler = read_reset_stat,
90472 },
90473 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90474 index 0ce7552..d074459 100644
90475 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90476 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90477 @@ -501,7 +501,7 @@ next_sge:
90478 svc_rdma_put_context(ctxt, 0);
90479 goto out;
90480 }
90481 - atomic_inc(&rdma_stat_read);
90482 + atomic_inc_unchecked(&rdma_stat_read);
90483
90484 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90485 chl_map->ch[ch_no].count -= read_wr.num_sge;
90486 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90487 dto_q);
90488 list_del_init(&ctxt->dto_q);
90489 } else {
90490 - atomic_inc(&rdma_stat_rq_starve);
90491 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90492 clear_bit(XPT_DATA, &xprt->xpt_flags);
90493 ctxt = NULL;
90494 }
90495 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90496 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90497 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90498 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90499 - atomic_inc(&rdma_stat_recv);
90500 + atomic_inc_unchecked(&rdma_stat_recv);
90501
90502 /* Build up the XDR from the receive buffers. */
90503 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90504 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90505 index c1d124d..acfc59e 100644
90506 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90507 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90508 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90509 write_wr.wr.rdma.remote_addr = to;
90510
90511 /* Post It */
90512 - atomic_inc(&rdma_stat_write);
90513 + atomic_inc_unchecked(&rdma_stat_write);
90514 if (svc_rdma_send(xprt, &write_wr))
90515 goto err;
90516 return 0;
90517 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90518 index 62e4f9b..dd3f2d7 100644
90519 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90520 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90521 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90522 return;
90523
90524 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90525 - atomic_inc(&rdma_stat_rq_poll);
90526 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90527
90528 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90529 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90530 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90531 }
90532
90533 if (ctxt)
90534 - atomic_inc(&rdma_stat_rq_prod);
90535 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90536
90537 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90538 /*
90539 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90540 return;
90541
90542 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90543 - atomic_inc(&rdma_stat_sq_poll);
90544 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90545 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90546 if (wc.status != IB_WC_SUCCESS)
90547 /* Close the transport */
90548 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90549 }
90550
90551 if (ctxt)
90552 - atomic_inc(&rdma_stat_sq_prod);
90553 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90554 }
90555
90556 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90557 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90558 spin_lock_bh(&xprt->sc_lock);
90559 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90560 spin_unlock_bh(&xprt->sc_lock);
90561 - atomic_inc(&rdma_stat_sq_starve);
90562 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90563
90564 /* See if we can opportunistically reap SQ WR to make room */
90565 sq_cq_reap(xprt);
90566 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90567 index 9bc6db0..47ac8c0 100644
90568 --- a/net/sysctl_net.c
90569 +++ b/net/sysctl_net.c
90570 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90571 kgid_t root_gid = make_kgid(net->user_ns, 0);
90572
90573 /* Allow network administrator to have same access as root. */
90574 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90575 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90576 uid_eq(root_uid, current_uid())) {
90577 int mode = (table->mode >> 6) & 7;
90578 return (mode << 6) | (mode << 3) | mode;
90579 diff --git a/net/tipc/link.c b/net/tipc/link.c
90580 index daa6080..02d357f 100644
90581 --- a/net/tipc/link.c
90582 +++ b/net/tipc/link.c
90583 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90584 struct tipc_msg fragm_hdr;
90585 struct sk_buff *buf, *buf_chain, *prev;
90586 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90587 - const unchar *sect_crs;
90588 + const unchar __user *sect_crs;
90589 int curr_sect;
90590 u32 fragm_no;
90591
90592 @@ -1242,7 +1242,7 @@ again:
90593
90594 if (!sect_rest) {
90595 sect_rest = msg_sect[++curr_sect].iov_len;
90596 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90597 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90598 }
90599
90600 if (sect_rest < fragm_rest)
90601 @@ -1261,7 +1261,7 @@ error:
90602 }
90603 } else
90604 skb_copy_to_linear_data_offset(buf, fragm_crs,
90605 - sect_crs, sz);
90606 + (const void __force_kernel *)sect_crs, sz);
90607 sect_crs += sz;
90608 sect_rest -= sz;
90609 fragm_crs += sz;
90610 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90611 index f2db8a8..9245aa4 100644
90612 --- a/net/tipc/msg.c
90613 +++ b/net/tipc/msg.c
90614 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90615 msg_sect[cnt].iov_len);
90616 else
90617 skb_copy_to_linear_data_offset(*buf, pos,
90618 - msg_sect[cnt].iov_base,
90619 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90620 msg_sect[cnt].iov_len);
90621 pos += msg_sect[cnt].iov_len;
90622 }
90623 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90624 index 6b42d47..2ac24d5 100644
90625 --- a/net/tipc/subscr.c
90626 +++ b/net/tipc/subscr.c
90627 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90628 {
90629 struct iovec msg_sect;
90630
90631 - msg_sect.iov_base = (void *)&sub->evt;
90632 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90633 msg_sect.iov_len = sizeof(struct tipc_event);
90634
90635 sub->evt.event = htohl(event, sub->swap);
90636 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90637 index f347754..bb4b223 100644
90638 --- a/net/unix/af_unix.c
90639 +++ b/net/unix/af_unix.c
90640 @@ -785,6 +785,12 @@ static struct sock *unix_find_other(struct net *net,
90641 err = -ECONNREFUSED;
90642 if (!S_ISSOCK(inode->i_mode))
90643 goto put_fail;
90644 +
90645 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90646 + err = -EACCES;
90647 + goto put_fail;
90648 + }
90649 +
90650 u = unix_find_socket_byinode(inode);
90651 if (!u)
90652 goto put_fail;
90653 @@ -805,6 +811,13 @@ static struct sock *unix_find_other(struct net *net,
90654 if (u) {
90655 struct dentry *dentry;
90656 dentry = unix_sk(u)->path.dentry;
90657 +
90658 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90659 + err = -EPERM;
90660 + sock_put(u);
90661 + goto fail;
90662 + }
90663 +
90664 if (dentry)
90665 touch_atime(&unix_sk(u)->path);
90666 } else
90667 @@ -838,12 +851,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90668 */
90669 err = security_path_mknod(&path, dentry, mode, 0);
90670 if (!err) {
90671 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90672 + err = -EACCES;
90673 + goto out;
90674 + }
90675 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90676 if (!err) {
90677 res->mnt = mntget(path.mnt);
90678 res->dentry = dget(dentry);
90679 + gr_handle_create(dentry, path.mnt);
90680 }
90681 }
90682 +out:
90683 done_path_create(&path, dentry);
90684 return err;
90685 }
90686 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90687 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90688 "Inode Path\n");
90689 else {
90690 - struct sock *s = v;
90691 + struct sock *s = v, *peer;
90692 struct unix_sock *u = unix_sk(s);
90693 unix_state_lock(s);
90694 + peer = unix_peer(s);
90695 + unix_state_unlock(s);
90696 +
90697 + unix_state_double_lock(s, peer);
90698
90699 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90700 s,
90701 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90702 }
90703 for ( ; i < len; i++)
90704 seq_putc(seq, u->addr->name->sun_path[i]);
90705 - }
90706 - unix_state_unlock(s);
90707 + } else if (peer)
90708 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90709 +
90710 + unix_state_double_unlock(s, peer);
90711 seq_putc(seq, '\n');
90712 }
90713
90714 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90715 index 8800604..0526440 100644
90716 --- a/net/unix/sysctl_net_unix.c
90717 +++ b/net/unix/sysctl_net_unix.c
90718 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90719
90720 int __net_init unix_sysctl_register(struct net *net)
90721 {
90722 - struct ctl_table *table;
90723 + ctl_table_no_const *table;
90724
90725 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90726 if (table == NULL)
90727 diff --git a/net/wireless/trace.h b/net/wireless/trace.h
90728 index 2134576..5d71a5a 100644
90729 --- a/net/wireless/trace.h
90730 +++ b/net/wireless/trace.h
90731 @@ -27,7 +27,8 @@
90732 #define WIPHY_PR_ARG __entry->wiphy_name
90733
90734 #define WDEV_ENTRY __field(u32, id)
90735 -#define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0)
90736 +#define WDEV_ASSIGN (__entry->id) = (!IS_ERR_OR_NULL(wdev) \
90737 + ? wdev->identifier : 0)
90738 #define WDEV_PR_FMT "wdev(%u)"
90739 #define WDEV_PR_ARG (__entry->id)
90740
90741 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90742 index c8717c1..08539f5 100644
90743 --- a/net/wireless/wext-core.c
90744 +++ b/net/wireless/wext-core.c
90745 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90746 */
90747
90748 /* Support for very large requests */
90749 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90750 - (user_length > descr->max_tokens)) {
90751 + if (user_length > descr->max_tokens) {
90752 /* Allow userspace to GET more than max so
90753 * we can support any size GET requests.
90754 * There is still a limit : -ENOMEM.
90755 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90756 }
90757 }
90758
90759 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90760 - /*
90761 - * If this is a GET, but not NOMAX, it means that the extra
90762 - * data is not bounded by userspace, but by max_tokens. Thus
90763 - * set the length to max_tokens. This matches the extra data
90764 - * allocation.
90765 - * The driver should fill it with the number of tokens it
90766 - * provided, and it may check iwp->length rather than having
90767 - * knowledge of max_tokens. If the driver doesn't change the
90768 - * iwp->length, this ioctl just copies back max_token tokens
90769 - * filled with zeroes. Hopefully the driver isn't claiming
90770 - * them to be valid data.
90771 - */
90772 - iwp->length = descr->max_tokens;
90773 - }
90774 -
90775 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90776
90777 iwp->length += essid_compat;
90778 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90779 index 07c5857..fde4018 100644
90780 --- a/net/xfrm/xfrm_policy.c
90781 +++ b/net/xfrm/xfrm_policy.c
90782 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90783 {
90784 policy->walk.dead = 1;
90785
90786 - atomic_inc(&policy->genid);
90787 + atomic_inc_unchecked(&policy->genid);
90788
90789 if (del_timer(&policy->timer))
90790 xfrm_pol_put(policy);
90791 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90792 hlist_add_head(&policy->bydst, chain);
90793 xfrm_pol_hold(policy);
90794 net->xfrm.policy_count[dir]++;
90795 - atomic_inc(&flow_cache_genid);
90796 + atomic_inc_unchecked(&flow_cache_genid);
90797 rt_genid_bump(net);
90798 if (delpol)
90799 __xfrm_policy_unlink(delpol, dir);
90800 @@ -1550,7 +1550,7 @@ free_dst:
90801 goto out;
90802 }
90803
90804 -static int inline
90805 +static inline int
90806 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90807 {
90808 if (!*target) {
90809 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90810 return 0;
90811 }
90812
90813 -static int inline
90814 +static inline int
90815 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90816 {
90817 #ifdef CONFIG_XFRM_SUB_POLICY
90818 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90819 #endif
90820 }
90821
90822 -static int inline
90823 +static inline int
90824 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90825 {
90826 #ifdef CONFIG_XFRM_SUB_POLICY
90827 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90828
90829 xdst->num_pols = num_pols;
90830 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90831 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90832 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90833
90834 return xdst;
90835 }
90836 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90837 if (xdst->xfrm_genid != dst->xfrm->genid)
90838 return 0;
90839 if (xdst->num_pols > 0 &&
90840 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90841 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90842 return 0;
90843
90844 mtu = dst_mtu(dst->child);
90845 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90846 dst_ops->link_failure = xfrm_link_failure;
90847 if (likely(dst_ops->neigh_lookup == NULL))
90848 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90849 - if (likely(afinfo->garbage_collect == NULL))
90850 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90851 + if (likely(afinfo->garbage_collect == NULL)) {
90852 + pax_open_kernel();
90853 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90854 + pax_close_kernel();
90855 + }
90856 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90857 }
90858 spin_unlock(&xfrm_policy_afinfo_lock);
90859 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90860 dst_ops->check = NULL;
90861 dst_ops->negative_advice = NULL;
90862 dst_ops->link_failure = NULL;
90863 - afinfo->garbage_collect = NULL;
90864 + pax_open_kernel();
90865 + *(void **)&afinfo->garbage_collect = NULL;
90866 + pax_close_kernel();
90867 }
90868 return err;
90869 }
90870 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90871 sizeof(pol->xfrm_vec[i].saddr));
90872 pol->xfrm_vec[i].encap_family = mp->new_family;
90873 /* flush bundles */
90874 - atomic_inc(&pol->genid);
90875 + atomic_inc_unchecked(&pol->genid);
90876 }
90877 }
90878
90879 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
90880 index 3459692..e7cdb1a 100644
90881 --- a/net/xfrm/xfrm_state.c
90882 +++ b/net/xfrm/xfrm_state.c
90883 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
90884
90885 if (unlikely(afinfo == NULL))
90886 return -EAFNOSUPPORT;
90887 - typemap = afinfo->type_map;
90888 + typemap = (const struct xfrm_type **)afinfo->type_map;
90889
90890 - if (likely(typemap[type->proto] == NULL))
90891 + if (likely(typemap[type->proto] == NULL)) {
90892 + pax_open_kernel();
90893 typemap[type->proto] = type;
90894 - else
90895 + pax_close_kernel();
90896 + } else
90897 err = -EEXIST;
90898 xfrm_state_unlock_afinfo(afinfo);
90899 return err;
90900 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
90901
90902 if (unlikely(afinfo == NULL))
90903 return -EAFNOSUPPORT;
90904 - typemap = afinfo->type_map;
90905 + typemap = (const struct xfrm_type **)afinfo->type_map;
90906
90907 if (unlikely(typemap[type->proto] != type))
90908 err = -ENOENT;
90909 - else
90910 + else {
90911 + pax_open_kernel();
90912 typemap[type->proto] = NULL;
90913 + pax_close_kernel();
90914 + }
90915 xfrm_state_unlock_afinfo(afinfo);
90916 return err;
90917 }
90918 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
90919 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
90920 {
90921 struct xfrm_state_afinfo *afinfo;
90922 - const struct xfrm_type **typemap;
90923 const struct xfrm_type *type;
90924 int modload_attempted = 0;
90925
90926 @@ -235,9 +239,8 @@ retry:
90927 afinfo = xfrm_state_get_afinfo(family);
90928 if (unlikely(afinfo == NULL))
90929 return NULL;
90930 - typemap = afinfo->type_map;
90931
90932 - type = typemap[proto];
90933 + type = afinfo->type_map[proto];
90934 if (unlikely(type && !try_module_get(type->owner)))
90935 type = NULL;
90936 if (!type && !modload_attempted) {
90937 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90938 return -EAFNOSUPPORT;
90939
90940 err = -EEXIST;
90941 - modemap = afinfo->mode_map;
90942 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90943 if (modemap[mode->encap])
90944 goto out;
90945
90946 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90947 if (!try_module_get(afinfo->owner))
90948 goto out;
90949
90950 - mode->afinfo = afinfo;
90951 + pax_open_kernel();
90952 + *(const void **)&mode->afinfo = afinfo;
90953 modemap[mode->encap] = mode;
90954 + pax_close_kernel();
90955 err = 0;
90956
90957 out:
90958 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
90959 return -EAFNOSUPPORT;
90960
90961 err = -ENOENT;
90962 - modemap = afinfo->mode_map;
90963 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90964 if (likely(modemap[mode->encap] == mode)) {
90965 + pax_open_kernel();
90966 modemap[mode->encap] = NULL;
90967 + pax_close_kernel();
90968 module_put(mode->afinfo->owner);
90969 err = 0;
90970 }
90971 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
90972 index 05a6e3d..6716ec9 100644
90973 --- a/net/xfrm/xfrm_sysctl.c
90974 +++ b/net/xfrm/xfrm_sysctl.c
90975 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
90976
90977 int __net_init xfrm_sysctl_init(struct net *net)
90978 {
90979 - struct ctl_table *table;
90980 + ctl_table_no_const *table;
90981
90982 __xfrm_sysctl_init(net);
90983
90984 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
90985 index 0e801c3..5c8ad3b 100644
90986 --- a/scripts/Makefile.build
90987 +++ b/scripts/Makefile.build
90988 @@ -111,7 +111,7 @@ endif
90989 endif
90990
90991 # Do not include host rules unless needed
90992 -ifneq ($(hostprogs-y)$(hostprogs-m),)
90993 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
90994 include scripts/Makefile.host
90995 endif
90996
90997 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
90998 index 686cb0d..9d653bf 100644
90999 --- a/scripts/Makefile.clean
91000 +++ b/scripts/Makefile.clean
91001 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91002 __clean-files := $(extra-y) $(always) \
91003 $(targets) $(clean-files) \
91004 $(host-progs) \
91005 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91006 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91007 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91008
91009 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91010
91011 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91012 index 1ac414f..38575f7 100644
91013 --- a/scripts/Makefile.host
91014 +++ b/scripts/Makefile.host
91015 @@ -31,6 +31,8 @@
91016 # Note: Shared libraries consisting of C++ files are not supported
91017
91018 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91019 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91020 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91021
91022 # C code
91023 # Executables compiled from a single .c file
91024 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91025 # Shared libaries (only .c supported)
91026 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91027 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91028 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91029 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91030 # Remove .so files from "xxx-objs"
91031 host-cobjs := $(filter-out %.so,$(host-cobjs))
91032 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91033
91034 -#Object (.o) files used by the shared libaries
91035 +# Object (.o) files used by the shared libaries
91036 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91037 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91038
91039 # output directory for programs/.o files
91040 # hostprogs-y := tools/build may have been specified. Retrieve directory
91041 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91042 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91043 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91044 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91045 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91046 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91047 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91048 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91049
91050 obj-dirs += $(host-objdirs)
91051 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91052 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91053 $(call if_changed_dep,host-cshobjs)
91054
91055 +# Compile .c file, create position independent .o file
91056 +# host-cxxshobjs -> .o
91057 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91058 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91059 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91060 + $(call if_changed_dep,host-cxxshobjs)
91061 +
91062 # Link a shared library, based on position independent .o files
91063 # *.o -> .so shared library (host-cshlib)
91064 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91065 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91066 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91067 $(call if_changed,host-cshlib)
91068
91069 +# Link a shared library, based on position independent .o files
91070 +# *.o -> .so shared library (host-cxxshlib)
91071 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91072 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91073 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91074 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91075 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91076 + $(call if_changed,host-cxxshlib)
91077 +
91078 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91079 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91080 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91081
91082 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91083 index cb1f50c..cef2a7c 100644
91084 --- a/scripts/basic/fixdep.c
91085 +++ b/scripts/basic/fixdep.c
91086 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91087 /*
91088 * Lookup a value in the configuration string.
91089 */
91090 -static int is_defined_config(const char *name, int len, unsigned int hash)
91091 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91092 {
91093 struct item *aux;
91094
91095 @@ -211,10 +211,10 @@ static void clear_config(void)
91096 /*
91097 * Record the use of a CONFIG_* word.
91098 */
91099 -static void use_config(const char *m, int slen)
91100 +static void use_config(const char *m, unsigned int slen)
91101 {
91102 unsigned int hash = strhash(m, slen);
91103 - int c, i;
91104 + unsigned int c, i;
91105
91106 if (is_defined_config(m, slen, hash))
91107 return;
91108 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91109
91110 static void parse_config_file(const char *map, size_t len)
91111 {
91112 - const int *end = (const int *) (map + len);
91113 + const unsigned int *end = (const unsigned int *) (map + len);
91114 /* start at +1, so that p can never be < map */
91115 - const int *m = (const int *) map + 1;
91116 + const unsigned int *m = (const unsigned int *) map + 1;
91117 const char *p, *q;
91118
91119 for (; m < end; m++) {
91120 @@ -406,7 +406,7 @@ static void print_deps(void)
91121 static void traps(void)
91122 {
91123 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91124 - int *p = (int *)test;
91125 + unsigned int *p = (unsigned int *)test;
91126
91127 if (*p != INT_CONF) {
91128 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
91129 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91130 new file mode 100644
91131 index 0000000..5e0222d
91132 --- /dev/null
91133 +++ b/scripts/gcc-plugin.sh
91134 @@ -0,0 +1,17 @@
91135 +#!/bin/bash
91136 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91137 +#include "gcc-plugin.h"
91138 +#include "tree.h"
91139 +#include "tm.h"
91140 +#include "rtl.h"
91141 +#ifdef ENABLE_BUILD_WITH_CXX
91142 +#warning $2
91143 +#else
91144 +#warning $1
91145 +#endif
91146 +EOF`
91147 +if [ $? -eq 0 ]
91148 +then
91149 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91150 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91151 +fi
91152 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91153 index 581ca99..a6ff02e 100644
91154 --- a/scripts/headers_install.pl
91155 +++ b/scripts/headers_install.pl
91156 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91157 $line =~ s/([\s(])__user\s/$1/g;
91158 $line =~ s/([\s(])__force\s/$1/g;
91159 $line =~ s/([\s(])__iomem\s/$1/g;
91160 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91161 $line =~ s/\s__attribute_const__\s/ /g;
91162 $line =~ s/\s__attribute_const__$//g;
91163 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91164 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91165 index b3d907e..a4782ab 100644
91166 --- a/scripts/link-vmlinux.sh
91167 +++ b/scripts/link-vmlinux.sh
91168 @@ -152,7 +152,7 @@ else
91169 fi;
91170
91171 # final build of init/
91172 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91173 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91174
91175 kallsymso=""
91176 kallsyms_vmlinux=""
91177 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91178 index df4fc23..0ea719d 100644
91179 --- a/scripts/mod/file2alias.c
91180 +++ b/scripts/mod/file2alias.c
91181 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
91182 unsigned long size, unsigned long id_size,
91183 void *symval)
91184 {
91185 - int i;
91186 + unsigned int i;
91187
91188 if (size % id_size || size < id_size) {
91189 if (cross_build != 0)
91190 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
91191 /* USB is special because the bcdDevice can be matched against a numeric range */
91192 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91193 static void do_usb_entry(struct usb_device_id *id,
91194 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91195 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91196 unsigned char range_lo, unsigned char range_hi,
91197 unsigned char max, struct module *mod)
91198 {
91199 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
91200 {
91201 unsigned int devlo, devhi;
91202 unsigned char chi, clo, max;
91203 - int ndigits;
91204 + unsigned int ndigits;
91205
91206 id->match_flags = TO_NATIVE(id->match_flags);
91207 id->idVendor = TO_NATIVE(id->idVendor);
91208 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91209 for (i = 0; i < count; i++) {
91210 const char *id = (char *)devs[i].id;
91211 char acpi_id[sizeof(devs[0].id)];
91212 - int j;
91213 + unsigned int j;
91214
91215 buf_printf(&mod->dev_table_buf,
91216 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91217 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91218
91219 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91220 const char *id = (char *)card->devs[j].id;
91221 - int i2, j2;
91222 + unsigned int i2, j2;
91223 int dup = 0;
91224
91225 if (!id[0])
91226 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91227 /* add an individual alias for every device entry */
91228 if (!dup) {
91229 char acpi_id[sizeof(card->devs[0].id)];
91230 - int k;
91231 + unsigned int k;
91232
91233 buf_printf(&mod->dev_table_buf,
91234 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91235 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91236 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
91237 char *alias)
91238 {
91239 - int i, j;
91240 + unsigned int i, j;
91241
91242 sprintf(alias, "dmi*");
91243
91244 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91245 index ff36c50..7ab4fa9 100644
91246 --- a/scripts/mod/modpost.c
91247 +++ b/scripts/mod/modpost.c
91248 @@ -929,6 +929,7 @@ enum mismatch {
91249 ANY_INIT_TO_ANY_EXIT,
91250 ANY_EXIT_TO_ANY_INIT,
91251 EXPORT_TO_INIT_EXIT,
91252 + DATA_TO_TEXT
91253 };
91254
91255 struct sectioncheck {
91256 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
91257 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91258 .mismatch = EXPORT_TO_INIT_EXIT,
91259 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91260 +},
91261 +/* Do not reference code from writable data */
91262 +{
91263 + .fromsec = { DATA_SECTIONS, NULL },
91264 + .tosec = { TEXT_SECTIONS, NULL },
91265 + .mismatch = DATA_TO_TEXT
91266 }
91267 };
91268
91269 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91270 continue;
91271 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91272 continue;
91273 - if (sym->st_value == addr)
91274 - return sym;
91275 /* Find a symbol nearby - addr are maybe negative */
91276 d = sym->st_value - addr;
91277 + if (d == 0)
91278 + return sym;
91279 if (d < 0)
91280 d = addr - sym->st_value;
91281 if (d < distance) {
91282 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
91283 tosym, prl_to, prl_to, tosym);
91284 free(prl_to);
91285 break;
91286 + case DATA_TO_TEXT:
91287 +#if 0
91288 + fprintf(stderr,
91289 + "The %s %s:%s references\n"
91290 + "the %s %s:%s%s\n",
91291 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91292 +#endif
91293 + break;
91294 }
91295 fprintf(stderr, "\n");
91296 }
91297 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91298 static void check_sec_ref(struct module *mod, const char *modname,
91299 struct elf_info *elf)
91300 {
91301 - int i;
91302 + unsigned int i;
91303 Elf_Shdr *sechdrs = elf->sechdrs;
91304
91305 /* Walk through all sections */
91306 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91307 va_end(ap);
91308 }
91309
91310 -void buf_write(struct buffer *buf, const char *s, int len)
91311 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91312 {
91313 if (buf->size - buf->pos < len) {
91314 buf->size += len + SZ;
91315 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91316 if (fstat(fileno(file), &st) < 0)
91317 goto close_write;
91318
91319 - if (st.st_size != b->pos)
91320 + if (st.st_size != (off_t)b->pos)
91321 goto close_write;
91322
91323 tmp = NOFAIL(malloc(b->pos));
91324 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91325 index 51207e4..f7d603d 100644
91326 --- a/scripts/mod/modpost.h
91327 +++ b/scripts/mod/modpost.h
91328 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91329
91330 struct buffer {
91331 char *p;
91332 - int pos;
91333 - int size;
91334 + unsigned int pos;
91335 + unsigned int size;
91336 };
91337
91338 void __attribute__((format(printf, 2, 3)))
91339 buf_printf(struct buffer *buf, const char *fmt, ...);
91340
91341 void
91342 -buf_write(struct buffer *buf, const char *s, int len);
91343 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91344
91345 struct module {
91346 struct module *next;
91347 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91348 index 9dfcd6d..099068e 100644
91349 --- a/scripts/mod/sumversion.c
91350 +++ b/scripts/mod/sumversion.c
91351 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91352 goto out;
91353 }
91354
91355 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91356 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91357 warn("writing sum in %s failed: %s\n",
91358 filename, strerror(errno));
91359 goto out;
91360 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91361 index acb8650..b8c5f02 100644
91362 --- a/scripts/package/builddeb
91363 +++ b/scripts/package/builddeb
91364 @@ -246,6 +246,7 @@ fi
91365 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91366 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91367 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91368 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91369 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91370 mkdir -p "$destdir"
91371 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91372 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91373 index 68bb4ef..2f419e1 100644
91374 --- a/scripts/pnmtologo.c
91375 +++ b/scripts/pnmtologo.c
91376 @@ -244,14 +244,14 @@ static void write_header(void)
91377 fprintf(out, " * Linux logo %s\n", logoname);
91378 fputs(" */\n\n", out);
91379 fputs("#include <linux/linux_logo.h>\n\n", out);
91380 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91381 + fprintf(out, "static unsigned char %s_data[] = {\n",
91382 logoname);
91383 }
91384
91385 static void write_footer(void)
91386 {
91387 fputs("\n};\n\n", out);
91388 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91389 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91390 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91391 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91392 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91393 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91394 fputs("\n};\n\n", out);
91395
91396 /* write logo clut */
91397 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91398 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91399 logoname);
91400 write_hex_cnt = 0;
91401 for (i = 0; i < logo_clutsize; i++) {
91402 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91403 index e4fd45b..2eeb5c4 100644
91404 --- a/scripts/sortextable.h
91405 +++ b/scripts/sortextable.h
91406 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91407 const char *secstrtab;
91408 const char *strtab;
91409 char *extab_image;
91410 - int extab_index = 0;
91411 - int i;
91412 - int idx;
91413 + unsigned int extab_index = 0;
91414 + unsigned int i;
91415 + unsigned int idx;
91416
91417 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91418 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91419 diff --git a/security/Kconfig b/security/Kconfig
91420 index e9c6ac7..eef8ada 100644
91421 --- a/security/Kconfig
91422 +++ b/security/Kconfig
91423 @@ -4,6 +4,943 @@
91424
91425 menu "Security options"
91426
91427 +menu "Grsecurity"
91428 +
91429 + config ARCH_TRACK_EXEC_LIMIT
91430 + bool
91431 +
91432 + config PAX_KERNEXEC_PLUGIN
91433 + bool
91434 +
91435 + config PAX_PER_CPU_PGD
91436 + bool
91437 +
91438 + config TASK_SIZE_MAX_SHIFT
91439 + int
91440 + depends on X86_64
91441 + default 47 if !PAX_PER_CPU_PGD
91442 + default 42 if PAX_PER_CPU_PGD
91443 +
91444 + config PAX_ENABLE_PAE
91445 + bool
91446 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91447 +
91448 + config PAX_USERCOPY_SLABS
91449 + bool
91450 +
91451 +config GRKERNSEC
91452 + bool "Grsecurity"
91453 + select CRYPTO
91454 + select CRYPTO_SHA256
91455 + select PROC_FS
91456 + select STOP_MACHINE
91457 + help
91458 + If you say Y here, you will be able to configure many features
91459 + that will enhance the security of your system. It is highly
91460 + recommended that you say Y here and read through the help
91461 + for each option so that you fully understand the features and
91462 + can evaluate their usefulness for your machine.
91463 +
91464 +choice
91465 + prompt "Configuration Method"
91466 + depends on GRKERNSEC
91467 + default GRKERNSEC_CONFIG_CUSTOM
91468 + help
91469 +
91470 +config GRKERNSEC_CONFIG_AUTO
91471 + bool "Automatic"
91472 + help
91473 + If you choose this configuration method, you'll be able to answer a small
91474 + number of simple questions about how you plan to use this kernel.
91475 + The settings of grsecurity and PaX will be automatically configured for
91476 + the highest commonly-used settings within the provided constraints.
91477 +
91478 + If you require additional configuration, custom changes can still be made
91479 + from the "custom configuration" menu.
91480 +
91481 +config GRKERNSEC_CONFIG_CUSTOM
91482 + bool "Custom"
91483 + help
91484 + If you choose this configuration method, you'll be able to configure all
91485 + grsecurity and PaX settings manually. Via this method, no options are
91486 + automatically enabled.
91487 +
91488 +endchoice
91489 +
91490 +choice
91491 + prompt "Usage Type"
91492 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91493 + default GRKERNSEC_CONFIG_SERVER
91494 + help
91495 +
91496 +config GRKERNSEC_CONFIG_SERVER
91497 + bool "Server"
91498 + help
91499 + Choose this option if you plan to use this kernel on a server.
91500 +
91501 +config GRKERNSEC_CONFIG_DESKTOP
91502 + bool "Desktop"
91503 + help
91504 + Choose this option if you plan to use this kernel on a desktop.
91505 +
91506 +endchoice
91507 +
91508 +choice
91509 + prompt "Virtualization Type"
91510 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91511 + default GRKERNSEC_CONFIG_VIRT_NONE
91512 + help
91513 +
91514 +config GRKERNSEC_CONFIG_VIRT_NONE
91515 + bool "None"
91516 + help
91517 + Choose this option if this kernel will be run on bare metal.
91518 +
91519 +config GRKERNSEC_CONFIG_VIRT_GUEST
91520 + bool "Guest"
91521 + help
91522 + Choose this option if this kernel will be run as a VM guest.
91523 +
91524 +config GRKERNSEC_CONFIG_VIRT_HOST
91525 + bool "Host"
91526 + help
91527 + Choose this option if this kernel will be run as a VM host.
91528 +
91529 +endchoice
91530 +
91531 +choice
91532 + prompt "Virtualization Hardware"
91533 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91534 + help
91535 +
91536 +config GRKERNSEC_CONFIG_VIRT_EPT
91537 + bool "EPT/RVI Processor Support"
91538 + depends on X86
91539 + help
91540 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91541 + hardware virtualization. This allows for additional kernel hardening protections
91542 + to operate without additional performance impact.
91543 +
91544 + To see if your Intel processor supports EPT, see:
91545 + http://ark.intel.com/Products/VirtualizationTechnology
91546 + (Most Core i3/5/7 support EPT)
91547 +
91548 + To see if your AMD processor supports RVI, see:
91549 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91550 +
91551 +config GRKERNSEC_CONFIG_VIRT_SOFT
91552 + bool "First-gen/No Hardware Virtualization"
91553 + help
91554 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91555 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91556 +
91557 +endchoice
91558 +
91559 +choice
91560 + prompt "Virtualization Software"
91561 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91562 + help
91563 +
91564 +config GRKERNSEC_CONFIG_VIRT_XEN
91565 + bool "Xen"
91566 + help
91567 + Choose this option if this kernel is running as a Xen guest or host.
91568 +
91569 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91570 + bool "VMWare"
91571 + help
91572 + Choose this option if this kernel is running as a VMWare guest or host.
91573 +
91574 +config GRKERNSEC_CONFIG_VIRT_KVM
91575 + bool "KVM"
91576 + help
91577 + Choose this option if this kernel is running as a KVM guest or host.
91578 +
91579 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91580 + bool "VirtualBox"
91581 + help
91582 + Choose this option if this kernel is running as a VirtualBox guest or host.
91583 +
91584 +endchoice
91585 +
91586 +choice
91587 + prompt "Required Priorities"
91588 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91589 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91590 + help
91591 +
91592 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91593 + bool "Performance"
91594 + help
91595 + Choose this option if performance is of highest priority for this deployment
91596 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91597 + clearing of structures intended for userland, and freed memory sanitizing will
91598 + be disabled.
91599 +
91600 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91601 + bool "Security"
91602 + help
91603 + Choose this option if security is of highest priority for this deployment of
91604 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91605 + for userland, and freed memory sanitizing will be enabled for this kernel.
91606 + In a worst-case scenario, these features can introduce a 20% performance hit
91607 + (UDEREF on x64 contributing half of this hit).
91608 +
91609 +endchoice
91610 +
91611 +menu "Default Special Groups"
91612 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91613 +
91614 +config GRKERNSEC_PROC_GID
91615 + int "GID exempted from /proc restrictions"
91616 + default 1001
91617 + help
91618 + Setting this GID determines which group will be exempted from
91619 + grsecurity's /proc restrictions, allowing users of the specified
91620 + group to view network statistics and the existence of other users'
91621 + processes on the system. This GID may also be chosen at boot time
91622 + via "grsec_proc_gid=" on the kernel commandline.
91623 +
91624 +config GRKERNSEC_TPE_UNTRUSTED_GID
91625 + int "GID for TPE-untrusted users"
91626 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91627 + default 1005
91628 + help
91629 + Setting this GID determines which group untrusted users should
91630 + be added to. These users will be placed under grsecurity's Trusted Path
91631 + Execution mechanism, preventing them from executing their own binaries.
91632 + The users will only be able to execute binaries in directories owned and
91633 + writable only by the root user. If the sysctl option is enabled, a sysctl
91634 + option with name "tpe_gid" is created.
91635 +
91636 +config GRKERNSEC_TPE_TRUSTED_GID
91637 + int "GID for TPE-trusted users"
91638 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91639 + default 1005
91640 + help
91641 + Setting this GID determines what group TPE restrictions will be
91642 + *disabled* for. If the sysctl option is enabled, a sysctl option
91643 + with name "tpe_gid" is created.
91644 +
91645 +config GRKERNSEC_SYMLINKOWN_GID
91646 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91647 + depends on GRKERNSEC_CONFIG_SERVER
91648 + default 1006
91649 + help
91650 + Setting this GID determines what group kernel-enforced
91651 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91652 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91653 +
91654 +
91655 +endmenu
91656 +
91657 +menu "Customize Configuration"
91658 +depends on GRKERNSEC
91659 +
91660 +menu "PaX"
91661 +
91662 +config PAX
91663 + bool "Enable various PaX features"
91664 + default y if GRKERNSEC_CONFIG_AUTO
91665 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91666 + help
91667 + This allows you to enable various PaX features. PaX adds
91668 + intrusion prevention mechanisms to the kernel that reduce
91669 + the risks posed by exploitable memory corruption bugs.
91670 +
91671 +menu "PaX Control"
91672 + depends on PAX
91673 +
91674 +config PAX_SOFTMODE
91675 + bool 'Support soft mode'
91676 + help
91677 + Enabling this option will allow you to run PaX in soft mode, that
91678 + is, PaX features will not be enforced by default, only on executables
91679 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91680 + support as they are the only way to mark executables for soft mode use.
91681 +
91682 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91683 + line option on boot. Furthermore you can control various PaX features
91684 + at runtime via the entries in /proc/sys/kernel/pax.
91685 +
91686 +config PAX_EI_PAX
91687 + bool 'Use legacy ELF header marking'
91688 + default y if GRKERNSEC_CONFIG_AUTO
91689 + help
91690 + Enabling this option will allow you to control PaX features on
91691 + a per executable basis via the 'chpax' utility available at
91692 + http://pax.grsecurity.net/. The control flags will be read from
91693 + an otherwise reserved part of the ELF header. This marking has
91694 + numerous drawbacks (no support for soft-mode, toolchain does not
91695 + know about the non-standard use of the ELF header) therefore it
91696 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91697 + support.
91698 +
91699 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91700 + support as well, they will override the legacy EI_PAX marks.
91701 +
91702 + If you enable none of the marking options then all applications
91703 + will run with PaX enabled on them by default.
91704 +
91705 +config PAX_PT_PAX_FLAGS
91706 + bool 'Use ELF program header marking'
91707 + default y if GRKERNSEC_CONFIG_AUTO
91708 + help
91709 + Enabling this option will allow you to control PaX features on
91710 + a per executable basis via the 'paxctl' utility available at
91711 + http://pax.grsecurity.net/. The control flags will be read from
91712 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91713 + has the benefits of supporting both soft mode and being fully
91714 + integrated into the toolchain (the binutils patch is available
91715 + from http://pax.grsecurity.net).
91716 +
91717 + Note that if you enable the legacy EI_PAX marking support as well,
91718 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91719 +
91720 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91721 + must make sure that the marks are the same if a binary has both marks.
91722 +
91723 + If you enable none of the marking options then all applications
91724 + will run with PaX enabled on them by default.
91725 +
91726 +config PAX_XATTR_PAX_FLAGS
91727 + bool 'Use filesystem extended attributes marking'
91728 + default y if GRKERNSEC_CONFIG_AUTO
91729 + select CIFS_XATTR if CIFS
91730 + select EXT2_FS_XATTR if EXT2_FS
91731 + select EXT3_FS_XATTR if EXT3_FS
91732 + select EXT4_FS_XATTR if EXT4_FS
91733 + select JFFS2_FS_XATTR if JFFS2_FS
91734 + select REISERFS_FS_XATTR if REISERFS_FS
91735 + select SQUASHFS_XATTR if SQUASHFS
91736 + select TMPFS_XATTR if TMPFS
91737 + select UBIFS_FS_XATTR if UBIFS_FS
91738 + help
91739 + Enabling this option will allow you to control PaX features on
91740 + a per executable basis via the 'setfattr' utility. The control
91741 + flags will be read from the user.pax.flags extended attribute of
91742 + the file. This marking has the benefit of supporting binary-only
91743 + applications that self-check themselves (e.g., skype) and would
91744 + not tolerate chpax/paxctl changes. The main drawback is that
91745 + extended attributes are not supported by some filesystems (e.g.,
91746 + isofs, udf, vfat) so copying files through such filesystems will
91747 + lose the extended attributes and these PaX markings.
91748 +
91749 + Note that if you enable the legacy EI_PAX marking support as well,
91750 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91751 +
91752 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91753 + must make sure that the marks are the same if a binary has both marks.
91754 +
91755 + If you enable none of the marking options then all applications
91756 + will run with PaX enabled on them by default.
91757 +
91758 +choice
91759 + prompt 'MAC system integration'
91760 + default PAX_HAVE_ACL_FLAGS
91761 + help
91762 + Mandatory Access Control systems have the option of controlling
91763 + PaX flags on a per executable basis, choose the method supported
91764 + by your particular system.
91765 +
91766 + - "none": if your MAC system does not interact with PaX,
91767 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91768 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91769 +
91770 + NOTE: this option is for developers/integrators only.
91771 +
91772 + config PAX_NO_ACL_FLAGS
91773 + bool 'none'
91774 +
91775 + config PAX_HAVE_ACL_FLAGS
91776 + bool 'direct'
91777 +
91778 + config PAX_HOOK_ACL_FLAGS
91779 + bool 'hook'
91780 +endchoice
91781 +
91782 +endmenu
91783 +
91784 +menu "Non-executable pages"
91785 + depends on PAX
91786 +
91787 +config PAX_NOEXEC
91788 + bool "Enforce non-executable pages"
91789 + default y if GRKERNSEC_CONFIG_AUTO
91790 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91791 + help
91792 + By design some architectures do not allow for protecting memory
91793 + pages against execution or even if they do, Linux does not make
91794 + use of this feature. In practice this means that if a page is
91795 + readable (such as the stack or heap) it is also executable.
91796 +
91797 + There is a well known exploit technique that makes use of this
91798 + fact and a common programming mistake where an attacker can
91799 + introduce code of his choice somewhere in the attacked program's
91800 + memory (typically the stack or the heap) and then execute it.
91801 +
91802 + If the attacked program was running with different (typically
91803 + higher) privileges than that of the attacker, then he can elevate
91804 + his own privilege level (e.g. get a root shell, write to files for
91805 + which he does not have write access to, etc).
91806 +
91807 + Enabling this option will let you choose from various features
91808 + that prevent the injection and execution of 'foreign' code in
91809 + a program.
91810 +
91811 + This will also break programs that rely on the old behaviour and
91812 + expect that dynamically allocated memory via the malloc() family
91813 + of functions is executable (which it is not). Notable examples
91814 + are the XFree86 4.x server, the java runtime and wine.
91815 +
91816 +config PAX_PAGEEXEC
91817 + bool "Paging based non-executable pages"
91818 + default y if GRKERNSEC_CONFIG_AUTO
91819 + 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)
91820 + select S390_SWITCH_AMODE if S390
91821 + select S390_EXEC_PROTECT if S390
91822 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91823 + help
91824 + This implementation is based on the paging feature of the CPU.
91825 + On i386 without hardware non-executable bit support there is a
91826 + variable but usually low performance impact, however on Intel's
91827 + P4 core based CPUs it is very high so you should not enable this
91828 + for kernels meant to be used on such CPUs.
91829 +
91830 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91831 + with hardware non-executable bit support there is no performance
91832 + impact, on ppc the impact is negligible.
91833 +
91834 + Note that several architectures require various emulations due to
91835 + badly designed userland ABIs, this will cause a performance impact
91836 + but will disappear as soon as userland is fixed. For example, ppc
91837 + userland MUST have been built with secure-plt by a recent toolchain.
91838 +
91839 +config PAX_SEGMEXEC
91840 + bool "Segmentation based non-executable pages"
91841 + default y if GRKERNSEC_CONFIG_AUTO
91842 + depends on PAX_NOEXEC && X86_32
91843 + help
91844 + This implementation is based on the segmentation feature of the
91845 + CPU and has a very small performance impact, however applications
91846 + will be limited to a 1.5 GB address space instead of the normal
91847 + 3 GB.
91848 +
91849 +config PAX_EMUTRAMP
91850 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91851 + default y if PARISC
91852 + help
91853 + There are some programs and libraries that for one reason or
91854 + another attempt to execute special small code snippets from
91855 + non-executable memory pages. Most notable examples are the
91856 + signal handler return code generated by the kernel itself and
91857 + the GCC trampolines.
91858 +
91859 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91860 + such programs will no longer work under your kernel.
91861 +
91862 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91863 + utilities to enable trampoline emulation for the affected programs
91864 + yet still have the protection provided by the non-executable pages.
91865 +
91866 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91867 + your system will not even boot.
91868 +
91869 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91870 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91871 + for the affected files.
91872 +
91873 + NOTE: enabling this feature *may* open up a loophole in the
91874 + protection provided by non-executable pages that an attacker
91875 + could abuse. Therefore the best solution is to not have any
91876 + files on your system that would require this option. This can
91877 + be achieved by not using libc5 (which relies on the kernel
91878 + signal handler return code) and not using or rewriting programs
91879 + that make use of the nested function implementation of GCC.
91880 + Skilled users can just fix GCC itself so that it implements
91881 + nested function calls in a way that does not interfere with PaX.
91882 +
91883 +config PAX_EMUSIGRT
91884 + bool "Automatically emulate sigreturn trampolines"
91885 + depends on PAX_EMUTRAMP && PARISC
91886 + default y
91887 + help
91888 + Enabling this option will have the kernel automatically detect
91889 + and emulate signal return trampolines executing on the stack
91890 + that would otherwise lead to task termination.
91891 +
91892 + This solution is intended as a temporary one for users with
91893 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
91894 + Modula-3 runtime, etc) or executables linked to such, basically
91895 + everything that does not specify its own SA_RESTORER function in
91896 + normal executable memory like glibc 2.1+ does.
91897 +
91898 + On parisc you MUST enable this option, otherwise your system will
91899 + not even boot.
91900 +
91901 + NOTE: this feature cannot be disabled on a per executable basis
91902 + and since it *does* open up a loophole in the protection provided
91903 + by non-executable pages, the best solution is to not have any
91904 + files on your system that would require this option.
91905 +
91906 +config PAX_MPROTECT
91907 + bool "Restrict mprotect()"
91908 + default y if GRKERNSEC_CONFIG_AUTO
91909 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
91910 + help
91911 + Enabling this option will prevent programs from
91912 + - changing the executable status of memory pages that were
91913 + not originally created as executable,
91914 + - making read-only executable pages writable again,
91915 + - creating executable pages from anonymous memory,
91916 + - making read-only-after-relocations (RELRO) data pages writable again.
91917 +
91918 + You should say Y here to complete the protection provided by
91919 + the enforcement of non-executable pages.
91920 +
91921 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91922 + this feature on a per file basis.
91923 +
91924 +config PAX_MPROTECT_COMPAT
91925 + bool "Use legacy/compat protection demoting (read help)"
91926 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91927 + depends on PAX_MPROTECT
91928 + help
91929 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
91930 + by sending the proper error code to the application. For some broken
91931 + userland, this can cause problems with Python or other applications. The
91932 + current implementation however allows for applications like clamav to
91933 + detect if JIT compilation/execution is allowed and to fall back gracefully
91934 + to an interpreter-based mode if it does not. While we encourage everyone
91935 + to use the current implementation as-is and push upstream to fix broken
91936 + userland (note that the RWX logging option can assist with this), in some
91937 + environments this may not be possible. Having to disable MPROTECT
91938 + completely on certain binaries reduces the security benefit of PaX,
91939 + so this option is provided for those environments to revert to the old
91940 + behavior.
91941 +
91942 +config PAX_ELFRELOCS
91943 + bool "Allow ELF text relocations (read help)"
91944 + depends on PAX_MPROTECT
91945 + default n
91946 + help
91947 + Non-executable pages and mprotect() restrictions are effective
91948 + in preventing the introduction of new executable code into an
91949 + attacked task's address space. There remain only two venues
91950 + for this kind of attack: if the attacker can execute already
91951 + existing code in the attacked task then he can either have it
91952 + create and mmap() a file containing his code or have it mmap()
91953 + an already existing ELF library that does not have position
91954 + independent code in it and use mprotect() on it to make it
91955 + writable and copy his code there. While protecting against
91956 + the former approach is beyond PaX, the latter can be prevented
91957 + by having only PIC ELF libraries on one's system (which do not
91958 + need to relocate their code). If you are sure this is your case,
91959 + as is the case with all modern Linux distributions, then leave
91960 + this option disabled. You should say 'n' here.
91961 +
91962 +config PAX_ETEXECRELOCS
91963 + bool "Allow ELF ET_EXEC text relocations"
91964 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
91965 + select PAX_ELFRELOCS
91966 + default y
91967 + help
91968 + On some architectures there are incorrectly created applications
91969 + that require text relocations and would not work without enabling
91970 + this option. If you are an alpha, ia64 or parisc user, you should
91971 + enable this option and disable it once you have made sure that
91972 + none of your applications need it.
91973 +
91974 +config PAX_EMUPLT
91975 + bool "Automatically emulate ELF PLT"
91976 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
91977 + default y
91978 + help
91979 + Enabling this option will have the kernel automatically detect
91980 + and emulate the Procedure Linkage Table entries in ELF files.
91981 + On some architectures such entries are in writable memory, and
91982 + become non-executable leading to task termination. Therefore
91983 + it is mandatory that you enable this option on alpha, parisc,
91984 + sparc and sparc64, otherwise your system would not even boot.
91985 +
91986 + NOTE: this feature *does* open up a loophole in the protection
91987 + provided by the non-executable pages, therefore the proper
91988 + solution is to modify the toolchain to produce a PLT that does
91989 + not need to be writable.
91990 +
91991 +config PAX_DLRESOLVE
91992 + bool 'Emulate old glibc resolver stub'
91993 + depends on PAX_EMUPLT && SPARC
91994 + default n
91995 + help
91996 + This option is needed if userland has an old glibc (before 2.4)
91997 + that puts a 'save' instruction into the runtime generated resolver
91998 + stub that needs special emulation.
91999 +
92000 +config PAX_KERNEXEC
92001 + bool "Enforce non-executable kernel pages"
92002 + 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))
92003 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92004 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92005 + select PAX_KERNEXEC_PLUGIN if X86_64
92006 + help
92007 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92008 + that is, enabling this option will make it harder to inject
92009 + and execute 'foreign' code in kernel memory itself.
92010 +
92011 +choice
92012 + prompt "Return Address Instrumentation Method"
92013 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92014 + depends on PAX_KERNEXEC_PLUGIN
92015 + help
92016 + Select the method used to instrument function pointer dereferences.
92017 + Note that binary modules cannot be instrumented by this approach.
92018 +
92019 + Note that the implementation requires a gcc with plugin support,
92020 + i.e., gcc 4.5 or newer. You may need to install the supporting
92021 + headers explicitly in addition to the normal gcc package.
92022 +
92023 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92024 + bool "bts"
92025 + help
92026 + This method is compatible with binary only modules but has
92027 + a higher runtime overhead.
92028 +
92029 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92030 + bool "or"
92031 + depends on !PARAVIRT
92032 + help
92033 + This method is incompatible with binary only modules but has
92034 + a lower runtime overhead.
92035 +endchoice
92036 +
92037 +config PAX_KERNEXEC_PLUGIN_METHOD
92038 + string
92039 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92040 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92041 + default ""
92042 +
92043 +config PAX_KERNEXEC_MODULE_TEXT
92044 + int "Minimum amount of memory reserved for module code"
92045 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92046 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92047 + depends on PAX_KERNEXEC && X86_32 && MODULES
92048 + help
92049 + Due to implementation details the kernel must reserve a fixed
92050 + amount of memory for module code at compile time that cannot be
92051 + changed at runtime. Here you can specify the minimum amount
92052 + in MB that will be reserved. Due to the same implementation
92053 + details this size will always be rounded up to the next 2/4 MB
92054 + boundary (depends on PAE) so the actually available memory for
92055 + module code will usually be more than this minimum.
92056 +
92057 + The default 4 MB should be enough for most users but if you have
92058 + an excessive number of modules (e.g., most distribution configs
92059 + compile many drivers as modules) or use huge modules such as
92060 + nvidia's kernel driver, you will need to adjust this amount.
92061 + A good rule of thumb is to look at your currently loaded kernel
92062 + modules and add up their sizes.
92063 +
92064 +endmenu
92065 +
92066 +menu "Address Space Layout Randomization"
92067 + depends on PAX
92068 +
92069 +config PAX_ASLR
92070 + bool "Address Space Layout Randomization"
92071 + default y if GRKERNSEC_CONFIG_AUTO
92072 + help
92073 + Many if not most exploit techniques rely on the knowledge of
92074 + certain addresses in the attacked program. The following options
92075 + will allow the kernel to apply a certain amount of randomization
92076 + to specific parts of the program thereby forcing an attacker to
92077 + guess them in most cases. Any failed guess will most likely crash
92078 + the attacked program which allows the kernel to detect such attempts
92079 + and react on them. PaX itself provides no reaction mechanisms,
92080 + instead it is strongly encouraged that you make use of Nergal's
92081 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92082 + (http://www.grsecurity.net/) built-in crash detection features or
92083 + develop one yourself.
92084 +
92085 + By saying Y here you can choose to randomize the following areas:
92086 + - top of the task's kernel stack
92087 + - top of the task's userland stack
92088 + - base address for mmap() requests that do not specify one
92089 + (this includes all libraries)
92090 + - base address of the main executable
92091 +
92092 + It is strongly recommended to say Y here as address space layout
92093 + randomization has negligible impact on performance yet it provides
92094 + a very effective protection.
92095 +
92096 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92097 + this feature on a per file basis.
92098 +
92099 +config PAX_RANDKSTACK
92100 + bool "Randomize kernel stack base"
92101 + default y if GRKERNSEC_CONFIG_AUTO
92102 + depends on X86_TSC && X86
92103 + help
92104 + By saying Y here the kernel will randomize every task's kernel
92105 + stack on every system call. This will not only force an attacker
92106 + to guess it but also prevent him from making use of possible
92107 + leaked information about it.
92108 +
92109 + Since the kernel stack is a rather scarce resource, randomization
92110 + may cause unexpected stack overflows, therefore you should very
92111 + carefully test your system. Note that once enabled in the kernel
92112 + configuration, this feature cannot be disabled on a per file basis.
92113 +
92114 +config PAX_RANDUSTACK
92115 + bool "Randomize user stack base"
92116 + default y if GRKERNSEC_CONFIG_AUTO
92117 + depends on PAX_ASLR
92118 + help
92119 + By saying Y here the kernel will randomize every task's userland
92120 + stack. The randomization is done in two steps where the second
92121 + one may apply a big amount of shift to the top of the stack and
92122 + cause problems for programs that want to use lots of memory (more
92123 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92124 + For this reason the second step can be controlled by 'chpax' or
92125 + 'paxctl' on a per file basis.
92126 +
92127 +config PAX_RANDMMAP
92128 + bool "Randomize mmap() base"
92129 + default y if GRKERNSEC_CONFIG_AUTO
92130 + depends on PAX_ASLR
92131 + help
92132 + By saying Y here the kernel will use a randomized base address for
92133 + mmap() requests that do not specify one themselves. As a result
92134 + all dynamically loaded libraries will appear at random addresses
92135 + and therefore be harder to exploit by a technique where an attacker
92136 + attempts to execute library code for his purposes (e.g. spawn a
92137 + shell from an exploited program that is running at an elevated
92138 + privilege level).
92139 +
92140 + Furthermore, if a program is relinked as a dynamic ELF file, its
92141 + base address will be randomized as well, completing the full
92142 + randomization of the address space layout. Attacking such programs
92143 + becomes a guess game. You can find an example of doing this at
92144 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92145 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92146 +
92147 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92148 + feature on a per file basis.
92149 +
92150 +endmenu
92151 +
92152 +menu "Miscellaneous hardening features"
92153 +
92154 +config PAX_MEMORY_SANITIZE
92155 + bool "Sanitize all freed memory"
92156 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92157 + depends on !HIBERNATION
92158 + help
92159 + By saying Y here the kernel will erase memory pages as soon as they
92160 + are freed. This in turn reduces the lifetime of data stored in the
92161 + pages, making it less likely that sensitive information such as
92162 + passwords, cryptographic secrets, etc stay in memory for too long.
92163 +
92164 + This is especially useful for programs whose runtime is short, long
92165 + lived processes and the kernel itself benefit from this as long as
92166 + they operate on whole memory pages and ensure timely freeing of pages
92167 + that may hold sensitive information.
92168 +
92169 + The tradeoff is performance impact, on a single CPU system kernel
92170 + compilation sees a 3% slowdown, other systems and workloads may vary
92171 + and you are advised to test this feature on your expected workload
92172 + before deploying it.
92173 +
92174 + Note that this feature does not protect data stored in live pages,
92175 + e.g., process memory swapped to disk may stay there for a long time.
92176 +
92177 +config PAX_MEMORY_STACKLEAK
92178 + bool "Sanitize kernel stack"
92179 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92180 + depends on X86
92181 + help
92182 + By saying Y here the kernel will erase the kernel stack before it
92183 + returns from a system call. This in turn reduces the information
92184 + that a kernel stack leak bug can reveal.
92185 +
92186 + Note that such a bug can still leak information that was put on
92187 + the stack by the current system call (the one eventually triggering
92188 + the bug) but traces of earlier system calls on the kernel stack
92189 + cannot leak anymore.
92190 +
92191 + The tradeoff is performance impact: on a single CPU system kernel
92192 + compilation sees a 1% slowdown, other systems and workloads may vary
92193 + and you are advised to test this feature on your expected workload
92194 + before deploying it.
92195 +
92196 + Note that the full feature requires a gcc with plugin support,
92197 + i.e., gcc 4.5 or newer. You may need to install the supporting
92198 + headers explicitly in addition to the normal gcc package. Using
92199 + older gcc versions means that functions with large enough stack
92200 + frames may leave uninitialized memory behind that may be exposed
92201 + to a later syscall leaking the stack.
92202 +
92203 +config PAX_MEMORY_STRUCTLEAK
92204 + bool "Forcibly initialize local variables copied to userland"
92205 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92206 + help
92207 + By saying Y here the kernel will zero initialize some local
92208 + variables that are going to be copied to userland. This in
92209 + turn prevents unintended information leakage from the kernel
92210 + stack should later code forget to explicitly set all parts of
92211 + the copied variable.
92212 +
92213 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92214 + at a much smaller coverage.
92215 +
92216 + Note that the implementation requires a gcc with plugin support,
92217 + i.e., gcc 4.5 or newer. You may need to install the supporting
92218 + headers explicitly in addition to the normal gcc package.
92219 +
92220 +config PAX_MEMORY_UDEREF
92221 + bool "Prevent invalid userland pointer dereference"
92222 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92223 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92224 + select PAX_PER_CPU_PGD if X86_64
92225 + help
92226 + By saying Y here the kernel will be prevented from dereferencing
92227 + userland pointers in contexts where the kernel expects only kernel
92228 + pointers. This is both a useful runtime debugging feature and a
92229 + security measure that prevents exploiting a class of kernel bugs.
92230 +
92231 + The tradeoff is that some virtualization solutions may experience
92232 + a huge slowdown and therefore you should not enable this feature
92233 + for kernels meant to run in such environments. Whether a given VM
92234 + solution is affected or not is best determined by simply trying it
92235 + out, the performance impact will be obvious right on boot as this
92236 + mechanism engages from very early on. A good rule of thumb is that
92237 + VMs running on CPUs without hardware virtualization support (i.e.,
92238 + the majority of IA-32 CPUs) will likely experience the slowdown.
92239 +
92240 +config PAX_REFCOUNT
92241 + bool "Prevent various kernel object reference counter overflows"
92242 + default y if GRKERNSEC_CONFIG_AUTO
92243 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92244 + help
92245 + By saying Y here the kernel will detect and prevent overflowing
92246 + various (but not all) kinds of object reference counters. Such
92247 + overflows can normally occur due to bugs only and are often, if
92248 + not always, exploitable.
92249 +
92250 + The tradeoff is that data structures protected by an overflowed
92251 + refcount will never be freed and therefore will leak memory. Note
92252 + that this leak also happens even without this protection but in
92253 + that case the overflow can eventually trigger the freeing of the
92254 + data structure while it is still being used elsewhere, resulting
92255 + in the exploitable situation that this feature prevents.
92256 +
92257 + Since this has a negligible performance impact, you should enable
92258 + this feature.
92259 +
92260 +config PAX_CONSTIFY_PLUGIN
92261 + bool "Automatically constify eligible structures"
92262 + default y
92263 + depends on !UML && PAX_KERNEXEC
92264 + help
92265 + By saying Y here the compiler will automatically constify a class
92266 + of types that contain only function pointers. This reduces the
92267 + kernel's attack surface and also produces a better memory layout.
92268 +
92269 + Note that the implementation requires a gcc with plugin support,
92270 + i.e., gcc 4.5 or newer. You may need to install the supporting
92271 + headers explicitly in addition to the normal gcc package.
92272 +
92273 + Note that if some code really has to modify constified variables
92274 + then the source code will have to be patched to allow it. Examples
92275 + can be found in PaX itself (the no_const attribute) and for some
92276 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92277 +
92278 +config PAX_USERCOPY
92279 + bool "Harden heap object copies between kernel and userland"
92280 + default y if GRKERNSEC_CONFIG_AUTO
92281 + depends on ARM || IA64 || PPC || SPARC || X86
92282 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92283 + select PAX_USERCOPY_SLABS
92284 + help
92285 + By saying Y here the kernel will enforce the size of heap objects
92286 + when they are copied in either direction between the kernel and
92287 + userland, even if only a part of the heap object is copied.
92288 +
92289 + Specifically, this checking prevents information leaking from the
92290 + kernel heap during kernel to userland copies (if the kernel heap
92291 + object is otherwise fully initialized) and prevents kernel heap
92292 + overflows during userland to kernel copies.
92293 +
92294 + Note that the current implementation provides the strictest bounds
92295 + checks for the SLUB allocator.
92296 +
92297 + Enabling this option also enables per-slab cache protection against
92298 + data in a given cache being copied into/out of via userland
92299 + accessors. Though the whitelist of regions will be reduced over
92300 + time, it notably protects important data structures like task structs.
92301 +
92302 + If frame pointers are enabled on x86, this option will also restrict
92303 + copies into and out of the kernel stack to local variables within a
92304 + single frame.
92305 +
92306 + Since this has a negligible performance impact, you should enable
92307 + this feature.
92308 +
92309 +config PAX_USERCOPY_DEBUG
92310 + bool
92311 + depends on X86 && PAX_USERCOPY
92312 + default n
92313 +
92314 +config PAX_SIZE_OVERFLOW
92315 + bool "Prevent various integer overflows in function size parameters"
92316 + default y if GRKERNSEC_CONFIG_AUTO
92317 + depends on X86
92318 + help
92319 + By saying Y here the kernel recomputes expressions of function
92320 + arguments marked by a size_overflow attribute with double integer
92321 + precision (DImode/TImode for 32/64 bit integer types).
92322 +
92323 + The recomputed argument is checked against TYPE_MAX and an event
92324 + is logged on overflow and the triggering process is killed.
92325 +
92326 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92327 +
92328 + Note that the implementation requires a gcc with plugin support,
92329 + i.e., gcc 4.5 or newer. You may need to install the supporting
92330 + headers explicitly in addition to the normal gcc package.
92331 +
92332 +config PAX_LATENT_ENTROPY
92333 + bool "Generate some entropy during boot"
92334 + default y if GRKERNSEC_CONFIG_AUTO
92335 + help
92336 + By saying Y here the kernel will instrument early boot code to
92337 + extract some entropy from both original and artificially created
92338 + program state. This will help especially embedded systems where
92339 + there is little 'natural' source of entropy normally. The cost
92340 + is some slowdown of the boot process.
92341 +
92342 + When pax_extra_latent_entropy is passed on the kernel command line,
92343 + entropy will be extracted from up to the first 4GB of RAM while the
92344 + runtime memory allocator is being initialized. This costs even more
92345 + slowdown of the boot process.
92346 +
92347 + Note that the implementation requires a gcc with plugin support,
92348 + i.e., gcc 4.5 or newer. You may need to install the supporting
92349 + headers explicitly in addition to the normal gcc package.
92350 +
92351 + Note that entropy extracted this way is not cryptographically
92352 + secure!
92353 +
92354 +endmenu
92355 +
92356 +endmenu
92357 +
92358 +source grsecurity/Kconfig
92359 +
92360 +endmenu
92361 +
92362 +endmenu
92363 +
92364 source security/keys/Kconfig
92365
92366 config SECURITY_DMESG_RESTRICT
92367 @@ -103,7 +1040,7 @@ config INTEL_TXT
92368 config LSM_MMAP_MIN_ADDR
92369 int "Low address space for LSM to protect from user allocation"
92370 depends on SECURITY && SECURITY_SELINUX
92371 - default 32768 if ARM
92372 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92373 default 65536
92374 help
92375 This is the portion of low virtual memory which should be protected
92376 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92377 index 8c2a7f6..b133ac9 100644
92378 --- a/security/apparmor/lsm.c
92379 +++ b/security/apparmor/lsm.c
92380 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92381 return error;
92382 }
92383
92384 -static struct security_operations apparmor_ops = {
92385 +static struct security_operations apparmor_ops __read_only = {
92386 .name = "apparmor",
92387
92388 .ptrace_access_check = apparmor_ptrace_access_check,
92389 diff --git a/security/commoncap.c b/security/commoncap.c
92390 index 7ee08c7..8d1a9d6 100644
92391 --- a/security/commoncap.c
92392 +++ b/security/commoncap.c
92393 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92394 return 0;
92395 }
92396
92397 +/* returns:
92398 + 1 for suid privilege
92399 + 2 for sgid privilege
92400 + 3 for fscap privilege
92401 +*/
92402 +int is_privileged_binary(const struct dentry *dentry)
92403 +{
92404 + struct cpu_vfs_cap_data capdata;
92405 + struct inode *inode = dentry->d_inode;
92406 +
92407 + if (!inode || S_ISDIR(inode->i_mode))
92408 + return 0;
92409 +
92410 + if (inode->i_mode & S_ISUID)
92411 + return 1;
92412 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92413 + return 2;
92414 +
92415 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92416 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92417 + return 3;
92418 + }
92419 +
92420 + return 0;
92421 +}
92422 +
92423 /*
92424 * Attempt to get the on-exec apply capability sets for an executable file from
92425 * its xattrs and, if present, apply them to the proposed credentials being
92426 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92427 const struct cred *cred = current_cred();
92428 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92429
92430 + if (gr_acl_enable_at_secure())
92431 + return 1;
92432 +
92433 if (!uid_eq(cred->uid, root_uid)) {
92434 if (bprm->cap_effective)
92435 return 1;
92436 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92437 index 079a85d..12e93f8 100644
92438 --- a/security/integrity/ima/ima.h
92439 +++ b/security/integrity/ima/ima.h
92440 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92441 extern spinlock_t ima_queue_lock;
92442
92443 struct ima_h_table {
92444 - atomic_long_t len; /* number of stored measurements in the list */
92445 - atomic_long_t violations;
92446 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92447 + atomic_long_unchecked_t violations;
92448 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92449 };
92450 extern struct ima_h_table ima_htable;
92451 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92452 index 0cea3db..2f0ef77 100644
92453 --- a/security/integrity/ima/ima_api.c
92454 +++ b/security/integrity/ima/ima_api.c
92455 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92456 int result;
92457
92458 /* can overflow, only indicator */
92459 - atomic_long_inc(&ima_htable.violations);
92460 + atomic_long_inc_unchecked(&ima_htable.violations);
92461
92462 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92463 if (!entry) {
92464 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92465 index 38477c9..87a60c7 100644
92466 --- a/security/integrity/ima/ima_fs.c
92467 +++ b/security/integrity/ima/ima_fs.c
92468 @@ -28,12 +28,12 @@
92469 static int valid_policy = 1;
92470 #define TMPBUFLEN 12
92471 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92472 - loff_t *ppos, atomic_long_t *val)
92473 + loff_t *ppos, atomic_long_unchecked_t *val)
92474 {
92475 char tmpbuf[TMPBUFLEN];
92476 ssize_t len;
92477
92478 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92479 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92480 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92481 }
92482
92483 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92484 index 55a6271..ad829c3 100644
92485 --- a/security/integrity/ima/ima_queue.c
92486 +++ b/security/integrity/ima/ima_queue.c
92487 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92488 INIT_LIST_HEAD(&qe->later);
92489 list_add_tail_rcu(&qe->later, &ima_measurements);
92490
92491 - atomic_long_inc(&ima_htable.len);
92492 + atomic_long_inc_unchecked(&ima_htable.len);
92493 key = ima_hash_key(entry->digest);
92494 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92495 return 0;
92496 diff --git a/security/keys/compat.c b/security/keys/compat.c
92497 index d65fa7f..cbfe366 100644
92498 --- a/security/keys/compat.c
92499 +++ b/security/keys/compat.c
92500 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92501 if (ret == 0)
92502 goto no_payload_free;
92503
92504 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92505 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92506 err:
92507 if (iov != iovstack)
92508 kfree(iov);
92509 diff --git a/security/keys/key.c b/security/keys/key.c
92510 index 8fb7c7b..ba3610d 100644
92511 --- a/security/keys/key.c
92512 +++ b/security/keys/key.c
92513 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92514
92515 atomic_set(&key->usage, 1);
92516 init_rwsem(&key->sem);
92517 - lockdep_set_class(&key->sem, &type->lock_class);
92518 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92519 key->type = type;
92520 key->user = user;
92521 key->quotalen = quotalen;
92522 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92523 struct key_type *p;
92524 int ret;
92525
92526 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92527 + pax_open_kernel();
92528 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92529 + pax_close_kernel();
92530
92531 ret = -EEXIST;
92532 down_write(&key_types_sem);
92533 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92534 }
92535
92536 /* store the type */
92537 - list_add(&ktype->link, &key_types_list);
92538 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92539
92540 pr_notice("Key type %s registered\n", ktype->name);
92541 ret = 0;
92542 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92543 void unregister_key_type(struct key_type *ktype)
92544 {
92545 down_write(&key_types_sem);
92546 - list_del_init(&ktype->link);
92547 + pax_list_del_init((struct list_head *)&ktype->link);
92548 downgrade_write(&key_types_sem);
92549 key_gc_keytype(ktype);
92550 pr_notice("Key type %s unregistered\n", ktype->name);
92551 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92552 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92553
92554 /* add the special key types */
92555 - list_add_tail(&key_type_keyring.link, &key_types_list);
92556 - list_add_tail(&key_type_dead.link, &key_types_list);
92557 - list_add_tail(&key_type_user.link, &key_types_list);
92558 - list_add_tail(&key_type_logon.link, &key_types_list);
92559 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92560 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92561 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92562 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92563
92564 /* record the root user tracking */
92565 rb_link_node(&root_key_user.node,
92566 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92567 index 4b5c948..2054dc1 100644
92568 --- a/security/keys/keyctl.c
92569 +++ b/security/keys/keyctl.c
92570 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92571 /*
92572 * Copy the iovec data from userspace
92573 */
92574 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92575 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92576 unsigned ioc)
92577 {
92578 for (; ioc > 0; ioc--) {
92579 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92580 * If successful, 0 will be returned.
92581 */
92582 long keyctl_instantiate_key_common(key_serial_t id,
92583 - const struct iovec *payload_iov,
92584 + const struct iovec __user *payload_iov,
92585 unsigned ioc,
92586 size_t plen,
92587 key_serial_t ringid)
92588 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92589 [0].iov_len = plen
92590 };
92591
92592 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92593 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92594 }
92595
92596 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92597 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92598 if (ret == 0)
92599 goto no_payload_free;
92600
92601 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92602 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92603 err:
92604 if (iov != iovstack)
92605 kfree(iov);
92606 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92607 index 6ece7f2..ecdb55c 100644
92608 --- a/security/keys/keyring.c
92609 +++ b/security/keys/keyring.c
92610 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92611 ret = -EFAULT;
92612
92613 for (loop = 0; loop < klist->nkeys; loop++) {
92614 + key_serial_t serial;
92615 key = rcu_deref_link_locked(klist, loop,
92616 keyring);
92617 + serial = key->serial;
92618
92619 tmp = sizeof(key_serial_t);
92620 if (tmp > buflen)
92621 tmp = buflen;
92622
92623 - if (copy_to_user(buffer,
92624 - &key->serial,
92625 - tmp) != 0)
92626 + if (copy_to_user(buffer, &serial, tmp))
92627 goto error;
92628
92629 buflen -= tmp;
92630 diff --git a/security/min_addr.c b/security/min_addr.c
92631 index f728728..6457a0c 100644
92632 --- a/security/min_addr.c
92633 +++ b/security/min_addr.c
92634 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92635 */
92636 static void update_mmap_min_addr(void)
92637 {
92638 +#ifndef SPARC
92639 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92640 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92641 mmap_min_addr = dac_mmap_min_addr;
92642 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92643 #else
92644 mmap_min_addr = dac_mmap_min_addr;
92645 #endif
92646 +#endif
92647 }
92648
92649 /*
92650 diff --git a/security/security.c b/security/security.c
92651 index 7b88c6a..1e3ea8f 100644
92652 --- a/security/security.c
92653 +++ b/security/security.c
92654 @@ -20,6 +20,7 @@
92655 #include <linux/ima.h>
92656 #include <linux/evm.h>
92657 #include <linux/fsnotify.h>
92658 +#include <linux/mm.h>
92659 #include <linux/mman.h>
92660 #include <linux/mount.h>
92661 #include <linux/personality.h>
92662 @@ -32,8 +33,8 @@
92663 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92664 CONFIG_DEFAULT_SECURITY;
92665
92666 -static struct security_operations *security_ops;
92667 -static struct security_operations default_security_ops = {
92668 +static struct security_operations *security_ops __read_only;
92669 +static struct security_operations default_security_ops __read_only = {
92670 .name = "default",
92671 };
92672
92673 @@ -74,7 +75,9 @@ int __init security_init(void)
92674
92675 void reset_security_ops(void)
92676 {
92677 + pax_open_kernel();
92678 security_ops = &default_security_ops;
92679 + pax_close_kernel();
92680 }
92681
92682 /* Save user chosen LSM */
92683 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92684 index ef26e96..642fb78 100644
92685 --- a/security/selinux/hooks.c
92686 +++ b/security/selinux/hooks.c
92687 @@ -95,8 +95,6 @@
92688
92689 #define NUM_SEL_MNT_OPTS 5
92690
92691 -extern struct security_operations *security_ops;
92692 -
92693 /* SECMARK reference count */
92694 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92695
92696 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92697
92698 #endif
92699
92700 -static struct security_operations selinux_ops = {
92701 +static struct security_operations selinux_ops __read_only = {
92702 .name = "selinux",
92703
92704 .ptrace_access_check = selinux_ptrace_access_check,
92705 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92706 index 65f67cb..3f141ef 100644
92707 --- a/security/selinux/include/xfrm.h
92708 +++ b/security/selinux/include/xfrm.h
92709 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92710
92711 static inline void selinux_xfrm_notify_policyload(void)
92712 {
92713 - atomic_inc(&flow_cache_genid);
92714 + atomic_inc_unchecked(&flow_cache_genid);
92715 rt_genid_bump(&init_net);
92716 }
92717 #else
92718 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92719 index 38be92c..21f49ee 100644
92720 --- a/security/smack/smack_lsm.c
92721 +++ b/security/smack/smack_lsm.c
92722 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92723 return 0;
92724 }
92725
92726 -struct security_operations smack_ops = {
92727 +struct security_operations smack_ops __read_only = {
92728 .name = "smack",
92729
92730 .ptrace_access_check = smack_ptrace_access_check,
92731 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92732 index 390c646..f2f8db3 100644
92733 --- a/security/tomoyo/mount.c
92734 +++ b/security/tomoyo/mount.c
92735 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92736 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92737 need_dev = -1; /* dev_name is a directory */
92738 } else {
92739 + if (!capable(CAP_SYS_ADMIN)) {
92740 + error = -EPERM;
92741 + goto out;
92742 + }
92743 fstype = get_fs_type(type);
92744 if (!fstype) {
92745 error = -ENODEV;
92746 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92747 index a2ee362..5754f34 100644
92748 --- a/security/tomoyo/tomoyo.c
92749 +++ b/security/tomoyo/tomoyo.c
92750 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92751 * tomoyo_security_ops is a "struct security_operations" which is used for
92752 * registering TOMOYO.
92753 */
92754 -static struct security_operations tomoyo_security_ops = {
92755 +static struct security_operations tomoyo_security_ops __read_only = {
92756 .name = "tomoyo",
92757 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92758 .cred_prepare = tomoyo_cred_prepare,
92759 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92760 index 20ef514..4182bed 100644
92761 --- a/security/yama/Kconfig
92762 +++ b/security/yama/Kconfig
92763 @@ -1,6 +1,6 @@
92764 config SECURITY_YAMA
92765 bool "Yama support"
92766 - depends on SECURITY
92767 + depends on SECURITY && !GRKERNSEC
92768 select SECURITYFS
92769 select SECURITY_PATH
92770 default n
92771 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92772 index 23414b9..f8c115e 100644
92773 --- a/security/yama/yama_lsm.c
92774 +++ b/security/yama/yama_lsm.c
92775 @@ -347,10 +347,8 @@ int yama_ptrace_traceme(struct task_struct *parent)
92776 /* Only disallow PTRACE_TRACEME on more aggressive settings. */
92777 switch (ptrace_scope) {
92778 case YAMA_SCOPE_CAPABILITY:
92779 - rcu_read_lock();
92780 - if (!ns_capable(__task_cred(parent)->user_ns, CAP_SYS_PTRACE))
92781 + if (!has_ns_capability(parent, current_user_ns(), CAP_SYS_PTRACE))
92782 rc = -EPERM;
92783 - rcu_read_unlock();
92784 break;
92785 case YAMA_SCOPE_NO_ATTACH:
92786 rc = -EPERM;
92787 @@ -367,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92788 }
92789
92790 #ifndef CONFIG_SECURITY_YAMA_STACKED
92791 -static struct security_operations yama_ops = {
92792 +static struct security_operations yama_ops __read_only = {
92793 .name = "yama",
92794
92795 .ptrace_access_check = yama_ptrace_access_check,
92796 @@ -378,28 +376,24 @@ static struct security_operations yama_ops = {
92797 #endif
92798
92799 #ifdef CONFIG_SYSCTL
92800 +static int zero __read_only;
92801 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92802 +
92803 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92804 void __user *buffer, size_t *lenp, loff_t *ppos)
92805 {
92806 - int rc;
92807 + ctl_table_no_const yama_table;
92808
92809 if (write && !capable(CAP_SYS_PTRACE))
92810 return -EPERM;
92811
92812 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92813 - if (rc)
92814 - return rc;
92815 -
92816 + yama_table = *table;
92817 /* Lock the max value if it ever gets set. */
92818 - if (write && *(int *)table->data == *(int *)table->extra2)
92819 - table->extra1 = table->extra2;
92820 -
92821 - return rc;
92822 + if (ptrace_scope == max_scope)
92823 + yama_table.extra1 = &max_scope;
92824 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92825 }
92826
92827 -static int zero;
92828 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92829 -
92830 struct ctl_path yama_sysctl_path[] = {
92831 { .procname = "kernel", },
92832 { .procname = "yama", },
92833 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92834 index 4cedc69..e59d8a3 100644
92835 --- a/sound/aoa/codecs/onyx.c
92836 +++ b/sound/aoa/codecs/onyx.c
92837 @@ -54,7 +54,7 @@ struct onyx {
92838 spdif_locked:1,
92839 analog_locked:1,
92840 original_mute:2;
92841 - int open_count;
92842 + local_t open_count;
92843 struct codec_info *codec_info;
92844
92845 /* mutex serializes concurrent access to the device
92846 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92847 struct onyx *onyx = cii->codec_data;
92848
92849 mutex_lock(&onyx->mutex);
92850 - onyx->open_count++;
92851 + local_inc(&onyx->open_count);
92852 mutex_unlock(&onyx->mutex);
92853
92854 return 0;
92855 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92856 struct onyx *onyx = cii->codec_data;
92857
92858 mutex_lock(&onyx->mutex);
92859 - onyx->open_count--;
92860 - if (!onyx->open_count)
92861 + if (local_dec_and_test(&onyx->open_count))
92862 onyx->spdif_locked = onyx->analog_locked = 0;
92863 mutex_unlock(&onyx->mutex);
92864
92865 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92866 index ffd2025..df062c9 100644
92867 --- a/sound/aoa/codecs/onyx.h
92868 +++ b/sound/aoa/codecs/onyx.h
92869 @@ -11,6 +11,7 @@
92870 #include <linux/i2c.h>
92871 #include <asm/pmac_low_i2c.h>
92872 #include <asm/prom.h>
92873 +#include <asm/local.h>
92874
92875 /* PCM3052 register definitions */
92876
92877 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
92878 index 4c1cc51..16040040 100644
92879 --- a/sound/core/oss/pcm_oss.c
92880 +++ b/sound/core/oss/pcm_oss.c
92881 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
92882 if (in_kernel) {
92883 mm_segment_t fs;
92884 fs = snd_enter_user();
92885 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92886 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92887 snd_leave_user(fs);
92888 } else {
92889 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92890 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92891 }
92892 if (ret != -EPIPE && ret != -ESTRPIPE)
92893 break;
92894 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
92895 if (in_kernel) {
92896 mm_segment_t fs;
92897 fs = snd_enter_user();
92898 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92899 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92900 snd_leave_user(fs);
92901 } else {
92902 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92903 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92904 }
92905 if (ret == -EPIPE) {
92906 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
92907 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
92908 struct snd_pcm_plugin_channel *channels;
92909 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
92910 if (!in_kernel) {
92911 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
92912 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
92913 return -EFAULT;
92914 buf = runtime->oss.buffer;
92915 }
92916 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
92917 }
92918 } else {
92919 tmp = snd_pcm_oss_write2(substream,
92920 - (const char __force *)buf,
92921 + (const char __force_kernel *)buf,
92922 runtime->oss.period_bytes, 0);
92923 if (tmp <= 0)
92924 goto err;
92925 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
92926 struct snd_pcm_runtime *runtime = substream->runtime;
92927 snd_pcm_sframes_t frames, frames1;
92928 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
92929 - char __user *final_dst = (char __force __user *)buf;
92930 + char __user *final_dst = (char __force_user *)buf;
92931 if (runtime->oss.plugin_first) {
92932 struct snd_pcm_plugin_channel *channels;
92933 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
92934 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
92935 xfer += tmp;
92936 runtime->oss.buffer_used -= tmp;
92937 } else {
92938 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
92939 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
92940 runtime->oss.period_bytes, 0);
92941 if (tmp <= 0)
92942 goto err;
92943 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
92944 size1);
92945 size1 /= runtime->channels; /* frames */
92946 fs = snd_enter_user();
92947 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
92948 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
92949 snd_leave_user(fs);
92950 }
92951 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
92952 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
92953 index af49721..e85058e 100644
92954 --- a/sound/core/pcm_compat.c
92955 +++ b/sound/core/pcm_compat.c
92956 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
92957 int err;
92958
92959 fs = snd_enter_user();
92960 - err = snd_pcm_delay(substream, &delay);
92961 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
92962 snd_leave_user(fs);
92963 if (err < 0)
92964 return err;
92965 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
92966 index f4aaf5a..3b04e3b 100644
92967 --- a/sound/core/pcm_native.c
92968 +++ b/sound/core/pcm_native.c
92969 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
92970 switch (substream->stream) {
92971 case SNDRV_PCM_STREAM_PLAYBACK:
92972 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
92973 - (void __user *)arg);
92974 + (void __force_user *)arg);
92975 break;
92976 case SNDRV_PCM_STREAM_CAPTURE:
92977 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
92978 - (void __user *)arg);
92979 + (void __force_user *)arg);
92980 break;
92981 default:
92982 result = -EINVAL;
92983 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
92984 index 040c60e..989a19a 100644
92985 --- a/sound/core/seq/seq_device.c
92986 +++ b/sound/core/seq/seq_device.c
92987 @@ -64,7 +64,7 @@ struct ops_list {
92988 int argsize; /* argument size */
92989
92990 /* operators */
92991 - struct snd_seq_dev_ops ops;
92992 + struct snd_seq_dev_ops *ops;
92993
92994 /* registered devices */
92995 struct list_head dev_list; /* list of devices */
92996 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
92997
92998 mutex_lock(&ops->reg_mutex);
92999 /* copy driver operators */
93000 - ops->ops = *entry;
93001 + ops->ops = entry;
93002 ops->driver |= DRIVER_LOADED;
93003 ops->argsize = argsize;
93004
93005 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
93006 dev->name, ops->id, ops->argsize, dev->argsize);
93007 return -EINVAL;
93008 }
93009 - if (ops->ops.init_device(dev) >= 0) {
93010 + if (ops->ops->init_device(dev) >= 0) {
93011 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
93012 ops->num_init_devices++;
93013 } else {
93014 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
93015 dev->name, ops->id, ops->argsize, dev->argsize);
93016 return -EINVAL;
93017 }
93018 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
93019 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
93020 dev->status = SNDRV_SEQ_DEVICE_FREE;
93021 dev->driver_data = NULL;
93022 ops->num_init_devices--;
93023 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
93024 index 4e0dd22..7a1f32c 100644
93025 --- a/sound/drivers/mts64.c
93026 +++ b/sound/drivers/mts64.c
93027 @@ -29,6 +29,7 @@
93028 #include <sound/initval.h>
93029 #include <sound/rawmidi.h>
93030 #include <sound/control.h>
93031 +#include <asm/local.h>
93032
93033 #define CARD_NAME "Miditerminal 4140"
93034 #define DRIVER_NAME "MTS64"
93035 @@ -67,7 +68,7 @@ struct mts64 {
93036 struct pardevice *pardev;
93037 int pardev_claimed;
93038
93039 - int open_count;
93040 + local_t open_count;
93041 int current_midi_output_port;
93042 int current_midi_input_port;
93043 u8 mode[MTS64_NUM_INPUT_PORTS];
93044 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93045 {
93046 struct mts64 *mts = substream->rmidi->private_data;
93047
93048 - if (mts->open_count == 0) {
93049 + if (local_read(&mts->open_count) == 0) {
93050 /* We don't need a spinlock here, because this is just called
93051 if the device has not been opened before.
93052 So there aren't any IRQs from the device */
93053 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93054
93055 msleep(50);
93056 }
93057 - ++(mts->open_count);
93058 + local_inc(&mts->open_count);
93059
93060 return 0;
93061 }
93062 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93063 struct mts64 *mts = substream->rmidi->private_data;
93064 unsigned long flags;
93065
93066 - --(mts->open_count);
93067 - if (mts->open_count == 0) {
93068 + if (local_dec_return(&mts->open_count) == 0) {
93069 /* We need the spinlock_irqsave here because we can still
93070 have IRQs at this point */
93071 spin_lock_irqsave(&mts->lock, flags);
93072 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93073
93074 msleep(500);
93075
93076 - } else if (mts->open_count < 0)
93077 - mts->open_count = 0;
93078 + } else if (local_read(&mts->open_count) < 0)
93079 + local_set(&mts->open_count, 0);
93080
93081 return 0;
93082 }
93083 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93084 index b953fb4..1999c01 100644
93085 --- a/sound/drivers/opl4/opl4_lib.c
93086 +++ b/sound/drivers/opl4/opl4_lib.c
93087 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93088 MODULE_DESCRIPTION("OPL4 driver");
93089 MODULE_LICENSE("GPL");
93090
93091 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93092 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93093 {
93094 int timeout = 10;
93095 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93096 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93097 index 991018d..8984740 100644
93098 --- a/sound/drivers/portman2x4.c
93099 +++ b/sound/drivers/portman2x4.c
93100 @@ -48,6 +48,7 @@
93101 #include <sound/initval.h>
93102 #include <sound/rawmidi.h>
93103 #include <sound/control.h>
93104 +#include <asm/local.h>
93105
93106 #define CARD_NAME "Portman 2x4"
93107 #define DRIVER_NAME "portman"
93108 @@ -85,7 +86,7 @@ struct portman {
93109 struct pardevice *pardev;
93110 int pardev_claimed;
93111
93112 - int open_count;
93113 + local_t open_count;
93114 int mode[PORTMAN_NUM_INPUT_PORTS];
93115 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93116 };
93117 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93118 index ea995af..f1bfa37 100644
93119 --- a/sound/firewire/amdtp.c
93120 +++ b/sound/firewire/amdtp.c
93121 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93122 ptr = s->pcm_buffer_pointer + data_blocks;
93123 if (ptr >= pcm->runtime->buffer_size)
93124 ptr -= pcm->runtime->buffer_size;
93125 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93126 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93127
93128 s->pcm_period_pointer += data_blocks;
93129 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93130 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93131 */
93132 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93133 {
93134 - ACCESS_ONCE(s->source_node_id_field) =
93135 + ACCESS_ONCE_RW(s->source_node_id_field) =
93136 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93137 }
93138 EXPORT_SYMBOL(amdtp_out_stream_update);
93139 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93140 index b680c5e..061b7a0 100644
93141 --- a/sound/firewire/amdtp.h
93142 +++ b/sound/firewire/amdtp.h
93143 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93144 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93145 struct snd_pcm_substream *pcm)
93146 {
93147 - ACCESS_ONCE(s->pcm) = pcm;
93148 + ACCESS_ONCE_RW(s->pcm) = pcm;
93149 }
93150
93151 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93152 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93153 index d428ffe..751ef78 100644
93154 --- a/sound/firewire/isight.c
93155 +++ b/sound/firewire/isight.c
93156 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93157 ptr += count;
93158 if (ptr >= runtime->buffer_size)
93159 ptr -= runtime->buffer_size;
93160 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93161 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93162
93163 isight->period_counter += count;
93164 if (isight->period_counter >= runtime->period_size) {
93165 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93166 if (err < 0)
93167 return err;
93168
93169 - ACCESS_ONCE(isight->pcm_active) = true;
93170 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93171
93172 return 0;
93173 }
93174 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93175 {
93176 struct isight *isight = substream->private_data;
93177
93178 - ACCESS_ONCE(isight->pcm_active) = false;
93179 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93180
93181 mutex_lock(&isight->mutex);
93182 isight_stop_streaming(isight);
93183 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93184
93185 switch (cmd) {
93186 case SNDRV_PCM_TRIGGER_START:
93187 - ACCESS_ONCE(isight->pcm_running) = true;
93188 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93189 break;
93190 case SNDRV_PCM_TRIGGER_STOP:
93191 - ACCESS_ONCE(isight->pcm_running) = false;
93192 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93193 break;
93194 default:
93195 return -EINVAL;
93196 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93197 index 844a555..985ab83 100644
93198 --- a/sound/firewire/scs1x.c
93199 +++ b/sound/firewire/scs1x.c
93200 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93201 {
93202 struct scs *scs = stream->rmidi->private_data;
93203
93204 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93205 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93206 if (up) {
93207 scs->output_idle = false;
93208 tasklet_schedule(&scs->tasklet);
93209 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93210 {
93211 struct scs *scs = stream->rmidi->private_data;
93212
93213 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93214 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93215 }
93216
93217 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93218 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93219
93220 snd_card_disconnect(scs->card);
93221
93222 - ACCESS_ONCE(scs->output) = NULL;
93223 - ACCESS_ONCE(scs->input) = NULL;
93224 + ACCESS_ONCE_RW(scs->output) = NULL;
93225 + ACCESS_ONCE_RW(scs->input) = NULL;
93226
93227 wait_event(scs->idle_wait, scs->output_idle);
93228
93229 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93230 index 048439a..3be9f6f 100644
93231 --- a/sound/oss/sb_audio.c
93232 +++ b/sound/oss/sb_audio.c
93233 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93234 buf16 = (signed short *)(localbuf + localoffs);
93235 while (c)
93236 {
93237 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93238 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93239 if (copy_from_user(lbuf8,
93240 userbuf+useroffs + p,
93241 locallen))
93242 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93243 index 7d8803a..559f8d0 100644
93244 --- a/sound/oss/swarm_cs4297a.c
93245 +++ b/sound/oss/swarm_cs4297a.c
93246 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93247 {
93248 struct cs4297a_state *s;
93249 u32 pwr, id;
93250 - mm_segment_t fs;
93251 int rval;
93252 #ifndef CONFIG_BCM_CS4297A_CSWARM
93253 u64 cfg;
93254 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93255 if (!rval) {
93256 char *sb1250_duart_present;
93257
93258 +#if 0
93259 + mm_segment_t fs;
93260 fs = get_fs();
93261 set_fs(KERNEL_DS);
93262 -#if 0
93263 val = SOUND_MASK_LINE;
93264 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93265 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93266 val = initvol[i].vol;
93267 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93268 }
93269 + set_fs(fs);
93270 // cs4297a_write_ac97(s, 0x18, 0x0808);
93271 #else
93272 // cs4297a_write_ac97(s, 0x5e, 0x180);
93273 cs4297a_write_ac97(s, 0x02, 0x0808);
93274 cs4297a_write_ac97(s, 0x18, 0x0808);
93275 #endif
93276 - set_fs(fs);
93277
93278 list_add(&s->list, &cs4297a_devs);
93279
93280 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93281 index 4631a23..001ae57 100644
93282 --- a/sound/pci/ymfpci/ymfpci.h
93283 +++ b/sound/pci/ymfpci/ymfpci.h
93284 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93285 spinlock_t reg_lock;
93286 spinlock_t voice_lock;
93287 wait_queue_head_t interrupt_sleep;
93288 - atomic_t interrupt_sleep_count;
93289 + atomic_unchecked_t interrupt_sleep_count;
93290 struct snd_info_entry *proc_entry;
93291 const struct firmware *dsp_microcode;
93292 const struct firmware *controller_microcode;
93293 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93294 index 22056c5..25d3244 100644
93295 --- a/sound/pci/ymfpci/ymfpci_main.c
93296 +++ b/sound/pci/ymfpci/ymfpci_main.c
93297 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93298 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93299 break;
93300 }
93301 - if (atomic_read(&chip->interrupt_sleep_count)) {
93302 - atomic_set(&chip->interrupt_sleep_count, 0);
93303 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93304 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93305 wake_up(&chip->interrupt_sleep);
93306 }
93307 __end:
93308 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93309 continue;
93310 init_waitqueue_entry(&wait, current);
93311 add_wait_queue(&chip->interrupt_sleep, &wait);
93312 - atomic_inc(&chip->interrupt_sleep_count);
93313 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93314 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93315 remove_wait_queue(&chip->interrupt_sleep, &wait);
93316 }
93317 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93318 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93319 spin_unlock(&chip->reg_lock);
93320
93321 - if (atomic_read(&chip->interrupt_sleep_count)) {
93322 - atomic_set(&chip->interrupt_sleep_count, 0);
93323 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93324 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93325 wake_up(&chip->interrupt_sleep);
93326 }
93327 }
93328 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93329 spin_lock_init(&chip->reg_lock);
93330 spin_lock_init(&chip->voice_lock);
93331 init_waitqueue_head(&chip->interrupt_sleep);
93332 - atomic_set(&chip->interrupt_sleep_count, 0);
93333 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93334 chip->card = card;
93335 chip->pci = pci;
93336 chip->irq = -1;
93337 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93338 new file mode 100644
93339 index 0000000..50f2f2f
93340 --- /dev/null
93341 +++ b/tools/gcc/.gitignore
93342 @@ -0,0 +1 @@
93343 +size_overflow_hash.h
93344 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93345 new file mode 100644
93346 index 0000000..144dbee
93347 --- /dev/null
93348 +++ b/tools/gcc/Makefile
93349 @@ -0,0 +1,45 @@
93350 +#CC := gcc
93351 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93352 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93353 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93354 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93355 +
93356 +ifeq ($(PLUGINCC),$(HOSTCC))
93357 +HOSTLIBS := hostlibs
93358 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93359 +else
93360 +HOSTLIBS := hostcxxlibs
93361 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93362 +endif
93363 +
93364 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93365 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93366 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93367 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93368 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93369 +$(HOSTLIBS)-y += colorize_plugin.so
93370 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93371 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93372 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93373 +
93374 +always := $($(HOSTLIBS)-y)
93375 +
93376 +constify_plugin-objs := constify_plugin.o
93377 +stackleak_plugin-objs := stackleak_plugin.o
93378 +kallocstat_plugin-objs := kallocstat_plugin.o
93379 +kernexec_plugin-objs := kernexec_plugin.o
93380 +checker_plugin-objs := checker_plugin.o
93381 +colorize_plugin-objs := colorize_plugin.o
93382 +size_overflow_plugin-objs := size_overflow_plugin.o
93383 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93384 +structleak_plugin-objs := structleak_plugin.o
93385 +
93386 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93387 +
93388 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93389 + cmd_build_size_overflow_hash = \
93390 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93391 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93392 + $(call if_changed,build_size_overflow_hash)
93393 +
93394 +targets += size_overflow_hash.h
93395 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93396 new file mode 100644
93397 index 0000000..d41b5af
93398 --- /dev/null
93399 +++ b/tools/gcc/checker_plugin.c
93400 @@ -0,0 +1,171 @@
93401 +/*
93402 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93403 + * Licensed under the GPL v2
93404 + *
93405 + * Note: the choice of the license means that the compilation process is
93406 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93407 + * but for the kernel it doesn't matter since it doesn't link against
93408 + * any of the gcc libraries
93409 + *
93410 + * gcc plugin to implement various sparse (source code checker) features
93411 + *
93412 + * TODO:
93413 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93414 + *
93415 + * BUGS:
93416 + * - none known
93417 + */
93418 +#include "gcc-plugin.h"
93419 +#include "config.h"
93420 +#include "system.h"
93421 +#include "coretypes.h"
93422 +#include "tree.h"
93423 +#include "tree-pass.h"
93424 +#include "flags.h"
93425 +#include "intl.h"
93426 +#include "toplev.h"
93427 +#include "plugin.h"
93428 +//#include "expr.h" where are you...
93429 +#include "diagnostic.h"
93430 +#include "plugin-version.h"
93431 +#include "tm.h"
93432 +#include "function.h"
93433 +#include "basic-block.h"
93434 +#include "gimple.h"
93435 +#include "rtl.h"
93436 +#include "emit-rtl.h"
93437 +#include "tree-flow.h"
93438 +#include "target.h"
93439 +
93440 +extern void c_register_addr_space (const char *str, addr_space_t as);
93441 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93442 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93443 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93444 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93445 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93446 +
93447 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93448 +extern rtx emit_move_insn(rtx x, rtx y);
93449 +
93450 +int plugin_is_GPL_compatible;
93451 +
93452 +static struct plugin_info checker_plugin_info = {
93453 + .version = "201111150100",
93454 +};
93455 +
93456 +#define ADDR_SPACE_KERNEL 0
93457 +#define ADDR_SPACE_FORCE_KERNEL 1
93458 +#define ADDR_SPACE_USER 2
93459 +#define ADDR_SPACE_FORCE_USER 3
93460 +#define ADDR_SPACE_IOMEM 0
93461 +#define ADDR_SPACE_FORCE_IOMEM 0
93462 +#define ADDR_SPACE_PERCPU 0
93463 +#define ADDR_SPACE_FORCE_PERCPU 0
93464 +#define ADDR_SPACE_RCU 0
93465 +#define ADDR_SPACE_FORCE_RCU 0
93466 +
93467 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93468 +{
93469 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93470 +}
93471 +
93472 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93473 +{
93474 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93475 +}
93476 +
93477 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93478 +{
93479 + return default_addr_space_valid_pointer_mode(mode, as);
93480 +}
93481 +
93482 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93483 +{
93484 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93485 +}
93486 +
93487 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93488 +{
93489 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93490 +}
93491 +
93492 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93493 +{
93494 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93495 + return true;
93496 +
93497 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93498 + return true;
93499 +
93500 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93501 + return true;
93502 +
93503 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93504 + return true;
93505 +
93506 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93507 + return true;
93508 +
93509 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93510 + return true;
93511 +
93512 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93513 + return true;
93514 +
93515 + return subset == superset;
93516 +}
93517 +
93518 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93519 +{
93520 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93521 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93522 +
93523 + return op;
93524 +}
93525 +
93526 +static void register_checker_address_spaces(void *event_data, void *data)
93527 +{
93528 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93529 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93530 + c_register_addr_space("__user", ADDR_SPACE_USER);
93531 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93532 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93533 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93534 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93535 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93536 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93537 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93538 +
93539 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93540 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93541 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93542 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93543 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93544 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93545 + targetm.addr_space.convert = checker_addr_space_convert;
93546 +}
93547 +
93548 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93549 +{
93550 + const char * const plugin_name = plugin_info->base_name;
93551 + const int argc = plugin_info->argc;
93552 + const struct plugin_argument * const argv = plugin_info->argv;
93553 + int i;
93554 +
93555 + if (!plugin_default_version_check(version, &gcc_version)) {
93556 + error(G_("incompatible gcc/plugin versions"));
93557 + return 1;
93558 + }
93559 +
93560 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93561 +
93562 + for (i = 0; i < argc; ++i)
93563 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93564 +
93565 + if (TARGET_64BIT == 0)
93566 + return 0;
93567 +
93568 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93569 +
93570 + return 0;
93571 +}
93572 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93573 new file mode 100644
93574 index 0000000..414fe5e
93575 --- /dev/null
93576 +++ b/tools/gcc/colorize_plugin.c
93577 @@ -0,0 +1,151 @@
93578 +/*
93579 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93580 + * Licensed under the GPL v2
93581 + *
93582 + * Note: the choice of the license means that the compilation process is
93583 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93584 + * but for the kernel it doesn't matter since it doesn't link against
93585 + * any of the gcc libraries
93586 + *
93587 + * gcc plugin to colorize diagnostic output
93588 + *
93589 + */
93590 +
93591 +#include "gcc-plugin.h"
93592 +#include "config.h"
93593 +#include "system.h"
93594 +#include "coretypes.h"
93595 +#include "tree.h"
93596 +#include "tree-pass.h"
93597 +#include "flags.h"
93598 +#include "intl.h"
93599 +#include "toplev.h"
93600 +#include "plugin.h"
93601 +#include "diagnostic.h"
93602 +#include "plugin-version.h"
93603 +#include "tm.h"
93604 +
93605 +int plugin_is_GPL_compatible;
93606 +
93607 +static struct plugin_info colorize_plugin_info = {
93608 + .version = "201302112000",
93609 + .help = NULL,
93610 +};
93611 +
93612 +#define GREEN "\033[32m\033[2m"
93613 +#define LIGHTGREEN "\033[32m\033[1m"
93614 +#define YELLOW "\033[33m\033[2m"
93615 +#define LIGHTYELLOW "\033[33m\033[1m"
93616 +#define RED "\033[31m\033[2m"
93617 +#define LIGHTRED "\033[31m\033[1m"
93618 +#define BLUE "\033[34m\033[2m"
93619 +#define LIGHTBLUE "\033[34m\033[1m"
93620 +#define BRIGHT "\033[m\033[1m"
93621 +#define NORMAL "\033[m"
93622 +
93623 +static diagnostic_starter_fn old_starter;
93624 +static diagnostic_finalizer_fn old_finalizer;
93625 +
93626 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93627 +{
93628 + const char *color;
93629 + char *newprefix;
93630 +
93631 + switch (diagnostic->kind) {
93632 + case DK_NOTE:
93633 + color = LIGHTBLUE;
93634 + break;
93635 +
93636 + case DK_PEDWARN:
93637 + case DK_WARNING:
93638 + color = LIGHTYELLOW;
93639 + break;
93640 +
93641 + case DK_ERROR:
93642 + case DK_FATAL:
93643 + case DK_ICE:
93644 + case DK_PERMERROR:
93645 + case DK_SORRY:
93646 + color = LIGHTRED;
93647 + break;
93648 +
93649 + default:
93650 + color = NORMAL;
93651 + }
93652 +
93653 + old_starter(context, diagnostic);
93654 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93655 + return;
93656 + pp_destroy_prefix(context->printer);
93657 + pp_set_prefix(context->printer, newprefix);
93658 +}
93659 +
93660 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93661 +{
93662 + old_finalizer(context, diagnostic);
93663 +}
93664 +
93665 +static void colorize_arm(void)
93666 +{
93667 + old_starter = diagnostic_starter(global_dc);
93668 + old_finalizer = diagnostic_finalizer(global_dc);
93669 +
93670 + diagnostic_starter(global_dc) = start_colorize;
93671 + diagnostic_finalizer(global_dc) = finalize_colorize;
93672 +}
93673 +
93674 +static unsigned int execute_colorize_rearm(void)
93675 +{
93676 + if (diagnostic_starter(global_dc) == start_colorize)
93677 + return 0;
93678 +
93679 + colorize_arm();
93680 + return 0;
93681 +}
93682 +
93683 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93684 + .pass = {
93685 + .type = SIMPLE_IPA_PASS,
93686 + .name = "colorize_rearm",
93687 +#if BUILDING_GCC_VERSION >= 4008
93688 + .optinfo_flags = OPTGROUP_NONE,
93689 +#endif
93690 + .gate = NULL,
93691 + .execute = execute_colorize_rearm,
93692 + .sub = NULL,
93693 + .next = NULL,
93694 + .static_pass_number = 0,
93695 + .tv_id = TV_NONE,
93696 + .properties_required = 0,
93697 + .properties_provided = 0,
93698 + .properties_destroyed = 0,
93699 + .todo_flags_start = 0,
93700 + .todo_flags_finish = 0
93701 + }
93702 +};
93703 +
93704 +static void colorize_start_unit(void *gcc_data, void *user_data)
93705 +{
93706 + colorize_arm();
93707 +}
93708 +
93709 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93710 +{
93711 + const char * const plugin_name = plugin_info->base_name;
93712 + struct register_pass_info colorize_rearm_pass_info = {
93713 + .pass = &pass_ipa_colorize_rearm.pass,
93714 + .reference_pass_name = "*free_lang_data",
93715 + .ref_pass_instance_number = 1,
93716 + .pos_op = PASS_POS_INSERT_AFTER
93717 + };
93718 +
93719 + if (!plugin_default_version_check(version, &gcc_version)) {
93720 + error(G_("incompatible gcc/plugin versions"));
93721 + return 1;
93722 + }
93723 +
93724 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93725 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93726 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93727 + return 0;
93728 +}
93729 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93730 new file mode 100644
93731 index 0000000..bee0acb
93732 --- /dev/null
93733 +++ b/tools/gcc/constify_plugin.c
93734 @@ -0,0 +1,518 @@
93735 +/*
93736 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93737 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93738 + * Licensed under the GPL v2, or (at your option) v3
93739 + *
93740 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93741 + *
93742 + * Homepage:
93743 + * http://www.grsecurity.net/~ephox/const_plugin/
93744 + *
93745 + * Usage:
93746 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93747 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93748 + */
93749 +
93750 +#include "gcc-plugin.h"
93751 +#include "config.h"
93752 +#include "system.h"
93753 +#include "coretypes.h"
93754 +#include "tree.h"
93755 +#include "tree-pass.h"
93756 +#include "flags.h"
93757 +#include "intl.h"
93758 +#include "toplev.h"
93759 +#include "plugin.h"
93760 +#include "diagnostic.h"
93761 +#include "plugin-version.h"
93762 +#include "tm.h"
93763 +#include "function.h"
93764 +#include "basic-block.h"
93765 +#include "gimple.h"
93766 +#include "rtl.h"
93767 +#include "emit-rtl.h"
93768 +#include "tree-flow.h"
93769 +#include "target.h"
93770 +#include "langhooks.h"
93771 +
93772 +// should come from c-tree.h if only it were installed for gcc 4.5...
93773 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93774 +
93775 +// unused type flag in all versions 4.5-4.8
93776 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93777 +
93778 +int plugin_is_GPL_compatible;
93779 +
93780 +static struct plugin_info const_plugin_info = {
93781 + .version = "201303270300",
93782 + .help = "no-constify\tturn off constification\n",
93783 +};
93784 +
93785 +typedef struct {
93786 + bool has_fptr_field;
93787 + bool has_writable_field;
93788 + bool has_do_const_field;
93789 + bool has_no_const_field;
93790 +} constify_info;
93791 +
93792 +static const_tree get_field_type(const_tree field)
93793 +{
93794 + return strip_array_types(TREE_TYPE(field));
93795 +}
93796 +
93797 +static bool is_fptr(const_tree field)
93798 +{
93799 + const_tree ptr = get_field_type(field);
93800 +
93801 + if (TREE_CODE(ptr) != POINTER_TYPE)
93802 + return false;
93803 +
93804 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93805 +}
93806 +
93807 +/*
93808 + * determine whether the given structure type meets the requirements for automatic constification,
93809 + * including the constification attributes on nested structure types
93810 + */
93811 +static void constifiable(const_tree node, constify_info *cinfo)
93812 +{
93813 + const_tree field;
93814 +
93815 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93816 +
93817 + // e.g., pointer to structure fields while still constructing the structure type
93818 + if (TYPE_FIELDS(node) == NULL_TREE)
93819 + return;
93820 +
93821 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93822 + const_tree type = get_field_type(field);
93823 + enum tree_code code = TREE_CODE(type);
93824 +
93825 + if (node == type)
93826 + continue;
93827 +
93828 + if (is_fptr(field))
93829 + cinfo->has_fptr_field = true;
93830 + else if (!TREE_READONLY(field))
93831 + cinfo->has_writable_field = true;
93832 +
93833 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93834 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93835 + cinfo->has_do_const_field = true;
93836 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93837 + cinfo->has_no_const_field = true;
93838 + else
93839 + constifiable(type, cinfo);
93840 + }
93841 + }
93842 +}
93843 +
93844 +static bool constified(const_tree node)
93845 +{
93846 + constify_info cinfo = {
93847 + .has_fptr_field = false,
93848 + .has_writable_field = false,
93849 + .has_do_const_field = false,
93850 + .has_no_const_field = false
93851 + };
93852 +
93853 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93854 +
93855 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93856 + gcc_assert(!TYPE_READONLY(node));
93857 + return false;
93858 + }
93859 +
93860 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93861 + gcc_assert(TYPE_READONLY(node));
93862 + return true;
93863 + }
93864 +
93865 + constifiable(node, &cinfo);
93866 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93867 + return false;
93868 +
93869 + return TYPE_READONLY(node);
93870 +}
93871 +
93872 +static void deconstify_tree(tree node);
93873 +
93874 +static void deconstify_type(tree type)
93875 +{
93876 + tree field;
93877 +
93878 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
93879 +
93880 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
93881 + const_tree fieldtype = get_field_type(field);
93882 +
93883 + // special case handling of simple ptr-to-same-array-type members
93884 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
93885 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
93886 +
93887 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
93888 + continue;
93889 + if (TREE_TYPE(TREE_TYPE(field)) == type)
93890 + continue;
93891 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
93892 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
93893 + TREE_TYPE(TREE_TYPE(field)) = type;
93894 + }
93895 + continue;
93896 + }
93897 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
93898 + continue;
93899 + if (!constified(fieldtype))
93900 + continue;
93901 +
93902 + deconstify_tree(field);
93903 + TREE_READONLY(field) = 0;
93904 + }
93905 + TYPE_READONLY(type) = 0;
93906 + C_TYPE_FIELDS_READONLY(type) = 0;
93907 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93908 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
93909 +}
93910 +
93911 +static void deconstify_tree(tree node)
93912 +{
93913 + tree old_type, new_type, field;
93914 +
93915 + old_type = TREE_TYPE(node);
93916 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
93917 + node = TREE_TYPE(node) = copy_node(old_type);
93918 + old_type = TREE_TYPE(old_type);
93919 + }
93920 +
93921 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
93922 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
93923 +
93924 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
93925 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
93926 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
93927 + DECL_FIELD_CONTEXT(field) = new_type;
93928 +
93929 + deconstify_type(new_type);
93930 +
93931 + TREE_TYPE(node) = new_type;
93932 +}
93933 +
93934 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93935 +{
93936 + tree type;
93937 + constify_info cinfo = {
93938 + .has_fptr_field = false,
93939 + .has_writable_field = false,
93940 + .has_do_const_field = false,
93941 + .has_no_const_field = false
93942 + };
93943 +
93944 + *no_add_attrs = true;
93945 + if (TREE_CODE(*node) == FUNCTION_DECL) {
93946 + error("%qE attribute does not apply to functions", name);
93947 + return NULL_TREE;
93948 + }
93949 +
93950 + if (TREE_CODE(*node) == PARM_DECL) {
93951 + error("%qE attribute does not apply to function parameters", name);
93952 + return NULL_TREE;
93953 + }
93954 +
93955 + if (TREE_CODE(*node) == VAR_DECL) {
93956 + error("%qE attribute does not apply to variables", name);
93957 + return NULL_TREE;
93958 + }
93959 +
93960 + if (TYPE_P(*node)) {
93961 + *no_add_attrs = false;
93962 + type = *node;
93963 + } else {
93964 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
93965 + type = TREE_TYPE(*node);
93966 + }
93967 +
93968 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
93969 + error("%qE attribute applies to struct and union types only", name);
93970 + return NULL_TREE;
93971 + }
93972 +
93973 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
93974 + error("%qE attribute is already applied to the type", name);
93975 + return NULL_TREE;
93976 + }
93977 +
93978 + if (TYPE_P(*node)) {
93979 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93980 + error("%qE attribute is incompatible with 'do_const'", name);
93981 + return NULL_TREE;
93982 + }
93983 +
93984 + constifiable(type, &cinfo);
93985 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93986 + deconstify_tree(*node);
93987 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
93988 + return NULL_TREE;
93989 + }
93990 +
93991 + error("%qE attribute used on type that is not constified", name);
93992 + return NULL_TREE;
93993 +}
93994 +
93995 +static void constify_type(tree type)
93996 +{
93997 + TYPE_READONLY(type) = 1;
93998 + C_TYPE_FIELDS_READONLY(type) = 1;
93999 + TYPE_CONSTIFY_VISITED(type) = 1;
94000 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
94001 +}
94002 +
94003 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94004 +{
94005 + *no_add_attrs = true;
94006 + if (!TYPE_P(*node)) {
94007 + error("%qE attribute applies to types only", name);
94008 + return NULL_TREE;
94009 + }
94010 +
94011 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94012 + error("%qE attribute applies to struct and union types only", name);
94013 + return NULL_TREE;
94014 + }
94015 +
94016 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94017 + error("%qE attribute is already applied to the type", name);
94018 + return NULL_TREE;
94019 + }
94020 +
94021 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
94022 + error("%qE attribute is incompatible with 'no_const'", name);
94023 + return NULL_TREE;
94024 + }
94025 +
94026 + *no_add_attrs = false;
94027 + return NULL_TREE;
94028 +}
94029 +
94030 +static struct attribute_spec no_const_attr = {
94031 + .name = "no_const",
94032 + .min_length = 0,
94033 + .max_length = 0,
94034 + .decl_required = false,
94035 + .type_required = false,
94036 + .function_type_required = false,
94037 + .handler = handle_no_const_attribute,
94038 +#if BUILDING_GCC_VERSION >= 4007
94039 + .affects_type_identity = true
94040 +#endif
94041 +};
94042 +
94043 +static struct attribute_spec do_const_attr = {
94044 + .name = "do_const",
94045 + .min_length = 0,
94046 + .max_length = 0,
94047 + .decl_required = false,
94048 + .type_required = false,
94049 + .function_type_required = false,
94050 + .handler = handle_do_const_attribute,
94051 +#if BUILDING_GCC_VERSION >= 4007
94052 + .affects_type_identity = true
94053 +#endif
94054 +};
94055 +
94056 +static void register_attributes(void *event_data, void *data)
94057 +{
94058 + register_attribute(&no_const_attr);
94059 + register_attribute(&do_const_attr);
94060 +}
94061 +
94062 +static void finish_type(void *event_data, void *data)
94063 +{
94064 + tree type = (tree)event_data;
94065 + constify_info cinfo = {
94066 + .has_fptr_field = false,
94067 + .has_writable_field = false,
94068 + .has_do_const_field = false,
94069 + .has_no_const_field = false
94070 + };
94071 +
94072 + if (type == NULL_TREE || type == error_mark_node)
94073 + return;
94074 +
94075 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94076 + return;
94077 +
94078 + constifiable(type, &cinfo);
94079 +
94080 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94081 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94082 + return;
94083 + if (cinfo.has_writable_field)
94084 + return;
94085 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94086 + return;
94087 + }
94088 +
94089 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94090 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94091 + deconstify_type(type);
94092 + TYPE_CONSTIFY_VISITED(type) = 1;
94093 + } else
94094 + error("'no_const' attribute used on type that is not constified");
94095 + return;
94096 + }
94097 +
94098 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94099 + constify_type(type);
94100 + return;
94101 + }
94102 +
94103 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94104 + constify_type(type);
94105 + return;
94106 + }
94107 +
94108 + deconstify_type(type);
94109 + TYPE_CONSTIFY_VISITED(type) = 1;
94110 +}
94111 +
94112 +static unsigned int check_local_variables(void)
94113 +{
94114 + unsigned int ret = 0;
94115 + tree var;
94116 +
94117 +#if BUILDING_GCC_VERSION == 4005
94118 + tree vars;
94119 +#else
94120 + unsigned int i;
94121 +#endif
94122 +
94123 +#if BUILDING_GCC_VERSION == 4005
94124 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94125 + var = TREE_VALUE(vars);
94126 +#else
94127 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94128 +#endif
94129 + tree type = TREE_TYPE(var);
94130 +
94131 + gcc_assert(DECL_P(var));
94132 + if (is_global_var(var))
94133 + continue;
94134 +
94135 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94136 + continue;
94137 +
94138 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94139 + continue;
94140 +
94141 + if (!TYPE_CONSTIFY_VISITED(type))
94142 + continue;
94143 +
94144 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94145 + ret = 1;
94146 + }
94147 + return ret;
94148 +}
94149 +
94150 +static struct gimple_opt_pass pass_local_variable = {
94151 + {
94152 + .type = GIMPLE_PASS,
94153 + .name = "check_local_variables",
94154 +#if BUILDING_GCC_VERSION >= 4008
94155 + .optinfo_flags = OPTGROUP_NONE,
94156 +#endif
94157 + .gate = NULL,
94158 + .execute = check_local_variables,
94159 + .sub = NULL,
94160 + .next = NULL,
94161 + .static_pass_number = 0,
94162 + .tv_id = TV_NONE,
94163 + .properties_required = 0,
94164 + .properties_provided = 0,
94165 + .properties_destroyed = 0,
94166 + .todo_flags_start = 0,
94167 + .todo_flags_finish = 0
94168 + }
94169 +};
94170 +
94171 +static struct {
94172 + const char *name;
94173 + const char *asm_op;
94174 +} sections[] = {
94175 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94176 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94177 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94178 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94179 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94180 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94181 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94182 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94183 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94184 +};
94185 +
94186 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94187 +
94188 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94189 +{
94190 + size_t i;
94191 +
94192 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94193 + if (!strcmp(sections[i].name, name))
94194 + return 0;
94195 + return old_section_type_flags(decl, name, reloc);
94196 +}
94197 +
94198 +static void constify_start_unit(void *gcc_data, void *user_data)
94199 +{
94200 +// size_t i;
94201 +
94202 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94203 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94204 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94205 +
94206 + old_section_type_flags = targetm.section_type_flags;
94207 + targetm.section_type_flags = constify_section_type_flags;
94208 +}
94209 +
94210 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94211 +{
94212 + const char * const plugin_name = plugin_info->base_name;
94213 + const int argc = plugin_info->argc;
94214 + const struct plugin_argument * const argv = plugin_info->argv;
94215 + int i;
94216 + bool constify = true;
94217 +
94218 + struct register_pass_info local_variable_pass_info = {
94219 + .pass = &pass_local_variable.pass,
94220 + .reference_pass_name = "ssa",
94221 + .ref_pass_instance_number = 1,
94222 + .pos_op = PASS_POS_INSERT_BEFORE
94223 + };
94224 +
94225 + if (!plugin_default_version_check(version, &gcc_version)) {
94226 + error(G_("incompatible gcc/plugin versions"));
94227 + return 1;
94228 + }
94229 +
94230 + for (i = 0; i < argc; ++i) {
94231 + if (!(strcmp(argv[i].key, "no-constify"))) {
94232 + constify = false;
94233 + continue;
94234 + }
94235 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94236 + }
94237 +
94238 + if (strcmp(lang_hooks.name, "GNU C")) {
94239 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94240 + constify = false;
94241 + }
94242 +
94243 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94244 + if (constify) {
94245 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94246 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94247 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94248 + }
94249 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94250 +
94251 + return 0;
94252 +}
94253 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94254 new file mode 100644
94255 index 0000000..e518932
94256 --- /dev/null
94257 +++ b/tools/gcc/generate_size_overflow_hash.sh
94258 @@ -0,0 +1,94 @@
94259 +#!/bin/bash
94260 +
94261 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94262 +
94263 +header1="size_overflow_hash.h"
94264 +database="size_overflow_hash.data"
94265 +n=65536
94266 +
94267 +usage() {
94268 +cat <<EOF
94269 +usage: $0 options
94270 +OPTIONS:
94271 + -h|--help help
94272 + -o header file
94273 + -d database file
94274 + -n hash array size
94275 +EOF
94276 + return 0
94277 +}
94278 +
94279 +while true
94280 +do
94281 + case "$1" in
94282 + -h|--help) usage && exit 0;;
94283 + -n) n=$2; shift 2;;
94284 + -o) header1="$2"; shift 2;;
94285 + -d) database="$2"; shift 2;;
94286 + --) shift 1; break ;;
94287 + *) break ;;
94288 + esac
94289 +done
94290 +
94291 +create_defines() {
94292 + for i in `seq 0 31`
94293 + do
94294 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94295 + done
94296 + echo >> "$header1"
94297 +}
94298 +
94299 +create_structs() {
94300 + rm -f "$header1"
94301 +
94302 + create_defines
94303 +
94304 + cat "$database" | while read data
94305 + do
94306 + data_array=($data)
94307 + struct_hash_name="${data_array[0]}"
94308 + funcn="${data_array[1]}"
94309 + params="${data_array[2]}"
94310 + next="${data_array[4]}"
94311 +
94312 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94313 +
94314 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94315 + echo -en "\t.param\t= " >> "$header1"
94316 + line=
94317 + for param_num in ${params//-/ };
94318 + do
94319 + line="${line}PARAM"$param_num"|"
94320 + done
94321 +
94322 + echo -e "${line%?},\n};\n" >> "$header1"
94323 + done
94324 +}
94325 +
94326 +create_headers() {
94327 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94328 +}
94329 +
94330 +create_array_elements() {
94331 + index=0
94332 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94333 + do
94334 + data_array=($data)
94335 + i="${data_array[3]}"
94336 + hash="${data_array[0]}"
94337 + while [[ $index -lt $i ]]
94338 + do
94339 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94340 + index=$(($index + 1))
94341 + done
94342 + index=$(($index + 1))
94343 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94344 + done
94345 + echo '};' >> $header1
94346 +}
94347 +
94348 +create_structs
94349 +create_headers
94350 +create_array_elements
94351 +
94352 +exit 0
94353 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
94354 new file mode 100644
94355 index 0000000..568b360
94356 --- /dev/null
94357 +++ b/tools/gcc/kallocstat_plugin.c
94358 @@ -0,0 +1,170 @@
94359 +/*
94360 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94361 + * Licensed under the GPL v2
94362 + *
94363 + * Note: the choice of the license means that the compilation process is
94364 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94365 + * but for the kernel it doesn't matter since it doesn't link against
94366 + * any of the gcc libraries
94367 + *
94368 + * gcc plugin to find the distribution of k*alloc sizes
94369 + *
94370 + * TODO:
94371 + *
94372 + * BUGS:
94373 + * - none known
94374 + */
94375 +#include "gcc-plugin.h"
94376 +#include "config.h"
94377 +#include "system.h"
94378 +#include "coretypes.h"
94379 +#include "tree.h"
94380 +#include "tree-pass.h"
94381 +#include "flags.h"
94382 +#include "intl.h"
94383 +#include "toplev.h"
94384 +#include "plugin.h"
94385 +//#include "expr.h" where are you...
94386 +#include "diagnostic.h"
94387 +#include "plugin-version.h"
94388 +#include "tm.h"
94389 +#include "function.h"
94390 +#include "basic-block.h"
94391 +#include "gimple.h"
94392 +#include "rtl.h"
94393 +#include "emit-rtl.h"
94394 +
94395 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94396 +
94397 +int plugin_is_GPL_compatible;
94398 +
94399 +static const char * const kalloc_functions[] = {
94400 + "__kmalloc",
94401 + "kmalloc",
94402 + "kmalloc_large",
94403 + "kmalloc_node",
94404 + "kmalloc_order",
94405 + "kmalloc_order_trace",
94406 + "kmalloc_slab",
94407 + "kzalloc",
94408 + "kzalloc_node",
94409 +};
94410 +
94411 +static struct plugin_info kallocstat_plugin_info = {
94412 + .version = "201302112000",
94413 +};
94414 +
94415 +static unsigned int execute_kallocstat(void);
94416 +
94417 +static struct gimple_opt_pass kallocstat_pass = {
94418 + .pass = {
94419 + .type = GIMPLE_PASS,
94420 + .name = "kallocstat",
94421 +#if BUILDING_GCC_VERSION >= 4008
94422 + .optinfo_flags = OPTGROUP_NONE,
94423 +#endif
94424 + .gate = NULL,
94425 + .execute = execute_kallocstat,
94426 + .sub = NULL,
94427 + .next = NULL,
94428 + .static_pass_number = 0,
94429 + .tv_id = TV_NONE,
94430 + .properties_required = 0,
94431 + .properties_provided = 0,
94432 + .properties_destroyed = 0,
94433 + .todo_flags_start = 0,
94434 + .todo_flags_finish = 0
94435 + }
94436 +};
94437 +
94438 +static bool is_kalloc(const char *fnname)
94439 +{
94440 + size_t i;
94441 +
94442 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94443 + if (!strcmp(fnname, kalloc_functions[i]))
94444 + return true;
94445 + return false;
94446 +}
94447 +
94448 +static unsigned int execute_kallocstat(void)
94449 +{
94450 + basic_block bb;
94451 +
94452 + // 1. loop through BBs and GIMPLE statements
94453 + FOR_EACH_BB(bb) {
94454 + gimple_stmt_iterator gsi;
94455 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94456 + // gimple match:
94457 + tree fndecl, size;
94458 + gimple call_stmt;
94459 + const char *fnname;
94460 +
94461 + // is it a call
94462 + call_stmt = gsi_stmt(gsi);
94463 + if (!is_gimple_call(call_stmt))
94464 + continue;
94465 + fndecl = gimple_call_fndecl(call_stmt);
94466 + if (fndecl == NULL_TREE)
94467 + continue;
94468 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94469 + continue;
94470 +
94471 + // is it a call to k*alloc
94472 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94473 + if (!is_kalloc(fnname))
94474 + continue;
94475 +
94476 + // is the size arg the result of a simple const assignment
94477 + size = gimple_call_arg(call_stmt, 0);
94478 + while (true) {
94479 + gimple def_stmt;
94480 + expanded_location xloc;
94481 + size_t size_val;
94482 +
94483 + if (TREE_CODE(size) != SSA_NAME)
94484 + break;
94485 + def_stmt = SSA_NAME_DEF_STMT(size);
94486 + if (!def_stmt || !is_gimple_assign(def_stmt))
94487 + break;
94488 + if (gimple_num_ops(def_stmt) != 2)
94489 + break;
94490 + size = gimple_assign_rhs1(def_stmt);
94491 + if (!TREE_CONSTANT(size))
94492 + continue;
94493 + xloc = expand_location(gimple_location(def_stmt));
94494 + if (!xloc.file)
94495 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94496 + size_val = TREE_INT_CST_LOW(size);
94497 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94498 + break;
94499 + }
94500 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94501 +//debug_tree(gimple_call_fn(call_stmt));
94502 +//print_node(stderr, "pax", fndecl, 4);
94503 + }
94504 + }
94505 +
94506 + return 0;
94507 +}
94508 +
94509 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94510 +{
94511 + const char * const plugin_name = plugin_info->base_name;
94512 + struct register_pass_info kallocstat_pass_info = {
94513 + .pass = &kallocstat_pass.pass,
94514 + .reference_pass_name = "ssa",
94515 + .ref_pass_instance_number = 1,
94516 + .pos_op = PASS_POS_INSERT_AFTER
94517 + };
94518 +
94519 + if (!plugin_default_version_check(version, &gcc_version)) {
94520 + error(G_("incompatible gcc/plugin versions"));
94521 + return 1;
94522 + }
94523 +
94524 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94525 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94526 +
94527 + return 0;
94528 +}
94529 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94530 new file mode 100644
94531 index 0000000..0408e06
94532 --- /dev/null
94533 +++ b/tools/gcc/kernexec_plugin.c
94534 @@ -0,0 +1,465 @@
94535 +/*
94536 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94537 + * Licensed under the GPL v2
94538 + *
94539 + * Note: the choice of the license means that the compilation process is
94540 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94541 + * but for the kernel it doesn't matter since it doesn't link against
94542 + * any of the gcc libraries
94543 + *
94544 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94545 + *
94546 + * TODO:
94547 + *
94548 + * BUGS:
94549 + * - none known
94550 + */
94551 +#include "gcc-plugin.h"
94552 +#include "config.h"
94553 +#include "system.h"
94554 +#include "coretypes.h"
94555 +#include "tree.h"
94556 +#include "tree-pass.h"
94557 +#include "flags.h"
94558 +#include "intl.h"
94559 +#include "toplev.h"
94560 +#include "plugin.h"
94561 +//#include "expr.h" where are you...
94562 +#include "diagnostic.h"
94563 +#include "plugin-version.h"
94564 +#include "tm.h"
94565 +#include "function.h"
94566 +#include "basic-block.h"
94567 +#include "gimple.h"
94568 +#include "rtl.h"
94569 +#include "emit-rtl.h"
94570 +#include "tree-flow.h"
94571 +
94572 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94573 +extern rtx emit_move_insn(rtx x, rtx y);
94574 +
94575 +#if BUILDING_GCC_VERSION <= 4006
94576 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94577 +#endif
94578 +
94579 +#if BUILDING_GCC_VERSION >= 4008
94580 +#define TODO_dump_func 0
94581 +#endif
94582 +
94583 +int plugin_is_GPL_compatible;
94584 +
94585 +static struct plugin_info kernexec_plugin_info = {
94586 + .version = "201302112000",
94587 + .help = "method=[bts|or]\tinstrumentation method\n"
94588 +};
94589 +
94590 +static unsigned int execute_kernexec_reload(void);
94591 +static unsigned int execute_kernexec_fptr(void);
94592 +static unsigned int execute_kernexec_retaddr(void);
94593 +static bool kernexec_cmodel_check(void);
94594 +
94595 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94596 +static void (*kernexec_instrument_retaddr)(rtx);
94597 +
94598 +static struct gimple_opt_pass kernexec_reload_pass = {
94599 + .pass = {
94600 + .type = GIMPLE_PASS,
94601 + .name = "kernexec_reload",
94602 +#if BUILDING_GCC_VERSION >= 4008
94603 + .optinfo_flags = OPTGROUP_NONE,
94604 +#endif
94605 + .gate = kernexec_cmodel_check,
94606 + .execute = execute_kernexec_reload,
94607 + .sub = NULL,
94608 + .next = NULL,
94609 + .static_pass_number = 0,
94610 + .tv_id = TV_NONE,
94611 + .properties_required = 0,
94612 + .properties_provided = 0,
94613 + .properties_destroyed = 0,
94614 + .todo_flags_start = 0,
94615 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94616 + }
94617 +};
94618 +
94619 +static struct gimple_opt_pass kernexec_fptr_pass = {
94620 + .pass = {
94621 + .type = GIMPLE_PASS,
94622 + .name = "kernexec_fptr",
94623 +#if BUILDING_GCC_VERSION >= 4008
94624 + .optinfo_flags = OPTGROUP_NONE,
94625 +#endif
94626 + .gate = kernexec_cmodel_check,
94627 + .execute = execute_kernexec_fptr,
94628 + .sub = NULL,
94629 + .next = NULL,
94630 + .static_pass_number = 0,
94631 + .tv_id = TV_NONE,
94632 + .properties_required = 0,
94633 + .properties_provided = 0,
94634 + .properties_destroyed = 0,
94635 + .todo_flags_start = 0,
94636 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94637 + }
94638 +};
94639 +
94640 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94641 + .pass = {
94642 + .type = RTL_PASS,
94643 + .name = "kernexec_retaddr",
94644 +#if BUILDING_GCC_VERSION >= 4008
94645 + .optinfo_flags = OPTGROUP_NONE,
94646 +#endif
94647 + .gate = kernexec_cmodel_check,
94648 + .execute = execute_kernexec_retaddr,
94649 + .sub = NULL,
94650 + .next = NULL,
94651 + .static_pass_number = 0,
94652 + .tv_id = TV_NONE,
94653 + .properties_required = 0,
94654 + .properties_provided = 0,
94655 + .properties_destroyed = 0,
94656 + .todo_flags_start = 0,
94657 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94658 + }
94659 +};
94660 +
94661 +static bool kernexec_cmodel_check(void)
94662 +{
94663 + tree section;
94664 +
94665 + if (ix86_cmodel != CM_KERNEL)
94666 + return false;
94667 +
94668 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94669 + if (!section || !TREE_VALUE(section))
94670 + return true;
94671 +
94672 + section = TREE_VALUE(TREE_VALUE(section));
94673 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94674 + return true;
94675 +
94676 + return false;
94677 +}
94678 +
94679 +/*
94680 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94681 + */
94682 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94683 +{
94684 + gimple asm_movabs_stmt;
94685 +
94686 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94687 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94688 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94689 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94690 + update_stmt(asm_movabs_stmt);
94691 +}
94692 +
94693 +/*
94694 + * find all asm() stmts that clobber r10 and add a reload of r10
94695 + */
94696 +static unsigned int execute_kernexec_reload(void)
94697 +{
94698 + basic_block bb;
94699 +
94700 + // 1. loop through BBs and GIMPLE statements
94701 + FOR_EACH_BB(bb) {
94702 + gimple_stmt_iterator gsi;
94703 +
94704 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94705 + // gimple match: __asm__ ("" : : : "r10");
94706 + gimple asm_stmt;
94707 + size_t nclobbers;
94708 +
94709 + // is it an asm ...
94710 + asm_stmt = gsi_stmt(gsi);
94711 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94712 + continue;
94713 +
94714 + // ... clobbering r10
94715 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94716 + while (nclobbers--) {
94717 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94718 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94719 + continue;
94720 + kernexec_reload_fptr_mask(&gsi);
94721 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94722 + break;
94723 + }
94724 + }
94725 + }
94726 +
94727 + return 0;
94728 +}
94729 +
94730 +/*
94731 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94732 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94733 + */
94734 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94735 +{
94736 + gimple assign_intptr, assign_new_fptr, call_stmt;
94737 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94738 +
94739 + call_stmt = gsi_stmt(*gsi);
94740 + old_fptr = gimple_call_fn(call_stmt);
94741 +
94742 + // create temporary unsigned long variable used for bitops and cast fptr to it
94743 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94744 +#if BUILDING_GCC_VERSION <= 4007
94745 + add_referenced_var(intptr);
94746 + mark_sym_for_renaming(intptr);
94747 +#endif
94748 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94749 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94750 + update_stmt(assign_intptr);
94751 +
94752 + // apply logical or to temporary unsigned long and bitmask
94753 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94754 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94755 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94756 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94757 + update_stmt(assign_intptr);
94758 +
94759 + // cast temporary unsigned long back to a temporary fptr variable
94760 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94761 +#if BUILDING_GCC_VERSION <= 4007
94762 + add_referenced_var(new_fptr);
94763 + mark_sym_for_renaming(new_fptr);
94764 +#endif
94765 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94766 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94767 + update_stmt(assign_new_fptr);
94768 +
94769 + // replace call stmt fn with the new fptr
94770 + gimple_call_set_fn(call_stmt, new_fptr);
94771 + update_stmt(call_stmt);
94772 +}
94773 +
94774 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94775 +{
94776 + gimple asm_or_stmt, call_stmt;
94777 + tree old_fptr, new_fptr, input, output;
94778 +#if BUILDING_GCC_VERSION <= 4007
94779 + VEC(tree, gc) *inputs = NULL;
94780 + VEC(tree, gc) *outputs = NULL;
94781 +#else
94782 + vec<tree, va_gc> *inputs = NULL;
94783 + vec<tree, va_gc> *outputs = NULL;
94784 +#endif
94785 +
94786 + call_stmt = gsi_stmt(*gsi);
94787 + old_fptr = gimple_call_fn(call_stmt);
94788 +
94789 + // create temporary fptr variable
94790 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94791 +#if BUILDING_GCC_VERSION <= 4007
94792 + add_referenced_var(new_fptr);
94793 + mark_sym_for_renaming(new_fptr);
94794 +#endif
94795 +
94796 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94797 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94798 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94799 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94800 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94801 +#if BUILDING_GCC_VERSION <= 4007
94802 + VEC_safe_push(tree, gc, inputs, input);
94803 + VEC_safe_push(tree, gc, outputs, output);
94804 +#else
94805 + vec_safe_push(inputs, input);
94806 + vec_safe_push(outputs, output);
94807 +#endif
94808 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94809 + gimple_asm_set_volatile(asm_or_stmt, true);
94810 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94811 + update_stmt(asm_or_stmt);
94812 +
94813 + // replace call stmt fn with the new fptr
94814 + gimple_call_set_fn(call_stmt, new_fptr);
94815 + update_stmt(call_stmt);
94816 +}
94817 +
94818 +/*
94819 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94820 + */
94821 +static unsigned int execute_kernexec_fptr(void)
94822 +{
94823 + basic_block bb;
94824 +
94825 + // 1. loop through BBs and GIMPLE statements
94826 + FOR_EACH_BB(bb) {
94827 + gimple_stmt_iterator gsi;
94828 +
94829 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94830 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94831 + tree fn;
94832 + gimple call_stmt;
94833 +
94834 + // is it a call ...
94835 + call_stmt = gsi_stmt(gsi);
94836 + if (!is_gimple_call(call_stmt))
94837 + continue;
94838 + fn = gimple_call_fn(call_stmt);
94839 + if (TREE_CODE(fn) == ADDR_EXPR)
94840 + continue;
94841 + if (TREE_CODE(fn) != SSA_NAME)
94842 + gcc_unreachable();
94843 +
94844 + // ... through a function pointer
94845 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94846 + fn = SSA_NAME_VAR(fn);
94847 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94848 + debug_tree(fn);
94849 + gcc_unreachable();
94850 + }
94851 + }
94852 + fn = TREE_TYPE(fn);
94853 + if (TREE_CODE(fn) != POINTER_TYPE)
94854 + continue;
94855 + fn = TREE_TYPE(fn);
94856 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94857 + continue;
94858 +
94859 + kernexec_instrument_fptr(&gsi);
94860 +
94861 +//debug_tree(gimple_call_fn(call_stmt));
94862 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94863 + }
94864 + }
94865 +
94866 + return 0;
94867 +}
94868 +
94869 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94870 +static void kernexec_instrument_retaddr_bts(rtx insn)
94871 +{
94872 + rtx btsq;
94873 + rtvec argvec, constraintvec, labelvec;
94874 + int line;
94875 +
94876 + // create asm volatile("btsq $63,(%%rsp)":::)
94877 + argvec = rtvec_alloc(0);
94878 + constraintvec = rtvec_alloc(0);
94879 + labelvec = rtvec_alloc(0);
94880 + line = expand_location(RTL_LOCATION(insn)).line;
94881 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94882 + MEM_VOLATILE_P(btsq) = 1;
94883 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
94884 + emit_insn_before(btsq, insn);
94885 +}
94886 +
94887 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
94888 +static void kernexec_instrument_retaddr_or(rtx insn)
94889 +{
94890 + rtx orq;
94891 + rtvec argvec, constraintvec, labelvec;
94892 + int line;
94893 +
94894 + // create asm volatile("orq %%r10,(%%rsp)":::)
94895 + argvec = rtvec_alloc(0);
94896 + constraintvec = rtvec_alloc(0);
94897 + labelvec = rtvec_alloc(0);
94898 + line = expand_location(RTL_LOCATION(insn)).line;
94899 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94900 + MEM_VOLATILE_P(orq) = 1;
94901 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
94902 + emit_insn_before(orq, insn);
94903 +}
94904 +
94905 +/*
94906 + * find all asm level function returns and forcibly set the highest bit of the return address
94907 + */
94908 +static unsigned int execute_kernexec_retaddr(void)
94909 +{
94910 + rtx insn;
94911 +
94912 + // 1. find function returns
94913 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
94914 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
94915 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
94916 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
94917 + rtx body;
94918 +
94919 + // is it a retn
94920 + if (!JUMP_P(insn))
94921 + continue;
94922 + body = PATTERN(insn);
94923 + if (GET_CODE(body) == PARALLEL)
94924 + body = XVECEXP(body, 0, 0);
94925 + if (!ANY_RETURN_P(body))
94926 + continue;
94927 + kernexec_instrument_retaddr(insn);
94928 + }
94929 +
94930 +// print_simple_rtl(stderr, get_insns());
94931 +// print_rtl(stderr, get_insns());
94932 +
94933 + return 0;
94934 +}
94935 +
94936 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94937 +{
94938 + const char * const plugin_name = plugin_info->base_name;
94939 + const int argc = plugin_info->argc;
94940 + const struct plugin_argument * const argv = plugin_info->argv;
94941 + int i;
94942 + struct register_pass_info kernexec_reload_pass_info = {
94943 + .pass = &kernexec_reload_pass.pass,
94944 + .reference_pass_name = "ssa",
94945 + .ref_pass_instance_number = 1,
94946 + .pos_op = PASS_POS_INSERT_AFTER
94947 + };
94948 + struct register_pass_info kernexec_fptr_pass_info = {
94949 + .pass = &kernexec_fptr_pass.pass,
94950 + .reference_pass_name = "ssa",
94951 + .ref_pass_instance_number = 1,
94952 + .pos_op = PASS_POS_INSERT_AFTER
94953 + };
94954 + struct register_pass_info kernexec_retaddr_pass_info = {
94955 + .pass = &kernexec_retaddr_pass.pass,
94956 + .reference_pass_name = "pro_and_epilogue",
94957 + .ref_pass_instance_number = 1,
94958 + .pos_op = PASS_POS_INSERT_AFTER
94959 + };
94960 +
94961 + if (!plugin_default_version_check(version, &gcc_version)) {
94962 + error(G_("incompatible gcc/plugin versions"));
94963 + return 1;
94964 + }
94965 +
94966 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
94967 +
94968 + if (TARGET_64BIT == 0)
94969 + return 0;
94970 +
94971 + for (i = 0; i < argc; ++i) {
94972 + if (!strcmp(argv[i].key, "method")) {
94973 + if (!argv[i].value) {
94974 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94975 + continue;
94976 + }
94977 + if (!strcmp(argv[i].value, "bts")) {
94978 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
94979 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
94980 + } else if (!strcmp(argv[i].value, "or")) {
94981 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
94982 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
94983 + fix_register("r10", 1, 1);
94984 + } else
94985 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
94986 + continue;
94987 + }
94988 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94989 + }
94990 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
94991 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
94992 +
94993 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
94994 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
94995 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
94996 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
94997 +
94998 + return 0;
94999 +}
95000 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
95001 new file mode 100644
95002 index 0000000..b5395ba
95003 --- /dev/null
95004 +++ b/tools/gcc/latent_entropy_plugin.c
95005 @@ -0,0 +1,327 @@
95006 +/*
95007 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
95008 + * Licensed under the GPL v2
95009 + *
95010 + * Note: the choice of the license means that the compilation process is
95011 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95012 + * but for the kernel it doesn't matter since it doesn't link against
95013 + * any of the gcc libraries
95014 + *
95015 + * gcc plugin to help generate a little bit of entropy from program state,
95016 + * used during boot in the kernel
95017 + *
95018 + * TODO:
95019 + * - add ipa pass to identify not explicitly marked candidate functions
95020 + * - mix in more program state (function arguments/return values, loop variables, etc)
95021 + * - more instrumentation control via attribute parameters
95022 + *
95023 + * BUGS:
95024 + * - LTO needs -flto-partition=none for now
95025 + */
95026 +#include "gcc-plugin.h"
95027 +#include "config.h"
95028 +#include "system.h"
95029 +#include "coretypes.h"
95030 +#include "tree.h"
95031 +#include "tree-pass.h"
95032 +#include "flags.h"
95033 +#include "intl.h"
95034 +#include "toplev.h"
95035 +#include "plugin.h"
95036 +//#include "expr.h" where are you...
95037 +#include "diagnostic.h"
95038 +#include "plugin-version.h"
95039 +#include "tm.h"
95040 +#include "function.h"
95041 +#include "basic-block.h"
95042 +#include "gimple.h"
95043 +#include "rtl.h"
95044 +#include "emit-rtl.h"
95045 +#include "tree-flow.h"
95046 +#include "langhooks.h"
95047 +
95048 +#if BUILDING_GCC_VERSION >= 4008
95049 +#define TODO_dump_func 0
95050 +#endif
95051 +
95052 +int plugin_is_GPL_compatible;
95053 +
95054 +static tree latent_entropy_decl;
95055 +
95056 +static struct plugin_info latent_entropy_plugin_info = {
95057 + .version = "201303102320",
95058 + .help = NULL
95059 +};
95060 +
95061 +static unsigned int execute_latent_entropy(void);
95062 +static bool gate_latent_entropy(void);
95063 +
95064 +static struct gimple_opt_pass latent_entropy_pass = {
95065 + .pass = {
95066 + .type = GIMPLE_PASS,
95067 + .name = "latent_entropy",
95068 +#if BUILDING_GCC_VERSION >= 4008
95069 + .optinfo_flags = OPTGROUP_NONE,
95070 +#endif
95071 + .gate = gate_latent_entropy,
95072 + .execute = execute_latent_entropy,
95073 + .sub = NULL,
95074 + .next = NULL,
95075 + .static_pass_number = 0,
95076 + .tv_id = TV_NONE,
95077 + .properties_required = PROP_gimple_leh | PROP_cfg,
95078 + .properties_provided = 0,
95079 + .properties_destroyed = 0,
95080 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95081 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95082 + }
95083 +};
95084 +
95085 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95086 +{
95087 + if (TREE_CODE(*node) != FUNCTION_DECL) {
95088 + *no_add_attrs = true;
95089 + error("%qE attribute only applies to functions", name);
95090 + }
95091 + return NULL_TREE;
95092 +}
95093 +
95094 +static struct attribute_spec latent_entropy_attr = {
95095 + .name = "latent_entropy",
95096 + .min_length = 0,
95097 + .max_length = 0,
95098 + .decl_required = true,
95099 + .type_required = false,
95100 + .function_type_required = false,
95101 + .handler = handle_latent_entropy_attribute,
95102 +#if BUILDING_GCC_VERSION >= 4007
95103 + .affects_type_identity = false
95104 +#endif
95105 +};
95106 +
95107 +static void register_attributes(void *event_data, void *data)
95108 +{
95109 + register_attribute(&latent_entropy_attr);
95110 +}
95111 +
95112 +static bool gate_latent_entropy(void)
95113 +{
95114 + tree latent_entropy_attr;
95115 +
95116 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95117 + return latent_entropy_attr != NULL_TREE;
95118 +}
95119 +
95120 +static unsigned HOST_WIDE_INT seed;
95121 +static unsigned HOST_WIDE_INT get_random_const(void)
95122 +{
95123 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95124 + return seed;
95125 +}
95126 +
95127 +static enum tree_code get_op(tree *rhs)
95128 +{
95129 + static enum tree_code op;
95130 + unsigned HOST_WIDE_INT random_const;
95131 +
95132 + random_const = get_random_const();
95133 +
95134 + switch (op) {
95135 + case BIT_XOR_EXPR:
95136 + op = PLUS_EXPR;
95137 + break;
95138 +
95139 + case PLUS_EXPR:
95140 + if (rhs) {
95141 + op = LROTATE_EXPR;
95142 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95143 + break;
95144 + }
95145 +
95146 + case LROTATE_EXPR:
95147 + default:
95148 + op = BIT_XOR_EXPR;
95149 + break;
95150 + }
95151 + if (rhs)
95152 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95153 + return op;
95154 +}
95155 +
95156 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95157 +{
95158 + gimple_stmt_iterator gsi;
95159 + gimple assign;
95160 + tree addxorrol, rhs;
95161 + enum tree_code op;
95162 +
95163 + op = get_op(&rhs);
95164 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95165 + assign = gimple_build_assign(local_entropy, addxorrol);
95166 +#if BUILDING_GCC_VERSION <= 4007
95167 + find_referenced_vars_in(assign);
95168 +#endif
95169 +//debug_bb(bb);
95170 + gsi = gsi_after_labels(bb);
95171 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95172 + update_stmt(assign);
95173 +}
95174 +
95175 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95176 +{
95177 + gimple_stmt_iterator gsi;
95178 + gimple assign;
95179 + tree addxorrol, temp;
95180 +
95181 + // 1. create temporary copy of latent_entropy
95182 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95183 +#if BUILDING_GCC_VERSION <= 4007
95184 + add_referenced_var(temp);
95185 + mark_sym_for_renaming(temp);
95186 +#endif
95187 +
95188 + // 2. read...
95189 + assign = gimple_build_assign(temp, latent_entropy_decl);
95190 +#if BUILDING_GCC_VERSION <= 4007
95191 + find_referenced_vars_in(assign);
95192 +#endif
95193 + gsi = gsi_after_labels(bb);
95194 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95195 + update_stmt(assign);
95196 +
95197 + // 3. ...modify...
95198 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95199 + assign = gimple_build_assign(temp, addxorrol);
95200 +#if BUILDING_GCC_VERSION <= 4007
95201 + find_referenced_vars_in(assign);
95202 +#endif
95203 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95204 + update_stmt(assign);
95205 +
95206 + // 4. ...write latent_entropy
95207 + assign = gimple_build_assign(latent_entropy_decl, temp);
95208 +#if BUILDING_GCC_VERSION <= 4007
95209 + find_referenced_vars_in(assign);
95210 +#endif
95211 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95212 + update_stmt(assign);
95213 +}
95214 +
95215 +static unsigned int execute_latent_entropy(void)
95216 +{
95217 + basic_block bb;
95218 + gimple assign;
95219 + gimple_stmt_iterator gsi;
95220 + tree local_entropy;
95221 +
95222 + if (!latent_entropy_decl) {
95223 + struct varpool_node *node;
95224 +
95225 +#if BUILDING_GCC_VERSION <= 4007
95226 + for (node = varpool_nodes; node; node = node->next) {
95227 + tree var = node->decl;
95228 +#else
95229 + FOR_EACH_VARIABLE(node) {
95230 + tree var = node->symbol.decl;
95231 +#endif
95232 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95233 + continue;
95234 + latent_entropy_decl = var;
95235 +// debug_tree(var);
95236 + break;
95237 + }
95238 + if (!latent_entropy_decl) {
95239 +// debug_tree(current_function_decl);
95240 + return 0;
95241 + }
95242 + }
95243 +
95244 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95245 +
95246 + // 1. create local entropy variable
95247 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95248 +#if BUILDING_GCC_VERSION <= 4007
95249 + add_referenced_var(local_entropy);
95250 + mark_sym_for_renaming(local_entropy);
95251 +#endif
95252 +
95253 + // 2. initialize local entropy variable
95254 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95255 + if (dom_info_available_p(CDI_DOMINATORS))
95256 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95257 + gsi = gsi_start_bb(bb);
95258 +
95259 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95260 +// gimple_set_location(assign, loc);
95261 +#if BUILDING_GCC_VERSION <= 4007
95262 + find_referenced_vars_in(assign);
95263 +#endif
95264 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95265 + update_stmt(assign);
95266 + bb = bb->next_bb;
95267 +
95268 + // 3. instrument each BB with an operation on the local entropy variable
95269 + while (bb != EXIT_BLOCK_PTR) {
95270 + perturb_local_entropy(bb, local_entropy);
95271 + bb = bb->next_bb;
95272 + };
95273 +
95274 + // 4. mix local entropy into the global entropy variable
95275 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95276 + return 0;
95277 +}
95278 +
95279 +static void start_unit_callback(void *gcc_data, void *user_data)
95280 +{
95281 + tree latent_entropy_type;
95282 +
95283 +#if BUILDING_GCC_VERSION >= 4007
95284 + seed = get_random_seed(false);
95285 +#else
95286 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95287 + seed *= seed;
95288 +#endif
95289 +
95290 + if (in_lto_p)
95291 + return;
95292 +
95293 + // extern volatile u64 latent_entropy
95294 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95295 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95296 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95297 +
95298 + TREE_STATIC(latent_entropy_decl) = 1;
95299 + TREE_PUBLIC(latent_entropy_decl) = 1;
95300 + TREE_USED(latent_entropy_decl) = 1;
95301 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95302 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95303 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95304 + DECL_INITIAL(latent_entropy_decl) = NULL;
95305 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95306 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95307 +// varpool_finalize_decl(latent_entropy_decl);
95308 +// varpool_mark_needed_node(latent_entropy_decl);
95309 +}
95310 +
95311 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95312 +{
95313 + const char * const plugin_name = plugin_info->base_name;
95314 + struct register_pass_info latent_entropy_pass_info = {
95315 + .pass = &latent_entropy_pass.pass,
95316 + .reference_pass_name = "optimized",
95317 + .ref_pass_instance_number = 1,
95318 + .pos_op = PASS_POS_INSERT_BEFORE
95319 + };
95320 +
95321 + if (!plugin_default_version_check(version, &gcc_version)) {
95322 + error(G_("incompatible gcc/plugin versions"));
95323 + return 1;
95324 + }
95325 +
95326 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95327 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95328 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95329 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95330 +
95331 + return 0;
95332 +}
95333 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95334 new file mode 100644
95335 index 0000000..ddd5b2e
95336 --- /dev/null
95337 +++ b/tools/gcc/size_overflow_hash.data
95338 @@ -0,0 +1,5876 @@
95339 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95340 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95341 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95342 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95343 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95344 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95345 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95346 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95347 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95348 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
95349 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
95350 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
95351 +load_msg_95 load_msg 2 95 NULL
95352 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
95353 +init_q_132 init_q 4 132 NULL
95354 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
95355 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
95356 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95357 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95358 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95359 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95360 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95361 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95362 +br_port_info_size_268 br_port_info_size 0 268 NULL
95363 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95364 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95365 +syslog_print_307 syslog_print 2 307 NULL
95366 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95367 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95368 +next_node_allowed_318 next_node_allowed 1 318 NULL
95369 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95370 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95371 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95372 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95373 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95374 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95375 +pidlist_resize_496 pidlist_resize 2 496 NULL
95376 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95377 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95378 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95379 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
95380 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95381 +dle_count_543 dle_count 0 543 NULL
95382 +devres_alloc_551 devres_alloc 2 551 NULL
95383 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95384 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95385 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95386 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95387 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95388 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95389 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95390 +isp1760_register_628 isp1760_register 1-2 628 NULL
95391 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95392 +unlink_queued_645 unlink_queued 3-4 645 NULL
95393 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95394 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
95395 +div_u64_rem_672 div_u64_rem 0 672 NULL
95396 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95397 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95398 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95399 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95400 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95401 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
95402 +dvb_video_write_754 dvb_video_write 3 754 NULL
95403 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
95404 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
95405 +if_writecmd_815 if_writecmd 2 815 NULL
95406 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95407 +read_fifo_826 read_fifo 3 826 NULL
95408 +read_tree_block_841 read_tree_block 3 841 NULL
95409 +um_idi_read_850 um_idi_read 3 850 NULL
95410 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95411 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95412 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95413 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95414 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95415 +readw_931 readw 0 931 NULL
95416 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95417 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
95418 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
95419 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95420 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
95421 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95422 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
95423 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95424 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95425 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95426 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95427 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95428 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95429 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95430 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95431 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
95432 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95433 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95434 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95435 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95436 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95437 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95438 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95439 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95440 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95441 +thin_status_1239 thin_status 5 1239 NULL
95442 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95443 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95444 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95445 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95446 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95447 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95448 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95449 +ffs_1322 ffs 0 1322 NULL
95450 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95451 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95452 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95453 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95454 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95455 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95456 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95457 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95458 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95459 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95460 +zone_page_state_1393 zone_page_state 0 1393 NULL
95461 +file_read_actor_1401 file_read_actor 4 1401 NULL
95462 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
95463 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95464 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95465 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95466 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95467 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95468 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95469 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95470 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95471 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95472 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95473 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95474 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95475 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95476 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95477 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95478 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95479 +rmap_add_1677 rmap_add 3 1677 NULL
95480 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95481 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95482 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95483 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95484 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95485 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95486 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95487 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95488 +cosa_write_1774 cosa_write 3 1774 NULL
95489 +update_macheader_1775 update_macheader 7 1775 NULL
95490 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95491 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95492 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95493 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95494 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95495 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95496 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95497 +read_swap_header_1957 read_swap_header 0 1957 NULL
95498 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95499 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95500 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
95501 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95502 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95503 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95504 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95505 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95506 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95507 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95508 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95509 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95510 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95511 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95512 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95513 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
95514 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95515 +audit_expand_2098 audit_expand 2 2098 NULL
95516 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95517 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95518 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95519 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95520 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95521 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
95522 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95523 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
95524 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
95525 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95526 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95527 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95528 +u32_array_read_2219 u32_array_read 3 2219 NULL
95529 +vhci_write_2224 vhci_write 3 2224 NULL
95530 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95531 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95532 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95533 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95534 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95535 +do_update_counters_2259 do_update_counters 4 2259 NULL
95536 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95537 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95538 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
95539 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95540 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95541 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95542 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95543 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95544 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95545 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95546 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95547 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95548 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95549 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95550 +raid1_size_2419 raid1_size 0-2 2419 NULL
95551 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95552 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95553 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95554 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95555 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
95556 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
95557 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95558 +update_pmkid_2481 update_pmkid 4 2481 NULL
95559 +wiphy_new_2482 wiphy_new 2 2482 NULL
95560 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95561 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95562 +dm_write_2513 dm_write 3 2513 NULL
95563 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95564 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95565 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95566 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95567 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95568 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95569 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95570 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95571 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95572 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95573 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95574 +__next_cpu_2782 __next_cpu 1 2782 NULL
95575 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95576 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
95577 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
95578 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95579 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95580 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95581 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95582 +__swab64p_2875 __swab64p 0 2875 NULL
95583 +nla_padlen_2883 nla_padlen 1 2883 NULL
95584 +cmm_write_2896 cmm_write 3 2896 NULL
95585 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
95586 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95587 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95588 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95589 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95590 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95591 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95592 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95593 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95594 +depth_write_3021 depth_write 3 3021 NULL
95595 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95596 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95597 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95598 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95599 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95600 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95601 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95602 +free_coherent_3082 free_coherent 4-2 3082 NULL
95603 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
95604 +rb_alloc_3102 rb_alloc 1 3102 NULL
95605 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95606 +print_time_3132 print_time 0 3132 NULL
95607 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95608 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95609 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95610 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95611 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95612 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95613 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95614 +alloc_context_3194 alloc_context 1 3194 NULL
95615 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95616 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95617 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95618 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95619 +key_key_read_3241 key_key_read 3 3241 NULL
95620 +number_3243 number 0 3243 NULL
95621 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95622 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95623 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95624 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95625 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95626 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
95627 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95628 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95629 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95630 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95631 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95632 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
95633 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
95634 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95635 +send_stream_3397 send_stream 4 3397 NULL
95636 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95637 +msix_map_region_3411 msix_map_region 3 3411 NULL
95638 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95639 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95640 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95641 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95642 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95643 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95644 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95645 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95646 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95647 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95648 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95649 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95650 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95651 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95652 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95653 +evtchn_read_3569 evtchn_read 3 3569 NULL
95654 +vc_resize_3585 vc_resize 2-3 3585 NULL
95655 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95656 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95657 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95658 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95659 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95660 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
95661 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
95662 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95663 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95664 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
95665 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95666 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95667 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95668 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95669 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
95670 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95671 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95672 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95673 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95674 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95675 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95676 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95677 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95678 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95679 +get_fd_set_3866 get_fd_set 1 3866 NULL
95680 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95681 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95682 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95683 +nvram_write_3894 nvram_write 3 3894 NULL
95684 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95685 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95686 +vcs_write_3910 vcs_write 3 3910 NULL
95687 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95688 +do_add_counters_3992 do_add_counters 3 3992 NULL
95689 +userspace_status_4004 userspace_status 4 4004 NULL
95690 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95691 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95692 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95693 +blk_end_request_4024 blk_end_request 3 4024 NULL
95694 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95695 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95696 +read_file_queues_4078 read_file_queues 3 4078 NULL
95697 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95698 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95699 +tm6000_read_4151 tm6000_read 3 4151 NULL
95700 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95701 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95702 +get_alua_req_4166 get_alua_req 3 4166 NULL
95703 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95704 +read_file_bool_4180 read_file_bool 3 4180 NULL
95705 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95706 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95707 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95708 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
95709 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95710 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95711 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
95712 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95713 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95714 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95715 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95716 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95717 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95718 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95719 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95720 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95721 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95722 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95723 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95724 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95725 +set_link_security_4502 set_link_security 4 4502 NULL
95726 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95727 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95728 +tty_register_device_4544 tty_register_device 2 4544 NULL
95729 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95730 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95731 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95732 +bch_alloc_4593 bch_alloc 1 4593 NULL
95733 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95734 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95735 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95736 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95737 +kone_receive_4690 kone_receive 4 4690 NULL
95738 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95739 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95740 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95741 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95742 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95743 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95744 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95745 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95746 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
95747 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95748 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95749 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95750 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95751 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95752 +sys_ipc_4889 sys_ipc 3 4889 NULL
95753 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
95754 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95755 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95756 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95757 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
95758 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95759 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95760 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95761 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95762 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95763 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95764 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
95765 +do_mincore_5018 do_mincore 0-1 5018 NULL
95766 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95767 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95768 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95769 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95770 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95771 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95772 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95773 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95774 +sound_write_5102 sound_write 3 5102 NULL
95775 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95776 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95777 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95778 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95779 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95780 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95781 +skb_network_header_5203 skb_network_header 0 5203 NULL
95782 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95783 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95784 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95785 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95786 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95787 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95788 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95789 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95790 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95791 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95792 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95793 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95794 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95795 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95796 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95797 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95798 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95799 +tty_write_5494 tty_write 3 5494 NULL
95800 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95801 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95802 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95803 +spidev_message_5518 spidev_message 3 5518 NULL
95804 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95805 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95806 +le_readq_5557 le_readq 0 5557 NULL
95807 +inw_5558 inw 0 5558 NULL
95808 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
95809 +fir16_create_5574 fir16_create 3 5574 NULL
95810 +bioset_create_5580 bioset_create 1 5580 NULL
95811 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95812 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
95813 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95814 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95815 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95816 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95817 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95818 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95819 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95820 +get_arg_5694 get_arg 3 5694 NULL
95821 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95822 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95823 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95824 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95825 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95826 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95827 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95828 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95829 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95830 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95831 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95832 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95833 +setup_req_5848 setup_req 3 5848 NULL
95834 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95835 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95836 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95837 +port_show_regs_5904 port_show_regs 3 5904 NULL
95838 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
95839 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95840 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95841 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95842 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95843 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95844 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95845 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95846 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95847 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95848 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95849 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95850 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95851 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95852 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95853 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95854 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95855 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95856 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95857 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95858 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95859 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95860 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95861 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95862 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95863 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95864 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95865 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95866 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
95867 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95868 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95869 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95870 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95871 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95872 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95873 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95874 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95875 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
95876 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
95877 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
95878 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
95879 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
95880 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
95881 +mei_read_6507 mei_read 3 6507 NULL
95882 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
95883 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
95884 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
95885 +wdm_read_6549 wdm_read 3 6549 NULL
95886 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
95887 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
95888 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
95889 +usemap_size_6601 usemap_size 0-1 6601 NULL
95890 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
95891 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
95892 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
95893 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
95894 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
95895 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
95896 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
95897 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
95898 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
95899 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
95900 +mpeg_read_6708 mpeg_read 3 6708 NULL
95901 +video_proc_write_6724 video_proc_write 3 6724 NULL
95902 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
95903 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
95904 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
95905 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
95906 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
95907 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
95908 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
95909 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
95910 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
95911 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
95912 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
95913 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
95914 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
95915 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
95916 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
95917 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
95918 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
95919 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
95920 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
95921 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
95922 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
95923 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
95924 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
95925 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
95926 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
95927 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
95928 +request_key_async_6990 request_key_async 4 6990 NULL
95929 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
95930 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
95931 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
95932 +wimax_msg_7030 wimax_msg 4 7030 NULL
95933 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
95934 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
95935 +event_enable_read_7074 event_enable_read 3 7074 NULL
95936 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
95937 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
95938 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
95939 +check_header_7108 check_header 0 7108 NULL
95940 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
95941 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
95942 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
95943 +get_param_h_7247 get_param_h 0 7247 NULL
95944 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
95945 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
95946 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
95947 +mgmt_control_7349 mgmt_control 3 7349 NULL
95948 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
95949 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
95950 +hweight_long_7388 hweight_long 0-1 7388 NULL
95951 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
95952 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
95953 +readb_7401 readb 0 7401 NULL
95954 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
95955 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
95956 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
95957 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
95958 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
95959 +garp_request_join_7471 garp_request_join 4 7471 NULL
95960 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
95961 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
95962 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
95963 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
95964 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
95965 +setup_usemap_7524 setup_usemap 3 7524 NULL
95966 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
95967 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
95968 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
95969 +groups_alloc_7614 groups_alloc 1 7614 NULL
95970 +sg_virt_7616 sg_virt 0 7616 NULL
95971 +cpumask_first_7648 cpumask_first 0 7648 NULL
95972 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
95973 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
95974 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
95975 +dev_write_7708 dev_write 3 7708 NULL
95976 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
95977 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
95978 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
95979 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
95980 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
95981 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
95982 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
95983 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
95984 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
95985 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
95986 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
95987 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
95988 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
95989 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
95990 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
95991 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
95992 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
95993 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
95994 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
95995 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
95996 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
95997 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
95998 +sys_mbind_7990 sys_mbind 5 7990 NULL
95999 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
96000 +vcs_read_8017 vcs_read 3 8017 NULL
96001 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
96002 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
96003 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
96004 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
96005 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
96006 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
96007 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
96008 +venus_lookup_8121 venus_lookup 4 8121 NULL
96009 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
96010 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
96011 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
96012 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
96013 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
96014 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
96015 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
96016 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
96017 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
96018 +play_iframe_8219 play_iframe 3 8219 NULL
96019 +create_log_8225 create_log 2 8225 NULL nohasharray
96020 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
96021 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
96022 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
96023 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
96024 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
96025 +init_cdev_8274 init_cdev 1 8274 NULL
96026 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
96027 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
96028 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
96029 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
96030 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
96031 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
96032 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
96033 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
96034 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
96035 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
96036 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
96037 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
96038 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
96039 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
96040 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96041 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96042 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
96043 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96044 +dev_config_8506 dev_config 3 8506 NULL
96045 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96046 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
96047 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96048 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96049 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96050 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96051 +profile_remove_8556 profile_remove 3 8556 NULL
96052 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96053 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96054 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96055 +tower_write_8580 tower_write 3 8580 NULL
96056 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96057 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96058 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96059 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96060 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96061 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96062 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96063 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96064 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96065 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96066 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96067 +arcfb_write_8702 arcfb_write 3 8702 NULL
96068 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96069 +init_header_8703 init_header 0 8703 &i_size_read_8703
96070 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96071 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
96072 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
96073 +f_dupfd_8730 f_dupfd 1 8730 NULL
96074 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
96075 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
96076 +sys_prctl_8766 sys_prctl 4 8766 NULL
96077 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
96078 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
96079 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
96080 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
96081 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
96082 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
96083 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
96084 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
96085 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
96086 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
96087 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
96088 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
96089 +send_pages_8872 send_pages 3 8872 NULL
96090 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
96091 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96092 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96093 +layout_commit_8926 layout_commit 3 8926 NULL
96094 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96095 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96096 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96097 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96098 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96099 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96100 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96101 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96102 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96103 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96104 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
96105 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
96106 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96107 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96108 +nla_put_9042 nla_put 3 9042 NULL
96109 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96110 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96111 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96112 +string_9080 string 0 9080 NULL
96113 +create_queues_9088 create_queues 2-3 9088 NULL
96114 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96115 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96116 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96117 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96118 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96119 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96120 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96121 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96122 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96123 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96124 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96125 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96126 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96127 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96128 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96129 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96130 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96131 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96132 +flakey_status_9274 flakey_status 5 9274 NULL
96133 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96134 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96135 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96136 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96137 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96138 +read_9397 read 3 9397 NULL
96139 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96140 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
96141 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96142 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96143 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96144 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96145 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96146 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96147 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96148 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
96149 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96150 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96151 +lp_write_9511 lp_write 3 9511 NULL
96152 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96153 +lm3533_update_9529 lm3533_update 2 9529 NULL
96154 +read_file_dma_9530 read_file_dma 3 9530 NULL
96155 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96156 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
96157 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96158 +readl_9557 readl 0 9557 NULL
96159 +fw_node_create_9559 fw_node_create 2 9559 NULL
96160 +kobj_map_9566 kobj_map 2-3 9566 NULL
96161 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96162 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96163 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96164 +do_sync_9604 do_sync 1 9604 NULL
96165 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96166 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96167 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96168 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96169 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96170 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96171 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96172 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96173 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96174 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96175 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96176 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
96177 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
96178 +fnb_9703 fnb 2-3 9703 NULL
96179 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
96180 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96181 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96182 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96183 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96184 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96185 +do_sigpending_9766 do_sigpending 2 9766 NULL
96186 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96187 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96188 +_regmap_write_9803 _regmap_write 2 9803 NULL
96189 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96190 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96191 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96192 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96193 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96194 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96195 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96196 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96197 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96198 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96199 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96200 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96201 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96202 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96203 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
96204 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96205 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96206 +read_file_misc_9948 read_file_misc 3 9948 NULL
96207 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96208 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96209 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96210 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96211 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96212 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96213 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
96214 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96215 +handle_request_10024 handle_request 9 10024 NULL
96216 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96217 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96218 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
96219 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96220 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
96221 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96222 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96223 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96224 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
96225 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96226 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96227 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96228 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96229 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96230 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96231 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96232 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96233 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96234 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96235 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96236 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96237 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96238 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
96239 +read_emulate_10310 read_emulate 2-4 10310 NULL
96240 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96241 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96242 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96243 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96244 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96245 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96246 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96247 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96248 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96249 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96250 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96251 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96252 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96253 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96254 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96255 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96256 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96257 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
96258 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96259 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96260 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96261 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96262 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96263 +otp_read_10594 otp_read 2-4-5 10594 NULL
96264 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96265 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
96266 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96267 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96268 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96269 +parport_write_10669 parport_write 0 10669 NULL
96270 +inl_10708 inl 0 10708 NULL nohasharray
96271 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96272 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96273 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96274 +spi_sync_10731 spi_sync 0 10731 NULL
96275 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96276 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96277 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96278 +sys_syslog_10746 sys_syslog 3 10746 NULL
96279 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96280 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96281 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
96282 +sys_bind_10799 sys_bind 3 10799 NULL
96283 +compat_put_int_10828 compat_put_int 1 10828 NULL
96284 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96285 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96286 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96287 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96288 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
96289 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96290 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96291 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96292 +get_scq_10897 get_scq 2 10897 NULL
96293 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96294 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96295 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96296 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96297 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96298 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96299 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96300 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96301 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96302 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96303 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96304 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96305 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
96306 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96307 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
96308 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96309 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
96310 +count_argc_11083 count_argc 0 11083 NULL
96311 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96312 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96313 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96314 +page_offset_11120 page_offset 0 11120 NULL
96315 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96316 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
96317 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96318 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96319 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96320 +__swab16p_11220 __swab16p 0 11220 NULL
96321 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96322 +of_irq_count_11253 of_irq_count 0 11253 NULL
96323 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96324 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96325 +cru_detect_11272 cru_detect 1 11272 NULL
96326 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96327 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96328 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96329 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96330 +next_segment_11330 next_segment 0-2-1 11330 NULL
96331 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96332 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96333 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96334 +sel_write_create_11353 sel_write_create 3 11353 NULL
96335 +handle_unit_11355 handle_unit 0-1 11355 NULL
96336 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96337 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96338 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96339 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96340 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
96341 +str_to_user_11411 str_to_user 2 11411 NULL
96342 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
96343 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
96344 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96345 +trace_options_read_11419 trace_options_read 3 11419 NULL
96346 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96347 +prepare_image_11424 prepare_image 0 11424 NULL
96348 +vring_size_11426 vring_size 0-1-2 11426 NULL
96349 +bttv_read_11432 bttv_read 3 11432 NULL
96350 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
96351 +swp_offset_11475 swp_offset 0 11475 NULL
96352 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
96353 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
96354 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
96355 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
96356 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96357 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96358 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96359 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96360 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96361 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96362 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96363 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96364 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96365 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96366 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96367 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
96368 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96369 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96370 +split_11691 split 2 11691 NULL
96371 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96372 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96373 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96374 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96375 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96376 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96377 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96378 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96379 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96380 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
96381 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96382 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96383 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96384 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96385 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96386 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96387 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96388 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96389 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96390 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96391 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96392 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
96393 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96394 +atmel_read16_11981 atmel_read16 0 11981 NULL
96395 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96396 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
96397 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96398 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96399 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96400 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96401 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96402 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
96403 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96404 +set_powered_12129 set_powered 4 12129 NULL
96405 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96406 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96407 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96408 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96409 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96410 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96411 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96412 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96413 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96414 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96415 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96416 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96417 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96418 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96419 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96420 +receive_copy_12216 receive_copy 3 12216 NULL
96421 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96422 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
96423 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96424 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96425 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96426 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96427 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96428 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96429 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96430 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96431 +split_bvec_12312 split_bvec 6 12312 NULL
96432 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96433 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96434 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96435 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96436 +receive_packet_12367 receive_packet 2 12367 NULL
96437 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96438 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96439 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
96440 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96441 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96442 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96443 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96444 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96445 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96446 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96447 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
96448 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96449 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96450 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96451 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96452 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96453 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96454 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96455 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96456 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96457 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96458 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
96459 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96460 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96461 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96462 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96463 +ivtv_write_12721 ivtv_write 3 12721 NULL
96464 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96465 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96466 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96467 +listxattr_12769 listxattr 3 12769 NULL
96468 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96469 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96470 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96471 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96472 +readq_12825 readq 0 12825 NULL
96473 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96474 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
96475 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
96476 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96477 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96478 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96479 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96480 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96481 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96482 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
96483 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96484 +bm_status_write_12964 bm_status_write 3 12964 NULL
96485 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96486 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96487 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96488 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96489 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96490 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96491 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96492 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96493 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96494 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
96495 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96496 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96497 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96498 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96499 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96500 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96501 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96502 +blk_update_request_13146 blk_update_request 3 13146 NULL
96503 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96504 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96505 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96506 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96507 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96508 +comedi_read_13199 comedi_read 3 13199 NULL
96509 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96510 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96511 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
96512 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96513 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96514 +fw_download_code_13249 fw_download_code 3 13249 NULL
96515 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96516 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96517 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96518 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96519 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96520 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96521 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96522 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96523 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96524 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
96525 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96526 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96527 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96528 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96529 +sky2_receive_13407 sky2_receive 2 13407 NULL
96530 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96531 +keyring_read_13438 keyring_read 3 13438 NULL
96532 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96533 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96534 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
96535 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96536 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96537 +core_status_13515 core_status 4 13515 NULL
96538 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96539 +bm_init_13529 bm_init 2 13529 NULL
96540 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
96541 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96542 +alloc_tio_13564 alloc_tio 3 13564 NULL
96543 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96544 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96545 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
96546 +cache_write_13589 cache_write 3 13589 NULL
96547 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96548 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96549 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96550 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96551 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96552 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
96553 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96554 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96555 +packet_snd_13634 packet_snd 3 13634 NULL
96556 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96557 +cache_downcall_13666 cache_downcall 3 13666 NULL
96558 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96559 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96560 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96561 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96562 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96563 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96564 +random_read_13815 random_read 3 13815 NULL
96565 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96566 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96567 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96568 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96569 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96570 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96571 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96572 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96573 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96574 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96575 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96576 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96577 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96578 +com90xx_found_13974 com90xx_found 3 13974 NULL
96579 +qcam_read_13977 qcam_read 3 13977 NULL
96580 +dsp_read_13980 dsp_read 2 13980 NULL
96581 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96582 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96583 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
96584 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96585 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96586 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96587 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96588 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96589 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96590 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96591 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96592 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96593 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96594 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96595 +em_canid_change_14150 em_canid_change 3 14150 NULL
96596 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96597 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96598 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96599 +alloc_async_14208 alloc_async 1 14208 NULL
96600 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96601 +pool_status_14230 pool_status 5 14230 NULL
96602 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96603 +inode_to_path_14235 inode_to_path 2 14235 NULL
96604 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96605 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
96606 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96607 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
96608 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96609 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96610 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96611 +rr_status_14293 rr_status 5 14293 NULL
96612 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
96613 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96614 +oo_objects_14319 oo_objects 0 14319 NULL
96615 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96616 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96617 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96618 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96619 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96620 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96621 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96622 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96623 +block_size_14443 block_size 0 14443 NULL
96624 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96625 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96626 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96627 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96628 +stripe_status_14506 stripe_status 5 14506 NULL
96629 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96630 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96631 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96632 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96633 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96634 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96635 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96636 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96637 +dbJoin_14644 dbJoin 0 14644 NULL
96638 +profile_replace_14652 profile_replace 3 14652 NULL
96639 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96640 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96641 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96642 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96643 +vfd_write_14717 vfd_write 3 14717 NULL
96644 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96645 +raid1_resize_14740 raid1_resize 2 14740 NULL
96646 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96647 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96648 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96649 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96650 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
96651 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96652 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96653 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96654 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96655 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96656 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
96657 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96658 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96659 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96660 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96661 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96662 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96663 +unifi_read_14899 unifi_read 3 14899 NULL
96664 +krealloc_14908 krealloc 2 14908 NULL
96665 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96666 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
96667 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96668 +queue_cnt_14951 queue_cnt 0 14951 NULL
96669 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96670 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96671 +setkey_14987 setkey 3 14987 NULL nohasharray
96672 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96673 +vmap_15025 vmap 2 15025 NULL
96674 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96675 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96676 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96677 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96678 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96679 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96680 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
96681 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96682 +start_port_15124 start_port 0 15124 NULL
96683 +memchr_15126 memchr 0 15126 NULL
96684 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96685 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96686 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96687 +reserve_resources_15194 reserve_resources 3 15194 NULL
96688 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96689 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
96690 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96691 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96692 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96693 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96694 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96695 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96696 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96697 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96698 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96699 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96700 +ioread16_15342 ioread16 0 15342 NULL
96701 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96702 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96703 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96704 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96705 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96706 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96707 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96708 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96709 +get_modalias_15406 get_modalias 2 15406 NULL
96710 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96711 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
96712 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96713 +memweight_15450 memweight 2 15450 NULL
96714 +vmalloc_15464 vmalloc 1 15464 NULL
96715 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
96716 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96717 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96718 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96719 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96720 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96721 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
96722 +persistent_status_15574 persistent_status 4 15574 NULL
96723 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96724 +vme_user_write_15587 vme_user_write 3 15587 NULL
96725 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96726 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96727 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96728 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96729 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96730 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96731 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96732 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96733 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96734 +fs_path_add_15648 fs_path_add 3 15648 NULL
96735 +xsd_read_15653 xsd_read 3 15653 NULL
96736 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96737 +unix_bind_15668 unix_bind 3 15668 NULL
96738 +dm_read_15674 dm_read 3 15674 NULL
96739 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96740 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96741 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96742 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96743 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96744 +do_test_15766 do_test 1 15766 NULL
96745 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96746 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96747 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96748 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96749 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96750 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96751 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96752 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96753 +table_size_15851 table_size 0-1-2 15851 NULL
96754 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96755 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96756 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96757 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
96758 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96759 +native_read_msr_15905 native_read_msr 0 15905 NULL
96760 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
96761 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96762 +power_read_15939 power_read 3 15939 NULL
96763 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96764 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96765 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96766 +set_spte_15977 set_spte 7-6 15977 NULL
96767 +frame_alloc_15981 frame_alloc 4 15981 NULL
96768 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96769 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96770 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96771 +got_frame_16028 got_frame 2 16028 NULL
96772 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96773 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96774 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96775 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96776 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96777 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96778 +fsm_init_16134 fsm_init 2 16134 NULL
96779 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96780 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96781 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96782 +mapping_level_16188 mapping_level 2 16188 NULL
96783 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96784 +create_table_16213 create_table 2 16213 NULL
96785 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96786 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96787 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
96788 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96789 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96790 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96791 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96792 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96793 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96794 +account_16283 account 0-2-4 16283 NULL nohasharray
96795 +mirror_status_16283 mirror_status 5 16283 &account_16283
96796 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96797 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
96798 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96799 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96800 +tps80031_update_16360 tps80031_update 3 16360 NULL
96801 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96802 +rbd_add_16366 rbd_add 3 16366 NULL
96803 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96804 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96805 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96806 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96807 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96808 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96809 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96810 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96811 +raid10_resize_16537 raid10_resize 2 16537 NULL
96812 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96813 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96814 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96815 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96816 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96817 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
96818 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
96819 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96820 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96821 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96822 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96823 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96824 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96825 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96826 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96827 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96828 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96829 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96830 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96831 +st_write_16874 st_write 3 16874 NULL
96832 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96833 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
96834 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96835 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96836 +random32_16937 random32 0 16937 NULL
96837 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96838 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96839 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96840 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96841 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96842 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96843 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96844 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96845 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96846 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96847 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96848 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96849 +mac_address_string_17091 mac_address_string 0 17091 NULL
96850 +entry_length_17093 entry_length 0 17093 NULL
96851 +sys_preadv_17100 sys_preadv 3 17100 NULL
96852 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96853 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96854 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96855 +sep_read_17161 sep_read 3 17161 NULL
96856 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96857 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96858 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96859 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96860 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96861 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96862 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96863 +ms_rw_17220 ms_rw 3-4 17220 NULL
96864 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96865 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96866 +alloc_ep_17269 alloc_ep 1 17269 NULL
96867 +pg_read_17276 pg_read 3 17276 NULL
96868 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96869 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96870 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96871 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96872 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96873 +skb_pad_17302 skb_pad 2 17302 NULL
96874 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96875 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
96876 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
96877 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
96878 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
96879 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
96880 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
96881 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
96882 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
96883 +compat_cmd_17465 compat_cmd 2 17465 NULL
96884 +probe_bios_17467 probe_bios 1 17467 NULL
96885 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
96886 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
96887 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
96888 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
96889 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
96890 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
96891 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
96892 +copy_from_user_17559 copy_from_user 3 17559 NULL
96893 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
96894 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
96895 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
96896 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
96897 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
96898 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
96899 +osst_execute_17607 osst_execute 7-6 17607 NULL
96900 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
96901 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
96902 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
96903 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
96904 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
96905 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
96906 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
96907 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
96908 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
96909 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
96910 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
96911 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
96912 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
96913 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
96914 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
96915 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
96916 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
96917 +count_leafs_17842 count_leafs 0 17842 NULL
96918 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
96919 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
96920 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
96921 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
96922 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
96923 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
96924 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
96925 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
96926 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
96927 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
96928 +recover_head_17904 recover_head 3 17904 NULL
96929 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
96930 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
96931 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
96932 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
96933 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
96934 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
96935 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
96936 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
96937 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
96938 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
96939 +prandom32_18007 prandom32 0 18007 NULL
96940 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
96941 +fill_read_18019 fill_read 0 18019 NULL
96942 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
96943 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
96944 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
96945 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
96946 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
96947 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
96948 +packet_came_18072 packet_came 3 18072 NULL
96949 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
96950 +get_vm_area_18080 get_vm_area 1 18080 NULL
96951 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
96952 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
96953 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
96954 +svc_getnl_18120 svc_getnl 0 18120 NULL
96955 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
96956 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
96957 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
96958 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
96959 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
96960 +_has_tag_18169 _has_tag 2 18169 NULL
96961 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
96962 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
96963 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
96964 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
96965 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
96966 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
96967 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
96968 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
96969 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
96970 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
96971 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
96972 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
96973 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
96974 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
96975 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
96976 +um_idi_write_18293 um_idi_write 3 18293 NULL
96977 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
96978 +vga_r_18310 vga_r 0 18310 NULL
96979 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
96980 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
96981 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
96982 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
96983 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
96984 +ep_io_18367 ep_io 0 18367 NULL
96985 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
96986 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
96987 +__video_register_device_18399 __video_register_device 3 18399 NULL
96988 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
96989 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
96990 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
96991 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
96992 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
96993 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
96994 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
96995 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
96996 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
96997 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
96998 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
96999 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
97000 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
97001 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
97002 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
97003 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
97004 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
97005 +debug_output_18575 debug_output 3 18575 NULL
97006 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
97007 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
97008 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
97009 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
97010 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
97011 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
97012 +from_buffer_18625 from_buffer 3 18625 NULL
97013 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
97014 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
97015 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
97016 +unmap_page_18665 unmap_page 2-3 18665 NULL
97017 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
97018 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
97019 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
97020 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
97021 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
97022 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
97023 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
97024 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
97025 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
97026 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
97027 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
97028 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
97029 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
97030 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
97031 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
97032 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
97033 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
97034 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
97035 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
97036 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
97037 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
97038 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
97039 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
97040 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97041 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97042 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97043 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97044 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97045 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97046 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
97047 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97048 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97049 +huge_page_size_19008 huge_page_size 0 19008 NULL
97050 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97051 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97052 +revalidate_19043 revalidate 2 19043 NULL
97053 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97054 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97055 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97056 +copy_and_check_19089 copy_and_check 3 19089 NULL
97057 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97058 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97059 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97060 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97061 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97062 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97063 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97064 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97065 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97066 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97067 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97068 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97069 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97070 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97071 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97072 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97073 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97074 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
97075 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97076 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97077 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97078 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97079 +qc_capture_19298 qc_capture 3 19298 NULL
97080 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97081 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97082 +debug_read_19322 debug_read 3 19322 NULL
97083 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
97084 +read_zero_19366 read_zero 3 19366 NULL
97085 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
97086 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
97087 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
97088 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
97089 +__phys_addr_19434 __phys_addr 0 19434 NULL
97090 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
97091 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97092 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97093 +sky2_read16_19475 sky2_read16 0 19475 NULL
97094 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97095 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97096 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97097 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97098 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97099 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97100 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97101 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97102 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97103 +nfsd_read_19568 nfsd_read 5 19568 NULL
97104 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97105 +bm_status_read_19583 bm_status_read 3 19583 NULL
97106 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97107 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97108 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97109 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97110 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97111 +read_reg_19723 read_reg 0 19723 NULL
97112 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97113 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97114 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97115 +p9_client_read_19750 p9_client_read 5 19750 NULL
97116 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97117 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97118 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97119 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97120 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97121 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97122 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97123 +vip_read_19832 vip_read 3 19832 NULL nohasharray
97124 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
97125 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97126 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97127 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97128 +__nla_put_19857 __nla_put 3 19857 NULL
97129 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97130 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97131 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97132 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97133 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97134 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97135 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97136 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97137 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
97138 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97139 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97140 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97141 +team_options_register_20091 team_options_register 3 20091 NULL
97142 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97143 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97144 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97145 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97146 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97147 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97148 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97149 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97150 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97151 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97152 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97153 +resource_size_20256 resource_size 0 20256 NULL
97154 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97155 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97156 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97157 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97158 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97159 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
97160 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97161 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97162 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97163 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97164 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
97165 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97166 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
97167 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97168 +read_buf_20469 read_buf 2 20469 NULL
97169 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97170 +fast_user_write_20494 fast_user_write 5 20494 NULL
97171 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97172 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97173 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97174 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97175 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97176 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97177 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97178 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97179 +venus_create_20555 venus_create 4 20555 NULL
97180 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97181 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97182 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
97183 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97184 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97185 +lirc_write_20604 lirc_write 3 20604 NULL
97186 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97187 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97188 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97189 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97190 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97191 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
97192 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97193 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
97194 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
97195 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97196 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
97197 +cpumask_size_20683 cpumask_size 0 20683 NULL
97198 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97199 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97200 +__maestro_read_20700 __maestro_read 0 20700 NULL
97201 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97202 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97203 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97204 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97205 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97206 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97207 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97208 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97209 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97210 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97211 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97212 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97213 +sys_sendto_20809 sys_sendto 6 20809 NULL
97214 +strndup_user_20819 strndup_user 2 20819 NULL
97215 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97216 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
97217 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97218 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97219 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97220 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97221 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97222 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97223 +htable_bits_20933 htable_bits 0 20933 NULL
97224 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97225 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97226 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97227 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97228 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97229 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97230 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97231 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97232 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97233 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97234 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97235 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97236 +multipath_status_21094 multipath_status 5 21094 NULL
97237 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97238 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97239 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97240 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97241 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97242 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97243 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
97244 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
97245 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97246 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97247 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97248 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97249 +input_ff_create_21240 input_ff_create 2 21240 NULL
97250 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97251 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97252 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97253 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
97254 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97255 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97256 +add_res_range_21310 add_res_range 4 21310 NULL
97257 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97258 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97259 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97260 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97261 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97262 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97263 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97264 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97265 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97266 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97267 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97268 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97269 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
97270 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97271 +concat_writev_21451 concat_writev 3 21451 NULL
97272 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
97273 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97274 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97275 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97276 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97277 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97278 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97279 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97280 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97281 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97282 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
97283 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97284 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
97285 +validate_nnode_21638 validate_nnode 0 21638 NULL
97286 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97287 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97288 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
97289 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97290 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97291 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97292 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97293 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97294 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97295 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97296 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97297 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97298 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97299 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97300 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97301 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97302 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97303 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97304 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97305 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97306 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97307 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97308 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97309 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97310 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97311 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97312 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
97313 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97314 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97315 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97316 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97317 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97318 +ti_recv_22027 ti_recv 4 22027 NULL
97319 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
97320 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97321 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97322 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97323 +mem_rw_22085 mem_rw 3 22085 NULL
97324 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
97325 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97326 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97327 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97328 +compat_insn_22142 compat_insn 2 22142 NULL
97329 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
97330 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97331 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
97332 +fls_22210 fls 0 22210 NULL
97333 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
97334 +mem_write_22232 mem_write 3 22232 NULL
97335 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97336 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97337 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97338 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97339 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97340 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97341 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97342 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97343 +get_segment_base_22324 get_segment_base 0 22324 NULL
97344 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97345 +atomic_read_22342 atomic_read 0 22342 NULL
97346 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97347 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
97348 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97349 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
97350 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
97351 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
97352 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
97353 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
97354 +zoran_write_22404 zoran_write 3 22404 NULL
97355 +queue_reply_22416 queue_reply 3 22416 NULL
97356 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97357 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97358 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97359 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97360 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97361 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97362 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97363 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97364 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97365 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97366 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97367 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97368 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97369 +snapshot_read_22601 snapshot_read 3 22601 NULL
97370 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97371 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97372 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97373 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97374 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97375 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97376 +fill_gap_22681 fill_gap 0 22681 NULL
97377 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97378 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97379 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97380 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97381 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97382 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97383 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97384 +print_frame_22769 print_frame 0 22769 NULL
97385 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97386 +retu_write_22800 retu_write 2 22800 NULL
97387 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97388 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
97389 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
97390 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97391 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
97392 +create_attr_set_22861 create_attr_set 1 22861 NULL
97393 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97394 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97395 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97396 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97397 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97398 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97399 +vme_get_size_22964 vme_get_size 0 22964 NULL
97400 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97401 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97402 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97403 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97404 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97405 +st_status_23032 st_status 5 23032 NULL
97406 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97407 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97408 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97409 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97410 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97411 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97412 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97413 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97414 +fls_long_23096 fls_long 0 23096 NULL
97415 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97416 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97417 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97418 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97419 +__clear_user_23118 __clear_user 0 23118 NULL
97420 +dm_write_async_23120 dm_write_async 3 23120 NULL
97421 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97422 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97423 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
97424 +read_file_ani_23161 read_file_ani 3 23161 NULL
97425 +ioremap_23172 ioremap 1-2 23172 NULL
97426 +usblp_write_23178 usblp_write 3 23178 NULL
97427 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97428 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97429 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97430 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97431 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97432 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
97433 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97434 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97435 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97436 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97437 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97438 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97439 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97440 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97441 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97442 +doc_probe_23285 doc_probe 1 23285 NULL
97443 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97444 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97445 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97446 +page_readlink_23346 page_readlink 3 23346 NULL
97447 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97448 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97449 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97450 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97451 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
97452 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
97453 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97454 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97455 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97456 +event_filter_read_23494 event_filter_read 3 23494 NULL
97457 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97458 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97459 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97460 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97461 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97462 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97463 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97464 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97465 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97466 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97467 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97468 +sInW_23663 sInW 0 23663 NULL
97469 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97470 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97471 +cx18_read_23699 cx18_read 3 23699 NULL
97472 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97473 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97474 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97475 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97476 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97477 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97478 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97479 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
97480 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97481 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97482 +p54_init_common_23850 p54_init_common 1 23850 NULL
97483 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97484 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97485 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97486 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97487 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
97488 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97489 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97490 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97491 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97492 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97493 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97494 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97495 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97496 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97497 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97498 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97499 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97500 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97501 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97502 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97503 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97504 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97505 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97506 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97507 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97508 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
97509 +mpu401_read_24126 mpu401_read 3 24126 NULL
97510 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97511 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97512 +adu_read_24177 adu_read 3 24177 NULL
97513 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97514 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97515 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97516 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97517 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97518 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97519 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97520 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97521 +thin_status_24278 thin_status 5 24278 NULL
97522 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97523 +msg_size_24288 msg_size 0 24288 NULL
97524 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97525 +map_page_24298 map_page 3-4 24298 NULL
97526 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97527 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97528 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97529 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97530 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97531 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97532 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97533 +igetword_24373 igetword 0 24373 NULL
97534 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97535 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97536 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97537 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97538 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
97539 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97540 +smk_user_access_24440 smk_user_access 3 24440 NULL
97541 +page_address_24444 page_address 0 24444 NULL
97542 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97543 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97544 +pd_video_read_24510 pd_video_read 3 24510 NULL
97545 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97546 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97547 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97548 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97549 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97550 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97551 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97552 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
97553 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
97554 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97555 +context_alloc_24645 context_alloc 3 24645 NULL
97556 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97557 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97558 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97559 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97560 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97561 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97562 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97563 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97564 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97565 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97566 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97567 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97568 +cache_read_24790 cache_read 3 24790 NULL
97569 +unpack_str_24798 unpack_str 0 24798 NULL
97570 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97571 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97572 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97573 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97574 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97575 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97576 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97577 +queues_read_24877 queues_read 3 24877 NULL
97578 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97579 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97580 +next_token_24929 next_token 0 24929 NULL
97581 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97582 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97583 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97584 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97585 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97586 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97587 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97588 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97589 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97590 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97591 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97592 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97593 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97594 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
97595 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
97596 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97597 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
97598 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97599 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97600 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
97601 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97602 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97603 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97604 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97605 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97606 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97607 +stripe_status_25259 stripe_status 5 25259 NULL
97608 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97609 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97610 +vfs_writev_25278 vfs_writev 3 25278 NULL
97611 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97612 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97613 +help_25316 help 5 25316 NULL nohasharray
97614 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97615 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97616 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
97617 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97618 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97619 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97620 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97621 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97622 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97623 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97624 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97625 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97626 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97627 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97628 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97629 +sb_permission_25523 sb_permission 0 25523 NULL
97630 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97631 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97632 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97633 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97634 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97635 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97636 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97637 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97638 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
97639 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97640 +__direct_map_25647 __direct_map 5-6 25647 NULL
97641 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97642 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97643 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97644 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97645 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97646 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97647 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97648 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
97649 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97650 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97651 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97652 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97653 +sg_read_25799 sg_read 3 25799 NULL
97654 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
97655 +system_enable_read_25815 system_enable_read 3 25815 NULL
97656 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97657 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97658 +parport_read_25855 parport_read 0 25855 NULL
97659 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97660 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97661 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97662 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97663 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97664 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97665 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97666 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
97667 +rcname_read_25919 rcname_read 3 25919 NULL
97668 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97669 +key_flags_read_25931 key_flags_read 3 25931 NULL
97670 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97671 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
97672 +flush_25957 flush 2 25957 NULL
97673 +video_register_device_25971 video_register_device 3 25971 NULL
97674 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97675 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97676 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97677 +mirror_status_26010 mirror_status 5 26010 NULL
97678 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97679 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97680 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97681 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97682 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97683 +tun_do_read_26047 tun_do_read 5 26047 NULL
97684 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97685 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97686 +cpumask_next_26096 cpumask_next 1 26096 NULL
97687 +skb_cow_26138 skb_cow 2 26138 NULL
97688 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97689 +__fswab64_26155 __fswab64 0 26155 NULL
97690 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97691 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97692 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97693 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97694 +disk_devt_26180 disk_devt 0 26180 NULL
97695 +get_registers_26187 get_registers 3 26187 NULL
97696 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97697 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97698 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97699 +mce_write_26201 mce_write 3 26201 NULL
97700 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97701 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
97702 +bio_split_26235 bio_split 2 26235 NULL
97703 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97704 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97705 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97706 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97707 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97708 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97709 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97710 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97711 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97712 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97713 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
97714 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97715 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97716 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97717 +read_vmcore_26501 read_vmcore 3 26501 NULL
97718 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97719 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97720 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
97721 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97722 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97723 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97724 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97725 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97726 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97727 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97728 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97729 +mmap_region_26649 mmap_region 0-2 26649 NULL
97730 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97731 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97732 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97733 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97734 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97735 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97736 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97737 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97738 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97739 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97740 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
97741 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97742 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97743 +smk_write_load_26829 smk_write_load 3 26829 NULL
97744 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97745 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97746 +scnprint_id_26842 scnprint_id 3 26842 NULL
97747 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97748 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97749 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97750 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97751 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97752 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
97753 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97754 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97755 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97756 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97757 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97758 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97759 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97760 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97761 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97762 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97763 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97764 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
97765 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97766 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97767 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97768 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97769 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97770 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97771 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97772 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97773 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97774 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97775 +pms_capture_27142 pms_capture 4 27142 NULL
97776 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97777 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97778 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
97779 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97780 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97781 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
97782 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97783 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97784 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97785 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97786 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97787 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97788 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97789 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97790 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
97791 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97792 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97793 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97794 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97795 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97796 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97797 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97798 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97799 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97800 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97801 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
97802 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
97803 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97804 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97805 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97806 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97807 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97808 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97809 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97810 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97811 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97812 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97813 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97814 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97815 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97816 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97817 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97818 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97819 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97820 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97821 +qword_get_27670 qword_get 0 27670 NULL
97822 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97823 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
97824 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97825 +evm_write_key_27715 evm_write_key 3 27715 NULL
97826 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97827 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97828 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97829 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97830 +kcalloc_27770 kcalloc 1-2 27770 NULL
97831 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97832 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97833 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97834 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97835 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97836 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97837 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97838 +read_profile_27859 read_profile 3 27859 NULL
97839 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97840 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97841 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97842 +gluebi_write_27905 gluebi_write 3 27905 NULL
97843 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
97844 +bm_find_next_27929 bm_find_next 2 27929 NULL
97845 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97846 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97847 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97848 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97849 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97850 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97851 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97852 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97853 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97854 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97855 +pool_status_28055 pool_status 5 28055 NULL
97856 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97857 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97858 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97859 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97860 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97861 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97862 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97863 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97864 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97865 +video_read_28148 video_read 3 28148 NULL
97866 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97867 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97868 +vread_28173 vread 0 28173 NULL
97869 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97870 +d_path_28198 d_path 0 28198 NULL
97871 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97872 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97873 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97874 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97875 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
97876 +usemap_size_28281 usemap_size 0 28281 NULL
97877 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
97878 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
97879 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
97880 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
97881 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
97882 +snapshot_write_28351 snapshot_write 3 28351 NULL
97883 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
97884 +sys_writev_28384 sys_writev 3 28384 NULL
97885 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
97886 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
97887 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
97888 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
97889 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
97890 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
97891 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
97892 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
97893 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
97894 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
97895 +max_response_pages_28492 max_response_pages 0 28492 NULL
97896 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
97897 +__next_node_28521 __next_node 1 28521 NULL
97898 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
97899 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
97900 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
97901 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
97902 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
97903 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
97904 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
97905 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
97906 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
97907 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
97908 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
97909 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
97910 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
97911 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
97912 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
97913 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
97914 +_set_range_28627 _set_range 3 28627 NULL
97915 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
97916 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
97917 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
97918 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
97919 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
97920 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
97921 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
97922 +spi_execute_28736 spi_execute 5 28736 NULL
97923 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
97924 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
97925 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
97926 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
97927 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
97928 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
97929 +sel_write_member_28800 sel_write_member 3 28800 NULL
97930 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
97931 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
97932 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
97933 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
97934 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
97935 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
97936 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
97937 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
97938 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
97939 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
97940 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
97941 +push_rx_28939 push_rx 3 28939 NULL
97942 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
97943 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
97944 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
97945 +bin_uuid_28999 bin_uuid 3 28999 NULL
97946 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
97947 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
97948 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
97949 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
97950 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
97951 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
97952 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
97953 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
97954 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
97955 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
97956 +snprintf_29125 snprintf 0 29125 NULL
97957 +iov_shorten_29130 iov_shorten 0 29130 NULL
97958 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
97959 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
97960 +reshape_ring_29147 reshape_ring 2 29147 NULL
97961 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
97962 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
97963 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
97964 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
97965 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
97966 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
97967 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
97968 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
97969 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
97970 +recover_peb_29238 recover_peb 6-7 29238 NULL
97971 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
97972 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
97973 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
97974 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
97975 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
97976 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
97977 +tun_put_user_29337 tun_put_user 5 29337 NULL
97978 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
97979 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
97980 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
97981 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
97982 +mempool_create_29437 mempool_create 1 29437 NULL
97983 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
97984 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
97985 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
97986 +do_register_entry_29478 do_register_entry 4 29478 NULL
97987 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
97988 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
97989 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
97990 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
97991 +ftrace_write_29551 ftrace_write 3 29551 NULL
97992 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
97993 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
97994 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
97995 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
97996 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
97997 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
97998 +slots_per_page_29601 slots_per_page 0 29601 NULL
97999 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
98000 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
98001 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
98002 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
98003 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
98004 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
98005 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
98006 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
98007 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
98008 +probes_write_29711 probes_write 3 29711 NULL
98009 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
98010 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
98011 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
98012 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
98013 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
98014 +dbAlloc_29794 dbAlloc 0 29794 NULL
98015 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
98016 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
98017 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
98018 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
98019 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
98020 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
98021 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
98022 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
98023 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
98024 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
98025 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
98026 +check586_29914 check586 2 29914 NULL
98027 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
98028 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
98029 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
98030 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
98031 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
98032 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
98033 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
98034 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
98035 +drp_wmove_30043 drp_wmove 4 30043 NULL
98036 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
98037 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
98038 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
98039 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
98040 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98041 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98042 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98043 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98044 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98045 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98046 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98047 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98048 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
98049 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98050 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98051 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98052 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98053 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98054 +compat_readv_30273 compat_readv 3 30273 NULL
98055 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98056 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
98057 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98058 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98059 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98060 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98061 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98062 +resource_from_user_30341 resource_from_user 3 30341 NULL
98063 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98064 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
98065 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98066 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98067 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98068 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98069 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98070 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98071 +enable_write_30456 enable_write 3 30456 NULL
98072 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98073 +urandom_read_30462 urandom_read 3 30462 NULL
98074 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98075 +write_head_30481 write_head 4 30481 NULL
98076 +adu_write_30487 adu_write 3 30487 NULL
98077 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
98078 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98079 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98080 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98081 +set_le_30581 set_le 4 30581 NULL
98082 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98083 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
98084 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
98085 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
98086 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
98087 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
98088 +agp_remap_30665 agp_remap 2 30665 NULL
98089 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
98090 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
98091 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98092 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98093 +snapshot_status_30744 snapshot_status 5 30744 NULL
98094 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
98095 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98096 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
98097 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98098 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98099 +create_subvol_30836 create_subvol 4 30836 NULL
98100 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98101 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
98102 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
98103 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98104 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98105 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
98106 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
98107 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98108 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98109 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98110 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98111 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98112 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98113 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98114 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98115 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98116 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98117 +sys_mincore_31079 sys_mincore 1 31079 NULL
98118 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98119 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98120 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
98121 +depth_read_31112 depth_read 3 31112 NULL
98122 +ssb_read16_31139 ssb_read16 0 31139 NULL
98123 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98124 +size_inside_page_31141 size_inside_page 0 31141 NULL
98125 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98126 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98127 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98128 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98129 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98130 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98131 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98132 +__read_reg_31216 __read_reg 0 31216 NULL
98133 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98134 +cyy_readb_31240 cyy_readb 0 31240 NULL
98135 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98136 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98137 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
98138 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98139 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98140 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98141 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
98142 +command_file_write_31318 command_file_write 3 31318 NULL
98143 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
98144 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98145 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
98146 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98147 +inb_31388 inb 0 31388 NULL
98148 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98149 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98150 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98151 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98152 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98153 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98154 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
98155 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98156 +do_fcntl_31468 do_fcntl 3 31468 NULL
98157 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98158 +alg_setkey_31485 alg_setkey 3 31485 NULL
98159 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98160 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98161 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
98162 +hidraw_write_31536 hidraw_write 3 31536 NULL
98163 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98164 +usbvision_read_31555 usbvision_read 3 31555 NULL
98165 +normalize_31566 normalize 0-1-2 31566 NULL
98166 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98167 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98168 +osst_write_31581 osst_write 3 31581 NULL
98169 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98170 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98171 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98172 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98173 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98174 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98175 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98176 +__lgread_31668 __lgread 4 31668 NULL
98177 +symbol_string_31670 symbol_string 0 31670 NULL
98178 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98179 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98180 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98181 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98182 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
98183 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98184 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98185 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98186 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98187 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98188 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
98189 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98190 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98191 +get_count_order_31800 get_count_order 0 31800 NULL
98192 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98193 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98194 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98195 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98196 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98197 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98198 +xattr_permission_31907 xattr_permission 0 31907 NULL
98199 +new_dir_31919 new_dir 3 31919 NULL
98200 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98201 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98202 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98203 +vb2_write_31948 vb2_write 3 31948 NULL
98204 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98205 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
98206 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98207 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98208 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98209 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98210 +calc_hmac_32010 calc_hmac 3 32010 NULL
98211 +aead_len_32021 aead_len 0 32021 NULL
98212 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98213 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98214 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98215 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98216 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98217 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98218 +bio_alloc_32095 bio_alloc 2 32095 NULL
98219 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98220 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98221 +disk_status_32120 disk_status 4 32120 NULL
98222 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
98223 +venus_link_32165 venus_link 5 32165 NULL
98224 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
98225 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98226 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98227 +load_header_32183 load_header 0 32183 NULL
98228 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98229 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98230 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98231 +lm3533_write_32236 lm3533_write 2 32236 NULL
98232 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98233 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98234 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98235 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98236 +hex_string_32310 hex_string 0 32310 NULL
98237 +flakey_status_32315 flakey_status 5 32315 NULL
98238 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98239 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98240 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98241 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98242 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
98243 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98244 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98245 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
98246 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98247 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98248 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98249 +log_text_32428 log_text 0 32428 NULL
98250 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98251 +hid_input_report_32458 hid_input_report 4 32458 NULL
98252 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
98253 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98254 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98255 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98256 +disconnect_32521 disconnect 4 32521 NULL
98257 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98258 +ilo_read_32531 ilo_read 3 32531 NULL
98259 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
98260 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
98261 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98262 +__first_node_32558 __first_node 0 32558 NULL
98263 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98264 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98265 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98266 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98267 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98268 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98269 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98270 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98271 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98272 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98273 +kvmalloc_32646 kvmalloc 1 32646 NULL
98274 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98275 +generic_readlink_32654 generic_readlink 3 32654 NULL
98276 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98277 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
98278 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98279 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98280 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98281 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98282 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98283 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98284 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98285 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98286 +vga_rseq_32848 vga_rseq 0 32848 NULL
98287 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98288 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98289 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98290 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98291 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98292 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98293 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98294 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98295 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98296 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98297 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98298 +compat_filldir_32999 compat_filldir 3 32999 NULL
98299 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98300 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
98301 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98302 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98303 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98304 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98305 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98306 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98307 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98308 +write_node_33121 write_node 4 33121 NULL
98309 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98310 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98311 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98312 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98313 +pp_read_33210 pp_read 3 33210 NULL
98314 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98315 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98316 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98317 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98318 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98319 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
98320 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98321 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98322 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98323 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98324 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98325 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98326 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98327 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
98328 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98329 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98330 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98331 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98332 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98333 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98334 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98335 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98336 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98337 +create_entry_33479 create_entry 2 33479 NULL
98338 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98339 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98340 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98341 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98342 +res_counter_read_33499 res_counter_read 4 33499 NULL
98343 +fb_read_33506 fb_read 3 33506 NULL
98344 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98345 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98346 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98347 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98348 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98349 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98350 +dup_array_33551 dup_array 3 33551 NULL
98351 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
98352 +count_subheaders_33591 count_subheaders 0 33591 NULL
98353 +scsi_execute_33596 scsi_execute 5 33596 NULL
98354 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
98355 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
98356 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98357 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
98358 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98359 +inw_p_33668 inw_p 0 33668 NULL
98360 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98361 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98362 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98363 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
98364 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98365 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98366 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98367 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98368 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98369 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98370 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98371 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98372 +Read_hfc_33755 Read_hfc 0 33755 NULL
98373 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98374 +hashtab_create_33769 hashtab_create 3 33769 NULL
98375 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98376 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98377 +find_next_offset_33804 find_next_offset 3 33804 NULL
98378 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98379 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98380 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98381 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98382 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
98383 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98384 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98385 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98386 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98387 +config_proc_write_33878 config_proc_write 3 33878 NULL
98388 +get_user_pages_33908 get_user_pages 0 33908 NULL
98389 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98390 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98391 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98392 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98393 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98394 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98395 +ppp_write_34034 ppp_write 3 34034 NULL
98396 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98397 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98398 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98399 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98400 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98401 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
98402 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98403 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98404 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98405 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98406 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98407 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98408 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98409 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98410 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98411 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98412 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98413 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98414 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98415 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98416 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98417 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98418 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98419 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98420 +ea_read_34378 ea_read 0 34378 NULL
98421 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98422 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98423 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98424 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
98425 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
98426 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98427 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98428 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98429 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
98430 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98431 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98432 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98433 +alloc_buf_34532 alloc_buf 1 34532 NULL
98434 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98435 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98436 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98437 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98438 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98439 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98440 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98441 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98442 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98443 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98444 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98445 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98446 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98447 +port_print_34704 port_print 3 34704 NULL
98448 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98449 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98450 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98451 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98452 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98453 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
98454 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98455 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98456 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98457 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98458 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98459 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98460 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98461 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
98462 +msg_print_text_34889 msg_print_text 0 34889 NULL
98463 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98464 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98465 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98466 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98467 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98468 +Realloc_34961 Realloc 2 34961 NULL
98469 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98470 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98471 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98472 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98473 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98474 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98475 +store_ifalias_35088 store_ifalias 4 35088 NULL
98476 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98477 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98478 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98479 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98480 +pointer_35138 pointer 0 35138 NULL
98481 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98482 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98483 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98484 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98485 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98486 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98487 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98488 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
98489 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
98490 +set_fd_set_35249 set_fd_set 1 35249 NULL
98491 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98492 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98493 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98494 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98495 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98496 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98497 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98498 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98499 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98500 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
98501 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98502 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98503 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98504 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98505 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98506 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98507 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98508 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98509 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98510 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98511 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
98512 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98513 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98514 +async_setkey_35521 async_setkey 3 35521 NULL
98515 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98516 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98517 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98518 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98519 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98520 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98521 +ReadZReg_35604 ReadZReg 0 35604 NULL
98522 +kernel_readv_35617 kernel_readv 3 35617 NULL
98523 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98524 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
98525 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98526 +store_debug_level_35652 store_debug_level 3 35652 NULL
98527 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
98528 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98529 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98530 +dm_table_create_35687 dm_table_create 3 35687 NULL
98531 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98532 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98533 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98534 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98535 +read_file_stations_35795 read_file_stations 3 35795 NULL
98536 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98537 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98538 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98539 +fls64_35862 fls64 0 35862 NULL
98540 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98541 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98542 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98543 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98544 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98545 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98546 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98547 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98548 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
98549 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98550 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98551 +acl_alloc_35979 acl_alloc 1 35979 NULL
98552 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98553 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98554 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98555 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98556 +sys_init_module_36047 sys_init_module 2 36047 NULL
98557 +account_shadowed_36048 account_shadowed 2 36048 NULL
98558 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98559 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
98560 +write_emulate_36065 write_emulate 2-4 36065 NULL
98561 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98562 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98563 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98564 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98565 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98566 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98567 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98568 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98569 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98570 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98571 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
98572 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98573 +twl_set_36154 twl_set 2 36154 NULL
98574 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98575 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98576 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98577 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98578 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98579 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98580 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98581 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98582 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98583 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98584 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98585 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98586 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98587 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
98588 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98589 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98590 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98591 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98592 +lc_create_36332 lc_create 4 36332 NULL
98593 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98594 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98595 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98596 +to_sector_36361 to_sector 0-1 36361 NULL
98597 +tunables_read_36385 tunables_read 3 36385 NULL
98598 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98599 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98600 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98601 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98602 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98603 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98604 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98605 +get_param_l_36518 get_param_l 0 36518 NULL
98606 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98607 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98608 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98609 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
98610 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98611 +get_entry_len_36549 get_entry_len 0 36549 NULL
98612 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98613 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98614 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98615 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98616 +__erst_read_36579 __erst_read 0 36579 NULL
98617 +put_cmsg_36589 put_cmsg 4 36589 NULL
98618 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98619 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98620 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98621 +format_decode_36638 format_decode 0 36638 NULL
98622 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98623 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98624 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98625 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98626 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98627 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98628 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
98629 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98630 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98631 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98632 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98633 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
98634 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98635 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98636 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98637 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98638 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98639 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
98640 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
98641 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98642 +cm_write_36858 cm_write 3 36858 NULL
98643 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98644 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98645 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98646 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98647 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
98648 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98649 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98650 +div_u64_36951 div_u64 0 36951 NULL
98651 +write_leb_36957 write_leb 5 36957 NULL
98652 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98653 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98654 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
98655 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98656 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98657 +setxattr_37006 setxattr 4 37006 NULL
98658 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
98659 +parse_command_37079 parse_command 2 37079 NULL
98660 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
98661 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98662 +tun_get_user_37094 tun_get_user 5 37094 NULL
98663 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98664 +msg_word_37164 msg_word 0 37164 NULL
98665 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98666 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98667 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98668 +__do_replace_37227 __do_replace 5 37227 NULL
98669 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98670 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98671 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98672 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98673 +c101_run_37279 c101_run 2 37279 NULL
98674 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98675 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98676 +send_msg_37323 send_msg 4 37323 NULL
98677 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98678 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98679 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98680 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98681 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98682 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98683 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98684 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98685 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98686 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98687 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98688 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98689 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98690 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98691 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98692 +get_est_timing_37484 get_est_timing 0 37484 NULL
98693 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
98694 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98695 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98696 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98697 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98698 +hdr_size_37536 hdr_size 0 37536 NULL
98699 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98700 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98701 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98702 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98703 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
98704 +alloc_fd_37637 alloc_fd 1 37637 NULL
98705 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98706 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98707 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98708 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98709 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98710 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98711 +nametbl_header_37698 nametbl_header 2 37698 NULL
98712 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98713 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
98714 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98715 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98716 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98717 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98718 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98719 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98720 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98721 +deny_write_access_37813 deny_write_access 0 37813 NULL
98722 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98723 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98724 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98725 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98726 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98727 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
98728 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98729 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98730 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98731 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98732 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98733 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98734 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98735 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98736 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98737 +vfs_readv_38011 vfs_readv 3 38011 NULL
98738 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98739 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98740 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98741 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
98742 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98743 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98744 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98745 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98746 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98747 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98748 +ep0_read_38095 ep0_read 3 38095 NULL
98749 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98750 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98751 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98752 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98753 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98754 +cdev_add_38176 cdev_add 2-3 38176 NULL
98755 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98756 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98757 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98758 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98759 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98760 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98761 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98762 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98763 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
98764 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98765 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98766 +verity_status_38273 verity_status 5 38273 NULL
98767 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98768 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98769 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98770 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
98771 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98772 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98773 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98774 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98775 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98776 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98777 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98778 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98779 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98780 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98781 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98782 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98783 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98784 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98785 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98786 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
98787 +dev_names_read_38509 dev_names_read 3 38509 NULL
98788 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98789 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98790 +set_queue_count_38519 set_queue_count 0 38519 NULL
98791 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98792 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98793 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
98794 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98795 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98796 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98797 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98798 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98799 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98800 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98801 +delay_status_38606 delay_status 5 38606 NULL
98802 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98803 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98804 +cma_create_area_38642 cma_create_area 2 38642 NULL
98805 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98806 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98807 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98808 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98809 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98810 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98811 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98812 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98813 +udf_readpages_38761 udf_readpages 4 38761 NULL
98814 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98815 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98816 +err_decode_38804 err_decode 2 38804 NULL
98817 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98818 +sys_select_38827 sys_select 1 38827 NULL
98819 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98820 +direct_entry_38836 direct_entry 3 38836 NULL
98821 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98822 +interfaces_38859 interfaces 2 38859 NULL
98823 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98824 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98825 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98826 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98827 +__fswab16_38898 __fswab16 0 38898 NULL
98828 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98829 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98830 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98831 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98832 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98833 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98834 +udf_new_block_38999 udf_new_block 4 38999 NULL
98835 +get_nodes_39012 get_nodes 3 39012 NULL
98836 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98837 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98838 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98839 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98840 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98841 +tun_get_user_39099 tun_get_user 4 39099 NULL
98842 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98843 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98844 +ea_foreach_39133 ea_foreach 0 39133 NULL
98845 +generic_permission_39150 generic_permission 0 39150 NULL
98846 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98847 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98848 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98849 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98850 +init_list_set_39188 init_list_set 2-3 39188 NULL
98851 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98852 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98853 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98854 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98855 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98856 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98857 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98858 +drm_order_39244 drm_order 0 39244 NULL
98859 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
98860 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98861 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98862 +__skb_cow_39254 __skb_cow 2 39254 NULL
98863 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98864 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98865 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98866 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98867 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98868 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98869 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98870 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98871 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98872 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98873 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98874 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98875 +__send_to_port_39386 __send_to_port 3 39386 NULL
98876 +user_power_read_39414 user_power_read 3 39414 NULL
98877 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
98878 +sys_semop_39457 sys_semop 3 39457 NULL
98879 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
98880 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
98881 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
98882 +int_proc_write_39542 int_proc_write 3 39542 NULL
98883 +pp_write_39554 pp_write 3 39554 NULL
98884 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
98885 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
98886 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
98887 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
98888 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
98889 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
98890 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
98891 +ext_depth_39607 ext_depth 0 39607 NULL
98892 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
98893 +sdio_readb_39618 sdio_readb 0 39618 NULL
98894 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
98895 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
98896 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
98897 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
98898 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
98899 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
98900 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
98901 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
98902 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
98903 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
98904 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
98905 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
98906 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
98907 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
98908 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
98909 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
98910 +pkt_add_39897 pkt_add 3 39897 NULL
98911 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
98912 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
98913 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
98914 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
98915 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
98916 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
98917 +__spi_async_39932 __spi_async 0 39932 NULL
98918 +__get_order_39935 __get_order 0 39935 NULL
98919 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
98920 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
98921 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
98922 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
98923 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
98924 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
98925 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
98926 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
98927 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
98928 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
98929 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
98930 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
98931 +add_tty_40055 add_tty 1 40055 NULL nohasharray
98932 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
98933 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
98934 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
98935 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
98936 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
98937 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
98938 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
98939 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
98940 +pt_write_40159 pt_write 3 40159 NULL
98941 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
98942 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
98943 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
98944 +allocate_probes_40204 allocate_probes 1 40204 NULL
98945 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
98946 +compat_put_long_40214 compat_put_long 1 40214 NULL
98947 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
98948 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
98949 +osst_read_40237 osst_read 3 40237 NULL
98950 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
98951 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
98952 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
98953 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
98954 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
98955 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
98956 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
98957 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
98958 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
98959 +mmio_read_40348 mmio_read 4 40348 NULL
98960 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
98961 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
98962 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
98963 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
98964 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
98965 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
98966 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
98967 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
98968 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
98969 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
98970 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
98971 +tty_write_room_40495 tty_write_room 0 40495 NULL
98972 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
98973 +sg_phys_40507 sg_phys 0 40507 NULL
98974 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
98975 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
98976 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
98977 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
98978 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
98979 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
98980 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
98981 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
98982 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
98983 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
98984 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
98985 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
98986 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
98987 +fops_read_40672 fops_read 3 40672 NULL
98988 +tps80031_write_40678 tps80031_write 3 40678 NULL
98989 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
98990 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
98991 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
98992 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
98993 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
98994 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
98995 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
98996 +card_send_command_40757 card_send_command 3 40757 NULL
98997 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
98998 +pg_write_40766 pg_write 3 40766 NULL
98999 +show_list_40775 show_list 3 40775 NULL
99000 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
99001 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
99002 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
99003 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
99004 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
99005 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
99006 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
99007 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
99008 +read_file_queue_40895 read_file_queue 3 40895 NULL
99009 +waiters_read_40902 waiters_read 3 40902 NULL
99010 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
99011 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
99012 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
99013 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
99014 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
99015 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
99016 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
99017 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
99018 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
99019 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
99020 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
99021 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
99022 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
99023 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
99024 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
99025 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
99026 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
99027 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
99028 +dma_attach_41094 dma_attach 5-6 41094 NULL
99029 +provide_user_output_41105 provide_user_output 3 41105 NULL
99030 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
99031 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
99032 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
99033 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
99034 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
99035 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
99036 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
99037 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
99038 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
99039 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
99040 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99041 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99042 +erst_read_41260 erst_read 0 41260 NULL
99043 +__fprog_create_41263 __fprog_create 2 41263 NULL
99044 +alloc_context_41283 alloc_context 1 41283 NULL
99045 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99046 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99047 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99048 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99049 +kmp_init_41373 kmp_init 2 41373 NULL
99050 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99051 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99052 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99053 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99054 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99055 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99056 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
99057 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99058 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99059 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99060 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99061 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
99062 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99063 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99064 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99065 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99066 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99067 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99068 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99069 +gserial_setup_41558 gserial_setup 2 41558 NULL
99070 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99071 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99072 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99073 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99074 +vga_io_r_41609 vga_io_r 0 41609 NULL
99075 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99076 +a2mp_send_41615 a2mp_send 4 41615 NULL
99077 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99078 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99079 +get_std_timing_41654 get_std_timing 0 41654 NULL
99080 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99081 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
99082 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
99083 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
99084 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
99085 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
99086 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
99087 +fillonedir_41746 fillonedir 3 41746 NULL
99088 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
99089 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
99090 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
99091 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99092 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99093 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99094 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
99095 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99096 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99097 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99098 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
99099 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99100 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99101 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99102 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99103 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99104 +portnames_read_41958 portnames_read 3 41958 NULL
99105 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99106 +dst_mtu_41969 dst_mtu 0 41969 NULL
99107 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99108 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99109 +lguest_map_42008 lguest_map 1-2 42008 NULL
99110 +pool_allocate_42012 pool_allocate 3 42012 NULL
99111 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99112 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99113 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99114 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99115 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99116 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99117 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99118 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99119 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99120 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99121 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99122 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
99123 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99124 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
99125 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99126 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99127 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99128 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99129 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99130 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99131 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99132 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99133 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99134 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99135 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99136 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99137 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99138 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99139 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
99140 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99141 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99142 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99143 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99144 +krng_get_random_42420 krng_get_random 3 42420 NULL
99145 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99146 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99147 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99148 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99149 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99150 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99151 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99152 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99153 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99154 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99155 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99156 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99157 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99158 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99159 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99160 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99161 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99162 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99163 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99164 +map_state_42602 map_state 1 42602 NULL nohasharray
99165 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99166 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99167 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99168 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99169 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99170 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
99171 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99172 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99173 +vb2_read_42703 vb2_read 3 42703 NULL
99174 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99175 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99176 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99177 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99178 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99179 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99180 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99181 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99182 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99183 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99184 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99185 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99186 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99187 +set_arg_42824 set_arg 3 42824 NULL
99188 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99189 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
99190 +prandom_u32_42853 prandom_u32 0 42853 NULL
99191 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99192 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99193 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99194 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99195 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99196 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99197 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99198 +hd_end_request_42904 hd_end_request 2 42904 NULL
99199 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99200 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99201 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99202 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99203 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99204 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99205 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99206 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99207 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99208 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99209 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99210 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99211 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99212 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99213 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99214 +uuid_string_43154 uuid_string 0 43154 NULL
99215 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99216 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99217 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99218 +process_measurement_43190 process_measurement 0 43190 NULL
99219 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99220 +uio_write_43202 uio_write 3 43202 NULL
99221 +iso_callback_43208 iso_callback 3 43208 NULL
99222 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99223 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99224 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99225 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99226 +fixup_leb_43256 fixup_leb 3 43256 NULL
99227 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99228 +evtchn_write_43278 evtchn_write 3 43278 NULL
99229 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99230 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99231 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99232 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99233 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99234 +xenfb_write_43412 xenfb_write 3 43412 NULL
99235 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
99236 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
99237 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99238 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99239 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99240 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99241 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99242 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99243 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99244 +do_readlink_43518 do_readlink 2 43518 NULL
99245 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99246 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99247 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99248 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99249 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99250 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99251 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99252 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99253 +proc_read_43614 proc_read 3 43614 NULL
99254 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99255 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
99256 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
99257 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99258 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99259 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99260 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
99261 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99262 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99263 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99264 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99265 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99266 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99267 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99268 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99269 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99270 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99271 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99272 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99273 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99274 +read_flush_43851 read_flush 3 43851 NULL
99275 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99276 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
99277 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
99278 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99279 +SendString_43928 SendString 3 43928 NULL
99280 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99281 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99282 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99283 +nla_reserve_43984 nla_reserve 3 43984 NULL
99284 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99285 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99286 +emit_flags_44006 emit_flags 4-3 44006 NULL
99287 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99288 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99289 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99290 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99291 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99292 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99293 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99294 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99295 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99296 +__set_free_44211 __set_free 2 44211 NULL
99297 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99298 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99299 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99300 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99301 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99302 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
99303 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
99304 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99305 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99306 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99307 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
99308 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99309 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99310 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99311 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99312 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99313 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99314 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99315 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99316 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99317 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99318 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99319 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99320 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99321 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99322 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99323 +spidev_write_44510 spidev_write 3 44510 NULL
99324 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99325 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99326 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
99327 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
99328 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99329 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99330 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
99331 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99332 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99333 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99334 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99335 +mpi_resize_44674 mpi_resize 2 44674 NULL
99336 +ts_read_44687 ts_read 3 44687 NULL
99337 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99338 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99339 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
99340 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
99341 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99342 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99343 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99344 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99345 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99346 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99347 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99348 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99349 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99350 +sisusb_write_44834 sisusb_write 3 44834 NULL
99351 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
99352 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
99353 +skb_availroom_44883 skb_availroom 0 44883 NULL
99354 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99355 +do_tty_write_44896 do_tty_write 5 44896 NULL
99356 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99357 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99358 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
99359 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
99360 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99361 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99362 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99363 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99364 +sel_write_user_45060 sel_write_user 3 45060 NULL
99365 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99366 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99367 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99368 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99369 +usbdev_read_45114 usbdev_read 3 45114 NULL
99370 +send_to_tty_45141 send_to_tty 3 45141 NULL
99371 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99372 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99373 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99374 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99375 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99376 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99377 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99378 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99379 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99380 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99381 +add_child_45201 add_child 4 45201 NULL
99382 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99383 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99384 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99385 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99386 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99387 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99388 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99389 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99390 +keymap_store_45406 keymap_store 4 45406 NULL
99391 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
99392 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99393 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
99394 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99395 +__node_remap_45458 __node_remap 4 45458 NULL
99396 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99397 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99398 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99399 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
99400 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
99401 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99402 +clone_bio_45516 clone_bio 6 45516 NULL
99403 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99404 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99405 +copy_macs_45534 copy_macs 4 45534 NULL
99406 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99407 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99408 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99409 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99410 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99411 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99412 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99413 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99414 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99415 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99416 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99417 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99418 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
99419 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99420 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99421 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99422 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99423 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99424 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99425 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99426 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99427 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99428 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99429 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99430 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99431 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99432 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99433 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99434 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99435 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99436 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99437 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99438 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99439 +amthi_read_45831 amthi_read 4 45831 NULL
99440 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99441 +isdn_write_45863 isdn_write 3 45863 NULL
99442 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
99443 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99444 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99445 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99446 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99447 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99448 +alloc_mr_45935 alloc_mr 1 45935 NULL
99449 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99450 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99451 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99452 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99453 +get_free_entries_46030 get_free_entries 1 46030 NULL
99454 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99455 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99456 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99457 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99458 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99459 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99460 +slhc_toss_46066 slhc_toss 0 46066 NULL
99461 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99462 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99463 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99464 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99465 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99466 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99467 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99468 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99469 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99470 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
99471 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99472 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99473 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99474 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99475 +dsp_write_46218 dsp_write 2 46218 NULL
99476 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99477 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
99478 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99479 +ReadReg_46277 ReadReg 0 46277 NULL
99480 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99481 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99482 +twl6040_write_46351 twl6040_write 2 46351 NULL
99483 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99484 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99485 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99486 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99487 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99488 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99489 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99490 +filldir64_46469 filldir64 3 46469 NULL
99491 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99492 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99493 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99494 +kmsg_read_46514 kmsg_read 3 46514 NULL
99495 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99496 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99497 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99498 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99499 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99500 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99501 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99502 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99503 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99504 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99505 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99506 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99507 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99508 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
99509 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99510 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99511 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99512 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99513 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99514 +prepare_copy_46725 prepare_copy 2 46725 NULL
99515 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99516 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
99517 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99518 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99519 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99520 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
99521 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99522 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99523 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99524 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99525 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
99526 +spi_async_46857 spi_async 0 46857 NULL
99527 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
99528 +vsnprintf_46863 vsnprintf 0 46863 NULL
99529 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99530 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99531 +rvmalloc_46873 rvmalloc 1 46873 NULL
99532 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99533 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99534 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
99535 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99536 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99537 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99538 +fb_write_46924 fb_write 3 46924 NULL
99539 +raid_status_46930 raid_status 5 46930 NULL
99540 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99541 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99542 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99543 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99544 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99545 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99546 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99547 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99548 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99549 +__map_single_47020 __map_single 3-4-7 47020 NULL
99550 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99551 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99552 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
99553 +fs_path_len_47060 fs_path_len 0 47060 NULL
99554 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99555 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99556 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99557 +mousedev_read_47123 mousedev_read 3 47123 NULL
99558 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99559 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99560 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
99561 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99562 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99563 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99564 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99565 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99566 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99567 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99568 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
99569 +l2headersize_47238 l2headersize 0 47238 NULL
99570 +options_write_47243 options_write 3 47243 NULL
99571 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99572 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99573 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99574 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99575 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99576 +vsnprintf_47291 vsnprintf 0 47291 NULL
99577 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99578 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99579 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99580 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99581 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99582 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
99583 +nametbl_list_47391 nametbl_list 2 47391 NULL
99584 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99585 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99586 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99587 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99588 +vzalloc_47421 vzalloc 1 47421 NULL
99589 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99590 +newpart_47485 newpart 6 47485 NULL
99591 +core_sys_select_47494 core_sys_select 1 47494 NULL
99592 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
99593 +unlink_simple_47506 unlink_simple 3 47506 NULL
99594 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99595 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
99596 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99597 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99598 +oz_events_read_47535 oz_events_read 3 47535 NULL
99599 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99600 +cycx_setup_47562 cycx_setup 4 47562 NULL
99601 +read_ldt_47570 read_ldt 2 47570 NULL
99602 +pci_iomap_47575 pci_iomap 3 47575 NULL
99603 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99604 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99605 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
99606 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99607 +uea_request_47613 uea_request 4 47613 NULL
99608 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99609 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
99610 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99611 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99612 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99613 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
99614 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
99615 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99616 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99617 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99618 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99619 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99620 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99621 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
99622 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99623 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99624 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99625 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99626 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99627 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
99628 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99629 +vhci_read_47878 vhci_read 3 47878 NULL
99630 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99631 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99632 +timeout_read_47915 timeout_read 3 47915 NULL
99633 +comedi_write_47926 comedi_write 3 47926 NULL
99634 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99635 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99636 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99637 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
99638 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99639 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99640 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99641 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99642 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99643 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99644 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99645 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99646 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99647 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99648 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99649 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
99650 +set_discoverable_48141 set_discoverable 4 48141 NULL
99651 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99652 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99653 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99654 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99655 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99656 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99657 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
99658 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
99659 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99660 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99661 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99662 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99663 +read_file_recv_48232 read_file_recv 3 48232 NULL
99664 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
99665 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
99666 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99667 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99668 +send_set_info_48288 send_set_info 7 48288 NULL
99669 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99670 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99671 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99672 +hash_setkey_48310 hash_setkey 3 48310 NULL
99673 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99674 +skb_add_data_48363 skb_add_data 3 48363 NULL
99675 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99676 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99677 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
99678 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99679 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99680 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99681 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99682 +send_control_msg_48498 send_control_msg 6 48498 NULL
99683 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99684 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99685 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99686 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99687 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99688 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99689 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99690 +named_distribute_48544 named_distribute 4 48544 NULL
99691 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99692 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
99693 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99694 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99695 +mtd_read_48655 mtd_read 0 48655 NULL
99696 +lc_create_48662 lc_create 3 48662 NULL
99697 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99698 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99699 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99700 +altera_drscan_48698 altera_drscan 2 48698 NULL
99701 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99702 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99703 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99704 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99705 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99706 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99707 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99708 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99709 +azx_get_position_48841 azx_get_position 0 48841 NULL
99710 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99711 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99712 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99713 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99714 +get_num_ops_48886 get_num_ops 0 48886 NULL
99715 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99716 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99717 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99718 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99719 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
99720 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
99721 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99722 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99723 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99724 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99725 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99726 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99727 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99728 +xd_rw_49020 xd_rw 3-4 49020 NULL
99729 +transient_status_49027 transient_status 4 49027 NULL
99730 +ubi_read_49061 ubi_read 0 49061 NULL
99731 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
99732 +calc_layout_49074 calc_layout 4 49074 NULL
99733 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
99734 +scsi_register_49094 scsi_register 2 49094 NULL
99735 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99736 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99737 +pt_read_49136 pt_read 3 49136 NULL
99738 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99739 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99740 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99741 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99742 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99743 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99744 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99745 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99746 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99747 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99748 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
99749 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99750 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99751 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99752 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99753 +uio_read_49300 uio_read 3 49300 NULL
99754 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99755 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99756 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99757 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99758 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99759 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99760 +px_raw_event_49371 px_raw_event 4 49371 NULL
99761 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99762 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99763 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99764 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99765 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99766 +md_domain_init_49432 md_domain_init 2 49432 NULL
99767 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99768 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99769 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99770 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99771 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
99772 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99773 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99774 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99775 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
99776 +smk_write_access_49561 smk_write_access 3 49561 NULL
99777 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99778 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99779 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99780 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99781 +heap_init_49617 heap_init 2 49617 NULL
99782 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99783 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99784 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
99785 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99786 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99787 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99788 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99789 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99790 +check_frame_49741 check_frame 0 49741 NULL
99791 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99792 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99793 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99794 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99795 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99796 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99797 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99798 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99799 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99800 +add_uuid_49831 add_uuid 4 49831 NULL
99801 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99802 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
99803 +twl4030_write_49846 twl4030_write 2 49846 NULL
99804 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99805 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99806 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99807 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99808 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99809 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99810 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99811 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99812 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99813 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
99814 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99815 +__module_alloc_50004 __module_alloc 1 50004 NULL
99816 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99817 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99818 +isdn_read_50021 isdn_read 3 50021 NULL
99819 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
99820 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99821 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99822 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99823 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99824 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99825 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99826 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99827 +read_file_slot_50111 read_file_slot 3 50111 NULL
99828 +copy_items_50140 copy_items 6 50140 NULL
99829 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99830 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99831 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99832 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99833 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99834 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99835 +odev_update_50169 odev_update 2 50169 NULL
99836 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99837 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99838 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99839 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99840 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99841 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99842 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99843 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99844 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99845 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99846 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99847 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99848 +do_launder_page_50329 do_launder_page 0 50329 NULL
99849 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99850 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99851 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99852 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99853 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99854 +tpm_read_50344 tpm_read 3 50344 NULL
99855 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99856 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99857 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99858 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99859 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99860 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99861 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99862 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99863 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99864 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99865 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
99866 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99867 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99868 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99869 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99870 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99871 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
99872 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99873 +fat_readpages_50582 fat_readpages 4 50582 NULL
99874 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99875 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
99876 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
99877 +__ffs_50625 __ffs 0 50625 NULL
99878 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
99879 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
99880 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
99881 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
99882 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
99883 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
99884 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
99885 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
99886 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
99887 +skb_padto_50759 skb_padto 2 50759 NULL
99888 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
99889 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
99890 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
99891 +tpm_write_50798 tpm_write 3 50798 NULL
99892 +tun_do_read_50800 tun_do_read 4 50800 NULL
99893 +write_flush_50803 write_flush 3 50803 NULL
99894 +dvb_play_50814 dvb_play 3 50814 NULL
99895 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
99896 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
99897 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
99898 +dma_attach_50831 dma_attach 6-7 50831 NULL
99899 +SetArea_50835 SetArea 4 50835 NULL nohasharray
99900 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
99901 +self_check_write_50856 self_check_write 5 50856 NULL
99902 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
99903 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
99904 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
99905 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
99906 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
99907 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
99908 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
99909 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
99910 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
99911 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
99912 +timeout_write_50991 timeout_write 3 50991 NULL
99913 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
99914 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
99915 +proc_write_51003 proc_write 3 51003 NULL
99916 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
99917 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
99918 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
99919 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
99920 +dump_midi_51040 dump_midi 3 51040 NULL
99921 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
99922 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
99923 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
99924 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
99925 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
99926 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
99927 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
99928 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
99929 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
99930 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
99931 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
99932 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
99933 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
99934 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
99935 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
99936 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
99937 +tipc_send_51238 tipc_send 4 51238 NULL
99938 +drm_property_create_51239 drm_property_create 4 51239 NULL
99939 +st_read_51251 st_read 3 51251 NULL
99940 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
99941 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
99942 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
99943 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
99944 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
99945 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
99946 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
99947 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
99948 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
99949 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
99950 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
99951 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
99952 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
99953 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
99954 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
99955 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
99956 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
99957 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
99958 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
99959 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
99960 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
99961 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
99962 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
99963 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
99964 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
99965 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
99966 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
99967 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
99968 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
99969 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
99970 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
99971 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
99972 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
99973 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
99974 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
99975 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
99976 +sel_write_access_51704 sel_write_access 3 51704 NULL
99977 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
99978 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
99979 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
99980 +msg_set_51725 msg_set 3 51725 NULL
99981 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
99982 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
99983 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
99984 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
99985 +if_write_51756 if_write 3 51756 NULL
99986 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
99987 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
99988 +__fswab32_51781 __fswab32 0 51781 NULL
99989 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
99990 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
99991 +wm2000_write_51834 wm2000_write 2 51834 NULL
99992 +ioread32_51847 ioread32 0 51847 NULL nohasharray
99993 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
99994 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
99995 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
99996 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
99997 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
99998 +user_read_51881 user_read 3 51881 NULL
99999 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
100000 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
100001 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
100002 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
100003 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
100004 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
100005 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
100006 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
100007 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
100008 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
100009 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
100010 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
100011 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
100012 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
100013 +rdmalt_52022 rdmalt 0 52022 NULL
100014 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
100015 +override_release_52032 override_release 2 52032 NULL
100016 +end_port_52042 end_port 0 52042 NULL
100017 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
100018 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
100019 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
100020 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
100021 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
100022 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
100023 +retry_count_read_52129 retry_count_read 3 52129 NULL
100024 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
100025 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
100026 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
100027 +htable_size_52148 htable_size 0-1 52148 NULL
100028 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
100029 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
100030 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
100031 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
100032 +print_prefix_52176 print_prefix 0 52176 NULL
100033 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
100034 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
100035 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
100036 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
100037 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
100038 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
100039 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
100040 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100041 +read_file_reset_52310 read_file_reset 3 52310 NULL
100042 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
100043 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100044 +hwflags_read_52318 hwflags_read 3 52318 NULL
100045 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
100046 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100047 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100048 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100049 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100050 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
100051 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100052 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100053 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100054 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
100055 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100056 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100057 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100058 +delay_status_52431 delay_status 5 52431 NULL
100059 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100060 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100061 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100062 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100063 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100064 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100065 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100066 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100067 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100068 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100069 +emit_code_52583 emit_code 0-3 52583 NULL
100070 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
100071 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100072 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
100073 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100074 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100075 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100076 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100077 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100078 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100079 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
100080 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100081 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100082 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100083 +twlreg_write_52880 twlreg_write 3 52880 NULL
100084 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
100085 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
100086 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
100087 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
100088 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
100089 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
100090 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
100091 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100092 +send_packet_52960 send_packet 4 52960 NULL
100093 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100094 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
100095 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100096 +num_node_state_52989 num_node_state 0 52989 NULL
100097 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100098 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100099 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100100 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100101 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100102 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100103 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100104 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100105 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100106 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100107 +verity_status_53120 verity_status 5 53120 NULL
100108 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
100109 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100110 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100111 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100112 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100113 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100114 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100115 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100116 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100117 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
100118 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100119 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100120 +vm_mmap_53339 vm_mmap 0 53339 NULL
100121 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100122 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100123 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100124 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
100125 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100126 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100127 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100128 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100129 +n2_run_53459 n2_run 3 53459 NULL
100130 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100131 +wm831x_write_53469 wm831x_write 2 53469 NULL
100132 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100133 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100134 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100135 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100136 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100137 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100138 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100139 +check_acl_53512 check_acl 0 53512 NULL
100140 +set_registers_53582 set_registers 3 53582 NULL
100141 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100142 +__readw_53594 __readw 0 53594 NULL
100143 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
100144 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100145 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100146 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100147 +_preload_range_53676 _preload_range 2-3 53676 NULL
100148 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100149 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100150 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
100151 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
100152 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100153 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100154 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100155 +wdm_write_53735 wdm_write 3 53735 NULL
100156 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100157 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100158 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100159 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100160 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100161 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100162 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100163 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
100164 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100165 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100166 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
100167 +pms_read_53873 pms_read 3 53873 NULL
100168 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100169 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100170 +proc_file_read_53905 proc_file_read 3 53905 NULL
100171 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
100172 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100173 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100174 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100175 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100176 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100177 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100178 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100179 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100180 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100181 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100182 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100183 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100184 +_malloc_54077 _malloc 1 54077 NULL
100185 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100186 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100187 +create_xattr_54106 create_xattr 5 54106 NULL
100188 +strn_len_54122 strn_len 0 54122 NULL
100189 +isku_receive_54130 isku_receive 4 54130 NULL
100190 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100191 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100192 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100193 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100194 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100195 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100196 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100197 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100198 +reada_add_block_54247 reada_add_block 2 54247 NULL
100199 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100200 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100201 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100202 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100203 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100204 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100205 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100206 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100207 +sprintf_54306 sprintf 0 54306 NULL
100208 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100209 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100210 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100211 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100212 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100213 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100214 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100215 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100216 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100217 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100218 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100219 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100220 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100221 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100222 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100223 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100224 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100225 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100226 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
100227 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100228 +viacam_read_54526 viacam_read 3 54526 NULL
100229 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100230 +setsockopt_54539 setsockopt 5 54539 NULL
100231 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100232 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100233 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100234 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100235 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100236 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
100237 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100238 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100239 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100240 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100241 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100242 +evm_read_key_54674 evm_read_key 3 54674 NULL
100243 +resource_string_54699 resource_string 0 54699 NULL
100244 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100245 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100246 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100247 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100248 +kzalloc_54740 kzalloc 1 54740 NULL
100249 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100250 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100251 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100252 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100253 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100254 +domain_init_54797 domain_init 2 54797 NULL
100255 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100256 +nfsd_write_54809 nfsd_write 6 54809 NULL
100257 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100258 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100259 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100260 +write_rio_54837 write_rio 3 54837 NULL
100261 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100262 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100263 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100264 +printer_read_54851 printer_read 3 54851 NULL
100265 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100266 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100267 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100268 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100269 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
100270 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100271 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100272 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100273 +add_port_54941 add_port 2 54941 NULL
100274 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100275 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100276 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100277 +c4_add_card_54968 c4_add_card 3 54968 NULL
100278 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100279 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100280 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100281 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
100282 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100283 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100284 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100285 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100286 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100287 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
100288 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100289 +corrupt_data_55120 corrupt_data 0 55120 NULL
100290 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100291 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100292 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100293 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100294 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100295 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100296 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100297 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100298 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
100299 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
100300 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
100301 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
100302 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100303 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100304 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100305 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100306 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100307 +ptrace_request_55288 ptrace_request 3 55288 NULL
100308 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100309 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
100310 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100311 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
100312 +vme_user_read_55338 vme_user_read 3 55338 NULL
100313 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100314 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100315 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100316 +__send_to_port_55383 __send_to_port 3 55383 NULL
100317 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100318 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100319 +alloc_skb_55439 alloc_skb 1 55439 NULL
100320 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100321 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100322 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100323 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100324 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100325 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100326 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
100327 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100328 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100329 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100330 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100331 +ea_get_55522 ea_get 0 55522 NULL
100332 +buffer_size_55534 buffer_size 0 55534 NULL
100333 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100334 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100335 +add_partition_55588 add_partition 2 55588 NULL
100336 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100337 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
100338 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100339 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100340 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100341 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100342 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100343 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100344 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100345 +read_oldmem_55658 read_oldmem 3 55658 NULL
100346 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100347 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100348 +get_info_55681 get_info 3 55681 NULL
100349 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
100350 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
100351 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
100352 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
100353 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100354 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
100355 +set_local_name_55757 set_local_name 4 55757 NULL
100356 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
100357 +strlen_55778 strlen 0 55778 NULL nohasharray
100358 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
100359 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100360 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100361 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100362 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
100363 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100364 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100365 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100366 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100367 +hsc_write_55875 hsc_write 3 55875 NULL
100368 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100369 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100370 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100371 +handle_response_55951 handle_response 5 55951 NULL
100372 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100373 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100374 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100375 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100376 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100377 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100378 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100379 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100380 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100381 +map_addr_56144 map_addr 7 56144 NULL
100382 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100383 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100384 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100385 +skb_headroom_56200 skb_headroom 0 56200 NULL
100386 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100387 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100388 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100389 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100390 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100391 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
100392 +fd_copyin_56247 fd_copyin 3 56247 NULL
100393 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100394 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100395 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100396 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100397 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100398 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100399 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100400 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100401 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100402 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100403 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100404 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100405 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
100406 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100407 +dev_read_56369 dev_read 3 56369 NULL
100408 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
100409 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
100410 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100411 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100412 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100413 +store_msg_56417 store_msg 3 56417 NULL
100414 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100415 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
100416 +fl_create_56435 fl_create 5 56435 NULL
100417 +gnttab_map_56439 gnttab_map 2 56439 NULL
100418 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100419 +set_connectable_56458 set_connectable 4 56458 NULL
100420 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100421 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100422 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100423 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100424 +ip_options_get_56538 ip_options_get 4 56538 NULL
100425 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100426 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100427 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100428 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100429 +event_filter_write_56609 event_filter_write 3 56609 NULL
100430 +gather_array_56641 gather_array 3 56641 NULL
100431 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100432 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100433 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100434 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100435 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100436 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100437 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100438 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100439 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100440 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100441 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100442 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100443 +do_syslog_56807 do_syslog 3 56807 NULL
100444 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100445 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100446 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100447 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100448 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100449 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100450 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100451 +strcspn_56913 strcspn 0 56913 NULL
100452 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100453 +check_header_56930 check_header 2 56930 NULL
100454 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100455 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100456 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100457 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100458 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100459 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100460 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100461 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100462 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100463 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100464 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100465 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100466 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100467 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100468 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100469 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
100470 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100471 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100472 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100473 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100474 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100475 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100476 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100477 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100478 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100479 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100480 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100481 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100482 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100483 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100484 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100485 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100486 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100487 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100488 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100489 +fw_file_size_57307 fw_file_size 0 57307 NULL
100490 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100491 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100492 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100493 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100494 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100495 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100496 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100497 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100498 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100499 +read_file_blob_57406 read_file_blob 3 57406 NULL
100500 +enclosure_register_57412 enclosure_register 3 57412 NULL
100501 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100502 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
100503 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100504 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100505 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100506 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100507 +ReadReg_57453 ReadReg 0 57453 NULL
100508 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100509 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100510 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100511 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100512 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100513 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100514 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100515 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100516 +skb_headlen_57501 skb_headlen 0 57501 NULL
100517 +copy_in_user_57502 copy_in_user 3 57502 NULL
100518 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100519 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100520 +init_tag_map_57515 init_tag_map 3 57515 NULL
100521 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100522 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100523 +inode_permission_57531 inode_permission 0 57531 NULL
100524 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100525 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100526 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100527 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100528 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
100529 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100530 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100531 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
100532 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
100533 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100534 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100535 +mem_read_57631 mem_read 3 57631 NULL
100536 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100537 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100538 +r3964_write_57662 r3964_write 4 57662 NULL
100539 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100540 +__lgwrite_57669 __lgwrite 4 57669 NULL
100541 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100542 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100543 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100544 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100545 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100546 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100547 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100548 +ld2_57794 ld2 0 57794 NULL
100549 +ivtv_read_57796 ivtv_read 3 57796 NULL
100550 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100551 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100552 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100553 +copy_to_user_57835 copy_to_user 3 57835 NULL
100554 +flash_read_57843 flash_read 3 57843 NULL
100555 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100556 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
100557 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100558 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100559 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100560 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100561 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100562 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100563 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100564 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100565 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100566 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100567 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100568 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100569 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100570 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100571 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100572 +mc13783_write_58033 mc13783_write 2 58033 NULL
100573 +mce_async_out_58056 mce_async_out 3 58056 NULL
100574 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100575 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100576 +cm4040_write_58079 cm4040_write 3 58079 NULL
100577 +udi_log_event_58105 udi_log_event 3 58105 NULL
100578 +savemem_58129 savemem 3 58129 NULL
100579 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100580 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100581 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100582 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100583 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100584 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
100585 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100586 +read_file_debug_58256 read_file_debug 3 58256 NULL
100587 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100588 +profile_load_58267 profile_load 3 58267 NULL
100589 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100590 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100591 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100592 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100593 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100594 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100595 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100596 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
100597 +next_pidmap_58347 next_pidmap 2 58347 NULL
100598 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100599 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100600 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100601 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100602 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100603 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100604 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100605 +capabilities_read_58457 capabilities_read 3 58457 NULL
100606 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100607 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100608 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100609 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100610 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100611 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100612 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
100613 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100614 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100615 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100616 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100617 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100618 +xip_file_read_58592 xip_file_read 3 58592 NULL
100619 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100620 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100621 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100622 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100623 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100624 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100625 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100626 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100627 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100628 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100629 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100630 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100631 +acpi_map_58725 acpi_map 1-2 58725 NULL
100632 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100633 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100634 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100635 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100636 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100637 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100638 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100639 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100640 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100641 +ep_read_58813 ep_read 3 58813 NULL
100642 +command_write_58841 command_write 3 58841 NULL
100643 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100644 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100645 +hw_write_58881 hw_write 2 58881 NULL
100646 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100647 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100648 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100649 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100650 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100651 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100652 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100653 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100654 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100655 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100656 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100657 +ep_write_59008 ep_write 3 59008 NULL
100658 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100659 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100660 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100661 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100662 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100663 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
100664 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100665 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100666 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100667 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100668 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100669 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100670 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100671 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100672 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100673 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100674 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100675 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100676 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100677 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100678 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100679 +dt3155_read_59226 dt3155_read 3 59226 NULL
100680 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100681 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
100682 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100683 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100684 +nla_len_59258 nla_len 0 59258 NULL
100685 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
100686 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100687 +fd_copyout_59323 fd_copyout 3 59323 NULL
100688 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100689 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100690 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
100691 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100692 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100693 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100694 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100695 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
100696 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100697 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100698 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100699 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100700 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100701 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100702 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100703 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
100704 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100705 +tunables_write_59563 tunables_write 3 59563 NULL
100706 +memdup_user_59590 memdup_user 2 59590 NULL
100707 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100708 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100709 +mtrr_write_59622 mtrr_write 3 59622 NULL
100710 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
100711 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100712 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100713 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100714 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100715 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100716 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100717 +wm8400_write_59675 wm8400_write 2 59675 NULL
100718 +sriov_enable_59689 sriov_enable 2 59689 NULL
100719 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100720 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
100721 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100722 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
100723 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100724 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100725 +strnlen_59746 strnlen 0 59746 NULL
100726 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100727 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100728 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100729 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
100730 +venus_remove_59781 venus_remove 4 59781 NULL
100731 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
100732 +ipw_write_59807 ipw_write 3 59807 NULL
100733 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100734 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100735 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100736 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100737 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
100738 +tun_put_user_59849 tun_put_user 4 59849 NULL
100739 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100740 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100741 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100742 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100743 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100744 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
100745 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
100746 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100747 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100748 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100749 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100750 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100751 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100752 +register_device_60015 register_device 2-3 60015 NULL
100753 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100754 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100755 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100756 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
100757 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100758 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100759 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100760 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100761 +load_module_60056 load_module 2 60056 NULL nohasharray
100762 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
100763 +compat_writev_60063 compat_writev 3 60063 NULL
100764 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
100765 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100766 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100767 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100768 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100769 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100770 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100771 +init_state_60165 init_state 2 60165 NULL
100772 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100773 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100774 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100775 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100776 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100777 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100778 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100779 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100780 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100781 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
100782 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
100783 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100784 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100785 +printer_write_60276 printer_write 3 60276 NULL
100786 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100787 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100788 +getDataLength_60301 getDataLength 0 60301 NULL
100789 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100790 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100791 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100792 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100793 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100794 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100795 +driver_names_read_60399 driver_names_read 3 60399 NULL
100796 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100797 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100798 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100799 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100800 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100801 +rx_data_60442 rx_data 4 60442 NULL
100802 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100803 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100804 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100805 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100806 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100807 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100808 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100809 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100810 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
100811 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100812 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100813 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100814 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100815 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100816 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100817 +init_data_container_60709 init_data_container 1 60709 NULL
100818 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100819 +raid_status_60755 raid_status 5 60755 NULL
100820 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100821 +opticon_write_60775 opticon_write 4 60775 NULL
100822 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100823 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100824 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100825 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100826 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
100827 +generic_writepages_60871 generic_writepages 0 60871 NULL
100828 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
100829 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100830 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
100831 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100832 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100833 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100834 +pti_char_write_60960 pti_char_write 3 60960 NULL
100835 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100836 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100837 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100838 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100839 +symtab_init_61050 symtab_init 2 61050 NULL
100840 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100841 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
100842 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100843 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100844 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
100845 +get_derived_key_61100 get_derived_key 4 61100 NULL
100846 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100847 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100848 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100849 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100850 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100851 +__vmalloc_61168 __vmalloc 1 61168 NULL
100852 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100853 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100854 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100855 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100856 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100857 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100858 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100859 +sys_add_key_61288 sys_add_key 4 61288 NULL
100860 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100861 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100862 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100863 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100864 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100865 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100866 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100867 +change_xattr_61390 change_xattr 5 61390 NULL
100868 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100869 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
100870 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100871 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100872 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100873 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100874 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100875 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
100876 +erst_errno_61526 erst_errno 0 61526 NULL
100877 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
100878 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
100879 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
100880 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
100881 +seq_open_private_61589 seq_open_private 3 61589 NULL
100882 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
100883 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
100884 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
100885 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
100886 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
100887 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
100888 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
100889 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
100890 +resize_stripes_61650 resize_stripes 2 61650 NULL
100891 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
100892 +insert_one_name_61668 insert_one_name 7 61668 NULL
100893 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
100894 +lock_loop_61681 lock_loop 1 61681 NULL
100895 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
100896 +filter_read_61692 filter_read 3 61692 NULL
100897 +iov_length_61716 iov_length 0 61716 NULL
100898 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
100899 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
100900 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
100901 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
100902 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
100903 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
100904 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
100905 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
100906 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
100907 +get_fw_name_61874 get_fw_name 3 61874 NULL
100908 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
100909 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
100910 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
100911 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
100912 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
100913 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
100914 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
100915 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
100916 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
100917 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
100918 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
100919 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
100920 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
100921 +cow_file_range_61979 cow_file_range 3 61979 NULL
100922 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
100923 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
100924 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
100925 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
100926 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
100927 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
100928 +do_pselect_62061 do_pselect 1 62061 NULL
100929 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
100930 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
100931 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
100932 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
100933 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
100934 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
100935 +ql_status_62135 ql_status 5 62135 NULL
100936 +video_usercopy_62151 video_usercopy 2 62151 NULL
100937 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
100938 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
100939 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
100940 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
100941 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
100942 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
100943 +allocate_partition_62245 allocate_partition 4 62245 NULL
100944 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
100945 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
100946 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
100947 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
100948 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
100949 +subseq_list_62332 subseq_list 3-0 62332 NULL
100950 +flash_write_62354 flash_write 3 62354 NULL
100951 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
100952 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
100953 +altera_irscan_62396 altera_irscan 2 62396 NULL
100954 +set_ssp_62411 set_ssp 4 62411 NULL
100955 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
100956 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
100957 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
100958 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
100959 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
100960 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
100961 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
100962 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
100963 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
100964 +debugfs_read_62535 debugfs_read 3 62535 NULL
100965 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
100966 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
100967 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
100968 +get_subdir_62581 get_subdir 3 62581 NULL
100969 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
100970 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
100971 +get_desc_base_62617 get_desc_base 0 62617 NULL
100972 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
100973 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
100974 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
100975 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
100976 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
100977 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
100978 +write_62671 write 3 62671 NULL
100979 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
100980 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
100981 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
100982 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
100983 +rdm_62719 rdm 0 62719 NULL
100984 +key_replays_read_62746 key_replays_read 3 62746 NULL
100985 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
100986 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
100987 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
100988 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
100989 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
100990 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
100991 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
100992 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
100993 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
100994 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
100995 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
100996 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
100997 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
100998 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
100999 +getdqbuf_62908 getdqbuf 1 62908 NULL
101000 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
101001 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
101002 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
101003 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
101004 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
101005 +unlink1_63059 unlink1 3 63059 NULL
101006 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
101007 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
101008 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
101009 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
101010 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
101011 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
101012 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
101013 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
101014 +vme_master_read_63221 vme_master_read 0 63221 NULL
101015 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
101016 +ptp_read_63251 ptp_read 4 63251 NULL
101017 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
101018 +raid5_resize_63306 raid5_resize 2 63306 NULL
101019 +proc_info_read_63344 proc_info_read 3 63344 NULL
101020 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
101021 +idmouse_read_63374 idmouse_read 3 63374 NULL
101022 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
101023 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
101024 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
101025 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
101026 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
101027 +kone_send_63435 kone_send 4 63435 NULL
101028 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
101029 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
101030 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
101031 +read_kcore_63488 read_kcore 3 63488 NULL
101032 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
101033 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
101034 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
101035 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
101036 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
101037 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
101038 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
101039 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
101040 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101041 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101042 +module_alloc_63630 module_alloc 1 63630 NULL
101043 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101044 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101045 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101046 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101047 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101048 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101049 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101050 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101051 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101052 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101053 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101054 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101055 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101056 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101057 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101058 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
101059 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101060 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101061 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101062 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101063 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101064 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101065 +sel_write_load_63830 sel_write_load 3 63830 NULL
101066 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101067 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
101068 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101069 +divas_write_63901 divas_write 3 63901 NULL
101070 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101071 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101072 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101073 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101074 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101075 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
101076 +__team_options_register_63941 __team_options_register 3 63941 NULL
101077 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
101078 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
101079 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
101080 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
101081 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
101082 +kmemdup_64015 kmemdup 2 64015 NULL
101083 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
101084 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
101085 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
101086 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
101087 +get_u8_64076 get_u8 0 64076 NULL
101088 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
101089 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
101090 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
101091 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101092 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101093 +init_bch_64130 init_bch 1-2 64130 NULL
101094 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101095 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101096 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101097 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101098 +read_pulse_64227 read_pulse 0-3 64227 NULL
101099 +header_len_64232 header_len 0 64232 NULL
101100 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101101 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101102 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101103 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101104 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101105 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101106 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101107 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101108 +ffz_64324 ffz 0 64324 NULL
101109 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101110 +ts_write_64336 ts_write 3 64336 NULL
101111 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101112 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101113 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101114 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101115 +ilo_write_64378 ilo_write 3 64378 NULL
101116 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101117 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101118 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101119 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101120 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101121 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101122 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101123 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101124 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101125 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
101126 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
101127 +cap_capable_64462 cap_capable 0 64462 NULL
101128 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101129 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101130 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101131 +remove_uuid_64505 remove_uuid 4 64505 NULL
101132 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101133 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101134 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101135 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101136 +__spi_sync_64561 __spi_sync 0 64561 NULL
101137 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101138 +fanotify_write_64623 fanotify_write 3 64623 NULL
101139 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101140 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101141 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101142 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101143 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101144 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101145 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101146 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101147 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101148 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101149 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101150 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101151 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101152 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101153 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101154 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101155 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
101156 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101157 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101158 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101159 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101160 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101161 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101162 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101163 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101164 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101165 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101166 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101167 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101168 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101169 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101170 +pskb_pull_65005 pskb_pull 2 65005 NULL
101171 +unifi_write_65012 unifi_write 3 65012 NULL
101172 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101173 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101174 +insert_dent_65034 insert_dent 7 65034 NULL
101175 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101176 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101177 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101178 +make_idx_node_65068 make_idx_node 0 65068 NULL
101179 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101180 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101181 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
101182 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101183 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101184 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101185 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101186 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
101187 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101188 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101189 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101190 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101191 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
101192 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101193 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101194 +get_var_len_65304 get_var_len 0 65304 NULL
101195 +unpack_array_65318 unpack_array 0 65318 NULL
101196 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101197 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101198 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101199 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101200 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101201 +strchr_65372 strchr 0 65372 NULL
101202 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
101203 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101204 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101205 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101206 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101207 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101208 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101209 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
101210 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101211 +regmap_write_65478 regmap_write 2 65478 NULL
101212 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101213 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101214 +alloc_dr_65495 alloc_dr 2 65495 NULL
101215 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101216 new file mode 100644
101217 index 0000000..9db0d0e
101218 --- /dev/null
101219 +++ b/tools/gcc/size_overflow_plugin.c
101220 @@ -0,0 +1,2114 @@
101221 +/*
101222 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101223 + * Licensed under the GPL v2, or (at your option) v3
101224 + *
101225 + * Homepage:
101226 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101227 + *
101228 + * Documentation:
101229 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101230 + *
101231 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101232 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101233 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101234 + *
101235 + * Usage:
101236 + * $ 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
101237 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101238 + */
101239 +
101240 +#include "gcc-plugin.h"
101241 +#include "config.h"
101242 +#include "system.h"
101243 +#include "coretypes.h"
101244 +#include "tree.h"
101245 +#include "tree-pass.h"
101246 +#include "intl.h"
101247 +#include "plugin-version.h"
101248 +#include "tm.h"
101249 +#include "toplev.h"
101250 +#include "function.h"
101251 +#include "tree-flow.h"
101252 +#include "plugin.h"
101253 +#include "gimple.h"
101254 +#include "diagnostic.h"
101255 +#include "cfgloop.h"
101256 +
101257 +#if BUILDING_GCC_VERSION >= 4008
101258 +#define TODO_dump_func 0
101259 +#endif
101260 +
101261 +struct size_overflow_hash {
101262 + const struct size_overflow_hash * const next;
101263 + const char * const name;
101264 + const unsigned int param;
101265 +};
101266 +
101267 +#include "size_overflow_hash.h"
101268 +
101269 +enum mark {
101270 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101271 +};
101272 +
101273 +enum err_code_conditions {
101274 + CAST_ONLY, FROM_CONST
101275 +};
101276 +
101277 +static unsigned int call_count = 0;
101278 +
101279 +#define __unused __attribute__((__unused__))
101280 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101281 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101282 +#define BEFORE_STMT true
101283 +#define AFTER_STMT false
101284 +#define CREATE_NEW_VAR NULL_TREE
101285 +#define CODES_LIMIT 32
101286 +#define MAX_PARAM 31
101287 +#define MY_STMT GF_PLF_1
101288 +#define NO_CAST_CHECK GF_PLF_2
101289 +#define FROM_ARG true
101290 +#define FROM_RET false
101291 +
101292 +#if BUILDING_GCC_VERSION == 4005
101293 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101294 +#endif
101295 +
101296 +int plugin_is_GPL_compatible;
101297 +void debug_gimple_stmt(gimple gs);
101298 +
101299 +static tree expand(struct pointer_set_t *visited, tree lhs);
101300 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101301 +static tree report_size_overflow_decl;
101302 +static const_tree const_char_ptr_type_node;
101303 +static unsigned int handle_function(void);
101304 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101305 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101306 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101307 +static void print_missing_msg(tree func, unsigned int argnum);
101308 +
101309 +static struct plugin_info size_overflow_plugin_info = {
101310 + .version = "20130410beta",
101311 + .help = "no-size-overflow\tturn off size overflow checking\n",
101312 +};
101313 +
101314 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101315 +{
101316 + unsigned int arg_count;
101317 + enum tree_code code = TREE_CODE(*node);
101318 +
101319 + switch (code) {
101320 + case FUNCTION_DECL:
101321 + arg_count = type_num_arguments(TREE_TYPE(*node));
101322 + break;
101323 + case FUNCTION_TYPE:
101324 + case METHOD_TYPE:
101325 + arg_count = type_num_arguments(*node);
101326 + break;
101327 + default:
101328 + *no_add_attrs = true;
101329 + error("%s: %qE attribute only applies to functions", __func__, name);
101330 + return NULL_TREE;
101331 + }
101332 +
101333 + for (; args; args = TREE_CHAIN(args)) {
101334 + tree position = TREE_VALUE(args);
101335 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101336 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101337 + *no_add_attrs = true;
101338 + }
101339 + }
101340 + return NULL_TREE;
101341 +}
101342 +
101343 +static const char* get_asm_name(tree node)
101344 +{
101345 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101346 +}
101347 +
101348 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101349 +{
101350 + unsigned int arg_count, arg_num;
101351 + enum tree_code code = TREE_CODE(*node);
101352 +
101353 + switch (code) {
101354 + case FUNCTION_DECL:
101355 + arg_count = type_num_arguments(TREE_TYPE(*node));
101356 + break;
101357 + case FUNCTION_TYPE:
101358 + case METHOD_TYPE:
101359 + arg_count = type_num_arguments(*node);
101360 + break;
101361 + case FIELD_DECL:
101362 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101363 + if (arg_num != 0) {
101364 + *no_add_attrs = true;
101365 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101366 + }
101367 + return NULL_TREE;
101368 + default:
101369 + *no_add_attrs = true;
101370 + error("%qE attribute only applies to functions", name);
101371 + return NULL_TREE;
101372 + }
101373 +
101374 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101375 + return NULL_TREE;
101376 +
101377 + for (; args; args = TREE_CHAIN(args)) {
101378 + tree position = TREE_VALUE(args);
101379 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101380 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101381 + *no_add_attrs = true;
101382 + }
101383 + }
101384 + return NULL_TREE;
101385 +}
101386 +
101387 +static struct attribute_spec size_overflow_attr = {
101388 + .name = "size_overflow",
101389 + .min_length = 1,
101390 + .max_length = -1,
101391 + .decl_required = true,
101392 + .type_required = false,
101393 + .function_type_required = false,
101394 + .handler = handle_size_overflow_attribute,
101395 +#if BUILDING_GCC_VERSION >= 4007
101396 + .affects_type_identity = false
101397 +#endif
101398 +};
101399 +
101400 +static struct attribute_spec intentional_overflow_attr = {
101401 + .name = "intentional_overflow",
101402 + .min_length = 1,
101403 + .max_length = -1,
101404 + .decl_required = true,
101405 + .type_required = false,
101406 + .function_type_required = false,
101407 + .handler = handle_intentional_overflow_attribute,
101408 +#if BUILDING_GCC_VERSION >= 4007
101409 + .affects_type_identity = false
101410 +#endif
101411 +};
101412 +
101413 +static void register_attributes(void __unused *event_data, void __unused *data)
101414 +{
101415 + register_attribute(&size_overflow_attr);
101416 + register_attribute(&intentional_overflow_attr);
101417 +}
101418 +
101419 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101420 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101421 +{
101422 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101423 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101424 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101425 +
101426 + unsigned int m = 0x57559429;
101427 + unsigned int n = 0x5052acdb;
101428 + const unsigned int *key4 = (const unsigned int *)key;
101429 + unsigned int h = len;
101430 + unsigned int k = len + seed + n;
101431 + unsigned long long p;
101432 +
101433 + while (len >= 8) {
101434 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101435 + len -= 8;
101436 + }
101437 + if (len >= 4) {
101438 + cwmixb(key4[0]) key4 += 1;
101439 + len -= 4;
101440 + }
101441 + if (len)
101442 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101443 + cwmixb(h ^ (k + n));
101444 + return k ^ h;
101445 +
101446 +#undef cwfold
101447 +#undef cwmixa
101448 +#undef cwmixb
101449 +}
101450 +
101451 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101452 +{
101453 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101454 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101455 + return fn ^ codes;
101456 +}
101457 +
101458 +static inline tree get_original_function_decl(tree fndecl)
101459 +{
101460 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101461 + return DECL_ABSTRACT_ORIGIN(fndecl);
101462 + return fndecl;
101463 +}
101464 +
101465 +static inline gimple get_def_stmt(const_tree node)
101466 +{
101467 + gcc_assert(node != NULL_TREE);
101468 + if (TREE_CODE(node) != SSA_NAME)
101469 + return NULL;
101470 + return SSA_NAME_DEF_STMT(node);
101471 +}
101472 +
101473 +static unsigned char get_tree_code(const_tree type)
101474 +{
101475 + switch (TREE_CODE(type)) {
101476 + case ARRAY_TYPE:
101477 + return 0;
101478 + case BOOLEAN_TYPE:
101479 + return 1;
101480 + case ENUMERAL_TYPE:
101481 + return 2;
101482 + case FUNCTION_TYPE:
101483 + return 3;
101484 + case INTEGER_TYPE:
101485 + return 4;
101486 + case POINTER_TYPE:
101487 + return 5;
101488 + case RECORD_TYPE:
101489 + return 6;
101490 + case UNION_TYPE:
101491 + return 7;
101492 + case VOID_TYPE:
101493 + return 8;
101494 + case REAL_TYPE:
101495 + return 9;
101496 + case VECTOR_TYPE:
101497 + return 10;
101498 + case REFERENCE_TYPE:
101499 + return 11;
101500 + case OFFSET_TYPE:
101501 + return 12;
101502 + case COMPLEX_TYPE:
101503 + return 13;
101504 + default:
101505 + debug_tree((tree)type);
101506 + gcc_unreachable();
101507 + }
101508 +}
101509 +
101510 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101511 +{
101512 + gcc_assert(type != NULL_TREE);
101513 +
101514 + while (type && len < CODES_LIMIT) {
101515 + tree_codes[len] = get_tree_code(type);
101516 + len++;
101517 + type = TREE_TYPE(type);
101518 + }
101519 + return len;
101520 +}
101521 +
101522 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101523 +{
101524 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101525 + enum tree_code code = TREE_CODE(type);
101526 + size_t len = 0;
101527 +
101528 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101529 +
101530 + arg = TYPE_ARG_TYPES(type);
101531 + // skip builtins __builtin_constant_p
101532 + if (!arg && DECL_BUILT_IN(fndecl))
101533 + return 0;
101534 +
101535 + if (TREE_CODE_CLASS(code) == tcc_type)
101536 + result = type;
101537 + else
101538 + result = DECL_RESULT(fndecl);
101539 +
101540 + gcc_assert(result != NULL_TREE);
101541 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101542 +
101543 + if (arg == NULL_TREE) {
101544 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101545 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101546 + if (arg_field == NULL_TREE)
101547 + return 0;
101548 + arg = TREE_TYPE(arg_field);
101549 + len = add_type_codes(arg, tree_codes, len);
101550 + gcc_assert(len != 0);
101551 + return len;
101552 + }
101553 +
101554 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101555 + while (arg && len < CODES_LIMIT) {
101556 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101557 + arg = TREE_CHAIN(arg);
101558 + }
101559 +
101560 + gcc_assert(len != 0);
101561 + return len;
101562 +}
101563 +
101564 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101565 +{
101566 + unsigned int hash;
101567 + const struct size_overflow_hash *entry;
101568 + unsigned char tree_codes[CODES_LIMIT];
101569 + size_t len;
101570 + const char *func_name;
101571 +
101572 + fndecl = get_original_function_decl(fndecl);
101573 + len = get_function_decl(fndecl, tree_codes);
101574 + if (len == 0)
101575 + return NULL;
101576 +
101577 + func_name = get_asm_name(fndecl);
101578 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101579 +
101580 + entry = size_overflow_hash[hash];
101581 + while (entry) {
101582 + if (!strcmp(entry->name, func_name))
101583 + return entry;
101584 + entry = entry->next;
101585 + }
101586 +
101587 + return NULL;
101588 +}
101589 +
101590 +static bool is_bool(const_tree node)
101591 +{
101592 + const_tree type;
101593 +
101594 + if (node == NULL_TREE)
101595 + return false;
101596 +
101597 + type = TREE_TYPE(node);
101598 + if (!INTEGRAL_TYPE_P(type))
101599 + return false;
101600 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101601 + return true;
101602 + if (TYPE_PRECISION(type) == 1)
101603 + return true;
101604 + return false;
101605 +}
101606 +
101607 +static bool skip_types(const_tree var)
101608 +{
101609 + tree type;
101610 +
101611 + if (is_gimple_constant(var))
101612 + return true;
101613 +
101614 + switch (TREE_CODE(var)) {
101615 + case ADDR_EXPR:
101616 +#if BUILDING_GCC_VERSION >= 4006
101617 + case MEM_REF:
101618 +#endif
101619 + case ARRAY_REF:
101620 + case BIT_FIELD_REF:
101621 + case INDIRECT_REF:
101622 + case TARGET_MEM_REF:
101623 + return true;
101624 + case PARM_DECL:
101625 + case VAR_DECL:
101626 + case COMPONENT_REF:
101627 + return false;
101628 + default:
101629 + break;
101630 + }
101631 +
101632 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101633 +
101634 + type = TREE_TYPE(var);
101635 + switch (TREE_CODE(type)) {
101636 + case INTEGER_TYPE:
101637 + case ENUMERAL_TYPE:
101638 + return false;
101639 + case BOOLEAN_TYPE:
101640 + return is_bool(var);
101641 + default:
101642 + break;
101643 + }
101644 +
101645 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101646 +
101647 + type = TREE_TYPE(type);
101648 + gcc_assert(type != NULL_TREE);
101649 + switch (TREE_CODE(type)) {
101650 + case RECORD_TYPE:
101651 + case POINTER_TYPE:
101652 + case ARRAY_TYPE:
101653 + return true;
101654 + case VOID_TYPE:
101655 + case INTEGER_TYPE:
101656 + case UNION_TYPE:
101657 + return false;
101658 + default:
101659 + break;
101660 + }
101661 +
101662 + debug_tree((tree)var);
101663 + gcc_unreachable();
101664 +}
101665 +
101666 +static unsigned int find_arg_number(const_tree arg, tree func)
101667 +{
101668 + tree var;
101669 + unsigned int argnum = 1;
101670 +
101671 + if (TREE_CODE(arg) == SSA_NAME)
101672 + arg = SSA_NAME_VAR(arg);
101673 +
101674 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101675 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101676 + continue;
101677 + if (!skip_types(var))
101678 + return argnum;
101679 + }
101680 +
101681 + return 0;
101682 +}
101683 +
101684 +static tree create_new_var(tree type)
101685 +{
101686 + tree new_var = create_tmp_var(type, "cicus");
101687 +
101688 +#if BUILDING_GCC_VERSION <= 4007
101689 + add_referenced_var(new_var);
101690 + mark_sym_for_renaming(new_var);
101691 +#endif
101692 + return new_var;
101693 +}
101694 +
101695 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101696 +{
101697 + gimple assign;
101698 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101699 + tree type = TREE_TYPE(rhs1);
101700 + tree lhs = create_new_var(type);
101701 +
101702 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101703 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101704 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101705 +
101706 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101707 + update_stmt(assign);
101708 + gimple_set_plf(assign, MY_STMT, true);
101709 + return assign;
101710 +}
101711 +
101712 +static tree cast_a_tree(tree type, tree var)
101713 +{
101714 + gcc_assert(type != NULL_TREE);
101715 + gcc_assert(var != NULL_TREE);
101716 + gcc_assert(fold_convertible_p(type, var));
101717 +
101718 + return fold_convert(type, var);
101719 +}
101720 +
101721 +static tree get_lhs(const_gimple stmt)
101722 +{
101723 + switch (gimple_code(stmt)) {
101724 + case GIMPLE_ASSIGN:
101725 + return gimple_get_lhs(stmt);
101726 + case GIMPLE_PHI:
101727 + return gimple_phi_result(stmt);
101728 + case GIMPLE_CALL:
101729 + return gimple_call_lhs(stmt);
101730 + default:
101731 + return NULL_TREE;
101732 + }
101733 +}
101734 +
101735 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101736 +{
101737 + const_gimple def_stmt = get_def_stmt(rhs);
101738 +
101739 + if (force)
101740 + return false;
101741 +
101742 + if (is_gimple_constant(rhs))
101743 + return false;
101744 +
101745 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101746 + return false;
101747 +
101748 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101749 + return false;
101750 +
101751 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101752 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101753 + return false;
101754 +
101755 + return true;
101756 +}
101757 +
101758 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101759 +{
101760 + gimple assign, def_stmt;
101761 +
101762 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101763 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101764 + gcc_unreachable();
101765 +
101766 + def_stmt = get_def_stmt(rhs);
101767 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101768 + return def_stmt;
101769 +
101770 + if (lhs == CREATE_NEW_VAR)
101771 + lhs = create_new_var(dst_type);
101772 +
101773 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101774 +
101775 + if (!gsi_end_p(*gsi)) {
101776 + location_t loc = gimple_location(gsi_stmt(*gsi));
101777 + gimple_set_location(assign, loc);
101778 + }
101779 +
101780 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101781 +
101782 + if (before)
101783 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101784 + else
101785 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101786 + update_stmt(assign);
101787 + gimple_set_plf(assign, MY_STMT, true);
101788 +
101789 + return assign;
101790 +}
101791 +
101792 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101793 +{
101794 + gimple_stmt_iterator gsi;
101795 + tree lhs;
101796 + const_gimple new_stmt;
101797 +
101798 + if (rhs == NULL_TREE)
101799 + return NULL_TREE;
101800 +
101801 + gsi = gsi_for_stmt(stmt);
101802 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101803 +
101804 + lhs = get_lhs(new_stmt);
101805 + gcc_assert(lhs != NULL_TREE);
101806 + return lhs;
101807 +}
101808 +
101809 +static tree cast_to_TI_type(gimple stmt, tree node)
101810 +{
101811 + gimple_stmt_iterator gsi;
101812 + gimple cast_stmt;
101813 + tree type = TREE_TYPE(node);
101814 +
101815 + if (types_compatible_p(type, intTI_type_node))
101816 + return node;
101817 +
101818 + gsi = gsi_for_stmt(stmt);
101819 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101820 + return gimple_get_lhs(cast_stmt);
101821 +}
101822 +
101823 +static void check_function_hash(const_gimple stmt)
101824 +{
101825 + tree func;
101826 + const struct size_overflow_hash *hash;
101827 +
101828 + if (gimple_code(stmt) != GIMPLE_CALL)
101829 + return;
101830 +
101831 + func = gimple_call_fndecl(stmt);
101832 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101833 + if (func == NULL_TREE)
101834 + return;
101835 +
101836 + hash = get_function_hash(func);
101837 + if (!hash)
101838 + print_missing_msg(func, 0);
101839 +}
101840 +
101841 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101842 +{
101843 + tree lhs, new_lhs;
101844 + gimple_stmt_iterator gsi;
101845 +
101846 + if (rhs1 == NULL_TREE) {
101847 + debug_gimple_stmt(oldstmt);
101848 + error("%s: rhs1 is NULL_TREE", __func__);
101849 + gcc_unreachable();
101850 + }
101851 +
101852 + switch (gimple_code(oldstmt)) {
101853 + case GIMPLE_ASM:
101854 + lhs = rhs1;
101855 + break;
101856 + case GIMPLE_CALL:
101857 + lhs = gimple_call_lhs(oldstmt);
101858 + break;
101859 + case GIMPLE_ASSIGN:
101860 + lhs = gimple_get_lhs(oldstmt);
101861 + break;
101862 + default:
101863 + debug_gimple_stmt(oldstmt);
101864 + gcc_unreachable();
101865 + }
101866 +
101867 + gsi = gsi_for_stmt(oldstmt);
101868 + pointer_set_insert(visited, oldstmt);
101869 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101870 + basic_block next_bb, cur_bb;
101871 + const_edge e;
101872 +
101873 + gcc_assert(before == false);
101874 + gcc_assert(stmt_can_throw_internal(oldstmt));
101875 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
101876 + gcc_assert(!gsi_end_p(gsi));
101877 +
101878 + cur_bb = gimple_bb(oldstmt);
101879 + next_bb = cur_bb->next_bb;
101880 + e = find_edge(cur_bb, next_bb);
101881 + gcc_assert(e != NULL);
101882 + gcc_assert(e->flags & EDGE_FALLTHRU);
101883 +
101884 + gsi = gsi_after_labels(next_bb);
101885 + gcc_assert(!gsi_end_p(gsi));
101886 +
101887 + before = true;
101888 + oldstmt = gsi_stmt(gsi);
101889 + }
101890 +
101891 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
101892 + return new_lhs;
101893 +}
101894 +
101895 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
101896 +{
101897 + gimple stmt;
101898 + gimple_stmt_iterator gsi;
101899 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
101900 +
101901 + if (gimple_plf(oldstmt, MY_STMT))
101902 + return lhs;
101903 +
101904 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
101905 + rhs1 = gimple_assign_rhs1(oldstmt);
101906 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
101907 + }
101908 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
101909 + rhs2 = gimple_assign_rhs2(oldstmt);
101910 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
101911 + }
101912 +
101913 + stmt = gimple_copy(oldstmt);
101914 + gimple_set_location(stmt, gimple_location(oldstmt));
101915 + gimple_set_plf(stmt, MY_STMT, true);
101916 +
101917 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
101918 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
101919 +
101920 + size_overflow_type = get_size_overflow_type(oldstmt, node);
101921 +
101922 + new_var = create_new_var(size_overflow_type);
101923 + new_var = make_ssa_name(new_var, stmt);
101924 + gimple_set_lhs(stmt, new_var);
101925 +
101926 + if (rhs1 != NULL_TREE)
101927 + gimple_assign_set_rhs1(stmt, rhs1);
101928 +
101929 + if (rhs2 != NULL_TREE)
101930 + gimple_assign_set_rhs2(stmt, rhs2);
101931 +#if BUILDING_GCC_VERSION >= 4007
101932 + if (rhs3 != NULL_TREE)
101933 + gimple_assign_set_rhs3(stmt, rhs3);
101934 +#endif
101935 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
101936 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
101937 +
101938 + gsi = gsi_for_stmt(oldstmt);
101939 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
101940 + update_stmt(stmt);
101941 + pointer_set_insert(visited, oldstmt);
101942 + return gimple_get_lhs(stmt);
101943 +}
101944 +
101945 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
101946 +{
101947 + basic_block first_bb;
101948 + gimple assign;
101949 + gimple_stmt_iterator gsi;
101950 +
101951 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101952 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101953 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
101954 +
101955 + gsi = gsi_start_bb(first_bb);
101956 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101957 + return gimple_get_lhs(assign);
101958 +}
101959 +
101960 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
101961 +{
101962 + gimple_stmt_iterator gsi;
101963 + const_gimple assign;
101964 + gimple def_stmt = get_def_stmt(new_arg);
101965 +
101966 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
101967 + gsi = gsi_after_labels(gimple_bb(def_stmt));
101968 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
101969 + } else {
101970 + gsi = gsi_for_stmt(def_stmt);
101971 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
101972 + }
101973 +
101974 + return gimple_get_lhs(assign);
101975 +}
101976 +
101977 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
101978 +{
101979 + basic_block bb;
101980 + gimple_stmt_iterator gsi;
101981 + const_gimple assign, def_stmt;
101982 +
101983 + def_stmt = get_def_stmt(arg);
101984 + bb = gimple_bb(def_stmt);
101985 + gcc_assert(bb->index != 0);
101986 + gsi = gsi_after_labels(bb);
101987 +
101988 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101989 + return gimple_get_lhs(assign);
101990 +}
101991 +
101992 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
101993 +{
101994 + tree size_overflow_type;
101995 + const_gimple def_stmt = get_def_stmt(arg);
101996 +
101997 + if (phi_ssa_name != NULL_TREE)
101998 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
101999 +
102000 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
102001 +
102002 + if (new_arg != NULL_TREE) {
102003 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
102004 + return use_phi_ssa_name(phi_ssa_name, new_arg);
102005 + }
102006 +
102007 + switch(gimple_code(def_stmt)) {
102008 + case GIMPLE_PHI:
102009 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
102010 + case GIMPLE_NOP:
102011 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
102012 + default:
102013 + debug_gimple_stmt((gimple)def_stmt);
102014 + gcc_unreachable();
102015 + }
102016 +}
102017 +
102018 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
102019 +{
102020 + basic_block bb;
102021 + gimple phi;
102022 + gimple_seq seq;
102023 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
102024 +
102025 + bb = gsi_bb(gsi);
102026 +
102027 + phi = create_phi_node(result, bb);
102028 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
102029 + seq = phi_nodes(bb);
102030 + gsi = gsi_last(seq);
102031 + gsi_remove(&gsi, false);
102032 +
102033 + gsi = gsi_for_stmt(oldstmt);
102034 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
102035 + gimple_set_bb(phi, bb);
102036 + gimple_set_plf(phi, MY_STMT, true);
102037 + return phi;
102038 +}
102039 +
102040 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102041 +{
102042 + gimple new_phi = NULL;
102043 + gimple oldstmt = get_def_stmt(orig_result);
102044 + tree phi_ssa_name = NULL_TREE;
102045 + unsigned int i;
102046 +
102047 + pointer_set_insert(visited, oldstmt);
102048 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102049 + tree arg, new_arg;
102050 +
102051 + arg = gimple_phi_arg_def(oldstmt, i);
102052 +
102053 + new_arg = expand(visited, arg);
102054 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102055 + if (i == 0) {
102056 + phi_ssa_name = new_arg;
102057 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102058 + }
102059 +
102060 + gcc_assert(new_phi != NULL);
102061 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102062 + }
102063 +
102064 + gcc_assert(new_phi != NULL);
102065 + update_stmt(new_phi);
102066 + return gimple_phi_result(new_phi);
102067 +}
102068 +
102069 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
102070 +{
102071 + const_gimple assign;
102072 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102073 + tree origtype = TREE_TYPE(orig_rhs);
102074 +
102075 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
102076 +
102077 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102078 + return gimple_get_lhs(assign);
102079 +}
102080 +
102081 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
102082 +{
102083 + const_tree rhs1, lhs, rhs1_type, lhs_type;
102084 + enum machine_mode lhs_mode, rhs_mode;
102085 + gimple def_stmt = get_def_stmt(no_const_rhs);
102086 +
102087 + if (!gimple_assign_cast_p(def_stmt))
102088 + return false;
102089 +
102090 + rhs1 = gimple_assign_rhs1(def_stmt);
102091 + lhs = gimple_get_lhs(def_stmt);
102092 + rhs1_type = TREE_TYPE(rhs1);
102093 + lhs_type = TREE_TYPE(lhs);
102094 + rhs_mode = TYPE_MODE(rhs1_type);
102095 + lhs_mode = TYPE_MODE(lhs_type);
102096 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102097 + return false;
102098 +
102099 + return true;
102100 +}
102101 +
102102 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102103 +{
102104 + tree rhs1 = gimple_assign_rhs1(stmt);
102105 + tree lhs = gimple_get_lhs(stmt);
102106 + const_tree rhs1_type = TREE_TYPE(rhs1);
102107 + const_tree lhs_type = TREE_TYPE(lhs);
102108 +
102109 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102110 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102111 +
102112 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102113 +}
102114 +
102115 +static bool no_uses(tree node)
102116 +{
102117 + imm_use_iterator imm_iter;
102118 + use_operand_p use_p;
102119 +
102120 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102121 + const_gimple use_stmt = USE_STMT(use_p);
102122 + if (use_stmt == NULL)
102123 + return true;
102124 + if (is_gimple_debug(use_stmt))
102125 + continue;
102126 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102127 + continue;
102128 + return false;
102129 + }
102130 + return true;
102131 +}
102132 +
102133 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102134 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102135 +{
102136 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102137 + gimple def_stmt = get_def_stmt(lhs);
102138 +
102139 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102140 + return false;
102141 +
102142 + rhs1 = gimple_assign_rhs1(def_stmt);
102143 + rhs_type = TREE_TYPE(rhs1);
102144 + lhs_type = TREE_TYPE(lhs);
102145 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102146 + return false;
102147 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102148 + return false;
102149 +
102150 + def_stmt = get_def_stmt(rhs1);
102151 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102152 + return false;
102153 +
102154 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102155 + return false;
102156 +
102157 + rhs1 = gimple_assign_rhs1(def_stmt);
102158 + rhs2 = gimple_assign_rhs2(def_stmt);
102159 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102160 + return false;
102161 +
102162 + if (is_gimple_constant(rhs2))
102163 + not_const_rhs = rhs1;
102164 + else
102165 + not_const_rhs = rhs2;
102166 +
102167 + return no_uses(not_const_rhs);
102168 +}
102169 +
102170 +static bool skip_lhs_cast_check(const_gimple stmt)
102171 +{
102172 + const_tree rhs = gimple_assign_rhs1(stmt);
102173 + const_gimple def_stmt = get_def_stmt(rhs);
102174 +
102175 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102176 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102177 + return true;
102178 +
102179 + if (is_const_plus_unsigned_signed_truncation(rhs))
102180 + return true;
102181 +
102182 + return false;
102183 +}
102184 +
102185 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102186 +{
102187 + bool cast_lhs, cast_rhs;
102188 + tree lhs = gimple_get_lhs(stmt);
102189 + tree rhs = gimple_assign_rhs1(stmt);
102190 + const_tree lhs_type = TREE_TYPE(lhs);
102191 + const_tree rhs_type = TREE_TYPE(rhs);
102192 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102193 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102194 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102195 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102196 +
102197 + static bool check_lhs[3][4] = {
102198 + // ss su us uu
102199 + { false, true, true, false }, // lhs > rhs
102200 + { false, false, false, false }, // lhs = rhs
102201 + { true, true, true, true }, // lhs < rhs
102202 + };
102203 +
102204 + static bool check_rhs[3][4] = {
102205 + // ss su us uu
102206 + { true, false, true, true }, // lhs > rhs
102207 + { true, false, true, true }, // lhs = rhs
102208 + { true, false, true, true }, // lhs < rhs
102209 + };
102210 +
102211 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102212 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102213 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102214 +
102215 + if (lhs_size > rhs_size) {
102216 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102217 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102218 + } else if (lhs_size == rhs_size) {
102219 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102220 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102221 + } else {
102222 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102223 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102224 + }
102225 +
102226 + if (!cast_lhs && !cast_rhs)
102227 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102228 +
102229 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102230 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102231 +
102232 + if (cast_rhs)
102233 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102234 +
102235 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102236 +}
102237 +
102238 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102239 +{
102240 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102241 +
102242 + if (gimple_plf(stmt, MY_STMT))
102243 + return lhs;
102244 +
102245 + rhs1 = gimple_assign_rhs1(stmt);
102246 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102247 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102248 +
102249 + new_rhs1 = expand(visited, rhs1);
102250 +
102251 + if (new_rhs1 == NULL_TREE)
102252 + return create_cast_assign(visited, stmt);
102253 +
102254 + if (gimple_plf(stmt, NO_CAST_CHECK))
102255 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102256 +
102257 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102258 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102259 +
102260 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102261 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102262 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102263 + }
102264 +
102265 + if (!gimple_assign_cast_p(stmt))
102266 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102267 +
102268 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102269 +}
102270 +
102271 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102272 +{
102273 + tree rhs1, lhs = gimple_get_lhs(stmt);
102274 + gimple def_stmt = get_def_stmt(lhs);
102275 +
102276 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102277 + rhs1 = gimple_assign_rhs1(def_stmt);
102278 +
102279 + if (is_gimple_constant(rhs1))
102280 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102281 +
102282 + switch (TREE_CODE(rhs1)) {
102283 + case SSA_NAME:
102284 + return handle_unary_rhs(visited, def_stmt);
102285 + case ARRAY_REF:
102286 + case BIT_FIELD_REF:
102287 + case ADDR_EXPR:
102288 + case COMPONENT_REF:
102289 + case INDIRECT_REF:
102290 +#if BUILDING_GCC_VERSION >= 4006
102291 + case MEM_REF:
102292 +#endif
102293 + case TARGET_MEM_REF:
102294 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102295 + case PARM_DECL:
102296 + case VAR_DECL:
102297 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102298 +
102299 + default:
102300 + debug_gimple_stmt(def_stmt);
102301 + debug_tree(rhs1);
102302 + gcc_unreachable();
102303 + }
102304 +}
102305 +
102306 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102307 +{
102308 + gimple cond_stmt;
102309 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102310 +
102311 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102312 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102313 + update_stmt(cond_stmt);
102314 +}
102315 +
102316 +static tree create_string_param(tree string)
102317 +{
102318 + tree i_type, a_type;
102319 + const int length = TREE_STRING_LENGTH(string);
102320 +
102321 + gcc_assert(length > 0);
102322 +
102323 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102324 + a_type = build_array_type(char_type_node, i_type);
102325 +
102326 + TREE_TYPE(string) = a_type;
102327 + TREE_CONSTANT(string) = 1;
102328 + TREE_READONLY(string) = 1;
102329 +
102330 + return build1(ADDR_EXPR, ptr_type_node, string);
102331 +}
102332 +
102333 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
102334 +{
102335 + gimple func_stmt;
102336 + const_gimple def_stmt;
102337 + const_tree loc_line;
102338 + tree loc_file, ssa_name, current_func;
102339 + expanded_location xloc;
102340 + char *ssa_name_buf;
102341 + int len;
102342 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102343 +
102344 + def_stmt = get_def_stmt(arg);
102345 + xloc = expand_location(gimple_location(def_stmt));
102346 +
102347 + if (!gimple_has_location(def_stmt)) {
102348 + xloc = expand_location(gimple_location(stmt));
102349 + if (!gimple_has_location(stmt))
102350 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102351 + }
102352 +
102353 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102354 +
102355 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102356 + loc_file = create_string_param(loc_file);
102357 +
102358 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102359 + current_func = create_string_param(current_func);
102360 +
102361 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102362 + call_count++;
102363 + 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);
102364 + gcc_assert(len > 0);
102365 + ssa_name = build_string(len + 1, ssa_name_buf);
102366 + free(ssa_name_buf);
102367 + ssa_name = create_string_param(ssa_name);
102368 +
102369 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102370 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102371 +
102372 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102373 +}
102374 +
102375 +static void __unused print_the_code_insertions(const_gimple stmt)
102376 +{
102377 + location_t loc = gimple_location(stmt);
102378 +
102379 + inform(loc, "Integer size_overflow check applied here.");
102380 +}
102381 +
102382 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102383 +{
102384 + basic_block cond_bb, join_bb, bb_true;
102385 + edge e;
102386 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102387 +
102388 + cond_bb = gimple_bb(stmt);
102389 + if (before)
102390 + gsi_prev(&gsi);
102391 + if (gsi_end_p(gsi))
102392 + e = split_block_after_labels(cond_bb);
102393 + else
102394 + e = split_block(cond_bb, gsi_stmt(gsi));
102395 + cond_bb = e->src;
102396 + join_bb = e->dest;
102397 + e->flags = EDGE_FALSE_VALUE;
102398 + e->probability = REG_BR_PROB_BASE;
102399 +
102400 + bb_true = create_empty_bb(cond_bb);
102401 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102402 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102403 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102404 +
102405 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102406 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102407 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102408 +
102409 + if (current_loops != NULL) {
102410 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102411 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102412 + }
102413 +
102414 + insert_cond(cond_bb, arg, cond_code, type_value);
102415 + insert_cond_result(bb_true, stmt, arg, min);
102416 +
102417 +// print_the_code_insertions(stmt);
102418 +}
102419 +
102420 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102421 +{
102422 + const_tree rhs_type = TREE_TYPE(rhs);
102423 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102424 +
102425 + gcc_assert(rhs_type != NULL_TREE);
102426 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102427 + return;
102428 +
102429 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102430 +
102431 + if (is_const_plus_unsigned_signed_truncation(rhs))
102432 + return;
102433 +
102434 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102435 + // typemax (-1) < typemin (0)
102436 + if (TREE_OVERFLOW(type_max))
102437 + return;
102438 +
102439 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102440 +
102441 + cast_rhs_type = TREE_TYPE(cast_rhs);
102442 + type_max_type = TREE_TYPE(type_max);
102443 + type_min_type = TREE_TYPE(type_min);
102444 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102445 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102446 +
102447 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102448 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102449 +}
102450 +
102451 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102452 +{
102453 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102454 + return false;
102455 + if (!is_gimple_constant(rhs))
102456 + return false;
102457 + return true;
102458 +}
102459 +
102460 +static tree get_def_stmt_rhs(const_tree var)
102461 +{
102462 + tree rhs1, def_stmt_rhs1;
102463 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102464 +
102465 + def_stmt = get_def_stmt(var);
102466 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102467 +
102468 + rhs1 = gimple_assign_rhs1(def_stmt);
102469 + rhs1_def_stmt = get_def_stmt(rhs1);
102470 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102471 + return rhs1;
102472 +
102473 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102474 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102475 +
102476 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102477 + case GIMPLE_CALL:
102478 + case GIMPLE_NOP:
102479 + case GIMPLE_ASM:
102480 + case GIMPLE_PHI:
102481 + return def_stmt_rhs1;
102482 + case GIMPLE_ASSIGN:
102483 + return rhs1;
102484 + default:
102485 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102486 + gcc_unreachable();
102487 + }
102488 +}
102489 +
102490 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102491 +{
102492 + tree new_rhs, orig_rhs;
102493 + void (*gimple_assign_set_rhs)(gimple, tree);
102494 + tree rhs1 = gimple_assign_rhs1(stmt);
102495 + tree rhs2 = gimple_assign_rhs2(stmt);
102496 + tree lhs = gimple_get_lhs(stmt);
102497 +
102498 + if (!check_overflow)
102499 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102500 +
102501 + if (change_rhs == NULL_TREE)
102502 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102503 +
102504 + if (new_rhs2 == NULL_TREE) {
102505 + orig_rhs = rhs1;
102506 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102507 + } else {
102508 + orig_rhs = rhs2;
102509 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102510 + }
102511 +
102512 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102513 +
102514 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102515 + gimple_assign_set_rhs(stmt, new_rhs);
102516 + update_stmt(stmt);
102517 +
102518 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102519 +}
102520 +
102521 +static bool is_subtraction_special(const_gimple stmt)
102522 +{
102523 + gimple rhs1_def_stmt, rhs2_def_stmt;
102524 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102525 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102526 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102527 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102528 +
102529 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102530 + return false;
102531 +
102532 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102533 +
102534 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102535 + return false;
102536 +
102537 + rhs1_def_stmt = get_def_stmt(rhs1);
102538 + rhs2_def_stmt = get_def_stmt(rhs2);
102539 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102540 + return false;
102541 +
102542 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102543 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102544 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102545 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102546 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102547 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102548 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102549 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102550 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102551 + return false;
102552 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102553 + return false;
102554 +
102555 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102556 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102557 + return true;
102558 +}
102559 +
102560 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102561 +{
102562 + tree new_rhs1, new_rhs2;
102563 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102564 + gimple assign, stmt = get_def_stmt(lhs);
102565 + tree rhs1 = gimple_assign_rhs1(stmt);
102566 + tree rhs2 = gimple_assign_rhs2(stmt);
102567 +
102568 + if (!is_subtraction_special(stmt))
102569 + return NULL_TREE;
102570 +
102571 + new_rhs1 = expand(visited, rhs1);
102572 + new_rhs2 = expand(visited, rhs2);
102573 +
102574 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102575 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102576 +
102577 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102578 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102579 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102580 + }
102581 +
102582 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102583 + new_lhs = gimple_get_lhs(assign);
102584 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102585 +
102586 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102587 +}
102588 +
102589 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102590 +{
102591 + const_gimple def_stmt;
102592 +
102593 + if (TREE_CODE(rhs) != SSA_NAME)
102594 + return false;
102595 +
102596 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102597 + return false;
102598 +
102599 + def_stmt = get_def_stmt(rhs);
102600 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102601 + return false;
102602 +
102603 + return true;
102604 +}
102605 +
102606 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102607 +{
102608 + tree rhs1, rhs2, new_lhs;
102609 + gimple def_stmt = get_def_stmt(lhs);
102610 + tree new_rhs1 = NULL_TREE;
102611 + tree new_rhs2 = NULL_TREE;
102612 +
102613 + rhs1 = gimple_assign_rhs1(def_stmt);
102614 + rhs2 = gimple_assign_rhs2(def_stmt);
102615 +
102616 + /* no DImode/TImode division in the 32/64 bit kernel */
102617 + switch (gimple_assign_rhs_code(def_stmt)) {
102618 + case RDIV_EXPR:
102619 + case TRUNC_DIV_EXPR:
102620 + case CEIL_DIV_EXPR:
102621 + case FLOOR_DIV_EXPR:
102622 + case ROUND_DIV_EXPR:
102623 + case TRUNC_MOD_EXPR:
102624 + case CEIL_MOD_EXPR:
102625 + case FLOOR_MOD_EXPR:
102626 + case ROUND_MOD_EXPR:
102627 + case EXACT_DIV_EXPR:
102628 + case POINTER_PLUS_EXPR:
102629 + case BIT_AND_EXPR:
102630 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102631 + default:
102632 + break;
102633 + }
102634 +
102635 + new_lhs = handle_integer_truncation(visited, lhs);
102636 + if (new_lhs != NULL_TREE)
102637 + return new_lhs;
102638 +
102639 + if (TREE_CODE(rhs1) == SSA_NAME)
102640 + new_rhs1 = expand(visited, rhs1);
102641 + if (TREE_CODE(rhs2) == SSA_NAME)
102642 + new_rhs2 = expand(visited, rhs2);
102643 +
102644 + if (is_a_neg_overflow(def_stmt, rhs2))
102645 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102646 + if (is_a_neg_overflow(def_stmt, rhs1))
102647 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102648 +
102649 +
102650 + if (is_a_constant_overflow(def_stmt, rhs2))
102651 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102652 + if (is_a_constant_overflow(def_stmt, rhs1))
102653 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102654 +
102655 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102656 +}
102657 +
102658 +#if BUILDING_GCC_VERSION >= 4007
102659 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102660 +{
102661 + if (is_gimple_constant(rhs))
102662 + return cast_a_tree(size_overflow_type, rhs);
102663 + if (TREE_CODE(rhs) != SSA_NAME)
102664 + return NULL_TREE;
102665 + return expand(visited, rhs);
102666 +}
102667 +
102668 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102669 +{
102670 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102671 + gimple def_stmt = get_def_stmt(lhs);
102672 +
102673 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102674 +
102675 + rhs1 = gimple_assign_rhs1(def_stmt);
102676 + rhs2 = gimple_assign_rhs2(def_stmt);
102677 + rhs3 = gimple_assign_rhs3(def_stmt);
102678 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102679 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102680 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102681 +
102682 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102683 +}
102684 +#endif
102685 +
102686 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102687 +{
102688 + const_tree type;
102689 + tree new_type;
102690 +
102691 + gcc_assert(node != NULL_TREE);
102692 +
102693 + type = TREE_TYPE(node);
102694 +
102695 + if (gimple_plf(stmt, MY_STMT))
102696 + return TREE_TYPE(node);
102697 +
102698 + switch (TYPE_MODE(type)) {
102699 + case QImode:
102700 + new_type = intHI_type_node;
102701 + break;
102702 + case HImode:
102703 + new_type = intSI_type_node;
102704 + break;
102705 + case SImode:
102706 + new_type = intDI_type_node;
102707 + break;
102708 + case DImode:
102709 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102710 + new_type = intDI_type_node;
102711 + else
102712 + new_type = intTI_type_node;
102713 + break;
102714 + default:
102715 + debug_tree((tree)node);
102716 + error("%s: unsupported gcc configuration.", __func__);
102717 + gcc_unreachable();
102718 + }
102719 +
102720 + if (TYPE_QUALS(type) != 0)
102721 + return build_qualified_type(new_type, TYPE_QUALS(type));
102722 + return new_type;
102723 +}
102724 +
102725 +static tree expand_visited(gimple def_stmt)
102726 +{
102727 + const_gimple next_stmt;
102728 + gimple_stmt_iterator gsi;
102729 + enum gimple_code code = gimple_code(def_stmt);
102730 +
102731 + if (code == GIMPLE_ASM)
102732 + return NULL_TREE;
102733 +
102734 + gsi = gsi_for_stmt(def_stmt);
102735 + gsi_next(&gsi);
102736 +
102737 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102738 + return NULL_TREE;
102739 + gcc_assert(!gsi_end_p(gsi));
102740 + next_stmt = gsi_stmt(gsi);
102741 +
102742 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102743 + return NULL_TREE;
102744 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102745 +
102746 + return get_lhs(next_stmt);
102747 +}
102748 +
102749 +static tree expand(struct pointer_set_t *visited, tree lhs)
102750 +{
102751 + gimple def_stmt;
102752 +
102753 + if (skip_types(lhs))
102754 + return NULL_TREE;
102755 +
102756 + def_stmt = get_def_stmt(lhs);
102757 +
102758 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102759 + return NULL_TREE;
102760 +
102761 + if (gimple_plf(def_stmt, MY_STMT))
102762 + return lhs;
102763 +
102764 + if (pointer_set_contains(visited, def_stmt))
102765 + return expand_visited(def_stmt);
102766 +
102767 + switch (gimple_code(def_stmt)) {
102768 + case GIMPLE_PHI:
102769 + return handle_phi(visited, lhs);
102770 + case GIMPLE_CALL:
102771 + case GIMPLE_ASM:
102772 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102773 + case GIMPLE_ASSIGN:
102774 + switch (gimple_num_ops(def_stmt)) {
102775 + case 2:
102776 + return handle_unary_ops(visited, def_stmt);
102777 + case 3:
102778 + return handle_binary_ops(visited, lhs);
102779 +#if BUILDING_GCC_VERSION >= 4007
102780 + case 4:
102781 + return handle_ternary_ops(visited, lhs);
102782 +#endif
102783 + }
102784 + default:
102785 + debug_gimple_stmt(def_stmt);
102786 + error("%s: unknown gimple code", __func__);
102787 + gcc_unreachable();
102788 + }
102789 +}
102790 +
102791 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102792 +{
102793 + const_gimple assign;
102794 + tree orig_type = TREE_TYPE(orig_node);
102795 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102796 +
102797 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102798 + return gimple_get_lhs(assign);
102799 +}
102800 +
102801 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102802 +{
102803 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102804 + update_stmt(stmt);
102805 +}
102806 +
102807 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102808 +{
102809 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102810 + update_stmt(stmt);
102811 +}
102812 +
102813 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102814 +{
102815 + tree arg;
102816 + const_tree origarg;
102817 +
102818 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102819 + return true;
102820 +
102821 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102822 + while (origarg && *argnum) {
102823 + (*argnum)--;
102824 + origarg = TREE_CHAIN(origarg);
102825 + }
102826 +
102827 + gcc_assert(*argnum == 0);
102828 +
102829 + gcc_assert(origarg != NULL_TREE);
102830 + *argnum = 0;
102831 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102832 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102833 + return true;
102834 + return false;
102835 +}
102836 +
102837 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102838 +{
102839 + gimple phi = get_def_stmt(result);
102840 + unsigned int i, n = gimple_phi_num_args(phi);
102841 +
102842 + if (!phi)
102843 + return MARK_NO;
102844 +
102845 + pointer_set_insert(visited, phi);
102846 + for (i = 0; i < n; i++) {
102847 + enum mark marked;
102848 + const_tree arg = gimple_phi_arg_def(phi, i);
102849 + marked = pre_expand(visited, search_err_code, arg);
102850 + if (marked != MARK_NO)
102851 + return marked;
102852 + }
102853 + return MARK_NO;
102854 +}
102855 +
102856 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102857 +{
102858 + gimple def_stmt = get_def_stmt(lhs);
102859 + const_tree rhs;
102860 +
102861 + if (!def_stmt)
102862 + return MARK_NO;
102863 +
102864 + rhs = gimple_assign_rhs1(def_stmt);
102865 +
102866 + def_stmt = get_def_stmt(rhs);
102867 + if (is_gimple_constant(rhs))
102868 + search_err_code[FROM_CONST] = true;
102869 +
102870 + return pre_expand(visited, search_err_code, rhs);
102871 +}
102872 +
102873 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102874 +{
102875 + gimple def_stmt = get_def_stmt(lhs);
102876 + const_tree rhs1, rhs2;
102877 + enum mark marked;
102878 +
102879 + if (!def_stmt)
102880 + return MARK_NO;
102881 +
102882 + search_err_code[CAST_ONLY] = false;
102883 +
102884 + rhs1 = gimple_assign_rhs1(def_stmt);
102885 + rhs2 = gimple_assign_rhs2(def_stmt);
102886 + marked = pre_expand(visited, search_err_code, rhs1);
102887 + if (marked != MARK_NO)
102888 + return marked;
102889 + return pre_expand(visited, search_err_code, rhs2);
102890 +}
102891 +
102892 +static const_tree search_field_decl(const_tree comp_ref)
102893 +{
102894 + const_tree field = NULL_TREE;
102895 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
102896 +
102897 + for (i = 0; i < len; i++) {
102898 + field = TREE_OPERAND(comp_ref, i);
102899 + if (TREE_CODE(field) == FIELD_DECL)
102900 + break;
102901 + }
102902 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
102903 + return field;
102904 +}
102905 +
102906 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
102907 +{
102908 + const_tree attr, p;
102909 +
102910 + // 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);
102911 + if (fndecl == NULL_TREE)
102912 + return MARK_NO;
102913 +
102914 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
102915 + if (!attr || !TREE_VALUE(attr))
102916 + return MARK_NO;
102917 +
102918 + p = TREE_VALUE(attr);
102919 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
102920 + return MARK_TURN_OFF;
102921 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
102922 + return MARK_NOT_INTENTIONAL;
102923 + if (argnum == 0) {
102924 + gcc_assert(current_function_decl == fndecl);
102925 + return MARK_NO;
102926 + }
102927 +
102928 + do {
102929 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
102930 + return MARK_YES;
102931 + p = TREE_CHAIN(p);
102932 + } while (p);
102933 +
102934 + return MARK_NO;
102935 +}
102936 +
102937 +static void print_missing_msg(tree func, unsigned int argnum)
102938 +{
102939 + unsigned int new_hash;
102940 + size_t len;
102941 + unsigned char tree_codes[CODES_LIMIT];
102942 + location_t loc;
102943 + const char *curfunc;
102944 +
102945 + func = get_original_function_decl(func);
102946 + loc = DECL_SOURCE_LOCATION(func);
102947 + curfunc = get_asm_name(func);
102948 +
102949 + len = get_function_decl(func, tree_codes);
102950 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
102951 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
102952 +}
102953 +
102954 +static unsigned int search_missing_attribute(const_tree arg)
102955 +{
102956 + unsigned int argnum;
102957 + const struct size_overflow_hash *hash;
102958 + const_tree type = TREE_TYPE(arg);
102959 + tree func = get_original_function_decl(current_function_decl);
102960 +
102961 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
102962 +
102963 + if (TREE_CODE(type) == POINTER_TYPE)
102964 + return 0;
102965 +
102966 + argnum = find_arg_number(arg, func);
102967 + if (argnum == 0)
102968 + return 0;
102969 +
102970 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
102971 + return argnum;
102972 +
102973 + hash = get_function_hash(func);
102974 + if (!hash || !(hash->param & (1U << argnum))) {
102975 + print_missing_msg(func, argnum);
102976 + return 0;
102977 + }
102978 + return argnum;
102979 +}
102980 +
102981 +static enum mark is_already_marked(const_tree lhs)
102982 +{
102983 + unsigned int argnum;
102984 + const_tree fndecl;
102985 +
102986 + argnum = search_missing_attribute(lhs);
102987 + fndecl = get_original_function_decl(current_function_decl);
102988 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
102989 + return MARK_YES;
102990 + return MARK_NO;
102991 +}
102992 +
102993 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102994 +{
102995 + const_gimple def_stmt;
102996 +
102997 + if (skip_types(lhs))
102998 + return MARK_NO;
102999 +
103000 + if (TREE_CODE(lhs) == PARM_DECL)
103001 + return is_already_marked(lhs);
103002 +
103003 + if (TREE_CODE(lhs) == COMPONENT_REF) {
103004 + const_tree field, attr;
103005 +
103006 + field = search_field_decl(lhs);
103007 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
103008 + if (!attr || !TREE_VALUE(attr))
103009 + return MARK_NO;
103010 + return MARK_YES;
103011 + }
103012 +
103013 + def_stmt = get_def_stmt(lhs);
103014 +
103015 + if (!def_stmt)
103016 + return MARK_NO;
103017 +
103018 + if (pointer_set_contains(visited, def_stmt))
103019 + return MARK_NO;
103020 +
103021 + switch (gimple_code(def_stmt)) {
103022 + case GIMPLE_NOP:
103023 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
103024 + return is_already_marked(lhs);
103025 + return MARK_NO;
103026 + case GIMPLE_PHI:
103027 + return walk_phi(visited, search_err_code, lhs);
103028 + case GIMPLE_CALL:
103029 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
103030 + return MARK_TURN_OFF;
103031 + check_function_hash(def_stmt);
103032 + return MARK_NO;
103033 + case GIMPLE_ASM:
103034 + search_err_code[CAST_ONLY] = false;
103035 + return MARK_NO;
103036 + case GIMPLE_ASSIGN:
103037 + switch (gimple_num_ops(def_stmt)) {
103038 + case 2:
103039 + return walk_unary_ops(visited, search_err_code, lhs);
103040 + case 3:
103041 + return walk_binary_ops(visited, search_err_code, lhs);
103042 + }
103043 + default:
103044 + debug_gimple_stmt((gimple)def_stmt);
103045 + error("%s: unknown gimple code", __func__);
103046 + gcc_unreachable();
103047 + }
103048 +}
103049 +
103050 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103051 +static bool skip_asm(const_tree arg)
103052 +{
103053 + gimple def_stmt = get_def_stmt(arg);
103054 +
103055 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103056 + return false;
103057 +
103058 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103059 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103060 +}
103061 +
103062 +/*
103063 +0</MARK_YES: no dup, search attributes (so, int)
103064 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103065 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103066 +*/
103067 +
103068 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
103069 +{
103070 + struct pointer_set_t *visited;
103071 + enum mark is_marked, is_found;
103072 + location_t loc;
103073 + bool search_err_code[2] = {true, false};
103074 +
103075 + is_marked = mark_status(current_function_decl, 0);
103076 + if (is_marked == MARK_TURN_OFF)
103077 + return true;
103078 +
103079 + is_marked = mark_status(fndecl, argnum + 1);
103080 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
103081 + return true;
103082 +
103083 + visited = pointer_set_create();
103084 + is_found = pre_expand(visited, search_err_code, arg);
103085 + pointer_set_destroy(visited);
103086 +
103087 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
103088 + return true;
103089 +
103090 + if (where == FROM_ARG && skip_asm(arg))
103091 + return true;
103092 +
103093 + if (is_found == MARK_TURN_OFF)
103094 + return true;
103095 +
103096 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103097 + return true;
103098 +
103099 + if (is_found == MARK_YES) {
103100 + loc = DECL_SOURCE_LOCATION(fndecl);
103101 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103102 + return true;
103103 + }
103104 + return false;
103105 +}
103106 +
103107 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103108 +{
103109 + struct pointer_set_t *visited;
103110 + tree arg, new_arg;
103111 + bool match;
103112 +
103113 + if (argnum == 0)
103114 + return;
103115 +
103116 + argnum--;
103117 +
103118 + match = get_function_arg(&argnum, fndecl);
103119 + if (!match)
103120 + return;
103121 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103122 + arg = gimple_call_arg(stmt, argnum);
103123 + if (arg == NULL_TREE)
103124 + return;
103125 +
103126 + if (skip_types(arg))
103127 + return;
103128 +
103129 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103130 + return;
103131 +
103132 + visited = pointer_set_create();
103133 + new_arg = expand(visited, arg);
103134 + pointer_set_destroy(visited);
103135 +
103136 + if (new_arg == NULL_TREE)
103137 + return;
103138 +
103139 + change_function_arg(stmt, arg, argnum, new_arg);
103140 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103141 +}
103142 +
103143 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103144 +{
103145 + tree p = TREE_VALUE(attr);
103146 + do {
103147 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103148 + p = TREE_CHAIN(p);
103149 + } while (p);
103150 +}
103151 +
103152 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103153 +{
103154 + unsigned int num;
103155 + const struct size_overflow_hash *hash;
103156 +
103157 + hash = get_function_hash(fndecl);
103158 + if (!hash)
103159 + return;
103160 +
103161 + for (num = 0; num <= MAX_PARAM; num++)
103162 + if (hash->param & (1U << num))
103163 + handle_function_arg(stmt, fndecl, num);
103164 +}
103165 +
103166 +static bool check_return_value(void)
103167 +{
103168 + const struct size_overflow_hash *hash;
103169 +
103170 + hash = get_function_hash(current_function_decl);
103171 + if (!hash || !(hash->param & 1U << 0))
103172 + return false;
103173 +
103174 + return true;
103175 +}
103176 +
103177 +static void handle_return_value(gimple ret_stmt)
103178 +{
103179 + struct pointer_set_t *visited;
103180 + tree ret, new_ret;
103181 +
103182 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103183 + return;
103184 +
103185 + ret = gimple_return_retval(ret_stmt);
103186 +
103187 + if (skip_types(ret))
103188 + return;
103189 +
103190 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103191 + return;
103192 +
103193 + visited = pointer_set_create();
103194 + new_ret = expand(visited, ret);
103195 + pointer_set_destroy(visited);
103196 +
103197 + change_function_return(ret_stmt, ret, new_ret);
103198 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103199 +}
103200 +
103201 +static void set_plf_false(void)
103202 +{
103203 + basic_block bb;
103204 +
103205 + FOR_ALL_BB(bb) {
103206 + gimple_stmt_iterator si;
103207 +
103208 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103209 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103210 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103211 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103212 + }
103213 +}
103214 +
103215 +static unsigned int handle_function(void)
103216 +{
103217 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103218 + bool check_ret;
103219 +
103220 + set_plf_false();
103221 +
103222 + check_ret = check_return_value();
103223 +
103224 + do {
103225 + gimple_stmt_iterator gsi;
103226 + next = bb->next_bb;
103227 +
103228 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103229 + tree fndecl, attr;
103230 + gimple stmt = gsi_stmt(gsi);
103231 +
103232 + if (check_ret)
103233 + handle_return_value(stmt);
103234 +
103235 + if (!(is_gimple_call(stmt)))
103236 + continue;
103237 + fndecl = gimple_call_fndecl(stmt);
103238 + if (fndecl == NULL_TREE)
103239 + continue;
103240 + if (gimple_call_num_args(stmt) == 0)
103241 + continue;
103242 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103243 + if (!attr || !TREE_VALUE(attr))
103244 + handle_function_by_hash(stmt, fndecl);
103245 + else
103246 + handle_function_by_attribute(stmt, attr, fndecl);
103247 + gsi = gsi_for_stmt(stmt);
103248 + next = gimple_bb(stmt)->next_bb;
103249 + }
103250 + bb = next;
103251 + } while (bb);
103252 + return 0;
103253 +}
103254 +
103255 +static struct gimple_opt_pass size_overflow_pass = {
103256 + .pass = {
103257 + .type = GIMPLE_PASS,
103258 + .name = "size_overflow",
103259 +#if BUILDING_GCC_VERSION >= 4008
103260 + .optinfo_flags = OPTGROUP_NONE,
103261 +#endif
103262 + .gate = NULL,
103263 + .execute = handle_function,
103264 + .sub = NULL,
103265 + .next = NULL,
103266 + .static_pass_number = 0,
103267 + .tv_id = TV_NONE,
103268 + .properties_required = PROP_cfg,
103269 + .properties_provided = 0,
103270 + .properties_destroyed = 0,
103271 + .todo_flags_start = 0,
103272 + .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
103273 + }
103274 +};
103275 +
103276 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103277 +{
103278 + tree fntype;
103279 +
103280 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103281 +
103282 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103283 + fntype = build_function_type_list(void_type_node,
103284 + const_char_ptr_type_node,
103285 + unsigned_type_node,
103286 + const_char_ptr_type_node,
103287 + const_char_ptr_type_node,
103288 + NULL_TREE);
103289 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103290 +
103291 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103292 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103293 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103294 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103295 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103296 +}
103297 +
103298 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103299 +{
103300 + int i;
103301 + const char * const plugin_name = plugin_info->base_name;
103302 + const int argc = plugin_info->argc;
103303 + const struct plugin_argument * const argv = plugin_info->argv;
103304 + bool enable = true;
103305 +
103306 + struct register_pass_info size_overflow_pass_info = {
103307 + .pass = &size_overflow_pass.pass,
103308 + .reference_pass_name = "ssa",
103309 + .ref_pass_instance_number = 1,
103310 + .pos_op = PASS_POS_INSERT_AFTER
103311 + };
103312 +
103313 + if (!plugin_default_version_check(version, &gcc_version)) {
103314 + error(G_("incompatible gcc/plugin versions"));
103315 + return 1;
103316 + }
103317 +
103318 + for (i = 0; i < argc; ++i) {
103319 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103320 + enable = false;
103321 + continue;
103322 + }
103323 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103324 + }
103325 +
103326 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103327 + if (enable) {
103328 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103329 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103330 + }
103331 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103332 +
103333 + return 0;
103334 +}
103335 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103336 new file mode 100644
103337 index 0000000..ac2901e
103338 --- /dev/null
103339 +++ b/tools/gcc/stackleak_plugin.c
103340 @@ -0,0 +1,327 @@
103341 +/*
103342 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103343 + * Licensed under the GPL v2
103344 + *
103345 + * Note: the choice of the license means that the compilation process is
103346 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103347 + * but for the kernel it doesn't matter since it doesn't link against
103348 + * any of the gcc libraries
103349 + *
103350 + * gcc plugin to help implement various PaX features
103351 + *
103352 + * - track lowest stack pointer
103353 + *
103354 + * TODO:
103355 + * - initialize all local variables
103356 + *
103357 + * BUGS:
103358 + * - none known
103359 + */
103360 +#include "gcc-plugin.h"
103361 +#include "config.h"
103362 +#include "system.h"
103363 +#include "coretypes.h"
103364 +#include "tree.h"
103365 +#include "tree-pass.h"
103366 +#include "flags.h"
103367 +#include "intl.h"
103368 +#include "toplev.h"
103369 +#include "plugin.h"
103370 +//#include "expr.h" where are you...
103371 +#include "diagnostic.h"
103372 +#include "plugin-version.h"
103373 +#include "tm.h"
103374 +#include "function.h"
103375 +#include "basic-block.h"
103376 +#include "gimple.h"
103377 +#include "rtl.h"
103378 +#include "emit-rtl.h"
103379 +
103380 +#if BUILDING_GCC_VERSION >= 4008
103381 +#define TODO_dump_func 0
103382 +#endif
103383 +
103384 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103385 +
103386 +int plugin_is_GPL_compatible;
103387 +
103388 +static int track_frame_size = -1;
103389 +static const char track_function[] = "pax_track_stack";
103390 +static const char check_function[] = "pax_check_alloca";
103391 +static bool init_locals;
103392 +
103393 +static struct plugin_info stackleak_plugin_info = {
103394 + .version = "201302112000",
103395 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103396 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103397 +};
103398 +
103399 +static bool gate_stackleak_track_stack(void);
103400 +static unsigned int execute_stackleak_tree_instrument(void);
103401 +static unsigned int execute_stackleak_final(void);
103402 +
103403 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103404 + .pass = {
103405 + .type = GIMPLE_PASS,
103406 + .name = "stackleak_tree_instrument",
103407 +#if BUILDING_GCC_VERSION >= 4008
103408 + .optinfo_flags = OPTGROUP_NONE,
103409 +#endif
103410 + .gate = gate_stackleak_track_stack,
103411 + .execute = execute_stackleak_tree_instrument,
103412 + .sub = NULL,
103413 + .next = NULL,
103414 + .static_pass_number = 0,
103415 + .tv_id = TV_NONE,
103416 + .properties_required = PROP_gimple_leh | PROP_cfg,
103417 + .properties_provided = 0,
103418 + .properties_destroyed = 0,
103419 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103420 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103421 + }
103422 +};
103423 +
103424 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103425 + .pass = {
103426 + .type = RTL_PASS,
103427 + .name = "stackleak_final",
103428 +#if BUILDING_GCC_VERSION >= 4008
103429 + .optinfo_flags = OPTGROUP_NONE,
103430 +#endif
103431 + .gate = gate_stackleak_track_stack,
103432 + .execute = execute_stackleak_final,
103433 + .sub = NULL,
103434 + .next = NULL,
103435 + .static_pass_number = 0,
103436 + .tv_id = TV_NONE,
103437 + .properties_required = 0,
103438 + .properties_provided = 0,
103439 + .properties_destroyed = 0,
103440 + .todo_flags_start = 0,
103441 + .todo_flags_finish = TODO_dump_func
103442 + }
103443 +};
103444 +
103445 +static bool gate_stackleak_track_stack(void)
103446 +{
103447 + return track_frame_size >= 0;
103448 +}
103449 +
103450 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103451 +{
103452 + gimple check_alloca;
103453 + tree fntype, fndecl, alloca_size;
103454 +
103455 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103456 + fndecl = build_fn_decl(check_function, fntype);
103457 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103458 +
103459 + // insert call to void pax_check_alloca(unsigned long size)
103460 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103461 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103462 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103463 +}
103464 +
103465 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103466 +{
103467 + gimple track_stack;
103468 + tree fntype, fndecl;
103469 +
103470 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103471 + fndecl = build_fn_decl(track_function, fntype);
103472 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103473 +
103474 + // insert call to void pax_track_stack(void)
103475 + track_stack = gimple_build_call(fndecl, 0);
103476 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103477 +}
103478 +
103479 +#if BUILDING_GCC_VERSION == 4005
103480 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103481 +{
103482 + tree fndecl;
103483 +
103484 + if (!is_gimple_call(stmt))
103485 + return false;
103486 + fndecl = gimple_call_fndecl(stmt);
103487 + if (!fndecl)
103488 + return false;
103489 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103490 + return false;
103491 +// print_node(stderr, "pax", fndecl, 4);
103492 + return DECL_FUNCTION_CODE(fndecl) == code;
103493 +}
103494 +#endif
103495 +
103496 +static bool is_alloca(gimple stmt)
103497 +{
103498 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103499 + return true;
103500 +
103501 +#if BUILDING_GCC_VERSION >= 4007
103502 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103503 + return true;
103504 +#endif
103505 +
103506 + return false;
103507 +}
103508 +
103509 +static unsigned int execute_stackleak_tree_instrument(void)
103510 +{
103511 + basic_block bb, entry_bb;
103512 + bool prologue_instrumented = false, is_leaf = true;
103513 +
103514 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103515 +
103516 + // 1. loop through BBs and GIMPLE statements
103517 + FOR_EACH_BB(bb) {
103518 + gimple_stmt_iterator gsi;
103519 +
103520 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103521 + gimple stmt;
103522 +
103523 + stmt = gsi_stmt(gsi);
103524 +
103525 + if (is_gimple_call(stmt))
103526 + is_leaf = false;
103527 +
103528 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103529 + if (!is_alloca(stmt))
103530 + continue;
103531 +
103532 + // 2. insert stack overflow check before each __builtin_alloca call
103533 + stackleak_check_alloca(&gsi);
103534 +
103535 + // 3. insert track call after each __builtin_alloca call
103536 + stackleak_add_instrumentation(&gsi);
103537 + if (bb == entry_bb)
103538 + prologue_instrumented = true;
103539 + }
103540 + }
103541 +
103542 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103543 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103544 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103545 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103546 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103547 + return 0;
103548 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103549 + return 0;
103550 +
103551 + // 4. insert track call at the beginning
103552 + if (!prologue_instrumented) {
103553 + gimple_stmt_iterator gsi;
103554 +
103555 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103556 + if (dom_info_available_p(CDI_DOMINATORS))
103557 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103558 + gsi = gsi_start_bb(bb);
103559 + stackleak_add_instrumentation(&gsi);
103560 + }
103561 +
103562 + return 0;
103563 +}
103564 +
103565 +static unsigned int execute_stackleak_final(void)
103566 +{
103567 + rtx insn, next;
103568 +
103569 + if (cfun->calls_alloca)
103570 + return 0;
103571 +
103572 + // keep calls only if function frame is big enough
103573 + if (get_frame_size() >= track_frame_size)
103574 + return 0;
103575 +
103576 + // 1. find pax_track_stack calls
103577 + for (insn = get_insns(); insn; insn = next) {
103578 + // 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))
103579 + rtx body;
103580 +
103581 + next = NEXT_INSN(insn);
103582 + if (!CALL_P(insn))
103583 + continue;
103584 + body = PATTERN(insn);
103585 + if (GET_CODE(body) != CALL)
103586 + continue;
103587 + body = XEXP(body, 0);
103588 + if (GET_CODE(body) != MEM)
103589 + continue;
103590 + body = XEXP(body, 0);
103591 + if (GET_CODE(body) != SYMBOL_REF)
103592 + continue;
103593 + if (strcmp(XSTR(body, 0), track_function))
103594 + continue;
103595 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103596 + // 2. delete call
103597 + delete_insn_and_edges(insn);
103598 +#if BUILDING_GCC_VERSION >= 4007
103599 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103600 + insn = next;
103601 + next = NEXT_INSN(insn);
103602 + delete_insn_and_edges(insn);
103603 + }
103604 +#endif
103605 + }
103606 +
103607 +// print_simple_rtl(stderr, get_insns());
103608 +// print_rtl(stderr, get_insns());
103609 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103610 +
103611 + return 0;
103612 +}
103613 +
103614 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103615 +{
103616 + const char * const plugin_name = plugin_info->base_name;
103617 + const int argc = plugin_info->argc;
103618 + const struct plugin_argument * const argv = plugin_info->argv;
103619 + int i;
103620 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103621 + .pass = &stackleak_tree_instrument_pass.pass,
103622 +// .reference_pass_name = "tree_profile",
103623 + .reference_pass_name = "optimized",
103624 + .ref_pass_instance_number = 1,
103625 + .pos_op = PASS_POS_INSERT_BEFORE
103626 + };
103627 + struct register_pass_info stackleak_final_pass_info = {
103628 + .pass = &stackleak_final_rtl_opt_pass.pass,
103629 + .reference_pass_name = "final",
103630 + .ref_pass_instance_number = 1,
103631 + .pos_op = PASS_POS_INSERT_BEFORE
103632 + };
103633 +
103634 + if (!plugin_default_version_check(version, &gcc_version)) {
103635 + error(G_("incompatible gcc/plugin versions"));
103636 + return 1;
103637 + }
103638 +
103639 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103640 +
103641 + for (i = 0; i < argc; ++i) {
103642 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103643 + if (!argv[i].value) {
103644 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103645 + continue;
103646 + }
103647 + track_frame_size = atoi(argv[i].value);
103648 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103649 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103650 + continue;
103651 + }
103652 + if (!strcmp(argv[i].key, "initialize-locals")) {
103653 + if (argv[i].value) {
103654 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103655 + continue;
103656 + }
103657 + init_locals = true;
103658 + continue;
103659 + }
103660 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103661 + }
103662 +
103663 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103664 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103665 +
103666 + return 0;
103667 +}
103668 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103669 new file mode 100644
103670 index 0000000..b07fe22
103671 --- /dev/null
103672 +++ b/tools/gcc/structleak_plugin.c
103673 @@ -0,0 +1,276 @@
103674 +/*
103675 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103676 + * Licensed under the GPL v2
103677 + *
103678 + * Note: the choice of the license means that the compilation process is
103679 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103680 + * but for the kernel it doesn't matter since it doesn't link against
103681 + * any of the gcc libraries
103682 + *
103683 + * gcc plugin to forcibly initialize certain local variables that could
103684 + * otherwise leak kernel stack to userland if they aren't properly initialized
103685 + * by later code
103686 + *
103687 + * Homepage: http://pax.grsecurity.net/
103688 + *
103689 + * Usage:
103690 + * $ # for 4.5/4.6/C based 4.7
103691 + * $ 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
103692 + * $ # for C++ based 4.7/4.8+
103693 + * $ 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
103694 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103695 + *
103696 + * TODO: eliminate redundant initializers
103697 + * increase type coverage
103698 + */
103699 +
103700 +#include "gcc-plugin.h"
103701 +#include "config.h"
103702 +#include "system.h"
103703 +#include "coretypes.h"
103704 +#include "tree.h"
103705 +#include "tree-pass.h"
103706 +#include "intl.h"
103707 +#include "plugin-version.h"
103708 +#include "tm.h"
103709 +#include "toplev.h"
103710 +#include "function.h"
103711 +#include "tree-flow.h"
103712 +#include "plugin.h"
103713 +#include "gimple.h"
103714 +#include "diagnostic.h"
103715 +#include "cfgloop.h"
103716 +#include "langhooks.h"
103717 +
103718 +#if BUILDING_GCC_VERSION >= 4008
103719 +#define TODO_dump_func 0
103720 +#endif
103721 +
103722 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103723 +
103724 +// unused type flag in all versions 4.5-4.8
103725 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103726 +
103727 +int plugin_is_GPL_compatible;
103728 +void debug_gimple_stmt(gimple gs);
103729 +
103730 +static struct plugin_info structleak_plugin_info = {
103731 + .version = "201304082245",
103732 + .help = "disable\tdo not activate plugin\n",
103733 +};
103734 +
103735 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103736 +{
103737 + *no_add_attrs = true;
103738 +
103739 + // check for types? for now accept everything linux has to offer
103740 + if (TREE_CODE(*node) != FIELD_DECL)
103741 + return NULL_TREE;
103742 +
103743 + *no_add_attrs = false;
103744 + return NULL_TREE;
103745 +}
103746 +
103747 +static struct attribute_spec user_attr = {
103748 + .name = "user",
103749 + .min_length = 0,
103750 + .max_length = 0,
103751 + .decl_required = false,
103752 + .type_required = false,
103753 + .function_type_required = false,
103754 + .handler = handle_user_attribute,
103755 +#if BUILDING_GCC_VERSION >= 4007
103756 + .affects_type_identity = true
103757 +#endif
103758 +};
103759 +
103760 +static void register_attributes(void *event_data, void *data)
103761 +{
103762 + register_attribute(&user_attr);
103763 +// register_attribute(&force_attr);
103764 +}
103765 +
103766 +static tree get_field_type(tree field)
103767 +{
103768 + return strip_array_types(TREE_TYPE(field));
103769 +}
103770 +
103771 +static bool is_userspace_type(tree type)
103772 +{
103773 + tree field;
103774 +
103775 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103776 + tree fieldtype = get_field_type(field);
103777 + enum tree_code code = TREE_CODE(fieldtype);
103778 +
103779 + if (code == RECORD_TYPE || code == UNION_TYPE)
103780 + if (is_userspace_type(fieldtype))
103781 + return true;
103782 +
103783 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103784 + return true;
103785 + }
103786 + return false;
103787 +}
103788 +
103789 +static void finish_type(void *event_data, void *data)
103790 +{
103791 + tree type = (tree)event_data;
103792 +
103793 + if (TYPE_USERSPACE(type))
103794 + return;
103795 +
103796 + if (is_userspace_type(type))
103797 + TYPE_USERSPACE(type) = 1;
103798 +}
103799 +
103800 +static void initialize(tree var)
103801 +{
103802 + basic_block bb;
103803 + gimple_stmt_iterator gsi;
103804 + tree initializer;
103805 + gimple init_stmt;
103806 +
103807 + // this is the original entry bb before the forced split
103808 + // TODO: check further BBs in case more splits occured before us
103809 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103810 +
103811 + // first check if the variable is already initialized, warn otherwise
103812 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103813 + gimple stmt = gsi_stmt(gsi);
103814 + tree rhs1 = gimple_assign_rhs1(stmt);
103815 +
103816 + // we're looking for an assignment of a single rhs...
103817 + if (!gimple_assign_single_p(stmt))
103818 + continue;
103819 +#if BUILDING_GCC_VERSION >= 4007
103820 + // ... of a non-clobbering expression...
103821 + if (TREE_CLOBBER_P(rhs1))
103822 + continue;
103823 +#endif
103824 + // ... to our variable...
103825 + if (gimple_get_lhs(stmt) != var)
103826 + continue;
103827 + // if it's an initializer then we're good
103828 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
103829 + return;
103830 + }
103831 +
103832 + // these aren't the 0days you're looking for
103833 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
103834 +
103835 + // build the initializer expression
103836 + initializer = build_constructor(TREE_TYPE(var), NULL);
103837 +
103838 + // build the initializer stmt
103839 + init_stmt = gimple_build_assign(var, initializer);
103840 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103841 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103842 + update_stmt(init_stmt);
103843 +}
103844 +
103845 +static unsigned int handle_function(void)
103846 +{
103847 + basic_block bb;
103848 + unsigned int ret = 0;
103849 + tree var;
103850 +
103851 +#if BUILDING_GCC_VERSION == 4005
103852 + tree vars;
103853 +#else
103854 + unsigned int i;
103855 +#endif
103856 +
103857 + // split the first bb where we can put the forced initializers
103858 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103859 + if (dom_info_available_p(CDI_DOMINATORS))
103860 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103861 +
103862 + // enumarate all local variables and forcibly initialize our targets
103863 +#if BUILDING_GCC_VERSION == 4005
103864 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103865 + var = TREE_VALUE(vars);
103866 +#else
103867 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103868 +#endif
103869 + tree type = TREE_TYPE(var);
103870 +
103871 + gcc_assert(DECL_P(var));
103872 + if (!auto_var_in_fn_p(var, current_function_decl))
103873 + continue;
103874 +
103875 + // only care about structure types
103876 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
103877 + continue;
103878 +
103879 + // if the type is of interest, examine the variable
103880 + if (TYPE_USERSPACE(type))
103881 + initialize(var);
103882 + }
103883 +
103884 + return ret;
103885 +}
103886 +
103887 +static struct gimple_opt_pass structleak_pass = {
103888 + .pass = {
103889 + .type = GIMPLE_PASS,
103890 + .name = "structleak",
103891 +#if BUILDING_GCC_VERSION >= 4008
103892 + .optinfo_flags = OPTGROUP_NONE,
103893 +#endif
103894 + .gate = NULL,
103895 + .execute = handle_function,
103896 + .sub = NULL,
103897 + .next = NULL,
103898 + .static_pass_number = 0,
103899 + .tv_id = TV_NONE,
103900 + .properties_required = PROP_cfg,
103901 + .properties_provided = 0,
103902 + .properties_destroyed = 0,
103903 + .todo_flags_start = 0,
103904 + .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
103905 + }
103906 +};
103907 +
103908 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103909 +{
103910 + int i;
103911 + const char * const plugin_name = plugin_info->base_name;
103912 + const int argc = plugin_info->argc;
103913 + const struct plugin_argument * const argv = plugin_info->argv;
103914 + bool enable = true;
103915 +
103916 + struct register_pass_info structleak_pass_info = {
103917 + .pass = &structleak_pass.pass,
103918 + .reference_pass_name = "ssa",
103919 + .ref_pass_instance_number = 1,
103920 + .pos_op = PASS_POS_INSERT_AFTER
103921 + };
103922 +
103923 + if (!plugin_default_version_check(version, &gcc_version)) {
103924 + error(G_("incompatible gcc/plugin versions"));
103925 + return 1;
103926 + }
103927 +
103928 + if (strcmp(lang_hooks.name, "GNU C")) {
103929 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
103930 + enable = false;
103931 + }
103932 +
103933 + for (i = 0; i < argc; ++i) {
103934 + if (!strcmp(argv[i].key, "disable")) {
103935 + enable = false;
103936 + continue;
103937 + }
103938 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103939 + }
103940 +
103941 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
103942 + if (enable) {
103943 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
103944 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
103945 + }
103946 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103947 +
103948 + return 0;
103949 +}
103950 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
103951 index 6789d78..4afd019e 100644
103952 --- a/tools/perf/util/include/asm/alternative-asm.h
103953 +++ b/tools/perf/util/include/asm/alternative-asm.h
103954 @@ -5,4 +5,7 @@
103955
103956 #define altinstruction_entry #
103957
103958 + .macro pax_force_retaddr rip=0, reload=0
103959 + .endm
103960 +
103961 #endif
103962 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
103963 index 96b919d..c49bb74 100644
103964 --- a/tools/perf/util/include/linux/compiler.h
103965 +++ b/tools/perf/util/include/linux/compiler.h
103966 @@ -18,4 +18,12 @@
103967 #define __force
103968 #endif
103969
103970 +#ifndef __size_overflow
103971 +# define __size_overflow(...)
103972 +#endif
103973 +
103974 +#ifndef __intentional_overflow
103975 +# define __intentional_overflow(...)
103976 +#endif
103977 +
103978 #endif
103979 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
103980 index 10afa34..f29c524 100644
103981 --- a/virt/kvm/kvm_main.c
103982 +++ b/virt/kvm/kvm_main.c
103983 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
103984
103985 static cpumask_var_t cpus_hardware_enabled;
103986 static int kvm_usage_count = 0;
103987 -static atomic_t hardware_enable_failed;
103988 +static atomic_unchecked_t hardware_enable_failed;
103989
103990 struct kmem_cache *kvm_vcpu_cache;
103991 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
103992
103993 -static __read_mostly struct preempt_ops kvm_preempt_ops;
103994 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
103995 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
103996 +static struct preempt_ops kvm_preempt_ops = {
103997 + .sched_in = kvm_sched_in,
103998 + .sched_out = kvm_sched_out,
103999 +};
104000
104001 struct dentry *kvm_debugfs_dir;
104002
104003 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
104004 /* We can read the guest memory with __xxx_user() later on. */
104005 if (user_alloc &&
104006 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
104007 - !access_ok(VERIFY_WRITE,
104008 + !__access_ok(VERIFY_WRITE,
104009 (void __user *)(unsigned long)mem->userspace_addr,
104010 mem->memory_size)))
104011 goto out;
104012 @@ -1810,7 +1815,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
104013 return 0;
104014 }
104015
104016 -static struct file_operations kvm_vcpu_fops = {
104017 +static file_operations_no_const kvm_vcpu_fops __read_only = {
104018 .release = kvm_vcpu_release,
104019 .unlocked_ioctl = kvm_vcpu_ioctl,
104020 #ifdef CONFIG_COMPAT
104021 @@ -2331,7 +2336,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
104022 return 0;
104023 }
104024
104025 -static struct file_operations kvm_vm_fops = {
104026 +static file_operations_no_const kvm_vm_fops __read_only = {
104027 .release = kvm_vm_release,
104028 .unlocked_ioctl = kvm_vm_ioctl,
104029 #ifdef CONFIG_COMPAT
104030 @@ -2429,7 +2434,7 @@ out:
104031 return r;
104032 }
104033
104034 -static struct file_operations kvm_chardev_ops = {
104035 +static file_operations_no_const kvm_chardev_ops __read_only = {
104036 .unlocked_ioctl = kvm_dev_ioctl,
104037 .compat_ioctl = kvm_dev_ioctl,
104038 .llseek = noop_llseek,
104039 @@ -2455,7 +2460,7 @@ static void hardware_enable_nolock(void *junk)
104040
104041 if (r) {
104042 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104043 - atomic_inc(&hardware_enable_failed);
104044 + atomic_inc_unchecked(&hardware_enable_failed);
104045 printk(KERN_INFO "kvm: enabling virtualization on "
104046 "CPU%d failed\n", cpu);
104047 }
104048 @@ -2509,10 +2514,10 @@ static int hardware_enable_all(void)
104049
104050 kvm_usage_count++;
104051 if (kvm_usage_count == 1) {
104052 - atomic_set(&hardware_enable_failed, 0);
104053 + atomic_set_unchecked(&hardware_enable_failed, 0);
104054 on_each_cpu(hardware_enable_nolock, NULL, 1);
104055
104056 - if (atomic_read(&hardware_enable_failed)) {
104057 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104058 hardware_disable_all_nolock();
104059 r = -EBUSY;
104060 }
104061 @@ -2870,7 +2875,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104062 kvm_arch_vcpu_put(vcpu);
104063 }
104064
104065 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104066 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104067 struct module *module)
104068 {
104069 int r;
104070 @@ -2906,7 +2911,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104071 if (!vcpu_align)
104072 vcpu_align = __alignof__(struct kvm_vcpu);
104073 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
104074 - 0, NULL);
104075 + SLAB_USERCOPY, NULL);
104076 if (!kvm_vcpu_cache) {
104077 r = -ENOMEM;
104078 goto out_free_3;
104079 @@ -2916,9 +2921,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104080 if (r)
104081 goto out_free;
104082
104083 + pax_open_kernel();
104084 kvm_chardev_ops.owner = module;
104085 kvm_vm_fops.owner = module;
104086 kvm_vcpu_fops.owner = module;
104087 + pax_close_kernel();
104088
104089 r = misc_register(&kvm_dev);
104090 if (r) {
104091 @@ -2928,9 +2935,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104092
104093 register_syscore_ops(&kvm_syscore_ops);
104094
104095 - kvm_preempt_ops.sched_in = kvm_sched_in;
104096 - kvm_preempt_ops.sched_out = kvm_sched_out;
104097 -
104098 r = kvm_init_debug();
104099 if (r) {
104100 printk(KERN_ERR "kvm: create debugfs files failed\n");