]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.10-201304262208.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.10-201304262208.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 e2b10b9..f916aa5 100644
263 --- a/Makefile
264 +++ b/Makefile
265 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
266
267 HOSTCC = gcc
268 HOSTCXX = g++
269 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
270 -HOSTCXXFLAGS = -O2
271 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
272 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
273 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
274
275 # Decide whether to build built-in, modular, or both.
276 # Normally, just do built-in.
277 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
278 # Rules shared between *config targets and build targets
279
280 # Basic helpers built in scripts/
281 -PHONY += scripts_basic
282 -scripts_basic:
283 +PHONY += scripts_basic gcc-plugins
284 +scripts_basic: gcc-plugins
285 $(Q)$(MAKE) $(build)=scripts/basic
286 $(Q)rm -f .tmp_quiet_recordmcount
287
288 @@ -575,6 +576,65 @@ else
289 KBUILD_CFLAGS += -O2
290 endif
291
292 +ifndef DISABLE_PAX_PLUGINS
293 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
294 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
295 +else
296 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
297 +endif
298 +ifneq ($(PLUGINCC),)
299 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
300 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
301 +endif
302 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
303 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
304 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
305 +endif
306 +ifdef CONFIG_KALLOCSTAT_PLUGIN
307 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
308 +endif
309 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
310 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
311 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
312 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
313 +endif
314 +ifdef CONFIG_CHECKER_PLUGIN
315 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
316 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
317 +endif
318 +endif
319 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
320 +ifdef CONFIG_PAX_SIZE_OVERFLOW
321 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
322 +endif
323 +ifdef CONFIG_PAX_LATENT_ENTROPY
324 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
325 +endif
326 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
327 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
328 +endif
329 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
330 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
331 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
332 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
333 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
334 +ifeq ($(KBUILD_EXTMOD),)
335 +gcc-plugins:
336 + $(Q)$(MAKE) $(build)=tools/gcc
337 +else
338 +gcc-plugins: ;
339 +endif
340 +else
341 +gcc-plugins:
342 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
343 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
344 +else
345 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
346 +endif
347 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
348 +endif
349 +endif
350 +
351 include $(srctree)/arch/$(SRCARCH)/Makefile
352
353 ifdef CONFIG_READABLE_ASM
354 @@ -731,7 +791,7 @@ export mod_sign_cmd
355
356
357 ifeq ($(KBUILD_EXTMOD),)
358 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
359 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
360
361 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
362 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
363 @@ -778,6 +838,8 @@ endif
364
365 # The actual objects are generated when descending,
366 # make sure no implicit rule kicks in
367 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
368 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
369 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
370
371 # Handle descending into subdirectories listed in $(vmlinux-dirs)
372 @@ -787,7 +849,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
373 # Error messages still appears in the original language
374
375 PHONY += $(vmlinux-dirs)
376 -$(vmlinux-dirs): prepare scripts
377 +$(vmlinux-dirs): gcc-plugins prepare scripts
378 $(Q)$(MAKE) $(build)=$@
379
380 # Store (new) KERNELRELASE string in include/config/kernel.release
381 @@ -831,6 +893,7 @@ prepare0: archprepare FORCE
382 $(Q)$(MAKE) $(build)=.
383
384 # All the preparing..
385 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
386 prepare: prepare0
387
388 # Generate some files
389 @@ -938,6 +1001,8 @@ all: modules
390 # using awk while concatenating to the final file.
391
392 PHONY += modules
393 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
396 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
397 @$(kecho) ' Building modules, stage 2.';
398 @@ -953,7 +1018,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
399
400 # Target to prepare building external modules
401 PHONY += modules_prepare
402 -modules_prepare: prepare scripts
403 +modules_prepare: gcc-plugins prepare scripts
404
405 # Target to install modules
406 PHONY += modules_install
407 @@ -1019,7 +1084,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
408 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
409 signing_key.priv signing_key.x509 x509.genkey \
410 extra_certificates signing_key.x509.keyid \
411 - signing_key.x509.signer
412 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
413
414 # clean - Delete most, but leave enough to build external modules
415 #
416 @@ -1059,6 +1124,7 @@ distclean: mrproper
417 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
418 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
419 -o -name '.*.rej' \
420 + -o -name '.*.rej' -o -name '*.so' \
421 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
422 -type f -print | xargs rm -f
423
424 @@ -1219,6 +1285,8 @@ PHONY += $(module-dirs) modules
425 $(module-dirs): crmodverdir $(objtree)/Module.symvers
426 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
427
428 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
429 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
430 modules: $(module-dirs)
431 @$(kecho) ' Building modules, stage 2.';
432 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
433 @@ -1355,17 +1423,21 @@ else
434 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
435 endif
436
437 -%.s: %.c prepare scripts FORCE
438 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
439 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
440 +%.s: %.c gcc-plugins prepare scripts FORCE
441 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
442 %.i: %.c prepare scripts FORCE
443 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
444 -%.o: %.c prepare scripts FORCE
445 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
446 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
447 +%.o: %.c gcc-plugins prepare scripts FORCE
448 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
449 %.lst: %.c prepare scripts FORCE
450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
451 -%.s: %.S prepare scripts FORCE
452 +%.s: %.S gcc-plugins prepare scripts FORCE
453 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
454 -%.o: %.S prepare scripts FORCE
455 +%.o: %.S gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.symtypes: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 @@ -1375,11 +1447,15 @@ endif
460 $(cmd_crmodverdir)
461 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
462 $(build)=$(build-dir)
463 -%/: prepare scripts FORCE
464 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
465 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
466 +%/: gcc-plugins prepare scripts FORCE
467 $(cmd_crmodverdir)
468 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
469 $(build)=$(build-dir)
470 -%.ko: prepare scripts FORCE
471 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
472 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
473 +%.ko: gcc-plugins prepare scripts FORCE
474 $(cmd_crmodverdir)
475 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
476 $(build)=$(build-dir) $(@:.ko=.o)
477 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
478 index c2cbe4f..f7264b4 100644
479 --- a/arch/alpha/include/asm/atomic.h
480 +++ b/arch/alpha/include/asm/atomic.h
481 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
482 #define atomic_dec(v) atomic_sub(1,(v))
483 #define atomic64_dec(v) atomic64_sub(1,(v))
484
485 +#define atomic64_read_unchecked(v) atomic64_read(v)
486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
494 +
495 #define smp_mb__before_atomic_dec() smp_mb()
496 #define smp_mb__after_atomic_dec() smp_mb()
497 #define smp_mb__before_atomic_inc() smp_mb()
498 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
499 index ad368a9..fbe0f25 100644
500 --- a/arch/alpha/include/asm/cache.h
501 +++ b/arch/alpha/include/asm/cache.h
502 @@ -4,19 +4,19 @@
503 #ifndef __ARCH_ALPHA_CACHE_H
504 #define __ARCH_ALPHA_CACHE_H
505
506 +#include <linux/const.h>
507
508 /* Bytes per L1 (data) cache line. */
509 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
510 -# define L1_CACHE_BYTES 64
511 # define L1_CACHE_SHIFT 6
512 #else
513 /* Both EV4 and EV5 are write-through, read-allocate,
514 direct-mapped, physical.
515 */
516 -# define L1_CACHE_BYTES 32
517 # define L1_CACHE_SHIFT 5
518 #endif
519
520 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
521 #define SMP_CACHE_BYTES L1_CACHE_BYTES
522
523 #endif
524 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
525 index 968d999..d36b2df 100644
526 --- a/arch/alpha/include/asm/elf.h
527 +++ b/arch/alpha/include/asm/elf.h
528 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
529
530 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
531
532 +#ifdef CONFIG_PAX_ASLR
533 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
534 +
535 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
536 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
537 +#endif
538 +
539 /* $0 is set by ld.so to a pointer to a function which might be
540 registered using atexit. This provides a mean for the dynamic
541 linker to call DT_FINI functions for shared libraries that have
542 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
543 index bc2a0da..8ad11ee 100644
544 --- a/arch/alpha/include/asm/pgalloc.h
545 +++ b/arch/alpha/include/asm/pgalloc.h
546 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
547 pgd_set(pgd, pmd);
548 }
549
550 +static inline void
551 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
552 +{
553 + pgd_populate(mm, pgd, pmd);
554 +}
555 +
556 extern pgd_t *pgd_alloc(struct mm_struct *mm);
557
558 static inline void
559 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
560 index 81a4342..348b927 100644
561 --- a/arch/alpha/include/asm/pgtable.h
562 +++ b/arch/alpha/include/asm/pgtable.h
563 @@ -102,6 +102,17 @@ struct vm_area_struct;
564 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
565 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
566 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
567 +
568 +#ifdef CONFIG_PAX_PAGEEXEC
569 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
570 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
571 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
572 +#else
573 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
574 +# define PAGE_COPY_NOEXEC PAGE_COPY
575 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
576 +#endif
577 +
578 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
579
580 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
581 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
582 index 2fd00b7..cfd5069 100644
583 --- a/arch/alpha/kernel/module.c
584 +++ b/arch/alpha/kernel/module.c
585 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
586
587 /* The small sections were sorted to the end of the segment.
588 The following should definitely cover them. */
589 - gp = (u64)me->module_core + me->core_size - 0x8000;
590 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
591 got = sechdrs[me->arch.gotsecindex].sh_addr;
592
593 for (i = 0; i < n; i++) {
594 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
595 index 14db93e..47bed62 100644
596 --- a/arch/alpha/kernel/osf_sys.c
597 +++ b/arch/alpha/kernel/osf_sys.c
598 @@ -1295,16 +1295,16 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
599 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
600
601 static unsigned long
602 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
603 - unsigned long limit)
604 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
605 + unsigned long limit, unsigned long flags)
606 {
607 struct vm_area_struct *vma = find_vma(current->mm, addr);
608 -
609 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
610 while (1) {
611 /* At this point: (!vma || addr < vma->vm_end). */
612 if (limit - len < addr)
613 return -ENOMEM;
614 - if (!vma || addr + len <= vma->vm_start)
615 + if (check_heap_stack_gap(vma, addr, len, offset))
616 return addr;
617 addr = vma->vm_end;
618 vma = vma->vm_next;
619 @@ -1340,20 +1340,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
620 merely specific addresses, but regions of memory -- perhaps
621 this feature should be incorporated into all ports? */
622
623 +#ifdef CONFIG_PAX_RANDMMAP
624 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
625 +#endif
626 +
627 if (addr) {
628 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
629 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
630 if (addr != (unsigned long) -ENOMEM)
631 return addr;
632 }
633
634 /* Next, try allocating at TASK_UNMAPPED_BASE. */
635 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
636 - len, limit);
637 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
638 +
639 if (addr != (unsigned long) -ENOMEM)
640 return addr;
641
642 /* Finally, try allocating in low memory. */
643 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
644 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
645
646 return addr;
647 }
648 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
649 index 0c4132d..88f0d53 100644
650 --- a/arch/alpha/mm/fault.c
651 +++ b/arch/alpha/mm/fault.c
652 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
653 __reload_thread(pcb);
654 }
655
656 +#ifdef CONFIG_PAX_PAGEEXEC
657 +/*
658 + * PaX: decide what to do with offenders (regs->pc = fault address)
659 + *
660 + * returns 1 when task should be killed
661 + * 2 when patched PLT trampoline was detected
662 + * 3 when unpatched PLT trampoline was detected
663 + */
664 +static int pax_handle_fetch_fault(struct pt_regs *regs)
665 +{
666 +
667 +#ifdef CONFIG_PAX_EMUPLT
668 + int err;
669 +
670 + do { /* PaX: patched PLT emulation #1 */
671 + unsigned int ldah, ldq, jmp;
672 +
673 + err = get_user(ldah, (unsigned int *)regs->pc);
674 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
675 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
676 +
677 + if (err)
678 + break;
679 +
680 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
681 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
682 + jmp == 0x6BFB0000U)
683 + {
684 + unsigned long r27, addr;
685 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
686 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
687 +
688 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
689 + err = get_user(r27, (unsigned long *)addr);
690 + if (err)
691 + break;
692 +
693 + regs->r27 = r27;
694 + regs->pc = r27;
695 + return 2;
696 + }
697 + } while (0);
698 +
699 + do { /* PaX: patched PLT emulation #2 */
700 + unsigned int ldah, lda, br;
701 +
702 + err = get_user(ldah, (unsigned int *)regs->pc);
703 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
704 + err |= get_user(br, (unsigned int *)(regs->pc+8));
705 +
706 + if (err)
707 + break;
708 +
709 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
710 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
711 + (br & 0xFFE00000U) == 0xC3E00000U)
712 + {
713 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
714 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
715 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
716 +
717 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
718 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
719 + return 2;
720 + }
721 + } while (0);
722 +
723 + do { /* PaX: unpatched PLT emulation */
724 + unsigned int br;
725 +
726 + err = get_user(br, (unsigned int *)regs->pc);
727 +
728 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
729 + unsigned int br2, ldq, nop, jmp;
730 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
731 +
732 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
733 + err = get_user(br2, (unsigned int *)addr);
734 + err |= get_user(ldq, (unsigned int *)(addr+4));
735 + err |= get_user(nop, (unsigned int *)(addr+8));
736 + err |= get_user(jmp, (unsigned int *)(addr+12));
737 + err |= get_user(resolver, (unsigned long *)(addr+16));
738 +
739 + if (err)
740 + break;
741 +
742 + if (br2 == 0xC3600000U &&
743 + ldq == 0xA77B000CU &&
744 + nop == 0x47FF041FU &&
745 + jmp == 0x6B7B0000U)
746 + {
747 + regs->r28 = regs->pc+4;
748 + regs->r27 = addr+16;
749 + regs->pc = resolver;
750 + return 3;
751 + }
752 + }
753 + } while (0);
754 +#endif
755 +
756 + return 1;
757 +}
758 +
759 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
760 +{
761 + unsigned long i;
762 +
763 + printk(KERN_ERR "PAX: bytes at PC: ");
764 + for (i = 0; i < 5; i++) {
765 + unsigned int c;
766 + if (get_user(c, (unsigned int *)pc+i))
767 + printk(KERN_CONT "???????? ");
768 + else
769 + printk(KERN_CONT "%08x ", c);
770 + }
771 + printk("\n");
772 +}
773 +#endif
774
775 /*
776 * This routine handles page faults. It determines the address,
777 @@ -133,8 +251,29 @@ retry:
778 good_area:
779 si_code = SEGV_ACCERR;
780 if (cause < 0) {
781 - if (!(vma->vm_flags & VM_EXEC))
782 + if (!(vma->vm_flags & VM_EXEC)) {
783 +
784 +#ifdef CONFIG_PAX_PAGEEXEC
785 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
786 + goto bad_area;
787 +
788 + up_read(&mm->mmap_sem);
789 + switch (pax_handle_fetch_fault(regs)) {
790 +
791 +#ifdef CONFIG_PAX_EMUPLT
792 + case 2:
793 + case 3:
794 + return;
795 +#endif
796 +
797 + }
798 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
799 + do_group_exit(SIGKILL);
800 +#else
801 goto bad_area;
802 +#endif
803 +
804 + }
805 } else if (!cause) {
806 /* Allow reads even for write-only mappings */
807 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
808 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
809 index 67874b8..9aa2d62 100644
810 --- a/arch/arm/Kconfig
811 +++ b/arch/arm/Kconfig
812 @@ -1427,6 +1427,16 @@ config ARM_ERRATA_775420
813 to deadlock. This workaround puts DSB before executing ISB if
814 an abort may occur on cache maintenance.
815
816 +config ARM_ERRATA_798181
817 + bool "ARM errata: TLBI/DSB failure on Cortex-A15"
818 + depends on CPU_V7 && SMP
819 + help
820 + On Cortex-A15 (r0p0..r3p2) the TLBI*IS/DSB operations are not
821 + adequately shooting down all use of the old entries. This
822 + option enables the Linux kernel workaround for this erratum
823 + which sends an IPI to the CPUs that are running the same ASID
824 + as the one being invalidated.
825 +
826 endmenu
827
828 source "arch/arm/common/Kconfig"
829 @@ -1813,7 +1823,7 @@ config ALIGNMENT_TRAP
830
831 config UACCESS_WITH_MEMCPY
832 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
833 - depends on MMU
834 + depends on MMU && !PAX_MEMORY_UDEREF
835 default y if CPU_FEROCEON
836 help
837 Implement faster copy_to_user and clear_user methods for CPU
838 diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
839 index 87dfa902..3a523fc 100644
840 --- a/arch/arm/common/gic.c
841 +++ b/arch/arm/common/gic.c
842 @@ -81,7 +81,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
843 * Supported arch specific GIC irq extension.
844 * Default make them NULL.
845 */
846 -struct irq_chip gic_arch_extn = {
847 +irq_chip_no_const gic_arch_extn __read_only = {
848 .irq_eoi = NULL,
849 .irq_mask = NULL,
850 .irq_unmask = NULL,
851 @@ -329,7 +329,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
852 chained_irq_exit(chip, desc);
853 }
854
855 -static struct irq_chip gic_chip = {
856 +static irq_chip_no_const gic_chip __read_only = {
857 .name = "GIC",
858 .irq_mask = gic_mask_irq,
859 .irq_unmask = gic_unmask_irq,
860 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
861 index c79f61f..9ac0642 100644
862 --- a/arch/arm/include/asm/atomic.h
863 +++ b/arch/arm/include/asm/atomic.h
864 @@ -17,17 +17,35 @@
865 #include <asm/barrier.h>
866 #include <asm/cmpxchg.h>
867
868 +#ifdef CONFIG_GENERIC_ATOMIC64
869 +#include <asm-generic/atomic64.h>
870 +#endif
871 +
872 #define ATOMIC_INIT(i) { (i) }
873
874 #ifdef __KERNEL__
875
876 +#define _ASM_EXTABLE(from, to) \
877 +" .pushsection __ex_table,\"a\"\n"\
878 +" .align 3\n" \
879 +" .long " #from ", " #to"\n" \
880 +" .popsection"
881 +
882 /*
883 * On ARM, ordinary assignment (str instruction) doesn't clear the local
884 * strex/ldrex monitor on some implementations. The reason we can use it for
885 * atomic_set() is the clrex or dummy strex done on every exception return.
886 */
887 #define atomic_read(v) (*(volatile int *)&(v)->counter)
888 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
889 +{
890 + return v->counter;
891 +}
892 #define atomic_set(v,i) (((v)->counter) = (i))
893 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
894 +{
895 + v->counter = i;
896 +}
897
898 #if __LINUX_ARM_ARCH__ >= 6
899
900 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
901 int result;
902
903 __asm__ __volatile__("@ atomic_add\n"
904 +"1: ldrex %1, [%3]\n"
905 +" adds %0, %1, %4\n"
906 +
907 +#ifdef CONFIG_PAX_REFCOUNT
908 +" bvc 3f\n"
909 +"2: bkpt 0xf103\n"
910 +"3:\n"
911 +#endif
912 +
913 +" strex %1, %0, [%3]\n"
914 +" teq %1, #0\n"
915 +" bne 1b"
916 +
917 +#ifdef CONFIG_PAX_REFCOUNT
918 +"\n4:\n"
919 + _ASM_EXTABLE(2b, 4b)
920 +#endif
921 +
922 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
923 + : "r" (&v->counter), "Ir" (i)
924 + : "cc");
925 +}
926 +
927 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
928 +{
929 + unsigned long tmp;
930 + int result;
931 +
932 + __asm__ __volatile__("@ atomic_add_unchecked\n"
933 "1: ldrex %0, [%3]\n"
934 " add %0, %0, %4\n"
935 " strex %1, %0, [%3]\n"
936 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
937 smp_mb();
938
939 __asm__ __volatile__("@ atomic_add_return\n"
940 +"1: ldrex %1, [%3]\n"
941 +" adds %0, %1, %4\n"
942 +
943 +#ifdef CONFIG_PAX_REFCOUNT
944 +" bvc 3f\n"
945 +" mov %0, %1\n"
946 +"2: bkpt 0xf103\n"
947 +"3:\n"
948 +#endif
949 +
950 +" strex %1, %0, [%3]\n"
951 +" teq %1, #0\n"
952 +" bne 1b"
953 +
954 +#ifdef CONFIG_PAX_REFCOUNT
955 +"\n4:\n"
956 + _ASM_EXTABLE(2b, 4b)
957 +#endif
958 +
959 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
960 + : "r" (&v->counter), "Ir" (i)
961 + : "cc");
962 +
963 + smp_mb();
964 +
965 + return result;
966 +}
967 +
968 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
969 +{
970 + unsigned long tmp;
971 + int result;
972 +
973 + smp_mb();
974 +
975 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
976 "1: ldrex %0, [%3]\n"
977 " add %0, %0, %4\n"
978 " strex %1, %0, [%3]\n"
979 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
980 int result;
981
982 __asm__ __volatile__("@ atomic_sub\n"
983 +"1: ldrex %1, [%3]\n"
984 +" subs %0, %1, %4\n"
985 +
986 +#ifdef CONFIG_PAX_REFCOUNT
987 +" bvc 3f\n"
988 +"2: bkpt 0xf103\n"
989 +"3:\n"
990 +#endif
991 +
992 +" strex %1, %0, [%3]\n"
993 +" teq %1, #0\n"
994 +" bne 1b"
995 +
996 +#ifdef CONFIG_PAX_REFCOUNT
997 +"\n4:\n"
998 + _ASM_EXTABLE(2b, 4b)
999 +#endif
1000 +
1001 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1002 + : "r" (&v->counter), "Ir" (i)
1003 + : "cc");
1004 +}
1005 +
1006 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1007 +{
1008 + unsigned long tmp;
1009 + int result;
1010 +
1011 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1012 "1: ldrex %0, [%3]\n"
1013 " sub %0, %0, %4\n"
1014 " strex %1, %0, [%3]\n"
1015 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1016 smp_mb();
1017
1018 __asm__ __volatile__("@ atomic_sub_return\n"
1019 -"1: ldrex %0, [%3]\n"
1020 -" sub %0, %0, %4\n"
1021 +"1: ldrex %1, [%3]\n"
1022 +" subs %0, %1, %4\n"
1023 +
1024 +#ifdef CONFIG_PAX_REFCOUNT
1025 +" bvc 3f\n"
1026 +" mov %0, %1\n"
1027 +"2: bkpt 0xf103\n"
1028 +"3:\n"
1029 +#endif
1030 +
1031 " strex %1, %0, [%3]\n"
1032 " teq %1, #0\n"
1033 " bne 1b"
1034 +
1035 +#ifdef CONFIG_PAX_REFCOUNT
1036 +"\n4:\n"
1037 + _ASM_EXTABLE(2b, 4b)
1038 +#endif
1039 +
1040 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1041 : "r" (&v->counter), "Ir" (i)
1042 : "cc");
1043 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1044 return oldval;
1045 }
1046
1047 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1048 +{
1049 + unsigned long oldval, res;
1050 +
1051 + smp_mb();
1052 +
1053 + do {
1054 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1055 + "ldrex %1, [%3]\n"
1056 + "mov %0, #0\n"
1057 + "teq %1, %4\n"
1058 + "strexeq %0, %5, [%3]\n"
1059 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1060 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1061 + : "cc");
1062 + } while (res);
1063 +
1064 + smp_mb();
1065 +
1066 + return oldval;
1067 +}
1068 +
1069 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1070 {
1071 unsigned long tmp, tmp2;
1072 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1073
1074 return val;
1075 }
1076 +
1077 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1078 +{
1079 + return atomic_add_return(i, v);
1080 +}
1081 +
1082 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1083 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1084 +{
1085 + (void) atomic_add_return(i, v);
1086 +}
1087
1088 static inline int atomic_sub_return(int i, atomic_t *v)
1089 {
1090 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1091 return val;
1092 }
1093 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1094 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1095 +{
1096 + (void) atomic_sub_return(i, v);
1097 +}
1098
1099 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1100 {
1101 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1102 return ret;
1103 }
1104
1105 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1106 +{
1107 + return atomic_cmpxchg(v, old, new);
1108 +}
1109 +
1110 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1111 {
1112 unsigned long flags;
1113 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1114 #endif /* __LINUX_ARM_ARCH__ */
1115
1116 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1117 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1118 +{
1119 + return xchg(&v->counter, new);
1120 +}
1121
1122 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1123 {
1124 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1125 }
1126
1127 #define atomic_inc(v) atomic_add(1, v)
1128 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1129 +{
1130 + atomic_add_unchecked(1, v);
1131 +}
1132 #define atomic_dec(v) atomic_sub(1, v)
1133 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1134 +{
1135 + atomic_sub_unchecked(1, v);
1136 +}
1137
1138 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1139 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1140 +{
1141 + return atomic_add_return_unchecked(1, v) == 0;
1142 +}
1143 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1144 #define atomic_inc_return(v) (atomic_add_return(1, v))
1145 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1146 +{
1147 + return atomic_add_return_unchecked(1, v);
1148 +}
1149 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1150 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1151
1152 @@ -241,6 +428,14 @@ typedef struct {
1153 u64 __aligned(8) counter;
1154 } atomic64_t;
1155
1156 +#ifdef CONFIG_PAX_REFCOUNT
1157 +typedef struct {
1158 + u64 __aligned(8) counter;
1159 +} atomic64_unchecked_t;
1160 +#else
1161 +typedef atomic64_t atomic64_unchecked_t;
1162 +#endif
1163 +
1164 #define ATOMIC64_INIT(i) { (i) }
1165
1166 static inline u64 atomic64_read(const atomic64_t *v)
1167 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1168 return result;
1169 }
1170
1171 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1172 +{
1173 + u64 result;
1174 +
1175 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1176 +" ldrexd %0, %H0, [%1]"
1177 + : "=&r" (result)
1178 + : "r" (&v->counter), "Qo" (v->counter)
1179 + );
1180 +
1181 + return result;
1182 +}
1183 +
1184 static inline void atomic64_set(atomic64_t *v, u64 i)
1185 {
1186 u64 tmp;
1187 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1188 : "cc");
1189 }
1190
1191 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1192 +{
1193 + u64 tmp;
1194 +
1195 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1196 +"1: ldrexd %0, %H0, [%2]\n"
1197 +" strexd %0, %3, %H3, [%2]\n"
1198 +" teq %0, #0\n"
1199 +" bne 1b"
1200 + : "=&r" (tmp), "=Qo" (v->counter)
1201 + : "r" (&v->counter), "r" (i)
1202 + : "cc");
1203 +}
1204 +
1205 static inline void atomic64_add(u64 i, atomic64_t *v)
1206 {
1207 u64 result;
1208 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1209 __asm__ __volatile__("@ atomic64_add\n"
1210 "1: ldrexd %0, %H0, [%3]\n"
1211 " adds %0, %0, %4\n"
1212 +" adcs %H0, %H0, %H4\n"
1213 +
1214 +#ifdef CONFIG_PAX_REFCOUNT
1215 +" bvc 3f\n"
1216 +"2: bkpt 0xf103\n"
1217 +"3:\n"
1218 +#endif
1219 +
1220 +" strexd %1, %0, %H0, [%3]\n"
1221 +" teq %1, #0\n"
1222 +" bne 1b"
1223 +
1224 +#ifdef CONFIG_PAX_REFCOUNT
1225 +"\n4:\n"
1226 + _ASM_EXTABLE(2b, 4b)
1227 +#endif
1228 +
1229 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1230 + : "r" (&v->counter), "r" (i)
1231 + : "cc");
1232 +}
1233 +
1234 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1235 +{
1236 + u64 result;
1237 + unsigned long tmp;
1238 +
1239 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1240 +"1: ldrexd %0, %H0, [%3]\n"
1241 +" adds %0, %0, %4\n"
1242 " adc %H0, %H0, %H4\n"
1243 " strexd %1, %0, %H0, [%3]\n"
1244 " teq %1, #0\n"
1245 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1246
1247 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1248 {
1249 - u64 result;
1250 - unsigned long tmp;
1251 + u64 result, tmp;
1252
1253 smp_mb();
1254
1255 __asm__ __volatile__("@ atomic64_add_return\n"
1256 +"1: ldrexd %1, %H1, [%3]\n"
1257 +" adds %0, %1, %4\n"
1258 +" adcs %H0, %H1, %H4\n"
1259 +
1260 +#ifdef CONFIG_PAX_REFCOUNT
1261 +" bvc 3f\n"
1262 +" mov %0, %1\n"
1263 +" mov %H0, %H1\n"
1264 +"2: bkpt 0xf103\n"
1265 +"3:\n"
1266 +#endif
1267 +
1268 +" strexd %1, %0, %H0, [%3]\n"
1269 +" teq %1, #0\n"
1270 +" bne 1b"
1271 +
1272 +#ifdef CONFIG_PAX_REFCOUNT
1273 +"\n4:\n"
1274 + _ASM_EXTABLE(2b, 4b)
1275 +#endif
1276 +
1277 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1278 + : "r" (&v->counter), "r" (i)
1279 + : "cc");
1280 +
1281 + smp_mb();
1282 +
1283 + return result;
1284 +}
1285 +
1286 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1287 +{
1288 + u64 result;
1289 + unsigned long tmp;
1290 +
1291 + smp_mb();
1292 +
1293 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1294 "1: ldrexd %0, %H0, [%3]\n"
1295 " adds %0, %0, %4\n"
1296 " adc %H0, %H0, %H4\n"
1297 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1298 __asm__ __volatile__("@ atomic64_sub\n"
1299 "1: ldrexd %0, %H0, [%3]\n"
1300 " subs %0, %0, %4\n"
1301 +" sbcs %H0, %H0, %H4\n"
1302 +
1303 +#ifdef CONFIG_PAX_REFCOUNT
1304 +" bvc 3f\n"
1305 +"2: bkpt 0xf103\n"
1306 +"3:\n"
1307 +#endif
1308 +
1309 +" strexd %1, %0, %H0, [%3]\n"
1310 +" teq %1, #0\n"
1311 +" bne 1b"
1312 +
1313 +#ifdef CONFIG_PAX_REFCOUNT
1314 +"\n4:\n"
1315 + _ASM_EXTABLE(2b, 4b)
1316 +#endif
1317 +
1318 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1319 + : "r" (&v->counter), "r" (i)
1320 + : "cc");
1321 +}
1322 +
1323 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1324 +{
1325 + u64 result;
1326 + unsigned long tmp;
1327 +
1328 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1329 +"1: ldrexd %0, %H0, [%3]\n"
1330 +" subs %0, %0, %4\n"
1331 " sbc %H0, %H0, %H4\n"
1332 " strexd %1, %0, %H0, [%3]\n"
1333 " teq %1, #0\n"
1334 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1335
1336 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1337 {
1338 - u64 result;
1339 - unsigned long tmp;
1340 + u64 result, tmp;
1341
1342 smp_mb();
1343
1344 __asm__ __volatile__("@ atomic64_sub_return\n"
1345 -"1: ldrexd %0, %H0, [%3]\n"
1346 -" subs %0, %0, %4\n"
1347 -" sbc %H0, %H0, %H4\n"
1348 +"1: ldrexd %1, %H1, [%3]\n"
1349 +" subs %0, %1, %4\n"
1350 +" sbcs %H0, %H1, %H4\n"
1351 +
1352 +#ifdef CONFIG_PAX_REFCOUNT
1353 +" bvc 3f\n"
1354 +" mov %0, %1\n"
1355 +" mov %H0, %H1\n"
1356 +"2: bkpt 0xf103\n"
1357 +"3:\n"
1358 +#endif
1359 +
1360 " strexd %1, %0, %H0, [%3]\n"
1361 " teq %1, #0\n"
1362 " bne 1b"
1363 +
1364 +#ifdef CONFIG_PAX_REFCOUNT
1365 +"\n4:\n"
1366 + _ASM_EXTABLE(2b, 4b)
1367 +#endif
1368 +
1369 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1370 : "r" (&v->counter), "r" (i)
1371 : "cc");
1372 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1373 return oldval;
1374 }
1375
1376 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1377 +{
1378 + u64 oldval;
1379 + unsigned long res;
1380 +
1381 + smp_mb();
1382 +
1383 + do {
1384 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1385 + "ldrexd %1, %H1, [%3]\n"
1386 + "mov %0, #0\n"
1387 + "teq %1, %4\n"
1388 + "teqeq %H1, %H4\n"
1389 + "strexdeq %0, %5, %H5, [%3]"
1390 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1391 + : "r" (&ptr->counter), "r" (old), "r" (new)
1392 + : "cc");
1393 + } while (res);
1394 +
1395 + smp_mb();
1396 +
1397 + return oldval;
1398 +}
1399 +
1400 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1401 {
1402 u64 result;
1403 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1404
1405 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1406 {
1407 - u64 result;
1408 - unsigned long tmp;
1409 + u64 result, tmp;
1410
1411 smp_mb();
1412
1413 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1414 -"1: ldrexd %0, %H0, [%3]\n"
1415 -" subs %0, %0, #1\n"
1416 -" sbc %H0, %H0, #0\n"
1417 +"1: ldrexd %1, %H1, [%3]\n"
1418 +" subs %0, %1, #1\n"
1419 +" sbcs %H0, %H1, #0\n"
1420 +
1421 +#ifdef CONFIG_PAX_REFCOUNT
1422 +" bvc 3f\n"
1423 +" mov %0, %1\n"
1424 +" mov %H0, %H1\n"
1425 +"2: bkpt 0xf103\n"
1426 +"3:\n"
1427 +#endif
1428 +
1429 " teq %H0, #0\n"
1430 -" bmi 2f\n"
1431 +" bmi 4f\n"
1432 " strexd %1, %0, %H0, [%3]\n"
1433 " teq %1, #0\n"
1434 " bne 1b\n"
1435 -"2:"
1436 +"4:\n"
1437 +
1438 +#ifdef CONFIG_PAX_REFCOUNT
1439 + _ASM_EXTABLE(2b, 4b)
1440 +#endif
1441 +
1442 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1443 : "r" (&v->counter)
1444 : "cc");
1445 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1446 " teq %0, %5\n"
1447 " teqeq %H0, %H5\n"
1448 " moveq %1, #0\n"
1449 -" beq 2f\n"
1450 +" beq 4f\n"
1451 " adds %0, %0, %6\n"
1452 -" adc %H0, %H0, %H6\n"
1453 +" adcs %H0, %H0, %H6\n"
1454 +
1455 +#ifdef CONFIG_PAX_REFCOUNT
1456 +" bvc 3f\n"
1457 +"2: bkpt 0xf103\n"
1458 +"3:\n"
1459 +#endif
1460 +
1461 " strexd %2, %0, %H0, [%4]\n"
1462 " teq %2, #0\n"
1463 " bne 1b\n"
1464 -"2:"
1465 +"4:\n"
1466 +
1467 +#ifdef CONFIG_PAX_REFCOUNT
1468 + _ASM_EXTABLE(2b, 4b)
1469 +#endif
1470 +
1471 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1472 : "r" (&v->counter), "r" (u), "r" (a)
1473 : "cc");
1474 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1475
1476 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1477 #define atomic64_inc(v) atomic64_add(1LL, (v))
1478 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1479 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1480 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1481 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1482 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1483 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1484 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1485 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1486 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1487 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1488 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1489 index 75fe66b..ba3dee4 100644
1490 --- a/arch/arm/include/asm/cache.h
1491 +++ b/arch/arm/include/asm/cache.h
1492 @@ -4,8 +4,10 @@
1493 #ifndef __ASMARM_CACHE_H
1494 #define __ASMARM_CACHE_H
1495
1496 +#include <linux/const.h>
1497 +
1498 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1499 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1500 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1501
1502 /*
1503 * Memory returned by kmalloc() may be used for DMA, so we must make
1504 @@ -24,5 +26,6 @@
1505 #endif
1506
1507 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1508 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1509
1510 #endif
1511 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1512 index e1489c5..d418304 100644
1513 --- a/arch/arm/include/asm/cacheflush.h
1514 +++ b/arch/arm/include/asm/cacheflush.h
1515 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1516 void (*dma_unmap_area)(const void *, size_t, int);
1517
1518 void (*dma_flush_range)(const void *, const void *);
1519 -};
1520 +} __no_const;
1521
1522 /*
1523 * Select the calling method
1524 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1525 index 6dcc164..b14d917 100644
1526 --- a/arch/arm/include/asm/checksum.h
1527 +++ b/arch/arm/include/asm/checksum.h
1528 @@ -37,7 +37,19 @@ __wsum
1529 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1530
1531 __wsum
1532 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1533 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1534 +
1535 +static inline __wsum
1536 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1537 +{
1538 + __wsum ret;
1539 + pax_open_userland();
1540 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1541 + pax_close_userland();
1542 + return ret;
1543 +}
1544 +
1545 +
1546
1547 /*
1548 * Fold a partial checksum without adding pseudo headers
1549 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1550 index 7eb18c1..e38b6d2 100644
1551 --- a/arch/arm/include/asm/cmpxchg.h
1552 +++ b/arch/arm/include/asm/cmpxchg.h
1553 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1554
1555 #define xchg(ptr,x) \
1556 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1557 +#define xchg_unchecked(ptr,x) \
1558 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1559
1560 #include <asm-generic/cmpxchg-local.h>
1561
1562 diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h
1563 index 720799f..2f67631 100644
1564 --- a/arch/arm/include/asm/delay.h
1565 +++ b/arch/arm/include/asm/delay.h
1566 @@ -25,9 +25,9 @@ extern struct arm_delay_ops {
1567 void (*const_udelay)(unsigned long);
1568 void (*udelay)(unsigned long);
1569 bool const_clock;
1570 -} arm_delay_ops;
1571 +} *arm_delay_ops;
1572
1573 -#define __delay(n) arm_delay_ops.delay(n)
1574 +#define __delay(n) arm_delay_ops->delay(n)
1575
1576 /*
1577 * This function intentionally does not exist; if you see references to
1578 @@ -48,8 +48,8 @@ extern void __bad_udelay(void);
1579 * first constant multiplications gets optimized away if the delay is
1580 * a constant)
1581 */
1582 -#define __udelay(n) arm_delay_ops.udelay(n)
1583 -#define __const_udelay(n) arm_delay_ops.const_udelay(n)
1584 +#define __udelay(n) arm_delay_ops->udelay(n)
1585 +#define __const_udelay(n) arm_delay_ops->const_udelay(n)
1586
1587 #define udelay(n) \
1588 (__builtin_constant_p(n) ? \
1589 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1590 index 6ddbe44..b5e38b1 100644
1591 --- a/arch/arm/include/asm/domain.h
1592 +++ b/arch/arm/include/asm/domain.h
1593 @@ -48,18 +48,37 @@
1594 * Domain types
1595 */
1596 #define DOMAIN_NOACCESS 0
1597 -#define DOMAIN_CLIENT 1
1598 #ifdef CONFIG_CPU_USE_DOMAINS
1599 +#define DOMAIN_USERCLIENT 1
1600 +#define DOMAIN_KERNELCLIENT 1
1601 #define DOMAIN_MANAGER 3
1602 +#define DOMAIN_VECTORS DOMAIN_USER
1603 #else
1604 +
1605 +#ifdef CONFIG_PAX_KERNEXEC
1606 #define DOMAIN_MANAGER 1
1607 +#define DOMAIN_KERNEXEC 3
1608 +#else
1609 +#define DOMAIN_MANAGER 1
1610 +#endif
1611 +
1612 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1613 +#define DOMAIN_USERCLIENT 0
1614 +#define DOMAIN_UDEREF 1
1615 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1616 +#else
1617 +#define DOMAIN_USERCLIENT 1
1618 +#define DOMAIN_VECTORS DOMAIN_USER
1619 +#endif
1620 +#define DOMAIN_KERNELCLIENT 1
1621 +
1622 #endif
1623
1624 #define domain_val(dom,type) ((type) << (2*(dom)))
1625
1626 #ifndef __ASSEMBLY__
1627
1628 -#ifdef CONFIG_CPU_USE_DOMAINS
1629 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1630 static inline void set_domain(unsigned val)
1631 {
1632 asm volatile(
1633 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1634 isb();
1635 }
1636
1637 -#define modify_domain(dom,type) \
1638 - do { \
1639 - struct thread_info *thread = current_thread_info(); \
1640 - unsigned int domain = thread->cpu_domain; \
1641 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1642 - thread->cpu_domain = domain | domain_val(dom, type); \
1643 - set_domain(thread->cpu_domain); \
1644 - } while (0)
1645 -
1646 +extern void modify_domain(unsigned int dom, unsigned int type);
1647 #else
1648 static inline void set_domain(unsigned val) { }
1649 static inline void modify_domain(unsigned dom, unsigned type) { }
1650 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1651 index 38050b1..9d90e8b 100644
1652 --- a/arch/arm/include/asm/elf.h
1653 +++ b/arch/arm/include/asm/elf.h
1654 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1655 the loader. We need to make sure that it is out of the way of the program
1656 that it will "exec", and that there is sufficient room for the brk. */
1657
1658 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1659 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1660 +
1661 +#ifdef CONFIG_PAX_ASLR
1662 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1663 +
1664 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1665 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1666 +#endif
1667
1668 /* When the program starts, a1 contains a pointer to a function to be
1669 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1670 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1671 extern void elf_set_personality(const struct elf32_hdr *);
1672 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1673
1674 -struct mm_struct;
1675 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1676 -#define arch_randomize_brk arch_randomize_brk
1677 -
1678 #endif
1679 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1680 index de53547..52b9a28 100644
1681 --- a/arch/arm/include/asm/fncpy.h
1682 +++ b/arch/arm/include/asm/fncpy.h
1683 @@ -81,7 +81,9 @@
1684 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1685 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1686 \
1687 + pax_open_kernel(); \
1688 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1689 + pax_close_kernel(); \
1690 flush_icache_range((unsigned long)(dest_buf), \
1691 (unsigned long)(dest_buf) + (size)); \
1692 \
1693 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1694 index e42cf59..7b94b8f 100644
1695 --- a/arch/arm/include/asm/futex.h
1696 +++ b/arch/arm/include/asm/futex.h
1697 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1698 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1699 return -EFAULT;
1700
1701 + pax_open_userland();
1702 +
1703 smp_mb();
1704 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1705 "1: ldrex %1, [%4]\n"
1706 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1707 : "cc", "memory");
1708 smp_mb();
1709
1710 + pax_close_userland();
1711 +
1712 *uval = val;
1713 return ret;
1714 }
1715 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1716 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1717 return -EFAULT;
1718
1719 + pax_open_userland();
1720 +
1721 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1722 "1: " TUSER(ldr) " %1, [%4]\n"
1723 " teq %1, %2\n"
1724 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1725 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1726 : "cc", "memory");
1727
1728 + pax_close_userland();
1729 +
1730 *uval = val;
1731 return ret;
1732 }
1733 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1734 return -EFAULT;
1735
1736 pagefault_disable(); /* implies preempt_disable() */
1737 + pax_open_userland();
1738
1739 switch (op) {
1740 case FUTEX_OP_SET:
1741 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1742 ret = -ENOSYS;
1743 }
1744
1745 + pax_close_userland();
1746 pagefault_enable(); /* subsumes preempt_enable() */
1747
1748 if (!ret) {
1749 diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h
1750 index 4b1ce6c..bea3f73 100644
1751 --- a/arch/arm/include/asm/hardware/gic.h
1752 +++ b/arch/arm/include/asm/hardware/gic.h
1753 @@ -34,9 +34,10 @@
1754
1755 #ifndef __ASSEMBLY__
1756 #include <linux/irqdomain.h>
1757 +#include <linux/irq.h>
1758 struct device_node;
1759
1760 -extern struct irq_chip gic_arch_extn;
1761 +extern irq_chip_no_const gic_arch_extn;
1762
1763 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
1764 u32 offset, struct device_node *);
1765 diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
1766 index 8c5e828..91b99ab 100644
1767 --- a/arch/arm/include/asm/highmem.h
1768 +++ b/arch/arm/include/asm/highmem.h
1769 @@ -41,6 +41,13 @@ extern void kunmap_high(struct page *page);
1770 #endif
1771 #endif
1772
1773 +/*
1774 + * Needed to be able to broadcast the TLB invalidation for kmap.
1775 + */
1776 +#ifdef CONFIG_ARM_ERRATA_798181
1777 +#undef ARCH_NEEDS_KMAP_HIGH_GET
1778 +#endif
1779 +
1780 #ifdef ARCH_NEEDS_KMAP_HIGH_GET
1781 extern void *kmap_high_get(struct page *page);
1782 #else
1783 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1784 index 83eb2f7..ed77159 100644
1785 --- a/arch/arm/include/asm/kmap_types.h
1786 +++ b/arch/arm/include/asm/kmap_types.h
1787 @@ -4,6 +4,6 @@
1788 /*
1789 * This is the "bare minimum". AIO seems to require this.
1790 */
1791 -#define KM_TYPE_NR 16
1792 +#define KM_TYPE_NR 17
1793
1794 #endif
1795 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1796 index 9e614a1..3302cca 100644
1797 --- a/arch/arm/include/asm/mach/dma.h
1798 +++ b/arch/arm/include/asm/mach/dma.h
1799 @@ -22,7 +22,7 @@ struct dma_ops {
1800 int (*residue)(unsigned int, dma_t *); /* optional */
1801 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1802 const char *type;
1803 -};
1804 +} __do_const;
1805
1806 struct dma_struct {
1807 void *addr; /* single DMA address */
1808 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1809 index 2fe141f..192dc01 100644
1810 --- a/arch/arm/include/asm/mach/map.h
1811 +++ b/arch/arm/include/asm/mach/map.h
1812 @@ -27,13 +27,16 @@ struct map_desc {
1813 #define MT_MINICLEAN 6
1814 #define MT_LOW_VECTORS 7
1815 #define MT_HIGH_VECTORS 8
1816 -#define MT_MEMORY 9
1817 +#define MT_MEMORY_RWX 9
1818 #define MT_ROM 10
1819 -#define MT_MEMORY_NONCACHED 11
1820 +#define MT_MEMORY_NONCACHED_RX 11
1821 #define MT_MEMORY_DTCM 12
1822 #define MT_MEMORY_ITCM 13
1823 #define MT_MEMORY_SO 14
1824 #define MT_MEMORY_DMA_READY 15
1825 +#define MT_MEMORY_RW 16
1826 +#define MT_MEMORY_RX 17
1827 +#define MT_MEMORY_NONCACHED_RW 18
1828
1829 #ifdef CONFIG_MMU
1830 extern void iotable_init(struct map_desc *, int);
1831 diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
1832 index 863a661..a7b85e0 100644
1833 --- a/arch/arm/include/asm/mmu_context.h
1834 +++ b/arch/arm/include/asm/mmu_context.h
1835 @@ -27,6 +27,8 @@ void __check_vmalloc_seq(struct mm_struct *mm);
1836 void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
1837 #define init_new_context(tsk,mm) ({ atomic64_set(&mm->context.id, 0); 0; })
1838
1839 +DECLARE_PER_CPU(atomic64_t, active_asids);
1840 +
1841 #else /* !CONFIG_CPU_HAS_ASID */
1842
1843 #ifdef CONFIG_MMU
1844 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1845 index 53426c6..c7baff3 100644
1846 --- a/arch/arm/include/asm/outercache.h
1847 +++ b/arch/arm/include/asm/outercache.h
1848 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1849 #endif
1850 void (*set_debug)(unsigned long);
1851 void (*resume)(void);
1852 -};
1853 +} __no_const;
1854
1855 #ifdef CONFIG_OUTER_CACHE
1856
1857 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1858 index 812a494..71fc0b6 100644
1859 --- a/arch/arm/include/asm/page.h
1860 +++ b/arch/arm/include/asm/page.h
1861 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1862 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1863 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1864 unsigned long vaddr, struct vm_area_struct *vma);
1865 -};
1866 +} __no_const;
1867
1868 #ifdef MULTI_USER
1869 extern struct cpu_user_fns cpu_user;
1870 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1871 index 943504f..c37a730 100644
1872 --- a/arch/arm/include/asm/pgalloc.h
1873 +++ b/arch/arm/include/asm/pgalloc.h
1874 @@ -17,6 +17,7 @@
1875 #include <asm/processor.h>
1876 #include <asm/cacheflush.h>
1877 #include <asm/tlbflush.h>
1878 +#include <asm/system_info.h>
1879
1880 #define check_pgt_cache() do { } while (0)
1881
1882 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1883 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1884 }
1885
1886 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1887 +{
1888 + pud_populate(mm, pud, pmd);
1889 +}
1890 +
1891 #else /* !CONFIG_ARM_LPAE */
1892
1893 /*
1894 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1895 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1896 #define pmd_free(mm, pmd) do { } while (0)
1897 #define pud_populate(mm,pmd,pte) BUG()
1898 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1899
1900 #endif /* CONFIG_ARM_LPAE */
1901
1902 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1903 __free_page(pte);
1904 }
1905
1906 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1907 +{
1908 +#ifdef CONFIG_ARM_LPAE
1909 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1910 +#else
1911 + if (addr & SECTION_SIZE)
1912 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1913 + else
1914 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1915 +#endif
1916 + flush_pmd_entry(pmdp);
1917 +}
1918 +
1919 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1920 pmdval_t prot)
1921 {
1922 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1923 static inline void
1924 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1925 {
1926 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1927 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1928 }
1929 #define pmd_pgtable(pmd) pmd_page(pmd)
1930
1931 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1932 index 5cfba15..f415e1a 100644
1933 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1934 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1935 @@ -20,12 +20,15 @@
1936 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1937 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1938 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1939 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1940 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1941 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1942 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1943 +
1944 /*
1945 * - section
1946 */
1947 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1948 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1949 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1950 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1951 @@ -37,6 +40,7 @@
1952 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1953 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1954 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1955 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1956
1957 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1958 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1959 @@ -66,6 +70,7 @@
1960 * - extended small page/tiny page
1961 */
1962 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1963 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1964 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1965 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1966 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1967 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1968 index f97ee02..07f1be5 100644
1969 --- a/arch/arm/include/asm/pgtable-2level.h
1970 +++ b/arch/arm/include/asm/pgtable-2level.h
1971 @@ -125,6 +125,7 @@
1972 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1973 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1974 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1975 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1976
1977 /*
1978 * These are the memory types, defined to be compatible with
1979 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1980 index d795282..a43ea90 100644
1981 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1982 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1983 @@ -32,15 +32,18 @@
1984 #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
1985 #define PMD_BIT4 (_AT(pmdval_t, 0))
1986 #define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
1987 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 59) /* PXNTable */
1988
1989 /*
1990 * - section
1991 */
1992 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1993 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1994 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1995 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1996 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1997 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1998 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
1999 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54)
2000 #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0))
2001 #define PMD_SECT_AP_READ (_AT(pmdval_t, 0))
2002 @@ -66,6 +69,7 @@
2003 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2004 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
2005 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
2006 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2007 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
2008
2009 /*
2010 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
2011 index a3f3792..7b932a6 100644
2012 --- a/arch/arm/include/asm/pgtable-3level.h
2013 +++ b/arch/arm/include/asm/pgtable-3level.h
2014 @@ -74,6 +74,7 @@
2015 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
2016 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2017 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
2018 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2019 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
2020 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
2021 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
2022 @@ -82,6 +83,7 @@
2023 /*
2024 * To be used in assembly code with the upper page attributes.
2025 */
2026 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
2027 #define L_PTE_XN_HIGH (1 << (54 - 32))
2028 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2029
2030 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2031 index c094749..a6ff605 100644
2032 --- a/arch/arm/include/asm/pgtable.h
2033 +++ b/arch/arm/include/asm/pgtable.h
2034 @@ -30,6 +30,9 @@
2035 #include <asm/pgtable-2level.h>
2036 #endif
2037
2038 +#define ktla_ktva(addr) (addr)
2039 +#define ktva_ktla(addr) (addr)
2040 +
2041 /*
2042 * Just any arbitrary offset to the start of the vmalloc VM area: the
2043 * current 8MB value just means that there will be a 8MB "hole" after the
2044 @@ -45,6 +48,9 @@
2045 #define LIBRARY_TEXT_START 0x0c000000
2046
2047 #ifndef __ASSEMBLY__
2048 +extern pteval_t __supported_pte_mask;
2049 +extern pmdval_t __supported_pmd_mask;
2050 +
2051 extern void __pte_error(const char *file, int line, pte_t);
2052 extern void __pmd_error(const char *file, int line, pmd_t);
2053 extern void __pgd_error(const char *file, int line, pgd_t);
2054 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2055 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2056 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2057
2058 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2059 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2060 +
2061 +#ifdef CONFIG_PAX_KERNEXEC
2062 +#include <asm/domain.h>
2063 +#include <linux/thread_info.h>
2064 +#include <linux/preempt.h>
2065 +#endif
2066 +
2067 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2068 +static inline int test_domain(int domain, int domaintype)
2069 +{
2070 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2071 +}
2072 +#endif
2073 +
2074 +#ifdef CONFIG_PAX_KERNEXEC
2075 +static inline unsigned long pax_open_kernel(void) {
2076 +#ifdef CONFIG_ARM_LPAE
2077 + /* TODO */
2078 +#else
2079 + preempt_disable();
2080 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2081 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2082 +#endif
2083 + return 0;
2084 +}
2085 +
2086 +static inline unsigned long pax_close_kernel(void) {
2087 +#ifdef CONFIG_ARM_LPAE
2088 + /* TODO */
2089 +#else
2090 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2091 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2092 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2093 + preempt_enable_no_resched();
2094 +#endif
2095 + return 0;
2096 +}
2097 +#else
2098 +static inline unsigned long pax_open_kernel(void) { return 0; }
2099 +static inline unsigned long pax_close_kernel(void) { return 0; }
2100 +#endif
2101 +
2102 /*
2103 * This is the lowest virtual address we can permit any user space
2104 * mapping to be mapped at. This is particularly important for
2105 @@ -63,8 +113,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2106 /*
2107 * The pgprot_* and protection_map entries will be fixed up in runtime
2108 * to include the cachable and bufferable bits based on memory policy,
2109 - * as well as any architecture dependent bits like global/ASID and SMP
2110 - * shared mapping bits.
2111 + * as well as any architecture dependent bits like global/ASID, PXN,
2112 + * and SMP shared mapping bits.
2113 */
2114 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2115
2116 @@ -241,7 +291,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2117 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2118 {
2119 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2120 - L_PTE_NONE | L_PTE_VALID;
2121 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2122 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2123 return pte;
2124 }
2125 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2126 index f3628fb..a0672dd 100644
2127 --- a/arch/arm/include/asm/proc-fns.h
2128 +++ b/arch/arm/include/asm/proc-fns.h
2129 @@ -75,7 +75,7 @@ extern struct processor {
2130 unsigned int suspend_size;
2131 void (*do_suspend)(void *);
2132 void (*do_resume)(void *);
2133 -} processor;
2134 +} __do_const processor;
2135
2136 #ifndef MULTI_CPU
2137 extern void cpu_proc_init(void);
2138 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2139 index 06e7d50..8a8e251 100644
2140 --- a/arch/arm/include/asm/processor.h
2141 +++ b/arch/arm/include/asm/processor.h
2142 @@ -65,9 +65,8 @@ struct thread_struct {
2143 regs->ARM_cpsr |= PSR_ENDSTATE; \
2144 regs->ARM_pc = pc & ~1; /* pc */ \
2145 regs->ARM_sp = sp; /* sp */ \
2146 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2147 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2148 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2149 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2150 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2151 nommu_start_thread(regs); \
2152 })
2153
2154 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2155 index d3a22be..3a69ad5 100644
2156 --- a/arch/arm/include/asm/smp.h
2157 +++ b/arch/arm/include/asm/smp.h
2158 @@ -107,7 +107,7 @@ struct smp_operations {
2159 int (*cpu_disable)(unsigned int cpu);
2160 #endif
2161 #endif
2162 -};
2163 +} __no_const;
2164
2165 /*
2166 * set platform specific SMP operations
2167 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2168 index cddda1f..ff357f7 100644
2169 --- a/arch/arm/include/asm/thread_info.h
2170 +++ b/arch/arm/include/asm/thread_info.h
2171 @@ -77,9 +77,9 @@ struct thread_info {
2172 .flags = 0, \
2173 .preempt_count = INIT_PREEMPT_COUNT, \
2174 .addr_limit = KERNEL_DS, \
2175 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2176 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2177 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2178 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2179 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2180 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2181 .restart_block = { \
2182 .fn = do_no_restart_syscall, \
2183 }, \
2184 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2185 #define TIF_SYSCALL_AUDIT 9
2186 #define TIF_SYSCALL_TRACEPOINT 10
2187 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2188 +
2189 +/* within 8 bits of TIF_SYSCALL_TRACE
2190 + * to meet flexible second operand requirements
2191 + */
2192 +#define TIF_GRSEC_SETXID 12
2193 +
2194 #define TIF_USING_IWMMXT 17
2195 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2196 #define TIF_RESTORE_SIGMASK 20
2197 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2198 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2199 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2200 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2201 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2202
2203 /* Checks for any syscall work in entry-common.S */
2204 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2205 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2206 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2207
2208 /*
2209 * Change these and you break ASM code in entry-common.S
2210 diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h
2211 index 6e924d3..a9f3ddf 100644
2212 --- a/arch/arm/include/asm/tlbflush.h
2213 +++ b/arch/arm/include/asm/tlbflush.h
2214 @@ -430,6 +430,21 @@ static inline void local_flush_tlb_kernel_page(unsigned long kaddr)
2215 }
2216 }
2217
2218 +#ifdef CONFIG_ARM_ERRATA_798181
2219 +static inline void dummy_flush_tlb_a15_erratum(void)
2220 +{
2221 + /*
2222 + * Dummy TLBIMVAIS. Using the unmapped address 0 and ASID 0.
2223 + */
2224 + asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0));
2225 + dsb();
2226 +}
2227 +#else
2228 +static inline void dummy_flush_tlb_a15_erratum(void)
2229 +{
2230 +}
2231 +#endif
2232 +
2233 /*
2234 * flush_pmd_entry
2235 *
2236 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2237 index 7e1f760..752fcb7 100644
2238 --- a/arch/arm/include/asm/uaccess.h
2239 +++ b/arch/arm/include/asm/uaccess.h
2240 @@ -18,6 +18,7 @@
2241 #include <asm/domain.h>
2242 #include <asm/unified.h>
2243 #include <asm/compiler.h>
2244 +#include <asm/pgtable.h>
2245
2246 #define VERIFY_READ 0
2247 #define VERIFY_WRITE 1
2248 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2249 #define USER_DS TASK_SIZE
2250 #define get_fs() (current_thread_info()->addr_limit)
2251
2252 +static inline void pax_open_userland(void)
2253 +{
2254 +
2255 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2256 + if (get_fs() == USER_DS) {
2257 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2258 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2259 + }
2260 +#endif
2261 +
2262 +}
2263 +
2264 +static inline void pax_close_userland(void)
2265 +{
2266 +
2267 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2268 + if (get_fs() == USER_DS) {
2269 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2270 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2271 + }
2272 +#endif
2273 +
2274 +}
2275 +
2276 static inline void set_fs(mm_segment_t fs)
2277 {
2278 current_thread_info()->addr_limit = fs;
2279 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2280 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2281 }
2282
2283 #define segment_eq(a,b) ((a) == (b))
2284 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2285
2286 #define get_user(x,p) \
2287 ({ \
2288 + int __e; \
2289 might_fault(); \
2290 - __get_user_check(x,p); \
2291 + pax_open_userland(); \
2292 + __e = __get_user_check(x,p); \
2293 + pax_close_userland(); \
2294 + __e; \
2295 })
2296
2297 extern int __put_user_1(void *, unsigned int);
2298 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2299
2300 #define put_user(x,p) \
2301 ({ \
2302 + int __e; \
2303 might_fault(); \
2304 - __put_user_check(x,p); \
2305 + pax_open_userland(); \
2306 + __e = __put_user_check(x,p); \
2307 + pax_close_userland(); \
2308 + __e; \
2309 })
2310
2311 #else /* CONFIG_MMU */
2312 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2313 #define __get_user(x,ptr) \
2314 ({ \
2315 long __gu_err = 0; \
2316 + pax_open_userland(); \
2317 __get_user_err((x),(ptr),__gu_err); \
2318 + pax_close_userland(); \
2319 __gu_err; \
2320 })
2321
2322 #define __get_user_error(x,ptr,err) \
2323 ({ \
2324 + pax_open_userland(); \
2325 __get_user_err((x),(ptr),err); \
2326 + pax_close_userland(); \
2327 (void) 0; \
2328 })
2329
2330 @@ -312,13 +349,17 @@ do { \
2331 #define __put_user(x,ptr) \
2332 ({ \
2333 long __pu_err = 0; \
2334 + pax_open_userland(); \
2335 __put_user_err((x),(ptr),__pu_err); \
2336 + pax_close_userland(); \
2337 __pu_err; \
2338 })
2339
2340 #define __put_user_error(x,ptr,err) \
2341 ({ \
2342 + pax_open_userland(); \
2343 __put_user_err((x),(ptr),err); \
2344 + pax_close_userland(); \
2345 (void) 0; \
2346 })
2347
2348 @@ -418,11 +459,44 @@ do { \
2349
2350
2351 #ifdef CONFIG_MMU
2352 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2353 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2354 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2355 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2356 +
2357 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2358 +{
2359 + unsigned long ret;
2360 +
2361 + check_object_size(to, n, false);
2362 + pax_open_userland();
2363 + ret = ___copy_from_user(to, from, n);
2364 + pax_close_userland();
2365 + return ret;
2366 +}
2367 +
2368 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2369 +{
2370 + unsigned long ret;
2371 +
2372 + check_object_size(from, n, true);
2373 + pax_open_userland();
2374 + ret = ___copy_to_user(to, from, n);
2375 + pax_close_userland();
2376 + return ret;
2377 +}
2378 +
2379 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2380 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2381 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2382 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2383 +
2384 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2385 +{
2386 + unsigned long ret;
2387 + pax_open_userland();
2388 + ret = ___clear_user(addr, n);
2389 + pax_close_userland();
2390 + return ret;
2391 +}
2392 +
2393 #else
2394 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2395 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2396 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2397
2398 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2399 {
2400 + if ((long)n < 0)
2401 + return n;
2402 +
2403 if (access_ok(VERIFY_READ, from, n))
2404 n = __copy_from_user(to, from, n);
2405 else /* security hole - plug it */
2406 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2407
2408 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2409 {
2410 + if ((long)n < 0)
2411 + return n;
2412 +
2413 if (access_ok(VERIFY_WRITE, to, n))
2414 n = __copy_to_user(to, from, n);
2415 return n;
2416 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2417 index 96ee092..37f1844 100644
2418 --- a/arch/arm/include/uapi/asm/ptrace.h
2419 +++ b/arch/arm/include/uapi/asm/ptrace.h
2420 @@ -73,7 +73,7 @@
2421 * ARMv7 groups of PSR bits
2422 */
2423 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2424 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2425 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2426 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2427 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2428
2429 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2430 index 60d3b73..d27ee09 100644
2431 --- a/arch/arm/kernel/armksyms.c
2432 +++ b/arch/arm/kernel/armksyms.c
2433 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2434 #ifdef CONFIG_MMU
2435 EXPORT_SYMBOL(copy_page);
2436
2437 -EXPORT_SYMBOL(__copy_from_user);
2438 -EXPORT_SYMBOL(__copy_to_user);
2439 -EXPORT_SYMBOL(__clear_user);
2440 +EXPORT_SYMBOL(___copy_from_user);
2441 +EXPORT_SYMBOL(___copy_to_user);
2442 +EXPORT_SYMBOL(___clear_user);
2443
2444 EXPORT_SYMBOL(__get_user_1);
2445 EXPORT_SYMBOL(__get_user_2);
2446 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2447 index 0f82098..3dbd3ee 100644
2448 --- a/arch/arm/kernel/entry-armv.S
2449 +++ b/arch/arm/kernel/entry-armv.S
2450 @@ -47,6 +47,87 @@
2451 9997:
2452 .endm
2453
2454 + .macro pax_enter_kernel
2455 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2456 + @ make aligned space for saved DACR
2457 + sub sp, sp, #8
2458 + @ save regs
2459 + stmdb sp!, {r1, r2}
2460 + @ read DACR from cpu_domain into r1
2461 + mov r2, sp
2462 + @ assume 8K pages, since we have to split the immediate in two
2463 + bic r2, r2, #(0x1fc0)
2464 + bic r2, r2, #(0x3f)
2465 + ldr r1, [r2, #TI_CPU_DOMAIN]
2466 + @ store old DACR on stack
2467 + str r1, [sp, #8]
2468 +#ifdef CONFIG_PAX_KERNEXEC
2469 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2470 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2471 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2472 +#endif
2473 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2474 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2475 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2476 +#endif
2477 + @ write r1 to current_thread_info()->cpu_domain
2478 + str r1, [r2, #TI_CPU_DOMAIN]
2479 + @ write r1 to DACR
2480 + mcr p15, 0, r1, c3, c0, 0
2481 + @ instruction sync
2482 + instr_sync
2483 + @ restore regs
2484 + ldmia sp!, {r1, r2}
2485 +#endif
2486 + .endm
2487 +
2488 + .macro pax_open_userland
2489 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2490 + @ save regs
2491 + stmdb sp!, {r0, r1}
2492 + @ read DACR from cpu_domain into r1
2493 + mov r0, sp
2494 + @ assume 8K pages, since we have to split the immediate in two
2495 + bic r0, r0, #(0x1fc0)
2496 + bic r0, r0, #(0x3f)
2497 + ldr r1, [r0, #TI_CPU_DOMAIN]
2498 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2499 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2500 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2501 + @ write r1 to current_thread_info()->cpu_domain
2502 + str r1, [r0, #TI_CPU_DOMAIN]
2503 + @ write r1 to DACR
2504 + mcr p15, 0, r1, c3, c0, 0
2505 + @ instruction sync
2506 + instr_sync
2507 + @ restore regs
2508 + ldmia sp!, {r0, r1}
2509 +#endif
2510 + .endm
2511 +
2512 + .macro pax_close_userland
2513 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2514 + @ save regs
2515 + stmdb sp!, {r0, r1}
2516 + @ read DACR from cpu_domain into r1
2517 + mov r0, sp
2518 + @ assume 8K pages, since we have to split the immediate in two
2519 + bic r0, r0, #(0x1fc0)
2520 + bic r0, r0, #(0x3f)
2521 + ldr r1, [r0, #TI_CPU_DOMAIN]
2522 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2523 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2524 + @ write r1 to current_thread_info()->cpu_domain
2525 + str r1, [r0, #TI_CPU_DOMAIN]
2526 + @ write r1 to DACR
2527 + mcr p15, 0, r1, c3, c0, 0
2528 + @ instruction sync
2529 + instr_sync
2530 + @ restore regs
2531 + ldmia sp!, {r0, r1}
2532 +#endif
2533 + .endm
2534 +
2535 .macro pabt_helper
2536 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2537 #ifdef MULTI_PABORT
2538 @@ -89,11 +170,15 @@
2539 * Invalid mode handlers
2540 */
2541 .macro inv_entry, reason
2542 +
2543 + pax_enter_kernel
2544 +
2545 sub sp, sp, #S_FRAME_SIZE
2546 ARM( stmib sp, {r1 - lr} )
2547 THUMB( stmia sp, {r0 - r12} )
2548 THUMB( str sp, [sp, #S_SP] )
2549 THUMB( str lr, [sp, #S_LR] )
2550 +
2551 mov r1, #\reason
2552 .endm
2553
2554 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2555 .macro svc_entry, stack_hole=0
2556 UNWIND(.fnstart )
2557 UNWIND(.save {r0 - pc} )
2558 +
2559 + pax_enter_kernel
2560 +
2561 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2562 +
2563 #ifdef CONFIG_THUMB2_KERNEL
2564 SPFIX( str r0, [sp] ) @ temporarily saved
2565 SPFIX( mov r0, sp )
2566 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2567 ldmia r0, {r3 - r5}
2568 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2569 mov r6, #-1 @ "" "" "" ""
2570 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2571 + @ offset sp by 8 as done in pax_enter_kernel
2572 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2573 +#else
2574 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2575 +#endif
2576 SPFIX( addeq r2, r2, #4 )
2577 str r3, [sp, #-4]! @ save the "real" r0 copied
2578 @ from the exception stack
2579 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2580 .macro usr_entry
2581 UNWIND(.fnstart )
2582 UNWIND(.cantunwind ) @ don't unwind the user space
2583 +
2584 + pax_enter_kernel_user
2585 +
2586 sub sp, sp, #S_FRAME_SIZE
2587 ARM( stmib sp, {r1 - r12} )
2588 THUMB( stmia sp, {r0 - r12} )
2589 @@ -456,7 +553,9 @@ __und_usr:
2590 tst r3, #PSR_T_BIT @ Thumb mode?
2591 bne __und_usr_thumb
2592 sub r4, r2, #4 @ ARM instr at LR - 4
2593 + pax_open_userland
2594 1: ldrt r0, [r4]
2595 + pax_close_userland
2596 #ifdef CONFIG_CPU_ENDIAN_BE8
2597 rev r0, r0 @ little endian instruction
2598 #endif
2599 @@ -491,10 +590,14 @@ __und_usr_thumb:
2600 */
2601 .arch armv6t2
2602 #endif
2603 + pax_open_userland
2604 2: ldrht r5, [r4]
2605 + pax_close_userland
2606 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2607 blo __und_usr_fault_16 @ 16bit undefined instruction
2608 + pax_open_userland
2609 3: ldrht r0, [r2]
2610 + pax_close_userland
2611 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2612 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2613 orr r0, r0, r5, lsl #16
2614 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2615 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2616 THUMB( str sp, [ip], #4 )
2617 THUMB( str lr, [ip], #4 )
2618 -#ifdef CONFIG_CPU_USE_DOMAINS
2619 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2620 ldr r6, [r2, #TI_CPU_DOMAIN]
2621 #endif
2622 set_tls r3, r4, r5
2623 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2624 ldr r8, =__stack_chk_guard
2625 ldr r7, [r7, #TSK_STACK_CANARY]
2626 #endif
2627 -#ifdef CONFIG_CPU_USE_DOMAINS
2628 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2629 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2630 #endif
2631 mov r5, r0
2632 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2633 index a6c301e..908821b 100644
2634 --- a/arch/arm/kernel/entry-common.S
2635 +++ b/arch/arm/kernel/entry-common.S
2636 @@ -10,18 +10,46 @@
2637
2638 #include <asm/unistd.h>
2639 #include <asm/ftrace.h>
2640 +#include <asm/domain.h>
2641 #include <asm/unwind.h>
2642
2643 +#include "entry-header.S"
2644 +
2645 #ifdef CONFIG_NEED_RET_TO_USER
2646 #include <mach/entry-macro.S>
2647 #else
2648 .macro arch_ret_to_user, tmp1, tmp2
2649 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2650 + @ save regs
2651 + stmdb sp!, {r1, r2}
2652 + @ read DACR from cpu_domain into r1
2653 + mov r2, sp
2654 + @ assume 8K pages, since we have to split the immediate in two
2655 + bic r2, r2, #(0x1fc0)
2656 + bic r2, r2, #(0x3f)
2657 + ldr r1, [r2, #TI_CPU_DOMAIN]
2658 +#ifdef CONFIG_PAX_KERNEXEC
2659 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2660 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2661 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2662 +#endif
2663 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2664 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2665 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2666 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2667 +#endif
2668 + @ write r1 to current_thread_info()->cpu_domain
2669 + str r1, [r2, #TI_CPU_DOMAIN]
2670 + @ write r1 to DACR
2671 + mcr p15, 0, r1, c3, c0, 0
2672 + @ instruction sync
2673 + instr_sync
2674 + @ restore regs
2675 + ldmia sp!, {r1, r2}
2676 +#endif
2677 .endm
2678 #endif
2679
2680 -#include "entry-header.S"
2681 -
2682 -
2683 .align 5
2684 /*
2685 * This is the fast syscall return path. We do as little as
2686 @@ -339,6 +367,7 @@ ENDPROC(ftrace_stub)
2687
2688 .align 5
2689 ENTRY(vector_swi)
2690 +
2691 sub sp, sp, #S_FRAME_SIZE
2692 stmia sp, {r0 - r12} @ Calling r0 - r12
2693 ARM( add r8, sp, #S_PC )
2694 @@ -388,6 +417,12 @@ ENTRY(vector_swi)
2695 ldr scno, [lr, #-4] @ get SWI instruction
2696 #endif
2697
2698 + /*
2699 + * do this here to avoid a performance hit of wrapping the code above
2700 + * that directly dereferences userland to parse the SWI instruction
2701 + */
2702 + pax_enter_kernel_user
2703 +
2704 #ifdef CONFIG_ALIGNMENT_TRAP
2705 ldr ip, __cr_alignment
2706 ldr ip, [ip]
2707 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2708 index 9a8531e..812e287 100644
2709 --- a/arch/arm/kernel/entry-header.S
2710 +++ b/arch/arm/kernel/entry-header.S
2711 @@ -73,9 +73,66 @@
2712 msr cpsr_c, \rtemp @ switch back to the SVC mode
2713 .endm
2714
2715 + .macro pax_enter_kernel_user
2716 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2717 + @ save regs
2718 + stmdb sp!, {r0, r1}
2719 + @ read DACR from cpu_domain into r1
2720 + mov r0, sp
2721 + @ assume 8K pages, since we have to split the immediate in two
2722 + bic r0, r0, #(0x1fc0)
2723 + bic r0, r0, #(0x3f)
2724 + ldr r1, [r0, #TI_CPU_DOMAIN]
2725 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2726 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2727 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2728 +#endif
2729 +#ifdef CONFIG_PAX_KERNEXEC
2730 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2731 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2732 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2733 +#endif
2734 + @ write r1 to current_thread_info()->cpu_domain
2735 + str r1, [r0, #TI_CPU_DOMAIN]
2736 + @ write r1 to DACR
2737 + mcr p15, 0, r1, c3, c0, 0
2738 + @ instruction sync
2739 + instr_sync
2740 + @ restore regs
2741 + ldmia sp!, {r0, r1}
2742 +#endif
2743 + .endm
2744 +
2745 + .macro pax_exit_kernel
2746 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2747 + @ save regs
2748 + stmdb sp!, {r0, r1}
2749 + @ read old DACR from stack into r1
2750 + ldr r1, [sp, #(8 + S_SP)]
2751 + sub r1, r1, #8
2752 + ldr r1, [r1]
2753 +
2754 + @ write r1 to current_thread_info()->cpu_domain
2755 + mov r0, sp
2756 + @ assume 8K pages, since we have to split the immediate in two
2757 + bic r0, r0, #(0x1fc0)
2758 + bic r0, r0, #(0x3f)
2759 + str r1, [r0, #TI_CPU_DOMAIN]
2760 + @ write r1 to DACR
2761 + mcr p15, 0, r1, c3, c0, 0
2762 + @ instruction sync
2763 + instr_sync
2764 + @ restore regs
2765 + ldmia sp!, {r0, r1}
2766 +#endif
2767 + .endm
2768 +
2769 #ifndef CONFIG_THUMB2_KERNEL
2770 .macro svc_exit, rpsr
2771 msr spsr_cxsf, \rpsr
2772 +
2773 + pax_exit_kernel
2774 +
2775 #if defined(CONFIG_CPU_V6)
2776 ldr r0, [sp]
2777 strex r1, r2, [sp] @ clear the exclusive monitor
2778 @@ -121,6 +178,9 @@
2779 .endm
2780 #else /* CONFIG_THUMB2_KERNEL */
2781 .macro svc_exit, rpsr
2782 +
2783 + pax_exit_kernel
2784 +
2785 ldr lr, [sp, #S_SP] @ top of the stack
2786 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2787 clrex @ clear the exclusive monitor
2788 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2789 index 2adda11..7fbe958 100644
2790 --- a/arch/arm/kernel/fiq.c
2791 +++ b/arch/arm/kernel/fiq.c
2792 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2793 #if defined(CONFIG_CPU_USE_DOMAINS)
2794 memcpy((void *)0xffff001c, start, length);
2795 #else
2796 + pax_open_kernel();
2797 memcpy(vectors_page + 0x1c, start, length);
2798 + pax_close_kernel();
2799 #endif
2800 flush_icache_range(0xffff001c, 0xffff001c + length);
2801 if (!vectors_high())
2802 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2803 index e0eb9a1..caee108 100644
2804 --- a/arch/arm/kernel/head.S
2805 +++ b/arch/arm/kernel/head.S
2806 @@ -52,7 +52,9 @@
2807 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2808
2809 .macro pgtbl, rd, phys
2810 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2811 + mov \rd, #TEXT_OFFSET
2812 + sub \rd, #PG_DIR_SIZE
2813 + add \rd, \rd, \phys
2814 .endm
2815
2816 /*
2817 @@ -267,7 +269,7 @@ __create_page_tables:
2818 addne r6, r6, #1 << SECTION_SHIFT
2819 strne r6, [r3]
2820
2821 -#if defined(CONFIG_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2822 +#if defined(CONFIG_ARM_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2823 sub r4, r4, #4 @ Fixup page table pointer
2824 @ for 64-bit descriptors
2825 #endif
2826 @@ -434,7 +436,7 @@ __enable_mmu:
2827 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2828 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2829 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2830 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2831 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2832 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2833 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2834 #endif
2835 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2836 index 5ff2e77..556d030 100644
2837 --- a/arch/arm/kernel/hw_breakpoint.c
2838 +++ b/arch/arm/kernel/hw_breakpoint.c
2839 @@ -1011,7 +1011,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2840 return NOTIFY_OK;
2841 }
2842
2843 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2844 +static struct notifier_block dbg_reset_nb = {
2845 .notifier_call = dbg_reset_notify,
2846 };
2847
2848 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2849 index 1e9be5d..03edbc2 100644
2850 --- a/arch/arm/kernel/module.c
2851 +++ b/arch/arm/kernel/module.c
2852 @@ -37,12 +37,37 @@
2853 #endif
2854
2855 #ifdef CONFIG_MMU
2856 -void *module_alloc(unsigned long size)
2857 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2858 {
2859 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2860 + return NULL;
2861 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2862 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2863 + GFP_KERNEL, prot, -1,
2864 __builtin_return_address(0));
2865 }
2866 +
2867 +void *module_alloc(unsigned long size)
2868 +{
2869 +
2870 +#ifdef CONFIG_PAX_KERNEXEC
2871 + return __module_alloc(size, PAGE_KERNEL);
2872 +#else
2873 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2874 +#endif
2875 +
2876 +}
2877 +
2878 +#ifdef CONFIG_PAX_KERNEXEC
2879 +void module_free_exec(struct module *mod, void *module_region)
2880 +{
2881 + module_free(mod, module_region);
2882 +}
2883 +
2884 +void *module_alloc_exec(unsigned long size)
2885 +{
2886 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2887 +}
2888 +#endif
2889 #endif
2890
2891 int
2892 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2893 index 07314af..c46655c 100644
2894 --- a/arch/arm/kernel/patch.c
2895 +++ b/arch/arm/kernel/patch.c
2896 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2897 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2898 int size;
2899
2900 + pax_open_kernel();
2901 if (thumb2 && __opcode_is_thumb16(insn)) {
2902 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2903 size = sizeof(u16);
2904 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2905 *(u32 *)addr = insn;
2906 size = sizeof(u32);
2907 }
2908 + pax_close_kernel();
2909
2910 flush_icache_range((uintptr_t)(addr),
2911 (uintptr_t)(addr) + size);
2912 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2913 index 5f66206..dce492f 100644
2914 --- a/arch/arm/kernel/perf_event_cpu.c
2915 +++ b/arch/arm/kernel/perf_event_cpu.c
2916 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2917 return NOTIFY_OK;
2918 }
2919
2920 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2921 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2922 .notifier_call = cpu_pmu_notify,
2923 };
2924
2925 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2926 index c6dec5f..e0fddd1 100644
2927 --- a/arch/arm/kernel/process.c
2928 +++ b/arch/arm/kernel/process.c
2929 @@ -28,7 +28,6 @@
2930 #include <linux/tick.h>
2931 #include <linux/utsname.h>
2932 #include <linux/uaccess.h>
2933 -#include <linux/random.h>
2934 #include <linux/hw_breakpoint.h>
2935 #include <linux/cpuidle.h>
2936 #include <linux/leds.h>
2937 @@ -256,9 +255,10 @@ void machine_power_off(void)
2938 machine_shutdown();
2939 if (pm_power_off)
2940 pm_power_off();
2941 + BUG();
2942 }
2943
2944 -void machine_restart(char *cmd)
2945 +__noreturn void machine_restart(char *cmd)
2946 {
2947 machine_shutdown();
2948
2949 @@ -283,8 +283,8 @@ void __show_regs(struct pt_regs *regs)
2950 init_utsname()->release,
2951 (int)strcspn(init_utsname()->version, " "),
2952 init_utsname()->version);
2953 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2954 - print_symbol("LR is at %s\n", regs->ARM_lr);
2955 + printk("PC is at %pA\n", instruction_pointer(regs));
2956 + printk("LR is at %pA\n", regs->ARM_lr);
2957 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2958 "sp : %08lx ip : %08lx fp : %08lx\n",
2959 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2960 @@ -452,12 +452,6 @@ unsigned long get_wchan(struct task_struct *p)
2961 return 0;
2962 }
2963
2964 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2965 -{
2966 - unsigned long range_end = mm->brk + 0x02000000;
2967 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2968 -}
2969 -
2970 #ifdef CONFIG_MMU
2971 /*
2972 * The vectors page is always readable from user space for the
2973 @@ -470,9 +464,8 @@ static int __init gate_vma_init(void)
2974 {
2975 gate_vma.vm_start = 0xffff0000;
2976 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2977 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2978 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2979 - VM_MAYREAD | VM_MAYEXEC;
2980 + gate_vma.vm_flags = VM_NONE;
2981 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2982 return 0;
2983 }
2984 arch_initcall(gate_vma_init);
2985 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2986 index 03deeff..741ce88 100644
2987 --- a/arch/arm/kernel/ptrace.c
2988 +++ b/arch/arm/kernel/ptrace.c
2989 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2990 return current_thread_info()->syscall;
2991 }
2992
2993 +#ifdef CONFIG_GRKERNSEC_SETXID
2994 +extern void gr_delayed_cred_worker(void);
2995 +#endif
2996 +
2997 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2998 {
2999 current_thread_info()->syscall = scno;
3000
3001 +#ifdef CONFIG_GRKERNSEC_SETXID
3002 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3003 + gr_delayed_cred_worker();
3004 +#endif
3005 +
3006 /* Do the secure computing check first; failures should be fast. */
3007 if (secure_computing(scno) == -1)
3008 return -1;
3009 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3010 index 3f6cbb2..39305c7 100644
3011 --- a/arch/arm/kernel/setup.c
3012 +++ b/arch/arm/kernel/setup.c
3013 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
3014 unsigned int elf_hwcap __read_mostly;
3015 EXPORT_SYMBOL(elf_hwcap);
3016
3017 +pteval_t __supported_pte_mask __read_only;
3018 +pmdval_t __supported_pmd_mask __read_only;
3019
3020 #ifdef MULTI_CPU
3021 -struct processor processor __read_mostly;
3022 +struct processor processor;
3023 #endif
3024 #ifdef MULTI_TLB
3025 -struct cpu_tlb_fns cpu_tlb __read_mostly;
3026 +struct cpu_tlb_fns cpu_tlb __read_only;
3027 #endif
3028 #ifdef MULTI_USER
3029 -struct cpu_user_fns cpu_user __read_mostly;
3030 +struct cpu_user_fns cpu_user __read_only;
3031 #endif
3032 #ifdef MULTI_CACHE
3033 -struct cpu_cache_fns cpu_cache __read_mostly;
3034 +struct cpu_cache_fns cpu_cache __read_only;
3035 #endif
3036 #ifdef CONFIG_OUTER_CACHE
3037 -struct outer_cache_fns outer_cache __read_mostly;
3038 +struct outer_cache_fns outer_cache __read_only;
3039 EXPORT_SYMBOL(outer_cache);
3040 #endif
3041
3042 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3043 asm("mrc p15, 0, %0, c0, c1, 4"
3044 : "=r" (mmfr0));
3045 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3046 - (mmfr0 & 0x000000f0) >= 0x00000030)
3047 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3048 cpu_arch = CPU_ARCH_ARMv7;
3049 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3050 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3051 + __supported_pte_mask |= L_PTE_PXN;
3052 + __supported_pmd_mask |= PMD_PXNTABLE;
3053 + }
3054 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3055 (mmfr0 & 0x000000f0) == 0x00000020)
3056 cpu_arch = CPU_ARCH_ARMv6;
3057 else
3058 @@ -462,7 +468,7 @@ static void __init setup_processor(void)
3059 __cpu_architecture = __get_cpu_architecture();
3060
3061 #ifdef MULTI_CPU
3062 - processor = *list->proc;
3063 + memcpy((void *)&processor, list->proc, sizeof processor);
3064 #endif
3065 #ifdef MULTI_TLB
3066 cpu_tlb = *list->tlb;
3067 @@ -524,7 +530,7 @@ int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
3068 size -= start & ~PAGE_MASK;
3069 bank->start = PAGE_ALIGN(start);
3070
3071 -#ifndef CONFIG_LPAE
3072 +#ifndef CONFIG_ARM_LPAE
3073 if (bank->start + size < bank->start) {
3074 printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
3075 "32-bit physical address space\n", (long long)start);
3076 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3077 index 56f72d2..6924200 100644
3078 --- a/arch/arm/kernel/signal.c
3079 +++ b/arch/arm/kernel/signal.c
3080 @@ -433,22 +433,14 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
3081 __put_user(sigreturn_codes[idx+1], rc+1))
3082 return 1;
3083
3084 - if (cpsr & MODE32_BIT) {
3085 - /*
3086 - * 32-bit code can use the new high-page
3087 - * signal return code support.
3088 - */
3089 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3090 - } else {
3091 - /*
3092 - * Ensure that the instruction cache sees
3093 - * the return code written onto the stack.
3094 - */
3095 - flush_icache_range((unsigned long)rc,
3096 - (unsigned long)(rc + 2));
3097 + /*
3098 + * Ensure that the instruction cache sees
3099 + * the return code written onto the stack.
3100 + */
3101 + flush_icache_range((unsigned long)rc,
3102 + (unsigned long)(rc + 2));
3103
3104 - retcode = ((unsigned long)rc) + thumb;
3105 - }
3106 + retcode = ((unsigned long)rc) + thumb;
3107 }
3108
3109 regs->ARM_r0 = usig;
3110 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3111 index 58af91c..343ce99 100644
3112 --- a/arch/arm/kernel/smp.c
3113 +++ b/arch/arm/kernel/smp.c
3114 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3115
3116 static DECLARE_COMPLETION(cpu_running);
3117
3118 -static struct smp_operations smp_ops;
3119 +static struct smp_operations smp_ops __read_only;
3120
3121 void __init smp_set_ops(struct smp_operations *ops)
3122 {
3123 diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
3124 index 02c5d2c..e5695ad 100644
3125 --- a/arch/arm/kernel/smp_tlb.c
3126 +++ b/arch/arm/kernel/smp_tlb.c
3127 @@ -12,6 +12,7 @@
3128
3129 #include <asm/smp_plat.h>
3130 #include <asm/tlbflush.h>
3131 +#include <asm/mmu_context.h>
3132
3133 /**********************************************************************/
3134
3135 @@ -64,12 +65,72 @@ static inline void ipi_flush_tlb_kernel_range(void *arg)
3136 local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
3137 }
3138
3139 +#ifdef CONFIG_ARM_ERRATA_798181
3140 +static int erratum_a15_798181(void)
3141 +{
3142 + unsigned int midr = read_cpuid_id();
3143 +
3144 + /* Cortex-A15 r0p0..r3p2 affected */
3145 + if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
3146 + return 0;
3147 + return 1;
3148 +}
3149 +#else
3150 +static int erratum_a15_798181(void)
3151 +{
3152 + return 0;
3153 +}
3154 +#endif
3155 +
3156 +static void ipi_flush_tlb_a15_erratum(void *arg)
3157 +{
3158 + dmb();
3159 +}
3160 +
3161 +static void broadcast_tlb_a15_erratum(void)
3162 +{
3163 + if (!erratum_a15_798181())
3164 + return;
3165 +
3166 + dummy_flush_tlb_a15_erratum();
3167 + smp_call_function_many(cpu_online_mask, ipi_flush_tlb_a15_erratum,
3168 + NULL, 1);
3169 +}
3170 +
3171 +static void broadcast_tlb_mm_a15_erratum(struct mm_struct *mm)
3172 +{
3173 + int cpu;
3174 + cpumask_t mask = { CPU_BITS_NONE };
3175 +
3176 + if (!erratum_a15_798181())
3177 + return;
3178 +
3179 + dummy_flush_tlb_a15_erratum();
3180 + for_each_online_cpu(cpu) {
3181 + if (cpu == smp_processor_id())
3182 + continue;
3183 + /*
3184 + * We only need to send an IPI if the other CPUs are running
3185 + * the same ASID as the one being invalidated. There is no
3186 + * need for locking around the active_asids check since the
3187 + * switch_mm() function has at least one dmb() (as required by
3188 + * this workaround) in case a context switch happens on
3189 + * another CPU after the condition below.
3190 + */
3191 + if (atomic64_read(&mm->context.id) ==
3192 + atomic64_read(&per_cpu(active_asids, cpu)))
3193 + cpumask_set_cpu(cpu, &mask);
3194 + }
3195 + smp_call_function_many(&mask, ipi_flush_tlb_a15_erratum, NULL, 1);
3196 +}
3197 +
3198 void flush_tlb_all(void)
3199 {
3200 if (tlb_ops_need_broadcast())
3201 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
3202 else
3203 local_flush_tlb_all();
3204 + broadcast_tlb_a15_erratum();
3205 }
3206
3207 void flush_tlb_mm(struct mm_struct *mm)
3208 @@ -78,6 +139,7 @@ void flush_tlb_mm(struct mm_struct *mm)
3209 on_each_cpu_mask(mm_cpumask(mm), ipi_flush_tlb_mm, mm, 1);
3210 else
3211 local_flush_tlb_mm(mm);
3212 + broadcast_tlb_mm_a15_erratum(mm);
3213 }
3214
3215 void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3216 @@ -90,6 +152,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3217 &ta, 1);
3218 } else
3219 local_flush_tlb_page(vma, uaddr);
3220 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3221 }
3222
3223 void flush_tlb_kernel_page(unsigned long kaddr)
3224 @@ -100,6 +163,7 @@ void flush_tlb_kernel_page(unsigned long kaddr)
3225 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
3226 } else
3227 local_flush_tlb_kernel_page(kaddr);
3228 + broadcast_tlb_a15_erratum();
3229 }
3230
3231 void flush_tlb_range(struct vm_area_struct *vma,
3232 @@ -114,6 +178,7 @@ void flush_tlb_range(struct vm_area_struct *vma,
3233 &ta, 1);
3234 } else
3235 local_flush_tlb_range(vma, start, end);
3236 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3237 }
3238
3239 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3240 @@ -125,5 +190,6 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3241 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
3242 } else
3243 local_flush_tlb_kernel_range(start, end);
3244 + broadcast_tlb_a15_erratum();
3245 }
3246
3247 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3248 index b0179b8..829510e 100644
3249 --- a/arch/arm/kernel/traps.c
3250 +++ b/arch/arm/kernel/traps.c
3251 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3252 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3253 {
3254 #ifdef CONFIG_KALLSYMS
3255 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3256 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3257 #else
3258 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3259 #endif
3260 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3261 static int die_owner = -1;
3262 static unsigned int die_nest_count;
3263
3264 +extern void gr_handle_kernel_exploit(void);
3265 +
3266 static unsigned long oops_begin(void)
3267 {
3268 int cpu;
3269 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3270 panic("Fatal exception in interrupt");
3271 if (panic_on_oops)
3272 panic("Fatal exception");
3273 +
3274 + gr_handle_kernel_exploit();
3275 +
3276 if (signr)
3277 do_exit(signr);
3278 }
3279 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3280 * The user helper at 0xffff0fe0 must be used instead.
3281 * (see entry-armv.S for details)
3282 */
3283 + pax_open_kernel();
3284 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3285 + pax_close_kernel();
3286 }
3287 return 0;
3288
3289 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3290 */
3291 kuser_get_tls_init(vectors);
3292
3293 - /*
3294 - * Copy signal return handlers into the vector page, and
3295 - * set sigreturn to be a pointer to these.
3296 - */
3297 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3298 - sigreturn_codes, sizeof(sigreturn_codes));
3299 -
3300 flush_icache_range(vectors, vectors + PAGE_SIZE);
3301 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3302 +
3303 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3304 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3305 +#endif
3306 +
3307 }
3308 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3309 index 11c1785..1b209f4 100644
3310 --- a/arch/arm/kernel/vmlinux.lds.S
3311 +++ b/arch/arm/kernel/vmlinux.lds.S
3312 @@ -8,7 +8,11 @@
3313 #include <asm/thread_info.h>
3314 #include <asm/memory.h>
3315 #include <asm/page.h>
3316 -
3317 +
3318 +#ifdef CONFIG_PAX_KERNEXEC
3319 +#include <asm/pgtable.h>
3320 +#endif
3321 +
3322 #define PROC_INFO \
3323 . = ALIGN(4); \
3324 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3325 @@ -90,6 +94,11 @@ SECTIONS
3326 _text = .;
3327 HEAD_TEXT
3328 }
3329 +
3330 +#ifdef CONFIG_PAX_KERNEXEC
3331 + . = ALIGN(1<<SECTION_SHIFT);
3332 +#endif
3333 +
3334 .text : { /* Real text segment */
3335 _stext = .; /* Text and read-only data */
3336 __exception_text_start = .;
3337 @@ -112,6 +121,8 @@ SECTIONS
3338 ARM_CPU_KEEP(PROC_INFO)
3339 }
3340
3341 + _etext = .; /* End of text section */
3342 +
3343 RO_DATA(PAGE_SIZE)
3344
3345 . = ALIGN(4);
3346 @@ -142,7 +153,9 @@ SECTIONS
3347
3348 NOTES
3349
3350 - _etext = .; /* End of text and rodata section */
3351 +#ifdef CONFIG_PAX_KERNEXEC
3352 + . = ALIGN(1<<SECTION_SHIFT);
3353 +#endif
3354
3355 #ifndef CONFIG_XIP_KERNEL
3356 . = ALIGN(PAGE_SIZE);
3357 @@ -203,6 +216,11 @@ SECTIONS
3358 . = PAGE_OFFSET + TEXT_OFFSET;
3359 #else
3360 __init_end = .;
3361 +
3362 +#ifdef CONFIG_PAX_KERNEXEC
3363 + . = ALIGN(1<<SECTION_SHIFT);
3364 +#endif
3365 +
3366 . = ALIGN(THREAD_SIZE);
3367 __data_loc = .;
3368 #endif
3369 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3370 index 14a0d98..7771a7d 100644
3371 --- a/arch/arm/lib/clear_user.S
3372 +++ b/arch/arm/lib/clear_user.S
3373 @@ -12,14 +12,14 @@
3374
3375 .text
3376
3377 -/* Prototype: int __clear_user(void *addr, size_t sz)
3378 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3379 * Purpose : clear some user memory
3380 * Params : addr - user memory address to clear
3381 * : sz - number of bytes to clear
3382 * Returns : number of bytes NOT cleared
3383 */
3384 ENTRY(__clear_user_std)
3385 -WEAK(__clear_user)
3386 +WEAK(___clear_user)
3387 stmfd sp!, {r1, lr}
3388 mov r2, #0
3389 cmp r1, #4
3390 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3391 USER( strnebt r2, [r0])
3392 mov r0, #0
3393 ldmfd sp!, {r1, pc}
3394 -ENDPROC(__clear_user)
3395 +ENDPROC(___clear_user)
3396 ENDPROC(__clear_user_std)
3397
3398 .pushsection .fixup,"ax"
3399 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3400 index 66a477a..bee61d3 100644
3401 --- a/arch/arm/lib/copy_from_user.S
3402 +++ b/arch/arm/lib/copy_from_user.S
3403 @@ -16,7 +16,7 @@
3404 /*
3405 * Prototype:
3406 *
3407 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3408 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3409 *
3410 * Purpose:
3411 *
3412 @@ -84,11 +84,11 @@
3413
3414 .text
3415
3416 -ENTRY(__copy_from_user)
3417 +ENTRY(___copy_from_user)
3418
3419 #include "copy_template.S"
3420
3421 -ENDPROC(__copy_from_user)
3422 +ENDPROC(___copy_from_user)
3423
3424 .pushsection .fixup,"ax"
3425 .align 0
3426 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3427 index 6ee2f67..d1cce76 100644
3428 --- a/arch/arm/lib/copy_page.S
3429 +++ b/arch/arm/lib/copy_page.S
3430 @@ -10,6 +10,7 @@
3431 * ASM optimised string functions
3432 */
3433 #include <linux/linkage.h>
3434 +#include <linux/const.h>
3435 #include <asm/assembler.h>
3436 #include <asm/asm-offsets.h>
3437 #include <asm/cache.h>
3438 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3439 index d066df6..df28194 100644
3440 --- a/arch/arm/lib/copy_to_user.S
3441 +++ b/arch/arm/lib/copy_to_user.S
3442 @@ -16,7 +16,7 @@
3443 /*
3444 * Prototype:
3445 *
3446 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3447 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3448 *
3449 * Purpose:
3450 *
3451 @@ -88,11 +88,11 @@
3452 .text
3453
3454 ENTRY(__copy_to_user_std)
3455 -WEAK(__copy_to_user)
3456 +WEAK(___copy_to_user)
3457
3458 #include "copy_template.S"
3459
3460 -ENDPROC(__copy_to_user)
3461 +ENDPROC(___copy_to_user)
3462 ENDPROC(__copy_to_user_std)
3463
3464 .pushsection .fixup,"ax"
3465 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3466 index 7d08b43..f7ca7ea 100644
3467 --- a/arch/arm/lib/csumpartialcopyuser.S
3468 +++ b/arch/arm/lib/csumpartialcopyuser.S
3469 @@ -57,8 +57,8 @@
3470 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3471 */
3472
3473 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3474 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3475 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3476 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3477
3478 #include "csumpartialcopygeneric.S"
3479
3480 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3481 index 6b93f6a..1aa92d0 100644
3482 --- a/arch/arm/lib/delay.c
3483 +++ b/arch/arm/lib/delay.c
3484 @@ -28,12 +28,15 @@
3485 /*
3486 * Default to the loop-based delay implementation.
3487 */
3488 -struct arm_delay_ops arm_delay_ops = {
3489 +static struct arm_delay_ops arm_loop_delay_ops = {
3490 .delay = __loop_delay,
3491 .const_udelay = __loop_const_udelay,
3492 .udelay = __loop_udelay,
3493 + .const_clock = false,
3494 };
3495
3496 +struct arm_delay_ops *arm_delay_ops __read_only = &arm_loop_delay_ops;
3497 +
3498 static const struct delay_timer *delay_timer;
3499 static bool delay_calibrated;
3500
3501 @@ -67,6 +70,13 @@ static void __timer_udelay(unsigned long usecs)
3502 __timer_const_udelay(usecs * UDELAY_MULT);
3503 }
3504
3505 +static struct arm_delay_ops arm_timer_delay_ops = {
3506 + .delay = __timer_delay,
3507 + .const_udelay = __timer_const_udelay,
3508 + .udelay = __timer_udelay,
3509 + .const_clock = true,
3510 +};
3511 +
3512 void __init register_current_timer_delay(const struct delay_timer *timer)
3513 {
3514 if (!delay_calibrated) {
3515 @@ -74,10 +84,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
3516 delay_timer = timer;
3517 lpj_fine = timer->freq / HZ;
3518 loops_per_jiffy = lpj_fine;
3519 - arm_delay_ops.delay = __timer_delay;
3520 - arm_delay_ops.const_udelay = __timer_const_udelay;
3521 - arm_delay_ops.udelay = __timer_udelay;
3522 - arm_delay_ops.const_clock = true;
3523 + arm_delay_ops = &arm_timer_delay_ops;
3524 delay_calibrated = true;
3525 } else {
3526 pr_info("Ignoring duplicate/late registration of read_current_timer delay\n");
3527 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3528 index 025f742..8432b08 100644
3529 --- a/arch/arm/lib/uaccess_with_memcpy.c
3530 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3531 @@ -104,7 +104,7 @@ out:
3532 }
3533
3534 unsigned long
3535 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3536 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3537 {
3538 /*
3539 * This test is stubbed out of the main function above to keep
3540 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3541 index bac21a5..b67ef8e 100644
3542 --- a/arch/arm/mach-kirkwood/common.c
3543 +++ b/arch/arm/mach-kirkwood/common.c
3544 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3545 clk_gate_ops.disable(hw);
3546 }
3547
3548 -static struct clk_ops clk_gate_fn_ops;
3549 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3550 +{
3551 + return clk_gate_ops.is_enabled(hw);
3552 +}
3553 +
3554 +static struct clk_ops clk_gate_fn_ops = {
3555 + .enable = clk_gate_fn_enable,
3556 + .disable = clk_gate_fn_disable,
3557 + .is_enabled = clk_gate_fn_is_enabled,
3558 +};
3559
3560 static struct clk __init *clk_register_gate_fn(struct device *dev,
3561 const char *name,
3562 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3563 gate_fn->fn_en = fn_en;
3564 gate_fn->fn_dis = fn_dis;
3565
3566 - /* ops is the gate ops, but with our enable/disable functions */
3567 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3568 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3569 - clk_gate_fn_ops = clk_gate_ops;
3570 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3571 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3572 - }
3573 -
3574 clk = clk_register(dev, &gate_fn->gate.hw);
3575
3576 if (IS_ERR(clk))
3577 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3578 index 0abb30f..54064da 100644
3579 --- a/arch/arm/mach-omap2/board-n8x0.c
3580 +++ b/arch/arm/mach-omap2/board-n8x0.c
3581 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3582 }
3583 #endif
3584
3585 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3586 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3587 .late_init = n8x0_menelaus_late_init,
3588 };
3589
3590 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3591 index 8033cb7..2f7cb62 100644
3592 --- a/arch/arm/mach-omap2/gpmc.c
3593 +++ b/arch/arm/mach-omap2/gpmc.c
3594 @@ -139,7 +139,6 @@ struct omap3_gpmc_regs {
3595 };
3596
3597 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3598 -static struct irq_chip gpmc_irq_chip;
3599 static unsigned gpmc_irq_start;
3600
3601 static struct resource gpmc_mem_root;
3602 @@ -700,6 +699,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3603
3604 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3605
3606 +static struct irq_chip gpmc_irq_chip = {
3607 + .name = "gpmc",
3608 + .irq_startup = gpmc_irq_noop_ret,
3609 + .irq_enable = gpmc_irq_enable,
3610 + .irq_disable = gpmc_irq_disable,
3611 + .irq_shutdown = gpmc_irq_noop,
3612 + .irq_ack = gpmc_irq_noop,
3613 + .irq_mask = gpmc_irq_noop,
3614 + .irq_unmask = gpmc_irq_noop,
3615 +
3616 +};
3617 +
3618 static int gpmc_setup_irq(void)
3619 {
3620 int i;
3621 @@ -714,15 +725,6 @@ static int gpmc_setup_irq(void)
3622 return gpmc_irq_start;
3623 }
3624
3625 - gpmc_irq_chip.name = "gpmc";
3626 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3627 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3628 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3629 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3630 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3631 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3632 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3633 -
3634 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3635 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3636
3637 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3638 index 5d3b4f4..ddba3c0 100644
3639 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3640 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3641 @@ -340,7 +340,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3642 return NOTIFY_OK;
3643 }
3644
3645 -static struct notifier_block __refdata irq_hotplug_notifier = {
3646 +static struct notifier_block irq_hotplug_notifier = {
3647 .notifier_call = irq_cpu_hotplug_notify,
3648 };
3649
3650 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3651 index e065daa..7b1ad9b 100644
3652 --- a/arch/arm/mach-omap2/omap_device.c
3653 +++ b/arch/arm/mach-omap2/omap_device.c
3654 @@ -686,7 +686,7 @@ void omap_device_delete(struct omap_device *od)
3655 * passes along the return value of omap_device_build_ss().
3656 */
3657 struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
3658 - struct omap_hwmod *oh, void *pdata,
3659 + struct omap_hwmod *oh, const void *pdata,
3660 int pdata_len,
3661 struct omap_device_pm_latency *pm_lats,
3662 int pm_lats_cnt, int is_early_device)
3663 @@ -720,7 +720,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
3664 */
3665 struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
3666 struct omap_hwmod **ohs, int oh_cnt,
3667 - void *pdata, int pdata_len,
3668 + const void *pdata, int pdata_len,
3669 struct omap_device_pm_latency *pm_lats,
3670 int pm_lats_cnt, int is_early_device)
3671 {
3672 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3673 index 0933c59..42b8e2d 100644
3674 --- a/arch/arm/mach-omap2/omap_device.h
3675 +++ b/arch/arm/mach-omap2/omap_device.h
3676 @@ -91,14 +91,14 @@ int omap_device_shutdown(struct platform_device *pdev);
3677 /* Core code interface */
3678
3679 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3680 - struct omap_hwmod *oh, void *pdata,
3681 + struct omap_hwmod *oh, const void *pdata,
3682 int pdata_len,
3683 struct omap_device_pm_latency *pm_lats,
3684 int pm_lats_cnt, int is_early_device);
3685
3686 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3687 struct omap_hwmod **oh, int oh_cnt,
3688 - void *pdata, int pdata_len,
3689 + const void *pdata, int pdata_len,
3690 struct omap_device_pm_latency *pm_lats,
3691 int pm_lats_cnt, int is_early_device);
3692
3693 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3694 index 4653efb..8c60bf7 100644
3695 --- a/arch/arm/mach-omap2/omap_hwmod.c
3696 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3697 @@ -189,10 +189,10 @@ struct omap_hwmod_soc_ops {
3698 int (*init_clkdm)(struct omap_hwmod *oh);
3699 void (*update_context_lost)(struct omap_hwmod *oh);
3700 int (*get_context_lost)(struct omap_hwmod *oh);
3701 -};
3702 +} __no_const;
3703
3704 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3705 -static struct omap_hwmod_soc_ops soc_ops;
3706 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3707
3708 /* omap_hwmod_list contains all registered struct omap_hwmods */
3709 static LIST_HEAD(omap_hwmod_list);
3710 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3711 index 7c2b4ed..b2ea51f 100644
3712 --- a/arch/arm/mach-omap2/wd_timer.c
3713 +++ b/arch/arm/mach-omap2/wd_timer.c
3714 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3715 struct omap_hwmod *oh;
3716 char *oh_name = "wd_timer2";
3717 char *dev_name = "omap_wdt";
3718 - struct omap_wd_timer_platform_data pdata;
3719 + static struct omap_wd_timer_platform_data pdata = {
3720 + .read_reset_sources = prm_read_reset_sources
3721 + };
3722
3723 if (!cpu_class_is_omap2() || of_have_populated_dt())
3724 return 0;
3725 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3726 return -EINVAL;
3727 }
3728
3729 - pdata.read_reset_sources = prm_read_reset_sources;
3730 -
3731 pdev = omap_device_build(dev_name, id, oh, &pdata,
3732 sizeof(struct omap_wd_timer_platform_data),
3733 NULL, 0, 0);
3734 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3735 index 6be4c4d..32ac32a 100644
3736 --- a/arch/arm/mach-ux500/include/mach/setup.h
3737 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3738 @@ -38,13 +38,6 @@ extern struct sys_timer ux500_timer;
3739 .type = MT_DEVICE, \
3740 }
3741
3742 -#define __MEM_DEV_DESC(x, sz) { \
3743 - .virtual = IO_ADDRESS(x), \
3744 - .pfn = __phys_to_pfn(x), \
3745 - .length = sz, \
3746 - .type = MT_MEMORY, \
3747 -}
3748 -
3749 extern struct smp_operations ux500_smp_ops;
3750 extern void ux500_cpu_die(unsigned int cpu);
3751
3752 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3753 index 3fd629d..8b1aca9 100644
3754 --- a/arch/arm/mm/Kconfig
3755 +++ b/arch/arm/mm/Kconfig
3756 @@ -425,7 +425,7 @@ config CPU_32v5
3757
3758 config CPU_32v6
3759 bool
3760 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3761 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3762 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3763
3764 config CPU_32v6K
3765 @@ -577,6 +577,7 @@ config CPU_CP15_MPU
3766
3767 config CPU_USE_DOMAINS
3768 bool
3769 + depends on !ARM_LPAE && !PAX_KERNEXEC
3770 help
3771 This option enables or disables the use of domain switching
3772 via the set_fs() function.
3773 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3774 index db26e2e..ee44569 100644
3775 --- a/arch/arm/mm/alignment.c
3776 +++ b/arch/arm/mm/alignment.c
3777 @@ -211,10 +211,12 @@ union offset_union {
3778 #define __get16_unaligned_check(ins,val,addr) \
3779 do { \
3780 unsigned int err = 0, v, a = addr; \
3781 + pax_open_userland(); \
3782 __get8_unaligned_check(ins,v,a,err); \
3783 val = v << ((BE) ? 8 : 0); \
3784 __get8_unaligned_check(ins,v,a,err); \
3785 val |= v << ((BE) ? 0 : 8); \
3786 + pax_close_userland(); \
3787 if (err) \
3788 goto fault; \
3789 } while (0)
3790 @@ -228,6 +230,7 @@ union offset_union {
3791 #define __get32_unaligned_check(ins,val,addr) \
3792 do { \
3793 unsigned int err = 0, v, a = addr; \
3794 + pax_open_userland(); \
3795 __get8_unaligned_check(ins,v,a,err); \
3796 val = v << ((BE) ? 24 : 0); \
3797 __get8_unaligned_check(ins,v,a,err); \
3798 @@ -236,6 +239,7 @@ union offset_union {
3799 val |= v << ((BE) ? 8 : 16); \
3800 __get8_unaligned_check(ins,v,a,err); \
3801 val |= v << ((BE) ? 0 : 24); \
3802 + pax_close_userland(); \
3803 if (err) \
3804 goto fault; \
3805 } while (0)
3806 @@ -249,6 +253,7 @@ union offset_union {
3807 #define __put16_unaligned_check(ins,val,addr) \
3808 do { \
3809 unsigned int err = 0, v = val, a = addr; \
3810 + pax_open_userland(); \
3811 __asm__( FIRST_BYTE_16 \
3812 ARM( "1: "ins" %1, [%2], #1\n" ) \
3813 THUMB( "1: "ins" %1, [%2]\n" ) \
3814 @@ -268,6 +273,7 @@ union offset_union {
3815 " .popsection\n" \
3816 : "=r" (err), "=&r" (v), "=&r" (a) \
3817 : "0" (err), "1" (v), "2" (a)); \
3818 + pax_close_userland(); \
3819 if (err) \
3820 goto fault; \
3821 } while (0)
3822 @@ -281,6 +287,7 @@ union offset_union {
3823 #define __put32_unaligned_check(ins,val,addr) \
3824 do { \
3825 unsigned int err = 0, v = val, a = addr; \
3826 + pax_open_userland(); \
3827 __asm__( FIRST_BYTE_32 \
3828 ARM( "1: "ins" %1, [%2], #1\n" ) \
3829 THUMB( "1: "ins" %1, [%2]\n" ) \
3830 @@ -310,6 +317,7 @@ union offset_union {
3831 " .popsection\n" \
3832 : "=r" (err), "=&r" (v), "=&r" (a) \
3833 : "0" (err), "1" (v), "2" (a)); \
3834 + pax_close_userland(); \
3835 if (err) \
3836 goto fault; \
3837 } while (0)
3838 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3839 index d07df17..59d5493 100644
3840 --- a/arch/arm/mm/context.c
3841 +++ b/arch/arm/mm/context.c
3842 @@ -45,7 +45,7 @@ static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3843 static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3844 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3845
3846 -static DEFINE_PER_CPU(atomic64_t, active_asids);
3847 +DEFINE_PER_CPU(atomic64_t, active_asids);
3848 static DEFINE_PER_CPU(u64, reserved_asids);
3849 static cpumask_t tlb_flush_pending;
3850
3851 @@ -209,8 +209,10 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3852 atomic64_set(&mm->context.id, asid);
3853 }
3854
3855 - if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending))
3856 + if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) {
3857 local_flush_tlb_all();
3858 + dummy_flush_tlb_a15_erratum();
3859 + }
3860
3861 atomic64_set(&per_cpu(active_asids, cpu), asid);
3862 cpumask_set_cpu(cpu, mm_cpumask(mm));
3863 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3864 index 5dbf13f..1a60561 100644
3865 --- a/arch/arm/mm/fault.c
3866 +++ b/arch/arm/mm/fault.c
3867 @@ -25,6 +25,7 @@
3868 #include <asm/system_misc.h>
3869 #include <asm/system_info.h>
3870 #include <asm/tlbflush.h>
3871 +#include <asm/sections.h>
3872
3873 #include "fault.h"
3874
3875 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3876 if (fixup_exception(regs))
3877 return;
3878
3879 +#ifdef CONFIG_PAX_KERNEXEC
3880 + if ((fsr & FSR_WRITE) &&
3881 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3882 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3883 + {
3884 + if (current->signal->curr_ip)
3885 + 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),
3886 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3887 + else
3888 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3889 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3890 + }
3891 +#endif
3892 +
3893 /*
3894 * No handler, we'll have to terminate things with extreme prejudice.
3895 */
3896 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3897 }
3898 #endif
3899
3900 +#ifdef CONFIG_PAX_PAGEEXEC
3901 + if (fsr & FSR_LNX_PF) {
3902 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3903 + do_group_exit(SIGKILL);
3904 + }
3905 +#endif
3906 +
3907 tsk->thread.address = addr;
3908 tsk->thread.error_code = fsr;
3909 tsk->thread.trap_no = 14;
3910 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3911 }
3912 #endif /* CONFIG_MMU */
3913
3914 +#ifdef CONFIG_PAX_PAGEEXEC
3915 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3916 +{
3917 + long i;
3918 +
3919 + printk(KERN_ERR "PAX: bytes at PC: ");
3920 + for (i = 0; i < 20; i++) {
3921 + unsigned char c;
3922 + if (get_user(c, (__force unsigned char __user *)pc+i))
3923 + printk(KERN_CONT "?? ");
3924 + else
3925 + printk(KERN_CONT "%02x ", c);
3926 + }
3927 + printk("\n");
3928 +
3929 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3930 + for (i = -1; i < 20; i++) {
3931 + unsigned long c;
3932 + if (get_user(c, (__force unsigned long __user *)sp+i))
3933 + printk(KERN_CONT "???????? ");
3934 + else
3935 + printk(KERN_CONT "%08lx ", c);
3936 + }
3937 + printk("\n");
3938 +}
3939 +#endif
3940 +
3941 /*
3942 * First Level Translation Fault Handler
3943 *
3944 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3945 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3946 struct siginfo info;
3947
3948 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3949 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3950 + if (current->signal->curr_ip)
3951 + 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),
3952 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3953 + else
3954 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3955 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3956 + goto die;
3957 + }
3958 +#endif
3959 +
3960 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3961 return;
3962
3963 +die:
3964 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3965 inf->name, fsr, addr);
3966
3967 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3968 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3969 struct siginfo info;
3970
3971 + if (user_mode(regs)) {
3972 + if (addr == 0xffff0fe0UL) {
3973 + /*
3974 + * PaX: __kuser_get_tls emulation
3975 + */
3976 + regs->ARM_r0 = current_thread_info()->tp_value;
3977 + regs->ARM_pc = regs->ARM_lr;
3978 + return;
3979 + }
3980 + }
3981 +
3982 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3983 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3984 + if (current->signal->curr_ip)
3985 + 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),
3986 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3987 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3988 + else
3989 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3990 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3991 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3992 + goto die;
3993 + }
3994 +#endif
3995 +
3996 +#ifdef CONFIG_PAX_REFCOUNT
3997 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3998 + unsigned int bkpt;
3999 +
4000 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
4001 + current->thread.error_code = ifsr;
4002 + current->thread.trap_no = 0;
4003 + pax_report_refcount_overflow(regs);
4004 + fixup_exception(regs);
4005 + return;
4006 + }
4007 + }
4008 +#endif
4009 +
4010 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4011 return;
4012
4013 +die:
4014 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4015 inf->name, ifsr, addr);
4016
4017 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4018 index cf08bdf..772656c 100644
4019 --- a/arch/arm/mm/fault.h
4020 +++ b/arch/arm/mm/fault.h
4021 @@ -3,6 +3,7 @@
4022
4023 /*
4024 * Fault status register encodings. We steal bit 31 for our own purposes.
4025 + * Set when the FSR value is from an instruction fault.
4026 */
4027 #define FSR_LNX_PF (1 << 31)
4028 #define FSR_WRITE (1 << 11)
4029 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4030 }
4031 #endif
4032
4033 +/* valid for LPAE and !LPAE */
4034 +static inline int is_xn_fault(unsigned int fsr)
4035 +{
4036 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4037 +}
4038 +
4039 +static inline int is_domain_fault(unsigned int fsr)
4040 +{
4041 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4042 +}
4043 +
4044 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4045 unsigned long search_exception_table(unsigned long addr);
4046
4047 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4048 index ad722f1..763fdd3 100644
4049 --- a/arch/arm/mm/init.c
4050 +++ b/arch/arm/mm/init.c
4051 @@ -30,6 +30,8 @@
4052 #include <asm/setup.h>
4053 #include <asm/tlb.h>
4054 #include <asm/fixmap.h>
4055 +#include <asm/system_info.h>
4056 +#include <asm/cp15.h>
4057
4058 #include <asm/mach/arch.h>
4059 #include <asm/mach/map.h>
4060 @@ -736,7 +738,46 @@ void free_initmem(void)
4061 {
4062 #ifdef CONFIG_HAVE_TCM
4063 extern char __tcm_start, __tcm_end;
4064 +#endif
4065
4066 +#ifdef CONFIG_PAX_KERNEXEC
4067 + unsigned long addr;
4068 + pgd_t *pgd;
4069 + pud_t *pud;
4070 + pmd_t *pmd;
4071 + int cpu_arch = cpu_architecture();
4072 + unsigned int cr = get_cr();
4073 +
4074 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4075 + /* make pages tables, etc before .text NX */
4076 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4077 + pgd = pgd_offset_k(addr);
4078 + pud = pud_offset(pgd, addr);
4079 + pmd = pmd_offset(pud, addr);
4080 + __section_update(pmd, addr, PMD_SECT_XN);
4081 + }
4082 + /* make init NX */
4083 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4084 + pgd = pgd_offset_k(addr);
4085 + pud = pud_offset(pgd, addr);
4086 + pmd = pmd_offset(pud, addr);
4087 + __section_update(pmd, addr, PMD_SECT_XN);
4088 + }
4089 + /* make kernel code/rodata RX */
4090 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4091 + pgd = pgd_offset_k(addr);
4092 + pud = pud_offset(pgd, addr);
4093 + pmd = pmd_offset(pud, addr);
4094 +#ifdef CONFIG_ARM_LPAE
4095 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4096 +#else
4097 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4098 +#endif
4099 + }
4100 + }
4101 +#endif
4102 +
4103 +#ifdef CONFIG_HAVE_TCM
4104 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4105 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
4106 __phys_to_pfn(__pa(&__tcm_end)),
4107 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4108 index 88fd86c..7a224ce 100644
4109 --- a/arch/arm/mm/ioremap.c
4110 +++ b/arch/arm/mm/ioremap.c
4111 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4112 unsigned int mtype;
4113
4114 if (cached)
4115 - mtype = MT_MEMORY;
4116 + mtype = MT_MEMORY_RX;
4117 else
4118 - mtype = MT_MEMORY_NONCACHED;
4119 + mtype = MT_MEMORY_NONCACHED_RX;
4120
4121 return __arm_ioremap_caller(phys_addr, size, mtype,
4122 __builtin_return_address(0));
4123 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4124 index 10062ce..aa96dd7 100644
4125 --- a/arch/arm/mm/mmap.c
4126 +++ b/arch/arm/mm/mmap.c
4127 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4128 struct vm_area_struct *vma;
4129 int do_align = 0;
4130 int aliasing = cache_is_vipt_aliasing();
4131 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4132 struct vm_unmapped_area_info info;
4133
4134 /*
4135 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4136 if (len > TASK_SIZE)
4137 return -ENOMEM;
4138
4139 +#ifdef CONFIG_PAX_RANDMMAP
4140 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4141 +#endif
4142 +
4143 if (addr) {
4144 if (do_align)
4145 addr = COLOUR_ALIGN(addr, pgoff);
4146 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4147 addr = PAGE_ALIGN(addr);
4148
4149 vma = find_vma(mm, addr);
4150 - if (TASK_SIZE - len >= addr &&
4151 - (!vma || addr + len <= vma->vm_start))
4152 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4153 return addr;
4154 }
4155
4156 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4157 unsigned long addr = addr0;
4158 int do_align = 0;
4159 int aliasing = cache_is_vipt_aliasing();
4160 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4161 struct vm_unmapped_area_info info;
4162
4163 /*
4164 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4165 return addr;
4166 }
4167
4168 +#ifdef CONFIG_PAX_RANDMMAP
4169 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4170 +#endif
4171 +
4172 /* requesting a specific address */
4173 if (addr) {
4174 if (do_align)
4175 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4176 else
4177 addr = PAGE_ALIGN(addr);
4178 vma = find_vma(mm, addr);
4179 - if (TASK_SIZE - len >= addr &&
4180 - (!vma || addr + len <= vma->vm_start))
4181 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4182 return addr;
4183 }
4184
4185 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4186 VM_BUG_ON(addr != -ENOMEM);
4187 info.flags = 0;
4188 info.low_limit = mm->mmap_base;
4189 +
4190 +#ifdef CONFIG_PAX_RANDMMAP
4191 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4192 + info.low_limit += mm->delta_mmap;
4193 +#endif
4194 +
4195 info.high_limit = TASK_SIZE;
4196 addr = vm_unmapped_area(&info);
4197 }
4198 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4199 {
4200 unsigned long random_factor = 0UL;
4201
4202 +#ifdef CONFIG_PAX_RANDMMAP
4203 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4204 +#endif
4205 +
4206 /* 8 bits of randomness in 20 address space bits */
4207 if ((current->flags & PF_RANDOMIZE) &&
4208 !(current->personality & ADDR_NO_RANDOMIZE))
4209 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4210
4211 if (mmap_is_legacy()) {
4212 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4213 +
4214 +#ifdef CONFIG_PAX_RANDMMAP
4215 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4216 + mm->mmap_base += mm->delta_mmap;
4217 +#endif
4218 +
4219 mm->get_unmapped_area = arch_get_unmapped_area;
4220 mm->unmap_area = arch_unmap_area;
4221 } else {
4222 mm->mmap_base = mmap_base(random_factor);
4223 +
4224 +#ifdef CONFIG_PAX_RANDMMAP
4225 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4226 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4227 +#endif
4228 +
4229 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4230 mm->unmap_area = arch_unmap_area_topdown;
4231 }
4232 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4233 index ce328c7..35b88dc 100644
4234 --- a/arch/arm/mm/mmu.c
4235 +++ b/arch/arm/mm/mmu.c
4236 @@ -35,6 +35,23 @@
4237
4238 #include "mm.h"
4239
4240 +
4241 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4242 +void modify_domain(unsigned int dom, unsigned int type)
4243 +{
4244 + struct thread_info *thread = current_thread_info();
4245 + unsigned int domain = thread->cpu_domain;
4246 + /*
4247 + * DOMAIN_MANAGER might be defined to some other value,
4248 + * use the arch-defined constant
4249 + */
4250 + domain &= ~domain_val(dom, 3);
4251 + thread->cpu_domain = domain | domain_val(dom, type);
4252 + set_domain(thread->cpu_domain);
4253 +}
4254 +EXPORT_SYMBOL(modify_domain);
4255 +#endif
4256 +
4257 /*
4258 * empty_zero_page is a special page that is used for
4259 * zero-initialized data and COW.
4260 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4261 }
4262 #endif
4263
4264 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4265 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4266 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4267
4268 -static struct mem_type mem_types[] = {
4269 +#ifdef CONFIG_PAX_KERNEXEC
4270 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4271 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4272 +#else
4273 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4274 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4275 +#endif
4276 +
4277 +static struct mem_type mem_types[] __read_only = {
4278 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4279 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4280 L_PTE_SHARED,
4281 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4282 [MT_UNCACHED] = {
4283 .prot_pte = PROT_PTE_DEVICE,
4284 .prot_l1 = PMD_TYPE_TABLE,
4285 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4286 + .prot_sect = PROT_SECT_DEVICE,
4287 .domain = DOMAIN_IO,
4288 },
4289 [MT_CACHECLEAN] = {
4290 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4291 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4292 .domain = DOMAIN_KERNEL,
4293 },
4294 #ifndef CONFIG_ARM_LPAE
4295 [MT_MINICLEAN] = {
4296 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4297 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4298 .domain = DOMAIN_KERNEL,
4299 },
4300 #endif
4301 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4302 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4303 L_PTE_RDONLY,
4304 .prot_l1 = PMD_TYPE_TABLE,
4305 - .domain = DOMAIN_USER,
4306 + .domain = DOMAIN_VECTORS,
4307 },
4308 [MT_HIGH_VECTORS] = {
4309 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4310 - L_PTE_USER | L_PTE_RDONLY,
4311 + L_PTE_RDONLY,
4312 .prot_l1 = PMD_TYPE_TABLE,
4313 - .domain = DOMAIN_USER,
4314 + .domain = DOMAIN_VECTORS,
4315 },
4316 - [MT_MEMORY] = {
4317 + [MT_MEMORY_RWX] = {
4318 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4319 .prot_l1 = PMD_TYPE_TABLE,
4320 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4321 .domain = DOMAIN_KERNEL,
4322 },
4323 + [MT_MEMORY_RW] = {
4324 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4325 + .prot_l1 = PMD_TYPE_TABLE,
4326 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4327 + .domain = DOMAIN_KERNEL,
4328 + },
4329 + [MT_MEMORY_RX] = {
4330 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4331 + .prot_l1 = PMD_TYPE_TABLE,
4332 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4333 + .domain = DOMAIN_KERNEL,
4334 + },
4335 [MT_ROM] = {
4336 - .prot_sect = PMD_TYPE_SECT,
4337 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4338 .domain = DOMAIN_KERNEL,
4339 },
4340 - [MT_MEMORY_NONCACHED] = {
4341 + [MT_MEMORY_NONCACHED_RW] = {
4342 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4343 L_PTE_MT_BUFFERABLE,
4344 .prot_l1 = PMD_TYPE_TABLE,
4345 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4346 .domain = DOMAIN_KERNEL,
4347 },
4348 + [MT_MEMORY_NONCACHED_RX] = {
4349 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4350 + L_PTE_MT_BUFFERABLE,
4351 + .prot_l1 = PMD_TYPE_TABLE,
4352 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4353 + .domain = DOMAIN_KERNEL,
4354 + },
4355 [MT_MEMORY_DTCM] = {
4356 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4357 - L_PTE_XN,
4358 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4359 .prot_l1 = PMD_TYPE_TABLE,
4360 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4361 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4362 .domain = DOMAIN_KERNEL,
4363 },
4364 [MT_MEMORY_ITCM] = {
4365 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4366 },
4367 [MT_MEMORY_SO] = {
4368 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4369 - L_PTE_MT_UNCACHED | L_PTE_XN,
4370 + L_PTE_MT_UNCACHED,
4371 .prot_l1 = PMD_TYPE_TABLE,
4372 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4373 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4374 + PMD_SECT_UNCACHED,
4375 .domain = DOMAIN_KERNEL,
4376 },
4377 [MT_MEMORY_DMA_READY] = {
4378 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4379 * to prevent speculative instruction fetches.
4380 */
4381 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4382 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4383 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4384 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4385 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4386 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4387 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4388 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4389 +
4390 + /* Mark other regions on ARMv6+ as execute-never */
4391 +
4392 +#ifdef CONFIG_PAX_KERNEXEC
4393 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4394 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4395 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4396 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4397 +#ifndef CONFIG_ARM_LPAE
4398 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4399 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4400 +#endif
4401 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4402 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4403 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4404 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4405 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4406 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4407 +#endif
4408 +
4409 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4410 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4411 }
4412 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4413 /*
4414 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4415 * from SVC mode and no access from userspace.
4416 */
4417 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4418 +#ifdef CONFIG_PAX_KERNEXEC
4419 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4420 +#endif
4421 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4422 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4423 #endif
4424 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4425 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4426 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4427 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4428 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4429 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4430 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4431 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4432 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4433 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4434 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4435 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4436 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4437 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4438 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4439 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4440 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4441 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4442 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4443 }
4444 }
4445
4446 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4447 if (cpu_arch >= CPU_ARCH_ARMv6) {
4448 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4449 /* Non-cacheable Normal is XCB = 001 */
4450 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4451 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4452 + PMD_SECT_BUFFERED;
4453 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4454 PMD_SECT_BUFFERED;
4455 } else {
4456 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4457 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4458 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4459 + PMD_SECT_TEX(1);
4460 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4461 PMD_SECT_TEX(1);
4462 }
4463 } else {
4464 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4465 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4466 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4467 }
4468
4469 #ifdef CONFIG_ARM_LPAE
4470 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4471 vecs_pgprot |= PTE_EXT_AF;
4472 #endif
4473
4474 + user_pgprot |= __supported_pte_mask;
4475 +
4476 for (i = 0; i < 16; i++) {
4477 pteval_t v = pgprot_val(protection_map[i]);
4478 protection_map[i] = __pgprot(v | user_pgprot);
4479 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4480
4481 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4482 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4483 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4484 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4485 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4486 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4487 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4488 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4489 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4490 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4491 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4492 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4493 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4494 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4495 mem_types[MT_ROM].prot_sect |= cp->pmd;
4496
4497 switch (cp->pmd) {
4498 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4499 * called function. This means you can't use any function or debugging
4500 * method which may touch any device, otherwise the kernel _will_ crash.
4501 */
4502 +
4503 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4504 +
4505 static void __init devicemaps_init(struct machine_desc *mdesc)
4506 {
4507 struct map_desc map;
4508 unsigned long addr;
4509 - void *vectors;
4510
4511 - /*
4512 - * Allocate the vector page early.
4513 - */
4514 - vectors = early_alloc(PAGE_SIZE);
4515 -
4516 - early_trap_init(vectors);
4517 + early_trap_init(&vectors);
4518
4519 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4520 pmd_clear(pmd_off_k(addr));
4521 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4522 * location (0xffff0000). If we aren't using high-vectors, also
4523 * create a mapping at the low-vectors virtual address.
4524 */
4525 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4526 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4527 map.virtual = 0xffff0000;
4528 map.length = PAGE_SIZE;
4529 map.type = MT_HIGH_VECTORS;
4530 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4531 map.pfn = __phys_to_pfn(start);
4532 map.virtual = __phys_to_virt(start);
4533 map.length = end - start;
4534 - map.type = MT_MEMORY;
4535
4536 +#ifdef CONFIG_PAX_KERNEXEC
4537 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4538 + struct map_desc kernel;
4539 + struct map_desc initmap;
4540 +
4541 + /* when freeing initmem we will make this RW */
4542 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4543 + initmap.virtual = (unsigned long)__init_begin;
4544 + initmap.length = _sdata - __init_begin;
4545 + initmap.type = MT_MEMORY_RWX;
4546 + create_mapping(&initmap);
4547 +
4548 + /* when freeing initmem we will make this RX */
4549 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4550 + kernel.virtual = (unsigned long)_stext;
4551 + kernel.length = __init_begin - _stext;
4552 + kernel.type = MT_MEMORY_RWX;
4553 + create_mapping(&kernel);
4554 +
4555 + if (map.virtual < (unsigned long)_stext) {
4556 + map.length = (unsigned long)_stext - map.virtual;
4557 + map.type = MT_MEMORY_RWX;
4558 + create_mapping(&map);
4559 + }
4560 +
4561 + map.pfn = __phys_to_pfn(__pa(_sdata));
4562 + map.virtual = (unsigned long)_sdata;
4563 + map.length = end - __pa(_sdata);
4564 + }
4565 +#endif
4566 +
4567 + map.type = MT_MEMORY_RW;
4568 create_mapping(&map);
4569 }
4570 }
4571 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4572 index 6d98c13..3cfb174 100644
4573 --- a/arch/arm/mm/proc-v7-2level.S
4574 +++ b/arch/arm/mm/proc-v7-2level.S
4575 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4576 tst r1, #L_PTE_XN
4577 orrne r3, r3, #PTE_EXT_XN
4578
4579 + tst r1, #L_PTE_PXN
4580 + orrne r3, r3, #PTE_EXT_PXN
4581 +
4582 tst r1, #L_PTE_YOUNG
4583 tstne r1, #L_PTE_VALID
4584 #ifndef CONFIG_CPU_USE_DOMAINS
4585 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4586 index a5bc92d..0bb4730 100644
4587 --- a/arch/arm/plat-omap/sram.c
4588 +++ b/arch/arm/plat-omap/sram.c
4589 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4590 * Looks like we need to preserve some bootloader code at the
4591 * beginning of SRAM for jumping to flash for reboot to work...
4592 */
4593 + pax_open_kernel();
4594 memset_io(omap_sram_base + omap_sram_skip, 0,
4595 omap_sram_size - omap_sram_skip);
4596 + pax_close_kernel();
4597 }
4598 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4599 index f5144cd..71f6d1f 100644
4600 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4601 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4602 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4603 int (*started)(unsigned ch);
4604 int (*flush)(unsigned ch);
4605 int (*stop)(unsigned ch);
4606 -};
4607 +} __no_const;
4608
4609 extern void *samsung_dmadev_get_ops(void);
4610 extern void *s3c_dma_get_ops(void);
4611 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4612 index 0c3ba9f..95722b3 100644
4613 --- a/arch/arm64/kernel/debug-monitors.c
4614 +++ b/arch/arm64/kernel/debug-monitors.c
4615 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4616 return NOTIFY_OK;
4617 }
4618
4619 -static struct notifier_block __cpuinitdata os_lock_nb = {
4620 +static struct notifier_block os_lock_nb = {
4621 .notifier_call = os_lock_notify,
4622 };
4623
4624 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4625 index 5ab825c..96aaec8 100644
4626 --- a/arch/arm64/kernel/hw_breakpoint.c
4627 +++ b/arch/arm64/kernel/hw_breakpoint.c
4628 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4629 return NOTIFY_OK;
4630 }
4631
4632 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4633 +static struct notifier_block hw_breakpoint_reset_nb = {
4634 .notifier_call = hw_breakpoint_reset_notify,
4635 };
4636
4637 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4638 index c3a58a1..78fbf54 100644
4639 --- a/arch/avr32/include/asm/cache.h
4640 +++ b/arch/avr32/include/asm/cache.h
4641 @@ -1,8 +1,10 @@
4642 #ifndef __ASM_AVR32_CACHE_H
4643 #define __ASM_AVR32_CACHE_H
4644
4645 +#include <linux/const.h>
4646 +
4647 #define L1_CACHE_SHIFT 5
4648 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4649 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4650
4651 /*
4652 * Memory returned by kmalloc() may be used for DMA, so we must make
4653 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4654 index e2c3287..6c4f98c 100644
4655 --- a/arch/avr32/include/asm/elf.h
4656 +++ b/arch/avr32/include/asm/elf.h
4657 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4658 the loader. We need to make sure that it is out of the way of the program
4659 that it will "exec", and that there is sufficient room for the brk. */
4660
4661 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4662 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4663
4664 +#ifdef CONFIG_PAX_ASLR
4665 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4666 +
4667 +#define PAX_DELTA_MMAP_LEN 15
4668 +#define PAX_DELTA_STACK_LEN 15
4669 +#endif
4670
4671 /* This yields a mask that user programs can use to figure out what
4672 instruction set this CPU supports. This could be done in user space,
4673 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4674 index 479330b..53717a8 100644
4675 --- a/arch/avr32/include/asm/kmap_types.h
4676 +++ b/arch/avr32/include/asm/kmap_types.h
4677 @@ -2,9 +2,9 @@
4678 #define __ASM_AVR32_KMAP_TYPES_H
4679
4680 #ifdef CONFIG_DEBUG_HIGHMEM
4681 -# define KM_TYPE_NR 29
4682 +# define KM_TYPE_NR 30
4683 #else
4684 -# define KM_TYPE_NR 14
4685 +# define KM_TYPE_NR 15
4686 #endif
4687
4688 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4689 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4690 index b2f2d2d..d1c85cb 100644
4691 --- a/arch/avr32/mm/fault.c
4692 +++ b/arch/avr32/mm/fault.c
4693 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4694
4695 int exception_trace = 1;
4696
4697 +#ifdef CONFIG_PAX_PAGEEXEC
4698 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4699 +{
4700 + unsigned long i;
4701 +
4702 + printk(KERN_ERR "PAX: bytes at PC: ");
4703 + for (i = 0; i < 20; i++) {
4704 + unsigned char c;
4705 + if (get_user(c, (unsigned char *)pc+i))
4706 + printk(KERN_CONT "???????? ");
4707 + else
4708 + printk(KERN_CONT "%02x ", c);
4709 + }
4710 + printk("\n");
4711 +}
4712 +#endif
4713 +
4714 /*
4715 * This routine handles page faults. It determines the address and the
4716 * problem, and then passes it off to one of the appropriate routines.
4717 @@ -174,6 +191,16 @@ bad_area:
4718 up_read(&mm->mmap_sem);
4719
4720 if (user_mode(regs)) {
4721 +
4722 +#ifdef CONFIG_PAX_PAGEEXEC
4723 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4724 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4725 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4726 + do_group_exit(SIGKILL);
4727 + }
4728 + }
4729 +#endif
4730 +
4731 if (exception_trace && printk_ratelimit())
4732 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4733 "sp %08lx ecr %lu\n",
4734 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4735 index 568885a..f8008df 100644
4736 --- a/arch/blackfin/include/asm/cache.h
4737 +++ b/arch/blackfin/include/asm/cache.h
4738 @@ -7,6 +7,7 @@
4739 #ifndef __ARCH_BLACKFIN_CACHE_H
4740 #define __ARCH_BLACKFIN_CACHE_H
4741
4742 +#include <linux/const.h>
4743 #include <linux/linkage.h> /* for asmlinkage */
4744
4745 /*
4746 @@ -14,7 +15,7 @@
4747 * Blackfin loads 32 bytes for cache
4748 */
4749 #define L1_CACHE_SHIFT 5
4750 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4751 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4752 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4753
4754 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4755 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4756 index aea2718..3639a60 100644
4757 --- a/arch/cris/include/arch-v10/arch/cache.h
4758 +++ b/arch/cris/include/arch-v10/arch/cache.h
4759 @@ -1,8 +1,9 @@
4760 #ifndef _ASM_ARCH_CACHE_H
4761 #define _ASM_ARCH_CACHE_H
4762
4763 +#include <linux/const.h>
4764 /* Etrax 100LX have 32-byte cache-lines. */
4765 -#define L1_CACHE_BYTES 32
4766 #define L1_CACHE_SHIFT 5
4767 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4768
4769 #endif /* _ASM_ARCH_CACHE_H */
4770 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4771 index 7caf25d..ee65ac5 100644
4772 --- a/arch/cris/include/arch-v32/arch/cache.h
4773 +++ b/arch/cris/include/arch-v32/arch/cache.h
4774 @@ -1,11 +1,12 @@
4775 #ifndef _ASM_CRIS_ARCH_CACHE_H
4776 #define _ASM_CRIS_ARCH_CACHE_H
4777
4778 +#include <linux/const.h>
4779 #include <arch/hwregs/dma.h>
4780
4781 /* A cache-line is 32 bytes. */
4782 -#define L1_CACHE_BYTES 32
4783 #define L1_CACHE_SHIFT 5
4784 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4785
4786 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4787
4788 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4789 index b86329d..6709906 100644
4790 --- a/arch/frv/include/asm/atomic.h
4791 +++ b/arch/frv/include/asm/atomic.h
4792 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4793 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4794 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4795
4796 +#define atomic64_read_unchecked(v) atomic64_read(v)
4797 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4798 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4799 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4800 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4801 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4802 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4803 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4804 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4805 +
4806 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4807 {
4808 int c, old;
4809 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4810 index 2797163..c2a401d 100644
4811 --- a/arch/frv/include/asm/cache.h
4812 +++ b/arch/frv/include/asm/cache.h
4813 @@ -12,10 +12,11 @@
4814 #ifndef __ASM_CACHE_H
4815 #define __ASM_CACHE_H
4816
4817 +#include <linux/const.h>
4818
4819 /* bytes per L1 cache line */
4820 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4821 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4822 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4823
4824 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4825 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4826 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4827 index 43901f2..0d8b865 100644
4828 --- a/arch/frv/include/asm/kmap_types.h
4829 +++ b/arch/frv/include/asm/kmap_types.h
4830 @@ -2,6 +2,6 @@
4831 #ifndef _ASM_KMAP_TYPES_H
4832 #define _ASM_KMAP_TYPES_H
4833
4834 -#define KM_TYPE_NR 17
4835 +#define KM_TYPE_NR 18
4836
4837 #endif
4838 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4839 index 385fd30..3aaf4fe 100644
4840 --- a/arch/frv/mm/elf-fdpic.c
4841 +++ b/arch/frv/mm/elf-fdpic.c
4842 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4843 {
4844 struct vm_area_struct *vma;
4845 unsigned long limit;
4846 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4847
4848 if (len > TASK_SIZE)
4849 return -ENOMEM;
4850 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4851 if (addr) {
4852 addr = PAGE_ALIGN(addr);
4853 vma = find_vma(current->mm, addr);
4854 - if (TASK_SIZE - len >= addr &&
4855 - (!vma || addr + len <= vma->vm_start))
4856 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4857 goto success;
4858 }
4859
4860 @@ -89,7 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4861 for (; vma; vma = vma->vm_next) {
4862 if (addr > limit)
4863 break;
4864 - if (addr + len <= vma->vm_start)
4865 + if (check_heap_stack_gap(vma, addr, len, offset))
4866 goto success;
4867 addr = vma->vm_end;
4868 }
4869 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4870 for (; vma; vma = vma->vm_next) {
4871 if (addr > limit)
4872 break;
4873 - if (addr + len <= vma->vm_start)
4874 + if (check_heap_stack_gap(vma, addr, len, offset))
4875 goto success;
4876 addr = vma->vm_end;
4877 }
4878 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4879 index f4ca594..adc72fd6 100644
4880 --- a/arch/hexagon/include/asm/cache.h
4881 +++ b/arch/hexagon/include/asm/cache.h
4882 @@ -21,9 +21,11 @@
4883 #ifndef __ASM_CACHE_H
4884 #define __ASM_CACHE_H
4885
4886 +#include <linux/const.h>
4887 +
4888 /* Bytes per L1 cache line */
4889 -#define L1_CACHE_SHIFT (5)
4890 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4891 +#define L1_CACHE_SHIFT 5
4892 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4893
4894 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4895 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4896 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4897 index 6e6fe18..a6ae668 100644
4898 --- a/arch/ia64/include/asm/atomic.h
4899 +++ b/arch/ia64/include/asm/atomic.h
4900 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4901 #define atomic64_inc(v) atomic64_add(1, (v))
4902 #define atomic64_dec(v) atomic64_sub(1, (v))
4903
4904 +#define atomic64_read_unchecked(v) atomic64_read(v)
4905 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4906 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4907 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4908 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4909 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4910 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4911 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4912 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4913 +
4914 /* Atomic operations are already serializing */
4915 #define smp_mb__before_atomic_dec() barrier()
4916 #define smp_mb__after_atomic_dec() barrier()
4917 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4918 index 988254a..e1ee885 100644
4919 --- a/arch/ia64/include/asm/cache.h
4920 +++ b/arch/ia64/include/asm/cache.h
4921 @@ -1,6 +1,7 @@
4922 #ifndef _ASM_IA64_CACHE_H
4923 #define _ASM_IA64_CACHE_H
4924
4925 +#include <linux/const.h>
4926
4927 /*
4928 * Copyright (C) 1998-2000 Hewlett-Packard Co
4929 @@ -9,7 +10,7 @@
4930
4931 /* Bytes per L1 (data) cache line. */
4932 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4933 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4934 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4935
4936 #ifdef CONFIG_SMP
4937 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4938 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4939 index b5298eb..67c6e62 100644
4940 --- a/arch/ia64/include/asm/elf.h
4941 +++ b/arch/ia64/include/asm/elf.h
4942 @@ -42,6 +42,13 @@
4943 */
4944 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4945
4946 +#ifdef CONFIG_PAX_ASLR
4947 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4948 +
4949 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4950 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4951 +#endif
4952 +
4953 #define PT_IA_64_UNWIND 0x70000001
4954
4955 /* IA-64 relocations: */
4956 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4957 index 96a8d92..617a1cf 100644
4958 --- a/arch/ia64/include/asm/pgalloc.h
4959 +++ b/arch/ia64/include/asm/pgalloc.h
4960 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4961 pgd_val(*pgd_entry) = __pa(pud);
4962 }
4963
4964 +static inline void
4965 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4966 +{
4967 + pgd_populate(mm, pgd_entry, pud);
4968 +}
4969 +
4970 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4971 {
4972 return quicklist_alloc(0, GFP_KERNEL, NULL);
4973 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4974 pud_val(*pud_entry) = __pa(pmd);
4975 }
4976
4977 +static inline void
4978 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4979 +{
4980 + pud_populate(mm, pud_entry, pmd);
4981 +}
4982 +
4983 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4984 {
4985 return quicklist_alloc(0, GFP_KERNEL, NULL);
4986 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4987 index 815810c..d60bd4c 100644
4988 --- a/arch/ia64/include/asm/pgtable.h
4989 +++ b/arch/ia64/include/asm/pgtable.h
4990 @@ -12,7 +12,7 @@
4991 * David Mosberger-Tang <davidm@hpl.hp.com>
4992 */
4993
4994 -
4995 +#include <linux/const.h>
4996 #include <asm/mman.h>
4997 #include <asm/page.h>
4998 #include <asm/processor.h>
4999 @@ -142,6 +142,17 @@
5000 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5001 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5002 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
5003 +
5004 +#ifdef CONFIG_PAX_PAGEEXEC
5005 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
5006 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5007 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
5008 +#else
5009 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5010 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5011 +# define PAGE_COPY_NOEXEC PAGE_COPY
5012 +#endif
5013 +
5014 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
5015 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
5016 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
5017 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
5018 index 54ff557..70c88b7 100644
5019 --- a/arch/ia64/include/asm/spinlock.h
5020 +++ b/arch/ia64/include/asm/spinlock.h
5021 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
5022 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
5023
5024 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
5025 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5026 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5027 }
5028
5029 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5030 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5031 index 449c8c0..18965fb 100644
5032 --- a/arch/ia64/include/asm/uaccess.h
5033 +++ b/arch/ia64/include/asm/uaccess.h
5034 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5035 static inline unsigned long
5036 __copy_to_user (void __user *to, const void *from, unsigned long count)
5037 {
5038 + if (count > INT_MAX)
5039 + return count;
5040 +
5041 + if (!__builtin_constant_p(count))
5042 + check_object_size(from, count, true);
5043 +
5044 return __copy_user(to, (__force void __user *) from, count);
5045 }
5046
5047 static inline unsigned long
5048 __copy_from_user (void *to, const void __user *from, unsigned long count)
5049 {
5050 + if (count > INT_MAX)
5051 + return count;
5052 +
5053 + if (!__builtin_constant_p(count))
5054 + check_object_size(to, count, false);
5055 +
5056 return __copy_user((__force void __user *) to, from, count);
5057 }
5058
5059 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5060 ({ \
5061 void __user *__cu_to = (to); \
5062 const void *__cu_from = (from); \
5063 - long __cu_len = (n); \
5064 + unsigned long __cu_len = (n); \
5065 \
5066 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5067 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5068 + if (!__builtin_constant_p(n)) \
5069 + check_object_size(__cu_from, __cu_len, true); \
5070 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5071 + } \
5072 __cu_len; \
5073 })
5074
5075 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5076 ({ \
5077 void *__cu_to = (to); \
5078 const void __user *__cu_from = (from); \
5079 - long __cu_len = (n); \
5080 + unsigned long __cu_len = (n); \
5081 \
5082 __chk_user_ptr(__cu_from); \
5083 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5084 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5085 + if (!__builtin_constant_p(n)) \
5086 + check_object_size(__cu_to, __cu_len, false); \
5087 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5088 + } \
5089 __cu_len; \
5090 })
5091
5092 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
5093 index 2d67317..07d8bfa 100644
5094 --- a/arch/ia64/kernel/err_inject.c
5095 +++ b/arch/ia64/kernel/err_inject.c
5096 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
5097 return NOTIFY_OK;
5098 }
5099
5100 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
5101 +static struct notifier_block err_inject_cpu_notifier =
5102 {
5103 .notifier_call = err_inject_cpu_callback,
5104 };
5105 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
5106 index 65bf9cd..794f06b 100644
5107 --- a/arch/ia64/kernel/mca.c
5108 +++ b/arch/ia64/kernel/mca.c
5109 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
5110 return NOTIFY_OK;
5111 }
5112
5113 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
5114 +static struct notifier_block mca_cpu_notifier = {
5115 .notifier_call = mca_cpu_callback
5116 };
5117
5118 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5119 index 24603be..948052d 100644
5120 --- a/arch/ia64/kernel/module.c
5121 +++ b/arch/ia64/kernel/module.c
5122 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5123 void
5124 module_free (struct module *mod, void *module_region)
5125 {
5126 - if (mod && mod->arch.init_unw_table &&
5127 - module_region == mod->module_init) {
5128 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5129 unw_remove_unwind_table(mod->arch.init_unw_table);
5130 mod->arch.init_unw_table = NULL;
5131 }
5132 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5133 }
5134
5135 static inline int
5136 +in_init_rx (const struct module *mod, uint64_t addr)
5137 +{
5138 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5139 +}
5140 +
5141 +static inline int
5142 +in_init_rw (const struct module *mod, uint64_t addr)
5143 +{
5144 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5145 +}
5146 +
5147 +static inline int
5148 in_init (const struct module *mod, uint64_t addr)
5149 {
5150 - return addr - (uint64_t) mod->module_init < mod->init_size;
5151 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5152 +}
5153 +
5154 +static inline int
5155 +in_core_rx (const struct module *mod, uint64_t addr)
5156 +{
5157 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5158 +}
5159 +
5160 +static inline int
5161 +in_core_rw (const struct module *mod, uint64_t addr)
5162 +{
5163 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5164 }
5165
5166 static inline int
5167 in_core (const struct module *mod, uint64_t addr)
5168 {
5169 - return addr - (uint64_t) mod->module_core < mod->core_size;
5170 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5171 }
5172
5173 static inline int
5174 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5175 break;
5176
5177 case RV_BDREL:
5178 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5179 + if (in_init_rx(mod, val))
5180 + val -= (uint64_t) mod->module_init_rx;
5181 + else if (in_init_rw(mod, val))
5182 + val -= (uint64_t) mod->module_init_rw;
5183 + else if (in_core_rx(mod, val))
5184 + val -= (uint64_t) mod->module_core_rx;
5185 + else if (in_core_rw(mod, val))
5186 + val -= (uint64_t) mod->module_core_rw;
5187 break;
5188
5189 case RV_LTV:
5190 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5191 * addresses have been selected...
5192 */
5193 uint64_t gp;
5194 - if (mod->core_size > MAX_LTOFF)
5195 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5196 /*
5197 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5198 * at the end of the module.
5199 */
5200 - gp = mod->core_size - MAX_LTOFF / 2;
5201 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5202 else
5203 - gp = mod->core_size / 2;
5204 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5205 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5206 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5207 mod->arch.gp = gp;
5208 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5209 }
5210 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5211 index 77597e5..189dd62f 100644
5212 --- a/arch/ia64/kernel/palinfo.c
5213 +++ b/arch/ia64/kernel/palinfo.c
5214 @@ -977,7 +977,7 @@ create_palinfo_proc_entries(unsigned int cpu)
5215 struct proc_dir_entry **pdir;
5216 struct proc_dir_entry *cpu_dir;
5217 int j;
5218 - char cpustr[sizeof(CPUSTR)];
5219 + char cpustr[3+4+1];
5220
5221
5222 /*
5223 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5224 return NOTIFY_OK;
5225 }
5226
5227 -static struct notifier_block __refdata palinfo_cpu_notifier =
5228 +static struct notifier_block palinfo_cpu_notifier =
5229 {
5230 .notifier_call = palinfo_cpu_callback,
5231 .priority = 0,
5232 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5233 index 79802e5..1a89ec5 100644
5234 --- a/arch/ia64/kernel/salinfo.c
5235 +++ b/arch/ia64/kernel/salinfo.c
5236 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5237 return NOTIFY_OK;
5238 }
5239
5240 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5241 +static struct notifier_block salinfo_cpu_notifier =
5242 {
5243 .notifier_call = salinfo_cpu_callback,
5244 .priority = 0,
5245 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5246 index d9439ef..d0cac6b 100644
5247 --- a/arch/ia64/kernel/sys_ia64.c
5248 +++ b/arch/ia64/kernel/sys_ia64.c
5249 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5250 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
5251 struct mm_struct *mm = current->mm;
5252 struct vm_area_struct *vma;
5253 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5254
5255 if (len > RGN_MAP_LIMIT)
5256 return -ENOMEM;
5257 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5258 if (REGION_NUMBER(addr) == RGN_HPAGE)
5259 addr = 0;
5260 #endif
5261 +
5262 +#ifdef CONFIG_PAX_RANDMMAP
5263 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5264 + addr = mm->free_area_cache;
5265 + else
5266 +#endif
5267 +
5268 if (!addr)
5269 addr = mm->free_area_cache;
5270
5271 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5272 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5273 /* At this point: (!vma || addr < vma->vm_end). */
5274 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5275 - if (start_addr != TASK_UNMAPPED_BASE) {
5276 + if (start_addr != mm->mmap_base) {
5277 /* Start a new search --- just in case we missed some holes. */
5278 - addr = TASK_UNMAPPED_BASE;
5279 + addr = mm->mmap_base;
5280 goto full_search;
5281 }
5282 return -ENOMEM;
5283 }
5284 - if (!vma || addr + len <= vma->vm_start) {
5285 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5286 /* Remember the address where we stopped this search: */
5287 mm->free_area_cache = addr + len;
5288 return addr;
5289 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5290 index dc00b2c..cce53c2 100644
5291 --- a/arch/ia64/kernel/topology.c
5292 +++ b/arch/ia64/kernel/topology.c
5293 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5294 return NOTIFY_OK;
5295 }
5296
5297 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5298 +static struct notifier_block cache_cpu_notifier =
5299 {
5300 .notifier_call = cache_cpu_callback
5301 };
5302 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5303 index 0ccb28f..8992469 100644
5304 --- a/arch/ia64/kernel/vmlinux.lds.S
5305 +++ b/arch/ia64/kernel/vmlinux.lds.S
5306 @@ -198,7 +198,7 @@ SECTIONS {
5307 /* Per-cpu data: */
5308 . = ALIGN(PERCPU_PAGE_SIZE);
5309 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5310 - __phys_per_cpu_start = __per_cpu_load;
5311 + __phys_per_cpu_start = per_cpu_load;
5312 /*
5313 * ensure percpu data fits
5314 * into percpu page size
5315 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5316 index 6cf0341..d352594 100644
5317 --- a/arch/ia64/mm/fault.c
5318 +++ b/arch/ia64/mm/fault.c
5319 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5320 return pte_present(pte);
5321 }
5322
5323 +#ifdef CONFIG_PAX_PAGEEXEC
5324 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5325 +{
5326 + unsigned long i;
5327 +
5328 + printk(KERN_ERR "PAX: bytes at PC: ");
5329 + for (i = 0; i < 8; i++) {
5330 + unsigned int c;
5331 + if (get_user(c, (unsigned int *)pc+i))
5332 + printk(KERN_CONT "???????? ");
5333 + else
5334 + printk(KERN_CONT "%08x ", c);
5335 + }
5336 + printk("\n");
5337 +}
5338 +#endif
5339 +
5340 # define VM_READ_BIT 0
5341 # define VM_WRITE_BIT 1
5342 # define VM_EXEC_BIT 2
5343 @@ -149,8 +166,21 @@ retry:
5344 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5345 goto bad_area;
5346
5347 - if ((vma->vm_flags & mask) != mask)
5348 + if ((vma->vm_flags & mask) != mask) {
5349 +
5350 +#ifdef CONFIG_PAX_PAGEEXEC
5351 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5352 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5353 + goto bad_area;
5354 +
5355 + up_read(&mm->mmap_sem);
5356 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5357 + do_group_exit(SIGKILL);
5358 + }
5359 +#endif
5360 +
5361 goto bad_area;
5362 + }
5363
5364 /*
5365 * If for any reason at all we couldn't handle the fault, make
5366 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5367 index 5ca674b..127c3cb 100644
5368 --- a/arch/ia64/mm/hugetlbpage.c
5369 +++ b/arch/ia64/mm/hugetlbpage.c
5370 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5371 unsigned long pgoff, unsigned long flags)
5372 {
5373 struct vm_area_struct *vmm;
5374 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5375
5376 if (len > RGN_MAP_LIMIT)
5377 return -ENOMEM;
5378 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5379 /* At this point: (!vmm || addr < vmm->vm_end). */
5380 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5381 return -ENOMEM;
5382 - if (!vmm || (addr + len) <= vmm->vm_start)
5383 + if (check_heap_stack_gap(vmm, addr, len, offset))
5384 return addr;
5385 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5386 }
5387 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5388 index b755ea9..b9a969e 100644
5389 --- a/arch/ia64/mm/init.c
5390 +++ b/arch/ia64/mm/init.c
5391 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5392 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5393 vma->vm_end = vma->vm_start + PAGE_SIZE;
5394 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5395 +
5396 +#ifdef CONFIG_PAX_PAGEEXEC
5397 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5398 + vma->vm_flags &= ~VM_EXEC;
5399 +
5400 +#ifdef CONFIG_PAX_MPROTECT
5401 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5402 + vma->vm_flags &= ~VM_MAYEXEC;
5403 +#endif
5404 +
5405 + }
5406 +#endif
5407 +
5408 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5409 down_write(&current->mm->mmap_sem);
5410 if (insert_vm_struct(current->mm, vma)) {
5411 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5412 index 40b3ee9..8c2c112 100644
5413 --- a/arch/m32r/include/asm/cache.h
5414 +++ b/arch/m32r/include/asm/cache.h
5415 @@ -1,8 +1,10 @@
5416 #ifndef _ASM_M32R_CACHE_H
5417 #define _ASM_M32R_CACHE_H
5418
5419 +#include <linux/const.h>
5420 +
5421 /* L1 cache line size */
5422 #define L1_CACHE_SHIFT 4
5423 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5424 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5425
5426 #endif /* _ASM_M32R_CACHE_H */
5427 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5428 index 82abd15..d95ae5d 100644
5429 --- a/arch/m32r/lib/usercopy.c
5430 +++ b/arch/m32r/lib/usercopy.c
5431 @@ -14,6 +14,9 @@
5432 unsigned long
5433 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5434 {
5435 + if ((long)n < 0)
5436 + return n;
5437 +
5438 prefetch(from);
5439 if (access_ok(VERIFY_WRITE, to, n))
5440 __copy_user(to,from,n);
5441 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5442 unsigned long
5443 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5444 {
5445 + if ((long)n < 0)
5446 + return n;
5447 +
5448 prefetchw(to);
5449 if (access_ok(VERIFY_READ, from, n))
5450 __copy_user_zeroing(to,from,n);
5451 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5452 index 0395c51..5f26031 100644
5453 --- a/arch/m68k/include/asm/cache.h
5454 +++ b/arch/m68k/include/asm/cache.h
5455 @@ -4,9 +4,11 @@
5456 #ifndef __ARCH_M68K_CACHE_H
5457 #define __ARCH_M68K_CACHE_H
5458
5459 +#include <linux/const.h>
5460 +
5461 /* bytes per L1 cache line */
5462 #define L1_CACHE_SHIFT 4
5463 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5464 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5465
5466 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5467
5468 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5469 index 4efe96a..60e8699 100644
5470 --- a/arch/microblaze/include/asm/cache.h
5471 +++ b/arch/microblaze/include/asm/cache.h
5472 @@ -13,11 +13,12 @@
5473 #ifndef _ASM_MICROBLAZE_CACHE_H
5474 #define _ASM_MICROBLAZE_CACHE_H
5475
5476 +#include <linux/const.h>
5477 #include <asm/registers.h>
5478
5479 #define L1_CACHE_SHIFT 5
5480 /* word-granular cache in microblaze */
5481 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5482 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5483
5484 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5485
5486 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5487 index 01cc6ba..bcb7a5d 100644
5488 --- a/arch/mips/include/asm/atomic.h
5489 +++ b/arch/mips/include/asm/atomic.h
5490 @@ -21,6 +21,10 @@
5491 #include <asm/cmpxchg.h>
5492 #include <asm/war.h>
5493
5494 +#ifdef CONFIG_GENERIC_ATOMIC64
5495 +#include <asm-generic/atomic64.h>
5496 +#endif
5497 +
5498 #define ATOMIC_INIT(i) { (i) }
5499
5500 /*
5501 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5502 */
5503 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5504
5505 +#define atomic64_read_unchecked(v) atomic64_read(v)
5506 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5507 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5508 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5509 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5510 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5511 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5512 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5513 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5514 +
5515 #endif /* CONFIG_64BIT */
5516
5517 /*
5518 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5519 index b4db69f..8f3b093 100644
5520 --- a/arch/mips/include/asm/cache.h
5521 +++ b/arch/mips/include/asm/cache.h
5522 @@ -9,10 +9,11 @@
5523 #ifndef _ASM_CACHE_H
5524 #define _ASM_CACHE_H
5525
5526 +#include <linux/const.h>
5527 #include <kmalloc.h>
5528
5529 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5530 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5531 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5532
5533 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5534 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5535 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5536 index 455c0ac..ad65fbe 100644
5537 --- a/arch/mips/include/asm/elf.h
5538 +++ b/arch/mips/include/asm/elf.h
5539 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5540 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5541 #endif
5542
5543 +#ifdef CONFIG_PAX_ASLR
5544 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5545 +
5546 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5547 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5548 +#endif
5549 +
5550 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5551 struct linux_binprm;
5552 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5553 int uses_interp);
5554
5555 -struct mm_struct;
5556 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5557 -#define arch_randomize_brk arch_randomize_brk
5558 -
5559 #endif /* _ASM_ELF_H */
5560 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5561 index c1f6afa..38cc6e9 100644
5562 --- a/arch/mips/include/asm/exec.h
5563 +++ b/arch/mips/include/asm/exec.h
5564 @@ -12,6 +12,6 @@
5565 #ifndef _ASM_EXEC_H
5566 #define _ASM_EXEC_H
5567
5568 -extern unsigned long arch_align_stack(unsigned long sp);
5569 +#define arch_align_stack(x) ((x) & ~0xfUL)
5570
5571 #endif /* _ASM_EXEC_H */
5572 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5573 index 21bff32..9f0c3b8 100644
5574 --- a/arch/mips/include/asm/page.h
5575 +++ b/arch/mips/include/asm/page.h
5576 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5577 #ifdef CONFIG_CPU_MIPS32
5578 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5579 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5580 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5581 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5582 #else
5583 typedef struct { unsigned long long pte; } pte_t;
5584 #define pte_val(x) ((x).pte)
5585 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5586 index 881d18b..cea38bc 100644
5587 --- a/arch/mips/include/asm/pgalloc.h
5588 +++ b/arch/mips/include/asm/pgalloc.h
5589 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5590 {
5591 set_pud(pud, __pud((unsigned long)pmd));
5592 }
5593 +
5594 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5595 +{
5596 + pud_populate(mm, pud, pmd);
5597 +}
5598 #endif
5599
5600 /*
5601 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5602 index b2050b9..d71bb1b 100644
5603 --- a/arch/mips/include/asm/thread_info.h
5604 +++ b/arch/mips/include/asm/thread_info.h
5605 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5606 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5607 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5608 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5609 +/* li takes a 32bit immediate */
5610 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5611 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5612
5613 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5614 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5615 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5616 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5617 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5618 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5619 +
5620 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5621
5622 /* work to do in syscall_trace_leave() */
5623 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5624 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5625
5626 /* work to do on interrupt/exception return */
5627 #define _TIF_WORK_MASK \
5628 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5629 /* work to do on any return to u-space */
5630 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5631 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5632
5633 #endif /* __KERNEL__ */
5634
5635 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5636 index 9fdd8bc..4bd7f1a 100644
5637 --- a/arch/mips/kernel/binfmt_elfn32.c
5638 +++ b/arch/mips/kernel/binfmt_elfn32.c
5639 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5640 #undef ELF_ET_DYN_BASE
5641 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5642
5643 +#ifdef CONFIG_PAX_ASLR
5644 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5645 +
5646 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5647 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5648 +#endif
5649 +
5650 #include <asm/processor.h>
5651 #include <linux/module.h>
5652 #include <linux/elfcore.h>
5653 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5654 index ff44823..97f8906 100644
5655 --- a/arch/mips/kernel/binfmt_elfo32.c
5656 +++ b/arch/mips/kernel/binfmt_elfo32.c
5657 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5658 #undef ELF_ET_DYN_BASE
5659 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5660
5661 +#ifdef CONFIG_PAX_ASLR
5662 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5663 +
5664 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5665 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5666 +#endif
5667 +
5668 #include <asm/processor.h>
5669
5670 /*
5671 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5672 index a11c6f9..be5e164 100644
5673 --- a/arch/mips/kernel/process.c
5674 +++ b/arch/mips/kernel/process.c
5675 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5676 out:
5677 return pc;
5678 }
5679 -
5680 -/*
5681 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5682 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5683 - */
5684 -unsigned long arch_align_stack(unsigned long sp)
5685 -{
5686 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5687 - sp -= get_random_int() & ~PAGE_MASK;
5688 -
5689 - return sp & ALMASK;
5690 -}
5691 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5692 index 4812c6d..2069554 100644
5693 --- a/arch/mips/kernel/ptrace.c
5694 +++ b/arch/mips/kernel/ptrace.c
5695 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5696 return arch;
5697 }
5698
5699 +#ifdef CONFIG_GRKERNSEC_SETXID
5700 +extern void gr_delayed_cred_worker(void);
5701 +#endif
5702 +
5703 /*
5704 * Notification of system call entry/exit
5705 * - triggered by current->work.syscall_trace
5706 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5707 /* do the secure computing check first */
5708 secure_computing_strict(regs->regs[2]);
5709
5710 +#ifdef CONFIG_GRKERNSEC_SETXID
5711 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5712 + gr_delayed_cred_worker();
5713 +#endif
5714 +
5715 if (!(current->ptrace & PT_PTRACED))
5716 goto out;
5717
5718 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5719 index d20a4bc..7096ae5 100644
5720 --- a/arch/mips/kernel/scall32-o32.S
5721 +++ b/arch/mips/kernel/scall32-o32.S
5722 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5723
5724 stack_done:
5725 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5726 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5727 + li t1, _TIF_SYSCALL_WORK
5728 and t0, t1
5729 bnez t0, syscall_trace_entry # -> yes
5730
5731 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5732 index b64f642..0fe6eab 100644
5733 --- a/arch/mips/kernel/scall64-64.S
5734 +++ b/arch/mips/kernel/scall64-64.S
5735 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5736
5737 sd a3, PT_R26(sp) # save a3 for syscall restarting
5738
5739 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5740 + li t1, _TIF_SYSCALL_WORK
5741 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5742 and t0, t1, t0
5743 bnez t0, syscall_trace_entry
5744 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5745 index c29ac19..c592d05 100644
5746 --- a/arch/mips/kernel/scall64-n32.S
5747 +++ b/arch/mips/kernel/scall64-n32.S
5748 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5749
5750 sd a3, PT_R26(sp) # save a3 for syscall restarting
5751
5752 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5753 + li t1, _TIF_SYSCALL_WORK
5754 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5755 and t0, t1, t0
5756 bnez t0, n32_syscall_trace_entry
5757 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5758 index cf3e75e..72e93fe 100644
5759 --- a/arch/mips/kernel/scall64-o32.S
5760 +++ b/arch/mips/kernel/scall64-o32.S
5761 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5762 PTR 4b, bad_stack
5763 .previous
5764
5765 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5766 + li t1, _TIF_SYSCALL_WORK
5767 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5768 and t0, t1, t0
5769 bnez t0, trace_a_syscall
5770 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5771 index ddcec1e..c7f983e 100644
5772 --- a/arch/mips/mm/fault.c
5773 +++ b/arch/mips/mm/fault.c
5774 @@ -27,6 +27,23 @@
5775 #include <asm/highmem.h> /* For VMALLOC_END */
5776 #include <linux/kdebug.h>
5777
5778 +#ifdef CONFIG_PAX_PAGEEXEC
5779 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5780 +{
5781 + unsigned long i;
5782 +
5783 + printk(KERN_ERR "PAX: bytes at PC: ");
5784 + for (i = 0; i < 5; i++) {
5785 + unsigned int c;
5786 + if (get_user(c, (unsigned int *)pc+i))
5787 + printk(KERN_CONT "???????? ");
5788 + else
5789 + printk(KERN_CONT "%08x ", c);
5790 + }
5791 + printk("\n");
5792 +}
5793 +#endif
5794 +
5795 /*
5796 * This routine handles page faults. It determines the address,
5797 * and the problem, and then passes it off to one of the appropriate
5798 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5799 index 7e5fe27..479a219 100644
5800 --- a/arch/mips/mm/mmap.c
5801 +++ b/arch/mips/mm/mmap.c
5802 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5803 struct vm_area_struct *vma;
5804 unsigned long addr = addr0;
5805 int do_color_align;
5806 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5807 struct vm_unmapped_area_info info;
5808
5809 if (unlikely(len > TASK_SIZE))
5810 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5811 do_color_align = 1;
5812
5813 /* requesting a specific address */
5814 +
5815 +#ifdef CONFIG_PAX_RANDMMAP
5816 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5817 +#endif
5818 +
5819 if (addr) {
5820 if (do_color_align)
5821 addr = COLOUR_ALIGN(addr, pgoff);
5822 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5823 addr = PAGE_ALIGN(addr);
5824
5825 vma = find_vma(mm, addr);
5826 - if (TASK_SIZE - len >= addr &&
5827 - (!vma || addr + len <= vma->vm_start))
5828 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5829 return addr;
5830 }
5831
5832 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5833 {
5834 unsigned long random_factor = 0UL;
5835
5836 +#ifdef CONFIG_PAX_RANDMMAP
5837 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5838 +#endif
5839 +
5840 if (current->flags & PF_RANDOMIZE) {
5841 random_factor = get_random_int();
5842 random_factor = random_factor << PAGE_SHIFT;
5843 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5844
5845 if (mmap_is_legacy()) {
5846 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5847 +
5848 +#ifdef CONFIG_PAX_RANDMMAP
5849 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5850 + mm->mmap_base += mm->delta_mmap;
5851 +#endif
5852 +
5853 mm->get_unmapped_area = arch_get_unmapped_area;
5854 mm->unmap_area = arch_unmap_area;
5855 } else {
5856 mm->mmap_base = mmap_base(random_factor);
5857 +
5858 +#ifdef CONFIG_PAX_RANDMMAP
5859 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5860 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5861 +#endif
5862 +
5863 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5864 mm->unmap_area = arch_unmap_area_topdown;
5865 }
5866 }
5867
5868 -static inline unsigned long brk_rnd(void)
5869 -{
5870 - unsigned long rnd = get_random_int();
5871 -
5872 - rnd = rnd << PAGE_SHIFT;
5873 - /* 8MB for 32bit, 256MB for 64bit */
5874 - if (TASK_IS_32BIT_ADDR)
5875 - rnd = rnd & 0x7ffffful;
5876 - else
5877 - rnd = rnd & 0xffffffful;
5878 -
5879 - return rnd;
5880 -}
5881 -
5882 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5883 -{
5884 - unsigned long base = mm->brk;
5885 - unsigned long ret;
5886 -
5887 - ret = PAGE_ALIGN(base + brk_rnd());
5888 -
5889 - if (ret < mm->brk)
5890 - return mm->brk;
5891 -
5892 - return ret;
5893 -}
5894 -
5895 int __virt_addr_valid(const volatile void *kaddr)
5896 {
5897 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5898 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5899 index 967d144..db12197 100644
5900 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5901 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5902 @@ -11,12 +11,14 @@
5903 #ifndef _ASM_PROC_CACHE_H
5904 #define _ASM_PROC_CACHE_H
5905
5906 +#include <linux/const.h>
5907 +
5908 /* L1 cache */
5909
5910 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5911 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5912 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5913 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5914 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5915 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5916
5917 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5918 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5919 index bcb5df2..84fabd2 100644
5920 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5921 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5922 @@ -16,13 +16,15 @@
5923 #ifndef _ASM_PROC_CACHE_H
5924 #define _ASM_PROC_CACHE_H
5925
5926 +#include <linux/const.h>
5927 +
5928 /*
5929 * L1 cache
5930 */
5931 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5932 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5933 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5934 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5935 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5936 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5937
5938 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5939 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5940 index 4ce7a01..449202a 100644
5941 --- a/arch/openrisc/include/asm/cache.h
5942 +++ b/arch/openrisc/include/asm/cache.h
5943 @@ -19,11 +19,13 @@
5944 #ifndef __ASM_OPENRISC_CACHE_H
5945 #define __ASM_OPENRISC_CACHE_H
5946
5947 +#include <linux/const.h>
5948 +
5949 /* FIXME: How can we replace these with values from the CPU...
5950 * they shouldn't be hard-coded!
5951 */
5952
5953 -#define L1_CACHE_BYTES 16
5954 #define L1_CACHE_SHIFT 4
5955 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5956
5957 #endif /* __ASM_OPENRISC_CACHE_H */
5958 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5959 index af9cf30..2aae9b2 100644
5960 --- a/arch/parisc/include/asm/atomic.h
5961 +++ b/arch/parisc/include/asm/atomic.h
5962 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5963
5964 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5965
5966 +#define atomic64_read_unchecked(v) atomic64_read(v)
5967 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5968 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5969 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5970 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5971 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5972 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5973 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5974 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5975 +
5976 #endif /* !CONFIG_64BIT */
5977
5978
5979 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5980 index 47f11c7..3420df2 100644
5981 --- a/arch/parisc/include/asm/cache.h
5982 +++ b/arch/parisc/include/asm/cache.h
5983 @@ -5,6 +5,7 @@
5984 #ifndef __ARCH_PARISC_CACHE_H
5985 #define __ARCH_PARISC_CACHE_H
5986
5987 +#include <linux/const.h>
5988
5989 /*
5990 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5991 @@ -15,13 +16,13 @@
5992 * just ruin performance.
5993 */
5994 #ifdef CONFIG_PA20
5995 -#define L1_CACHE_BYTES 64
5996 #define L1_CACHE_SHIFT 6
5997 #else
5998 -#define L1_CACHE_BYTES 32
5999 #define L1_CACHE_SHIFT 5
6000 #endif
6001
6002 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6003 +
6004 #ifndef __ASSEMBLY__
6005
6006 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6007 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
6008 index 19f6cb1..6c78cf2 100644
6009 --- a/arch/parisc/include/asm/elf.h
6010 +++ b/arch/parisc/include/asm/elf.h
6011 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
6012
6013 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
6014
6015 +#ifdef CONFIG_PAX_ASLR
6016 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
6017 +
6018 +#define PAX_DELTA_MMAP_LEN 16
6019 +#define PAX_DELTA_STACK_LEN 16
6020 +#endif
6021 +
6022 /* This yields a mask that user programs can use to figure out what
6023 instruction set this CPU supports. This could be done in user space,
6024 but it's not easy, and we've already done it here. */
6025 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
6026 index fc987a1..6e068ef 100644
6027 --- a/arch/parisc/include/asm/pgalloc.h
6028 +++ b/arch/parisc/include/asm/pgalloc.h
6029 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6030 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
6031 }
6032
6033 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6034 +{
6035 + pgd_populate(mm, pgd, pmd);
6036 +}
6037 +
6038 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
6039 {
6040 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
6041 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
6042 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
6043 #define pmd_free(mm, x) do { } while (0)
6044 #define pgd_populate(mm, pmd, pte) BUG()
6045 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
6046
6047 #endif
6048
6049 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
6050 index 7df49fa..a3eb445 100644
6051 --- a/arch/parisc/include/asm/pgtable.h
6052 +++ b/arch/parisc/include/asm/pgtable.h
6053 @@ -16,6 +16,8 @@
6054 #include <asm/processor.h>
6055 #include <asm/cache.h>
6056
6057 +extern spinlock_t pa_dbit_lock;
6058 +
6059 /*
6060 * kern_addr_valid(ADDR) tests if ADDR is pointing to valid kernel
6061 * memory. For the return value to be meaningful, ADDR must be >=
6062 @@ -44,8 +46,11 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6063
6064 #define set_pte_at(mm, addr, ptep, pteval) \
6065 do { \
6066 + unsigned long flags; \
6067 + spin_lock_irqsave(&pa_dbit_lock, flags); \
6068 set_pte(ptep, pteval); \
6069 purge_tlb_entries(mm, addr); \
6070 + spin_unlock_irqrestore(&pa_dbit_lock, flags); \
6071 } while (0)
6072
6073 #endif /* !__ASSEMBLY__ */
6074 @@ -218,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6075 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6076 #define PAGE_COPY PAGE_EXECREAD
6077 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6078 +
6079 +#ifdef CONFIG_PAX_PAGEEXEC
6080 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6081 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6082 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6083 +#else
6084 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6085 +# define PAGE_COPY_NOEXEC PAGE_COPY
6086 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
6087 +#endif
6088 +
6089 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
6090 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
6091 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
6092 @@ -435,48 +451,46 @@ extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *);
6093
6094 static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
6095 {
6096 -#ifdef CONFIG_SMP
6097 + pte_t pte;
6098 + unsigned long flags;
6099 +
6100 if (!pte_young(*ptep))
6101 return 0;
6102 - return test_and_clear_bit(xlate_pabit(_PAGE_ACCESSED_BIT), &pte_val(*ptep));
6103 -#else
6104 - pte_t pte = *ptep;
6105 - if (!pte_young(pte))
6106 +
6107 + spin_lock_irqsave(&pa_dbit_lock, flags);
6108 + pte = *ptep;
6109 + if (!pte_young(pte)) {
6110 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6111 return 0;
6112 - set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
6113 + }
6114 + set_pte(ptep, pte_mkold(pte));
6115 + purge_tlb_entries(vma->vm_mm, addr);
6116 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6117 return 1;
6118 -#endif
6119 }
6120
6121 -extern spinlock_t pa_dbit_lock;
6122 -
6123 struct mm_struct;
6124 static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
6125 {
6126 pte_t old_pte;
6127 + unsigned long flags;
6128
6129 - spin_lock(&pa_dbit_lock);
6130 + spin_lock_irqsave(&pa_dbit_lock, flags);
6131 old_pte = *ptep;
6132 pte_clear(mm,addr,ptep);
6133 - spin_unlock(&pa_dbit_lock);
6134 + purge_tlb_entries(mm, addr);
6135 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6136
6137 return old_pte;
6138 }
6139
6140 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
6141 {
6142 -#ifdef CONFIG_SMP
6143 - unsigned long new, old;
6144 -
6145 - do {
6146 - old = pte_val(*ptep);
6147 - new = pte_val(pte_wrprotect(__pte (old)));
6148 - } while (cmpxchg((unsigned long *) ptep, old, new) != old);
6149 + unsigned long flags;
6150 + spin_lock_irqsave(&pa_dbit_lock, flags);
6151 + set_pte(ptep, pte_wrprotect(*ptep));
6152 purge_tlb_entries(mm, addr);
6153 -#else
6154 - pte_t old_pte = *ptep;
6155 - set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
6156 -#endif
6157 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6158 }
6159
6160 #define pte_same(A,B) (pte_val(A) == pte_val(B))
6161 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
6162 index 4ba2c93..f5e3974 100644
6163 --- a/arch/parisc/include/asm/uaccess.h
6164 +++ b/arch/parisc/include/asm/uaccess.h
6165 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
6166 const void __user *from,
6167 unsigned long n)
6168 {
6169 - int sz = __compiletime_object_size(to);
6170 + size_t sz = __compiletime_object_size(to);
6171 int ret = -EFAULT;
6172
6173 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
6174 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
6175 ret = __copy_from_user(to, from, n);
6176 else
6177 copy_from_user_overflow();
6178 diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
6179 index b89a85a..a9891fa 100644
6180 --- a/arch/parisc/kernel/cache.c
6181 +++ b/arch/parisc/kernel/cache.c
6182 @@ -426,14 +426,11 @@ void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
6183 /* Note: purge_tlb_entries can be called at startup with
6184 no context. */
6185
6186 - /* Disable preemption while we play with %sr1. */
6187 - preempt_disable();
6188 + purge_tlb_start(flags);
6189 mtsp(mm->context, 1);
6190 - purge_tlb_start(flags);
6191 pdtlb(addr);
6192 pitlb(addr);
6193 purge_tlb_end(flags);
6194 - preempt_enable();
6195 }
6196 EXPORT_SYMBOL(purge_tlb_entries);
6197
6198 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
6199 index 2a625fb..9908930 100644
6200 --- a/arch/parisc/kernel/module.c
6201 +++ b/arch/parisc/kernel/module.c
6202 @@ -98,16 +98,38 @@
6203
6204 /* three functions to determine where in the module core
6205 * or init pieces the location is */
6206 +static inline int in_init_rx(struct module *me, void *loc)
6207 +{
6208 + return (loc >= me->module_init_rx &&
6209 + loc < (me->module_init_rx + me->init_size_rx));
6210 +}
6211 +
6212 +static inline int in_init_rw(struct module *me, void *loc)
6213 +{
6214 + return (loc >= me->module_init_rw &&
6215 + loc < (me->module_init_rw + me->init_size_rw));
6216 +}
6217 +
6218 static inline int in_init(struct module *me, void *loc)
6219 {
6220 - return (loc >= me->module_init &&
6221 - loc <= (me->module_init + me->init_size));
6222 + return in_init_rx(me, loc) || in_init_rw(me, loc);
6223 +}
6224 +
6225 +static inline int in_core_rx(struct module *me, void *loc)
6226 +{
6227 + return (loc >= me->module_core_rx &&
6228 + loc < (me->module_core_rx + me->core_size_rx));
6229 +}
6230 +
6231 +static inline int in_core_rw(struct module *me, void *loc)
6232 +{
6233 + return (loc >= me->module_core_rw &&
6234 + loc < (me->module_core_rw + me->core_size_rw));
6235 }
6236
6237 static inline int in_core(struct module *me, void *loc)
6238 {
6239 - return (loc >= me->module_core &&
6240 - loc <= (me->module_core + me->core_size));
6241 + return in_core_rx(me, loc) || in_core_rw(me, loc);
6242 }
6243
6244 static inline int in_local(struct module *me, void *loc)
6245 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
6246 }
6247
6248 /* align things a bit */
6249 - me->core_size = ALIGN(me->core_size, 16);
6250 - me->arch.got_offset = me->core_size;
6251 - me->core_size += gots * sizeof(struct got_entry);
6252 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6253 + me->arch.got_offset = me->core_size_rw;
6254 + me->core_size_rw += gots * sizeof(struct got_entry);
6255
6256 - me->core_size = ALIGN(me->core_size, 16);
6257 - me->arch.fdesc_offset = me->core_size;
6258 - me->core_size += fdescs * sizeof(Elf_Fdesc);
6259 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6260 + me->arch.fdesc_offset = me->core_size_rw;
6261 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
6262
6263 me->arch.got_max = gots;
6264 me->arch.fdesc_max = fdescs;
6265 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6266
6267 BUG_ON(value == 0);
6268
6269 - got = me->module_core + me->arch.got_offset;
6270 + got = me->module_core_rw + me->arch.got_offset;
6271 for (i = 0; got[i].addr; i++)
6272 if (got[i].addr == value)
6273 goto out;
6274 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6275 #ifdef CONFIG_64BIT
6276 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6277 {
6278 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
6279 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
6280
6281 if (!value) {
6282 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
6283 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6284
6285 /* Create new one */
6286 fdesc->addr = value;
6287 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6288 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6289 return (Elf_Addr)fdesc;
6290 }
6291 #endif /* CONFIG_64BIT */
6292 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
6293
6294 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
6295 end = table + sechdrs[me->arch.unwind_section].sh_size;
6296 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6297 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6298
6299 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
6300 me->arch.unwind_section, table, end, gp);
6301 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
6302 index f76c108..92bad82 100644
6303 --- a/arch/parisc/kernel/sys_parisc.c
6304 +++ b/arch/parisc/kernel/sys_parisc.c
6305 @@ -33,9 +33,11 @@
6306 #include <linux/utsname.h>
6307 #include <linux/personality.h>
6308
6309 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6310 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
6311 + unsigned long flags)
6312 {
6313 struct vm_area_struct *vma;
6314 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6315
6316 addr = PAGE_ALIGN(addr);
6317
6318 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6319 /* At this point: (!vma || addr < vma->vm_end). */
6320 if (TASK_SIZE - len < addr)
6321 return -ENOMEM;
6322 - if (!vma || addr + len <= vma->vm_start)
6323 + if (check_heap_stack_gap(vma, addr, len, offset))
6324 return addr;
6325 addr = vma->vm_end;
6326 }
6327 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
6328 return offset & 0x3FF000;
6329 }
6330
6331 -static unsigned long get_shared_area(struct address_space *mapping,
6332 - unsigned long addr, unsigned long len, unsigned long pgoff)
6333 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
6334 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
6335 {
6336 struct vm_area_struct *vma;
6337 int offset = mapping ? get_offset(mapping) : 0;
6338 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6339
6340 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
6341
6342 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6343 /* At this point: (!vma || addr < vma->vm_end). */
6344 if (TASK_SIZE - len < addr)
6345 return -ENOMEM;
6346 - if (!vma || addr + len <= vma->vm_start)
6347 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
6348 return addr;
6349 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
6350 if (addr < vma->vm_end) /* handle wraparound */
6351 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6352 if (flags & MAP_FIXED)
6353 return addr;
6354 if (!addr)
6355 - addr = TASK_UNMAPPED_BASE;
6356 + addr = current->mm->mmap_base;
6357
6358 if (filp) {
6359 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6360 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6361 } else if(flags & MAP_SHARED) {
6362 - addr = get_shared_area(NULL, addr, len, pgoff);
6363 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6364 } else {
6365 - addr = get_unshared_area(addr, len);
6366 + addr = get_unshared_area(filp, addr, len, flags);
6367 }
6368 return addr;
6369 }
6370 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6371 index 45ba99f..8e22c33 100644
6372 --- a/arch/parisc/kernel/traps.c
6373 +++ b/arch/parisc/kernel/traps.c
6374 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6375
6376 down_read(&current->mm->mmap_sem);
6377 vma = find_vma(current->mm,regs->iaoq[0]);
6378 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6379 - && (vma->vm_flags & VM_EXEC)) {
6380 -
6381 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6382 fault_address = regs->iaoq[0];
6383 fault_space = regs->iasq[0];
6384
6385 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6386 index 18162ce..94de376 100644
6387 --- a/arch/parisc/mm/fault.c
6388 +++ b/arch/parisc/mm/fault.c
6389 @@ -15,6 +15,7 @@
6390 #include <linux/sched.h>
6391 #include <linux/interrupt.h>
6392 #include <linux/module.h>
6393 +#include <linux/unistd.h>
6394
6395 #include <asm/uaccess.h>
6396 #include <asm/traps.h>
6397 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6398 static unsigned long
6399 parisc_acctyp(unsigned long code, unsigned int inst)
6400 {
6401 - if (code == 6 || code == 16)
6402 + if (code == 6 || code == 7 || code == 16)
6403 return VM_EXEC;
6404
6405 switch (inst & 0xf0000000) {
6406 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6407 }
6408 #endif
6409
6410 +#ifdef CONFIG_PAX_PAGEEXEC
6411 +/*
6412 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6413 + *
6414 + * returns 1 when task should be killed
6415 + * 2 when rt_sigreturn trampoline was detected
6416 + * 3 when unpatched PLT trampoline was detected
6417 + */
6418 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6419 +{
6420 +
6421 +#ifdef CONFIG_PAX_EMUPLT
6422 + int err;
6423 +
6424 + do { /* PaX: unpatched PLT emulation */
6425 + unsigned int bl, depwi;
6426 +
6427 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6428 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6429 +
6430 + if (err)
6431 + break;
6432 +
6433 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6434 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6435 +
6436 + err = get_user(ldw, (unsigned int *)addr);
6437 + err |= get_user(bv, (unsigned int *)(addr+4));
6438 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6439 +
6440 + if (err)
6441 + break;
6442 +
6443 + if (ldw == 0x0E801096U &&
6444 + bv == 0xEAC0C000U &&
6445 + ldw2 == 0x0E881095U)
6446 + {
6447 + unsigned int resolver, map;
6448 +
6449 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6450 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6451 + if (err)
6452 + break;
6453 +
6454 + regs->gr[20] = instruction_pointer(regs)+8;
6455 + regs->gr[21] = map;
6456 + regs->gr[22] = resolver;
6457 + regs->iaoq[0] = resolver | 3UL;
6458 + regs->iaoq[1] = regs->iaoq[0] + 4;
6459 + return 3;
6460 + }
6461 + }
6462 + } while (0);
6463 +#endif
6464 +
6465 +#ifdef CONFIG_PAX_EMUTRAMP
6466 +
6467 +#ifndef CONFIG_PAX_EMUSIGRT
6468 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6469 + return 1;
6470 +#endif
6471 +
6472 + do { /* PaX: rt_sigreturn emulation */
6473 + unsigned int ldi1, ldi2, bel, nop;
6474 +
6475 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6476 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6477 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6478 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6479 +
6480 + if (err)
6481 + break;
6482 +
6483 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6484 + ldi2 == 0x3414015AU &&
6485 + bel == 0xE4008200U &&
6486 + nop == 0x08000240U)
6487 + {
6488 + regs->gr[25] = (ldi1 & 2) >> 1;
6489 + regs->gr[20] = __NR_rt_sigreturn;
6490 + regs->gr[31] = regs->iaoq[1] + 16;
6491 + regs->sr[0] = regs->iasq[1];
6492 + regs->iaoq[0] = 0x100UL;
6493 + regs->iaoq[1] = regs->iaoq[0] + 4;
6494 + regs->iasq[0] = regs->sr[2];
6495 + regs->iasq[1] = regs->sr[2];
6496 + return 2;
6497 + }
6498 + } while (0);
6499 +#endif
6500 +
6501 + return 1;
6502 +}
6503 +
6504 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6505 +{
6506 + unsigned long i;
6507 +
6508 + printk(KERN_ERR "PAX: bytes at PC: ");
6509 + for (i = 0; i < 5; i++) {
6510 + unsigned int c;
6511 + if (get_user(c, (unsigned int *)pc+i))
6512 + printk(KERN_CONT "???????? ");
6513 + else
6514 + printk(KERN_CONT "%08x ", c);
6515 + }
6516 + printk("\n");
6517 +}
6518 +#endif
6519 +
6520 int fixup_exception(struct pt_regs *regs)
6521 {
6522 const struct exception_table_entry *fix;
6523 @@ -192,8 +303,33 @@ good_area:
6524
6525 acc_type = parisc_acctyp(code,regs->iir);
6526
6527 - if ((vma->vm_flags & acc_type) != acc_type)
6528 + if ((vma->vm_flags & acc_type) != acc_type) {
6529 +
6530 +#ifdef CONFIG_PAX_PAGEEXEC
6531 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6532 + (address & ~3UL) == instruction_pointer(regs))
6533 + {
6534 + up_read(&mm->mmap_sem);
6535 + switch (pax_handle_fetch_fault(regs)) {
6536 +
6537 +#ifdef CONFIG_PAX_EMUPLT
6538 + case 3:
6539 + return;
6540 +#endif
6541 +
6542 +#ifdef CONFIG_PAX_EMUTRAMP
6543 + case 2:
6544 + return;
6545 +#endif
6546 +
6547 + }
6548 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6549 + do_group_exit(SIGKILL);
6550 + }
6551 +#endif
6552 +
6553 goto bad_area;
6554 + }
6555
6556 /*
6557 * If for any reason at all we couldn't handle the fault, make
6558 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6559 index e3b1d41..8e81edf 100644
6560 --- a/arch/powerpc/include/asm/atomic.h
6561 +++ b/arch/powerpc/include/asm/atomic.h
6562 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6563 return t1;
6564 }
6565
6566 +#define atomic64_read_unchecked(v) atomic64_read(v)
6567 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6568 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6569 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6570 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6571 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6572 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6573 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6574 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6575 +
6576 #endif /* __powerpc64__ */
6577
6578 #endif /* __KERNEL__ */
6579 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6580 index 9e495c9..b6878e5 100644
6581 --- a/arch/powerpc/include/asm/cache.h
6582 +++ b/arch/powerpc/include/asm/cache.h
6583 @@ -3,6 +3,7 @@
6584
6585 #ifdef __KERNEL__
6586
6587 +#include <linux/const.h>
6588
6589 /* bytes per L1 cache line */
6590 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6591 @@ -22,7 +23,7 @@
6592 #define L1_CACHE_SHIFT 7
6593 #endif
6594
6595 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6596 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6597
6598 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6599
6600 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6601 index 6abf0a1..459d0f1 100644
6602 --- a/arch/powerpc/include/asm/elf.h
6603 +++ b/arch/powerpc/include/asm/elf.h
6604 @@ -28,8 +28,19 @@
6605 the loader. We need to make sure that it is out of the way of the program
6606 that it will "exec", and that there is sufficient room for the brk. */
6607
6608 -extern unsigned long randomize_et_dyn(unsigned long base);
6609 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6610 +#define ELF_ET_DYN_BASE (0x20000000)
6611 +
6612 +#ifdef CONFIG_PAX_ASLR
6613 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6614 +
6615 +#ifdef __powerpc64__
6616 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6617 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6618 +#else
6619 +#define PAX_DELTA_MMAP_LEN 15
6620 +#define PAX_DELTA_STACK_LEN 15
6621 +#endif
6622 +#endif
6623
6624 /*
6625 * Our registers are always unsigned longs, whether we're a 32 bit
6626 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6627 (0x7ff >> (PAGE_SHIFT - 12)) : \
6628 (0x3ffff >> (PAGE_SHIFT - 12)))
6629
6630 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6631 -#define arch_randomize_brk arch_randomize_brk
6632 -
6633 -
6634 #ifdef CONFIG_SPU_BASE
6635 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6636 #define NT_SPU 1
6637 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6638 index 8196e9c..d83a9f3 100644
6639 --- a/arch/powerpc/include/asm/exec.h
6640 +++ b/arch/powerpc/include/asm/exec.h
6641 @@ -4,6 +4,6 @@
6642 #ifndef _ASM_POWERPC_EXEC_H
6643 #define _ASM_POWERPC_EXEC_H
6644
6645 -extern unsigned long arch_align_stack(unsigned long sp);
6646 +#define arch_align_stack(x) ((x) & ~0xfUL)
6647
6648 #endif /* _ASM_POWERPC_EXEC_H */
6649 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6650 index 5acabbd..7ea14fa 100644
6651 --- a/arch/powerpc/include/asm/kmap_types.h
6652 +++ b/arch/powerpc/include/asm/kmap_types.h
6653 @@ -10,7 +10,7 @@
6654 * 2 of the License, or (at your option) any later version.
6655 */
6656
6657 -#define KM_TYPE_NR 16
6658 +#define KM_TYPE_NR 17
6659
6660 #endif /* __KERNEL__ */
6661 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6662 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6663 index 8565c25..2865190 100644
6664 --- a/arch/powerpc/include/asm/mman.h
6665 +++ b/arch/powerpc/include/asm/mman.h
6666 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6667 }
6668 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6669
6670 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6671 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6672 {
6673 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6674 }
6675 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6676 index f072e97..b436dee 100644
6677 --- a/arch/powerpc/include/asm/page.h
6678 +++ b/arch/powerpc/include/asm/page.h
6679 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6680 * and needs to be executable. This means the whole heap ends
6681 * up being executable.
6682 */
6683 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6684 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6685 +#define VM_DATA_DEFAULT_FLAGS32 \
6686 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6687 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6688
6689 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6690 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6691 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6692 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6693 #endif
6694
6695 +#define ktla_ktva(addr) (addr)
6696 +#define ktva_ktla(addr) (addr)
6697 +
6698 /*
6699 * Use the top bit of the higher-level page table entries to indicate whether
6700 * the entries we point to contain hugepages. This works because we know that
6701 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6702 index cd915d6..c10cee8 100644
6703 --- a/arch/powerpc/include/asm/page_64.h
6704 +++ b/arch/powerpc/include/asm/page_64.h
6705 @@ -154,15 +154,18 @@ do { \
6706 * stack by default, so in the absence of a PT_GNU_STACK program header
6707 * we turn execute permission off.
6708 */
6709 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6710 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6711 +#define VM_STACK_DEFAULT_FLAGS32 \
6712 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6713 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6714
6715 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6716 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6717
6718 +#ifndef CONFIG_PAX_PAGEEXEC
6719 #define VM_STACK_DEFAULT_FLAGS \
6720 (is_32bit_task() ? \
6721 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6722 +#endif
6723
6724 #include <asm-generic/getorder.h>
6725
6726 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6727 index 292725c..f87ae14 100644
6728 --- a/arch/powerpc/include/asm/pgalloc-64.h
6729 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6730 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6731 #ifndef CONFIG_PPC_64K_PAGES
6732
6733 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6734 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6735
6736 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6737 {
6738 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6739 pud_set(pud, (unsigned long)pmd);
6740 }
6741
6742 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6743 +{
6744 + pud_populate(mm, pud, pmd);
6745 +}
6746 +
6747 #define pmd_populate(mm, pmd, pte_page) \
6748 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6749 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6750 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6751 #else /* CONFIG_PPC_64K_PAGES */
6752
6753 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6754 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6755
6756 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6757 pte_t *pte)
6758 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6759 index a9cbd3b..3b67efa 100644
6760 --- a/arch/powerpc/include/asm/pgtable.h
6761 +++ b/arch/powerpc/include/asm/pgtable.h
6762 @@ -2,6 +2,7 @@
6763 #define _ASM_POWERPC_PGTABLE_H
6764 #ifdef __KERNEL__
6765
6766 +#include <linux/const.h>
6767 #ifndef __ASSEMBLY__
6768 #include <asm/processor.h> /* For TASK_SIZE */
6769 #include <asm/mmu.h>
6770 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6771 index 4aad413..85d86bf 100644
6772 --- a/arch/powerpc/include/asm/pte-hash32.h
6773 +++ b/arch/powerpc/include/asm/pte-hash32.h
6774 @@ -21,6 +21,7 @@
6775 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6776 #define _PAGE_USER 0x004 /* usermode access allowed */
6777 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6778 +#define _PAGE_EXEC _PAGE_GUARDED
6779 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6780 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6781 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6782 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6783 index 3d5c9dc..62f8414 100644
6784 --- a/arch/powerpc/include/asm/reg.h
6785 +++ b/arch/powerpc/include/asm/reg.h
6786 @@ -215,6 +215,7 @@
6787 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6788 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6789 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6790 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6791 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6792 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6793 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6794 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6795 index 195ce2a..ab5c614 100644
6796 --- a/arch/powerpc/include/asm/smp.h
6797 +++ b/arch/powerpc/include/asm/smp.h
6798 @@ -50,7 +50,7 @@ struct smp_ops_t {
6799 int (*cpu_disable)(void);
6800 void (*cpu_die)(unsigned int nr);
6801 int (*cpu_bootable)(unsigned int nr);
6802 -};
6803 +} __no_const;
6804
6805 extern void smp_send_debugger_break(void);
6806 extern void start_secondary_resume(void);
6807 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6808 index 406b7b9..af63426 100644
6809 --- a/arch/powerpc/include/asm/thread_info.h
6810 +++ b/arch/powerpc/include/asm/thread_info.h
6811 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6812 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6813 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6814 #define TIF_SINGLESTEP 8 /* singlestepping active */
6815 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6816 #define TIF_SECCOMP 10 /* secure computing */
6817 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6818 #define TIF_NOERROR 12 /* Force successful syscall return */
6819 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6820 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6821 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6822 for stack store? */
6823 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6824 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6825 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6826
6827 /* as above, but as bit values */
6828 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6829 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6830 #define _TIF_UPROBE (1<<TIF_UPROBE)
6831 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6832 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6833 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6834 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6835 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6836 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6837 + _TIF_GRSEC_SETXID)
6838
6839 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6840 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6841 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6842 index 4db4959..aba5c41 100644
6843 --- a/arch/powerpc/include/asm/uaccess.h
6844 +++ b/arch/powerpc/include/asm/uaccess.h
6845 @@ -318,52 +318,6 @@ do { \
6846 extern unsigned long __copy_tofrom_user(void __user *to,
6847 const void __user *from, unsigned long size);
6848
6849 -#ifndef __powerpc64__
6850 -
6851 -static inline unsigned long copy_from_user(void *to,
6852 - const void __user *from, unsigned long n)
6853 -{
6854 - unsigned long over;
6855 -
6856 - if (access_ok(VERIFY_READ, from, n))
6857 - return __copy_tofrom_user((__force void __user *)to, from, n);
6858 - if ((unsigned long)from < TASK_SIZE) {
6859 - over = (unsigned long)from + n - TASK_SIZE;
6860 - return __copy_tofrom_user((__force void __user *)to, from,
6861 - n - over) + over;
6862 - }
6863 - return n;
6864 -}
6865 -
6866 -static inline unsigned long copy_to_user(void __user *to,
6867 - const void *from, unsigned long n)
6868 -{
6869 - unsigned long over;
6870 -
6871 - if (access_ok(VERIFY_WRITE, to, n))
6872 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6873 - if ((unsigned long)to < TASK_SIZE) {
6874 - over = (unsigned long)to + n - TASK_SIZE;
6875 - return __copy_tofrom_user(to, (__force void __user *)from,
6876 - n - over) + over;
6877 - }
6878 - return n;
6879 -}
6880 -
6881 -#else /* __powerpc64__ */
6882 -
6883 -#define __copy_in_user(to, from, size) \
6884 - __copy_tofrom_user((to), (from), (size))
6885 -
6886 -extern unsigned long copy_from_user(void *to, const void __user *from,
6887 - unsigned long n);
6888 -extern unsigned long copy_to_user(void __user *to, const void *from,
6889 - unsigned long n);
6890 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6891 - unsigned long n);
6892 -
6893 -#endif /* __powerpc64__ */
6894 -
6895 static inline unsigned long __copy_from_user_inatomic(void *to,
6896 const void __user *from, unsigned long n)
6897 {
6898 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6899 if (ret == 0)
6900 return 0;
6901 }
6902 +
6903 + if (!__builtin_constant_p(n))
6904 + check_object_size(to, n, false);
6905 +
6906 return __copy_tofrom_user((__force void __user *)to, from, n);
6907 }
6908
6909 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6910 if (ret == 0)
6911 return 0;
6912 }
6913 +
6914 + if (!__builtin_constant_p(n))
6915 + check_object_size(from, n, true);
6916 +
6917 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6918 }
6919
6920 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6921 return __copy_to_user_inatomic(to, from, size);
6922 }
6923
6924 +#ifndef __powerpc64__
6925 +
6926 +static inline unsigned long __must_check copy_from_user(void *to,
6927 + const void __user *from, unsigned long n)
6928 +{
6929 + unsigned long over;
6930 +
6931 + if ((long)n < 0)
6932 + return n;
6933 +
6934 + if (access_ok(VERIFY_READ, from, n)) {
6935 + if (!__builtin_constant_p(n))
6936 + check_object_size(to, n, false);
6937 + return __copy_tofrom_user((__force void __user *)to, from, n);
6938 + }
6939 + if ((unsigned long)from < TASK_SIZE) {
6940 + over = (unsigned long)from + n - TASK_SIZE;
6941 + if (!__builtin_constant_p(n - over))
6942 + check_object_size(to, n - over, false);
6943 + return __copy_tofrom_user((__force void __user *)to, from,
6944 + n - over) + over;
6945 + }
6946 + return n;
6947 +}
6948 +
6949 +static inline unsigned long __must_check copy_to_user(void __user *to,
6950 + const void *from, unsigned long n)
6951 +{
6952 + unsigned long over;
6953 +
6954 + if ((long)n < 0)
6955 + return n;
6956 +
6957 + if (access_ok(VERIFY_WRITE, to, n)) {
6958 + if (!__builtin_constant_p(n))
6959 + check_object_size(from, n, true);
6960 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6961 + }
6962 + if ((unsigned long)to < TASK_SIZE) {
6963 + over = (unsigned long)to + n - TASK_SIZE;
6964 + if (!__builtin_constant_p(n))
6965 + check_object_size(from, n - over, true);
6966 + return __copy_tofrom_user(to, (__force void __user *)from,
6967 + n - over) + over;
6968 + }
6969 + return n;
6970 +}
6971 +
6972 +#else /* __powerpc64__ */
6973 +
6974 +#define __copy_in_user(to, from, size) \
6975 + __copy_tofrom_user((to), (from), (size))
6976 +
6977 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6978 +{
6979 + if ((long)n < 0 || n > INT_MAX)
6980 + return n;
6981 +
6982 + if (!__builtin_constant_p(n))
6983 + check_object_size(to, n, false);
6984 +
6985 + if (likely(access_ok(VERIFY_READ, from, n)))
6986 + n = __copy_from_user(to, from, n);
6987 + else
6988 + memset(to, 0, n);
6989 + return n;
6990 +}
6991 +
6992 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6993 +{
6994 + if ((long)n < 0 || n > INT_MAX)
6995 + return n;
6996 +
6997 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6998 + if (!__builtin_constant_p(n))
6999 + check_object_size(from, n, true);
7000 + n = __copy_to_user(to, from, n);
7001 + }
7002 + return n;
7003 +}
7004 +
7005 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7006 + unsigned long n);
7007 +
7008 +#endif /* __powerpc64__ */
7009 +
7010 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7011
7012 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7013 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7014 index 4684e33..acc4d19e 100644
7015 --- a/arch/powerpc/kernel/exceptions-64e.S
7016 +++ b/arch/powerpc/kernel/exceptions-64e.S
7017 @@ -715,6 +715,7 @@ storage_fault_common:
7018 std r14,_DAR(r1)
7019 std r15,_DSISR(r1)
7020 addi r3,r1,STACK_FRAME_OVERHEAD
7021 + bl .save_nvgprs
7022 mr r4,r14
7023 mr r5,r15
7024 ld r14,PACA_EXGEN+EX_R14(r13)
7025 @@ -723,8 +724,7 @@ storage_fault_common:
7026 cmpdi r3,0
7027 bne- 1f
7028 b .ret_from_except_lite
7029 -1: bl .save_nvgprs
7030 - mr r5,r3
7031 +1: mr r5,r3
7032 addi r3,r1,STACK_FRAME_OVERHEAD
7033 ld r4,_DAR(r1)
7034 bl .bad_page_fault
7035 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7036 index 3684cbd..bc89eab 100644
7037 --- a/arch/powerpc/kernel/exceptions-64s.S
7038 +++ b/arch/powerpc/kernel/exceptions-64s.S
7039 @@ -1206,10 +1206,10 @@ handle_page_fault:
7040 11: ld r4,_DAR(r1)
7041 ld r5,_DSISR(r1)
7042 addi r3,r1,STACK_FRAME_OVERHEAD
7043 + bl .save_nvgprs
7044 bl .do_page_fault
7045 cmpdi r3,0
7046 beq+ 12f
7047 - bl .save_nvgprs
7048 mr r5,r3
7049 addi r3,r1,STACK_FRAME_OVERHEAD
7050 lwz r4,_DAR(r1)
7051 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7052 index 2e3200c..72095ce 100644
7053 --- a/arch/powerpc/kernel/module_32.c
7054 +++ b/arch/powerpc/kernel/module_32.c
7055 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7056 me->arch.core_plt_section = i;
7057 }
7058 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7059 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7060 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7061 return -ENOEXEC;
7062 }
7063
7064 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7065
7066 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7067 /* Init, or core PLT? */
7068 - if (location >= mod->module_core
7069 - && location < mod->module_core + mod->core_size)
7070 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7071 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7072 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7073 - else
7074 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7075 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7076 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7077 + else {
7078 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7079 + return ~0UL;
7080 + }
7081
7082 /* Find this entry, or if that fails, the next avail. entry */
7083 while (entry->jump[0]) {
7084 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7085 index 8143067..21ae55b 100644
7086 --- a/arch/powerpc/kernel/process.c
7087 +++ b/arch/powerpc/kernel/process.c
7088 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
7089 * Lookup NIP late so we have the best change of getting the
7090 * above info out without failing
7091 */
7092 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7093 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7094 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7095 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7096 #endif
7097 show_stack(current, (unsigned long *) regs->gpr[1]);
7098 if (!user_mode(regs))
7099 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7100 newsp = stack[0];
7101 ip = stack[STACK_FRAME_LR_SAVE];
7102 if (!firstframe || ip != lr) {
7103 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
7104 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
7105 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7106 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
7107 - printk(" (%pS)",
7108 + printk(" (%pA)",
7109 (void *)current->ret_stack[curr_frame].ret);
7110 curr_frame--;
7111 }
7112 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7113 struct pt_regs *regs = (struct pt_regs *)
7114 (sp + STACK_FRAME_OVERHEAD);
7115 lr = regs->link;
7116 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
7117 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
7118 regs->trap, (void *)regs->nip, (void *)lr);
7119 firstframe = 1;
7120 }
7121 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
7122 mtspr(SPRN_CTRLT, ctrl);
7123 }
7124 #endif /* CONFIG_PPC64 */
7125 -
7126 -unsigned long arch_align_stack(unsigned long sp)
7127 -{
7128 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7129 - sp -= get_random_int() & ~PAGE_MASK;
7130 - return sp & ~0xf;
7131 -}
7132 -
7133 -static inline unsigned long brk_rnd(void)
7134 -{
7135 - unsigned long rnd = 0;
7136 -
7137 - /* 8MB for 32bit, 1GB for 64bit */
7138 - if (is_32bit_task())
7139 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7140 - else
7141 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7142 -
7143 - return rnd << PAGE_SHIFT;
7144 -}
7145 -
7146 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7147 -{
7148 - unsigned long base = mm->brk;
7149 - unsigned long ret;
7150 -
7151 -#ifdef CONFIG_PPC_STD_MMU_64
7152 - /*
7153 - * If we are using 1TB segments and we are allowed to randomise
7154 - * the heap, we can put it above 1TB so it is backed by a 1TB
7155 - * segment. Otherwise the heap will be in the bottom 1TB
7156 - * which always uses 256MB segments and this may result in a
7157 - * performance penalty.
7158 - */
7159 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7160 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7161 -#endif
7162 -
7163 - ret = PAGE_ALIGN(base + brk_rnd());
7164 -
7165 - if (ret < mm->brk)
7166 - return mm->brk;
7167 -
7168 - return ret;
7169 -}
7170 -
7171 -unsigned long randomize_et_dyn(unsigned long base)
7172 -{
7173 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7174 -
7175 - if (ret < base)
7176 - return base;
7177 -
7178 - return ret;
7179 -}
7180 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
7181 index c497000..8fde506 100644
7182 --- a/arch/powerpc/kernel/ptrace.c
7183 +++ b/arch/powerpc/kernel/ptrace.c
7184 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
7185 return ret;
7186 }
7187
7188 +#ifdef CONFIG_GRKERNSEC_SETXID
7189 +extern void gr_delayed_cred_worker(void);
7190 +#endif
7191 +
7192 /*
7193 * We must return the syscall number to actually look up in the table.
7194 * This can be -1L to skip running any syscall at all.
7195 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
7196
7197 secure_computing_strict(regs->gpr[0]);
7198
7199 +#ifdef CONFIG_GRKERNSEC_SETXID
7200 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7201 + gr_delayed_cred_worker();
7202 +#endif
7203 +
7204 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
7205 tracehook_report_syscall_entry(regs))
7206 /*
7207 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
7208 {
7209 int step;
7210
7211 +#ifdef CONFIG_GRKERNSEC_SETXID
7212 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7213 + gr_delayed_cred_worker();
7214 +#endif
7215 +
7216 audit_syscall_exit(regs);
7217
7218 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7219 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
7220 index 804e323..79181c1 100644
7221 --- a/arch/powerpc/kernel/signal_32.c
7222 +++ b/arch/powerpc/kernel/signal_32.c
7223 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
7224 /* Save user registers on the stack */
7225 frame = &rt_sf->uc.uc_mcontext;
7226 addr = frame;
7227 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
7228 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7229 if (save_user_regs(regs, frame, 0, 1))
7230 goto badframe;
7231 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
7232 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
7233 index 1ca045d..139c3f7 100644
7234 --- a/arch/powerpc/kernel/signal_64.c
7235 +++ b/arch/powerpc/kernel/signal_64.c
7236 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
7237 current->thread.fpscr.val = 0;
7238
7239 /* Set up to return from userspace. */
7240 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
7241 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7242 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
7243 } else {
7244 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
7245 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
7246 index 3ce1f86..c30e629 100644
7247 --- a/arch/powerpc/kernel/sysfs.c
7248 +++ b/arch/powerpc/kernel/sysfs.c
7249 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
7250 return NOTIFY_OK;
7251 }
7252
7253 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
7254 +static struct notifier_block sysfs_cpu_nb = {
7255 .notifier_call = sysfs_cpu_notify,
7256 };
7257
7258 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
7259 index 3251840..3f7c77a 100644
7260 --- a/arch/powerpc/kernel/traps.c
7261 +++ b/arch/powerpc/kernel/traps.c
7262 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
7263 return flags;
7264 }
7265
7266 +extern void gr_handle_kernel_exploit(void);
7267 +
7268 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7269 int signr)
7270 {
7271 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7272 panic("Fatal exception in interrupt");
7273 if (panic_on_oops)
7274 panic("Fatal exception");
7275 +
7276 + gr_handle_kernel_exploit();
7277 +
7278 do_exit(signr);
7279 }
7280
7281 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
7282 index 1b2076f..835e4be 100644
7283 --- a/arch/powerpc/kernel/vdso.c
7284 +++ b/arch/powerpc/kernel/vdso.c
7285 @@ -34,6 +34,7 @@
7286 #include <asm/firmware.h>
7287 #include <asm/vdso.h>
7288 #include <asm/vdso_datapage.h>
7289 +#include <asm/mman.h>
7290
7291 #include "setup.h"
7292
7293 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7294 vdso_base = VDSO32_MBASE;
7295 #endif
7296
7297 - current->mm->context.vdso_base = 0;
7298 + current->mm->context.vdso_base = ~0UL;
7299
7300 /* vDSO has a problem and was disabled, just don't "enable" it for the
7301 * process
7302 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7303 vdso_base = get_unmapped_area(NULL, vdso_base,
7304 (vdso_pages << PAGE_SHIFT) +
7305 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
7306 - 0, 0);
7307 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
7308 if (IS_ERR_VALUE(vdso_base)) {
7309 rc = vdso_base;
7310 goto fail_mmapsem;
7311 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
7312 index 5eea6f3..5d10396 100644
7313 --- a/arch/powerpc/lib/usercopy_64.c
7314 +++ b/arch/powerpc/lib/usercopy_64.c
7315 @@ -9,22 +9,6 @@
7316 #include <linux/module.h>
7317 #include <asm/uaccess.h>
7318
7319 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
7320 -{
7321 - if (likely(access_ok(VERIFY_READ, from, n)))
7322 - n = __copy_from_user(to, from, n);
7323 - else
7324 - memset(to, 0, n);
7325 - return n;
7326 -}
7327 -
7328 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
7329 -{
7330 - if (likely(access_ok(VERIFY_WRITE, to, n)))
7331 - n = __copy_to_user(to, from, n);
7332 - return n;
7333 -}
7334 -
7335 unsigned long copy_in_user(void __user *to, const void __user *from,
7336 unsigned long n)
7337 {
7338 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7339 return n;
7340 }
7341
7342 -EXPORT_SYMBOL(copy_from_user);
7343 -EXPORT_SYMBOL(copy_to_user);
7344 EXPORT_SYMBOL(copy_in_user);
7345
7346 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7347 index 3a8489a..6a63b3b 100644
7348 --- a/arch/powerpc/mm/fault.c
7349 +++ b/arch/powerpc/mm/fault.c
7350 @@ -32,6 +32,10 @@
7351 #include <linux/perf_event.h>
7352 #include <linux/magic.h>
7353 #include <linux/ratelimit.h>
7354 +#include <linux/slab.h>
7355 +#include <linux/pagemap.h>
7356 +#include <linux/compiler.h>
7357 +#include <linux/unistd.h>
7358
7359 #include <asm/firmware.h>
7360 #include <asm/page.h>
7361 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7362 }
7363 #endif
7364
7365 +#ifdef CONFIG_PAX_PAGEEXEC
7366 +/*
7367 + * PaX: decide what to do with offenders (regs->nip = fault address)
7368 + *
7369 + * returns 1 when task should be killed
7370 + */
7371 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7372 +{
7373 + return 1;
7374 +}
7375 +
7376 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7377 +{
7378 + unsigned long i;
7379 +
7380 + printk(KERN_ERR "PAX: bytes at PC: ");
7381 + for (i = 0; i < 5; i++) {
7382 + unsigned int c;
7383 + if (get_user(c, (unsigned int __user *)pc+i))
7384 + printk(KERN_CONT "???????? ");
7385 + else
7386 + printk(KERN_CONT "%08x ", c);
7387 + }
7388 + printk("\n");
7389 +}
7390 +#endif
7391 +
7392 /*
7393 * Check whether the instruction at regs->nip is a store using
7394 * an update addressing form which will update r1.
7395 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7396 * indicate errors in DSISR but can validly be set in SRR1.
7397 */
7398 if (trap == 0x400)
7399 - error_code &= 0x48200000;
7400 + error_code &= 0x58200000;
7401 else
7402 is_write = error_code & DSISR_ISSTORE;
7403 #else
7404 @@ -364,7 +395,7 @@ good_area:
7405 * "undefined". Of those that can be set, this is the only
7406 * one which seems bad.
7407 */
7408 - if (error_code & 0x10000000)
7409 + if (error_code & DSISR_GUARDED)
7410 /* Guarded storage error. */
7411 goto bad_area;
7412 #endif /* CONFIG_8xx */
7413 @@ -379,7 +410,7 @@ good_area:
7414 * processors use the same I/D cache coherency mechanism
7415 * as embedded.
7416 */
7417 - if (error_code & DSISR_PROTFAULT)
7418 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7419 goto bad_area;
7420 #endif /* CONFIG_PPC_STD_MMU */
7421
7422 @@ -462,6 +493,23 @@ bad_area:
7423 bad_area_nosemaphore:
7424 /* User mode accesses cause a SIGSEGV */
7425 if (user_mode(regs)) {
7426 +
7427 +#ifdef CONFIG_PAX_PAGEEXEC
7428 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7429 +#ifdef CONFIG_PPC_STD_MMU
7430 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7431 +#else
7432 + if (is_exec && regs->nip == address) {
7433 +#endif
7434 + switch (pax_handle_fetch_fault(regs)) {
7435 + }
7436 +
7437 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7438 + do_group_exit(SIGKILL);
7439 + }
7440 + }
7441 +#endif
7442 +
7443 _exception(SIGSEGV, regs, code, address);
7444 return 0;
7445 }
7446 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7447 index 67a42ed..cd463e0 100644
7448 --- a/arch/powerpc/mm/mmap_64.c
7449 +++ b/arch/powerpc/mm/mmap_64.c
7450 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7451 {
7452 unsigned long rnd = 0;
7453
7454 +#ifdef CONFIG_PAX_RANDMMAP
7455 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7456 +#endif
7457 +
7458 if (current->flags & PF_RANDOMIZE) {
7459 /* 8MB for 32bit, 1GB for 64bit */
7460 if (is_32bit_task())
7461 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7462 */
7463 if (mmap_is_legacy()) {
7464 mm->mmap_base = TASK_UNMAPPED_BASE;
7465 +
7466 +#ifdef CONFIG_PAX_RANDMMAP
7467 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7468 + mm->mmap_base += mm->delta_mmap;
7469 +#endif
7470 +
7471 mm->get_unmapped_area = arch_get_unmapped_area;
7472 mm->unmap_area = arch_unmap_area;
7473 } else {
7474 mm->mmap_base = mmap_base();
7475 +
7476 +#ifdef CONFIG_PAX_RANDMMAP
7477 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7478 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7479 +#endif
7480 +
7481 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7482 mm->unmap_area = arch_unmap_area_topdown;
7483 }
7484 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7485 index e779642..e5bb889 100644
7486 --- a/arch/powerpc/mm/mmu_context_nohash.c
7487 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7488 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7489 return NOTIFY_OK;
7490 }
7491
7492 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7493 +static struct notifier_block mmu_context_cpu_nb = {
7494 .notifier_call = mmu_context_cpu_notify,
7495 };
7496
7497 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7498 index bba87ca..c346a33 100644
7499 --- a/arch/powerpc/mm/numa.c
7500 +++ b/arch/powerpc/mm/numa.c
7501 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7502 return ret;
7503 }
7504
7505 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7506 +static struct notifier_block ppc64_numa_nb = {
7507 .notifier_call = cpu_numa_callback,
7508 .priority = 1 /* Must run before sched domains notifier. */
7509 };
7510 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7511 index cf9dada..241529f 100644
7512 --- a/arch/powerpc/mm/slice.c
7513 +++ b/arch/powerpc/mm/slice.c
7514 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7515 if ((mm->task_size - len) < addr)
7516 return 0;
7517 vma = find_vma(mm, addr);
7518 - return (!vma || (addr + len) <= vma->vm_start);
7519 + return check_heap_stack_gap(vma, addr, len, 0);
7520 }
7521
7522 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7523 @@ -272,7 +272,7 @@ full_search:
7524 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7525 continue;
7526 }
7527 - if (!vma || addr + len <= vma->vm_start) {
7528 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7529 /*
7530 * Remember the place where we stopped the search:
7531 */
7532 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7533 }
7534 }
7535
7536 - addr = mm->mmap_base;
7537 - while (addr > len) {
7538 + if (mm->mmap_base < len)
7539 + addr = -ENOMEM;
7540 + else
7541 + addr = mm->mmap_base - len;
7542 +
7543 + while (!IS_ERR_VALUE(addr)) {
7544 /* Go down by chunk size */
7545 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7546 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7547
7548 /* Check for hit with different page size */
7549 mask = slice_range_to_mask(addr, len);
7550 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7551 * return with success:
7552 */
7553 vma = find_vma(mm, addr);
7554 - if (!vma || (addr + len) <= vma->vm_start) {
7555 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7556 /* remember the address as a hint for next time */
7557 if (use_cache)
7558 mm->free_area_cache = addr;
7559 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7560 mm->cached_hole_size = vma->vm_start - addr;
7561
7562 /* try just below the current vma->vm_start */
7563 - addr = vma->vm_start;
7564 + addr = skip_heap_stack_gap(vma, len, 0);
7565 }
7566
7567 /*
7568 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7569 if (fixed && addr > (mm->task_size - len))
7570 return -EINVAL;
7571
7572 +#ifdef CONFIG_PAX_RANDMMAP
7573 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7574 + addr = 0;
7575 +#endif
7576 +
7577 /* If hint, make sure it matches our alignment restrictions */
7578 if (!fixed && addr) {
7579 addr = _ALIGN_UP(addr, 1ul << pshift);
7580 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7581 index 0cfece4..2f1a0e5 100644
7582 --- a/arch/powerpc/platforms/cell/spufs/file.c
7583 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7584 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7585 return VM_FAULT_NOPAGE;
7586 }
7587
7588 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7589 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7590 unsigned long address,
7591 - void *buf, int len, int write)
7592 + void *buf, size_t len, int write)
7593 {
7594 struct spu_context *ctx = vma->vm_file->private_data;
7595 unsigned long offset = address - vma->vm_start;
7596 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7597 index bdb738a..49c9f95 100644
7598 --- a/arch/powerpc/platforms/powermac/smp.c
7599 +++ b/arch/powerpc/platforms/powermac/smp.c
7600 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7601 return NOTIFY_OK;
7602 }
7603
7604 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7605 +static struct notifier_block smp_core99_cpu_nb = {
7606 .notifier_call = smp_core99_cpu_notify,
7607 };
7608 #endif /* CONFIG_HOTPLUG_CPU */
7609 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7610 index c797832..ce575c8 100644
7611 --- a/arch/s390/include/asm/atomic.h
7612 +++ b/arch/s390/include/asm/atomic.h
7613 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7614 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7615 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7616
7617 +#define atomic64_read_unchecked(v) atomic64_read(v)
7618 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7619 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7620 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7621 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7622 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7623 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7624 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7625 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7626 +
7627 #define smp_mb__before_atomic_dec() smp_mb()
7628 #define smp_mb__after_atomic_dec() smp_mb()
7629 #define smp_mb__before_atomic_inc() smp_mb()
7630 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7631 index 4d7ccac..d03d0ad 100644
7632 --- a/arch/s390/include/asm/cache.h
7633 +++ b/arch/s390/include/asm/cache.h
7634 @@ -9,8 +9,10 @@
7635 #ifndef __ARCH_S390_CACHE_H
7636 #define __ARCH_S390_CACHE_H
7637
7638 -#define L1_CACHE_BYTES 256
7639 +#include <linux/const.h>
7640 +
7641 #define L1_CACHE_SHIFT 8
7642 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7643 #define NET_SKB_PAD 32
7644
7645 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7646 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7647 index 178ff96..8c93bd1 100644
7648 --- a/arch/s390/include/asm/elf.h
7649 +++ b/arch/s390/include/asm/elf.h
7650 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7651 the loader. We need to make sure that it is out of the way of the program
7652 that it will "exec", and that there is sufficient room for the brk. */
7653
7654 -extern unsigned long randomize_et_dyn(unsigned long base);
7655 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7656 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7657 +
7658 +#ifdef CONFIG_PAX_ASLR
7659 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7660 +
7661 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7662 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7663 +#endif
7664
7665 /* This yields a mask that user programs can use to figure out what
7666 instruction set this CPU supports. */
7667 @@ -210,9 +216,6 @@ struct linux_binprm;
7668 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7669 int arch_setup_additional_pages(struct linux_binprm *, int);
7670
7671 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7672 -#define arch_randomize_brk arch_randomize_brk
7673 -
7674 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7675
7676 #endif
7677 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7678 index c4a93d6..4d2a9b4 100644
7679 --- a/arch/s390/include/asm/exec.h
7680 +++ b/arch/s390/include/asm/exec.h
7681 @@ -7,6 +7,6 @@
7682 #ifndef __ASM_EXEC_H
7683 #define __ASM_EXEC_H
7684
7685 -extern unsigned long arch_align_stack(unsigned long sp);
7686 +#define arch_align_stack(x) ((x) & ~0xfUL)
7687
7688 #endif /* __ASM_EXEC_H */
7689 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7690 index 34268df..ea97318 100644
7691 --- a/arch/s390/include/asm/uaccess.h
7692 +++ b/arch/s390/include/asm/uaccess.h
7693 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7694 copy_to_user(void __user *to, const void *from, unsigned long n)
7695 {
7696 might_fault();
7697 +
7698 + if ((long)n < 0)
7699 + return n;
7700 +
7701 if (access_ok(VERIFY_WRITE, to, n))
7702 n = __copy_to_user(to, from, n);
7703 return n;
7704 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7705 static inline unsigned long __must_check
7706 __copy_from_user(void *to, const void __user *from, unsigned long n)
7707 {
7708 + if ((long)n < 0)
7709 + return n;
7710 +
7711 if (__builtin_constant_p(n) && (n <= 256))
7712 return uaccess.copy_from_user_small(n, from, to);
7713 else
7714 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7715 static inline unsigned long __must_check
7716 copy_from_user(void *to, const void __user *from, unsigned long n)
7717 {
7718 - unsigned int sz = __compiletime_object_size(to);
7719 + size_t sz = __compiletime_object_size(to);
7720
7721 might_fault();
7722 - if (unlikely(sz != -1 && sz < n)) {
7723 +
7724 + if ((long)n < 0)
7725 + return n;
7726 +
7727 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7728 copy_from_user_overflow();
7729 return n;
7730 }
7731 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7732 index 4610dea..cf0af21 100644
7733 --- a/arch/s390/kernel/module.c
7734 +++ b/arch/s390/kernel/module.c
7735 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7736
7737 /* Increase core size by size of got & plt and set start
7738 offsets for got and plt. */
7739 - me->core_size = ALIGN(me->core_size, 4);
7740 - me->arch.got_offset = me->core_size;
7741 - me->core_size += me->arch.got_size;
7742 - me->arch.plt_offset = me->core_size;
7743 - me->core_size += me->arch.plt_size;
7744 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7745 + me->arch.got_offset = me->core_size_rw;
7746 + me->core_size_rw += me->arch.got_size;
7747 + me->arch.plt_offset = me->core_size_rx;
7748 + me->core_size_rx += me->arch.plt_size;
7749 return 0;
7750 }
7751
7752 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7753 if (info->got_initialized == 0) {
7754 Elf_Addr *gotent;
7755
7756 - gotent = me->module_core + me->arch.got_offset +
7757 + gotent = me->module_core_rw + me->arch.got_offset +
7758 info->got_offset;
7759 *gotent = val;
7760 info->got_initialized = 1;
7761 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7762 else if (r_type == R_390_GOTENT ||
7763 r_type == R_390_GOTPLTENT)
7764 *(unsigned int *) loc =
7765 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7766 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7767 else if (r_type == R_390_GOT64 ||
7768 r_type == R_390_GOTPLT64)
7769 *(unsigned long *) loc = val;
7770 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7771 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7772 if (info->plt_initialized == 0) {
7773 unsigned int *ip;
7774 - ip = me->module_core + me->arch.plt_offset +
7775 + ip = me->module_core_rx + me->arch.plt_offset +
7776 info->plt_offset;
7777 #ifndef CONFIG_64BIT
7778 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7779 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7780 val - loc + 0xffffUL < 0x1ffffeUL) ||
7781 (r_type == R_390_PLT32DBL &&
7782 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7783 - val = (Elf_Addr) me->module_core +
7784 + val = (Elf_Addr) me->module_core_rx +
7785 me->arch.plt_offset +
7786 info->plt_offset;
7787 val += rela->r_addend - loc;
7788 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7789 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7790 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7791 val = val + rela->r_addend -
7792 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7793 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7794 if (r_type == R_390_GOTOFF16)
7795 *(unsigned short *) loc = val;
7796 else if (r_type == R_390_GOTOFF32)
7797 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7798 break;
7799 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7800 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7801 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7802 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7803 rela->r_addend - loc;
7804 if (r_type == R_390_GOTPC)
7805 *(unsigned int *) loc = val;
7806 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7807 index 536d645..4a5bd9e 100644
7808 --- a/arch/s390/kernel/process.c
7809 +++ b/arch/s390/kernel/process.c
7810 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7811 }
7812 return 0;
7813 }
7814 -
7815 -unsigned long arch_align_stack(unsigned long sp)
7816 -{
7817 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7818 - sp -= get_random_int() & ~PAGE_MASK;
7819 - return sp & ~0xf;
7820 -}
7821 -
7822 -static inline unsigned long brk_rnd(void)
7823 -{
7824 - /* 8MB for 32bit, 1GB for 64bit */
7825 - if (is_32bit_task())
7826 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7827 - else
7828 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7829 -}
7830 -
7831 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7832 -{
7833 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7834 -
7835 - if (ret < mm->brk)
7836 - return mm->brk;
7837 - return ret;
7838 -}
7839 -
7840 -unsigned long randomize_et_dyn(unsigned long base)
7841 -{
7842 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7843 -
7844 - if (!(current->flags & PF_RANDOMIZE))
7845 - return base;
7846 - if (ret < base)
7847 - return base;
7848 - return ret;
7849 -}
7850 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7851 index c59a5ef..3fae59c 100644
7852 --- a/arch/s390/mm/mmap.c
7853 +++ b/arch/s390/mm/mmap.c
7854 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7855 */
7856 if (mmap_is_legacy()) {
7857 mm->mmap_base = TASK_UNMAPPED_BASE;
7858 +
7859 +#ifdef CONFIG_PAX_RANDMMAP
7860 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7861 + mm->mmap_base += mm->delta_mmap;
7862 +#endif
7863 +
7864 mm->get_unmapped_area = arch_get_unmapped_area;
7865 mm->unmap_area = arch_unmap_area;
7866 } else {
7867 mm->mmap_base = mmap_base();
7868 +
7869 +#ifdef CONFIG_PAX_RANDMMAP
7870 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7871 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7872 +#endif
7873 +
7874 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7875 mm->unmap_area = arch_unmap_area_topdown;
7876 }
7877 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7878 */
7879 if (mmap_is_legacy()) {
7880 mm->mmap_base = TASK_UNMAPPED_BASE;
7881 +
7882 +#ifdef CONFIG_PAX_RANDMMAP
7883 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7884 + mm->mmap_base += mm->delta_mmap;
7885 +#endif
7886 +
7887 mm->get_unmapped_area = s390_get_unmapped_area;
7888 mm->unmap_area = arch_unmap_area;
7889 } else {
7890 mm->mmap_base = mmap_base();
7891 +
7892 +#ifdef CONFIG_PAX_RANDMMAP
7893 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7894 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7895 +#endif
7896 +
7897 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7898 mm->unmap_area = arch_unmap_area_topdown;
7899 }
7900 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7901 index ae3d59f..f65f075 100644
7902 --- a/arch/score/include/asm/cache.h
7903 +++ b/arch/score/include/asm/cache.h
7904 @@ -1,7 +1,9 @@
7905 #ifndef _ASM_SCORE_CACHE_H
7906 #define _ASM_SCORE_CACHE_H
7907
7908 +#include <linux/const.h>
7909 +
7910 #define L1_CACHE_SHIFT 4
7911 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7912 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7913
7914 #endif /* _ASM_SCORE_CACHE_H */
7915 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7916 index f9f3cd5..58ff438 100644
7917 --- a/arch/score/include/asm/exec.h
7918 +++ b/arch/score/include/asm/exec.h
7919 @@ -1,6 +1,6 @@
7920 #ifndef _ASM_SCORE_EXEC_H
7921 #define _ASM_SCORE_EXEC_H
7922
7923 -extern unsigned long arch_align_stack(unsigned long sp);
7924 +#define arch_align_stack(x) (x)
7925
7926 #endif /* _ASM_SCORE_EXEC_H */
7927 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7928 index 7956846..5f37677 100644
7929 --- a/arch/score/kernel/process.c
7930 +++ b/arch/score/kernel/process.c
7931 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7932
7933 return task_pt_regs(task)->cp0_epc;
7934 }
7935 -
7936 -unsigned long arch_align_stack(unsigned long sp)
7937 -{
7938 - return sp;
7939 -}
7940 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7941 index ef9e555..331bd29 100644
7942 --- a/arch/sh/include/asm/cache.h
7943 +++ b/arch/sh/include/asm/cache.h
7944 @@ -9,10 +9,11 @@
7945 #define __ASM_SH_CACHE_H
7946 #ifdef __KERNEL__
7947
7948 +#include <linux/const.h>
7949 #include <linux/init.h>
7950 #include <cpu/cache.h>
7951
7952 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7953 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7954
7955 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7956
7957 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7958 index 03f2b55..b027032 100644
7959 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7960 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7961 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7962 return NOTIFY_OK;
7963 }
7964
7965 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7966 +static struct notifier_block shx3_cpu_notifier = {
7967 .notifier_call = shx3_cpu_callback,
7968 };
7969
7970 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7971 index 6777177..cb5e44f 100644
7972 --- a/arch/sh/mm/mmap.c
7973 +++ b/arch/sh/mm/mmap.c
7974 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7975 struct mm_struct *mm = current->mm;
7976 struct vm_area_struct *vma;
7977 int do_colour_align;
7978 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7979 struct vm_unmapped_area_info info;
7980
7981 if (flags & MAP_FIXED) {
7982 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7983 if (filp || (flags & MAP_SHARED))
7984 do_colour_align = 1;
7985
7986 +#ifdef CONFIG_PAX_RANDMMAP
7987 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7988 +#endif
7989 +
7990 if (addr) {
7991 if (do_colour_align)
7992 addr = COLOUR_ALIGN(addr, pgoff);
7993 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7994 addr = PAGE_ALIGN(addr);
7995
7996 vma = find_vma(mm, addr);
7997 - if (TASK_SIZE - len >= addr &&
7998 - (!vma || addr + len <= vma->vm_start))
7999 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8000 return addr;
8001 }
8002
8003 info.flags = 0;
8004 info.length = len;
8005 - info.low_limit = TASK_UNMAPPED_BASE;
8006 + info.low_limit = mm->mmap_base;
8007 info.high_limit = TASK_SIZE;
8008 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8009 info.align_offset = pgoff << PAGE_SHIFT;
8010 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8011 struct mm_struct *mm = current->mm;
8012 unsigned long addr = addr0;
8013 int do_colour_align;
8014 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8015 struct vm_unmapped_area_info info;
8016
8017 if (flags & MAP_FIXED) {
8018 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8019 if (filp || (flags & MAP_SHARED))
8020 do_colour_align = 1;
8021
8022 +#ifdef CONFIG_PAX_RANDMMAP
8023 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8024 +#endif
8025 +
8026 /* requesting a specific address */
8027 if (addr) {
8028 if (do_colour_align)
8029 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8030 addr = PAGE_ALIGN(addr);
8031
8032 vma = find_vma(mm, addr);
8033 - if (TASK_SIZE - len >= addr &&
8034 - (!vma || addr + len <= vma->vm_start))
8035 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8036 return addr;
8037 }
8038
8039 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8040 VM_BUG_ON(addr != -ENOMEM);
8041 info.flags = 0;
8042 info.low_limit = TASK_UNMAPPED_BASE;
8043 +
8044 +#ifdef CONFIG_PAX_RANDMMAP
8045 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8046 + info.low_limit += mm->delta_mmap;
8047 +#endif
8048 +
8049 info.high_limit = TASK_SIZE;
8050 addr = vm_unmapped_area(&info);
8051 }
8052 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8053 index be56a24..443328f 100644
8054 --- a/arch/sparc/include/asm/atomic_64.h
8055 +++ b/arch/sparc/include/asm/atomic_64.h
8056 @@ -14,18 +14,40 @@
8057 #define ATOMIC64_INIT(i) { (i) }
8058
8059 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8060 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8061 +{
8062 + return v->counter;
8063 +}
8064 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8065 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8066 +{
8067 + return v->counter;
8068 +}
8069
8070 #define atomic_set(v, i) (((v)->counter) = i)
8071 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8072 +{
8073 + v->counter = i;
8074 +}
8075 #define atomic64_set(v, i) (((v)->counter) = i)
8076 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8077 +{
8078 + v->counter = i;
8079 +}
8080
8081 extern void atomic_add(int, atomic_t *);
8082 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8083 extern void atomic64_add(long, atomic64_t *);
8084 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8085 extern void atomic_sub(int, atomic_t *);
8086 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8087 extern void atomic64_sub(long, atomic64_t *);
8088 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8089
8090 extern int atomic_add_ret(int, atomic_t *);
8091 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8092 extern long atomic64_add_ret(long, atomic64_t *);
8093 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8094 extern int atomic_sub_ret(int, atomic_t *);
8095 extern long atomic64_sub_ret(long, atomic64_t *);
8096
8097 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8098 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8099
8100 #define atomic_inc_return(v) atomic_add_ret(1, v)
8101 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8102 +{
8103 + return atomic_add_ret_unchecked(1, v);
8104 +}
8105 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8106 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8107 +{
8108 + return atomic64_add_ret_unchecked(1, v);
8109 +}
8110
8111 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8112 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8113
8114 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8115 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8116 +{
8117 + return atomic_add_ret_unchecked(i, v);
8118 +}
8119 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8120 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8121 +{
8122 + return atomic64_add_ret_unchecked(i, v);
8123 +}
8124
8125 /*
8126 * atomic_inc_and_test - increment and test
8127 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8128 * other cases.
8129 */
8130 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8131 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8132 +{
8133 + return atomic_inc_return_unchecked(v) == 0;
8134 +}
8135 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8136
8137 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8138 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8139 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8140
8141 #define atomic_inc(v) atomic_add(1, v)
8142 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8143 +{
8144 + atomic_add_unchecked(1, v);
8145 +}
8146 #define atomic64_inc(v) atomic64_add(1, v)
8147 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8148 +{
8149 + atomic64_add_unchecked(1, v);
8150 +}
8151
8152 #define atomic_dec(v) atomic_sub(1, v)
8153 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8154 +{
8155 + atomic_sub_unchecked(1, v);
8156 +}
8157 #define atomic64_dec(v) atomic64_sub(1, v)
8158 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8159 +{
8160 + atomic64_sub_unchecked(1, v);
8161 +}
8162
8163 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8164 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8165
8166 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8167 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8168 +{
8169 + return cmpxchg(&v->counter, old, new);
8170 +}
8171 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8172 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8173 +{
8174 + return xchg(&v->counter, new);
8175 +}
8176
8177 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8178 {
8179 - int c, old;
8180 + int c, old, new;
8181 c = atomic_read(v);
8182 for (;;) {
8183 - if (unlikely(c == (u)))
8184 + if (unlikely(c == u))
8185 break;
8186 - old = atomic_cmpxchg((v), c, c + (a));
8187 +
8188 + asm volatile("addcc %2, %0, %0\n"
8189 +
8190 +#ifdef CONFIG_PAX_REFCOUNT
8191 + "tvs %%icc, 6\n"
8192 +#endif
8193 +
8194 + : "=r" (new)
8195 + : "0" (c), "ir" (a)
8196 + : "cc");
8197 +
8198 + old = atomic_cmpxchg(v, c, new);
8199 if (likely(old == c))
8200 break;
8201 c = old;
8202 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8203 #define atomic64_cmpxchg(v, o, n) \
8204 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8205 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8206 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8207 +{
8208 + return xchg(&v->counter, new);
8209 +}
8210
8211 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8212 {
8213 - long c, old;
8214 + long c, old, new;
8215 c = atomic64_read(v);
8216 for (;;) {
8217 - if (unlikely(c == (u)))
8218 + if (unlikely(c == u))
8219 break;
8220 - old = atomic64_cmpxchg((v), c, c + (a));
8221 +
8222 + asm volatile("addcc %2, %0, %0\n"
8223 +
8224 +#ifdef CONFIG_PAX_REFCOUNT
8225 + "tvs %%xcc, 6\n"
8226 +#endif
8227 +
8228 + : "=r" (new)
8229 + : "0" (c), "ir" (a)
8230 + : "cc");
8231 +
8232 + old = atomic64_cmpxchg(v, c, new);
8233 if (likely(old == c))
8234 break;
8235 c = old;
8236 }
8237 - return c != (u);
8238 + return c != u;
8239 }
8240
8241 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8242 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8243 index 5bb6991..5c2132e 100644
8244 --- a/arch/sparc/include/asm/cache.h
8245 +++ b/arch/sparc/include/asm/cache.h
8246 @@ -7,10 +7,12 @@
8247 #ifndef _SPARC_CACHE_H
8248 #define _SPARC_CACHE_H
8249
8250 +#include <linux/const.h>
8251 +
8252 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8253
8254 #define L1_CACHE_SHIFT 5
8255 -#define L1_CACHE_BYTES 32
8256 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8257
8258 #ifdef CONFIG_SPARC32
8259 #define SMP_CACHE_BYTES_SHIFT 5
8260 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8261 index ac74a2c..a9e58af 100644
8262 --- a/arch/sparc/include/asm/elf_32.h
8263 +++ b/arch/sparc/include/asm/elf_32.h
8264 @@ -114,6 +114,13 @@ typedef struct {
8265
8266 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8267
8268 +#ifdef CONFIG_PAX_ASLR
8269 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8270 +
8271 +#define PAX_DELTA_MMAP_LEN 16
8272 +#define PAX_DELTA_STACK_LEN 16
8273 +#endif
8274 +
8275 /* This yields a mask that user programs can use to figure out what
8276 instruction set this cpu supports. This can NOT be done in userspace
8277 on Sparc. */
8278 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
8279 index 370ca1e..d4f4a98 100644
8280 --- a/arch/sparc/include/asm/elf_64.h
8281 +++ b/arch/sparc/include/asm/elf_64.h
8282 @@ -189,6 +189,13 @@ typedef struct {
8283 #define ELF_ET_DYN_BASE 0x0000010000000000UL
8284 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
8285
8286 +#ifdef CONFIG_PAX_ASLR
8287 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
8288 +
8289 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
8290 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
8291 +#endif
8292 +
8293 extern unsigned long sparc64_elf_hwcap;
8294 #define ELF_HWCAP sparc64_elf_hwcap
8295
8296 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
8297 index 9b1c36d..209298b 100644
8298 --- a/arch/sparc/include/asm/pgalloc_32.h
8299 +++ b/arch/sparc/include/asm/pgalloc_32.h
8300 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
8301 }
8302
8303 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
8304 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
8305
8306 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
8307 unsigned long address)
8308 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
8309 index bcfe063..b333142 100644
8310 --- a/arch/sparc/include/asm/pgalloc_64.h
8311 +++ b/arch/sparc/include/asm/pgalloc_64.h
8312 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8313 }
8314
8315 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
8316 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
8317
8318 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
8319 {
8320 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
8321 index 6fc1348..390c50a 100644
8322 --- a/arch/sparc/include/asm/pgtable_32.h
8323 +++ b/arch/sparc/include/asm/pgtable_32.h
8324 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
8325 #define PAGE_SHARED SRMMU_PAGE_SHARED
8326 #define PAGE_COPY SRMMU_PAGE_COPY
8327 #define PAGE_READONLY SRMMU_PAGE_RDONLY
8328 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
8329 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
8330 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
8331 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
8332
8333 /* Top-level page directory - dummy used by init-mm.
8334 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
8335
8336 /* xwr */
8337 #define __P000 PAGE_NONE
8338 -#define __P001 PAGE_READONLY
8339 -#define __P010 PAGE_COPY
8340 -#define __P011 PAGE_COPY
8341 +#define __P001 PAGE_READONLY_NOEXEC
8342 +#define __P010 PAGE_COPY_NOEXEC
8343 +#define __P011 PAGE_COPY_NOEXEC
8344 #define __P100 PAGE_READONLY
8345 #define __P101 PAGE_READONLY
8346 #define __P110 PAGE_COPY
8347 #define __P111 PAGE_COPY
8348
8349 #define __S000 PAGE_NONE
8350 -#define __S001 PAGE_READONLY
8351 -#define __S010 PAGE_SHARED
8352 -#define __S011 PAGE_SHARED
8353 +#define __S001 PAGE_READONLY_NOEXEC
8354 +#define __S010 PAGE_SHARED_NOEXEC
8355 +#define __S011 PAGE_SHARED_NOEXEC
8356 #define __S100 PAGE_READONLY
8357 #define __S101 PAGE_READONLY
8358 #define __S110 PAGE_SHARED
8359 diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
8360 index 08fcce9..7619f2f 100644
8361 --- a/arch/sparc/include/asm/pgtable_64.h
8362 +++ b/arch/sparc/include/asm/pgtable_64.h
8363 @@ -915,6 +915,7 @@ static inline int io_remap_pfn_range(struct vm_area_struct *vma,
8364 return remap_pfn_range(vma, from, phys_base >> PAGE_SHIFT, size, prot);
8365 }
8366
8367 +#include <asm/tlbflush.h>
8368 #include <asm-generic/pgtable.h>
8369
8370 /* We provide our own get_unmapped_area to cope with VA holes and
8371 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
8372 index 79da178..c2eede8 100644
8373 --- a/arch/sparc/include/asm/pgtsrmmu.h
8374 +++ b/arch/sparc/include/asm/pgtsrmmu.h
8375 @@ -115,6 +115,11 @@
8376 SRMMU_EXEC | SRMMU_REF)
8377 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
8378 SRMMU_EXEC | SRMMU_REF)
8379 +
8380 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8381 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8382 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8383 +
8384 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8385 SRMMU_DIRTY | SRMMU_REF)
8386
8387 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8388 index 9689176..63c18ea 100644
8389 --- a/arch/sparc/include/asm/spinlock_64.h
8390 +++ b/arch/sparc/include/asm/spinlock_64.h
8391 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8392
8393 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8394
8395 -static void inline arch_read_lock(arch_rwlock_t *lock)
8396 +static inline void arch_read_lock(arch_rwlock_t *lock)
8397 {
8398 unsigned long tmp1, tmp2;
8399
8400 __asm__ __volatile__ (
8401 "1: ldsw [%2], %0\n"
8402 " brlz,pn %0, 2f\n"
8403 -"4: add %0, 1, %1\n"
8404 +"4: addcc %0, 1, %1\n"
8405 +
8406 +#ifdef CONFIG_PAX_REFCOUNT
8407 +" tvs %%icc, 6\n"
8408 +#endif
8409 +
8410 " cas [%2], %0, %1\n"
8411 " cmp %0, %1\n"
8412 " bne,pn %%icc, 1b\n"
8413 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8414 " .previous"
8415 : "=&r" (tmp1), "=&r" (tmp2)
8416 : "r" (lock)
8417 - : "memory");
8418 + : "memory", "cc");
8419 }
8420
8421 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8422 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8423 {
8424 int tmp1, tmp2;
8425
8426 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8427 "1: ldsw [%2], %0\n"
8428 " brlz,a,pn %0, 2f\n"
8429 " mov 0, %0\n"
8430 -" add %0, 1, %1\n"
8431 +" addcc %0, 1, %1\n"
8432 +
8433 +#ifdef CONFIG_PAX_REFCOUNT
8434 +" tvs %%icc, 6\n"
8435 +#endif
8436 +
8437 " cas [%2], %0, %1\n"
8438 " cmp %0, %1\n"
8439 " bne,pn %%icc, 1b\n"
8440 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8441 return tmp1;
8442 }
8443
8444 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8445 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8446 {
8447 unsigned long tmp1, tmp2;
8448
8449 __asm__ __volatile__(
8450 "1: lduw [%2], %0\n"
8451 -" sub %0, 1, %1\n"
8452 +" subcc %0, 1, %1\n"
8453 +
8454 +#ifdef CONFIG_PAX_REFCOUNT
8455 +" tvs %%icc, 6\n"
8456 +#endif
8457 +
8458 " cas [%2], %0, %1\n"
8459 " cmp %0, %1\n"
8460 " bne,pn %%xcc, 1b\n"
8461 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8462 : "memory");
8463 }
8464
8465 -static void inline arch_write_lock(arch_rwlock_t *lock)
8466 +static inline void arch_write_lock(arch_rwlock_t *lock)
8467 {
8468 unsigned long mask, tmp1, tmp2;
8469
8470 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8471 : "memory");
8472 }
8473
8474 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8475 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8476 {
8477 __asm__ __volatile__(
8478 " stw %%g0, [%0]"
8479 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8480 : "memory");
8481 }
8482
8483 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8484 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8485 {
8486 unsigned long mask, tmp1, tmp2, result;
8487
8488 diff --git a/arch/sparc/include/asm/switch_to_64.h b/arch/sparc/include/asm/switch_to_64.h
8489 index cad36f5..c7de332 100644
8490 --- a/arch/sparc/include/asm/switch_to_64.h
8491 +++ b/arch/sparc/include/asm/switch_to_64.h
8492 @@ -18,8 +18,7 @@ do { \
8493 * and 2 stores in this critical code path. -DaveM
8494 */
8495 #define switch_to(prev, next, last) \
8496 -do { flush_tlb_pending(); \
8497 - save_and_clear_fpu(); \
8498 +do { save_and_clear_fpu(); \
8499 /* If you are tempted to conditionalize the following */ \
8500 /* so that ASI is only written if it changes, think again. */ \
8501 __asm__ __volatile__("wr %%g0, %0, %%asi" \
8502 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8503 index 25849ae..924c54b 100644
8504 --- a/arch/sparc/include/asm/thread_info_32.h
8505 +++ b/arch/sparc/include/asm/thread_info_32.h
8506 @@ -49,6 +49,8 @@ struct thread_info {
8507 unsigned long w_saved;
8508
8509 struct restart_block restart_block;
8510 +
8511 + unsigned long lowest_stack;
8512 };
8513
8514 /*
8515 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8516 index 269bd92..e46a9b8 100644
8517 --- a/arch/sparc/include/asm/thread_info_64.h
8518 +++ b/arch/sparc/include/asm/thread_info_64.h
8519 @@ -63,6 +63,8 @@ struct thread_info {
8520 struct pt_regs *kern_una_regs;
8521 unsigned int kern_una_insn;
8522
8523 + unsigned long lowest_stack;
8524 +
8525 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8526 };
8527
8528 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8529 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8530 /* flag bit 6 is available */
8531 #define TIF_32BIT 7 /* 32-bit binary */
8532 -/* flag bit 8 is available */
8533 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8534 #define TIF_SECCOMP 9 /* secure computing */
8535 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8536 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8537 +
8538 /* NOTE: Thread flags >= 12 should be ones we have no interest
8539 * in using in assembly, else we can't use the mask as
8540 * an immediate value in instructions such as andcc.
8541 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8542 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8543 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8544 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8545 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8546
8547 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8548 _TIF_DO_NOTIFY_RESUME_MASK | \
8549 _TIF_NEED_RESCHED)
8550 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8551
8552 +#define _TIF_WORK_SYSCALL \
8553 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8554 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8555 +
8556 +
8557 /*
8558 * Thread-synchronous status.
8559 *
8560 diff --git a/arch/sparc/include/asm/tlbflush_64.h b/arch/sparc/include/asm/tlbflush_64.h
8561 index 2ef4634..f0d6a97 100644
8562 --- a/arch/sparc/include/asm/tlbflush_64.h
8563 +++ b/arch/sparc/include/asm/tlbflush_64.h
8564 @@ -11,24 +11,40 @@
8565 struct tlb_batch {
8566 struct mm_struct *mm;
8567 unsigned long tlb_nr;
8568 + unsigned long active;
8569 unsigned long vaddrs[TLB_BATCH_NR];
8570 };
8571
8572 extern void flush_tsb_kernel_range(unsigned long start, unsigned long end);
8573 extern void flush_tsb_user(struct tlb_batch *tb);
8574 +extern void flush_tsb_user_page(struct mm_struct *mm, unsigned long vaddr);
8575
8576 /* TLB flush operations. */
8577
8578 +static inline void flush_tlb_mm(struct mm_struct *mm)
8579 +{
8580 +}
8581 +
8582 +static inline void flush_tlb_page(struct vm_area_struct *vma,
8583 + unsigned long vmaddr)
8584 +{
8585 +}
8586 +
8587 +static inline void flush_tlb_range(struct vm_area_struct *vma,
8588 + unsigned long start, unsigned long end)
8589 +{
8590 +}
8591 +
8592 +#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
8593 +
8594 extern void flush_tlb_pending(void);
8595 -
8596 -#define flush_tlb_range(vma,start,end) \
8597 - do { (void)(start); flush_tlb_pending(); } while (0)
8598 -#define flush_tlb_page(vma,addr) flush_tlb_pending()
8599 -#define flush_tlb_mm(mm) flush_tlb_pending()
8600 +extern void arch_enter_lazy_mmu_mode(void);
8601 +extern void arch_leave_lazy_mmu_mode(void);
8602 +#define arch_flush_lazy_mmu_mode() do {} while (0)
8603
8604 /* Local cpu only. */
8605 extern void __flush_tlb_all(void);
8606 -
8607 +extern void __flush_tlb_page(unsigned long context, unsigned long vaddr);
8608 extern void __flush_tlb_kernel_range(unsigned long start, unsigned long end);
8609
8610 #ifndef CONFIG_SMP
8611 @@ -38,15 +54,24 @@ do { flush_tsb_kernel_range(start,end); \
8612 __flush_tlb_kernel_range(start,end); \
8613 } while (0)
8614
8615 +static inline void global_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr)
8616 +{
8617 + __flush_tlb_page(CTX_HWBITS(mm->context), vaddr);
8618 +}
8619 +
8620 #else /* CONFIG_SMP */
8621
8622 extern void smp_flush_tlb_kernel_range(unsigned long start, unsigned long end);
8623 +extern void smp_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr);
8624
8625 #define flush_tlb_kernel_range(start, end) \
8626 do { flush_tsb_kernel_range(start,end); \
8627 smp_flush_tlb_kernel_range(start, end); \
8628 } while (0)
8629
8630 +#define global_flush_tlb_page(mm, vaddr) \
8631 + smp_flush_tlb_page(mm, vaddr)
8632 +
8633 #endif /* ! CONFIG_SMP */
8634
8635 #endif /* _SPARC64_TLBFLUSH_H */
8636 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8637 index 0167d26..767bb0c 100644
8638 --- a/arch/sparc/include/asm/uaccess.h
8639 +++ b/arch/sparc/include/asm/uaccess.h
8640 @@ -1,5 +1,6 @@
8641 #ifndef ___ASM_SPARC_UACCESS_H
8642 #define ___ASM_SPARC_UACCESS_H
8643 +
8644 #if defined(__sparc__) && defined(__arch64__)
8645 #include <asm/uaccess_64.h>
8646 #else
8647 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8648 index 53a28dd..50c38c3 100644
8649 --- a/arch/sparc/include/asm/uaccess_32.h
8650 +++ b/arch/sparc/include/asm/uaccess_32.h
8651 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8652
8653 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8654 {
8655 - if (n && __access_ok((unsigned long) to, n))
8656 + if ((long)n < 0)
8657 + return n;
8658 +
8659 + if (n && __access_ok((unsigned long) to, n)) {
8660 + if (!__builtin_constant_p(n))
8661 + check_object_size(from, n, true);
8662 return __copy_user(to, (__force void __user *) from, n);
8663 - else
8664 + } else
8665 return n;
8666 }
8667
8668 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8669 {
8670 + if ((long)n < 0)
8671 + return n;
8672 +
8673 + if (!__builtin_constant_p(n))
8674 + check_object_size(from, n, true);
8675 +
8676 return __copy_user(to, (__force void __user *) from, n);
8677 }
8678
8679 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8680 {
8681 - if (n && __access_ok((unsigned long) from, n))
8682 + if ((long)n < 0)
8683 + return n;
8684 +
8685 + if (n && __access_ok((unsigned long) from, n)) {
8686 + if (!__builtin_constant_p(n))
8687 + check_object_size(to, n, false);
8688 return __copy_user((__force void __user *) to, from, n);
8689 - else
8690 + } else
8691 return n;
8692 }
8693
8694 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8695 {
8696 + if ((long)n < 0)
8697 + return n;
8698 +
8699 return __copy_user((__force void __user *) to, from, n);
8700 }
8701
8702 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8703 index e562d3c..191f176 100644
8704 --- a/arch/sparc/include/asm/uaccess_64.h
8705 +++ b/arch/sparc/include/asm/uaccess_64.h
8706 @@ -10,6 +10,7 @@
8707 #include <linux/compiler.h>
8708 #include <linux/string.h>
8709 #include <linux/thread_info.h>
8710 +#include <linux/kernel.h>
8711 #include <asm/asi.h>
8712 #include <asm/spitfire.h>
8713 #include <asm-generic/uaccess-unaligned.h>
8714 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8715 static inline unsigned long __must_check
8716 copy_from_user(void *to, const void __user *from, unsigned long size)
8717 {
8718 - unsigned long ret = ___copy_from_user(to, from, size);
8719 + unsigned long ret;
8720
8721 + if ((long)size < 0 || size > INT_MAX)
8722 + return size;
8723 +
8724 + if (!__builtin_constant_p(size))
8725 + check_object_size(to, size, false);
8726 +
8727 + ret = ___copy_from_user(to, from, size);
8728 if (unlikely(ret))
8729 ret = copy_from_user_fixup(to, from, size);
8730
8731 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8732 static inline unsigned long __must_check
8733 copy_to_user(void __user *to, const void *from, unsigned long size)
8734 {
8735 - unsigned long ret = ___copy_to_user(to, from, size);
8736 + unsigned long ret;
8737
8738 + if ((long)size < 0 || size > INT_MAX)
8739 + return size;
8740 +
8741 + if (!__builtin_constant_p(size))
8742 + check_object_size(from, size, true);
8743 +
8744 + ret = ___copy_to_user(to, from, size);
8745 if (unlikely(ret))
8746 ret = copy_to_user_fixup(to, from, size);
8747 return ret;
8748 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8749 index 6cf591b..b49e65a 100644
8750 --- a/arch/sparc/kernel/Makefile
8751 +++ b/arch/sparc/kernel/Makefile
8752 @@ -3,7 +3,7 @@
8753 #
8754
8755 asflags-y := -ansi
8756 -ccflags-y := -Werror
8757 +#ccflags-y := -Werror
8758
8759 extra-y := head_$(BITS).o
8760
8761 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8762 index be8e862..5b50b12 100644
8763 --- a/arch/sparc/kernel/process_32.c
8764 +++ b/arch/sparc/kernel/process_32.c
8765 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8766
8767 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8768 r->psr, r->pc, r->npc, r->y, print_tainted());
8769 - printk("PC: <%pS>\n", (void *) r->pc);
8770 + printk("PC: <%pA>\n", (void *) r->pc);
8771 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8772 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8773 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8774 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8775 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8776 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8777 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8778 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8779
8780 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8781 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8782 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8783 rw = (struct reg_window32 *) fp;
8784 pc = rw->ins[7];
8785 printk("[%08lx : ", pc);
8786 - printk("%pS ] ", (void *) pc);
8787 + printk("%pA ] ", (void *) pc);
8788 fp = rw->ins[6];
8789 } while (++count < 16);
8790 printk("\n");
8791 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8792 index cdb80b2..5ca141d 100644
8793 --- a/arch/sparc/kernel/process_64.c
8794 +++ b/arch/sparc/kernel/process_64.c
8795 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8796 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8797 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8798 if (regs->tstate & TSTATE_PRIV)
8799 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8800 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8801 }
8802
8803 void show_regs(struct pt_regs *regs)
8804 {
8805 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8806 regs->tpc, regs->tnpc, regs->y, print_tainted());
8807 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8808 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8809 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8810 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8811 regs->u_regs[3]);
8812 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8813 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8814 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8815 regs->u_regs[15]);
8816 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8817 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8818 show_regwindow(regs);
8819 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8820 }
8821 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8822 ((tp && tp->task) ? tp->task->pid : -1));
8823
8824 if (gp->tstate & TSTATE_PRIV) {
8825 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8826 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8827 (void *) gp->tpc,
8828 (void *) gp->o7,
8829 (void *) gp->i7,
8830 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8831 index 1303021..c2a6321 100644
8832 --- a/arch/sparc/kernel/prom_common.c
8833 +++ b/arch/sparc/kernel/prom_common.c
8834 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8835
8836 unsigned int prom_early_allocated __initdata;
8837
8838 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8839 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8840 .nextprop = prom_common_nextprop,
8841 .getproplen = prom_getproplen,
8842 .getproperty = prom_getproperty,
8843 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8844 index 7ff45e4..a58f271 100644
8845 --- a/arch/sparc/kernel/ptrace_64.c
8846 +++ b/arch/sparc/kernel/ptrace_64.c
8847 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8848 return ret;
8849 }
8850
8851 +#ifdef CONFIG_GRKERNSEC_SETXID
8852 +extern void gr_delayed_cred_worker(void);
8853 +#endif
8854 +
8855 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8856 {
8857 int ret = 0;
8858 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8859 /* do the secure computing check first */
8860 secure_computing_strict(regs->u_regs[UREG_G1]);
8861
8862 +#ifdef CONFIG_GRKERNSEC_SETXID
8863 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8864 + gr_delayed_cred_worker();
8865 +#endif
8866 +
8867 if (test_thread_flag(TIF_SYSCALL_TRACE))
8868 ret = tracehook_report_syscall_entry(regs);
8869
8870 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8871
8872 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8873 {
8874 +#ifdef CONFIG_GRKERNSEC_SETXID
8875 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8876 + gr_delayed_cred_worker();
8877 +#endif
8878 +
8879 audit_syscall_exit(regs);
8880
8881 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8882 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
8883 index 537eb66..ca64d2a 100644
8884 --- a/arch/sparc/kernel/smp_64.c
8885 +++ b/arch/sparc/kernel/smp_64.c
8886 @@ -849,7 +849,7 @@ void smp_tsb_sync(struct mm_struct *mm)
8887 }
8888
8889 extern unsigned long xcall_flush_tlb_mm;
8890 -extern unsigned long xcall_flush_tlb_pending;
8891 +extern unsigned long xcall_flush_tlb_page;
8892 extern unsigned long xcall_flush_tlb_kernel_range;
8893 extern unsigned long xcall_fetch_glob_regs;
8894 extern unsigned long xcall_fetch_glob_pmu;
8895 @@ -1074,23 +1074,56 @@ local_flush_and_out:
8896 put_cpu();
8897 }
8898
8899 +struct tlb_pending_info {
8900 + unsigned long ctx;
8901 + unsigned long nr;
8902 + unsigned long *vaddrs;
8903 +};
8904 +
8905 +static void tlb_pending_func(void *info)
8906 +{
8907 + struct tlb_pending_info *t = info;
8908 +
8909 + __flush_tlb_pending(t->ctx, t->nr, t->vaddrs);
8910 +}
8911 +
8912 void smp_flush_tlb_pending(struct mm_struct *mm, unsigned long nr, unsigned long *vaddrs)
8913 {
8914 u32 ctx = CTX_HWBITS(mm->context);
8915 + struct tlb_pending_info info;
8916 int cpu = get_cpu();
8917
8918 + info.ctx = ctx;
8919 + info.nr = nr;
8920 + info.vaddrs = vaddrs;
8921 +
8922 if (mm == current->mm && atomic_read(&mm->mm_users) == 1)
8923 cpumask_copy(mm_cpumask(mm), cpumask_of(cpu));
8924 else
8925 - smp_cross_call_masked(&xcall_flush_tlb_pending,
8926 - ctx, nr, (unsigned long) vaddrs,
8927 - mm_cpumask(mm));
8928 + smp_call_function_many(mm_cpumask(mm), tlb_pending_func,
8929 + &info, 1);
8930
8931 __flush_tlb_pending(ctx, nr, vaddrs);
8932
8933 put_cpu();
8934 }
8935
8936 +void smp_flush_tlb_page(struct mm_struct *mm, unsigned long vaddr)
8937 +{
8938 + unsigned long context = CTX_HWBITS(mm->context);
8939 + int cpu = get_cpu();
8940 +
8941 + if (mm == current->mm && atomic_read(&mm->mm_users) == 1)
8942 + cpumask_copy(mm_cpumask(mm), cpumask_of(cpu));
8943 + else
8944 + smp_cross_call_masked(&xcall_flush_tlb_page,
8945 + context, vaddr, 0,
8946 + mm_cpumask(mm));
8947 + __flush_tlb_page(context, vaddr);
8948 +
8949 + put_cpu();
8950 +}
8951 +
8952 void smp_flush_tlb_kernel_range(unsigned long start, unsigned long end)
8953 {
8954 start &= PAGE_MASK;
8955 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8956 index 2da0bdc..79128d2 100644
8957 --- a/arch/sparc/kernel/sys_sparc_32.c
8958 +++ b/arch/sparc/kernel/sys_sparc_32.c
8959 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8960 if (len > TASK_SIZE - PAGE_SIZE)
8961 return -ENOMEM;
8962 if (!addr)
8963 - addr = TASK_UNMAPPED_BASE;
8964 + addr = current->mm->mmap_base;
8965
8966 info.flags = 0;
8967 info.length = len;
8968 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8969 index 708bc29..f0129cb 100644
8970 --- a/arch/sparc/kernel/sys_sparc_64.c
8971 +++ b/arch/sparc/kernel/sys_sparc_64.c
8972 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8973 struct vm_area_struct * vma;
8974 unsigned long task_size = TASK_SIZE;
8975 int do_color_align;
8976 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8977 struct vm_unmapped_area_info info;
8978
8979 if (flags & MAP_FIXED) {
8980 /* We do not accept a shared mapping if it would violate
8981 * cache aliasing constraints.
8982 */
8983 - if ((flags & MAP_SHARED) &&
8984 + if ((filp || (flags & MAP_SHARED)) &&
8985 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8986 return -EINVAL;
8987 return addr;
8988 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8989 if (filp || (flags & MAP_SHARED))
8990 do_color_align = 1;
8991
8992 +#ifdef CONFIG_PAX_RANDMMAP
8993 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8994 +#endif
8995 +
8996 if (addr) {
8997 if (do_color_align)
8998 addr = COLOR_ALIGN(addr, pgoff);
8999 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9000 addr = PAGE_ALIGN(addr);
9001
9002 vma = find_vma(mm, addr);
9003 - if (task_size - len >= addr &&
9004 - (!vma || addr + len <= vma->vm_start))
9005 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9006 return addr;
9007 }
9008
9009 info.flags = 0;
9010 info.length = len;
9011 - info.low_limit = TASK_UNMAPPED_BASE;
9012 + info.low_limit = mm->mmap_base;
9013 info.high_limit = min(task_size, VA_EXCLUDE_START);
9014 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9015 info.align_offset = pgoff << PAGE_SHIFT;
9016 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9017 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9018 VM_BUG_ON(addr != -ENOMEM);
9019 info.low_limit = VA_EXCLUDE_END;
9020 +
9021 +#ifdef CONFIG_PAX_RANDMMAP
9022 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9023 + info.low_limit += mm->delta_mmap;
9024 +#endif
9025 +
9026 info.high_limit = task_size;
9027 addr = vm_unmapped_area(&info);
9028 }
9029 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9030 unsigned long task_size = STACK_TOP32;
9031 unsigned long addr = addr0;
9032 int do_color_align;
9033 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9034 struct vm_unmapped_area_info info;
9035
9036 /* This should only ever run for 32-bit processes. */
9037 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9038 /* We do not accept a shared mapping if it would violate
9039 * cache aliasing constraints.
9040 */
9041 - if ((flags & MAP_SHARED) &&
9042 + if ((filp || (flags & MAP_SHARED)) &&
9043 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9044 return -EINVAL;
9045 return addr;
9046 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9047 if (filp || (flags & MAP_SHARED))
9048 do_color_align = 1;
9049
9050 +#ifdef CONFIG_PAX_RANDMMAP
9051 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9052 +#endif
9053 +
9054 /* requesting a specific address */
9055 if (addr) {
9056 if (do_color_align)
9057 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9058 addr = PAGE_ALIGN(addr);
9059
9060 vma = find_vma(mm, addr);
9061 - if (task_size - len >= addr &&
9062 - (!vma || addr + len <= vma->vm_start))
9063 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9064 return addr;
9065 }
9066
9067 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9068 VM_BUG_ON(addr != -ENOMEM);
9069 info.flags = 0;
9070 info.low_limit = TASK_UNMAPPED_BASE;
9071 +
9072 +#ifdef CONFIG_PAX_RANDMMAP
9073 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9074 + info.low_limit += mm->delta_mmap;
9075 +#endif
9076 +
9077 info.high_limit = STACK_TOP32;
9078 addr = vm_unmapped_area(&info);
9079 }
9080 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
9081 {
9082 unsigned long rnd = 0UL;
9083
9084 +#ifdef CONFIG_PAX_RANDMMAP
9085 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9086 +#endif
9087 +
9088 if (current->flags & PF_RANDOMIZE) {
9089 unsigned long val = get_random_int();
9090 if (test_thread_flag(TIF_32BIT))
9091 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9092 gap == RLIM_INFINITY ||
9093 sysctl_legacy_va_layout) {
9094 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9095 +
9096 +#ifdef CONFIG_PAX_RANDMMAP
9097 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9098 + mm->mmap_base += mm->delta_mmap;
9099 +#endif
9100 +
9101 mm->get_unmapped_area = arch_get_unmapped_area;
9102 mm->unmap_area = arch_unmap_area;
9103 } else {
9104 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9105 gap = (task_size / 6 * 5);
9106
9107 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9108 +
9109 +#ifdef CONFIG_PAX_RANDMMAP
9110 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9111 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9112 +#endif
9113 +
9114 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9115 mm->unmap_area = arch_unmap_area_topdown;
9116 }
9117 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9118 index e0fed77..604a7e5 100644
9119 --- a/arch/sparc/kernel/syscalls.S
9120 +++ b/arch/sparc/kernel/syscalls.S
9121 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
9122 #endif
9123 .align 32
9124 1: ldx [%g6 + TI_FLAGS], %l5
9125 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9126 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9127 be,pt %icc, rtrap
9128 nop
9129 call syscall_trace_leave
9130 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
9131
9132 srl %i5, 0, %o5 ! IEU1
9133 srl %i2, 0, %o2 ! IEU0 Group
9134 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9135 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9136 bne,pn %icc, linux_syscall_trace32 ! CTI
9137 mov %i0, %l5 ! IEU1
9138 call %l7 ! CTI Group brk forced
9139 @@ -213,7 +213,7 @@ linux_sparc_syscall:
9140
9141 mov %i3, %o3 ! IEU1
9142 mov %i4, %o4 ! IEU0 Group
9143 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9144 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9145 bne,pn %icc, linux_syscall_trace ! CTI Group
9146 mov %i0, %l5 ! IEU0
9147 2: call %l7 ! CTI Group brk forced
9148 @@ -229,7 +229,7 @@ ret_sys_call:
9149
9150 cmp %o0, -ERESTART_RESTARTBLOCK
9151 bgeu,pn %xcc, 1f
9152 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9153 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9154 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9155
9156 2:
9157 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
9158 index 654e8aa..45f431b 100644
9159 --- a/arch/sparc/kernel/sysfs.c
9160 +++ b/arch/sparc/kernel/sysfs.c
9161 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
9162 return NOTIFY_OK;
9163 }
9164
9165 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
9166 +static struct notifier_block sysfs_cpu_nb = {
9167 .notifier_call = sysfs_cpu_notify,
9168 };
9169
9170 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9171 index a5785ea..405c5f7 100644
9172 --- a/arch/sparc/kernel/traps_32.c
9173 +++ b/arch/sparc/kernel/traps_32.c
9174 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9175 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9176 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9177
9178 +extern void gr_handle_kernel_exploit(void);
9179 +
9180 void die_if_kernel(char *str, struct pt_regs *regs)
9181 {
9182 static int die_counter;
9183 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9184 count++ < 30 &&
9185 (((unsigned long) rw) >= PAGE_OFFSET) &&
9186 !(((unsigned long) rw) & 0x7)) {
9187 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9188 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9189 (void *) rw->ins[7]);
9190 rw = (struct reg_window32 *)rw->ins[6];
9191 }
9192 }
9193 printk("Instruction DUMP:");
9194 instruction_dump ((unsigned long *) regs->pc);
9195 - if(regs->psr & PSR_PS)
9196 + if(regs->psr & PSR_PS) {
9197 + gr_handle_kernel_exploit();
9198 do_exit(SIGKILL);
9199 + }
9200 do_exit(SIGSEGV);
9201 }
9202
9203 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9204 index e7ecf15..6520e65 100644
9205 --- a/arch/sparc/kernel/traps_64.c
9206 +++ b/arch/sparc/kernel/traps_64.c
9207 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9208 i + 1,
9209 p->trapstack[i].tstate, p->trapstack[i].tpc,
9210 p->trapstack[i].tnpc, p->trapstack[i].tt);
9211 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9212 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9213 }
9214 }
9215
9216 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9217
9218 lvl -= 0x100;
9219 if (regs->tstate & TSTATE_PRIV) {
9220 +
9221 +#ifdef CONFIG_PAX_REFCOUNT
9222 + if (lvl == 6)
9223 + pax_report_refcount_overflow(regs);
9224 +#endif
9225 +
9226 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9227 die_if_kernel(buffer, regs);
9228 }
9229 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9230 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9231 {
9232 char buffer[32];
9233 -
9234 +
9235 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9236 0, lvl, SIGTRAP) == NOTIFY_STOP)
9237 return;
9238
9239 +#ifdef CONFIG_PAX_REFCOUNT
9240 + if (lvl == 6)
9241 + pax_report_refcount_overflow(regs);
9242 +#endif
9243 +
9244 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9245
9246 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9247 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9248 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9249 printk("%s" "ERROR(%d): ",
9250 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9251 - printk("TPC<%pS>\n", (void *) regs->tpc);
9252 + printk("TPC<%pA>\n", (void *) regs->tpc);
9253 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9254 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9255 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9256 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9257 smp_processor_id(),
9258 (type & 0x1) ? 'I' : 'D',
9259 regs->tpc);
9260 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9261 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9262 panic("Irrecoverable Cheetah+ parity error.");
9263 }
9264
9265 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9266 smp_processor_id(),
9267 (type & 0x1) ? 'I' : 'D',
9268 regs->tpc);
9269 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9270 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9271 }
9272
9273 struct sun4v_error_entry {
9274 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
9275
9276 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
9277 regs->tpc, tl);
9278 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
9279 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
9280 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9281 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
9282 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
9283 (void *) regs->u_regs[UREG_I7]);
9284 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
9285 "pte[%lx] error[%lx]\n",
9286 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
9287
9288 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
9289 regs->tpc, tl);
9290 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
9291 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
9292 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9293 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
9294 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
9295 (void *) regs->u_regs[UREG_I7]);
9296 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
9297 "pte[%lx] error[%lx]\n",
9298 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9299 fp = (unsigned long)sf->fp + STACK_BIAS;
9300 }
9301
9302 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9303 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9304 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9305 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
9306 int index = tsk->curr_ret_stack;
9307 if (tsk->ret_stack && index >= graph) {
9308 pc = tsk->ret_stack[index - graph].ret;
9309 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9310 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9311 graph++;
9312 }
9313 }
9314 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9315 return (struct reg_window *) (fp + STACK_BIAS);
9316 }
9317
9318 +extern void gr_handle_kernel_exploit(void);
9319 +
9320 void die_if_kernel(char *str, struct pt_regs *regs)
9321 {
9322 static int die_counter;
9323 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9324 while (rw &&
9325 count++ < 30 &&
9326 kstack_valid(tp, (unsigned long) rw)) {
9327 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9328 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9329 (void *) rw->ins[7]);
9330
9331 rw = kernel_stack_up(rw);
9332 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9333 }
9334 user_instruction_dump ((unsigned int __user *) regs->tpc);
9335 }
9336 - if (regs->tstate & TSTATE_PRIV)
9337 + if (regs->tstate & TSTATE_PRIV) {
9338 + gr_handle_kernel_exploit();
9339 do_exit(SIGKILL);
9340 + }
9341 do_exit(SIGSEGV);
9342 }
9343 EXPORT_SYMBOL(die_if_kernel);
9344 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
9345 index 8201c25e..072a2a7 100644
9346 --- a/arch/sparc/kernel/unaligned_64.c
9347 +++ b/arch/sparc/kernel/unaligned_64.c
9348 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
9349 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
9350
9351 if (__ratelimit(&ratelimit)) {
9352 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
9353 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
9354 regs->tpc, (void *) regs->tpc);
9355 }
9356 }
9357 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
9358 index eb1624b..f9f4ddb 100644
9359 --- a/arch/sparc/kernel/us3_cpufreq.c
9360 +++ b/arch/sparc/kernel/us3_cpufreq.c
9361 @@ -18,14 +18,12 @@
9362 #include <asm/head.h>
9363 #include <asm/timer.h>
9364
9365 -static struct cpufreq_driver *cpufreq_us3_driver;
9366 -
9367 struct us3_freq_percpu_info {
9368 struct cpufreq_frequency_table table[4];
9369 };
9370
9371 /* Indexed by cpu number. */
9372 -static struct us3_freq_percpu_info *us3_freq_table;
9373 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
9374
9375 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
9376 * in the Safari config register.
9377 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
9378
9379 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
9380 {
9381 - if (cpufreq_us3_driver)
9382 - us3_set_cpu_divider_index(policy->cpu, 0);
9383 + us3_set_cpu_divider_index(policy->cpu, 0);
9384
9385 return 0;
9386 }
9387
9388 +static int __init us3_freq_init(void);
9389 +static void __exit us3_freq_exit(void);
9390 +
9391 +static struct cpufreq_driver cpufreq_us3_driver = {
9392 + .init = us3_freq_cpu_init,
9393 + .verify = us3_freq_verify,
9394 + .target = us3_freq_target,
9395 + .get = us3_freq_get,
9396 + .exit = us3_freq_cpu_exit,
9397 + .owner = THIS_MODULE,
9398 + .name = "UltraSPARC-III",
9399 +
9400 +};
9401 +
9402 static int __init us3_freq_init(void)
9403 {
9404 unsigned long manuf, impl, ver;
9405 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
9406 (impl == CHEETAH_IMPL ||
9407 impl == CHEETAH_PLUS_IMPL ||
9408 impl == JAGUAR_IMPL ||
9409 - impl == PANTHER_IMPL)) {
9410 - struct cpufreq_driver *driver;
9411 -
9412 - ret = -ENOMEM;
9413 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
9414 - if (!driver)
9415 - goto err_out;
9416 -
9417 - us3_freq_table = kzalloc(
9418 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
9419 - GFP_KERNEL);
9420 - if (!us3_freq_table)
9421 - goto err_out;
9422 -
9423 - driver->init = us3_freq_cpu_init;
9424 - driver->verify = us3_freq_verify;
9425 - driver->target = us3_freq_target;
9426 - driver->get = us3_freq_get;
9427 - driver->exit = us3_freq_cpu_exit;
9428 - driver->owner = THIS_MODULE,
9429 - strcpy(driver->name, "UltraSPARC-III");
9430 -
9431 - cpufreq_us3_driver = driver;
9432 - ret = cpufreq_register_driver(driver);
9433 - if (ret)
9434 - goto err_out;
9435 -
9436 - return 0;
9437 -
9438 -err_out:
9439 - if (driver) {
9440 - kfree(driver);
9441 - cpufreq_us3_driver = NULL;
9442 - }
9443 - kfree(us3_freq_table);
9444 - us3_freq_table = NULL;
9445 - return ret;
9446 - }
9447 + impl == PANTHER_IMPL))
9448 + return cpufreq_register_driver(cpufreq_us3_driver);
9449
9450 return -ENODEV;
9451 }
9452
9453 static void __exit us3_freq_exit(void)
9454 {
9455 - if (cpufreq_us3_driver) {
9456 - cpufreq_unregister_driver(cpufreq_us3_driver);
9457 - kfree(cpufreq_us3_driver);
9458 - cpufreq_us3_driver = NULL;
9459 - kfree(us3_freq_table);
9460 - us3_freq_table = NULL;
9461 - }
9462 + cpufreq_unregister_driver(cpufreq_us3_driver);
9463 }
9464
9465 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
9466 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
9467 index 8410065f2..4fd4ca22 100644
9468 --- a/arch/sparc/lib/Makefile
9469 +++ b/arch/sparc/lib/Makefile
9470 @@ -2,7 +2,7 @@
9471 #
9472
9473 asflags-y := -ansi -DST_DIV0=0x02
9474 -ccflags-y := -Werror
9475 +#ccflags-y := -Werror
9476
9477 lib-$(CONFIG_SPARC32) += ashrdi3.o
9478 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9479 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
9480 index 85c233d..68500e0 100644
9481 --- a/arch/sparc/lib/atomic_64.S
9482 +++ b/arch/sparc/lib/atomic_64.S
9483 @@ -17,7 +17,12 @@
9484 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9485 BACKOFF_SETUP(%o2)
9486 1: lduw [%o1], %g1
9487 - add %g1, %o0, %g7
9488 + addcc %g1, %o0, %g7
9489 +
9490 +#ifdef CONFIG_PAX_REFCOUNT
9491 + tvs %icc, 6
9492 +#endif
9493 +
9494 cas [%o1], %g1, %g7
9495 cmp %g1, %g7
9496 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9497 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9498 2: BACKOFF_SPIN(%o2, %o3, 1b)
9499 ENDPROC(atomic_add)
9500
9501 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9502 + BACKOFF_SETUP(%o2)
9503 +1: lduw [%o1], %g1
9504 + add %g1, %o0, %g7
9505 + cas [%o1], %g1, %g7
9506 + cmp %g1, %g7
9507 + bne,pn %icc, 2f
9508 + nop
9509 + retl
9510 + nop
9511 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9512 +ENDPROC(atomic_add_unchecked)
9513 +
9514 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9515 BACKOFF_SETUP(%o2)
9516 1: lduw [%o1], %g1
9517 - sub %g1, %o0, %g7
9518 + subcc %g1, %o0, %g7
9519 +
9520 +#ifdef CONFIG_PAX_REFCOUNT
9521 + tvs %icc, 6
9522 +#endif
9523 +
9524 cas [%o1], %g1, %g7
9525 cmp %g1, %g7
9526 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9527 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9528 2: BACKOFF_SPIN(%o2, %o3, 1b)
9529 ENDPROC(atomic_sub)
9530
9531 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9532 + BACKOFF_SETUP(%o2)
9533 +1: lduw [%o1], %g1
9534 + sub %g1, %o0, %g7
9535 + cas [%o1], %g1, %g7
9536 + cmp %g1, %g7
9537 + bne,pn %icc, 2f
9538 + nop
9539 + retl
9540 + nop
9541 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9542 +ENDPROC(atomic_sub_unchecked)
9543 +
9544 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9545 BACKOFF_SETUP(%o2)
9546 1: lduw [%o1], %g1
9547 - add %g1, %o0, %g7
9548 + addcc %g1, %o0, %g7
9549 +
9550 +#ifdef CONFIG_PAX_REFCOUNT
9551 + tvs %icc, 6
9552 +#endif
9553 +
9554 cas [%o1], %g1, %g7
9555 cmp %g1, %g7
9556 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9557 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9558 2: BACKOFF_SPIN(%o2, %o3, 1b)
9559 ENDPROC(atomic_add_ret)
9560
9561 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9562 + BACKOFF_SETUP(%o2)
9563 +1: lduw [%o1], %g1
9564 + addcc %g1, %o0, %g7
9565 + cas [%o1], %g1, %g7
9566 + cmp %g1, %g7
9567 + bne,pn %icc, 2f
9568 + add %g7, %o0, %g7
9569 + sra %g7, 0, %o0
9570 + retl
9571 + nop
9572 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9573 +ENDPROC(atomic_add_ret_unchecked)
9574 +
9575 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9576 BACKOFF_SETUP(%o2)
9577 1: lduw [%o1], %g1
9578 - sub %g1, %o0, %g7
9579 + subcc %g1, %o0, %g7
9580 +
9581 +#ifdef CONFIG_PAX_REFCOUNT
9582 + tvs %icc, 6
9583 +#endif
9584 +
9585 cas [%o1], %g1, %g7
9586 cmp %g1, %g7
9587 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9588 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9589 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9590 BACKOFF_SETUP(%o2)
9591 1: ldx [%o1], %g1
9592 - add %g1, %o0, %g7
9593 + addcc %g1, %o0, %g7
9594 +
9595 +#ifdef CONFIG_PAX_REFCOUNT
9596 + tvs %xcc, 6
9597 +#endif
9598 +
9599 casx [%o1], %g1, %g7
9600 cmp %g1, %g7
9601 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9602 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9603 2: BACKOFF_SPIN(%o2, %o3, 1b)
9604 ENDPROC(atomic64_add)
9605
9606 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9607 + BACKOFF_SETUP(%o2)
9608 +1: ldx [%o1], %g1
9609 + addcc %g1, %o0, %g7
9610 + casx [%o1], %g1, %g7
9611 + cmp %g1, %g7
9612 + bne,pn %xcc, 2f
9613 + nop
9614 + retl
9615 + nop
9616 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9617 +ENDPROC(atomic64_add_unchecked)
9618 +
9619 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9620 BACKOFF_SETUP(%o2)
9621 1: ldx [%o1], %g1
9622 - sub %g1, %o0, %g7
9623 + subcc %g1, %o0, %g7
9624 +
9625 +#ifdef CONFIG_PAX_REFCOUNT
9626 + tvs %xcc, 6
9627 +#endif
9628 +
9629 casx [%o1], %g1, %g7
9630 cmp %g1, %g7
9631 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9632 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9633 2: BACKOFF_SPIN(%o2, %o3, 1b)
9634 ENDPROC(atomic64_sub)
9635
9636 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9637 + BACKOFF_SETUP(%o2)
9638 +1: ldx [%o1], %g1
9639 + subcc %g1, %o0, %g7
9640 + casx [%o1], %g1, %g7
9641 + cmp %g1, %g7
9642 + bne,pn %xcc, 2f
9643 + nop
9644 + retl
9645 + nop
9646 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9647 +ENDPROC(atomic64_sub_unchecked)
9648 +
9649 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9650 BACKOFF_SETUP(%o2)
9651 1: ldx [%o1], %g1
9652 - add %g1, %o0, %g7
9653 + addcc %g1, %o0, %g7
9654 +
9655 +#ifdef CONFIG_PAX_REFCOUNT
9656 + tvs %xcc, 6
9657 +#endif
9658 +
9659 casx [%o1], %g1, %g7
9660 cmp %g1, %g7
9661 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9662 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9663 2: BACKOFF_SPIN(%o2, %o3, 1b)
9664 ENDPROC(atomic64_add_ret)
9665
9666 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9667 + BACKOFF_SETUP(%o2)
9668 +1: ldx [%o1], %g1
9669 + addcc %g1, %o0, %g7
9670 + casx [%o1], %g1, %g7
9671 + cmp %g1, %g7
9672 + bne,pn %xcc, 2f
9673 + add %g7, %o0, %g7
9674 + mov %g7, %o0
9675 + retl
9676 + nop
9677 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9678 +ENDPROC(atomic64_add_ret_unchecked)
9679 +
9680 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9681 BACKOFF_SETUP(%o2)
9682 1: ldx [%o1], %g1
9683 - sub %g1, %o0, %g7
9684 + subcc %g1, %o0, %g7
9685 +
9686 +#ifdef CONFIG_PAX_REFCOUNT
9687 + tvs %xcc, 6
9688 +#endif
9689 +
9690 casx [%o1], %g1, %g7
9691 cmp %g1, %g7
9692 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9693 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9694 index 0c4e35e..745d3e4 100644
9695 --- a/arch/sparc/lib/ksyms.c
9696 +++ b/arch/sparc/lib/ksyms.c
9697 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9698
9699 /* Atomic counter implementation. */
9700 EXPORT_SYMBOL(atomic_add);
9701 +EXPORT_SYMBOL(atomic_add_unchecked);
9702 EXPORT_SYMBOL(atomic_add_ret);
9703 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9704 EXPORT_SYMBOL(atomic_sub);
9705 +EXPORT_SYMBOL(atomic_sub_unchecked);
9706 EXPORT_SYMBOL(atomic_sub_ret);
9707 EXPORT_SYMBOL(atomic64_add);
9708 +EXPORT_SYMBOL(atomic64_add_unchecked);
9709 EXPORT_SYMBOL(atomic64_add_ret);
9710 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9711 EXPORT_SYMBOL(atomic64_sub);
9712 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9713 EXPORT_SYMBOL(atomic64_sub_ret);
9714 EXPORT_SYMBOL(atomic64_dec_if_positive);
9715
9716 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9717 index 30c3ecc..736f015 100644
9718 --- a/arch/sparc/mm/Makefile
9719 +++ b/arch/sparc/mm/Makefile
9720 @@ -2,7 +2,7 @@
9721 #
9722
9723 asflags-y := -ansi
9724 -ccflags-y := -Werror
9725 +#ccflags-y := -Werror
9726
9727 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9728 obj-y += fault_$(BITS).o
9729 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9730 index e98bfda..ea8d221 100644
9731 --- a/arch/sparc/mm/fault_32.c
9732 +++ b/arch/sparc/mm/fault_32.c
9733 @@ -21,6 +21,9 @@
9734 #include <linux/perf_event.h>
9735 #include <linux/interrupt.h>
9736 #include <linux/kdebug.h>
9737 +#include <linux/slab.h>
9738 +#include <linux/pagemap.h>
9739 +#include <linux/compiler.h>
9740
9741 #include <asm/page.h>
9742 #include <asm/pgtable.h>
9743 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9744 return safe_compute_effective_address(regs, insn);
9745 }
9746
9747 +#ifdef CONFIG_PAX_PAGEEXEC
9748 +#ifdef CONFIG_PAX_DLRESOLVE
9749 +static void pax_emuplt_close(struct vm_area_struct *vma)
9750 +{
9751 + vma->vm_mm->call_dl_resolve = 0UL;
9752 +}
9753 +
9754 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9755 +{
9756 + unsigned int *kaddr;
9757 +
9758 + vmf->page = alloc_page(GFP_HIGHUSER);
9759 + if (!vmf->page)
9760 + return VM_FAULT_OOM;
9761 +
9762 + kaddr = kmap(vmf->page);
9763 + memset(kaddr, 0, PAGE_SIZE);
9764 + kaddr[0] = 0x9DE3BFA8U; /* save */
9765 + flush_dcache_page(vmf->page);
9766 + kunmap(vmf->page);
9767 + return VM_FAULT_MAJOR;
9768 +}
9769 +
9770 +static const struct vm_operations_struct pax_vm_ops = {
9771 + .close = pax_emuplt_close,
9772 + .fault = pax_emuplt_fault
9773 +};
9774 +
9775 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9776 +{
9777 + int ret;
9778 +
9779 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9780 + vma->vm_mm = current->mm;
9781 + vma->vm_start = addr;
9782 + vma->vm_end = addr + PAGE_SIZE;
9783 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9784 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9785 + vma->vm_ops = &pax_vm_ops;
9786 +
9787 + ret = insert_vm_struct(current->mm, vma);
9788 + if (ret)
9789 + return ret;
9790 +
9791 + ++current->mm->total_vm;
9792 + return 0;
9793 +}
9794 +#endif
9795 +
9796 +/*
9797 + * PaX: decide what to do with offenders (regs->pc = fault address)
9798 + *
9799 + * returns 1 when task should be killed
9800 + * 2 when patched PLT trampoline was detected
9801 + * 3 when unpatched PLT trampoline was detected
9802 + */
9803 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9804 +{
9805 +
9806 +#ifdef CONFIG_PAX_EMUPLT
9807 + int err;
9808 +
9809 + do { /* PaX: patched PLT emulation #1 */
9810 + unsigned int sethi1, sethi2, jmpl;
9811 +
9812 + err = get_user(sethi1, (unsigned int *)regs->pc);
9813 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9814 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9815 +
9816 + if (err)
9817 + break;
9818 +
9819 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9820 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9821 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9822 + {
9823 + unsigned int addr;
9824 +
9825 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9826 + addr = regs->u_regs[UREG_G1];
9827 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9828 + regs->pc = addr;
9829 + regs->npc = addr+4;
9830 + return 2;
9831 + }
9832 + } while (0);
9833 +
9834 + do { /* PaX: patched PLT emulation #2 */
9835 + unsigned int ba;
9836 +
9837 + err = get_user(ba, (unsigned int *)regs->pc);
9838 +
9839 + if (err)
9840 + break;
9841 +
9842 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9843 + unsigned int addr;
9844 +
9845 + if ((ba & 0xFFC00000U) == 0x30800000U)
9846 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9847 + else
9848 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9849 + regs->pc = addr;
9850 + regs->npc = addr+4;
9851 + return 2;
9852 + }
9853 + } while (0);
9854 +
9855 + do { /* PaX: patched PLT emulation #3 */
9856 + unsigned int sethi, bajmpl, nop;
9857 +
9858 + err = get_user(sethi, (unsigned int *)regs->pc);
9859 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9860 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9861 +
9862 + if (err)
9863 + break;
9864 +
9865 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9866 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9867 + nop == 0x01000000U)
9868 + {
9869 + unsigned int addr;
9870 +
9871 + addr = (sethi & 0x003FFFFFU) << 10;
9872 + regs->u_regs[UREG_G1] = addr;
9873 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9874 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9875 + else
9876 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9877 + regs->pc = addr;
9878 + regs->npc = addr+4;
9879 + return 2;
9880 + }
9881 + } while (0);
9882 +
9883 + do { /* PaX: unpatched PLT emulation step 1 */
9884 + unsigned int sethi, ba, nop;
9885 +
9886 + err = get_user(sethi, (unsigned int *)regs->pc);
9887 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9888 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9889 +
9890 + if (err)
9891 + break;
9892 +
9893 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9894 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9895 + nop == 0x01000000U)
9896 + {
9897 + unsigned int addr, save, call;
9898 +
9899 + if ((ba & 0xFFC00000U) == 0x30800000U)
9900 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9901 + else
9902 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9903 +
9904 + err = get_user(save, (unsigned int *)addr);
9905 + err |= get_user(call, (unsigned int *)(addr+4));
9906 + err |= get_user(nop, (unsigned int *)(addr+8));
9907 + if (err)
9908 + break;
9909 +
9910 +#ifdef CONFIG_PAX_DLRESOLVE
9911 + if (save == 0x9DE3BFA8U &&
9912 + (call & 0xC0000000U) == 0x40000000U &&
9913 + nop == 0x01000000U)
9914 + {
9915 + struct vm_area_struct *vma;
9916 + unsigned long call_dl_resolve;
9917 +
9918 + down_read(&current->mm->mmap_sem);
9919 + call_dl_resolve = current->mm->call_dl_resolve;
9920 + up_read(&current->mm->mmap_sem);
9921 + if (likely(call_dl_resolve))
9922 + goto emulate;
9923 +
9924 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9925 +
9926 + down_write(&current->mm->mmap_sem);
9927 + if (current->mm->call_dl_resolve) {
9928 + call_dl_resolve = current->mm->call_dl_resolve;
9929 + up_write(&current->mm->mmap_sem);
9930 + if (vma)
9931 + kmem_cache_free(vm_area_cachep, vma);
9932 + goto emulate;
9933 + }
9934 +
9935 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9936 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9937 + up_write(&current->mm->mmap_sem);
9938 + if (vma)
9939 + kmem_cache_free(vm_area_cachep, vma);
9940 + return 1;
9941 + }
9942 +
9943 + if (pax_insert_vma(vma, call_dl_resolve)) {
9944 + up_write(&current->mm->mmap_sem);
9945 + kmem_cache_free(vm_area_cachep, vma);
9946 + return 1;
9947 + }
9948 +
9949 + current->mm->call_dl_resolve = call_dl_resolve;
9950 + up_write(&current->mm->mmap_sem);
9951 +
9952 +emulate:
9953 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9954 + regs->pc = call_dl_resolve;
9955 + regs->npc = addr+4;
9956 + return 3;
9957 + }
9958 +#endif
9959 +
9960 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9961 + if ((save & 0xFFC00000U) == 0x05000000U &&
9962 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9963 + nop == 0x01000000U)
9964 + {
9965 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9966 + regs->u_regs[UREG_G2] = addr + 4;
9967 + addr = (save & 0x003FFFFFU) << 10;
9968 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9969 + regs->pc = addr;
9970 + regs->npc = addr+4;
9971 + return 3;
9972 + }
9973 + }
9974 + } while (0);
9975 +
9976 + do { /* PaX: unpatched PLT emulation step 2 */
9977 + unsigned int save, call, nop;
9978 +
9979 + err = get_user(save, (unsigned int *)(regs->pc-4));
9980 + err |= get_user(call, (unsigned int *)regs->pc);
9981 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9982 + if (err)
9983 + break;
9984 +
9985 + if (save == 0x9DE3BFA8U &&
9986 + (call & 0xC0000000U) == 0x40000000U &&
9987 + nop == 0x01000000U)
9988 + {
9989 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9990 +
9991 + regs->u_regs[UREG_RETPC] = regs->pc;
9992 + regs->pc = dl_resolve;
9993 + regs->npc = dl_resolve+4;
9994 + return 3;
9995 + }
9996 + } while (0);
9997 +#endif
9998 +
9999 + return 1;
10000 +}
10001 +
10002 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10003 +{
10004 + unsigned long i;
10005 +
10006 + printk(KERN_ERR "PAX: bytes at PC: ");
10007 + for (i = 0; i < 8; i++) {
10008 + unsigned int c;
10009 + if (get_user(c, (unsigned int *)pc+i))
10010 + printk(KERN_CONT "???????? ");
10011 + else
10012 + printk(KERN_CONT "%08x ", c);
10013 + }
10014 + printk("\n");
10015 +}
10016 +#endif
10017 +
10018 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10019 int text_fault)
10020 {
10021 @@ -230,6 +504,24 @@ good_area:
10022 if (!(vma->vm_flags & VM_WRITE))
10023 goto bad_area;
10024 } else {
10025 +
10026 +#ifdef CONFIG_PAX_PAGEEXEC
10027 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10028 + up_read(&mm->mmap_sem);
10029 + switch (pax_handle_fetch_fault(regs)) {
10030 +
10031 +#ifdef CONFIG_PAX_EMUPLT
10032 + case 2:
10033 + case 3:
10034 + return;
10035 +#endif
10036 +
10037 + }
10038 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10039 + do_group_exit(SIGKILL);
10040 + }
10041 +#endif
10042 +
10043 /* Allow reads even for write-only mappings */
10044 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10045 goto bad_area;
10046 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10047 index 5062ff3..e0b75f3 100644
10048 --- a/arch/sparc/mm/fault_64.c
10049 +++ b/arch/sparc/mm/fault_64.c
10050 @@ -21,6 +21,9 @@
10051 #include <linux/kprobes.h>
10052 #include <linux/kdebug.h>
10053 #include <linux/percpu.h>
10054 +#include <linux/slab.h>
10055 +#include <linux/pagemap.h>
10056 +#include <linux/compiler.h>
10057
10058 #include <asm/page.h>
10059 #include <asm/pgtable.h>
10060 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10061 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10062 regs->tpc);
10063 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10064 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10065 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10066 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10067 dump_stack();
10068 unhandled_fault(regs->tpc, current, regs);
10069 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10070 show_regs(regs);
10071 }
10072
10073 +#ifdef CONFIG_PAX_PAGEEXEC
10074 +#ifdef CONFIG_PAX_DLRESOLVE
10075 +static void pax_emuplt_close(struct vm_area_struct *vma)
10076 +{
10077 + vma->vm_mm->call_dl_resolve = 0UL;
10078 +}
10079 +
10080 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10081 +{
10082 + unsigned int *kaddr;
10083 +
10084 + vmf->page = alloc_page(GFP_HIGHUSER);
10085 + if (!vmf->page)
10086 + return VM_FAULT_OOM;
10087 +
10088 + kaddr = kmap(vmf->page);
10089 + memset(kaddr, 0, PAGE_SIZE);
10090 + kaddr[0] = 0x9DE3BFA8U; /* save */
10091 + flush_dcache_page(vmf->page);
10092 + kunmap(vmf->page);
10093 + return VM_FAULT_MAJOR;
10094 +}
10095 +
10096 +static const struct vm_operations_struct pax_vm_ops = {
10097 + .close = pax_emuplt_close,
10098 + .fault = pax_emuplt_fault
10099 +};
10100 +
10101 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10102 +{
10103 + int ret;
10104 +
10105 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10106 + vma->vm_mm = current->mm;
10107 + vma->vm_start = addr;
10108 + vma->vm_end = addr + PAGE_SIZE;
10109 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10110 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10111 + vma->vm_ops = &pax_vm_ops;
10112 +
10113 + ret = insert_vm_struct(current->mm, vma);
10114 + if (ret)
10115 + return ret;
10116 +
10117 + ++current->mm->total_vm;
10118 + return 0;
10119 +}
10120 +#endif
10121 +
10122 +/*
10123 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10124 + *
10125 + * returns 1 when task should be killed
10126 + * 2 when patched PLT trampoline was detected
10127 + * 3 when unpatched PLT trampoline was detected
10128 + */
10129 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10130 +{
10131 +
10132 +#ifdef CONFIG_PAX_EMUPLT
10133 + int err;
10134 +
10135 + do { /* PaX: patched PLT emulation #1 */
10136 + unsigned int sethi1, sethi2, jmpl;
10137 +
10138 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10139 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10140 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10141 +
10142 + if (err)
10143 + break;
10144 +
10145 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10146 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10147 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10148 + {
10149 + unsigned long addr;
10150 +
10151 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10152 + addr = regs->u_regs[UREG_G1];
10153 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10154 +
10155 + if (test_thread_flag(TIF_32BIT))
10156 + addr &= 0xFFFFFFFFUL;
10157 +
10158 + regs->tpc = addr;
10159 + regs->tnpc = addr+4;
10160 + return 2;
10161 + }
10162 + } while (0);
10163 +
10164 + do { /* PaX: patched PLT emulation #2 */
10165 + unsigned int ba;
10166 +
10167 + err = get_user(ba, (unsigned int *)regs->tpc);
10168 +
10169 + if (err)
10170 + break;
10171 +
10172 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10173 + unsigned long addr;
10174 +
10175 + if ((ba & 0xFFC00000U) == 0x30800000U)
10176 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10177 + else
10178 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10179 +
10180 + if (test_thread_flag(TIF_32BIT))
10181 + addr &= 0xFFFFFFFFUL;
10182 +
10183 + regs->tpc = addr;
10184 + regs->tnpc = addr+4;
10185 + return 2;
10186 + }
10187 + } while (0);
10188 +
10189 + do { /* PaX: patched PLT emulation #3 */
10190 + unsigned int sethi, bajmpl, nop;
10191 +
10192 + err = get_user(sethi, (unsigned int *)regs->tpc);
10193 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10194 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10195 +
10196 + if (err)
10197 + break;
10198 +
10199 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10200 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10201 + nop == 0x01000000U)
10202 + {
10203 + unsigned long addr;
10204 +
10205 + addr = (sethi & 0x003FFFFFU) << 10;
10206 + regs->u_regs[UREG_G1] = addr;
10207 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10208 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10209 + else
10210 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10211 +
10212 + if (test_thread_flag(TIF_32BIT))
10213 + addr &= 0xFFFFFFFFUL;
10214 +
10215 + regs->tpc = addr;
10216 + regs->tnpc = addr+4;
10217 + return 2;
10218 + }
10219 + } while (0);
10220 +
10221 + do { /* PaX: patched PLT emulation #4 */
10222 + unsigned int sethi, mov1, call, mov2;
10223 +
10224 + err = get_user(sethi, (unsigned int *)regs->tpc);
10225 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10226 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10227 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10228 +
10229 + if (err)
10230 + break;
10231 +
10232 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10233 + mov1 == 0x8210000FU &&
10234 + (call & 0xC0000000U) == 0x40000000U &&
10235 + mov2 == 0x9E100001U)
10236 + {
10237 + unsigned long addr;
10238 +
10239 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10240 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10241 +
10242 + if (test_thread_flag(TIF_32BIT))
10243 + addr &= 0xFFFFFFFFUL;
10244 +
10245 + regs->tpc = addr;
10246 + regs->tnpc = addr+4;
10247 + return 2;
10248 + }
10249 + } while (0);
10250 +
10251 + do { /* PaX: patched PLT emulation #5 */
10252 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10253 +
10254 + err = get_user(sethi, (unsigned int *)regs->tpc);
10255 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10256 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10257 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10258 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10259 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10260 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10261 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10262 +
10263 + if (err)
10264 + break;
10265 +
10266 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10267 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10268 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10269 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10270 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10271 + sllx == 0x83287020U &&
10272 + jmpl == 0x81C04005U &&
10273 + nop == 0x01000000U)
10274 + {
10275 + unsigned long addr;
10276 +
10277 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10278 + regs->u_regs[UREG_G1] <<= 32;
10279 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10280 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10281 + regs->tpc = addr;
10282 + regs->tnpc = addr+4;
10283 + return 2;
10284 + }
10285 + } while (0);
10286 +
10287 + do { /* PaX: patched PLT emulation #6 */
10288 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10289 +
10290 + err = get_user(sethi, (unsigned int *)regs->tpc);
10291 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10292 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10293 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10294 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10295 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10296 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10297 +
10298 + if (err)
10299 + break;
10300 +
10301 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10302 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10303 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10304 + sllx == 0x83287020U &&
10305 + (or & 0xFFFFE000U) == 0x8A116000U &&
10306 + jmpl == 0x81C04005U &&
10307 + nop == 0x01000000U)
10308 + {
10309 + unsigned long addr;
10310 +
10311 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10312 + regs->u_regs[UREG_G1] <<= 32;
10313 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10314 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10315 + regs->tpc = addr;
10316 + regs->tnpc = addr+4;
10317 + return 2;
10318 + }
10319 + } while (0);
10320 +
10321 + do { /* PaX: unpatched PLT emulation step 1 */
10322 + unsigned int sethi, ba, nop;
10323 +
10324 + err = get_user(sethi, (unsigned int *)regs->tpc);
10325 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10326 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10327 +
10328 + if (err)
10329 + break;
10330 +
10331 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10332 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10333 + nop == 0x01000000U)
10334 + {
10335 + unsigned long addr;
10336 + unsigned int save, call;
10337 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10338 +
10339 + if ((ba & 0xFFC00000U) == 0x30800000U)
10340 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10341 + else
10342 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10343 +
10344 + if (test_thread_flag(TIF_32BIT))
10345 + addr &= 0xFFFFFFFFUL;
10346 +
10347 + err = get_user(save, (unsigned int *)addr);
10348 + err |= get_user(call, (unsigned int *)(addr+4));
10349 + err |= get_user(nop, (unsigned int *)(addr+8));
10350 + if (err)
10351 + break;
10352 +
10353 +#ifdef CONFIG_PAX_DLRESOLVE
10354 + if (save == 0x9DE3BFA8U &&
10355 + (call & 0xC0000000U) == 0x40000000U &&
10356 + nop == 0x01000000U)
10357 + {
10358 + struct vm_area_struct *vma;
10359 + unsigned long call_dl_resolve;
10360 +
10361 + down_read(&current->mm->mmap_sem);
10362 + call_dl_resolve = current->mm->call_dl_resolve;
10363 + up_read(&current->mm->mmap_sem);
10364 + if (likely(call_dl_resolve))
10365 + goto emulate;
10366 +
10367 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10368 +
10369 + down_write(&current->mm->mmap_sem);
10370 + if (current->mm->call_dl_resolve) {
10371 + call_dl_resolve = current->mm->call_dl_resolve;
10372 + up_write(&current->mm->mmap_sem);
10373 + if (vma)
10374 + kmem_cache_free(vm_area_cachep, vma);
10375 + goto emulate;
10376 + }
10377 +
10378 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10379 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10380 + up_write(&current->mm->mmap_sem);
10381 + if (vma)
10382 + kmem_cache_free(vm_area_cachep, vma);
10383 + return 1;
10384 + }
10385 +
10386 + if (pax_insert_vma(vma, call_dl_resolve)) {
10387 + up_write(&current->mm->mmap_sem);
10388 + kmem_cache_free(vm_area_cachep, vma);
10389 + return 1;
10390 + }
10391 +
10392 + current->mm->call_dl_resolve = call_dl_resolve;
10393 + up_write(&current->mm->mmap_sem);
10394 +
10395 +emulate:
10396 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10397 + regs->tpc = call_dl_resolve;
10398 + regs->tnpc = addr+4;
10399 + return 3;
10400 + }
10401 +#endif
10402 +
10403 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10404 + if ((save & 0xFFC00000U) == 0x05000000U &&
10405 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10406 + nop == 0x01000000U)
10407 + {
10408 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10409 + regs->u_regs[UREG_G2] = addr + 4;
10410 + addr = (save & 0x003FFFFFU) << 10;
10411 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10412 +
10413 + if (test_thread_flag(TIF_32BIT))
10414 + addr &= 0xFFFFFFFFUL;
10415 +
10416 + regs->tpc = addr;
10417 + regs->tnpc = addr+4;
10418 + return 3;
10419 + }
10420 +
10421 + /* PaX: 64-bit PLT stub */
10422 + err = get_user(sethi1, (unsigned int *)addr);
10423 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10424 + err |= get_user(or1, (unsigned int *)(addr+8));
10425 + err |= get_user(or2, (unsigned int *)(addr+12));
10426 + err |= get_user(sllx, (unsigned int *)(addr+16));
10427 + err |= get_user(add, (unsigned int *)(addr+20));
10428 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10429 + err |= get_user(nop, (unsigned int *)(addr+28));
10430 + if (err)
10431 + break;
10432 +
10433 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10434 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10435 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10436 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10437 + sllx == 0x89293020U &&
10438 + add == 0x8A010005U &&
10439 + jmpl == 0x89C14000U &&
10440 + nop == 0x01000000U)
10441 + {
10442 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10443 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10444 + regs->u_regs[UREG_G4] <<= 32;
10445 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10446 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
10447 + regs->u_regs[UREG_G4] = addr + 24;
10448 + addr = regs->u_regs[UREG_G5];
10449 + regs->tpc = addr;
10450 + regs->tnpc = addr+4;
10451 + return 3;
10452 + }
10453 + }
10454 + } while (0);
10455 +
10456 +#ifdef CONFIG_PAX_DLRESOLVE
10457 + do { /* PaX: unpatched PLT emulation step 2 */
10458 + unsigned int save, call, nop;
10459 +
10460 + err = get_user(save, (unsigned int *)(regs->tpc-4));
10461 + err |= get_user(call, (unsigned int *)regs->tpc);
10462 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
10463 + if (err)
10464 + break;
10465 +
10466 + if (save == 0x9DE3BFA8U &&
10467 + (call & 0xC0000000U) == 0x40000000U &&
10468 + nop == 0x01000000U)
10469 + {
10470 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10471 +
10472 + if (test_thread_flag(TIF_32BIT))
10473 + dl_resolve &= 0xFFFFFFFFUL;
10474 +
10475 + regs->u_regs[UREG_RETPC] = regs->tpc;
10476 + regs->tpc = dl_resolve;
10477 + regs->tnpc = dl_resolve+4;
10478 + return 3;
10479 + }
10480 + } while (0);
10481 +#endif
10482 +
10483 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
10484 + unsigned int sethi, ba, nop;
10485 +
10486 + err = get_user(sethi, (unsigned int *)regs->tpc);
10487 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10488 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10489 +
10490 + if (err)
10491 + break;
10492 +
10493 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10494 + (ba & 0xFFF00000U) == 0x30600000U &&
10495 + nop == 0x01000000U)
10496 + {
10497 + unsigned long addr;
10498 +
10499 + addr = (sethi & 0x003FFFFFU) << 10;
10500 + regs->u_regs[UREG_G1] = addr;
10501 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10502 +
10503 + if (test_thread_flag(TIF_32BIT))
10504 + addr &= 0xFFFFFFFFUL;
10505 +
10506 + regs->tpc = addr;
10507 + regs->tnpc = addr+4;
10508 + return 2;
10509 + }
10510 + } while (0);
10511 +
10512 +#endif
10513 +
10514 + return 1;
10515 +}
10516 +
10517 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10518 +{
10519 + unsigned long i;
10520 +
10521 + printk(KERN_ERR "PAX: bytes at PC: ");
10522 + for (i = 0; i < 8; i++) {
10523 + unsigned int c;
10524 + if (get_user(c, (unsigned int *)pc+i))
10525 + printk(KERN_CONT "???????? ");
10526 + else
10527 + printk(KERN_CONT "%08x ", c);
10528 + }
10529 + printk("\n");
10530 +}
10531 +#endif
10532 +
10533 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
10534 {
10535 struct mm_struct *mm = current->mm;
10536 @@ -341,6 +804,29 @@ retry:
10537 if (!vma)
10538 goto bad_area;
10539
10540 +#ifdef CONFIG_PAX_PAGEEXEC
10541 + /* PaX: detect ITLB misses on non-exec pages */
10542 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
10543 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
10544 + {
10545 + if (address != regs->tpc)
10546 + goto good_area;
10547 +
10548 + up_read(&mm->mmap_sem);
10549 + switch (pax_handle_fetch_fault(regs)) {
10550 +
10551 +#ifdef CONFIG_PAX_EMUPLT
10552 + case 2:
10553 + case 3:
10554 + return;
10555 +#endif
10556 +
10557 + }
10558 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
10559 + do_group_exit(SIGKILL);
10560 + }
10561 +#endif
10562 +
10563 /* Pure DTLB misses do not tell us whether the fault causing
10564 * load/store/atomic was a write or not, it only says that there
10565 * was no match. So in such a case we (carefully) read the
10566 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10567 index d2b5944..bd813f2 100644
10568 --- a/arch/sparc/mm/hugetlbpage.c
10569 +++ b/arch/sparc/mm/hugetlbpage.c
10570 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10571
10572 info.flags = 0;
10573 info.length = len;
10574 - info.low_limit = TASK_UNMAPPED_BASE;
10575 + info.low_limit = mm->mmap_base;
10576 info.high_limit = min(task_size, VA_EXCLUDE_START);
10577 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10578 info.align_offset = 0;
10579 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10580 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10581 VM_BUG_ON(addr != -ENOMEM);
10582 info.low_limit = VA_EXCLUDE_END;
10583 +
10584 +#ifdef CONFIG_PAX_RANDMMAP
10585 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10586 + info.low_limit += mm->delta_mmap;
10587 +#endif
10588 +
10589 info.high_limit = task_size;
10590 addr = vm_unmapped_area(&info);
10591 }
10592 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10593 VM_BUG_ON(addr != -ENOMEM);
10594 info.flags = 0;
10595 info.low_limit = TASK_UNMAPPED_BASE;
10596 +
10597 +#ifdef CONFIG_PAX_RANDMMAP
10598 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10599 + info.low_limit += mm->delta_mmap;
10600 +#endif
10601 +
10602 info.high_limit = STACK_TOP32;
10603 addr = vm_unmapped_area(&info);
10604 }
10605 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10606 struct mm_struct *mm = current->mm;
10607 struct vm_area_struct *vma;
10608 unsigned long task_size = TASK_SIZE;
10609 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10610
10611 if (test_thread_flag(TIF_32BIT))
10612 task_size = STACK_TOP32;
10613 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10614 return addr;
10615 }
10616
10617 +#ifdef CONFIG_PAX_RANDMMAP
10618 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10619 +#endif
10620 +
10621 if (addr) {
10622 addr = ALIGN(addr, HPAGE_SIZE);
10623 vma = find_vma(mm, addr);
10624 - if (task_size - len >= addr &&
10625 - (!vma || addr + len <= vma->vm_start))
10626 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10627 return addr;
10628 }
10629 if (mm->get_unmapped_area == arch_get_unmapped_area)
10630 diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c
10631 index ba6ae7f..83d89bc 100644
10632 --- a/arch/sparc/mm/tlb.c
10633 +++ b/arch/sparc/mm/tlb.c
10634 @@ -24,11 +24,17 @@ static DEFINE_PER_CPU(struct tlb_batch, tlb_batch);
10635 void flush_tlb_pending(void)
10636 {
10637 struct tlb_batch *tb = &get_cpu_var(tlb_batch);
10638 + struct mm_struct *mm = tb->mm;
10639
10640 - if (tb->tlb_nr) {
10641 - flush_tsb_user(tb);
10642 + if (!tb->tlb_nr)
10643 + goto out;
10644
10645 - if (CTX_VALID(tb->mm->context)) {
10646 + flush_tsb_user(tb);
10647 +
10648 + if (CTX_VALID(mm->context)) {
10649 + if (tb->tlb_nr == 1) {
10650 + global_flush_tlb_page(mm, tb->vaddrs[0]);
10651 + } else {
10652 #ifdef CONFIG_SMP
10653 smp_flush_tlb_pending(tb->mm, tb->tlb_nr,
10654 &tb->vaddrs[0]);
10655 @@ -37,12 +43,30 @@ void flush_tlb_pending(void)
10656 tb->tlb_nr, &tb->vaddrs[0]);
10657 #endif
10658 }
10659 - tb->tlb_nr = 0;
10660 }
10661
10662 + tb->tlb_nr = 0;
10663 +
10664 +out:
10665 put_cpu_var(tlb_batch);
10666 }
10667
10668 +void arch_enter_lazy_mmu_mode(void)
10669 +{
10670 + struct tlb_batch *tb = &__get_cpu_var(tlb_batch);
10671 +
10672 + tb->active = 1;
10673 +}
10674 +
10675 +void arch_leave_lazy_mmu_mode(void)
10676 +{
10677 + struct tlb_batch *tb = &__get_cpu_var(tlb_batch);
10678 +
10679 + if (tb->tlb_nr)
10680 + flush_tlb_pending();
10681 + tb->active = 0;
10682 +}
10683 +
10684 static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,
10685 bool exec)
10686 {
10687 @@ -60,6 +84,12 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,
10688 nr = 0;
10689 }
10690
10691 + if (!tb->active) {
10692 + global_flush_tlb_page(mm, vaddr);
10693 + flush_tsb_user_page(mm, vaddr);
10694 + goto out;
10695 + }
10696 +
10697 if (nr == 0)
10698 tb->mm = mm;
10699
10700 @@ -68,6 +98,7 @@ static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,
10701 if (nr >= TLB_BATCH_NR)
10702 flush_tlb_pending();
10703
10704 +out:
10705 put_cpu_var(tlb_batch);
10706 }
10707
10708 diff --git a/arch/sparc/mm/tsb.c b/arch/sparc/mm/tsb.c
10709 index 428982b..2cc3bce 100644
10710 --- a/arch/sparc/mm/tsb.c
10711 +++ b/arch/sparc/mm/tsb.c
10712 @@ -7,11 +7,10 @@
10713 #include <linux/preempt.h>
10714 #include <linux/slab.h>
10715 #include <asm/page.h>
10716 -#include <asm/tlbflush.h>
10717 -#include <asm/tlb.h>
10718 -#include <asm/mmu_context.h>
10719 #include <asm/pgtable.h>
10720 +#include <asm/mmu_context.h>
10721 #include <asm/tsb.h>
10722 +#include <asm/tlb.h>
10723 #include <asm/oplib.h>
10724
10725 extern struct tsb swapper_tsb[KERNEL_TSB_NENTRIES];
10726 @@ -46,23 +45,27 @@ void flush_tsb_kernel_range(unsigned long start, unsigned long end)
10727 }
10728 }
10729
10730 +static void __flush_tsb_one_entry(unsigned long tsb, unsigned long v,
10731 + unsigned long hash_shift,
10732 + unsigned long nentries)
10733 +{
10734 + unsigned long tag, ent, hash;
10735 +
10736 + v &= ~0x1UL;
10737 + hash = tsb_hash(v, hash_shift, nentries);
10738 + ent = tsb + (hash * sizeof(struct tsb));
10739 + tag = (v >> 22UL);
10740 +
10741 + tsb_flush(ent, tag);
10742 +}
10743 +
10744 static void __flush_tsb_one(struct tlb_batch *tb, unsigned long hash_shift,
10745 unsigned long tsb, unsigned long nentries)
10746 {
10747 unsigned long i;
10748
10749 - for (i = 0; i < tb->tlb_nr; i++) {
10750 - unsigned long v = tb->vaddrs[i];
10751 - unsigned long tag, ent, hash;
10752 -
10753 - v &= ~0x1UL;
10754 -
10755 - hash = tsb_hash(v, hash_shift, nentries);
10756 - ent = tsb + (hash * sizeof(struct tsb));
10757 - tag = (v >> 22UL);
10758 -
10759 - tsb_flush(ent, tag);
10760 - }
10761 + for (i = 0; i < tb->tlb_nr; i++)
10762 + __flush_tsb_one_entry(tsb, tb->vaddrs[i], hash_shift, nentries);
10763 }
10764
10765 void flush_tsb_user(struct tlb_batch *tb)
10766 @@ -90,6 +93,30 @@ void flush_tsb_user(struct tlb_batch *tb)
10767 spin_unlock_irqrestore(&mm->context.lock, flags);
10768 }
10769
10770 +void flush_tsb_user_page(struct mm_struct *mm, unsigned long vaddr)
10771 +{
10772 + unsigned long nentries, base, flags;
10773 +
10774 + spin_lock_irqsave(&mm->context.lock, flags);
10775 +
10776 + base = (unsigned long) mm->context.tsb_block[MM_TSB_BASE].tsb;
10777 + nentries = mm->context.tsb_block[MM_TSB_BASE].tsb_nentries;
10778 + if (tlb_type == cheetah_plus || tlb_type == hypervisor)
10779 + base = __pa(base);
10780 + __flush_tsb_one_entry(base, vaddr, PAGE_SHIFT, nentries);
10781 +
10782 +#if defined(CONFIG_HUGETLB_PAGE) || defined(CONFIG_TRANSPARENT_HUGEPAGE)
10783 + if (mm->context.tsb_block[MM_TSB_HUGE].tsb) {
10784 + base = (unsigned long) mm->context.tsb_block[MM_TSB_HUGE].tsb;
10785 + nentries = mm->context.tsb_block[MM_TSB_HUGE].tsb_nentries;
10786 + if (tlb_type == cheetah_plus || tlb_type == hypervisor)
10787 + base = __pa(base);
10788 + __flush_tsb_one_entry(base, vaddr, HPAGE_SHIFT, nentries);
10789 + }
10790 +#endif
10791 + spin_unlock_irqrestore(&mm->context.lock, flags);
10792 +}
10793 +
10794 #define HV_PGSZ_IDX_BASE HV_PGSZ_IDX_8K
10795 #define HV_PGSZ_MASK_BASE HV_PGSZ_MASK_8K
10796
10797 diff --git a/arch/sparc/mm/ultra.S b/arch/sparc/mm/ultra.S
10798 index f8e13d4..432aa0c 100644
10799 --- a/arch/sparc/mm/ultra.S
10800 +++ b/arch/sparc/mm/ultra.S
10801 @@ -53,6 +53,33 @@ __flush_tlb_mm: /* 18 insns */
10802 nop
10803
10804 .align 32
10805 + .globl __flush_tlb_page
10806 +__flush_tlb_page: /* 22 insns */
10807 + /* %o0 = context, %o1 = vaddr */
10808 + rdpr %pstate, %g7
10809 + andn %g7, PSTATE_IE, %g2
10810 + wrpr %g2, %pstate
10811 + mov SECONDARY_CONTEXT, %o4
10812 + ldxa [%o4] ASI_DMMU, %g2
10813 + stxa %o0, [%o4] ASI_DMMU
10814 + andcc %o1, 1, %g0
10815 + andn %o1, 1, %o3
10816 + be,pn %icc, 1f
10817 + or %o3, 0x10, %o3
10818 + stxa %g0, [%o3] ASI_IMMU_DEMAP
10819 +1: stxa %g0, [%o3] ASI_DMMU_DEMAP
10820 + membar #Sync
10821 + stxa %g2, [%o4] ASI_DMMU
10822 + sethi %hi(KERNBASE), %o4
10823 + flush %o4
10824 + retl
10825 + wrpr %g7, 0x0, %pstate
10826 + nop
10827 + nop
10828 + nop
10829 + nop
10830 +
10831 + .align 32
10832 .globl __flush_tlb_pending
10833 __flush_tlb_pending: /* 26 insns */
10834 /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
10835 @@ -203,6 +230,31 @@ __cheetah_flush_tlb_mm: /* 19 insns */
10836 retl
10837 wrpr %g7, 0x0, %pstate
10838
10839 +__cheetah_flush_tlb_page: /* 22 insns */
10840 + /* %o0 = context, %o1 = vaddr */
10841 + rdpr %pstate, %g7
10842 + andn %g7, PSTATE_IE, %g2
10843 + wrpr %g2, 0x0, %pstate
10844 + wrpr %g0, 1, %tl
10845 + mov PRIMARY_CONTEXT, %o4
10846 + ldxa [%o4] ASI_DMMU, %g2
10847 + srlx %g2, CTX_PGSZ1_NUC_SHIFT, %o3
10848 + sllx %o3, CTX_PGSZ1_NUC_SHIFT, %o3
10849 + or %o0, %o3, %o0 /* Preserve nucleus page size fields */
10850 + stxa %o0, [%o4] ASI_DMMU
10851 + andcc %o1, 1, %g0
10852 + be,pn %icc, 1f
10853 + andn %o1, 1, %o3
10854 + stxa %g0, [%o3] ASI_IMMU_DEMAP
10855 +1: stxa %g0, [%o3] ASI_DMMU_DEMAP
10856 + membar #Sync
10857 + stxa %g2, [%o4] ASI_DMMU
10858 + sethi %hi(KERNBASE), %o4
10859 + flush %o4
10860 + wrpr %g0, 0, %tl
10861 + retl
10862 + wrpr %g7, 0x0, %pstate
10863 +
10864 __cheetah_flush_tlb_pending: /* 27 insns */
10865 /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
10866 rdpr %pstate, %g7
10867 @@ -269,6 +321,20 @@ __hypervisor_flush_tlb_mm: /* 10 insns */
10868 retl
10869 nop
10870
10871 +__hypervisor_flush_tlb_page: /* 11 insns */
10872 + /* %o0 = context, %o1 = vaddr */
10873 + mov %o0, %g2
10874 + mov %o1, %o0 /* ARG0: vaddr + IMMU-bit */
10875 + mov %g2, %o1 /* ARG1: mmu context */
10876 + mov HV_MMU_ALL, %o2 /* ARG2: flags */
10877 + srlx %o0, PAGE_SHIFT, %o0
10878 + sllx %o0, PAGE_SHIFT, %o0
10879 + ta HV_MMU_UNMAP_ADDR_TRAP
10880 + brnz,pn %o0, __hypervisor_tlb_tl0_error
10881 + mov HV_MMU_UNMAP_ADDR_TRAP, %o1
10882 + retl
10883 + nop
10884 +
10885 __hypervisor_flush_tlb_pending: /* 16 insns */
10886 /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
10887 sllx %o1, 3, %g1
10888 @@ -339,6 +405,13 @@ cheetah_patch_cachetlbops:
10889 call tlb_patch_one
10890 mov 19, %o2
10891
10892 + sethi %hi(__flush_tlb_page), %o0
10893 + or %o0, %lo(__flush_tlb_page), %o0
10894 + sethi %hi(__cheetah_flush_tlb_page), %o1
10895 + or %o1, %lo(__cheetah_flush_tlb_page), %o1
10896 + call tlb_patch_one
10897 + mov 22, %o2
10898 +
10899 sethi %hi(__flush_tlb_pending), %o0
10900 or %o0, %lo(__flush_tlb_pending), %o0
10901 sethi %hi(__cheetah_flush_tlb_pending), %o1
10902 @@ -397,10 +470,9 @@ xcall_flush_tlb_mm: /* 21 insns */
10903 nop
10904 nop
10905
10906 - .globl xcall_flush_tlb_pending
10907 -xcall_flush_tlb_pending: /* 21 insns */
10908 - /* %g5=context, %g1=nr, %g7=vaddrs[] */
10909 - sllx %g1, 3, %g1
10910 + .globl xcall_flush_tlb_page
10911 +xcall_flush_tlb_page: /* 17 insns */
10912 + /* %g5=context, %g1=vaddr */
10913 mov PRIMARY_CONTEXT, %g4
10914 ldxa [%g4] ASI_DMMU, %g2
10915 srlx %g2, CTX_PGSZ1_NUC_SHIFT, %g4
10916 @@ -408,20 +480,16 @@ xcall_flush_tlb_pending: /* 21 insns */
10917 or %g5, %g4, %g5
10918 mov PRIMARY_CONTEXT, %g4
10919 stxa %g5, [%g4] ASI_DMMU
10920 -1: sub %g1, (1 << 3), %g1
10921 - ldx [%g7 + %g1], %g5
10922 - andcc %g5, 0x1, %g0
10923 + andcc %g1, 0x1, %g0
10924 be,pn %icc, 2f
10925 -
10926 - andn %g5, 0x1, %g5
10927 + andn %g1, 0x1, %g5
10928 stxa %g0, [%g5] ASI_IMMU_DEMAP
10929 2: stxa %g0, [%g5] ASI_DMMU_DEMAP
10930 membar #Sync
10931 - brnz,pt %g1, 1b
10932 - nop
10933 stxa %g2, [%g4] ASI_DMMU
10934 retry
10935 nop
10936 + nop
10937
10938 .globl xcall_flush_tlb_kernel_range
10939 xcall_flush_tlb_kernel_range: /* 25 insns */
10940 @@ -656,15 +724,13 @@ __hypervisor_xcall_flush_tlb_mm: /* 21 insns */
10941 membar #Sync
10942 retry
10943
10944 - .globl __hypervisor_xcall_flush_tlb_pending
10945 -__hypervisor_xcall_flush_tlb_pending: /* 21 insns */
10946 - /* %g5=ctx, %g1=nr, %g7=vaddrs[], %g2,%g3,%g4,g6=scratch */
10947 - sllx %g1, 3, %g1
10948 + .globl __hypervisor_xcall_flush_tlb_page
10949 +__hypervisor_xcall_flush_tlb_page: /* 17 insns */
10950 + /* %g5=ctx, %g1=vaddr */
10951 mov %o0, %g2
10952 mov %o1, %g3
10953 mov %o2, %g4
10954 -1: sub %g1, (1 << 3), %g1
10955 - ldx [%g7 + %g1], %o0 /* ARG0: virtual address */
10956 + mov %g1, %o0 /* ARG0: virtual address */
10957 mov %g5, %o1 /* ARG1: mmu context */
10958 mov HV_MMU_ALL, %o2 /* ARG2: flags */
10959 srlx %o0, PAGE_SHIFT, %o0
10960 @@ -673,8 +739,6 @@ __hypervisor_xcall_flush_tlb_pending: /* 21 insns */
10961 mov HV_MMU_UNMAP_ADDR_TRAP, %g6
10962 brnz,a,pn %o0, __hypervisor_tlb_xcall_error
10963 mov %o0, %g5
10964 - brnz,pt %g1, 1b
10965 - nop
10966 mov %g2, %o0
10967 mov %g3, %o1
10968 mov %g4, %o2
10969 @@ -757,6 +821,13 @@ hypervisor_patch_cachetlbops:
10970 call tlb_patch_one
10971 mov 10, %o2
10972
10973 + sethi %hi(__flush_tlb_page), %o0
10974 + or %o0, %lo(__flush_tlb_page), %o0
10975 + sethi %hi(__hypervisor_flush_tlb_page), %o1
10976 + or %o1, %lo(__hypervisor_flush_tlb_page), %o1
10977 + call tlb_patch_one
10978 + mov 11, %o2
10979 +
10980 sethi %hi(__flush_tlb_pending), %o0
10981 or %o0, %lo(__flush_tlb_pending), %o0
10982 sethi %hi(__hypervisor_flush_tlb_pending), %o1
10983 @@ -788,12 +859,12 @@ hypervisor_patch_cachetlbops:
10984 call tlb_patch_one
10985 mov 21, %o2
10986
10987 - sethi %hi(xcall_flush_tlb_pending), %o0
10988 - or %o0, %lo(xcall_flush_tlb_pending), %o0
10989 - sethi %hi(__hypervisor_xcall_flush_tlb_pending), %o1
10990 - or %o1, %lo(__hypervisor_xcall_flush_tlb_pending), %o1
10991 + sethi %hi(xcall_flush_tlb_page), %o0
10992 + or %o0, %lo(xcall_flush_tlb_page), %o0
10993 + sethi %hi(__hypervisor_xcall_flush_tlb_page), %o1
10994 + or %o1, %lo(__hypervisor_xcall_flush_tlb_page), %o1
10995 call tlb_patch_one
10996 - mov 21, %o2
10997 + mov 17, %o2
10998
10999 sethi %hi(xcall_flush_tlb_kernel_range), %o0
11000 or %o0, %lo(xcall_flush_tlb_kernel_range), %o0
11001 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11002 index f4500c6..889656c 100644
11003 --- a/arch/tile/include/asm/atomic_64.h
11004 +++ b/arch/tile/include/asm/atomic_64.h
11005 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11006
11007 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11008
11009 +#define atomic64_read_unchecked(v) atomic64_read(v)
11010 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11011 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11012 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11013 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11014 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11015 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11016 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11017 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11018 +
11019 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11020 #define smp_mb__before_atomic_dec() smp_mb()
11021 #define smp_mb__after_atomic_dec() smp_mb()
11022 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11023 index a9a5299..0fce79e 100644
11024 --- a/arch/tile/include/asm/cache.h
11025 +++ b/arch/tile/include/asm/cache.h
11026 @@ -15,11 +15,12 @@
11027 #ifndef _ASM_TILE_CACHE_H
11028 #define _ASM_TILE_CACHE_H
11029
11030 +#include <linux/const.h>
11031 #include <arch/chip.h>
11032
11033 /* bytes per L1 data cache line */
11034 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11035 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11036 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11037
11038 /* bytes per L2 cache line */
11039 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11040 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11041 index 9ab078a..d6635c2 100644
11042 --- a/arch/tile/include/asm/uaccess.h
11043 +++ b/arch/tile/include/asm/uaccess.h
11044 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11045 const void __user *from,
11046 unsigned long n)
11047 {
11048 - int sz = __compiletime_object_size(to);
11049 + size_t sz = __compiletime_object_size(to);
11050
11051 - if (likely(sz == -1 || sz >= n))
11052 + if (likely(sz == (size_t)-1 || sz >= n))
11053 n = _copy_from_user(to, from, n);
11054 else
11055 copy_from_user_overflow();
11056 diff --git a/arch/um/Makefile b/arch/um/Makefile
11057 index 133f7de..1d6f2f1 100644
11058 --- a/arch/um/Makefile
11059 +++ b/arch/um/Makefile
11060 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11061 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11062 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11063
11064 +ifdef CONSTIFY_PLUGIN
11065 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11066 +endif
11067 +
11068 #This will adjust *FLAGS accordingly to the platform.
11069 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11070
11071 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11072 index 19e1bdd..3665b77 100644
11073 --- a/arch/um/include/asm/cache.h
11074 +++ b/arch/um/include/asm/cache.h
11075 @@ -1,6 +1,7 @@
11076 #ifndef __UM_CACHE_H
11077 #define __UM_CACHE_H
11078
11079 +#include <linux/const.h>
11080
11081 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11082 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11083 @@ -12,6 +13,6 @@
11084 # define L1_CACHE_SHIFT 5
11085 #endif
11086
11087 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11088 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11089
11090 #endif
11091 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11092 index 2e0a6b1..a64d0f5 100644
11093 --- a/arch/um/include/asm/kmap_types.h
11094 +++ b/arch/um/include/asm/kmap_types.h
11095 @@ -8,6 +8,6 @@
11096
11097 /* No more #include "asm/arch/kmap_types.h" ! */
11098
11099 -#define KM_TYPE_NR 14
11100 +#define KM_TYPE_NR 15
11101
11102 #endif
11103 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11104 index 5ff53d9..5850cdf 100644
11105 --- a/arch/um/include/asm/page.h
11106 +++ b/arch/um/include/asm/page.h
11107 @@ -14,6 +14,9 @@
11108 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11109 #define PAGE_MASK (~(PAGE_SIZE-1))
11110
11111 +#define ktla_ktva(addr) (addr)
11112 +#define ktva_ktla(addr) (addr)
11113 +
11114 #ifndef __ASSEMBLY__
11115
11116 struct page;
11117 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11118 index 0032f92..cd151e0 100644
11119 --- a/arch/um/include/asm/pgtable-3level.h
11120 +++ b/arch/um/include/asm/pgtable-3level.h
11121 @@ -58,6 +58,7 @@
11122 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11123 #define pud_populate(mm, pud, pmd) \
11124 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11125 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11126
11127 #ifdef CONFIG_64BIT
11128 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11129 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11130 index b462b13..e7a19aa 100644
11131 --- a/arch/um/kernel/process.c
11132 +++ b/arch/um/kernel/process.c
11133 @@ -386,22 +386,6 @@ int singlestepping(void * t)
11134 return 2;
11135 }
11136
11137 -/*
11138 - * Only x86 and x86_64 have an arch_align_stack().
11139 - * All other arches have "#define arch_align_stack(x) (x)"
11140 - * in their asm/system.h
11141 - * As this is included in UML from asm-um/system-generic.h,
11142 - * we can use it to behave as the subarch does.
11143 - */
11144 -#ifndef arch_align_stack
11145 -unsigned long arch_align_stack(unsigned long sp)
11146 -{
11147 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11148 - sp -= get_random_int() % 8192;
11149 - return sp & ~0xf;
11150 -}
11151 -#endif
11152 -
11153 unsigned long get_wchan(struct task_struct *p)
11154 {
11155 unsigned long stack_page, sp, ip;
11156 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11157 index ad8f795..2c7eec6 100644
11158 --- a/arch/unicore32/include/asm/cache.h
11159 +++ b/arch/unicore32/include/asm/cache.h
11160 @@ -12,8 +12,10 @@
11161 #ifndef __UNICORE_CACHE_H__
11162 #define __UNICORE_CACHE_H__
11163
11164 -#define L1_CACHE_SHIFT (5)
11165 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11166 +#include <linux/const.h>
11167 +
11168 +#define L1_CACHE_SHIFT 5
11169 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11170
11171 /*
11172 * Memory returned by kmalloc() may be used for DMA, so we must make
11173 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11174 index 0694d09..58ea1a1 100644
11175 --- a/arch/x86/Kconfig
11176 +++ b/arch/x86/Kconfig
11177 @@ -238,7 +238,7 @@ config X86_HT
11178
11179 config X86_32_LAZY_GS
11180 def_bool y
11181 - depends on X86_32 && !CC_STACKPROTECTOR
11182 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11183
11184 config ARCH_HWEIGHT_CFLAGS
11185 string
11186 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
11187
11188 config X86_MSR
11189 tristate "/dev/cpu/*/msr - Model-specific register support"
11190 + depends on !GRKERNSEC_KMEM
11191 ---help---
11192 This device gives privileged processes access to the x86
11193 Model-Specific Registers (MSRs). It is a character device with
11194 @@ -1054,7 +1055,7 @@ choice
11195
11196 config NOHIGHMEM
11197 bool "off"
11198 - depends on !X86_NUMAQ
11199 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11200 ---help---
11201 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11202 However, the address space of 32-bit x86 processors is only 4
11203 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
11204
11205 config HIGHMEM4G
11206 bool "4GB"
11207 - depends on !X86_NUMAQ
11208 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11209 ---help---
11210 Select this if you have a 32-bit processor and between 1 and 4
11211 gigabytes of physical RAM.
11212 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
11213 hex
11214 default 0xB0000000 if VMSPLIT_3G_OPT
11215 default 0x80000000 if VMSPLIT_2G
11216 - default 0x78000000 if VMSPLIT_2G_OPT
11217 + default 0x70000000 if VMSPLIT_2G_OPT
11218 default 0x40000000 if VMSPLIT_1G
11219 default 0xC0000000
11220 depends on X86_32
11221 @@ -1542,6 +1543,7 @@ config SECCOMP
11222
11223 config CC_STACKPROTECTOR
11224 bool "Enable -fstack-protector buffer overflow detection"
11225 + depends on X86_64 || !PAX_MEMORY_UDEREF
11226 ---help---
11227 This option turns on the -fstack-protector GCC feature. This
11228 feature puts, at the beginning of functions, a canary value on
11229 @@ -1662,6 +1664,8 @@ config X86_NEED_RELOCS
11230 config PHYSICAL_ALIGN
11231 hex "Alignment value to which kernel should be aligned" if X86_32
11232 default "0x1000000"
11233 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11234 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11235 range 0x2000 0x1000000
11236 ---help---
11237 This value puts the alignment restrictions on physical address
11238 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
11239 If unsure, say N.
11240
11241 config COMPAT_VDSO
11242 - def_bool y
11243 + def_bool n
11244 prompt "Compat VDSO support"
11245 depends on X86_32 || IA32_EMULATION
11246 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11247 ---help---
11248 Map the 32-bit VDSO to the predictable old-style address too.
11249
11250 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11251 index c026cca..14657ae 100644
11252 --- a/arch/x86/Kconfig.cpu
11253 +++ b/arch/x86/Kconfig.cpu
11254 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11255
11256 config X86_F00F_BUG
11257 def_bool y
11258 - depends on M586MMX || M586TSC || M586 || M486
11259 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11260
11261 config X86_INVD_BUG
11262 def_bool y
11263 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11264
11265 config X86_ALIGNMENT_16
11266 def_bool y
11267 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11268 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11269
11270 config X86_INTEL_USERCOPY
11271 def_bool y
11272 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11273 # generates cmov.
11274 config X86_CMOV
11275 def_bool y
11276 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11277 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11278
11279 config X86_MINIMUM_CPU_FAMILY
11280 int
11281 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11282 index b322f12..652d0d9 100644
11283 --- a/arch/x86/Kconfig.debug
11284 +++ b/arch/x86/Kconfig.debug
11285 @@ -84,7 +84,7 @@ config X86_PTDUMP
11286 config DEBUG_RODATA
11287 bool "Write protect kernel read-only data structures"
11288 default y
11289 - depends on DEBUG_KERNEL
11290 + depends on DEBUG_KERNEL && BROKEN
11291 ---help---
11292 Mark the kernel read-only data as write-protected in the pagetables,
11293 in order to catch accidental (and incorrect) writes to such const
11294 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
11295
11296 config DEBUG_SET_MODULE_RONX
11297 bool "Set loadable kernel module data as NX and text as RO"
11298 - depends on MODULES
11299 + depends on MODULES && BROKEN
11300 ---help---
11301 This option helps catch unintended modifications to loadable
11302 kernel module's text and read-only data. It also prevents execution
11303 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
11304
11305 config DEBUG_STRICT_USER_COPY_CHECKS
11306 bool "Strict copy size checks"
11307 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
11308 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
11309 ---help---
11310 Enabling this option turns a certain set of sanity checks for user
11311 copy operations into compile time failures.
11312 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11313 index e71fc42..7829607 100644
11314 --- a/arch/x86/Makefile
11315 +++ b/arch/x86/Makefile
11316 @@ -50,6 +50,7 @@ else
11317 UTS_MACHINE := x86_64
11318 CHECKFLAGS += -D__x86_64__ -m64
11319
11320 + biarch := $(call cc-option,-m64)
11321 KBUILD_AFLAGS += -m64
11322 KBUILD_CFLAGS += -m64
11323
11324 @@ -230,3 +231,12 @@ define archhelp
11325 echo ' FDARGS="..." arguments for the booted kernel'
11326 echo ' FDINITRD=file initrd for the booted kernel'
11327 endef
11328 +
11329 +define OLD_LD
11330 +
11331 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11332 +*** Please upgrade your binutils to 2.18 or newer
11333 +endef
11334 +
11335 +archprepare:
11336 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11337 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11338 index 379814b..add62ce 100644
11339 --- a/arch/x86/boot/Makefile
11340 +++ b/arch/x86/boot/Makefile
11341 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11342 $(call cc-option, -fno-stack-protector) \
11343 $(call cc-option, -mpreferred-stack-boundary=2)
11344 KBUILD_CFLAGS += $(call cc-option, -m32)
11345 +ifdef CONSTIFY_PLUGIN
11346 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11347 +endif
11348 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11349 GCOV_PROFILE := n
11350
11351 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11352 index 878e4b9..20537ab 100644
11353 --- a/arch/x86/boot/bitops.h
11354 +++ b/arch/x86/boot/bitops.h
11355 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11356 u8 v;
11357 const u32 *p = (const u32 *)addr;
11358
11359 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11360 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11361 return v;
11362 }
11363
11364 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11365
11366 static inline void set_bit(int nr, void *addr)
11367 {
11368 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11369 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11370 }
11371
11372 #endif /* BOOT_BITOPS_H */
11373 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11374 index 18997e5..83d9c67 100644
11375 --- a/arch/x86/boot/boot.h
11376 +++ b/arch/x86/boot/boot.h
11377 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11378 static inline u16 ds(void)
11379 {
11380 u16 seg;
11381 - asm("movw %%ds,%0" : "=rm" (seg));
11382 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11383 return seg;
11384 }
11385
11386 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11387 static inline int memcmp(const void *s1, const void *s2, size_t len)
11388 {
11389 u8 diff;
11390 - asm("repe; cmpsb; setnz %0"
11391 + asm volatile("repe; cmpsb; setnz %0"
11392 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11393 return diff;
11394 }
11395 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11396 index 5ef205c..342191d 100644
11397 --- a/arch/x86/boot/compressed/Makefile
11398 +++ b/arch/x86/boot/compressed/Makefile
11399 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11400 KBUILD_CFLAGS += $(cflags-y)
11401 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11402 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11403 +ifdef CONSTIFY_PLUGIN
11404 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11405 +endif
11406
11407 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11408 GCOV_PROFILE := n
11409 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11410 index c205035..5853587 100644
11411 --- a/arch/x86/boot/compressed/eboot.c
11412 +++ b/arch/x86/boot/compressed/eboot.c
11413 @@ -150,7 +150,6 @@ again:
11414 *addr = max_addr;
11415 }
11416
11417 -free_pool:
11418 efi_call_phys1(sys_table->boottime->free_pool, map);
11419
11420 fail:
11421 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11422 if (i == map_size / desc_size)
11423 status = EFI_NOT_FOUND;
11424
11425 -free_pool:
11426 efi_call_phys1(sys_table->boottime->free_pool, map);
11427 fail:
11428 return status;
11429 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11430 index 1e3184f..0d11e2e 100644
11431 --- a/arch/x86/boot/compressed/head_32.S
11432 +++ b/arch/x86/boot/compressed/head_32.S
11433 @@ -118,7 +118,7 @@ preferred_addr:
11434 notl %eax
11435 andl %eax, %ebx
11436 #else
11437 - movl $LOAD_PHYSICAL_ADDR, %ebx
11438 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11439 #endif
11440
11441 /* Target address to relocate to for decompression */
11442 @@ -204,7 +204,7 @@ relocated:
11443 * and where it was actually loaded.
11444 */
11445 movl %ebp, %ebx
11446 - subl $LOAD_PHYSICAL_ADDR, %ebx
11447 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11448 jz 2f /* Nothing to be done if loaded at compiled addr. */
11449 /*
11450 * Process relocations.
11451 @@ -212,8 +212,7 @@ relocated:
11452
11453 1: subl $4, %edi
11454 movl (%edi), %ecx
11455 - testl %ecx, %ecx
11456 - jz 2f
11457 + jecxz 2f
11458 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11459 jmp 1b
11460 2:
11461 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11462 index f5d1aaa..cce11dc 100644
11463 --- a/arch/x86/boot/compressed/head_64.S
11464 +++ b/arch/x86/boot/compressed/head_64.S
11465 @@ -91,7 +91,7 @@ ENTRY(startup_32)
11466 notl %eax
11467 andl %eax, %ebx
11468 #else
11469 - movl $LOAD_PHYSICAL_ADDR, %ebx
11470 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11471 #endif
11472
11473 /* Target address to relocate to for decompression */
11474 @@ -273,7 +273,7 @@ preferred_addr:
11475 notq %rax
11476 andq %rax, %rbp
11477 #else
11478 - movq $LOAD_PHYSICAL_ADDR, %rbp
11479 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11480 #endif
11481
11482 /* Target address to relocate to for decompression */
11483 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11484 index 88f7ff6..ed695dd 100644
11485 --- a/arch/x86/boot/compressed/misc.c
11486 +++ b/arch/x86/boot/compressed/misc.c
11487 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
11488 case PT_LOAD:
11489 #ifdef CONFIG_RELOCATABLE
11490 dest = output;
11491 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11492 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11493 #else
11494 dest = (void *)(phdr->p_paddr);
11495 #endif
11496 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11497 error("Destination address too large");
11498 #endif
11499 #ifndef CONFIG_RELOCATABLE
11500 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11501 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11502 error("Wrong destination address");
11503 #endif
11504
11505 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11506 index 4d3ff03..e4972ff 100644
11507 --- a/arch/x86/boot/cpucheck.c
11508 +++ b/arch/x86/boot/cpucheck.c
11509 @@ -74,7 +74,7 @@ static int has_fpu(void)
11510 u16 fcw = -1, fsw = -1;
11511 u32 cr0;
11512
11513 - asm("movl %%cr0,%0" : "=r" (cr0));
11514 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11515 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11516 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11517 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11518 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11519 {
11520 u32 f0, f1;
11521
11522 - asm("pushfl ; "
11523 + asm volatile("pushfl ; "
11524 "pushfl ; "
11525 "popl %0 ; "
11526 "movl %0,%1 ; "
11527 @@ -115,7 +115,7 @@ static void get_flags(void)
11528 set_bit(X86_FEATURE_FPU, cpu.flags);
11529
11530 if (has_eflag(X86_EFLAGS_ID)) {
11531 - asm("cpuid"
11532 + asm volatile("cpuid"
11533 : "=a" (max_intel_level),
11534 "=b" (cpu_vendor[0]),
11535 "=d" (cpu_vendor[1]),
11536 @@ -124,7 +124,7 @@ static void get_flags(void)
11537
11538 if (max_intel_level >= 0x00000001 &&
11539 max_intel_level <= 0x0000ffff) {
11540 - asm("cpuid"
11541 + asm volatile("cpuid"
11542 : "=a" (tfms),
11543 "=c" (cpu.flags[4]),
11544 "=d" (cpu.flags[0])
11545 @@ -136,7 +136,7 @@ static void get_flags(void)
11546 cpu.model += ((tfms >> 16) & 0xf) << 4;
11547 }
11548
11549 - asm("cpuid"
11550 + asm volatile("cpuid"
11551 : "=a" (max_amd_level)
11552 : "a" (0x80000000)
11553 : "ebx", "ecx", "edx");
11554 @@ -144,7 +144,7 @@ static void get_flags(void)
11555 if (max_amd_level >= 0x80000001 &&
11556 max_amd_level <= 0x8000ffff) {
11557 u32 eax = 0x80000001;
11558 - asm("cpuid"
11559 + asm volatile("cpuid"
11560 : "+a" (eax),
11561 "=c" (cpu.flags[6]),
11562 "=d" (cpu.flags[1])
11563 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11564 u32 ecx = MSR_K7_HWCR;
11565 u32 eax, edx;
11566
11567 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11568 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11569 eax &= ~(1 << 15);
11570 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11571 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11572
11573 get_flags(); /* Make sure it really did something */
11574 err = check_flags();
11575 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11576 u32 ecx = MSR_VIA_FCR;
11577 u32 eax, edx;
11578
11579 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11580 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11581 eax |= (1<<1)|(1<<7);
11582 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11583 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11584
11585 set_bit(X86_FEATURE_CX8, cpu.flags);
11586 err = check_flags();
11587 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11588 u32 eax, edx;
11589 u32 level = 1;
11590
11591 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11592 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11593 - asm("cpuid"
11594 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11595 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11596 + asm volatile("cpuid"
11597 : "+a" (level), "=d" (cpu.flags[0])
11598 : : "ecx", "ebx");
11599 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11600 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11601
11602 err = check_flags();
11603 }
11604 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
11605 index 944ce59..87ee37a 100644
11606 --- a/arch/x86/boot/header.S
11607 +++ b/arch/x86/boot/header.S
11608 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
11609 # single linked list of
11610 # struct setup_data
11611
11612 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
11613 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
11614
11615 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
11616 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
11617 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
11618 +#else
11619 #define VO_INIT_SIZE (VO__end - VO__text)
11620 +#endif
11621 #if ZO_INIT_SIZE > VO_INIT_SIZE
11622 #define INIT_SIZE ZO_INIT_SIZE
11623 #else
11624 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
11625 index db75d07..8e6d0af 100644
11626 --- a/arch/x86/boot/memory.c
11627 +++ b/arch/x86/boot/memory.c
11628 @@ -19,7 +19,7 @@
11629
11630 static int detect_memory_e820(void)
11631 {
11632 - int count = 0;
11633 + unsigned int count = 0;
11634 struct biosregs ireg, oreg;
11635 struct e820entry *desc = boot_params.e820_map;
11636 static struct e820entry buf; /* static so it is zeroed */
11637 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
11638 index 11e8c6e..fdbb1ed 100644
11639 --- a/arch/x86/boot/video-vesa.c
11640 +++ b/arch/x86/boot/video-vesa.c
11641 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
11642
11643 boot_params.screen_info.vesapm_seg = oreg.es;
11644 boot_params.screen_info.vesapm_off = oreg.di;
11645 + boot_params.screen_info.vesapm_size = oreg.cx;
11646 }
11647
11648 /*
11649 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
11650 index 43eda28..5ab5fdb 100644
11651 --- a/arch/x86/boot/video.c
11652 +++ b/arch/x86/boot/video.c
11653 @@ -96,7 +96,7 @@ static void store_mode_params(void)
11654 static unsigned int get_entry(void)
11655 {
11656 char entry_buf[4];
11657 - int i, len = 0;
11658 + unsigned int i, len = 0;
11659 int key;
11660 unsigned int v;
11661
11662 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
11663 index 5b577d5..3c1fed4 100644
11664 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
11665 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
11666 @@ -8,6 +8,8 @@
11667 * including this sentence is retained in full.
11668 */
11669
11670 +#include <asm/alternative-asm.h>
11671 +
11672 .extern crypto_ft_tab
11673 .extern crypto_it_tab
11674 .extern crypto_fl_tab
11675 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
11676 je B192; \
11677 leaq 32(r9),r9;
11678
11679 +#define ret pax_force_retaddr 0, 1; ret
11680 +
11681 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
11682 movq r1,r2; \
11683 movq r3,r4; \
11684 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
11685 index 3470624..201259d 100644
11686 --- a/arch/x86/crypto/aesni-intel_asm.S
11687 +++ b/arch/x86/crypto/aesni-intel_asm.S
11688 @@ -31,6 +31,7 @@
11689
11690 #include <linux/linkage.h>
11691 #include <asm/inst.h>
11692 +#include <asm/alternative-asm.h>
11693
11694 #ifdef __x86_64__
11695 .data
11696 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
11697 pop %r14
11698 pop %r13
11699 pop %r12
11700 + pax_force_retaddr 0, 1
11701 ret
11702 +ENDPROC(aesni_gcm_dec)
11703
11704
11705 /*****************************************************************************
11706 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
11707 pop %r14
11708 pop %r13
11709 pop %r12
11710 + pax_force_retaddr 0, 1
11711 ret
11712 +ENDPROC(aesni_gcm_enc)
11713
11714 #endif
11715
11716 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
11717 pxor %xmm1, %xmm0
11718 movaps %xmm0, (TKEYP)
11719 add $0x10, TKEYP
11720 + pax_force_retaddr_bts
11721 ret
11722
11723 .align 4
11724 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
11725 shufps $0b01001110, %xmm2, %xmm1
11726 movaps %xmm1, 0x10(TKEYP)
11727 add $0x20, TKEYP
11728 + pax_force_retaddr_bts
11729 ret
11730
11731 .align 4
11732 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
11733
11734 movaps %xmm0, (TKEYP)
11735 add $0x10, TKEYP
11736 + pax_force_retaddr_bts
11737 ret
11738
11739 .align 4
11740 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
11741 pxor %xmm1, %xmm2
11742 movaps %xmm2, (TKEYP)
11743 add $0x10, TKEYP
11744 + pax_force_retaddr_bts
11745 ret
11746
11747 /*
11748 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
11749 #ifndef __x86_64__
11750 popl KEYP
11751 #endif
11752 + pax_force_retaddr 0, 1
11753 ret
11754 +ENDPROC(aesni_set_key)
11755
11756 /*
11757 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
11758 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
11759 popl KLEN
11760 popl KEYP
11761 #endif
11762 + pax_force_retaddr 0, 1
11763 ret
11764 +ENDPROC(aesni_enc)
11765
11766 /*
11767 * _aesni_enc1: internal ABI
11768 @@ -1959,6 +1972,7 @@ _aesni_enc1:
11769 AESENC KEY STATE
11770 movaps 0x70(TKEYP), KEY
11771 AESENCLAST KEY STATE
11772 + pax_force_retaddr_bts
11773 ret
11774
11775 /*
11776 @@ -2067,6 +2081,7 @@ _aesni_enc4:
11777 AESENCLAST KEY STATE2
11778 AESENCLAST KEY STATE3
11779 AESENCLAST KEY STATE4
11780 + pax_force_retaddr_bts
11781 ret
11782
11783 /*
11784 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
11785 popl KLEN
11786 popl KEYP
11787 #endif
11788 + pax_force_retaddr 0, 1
11789 ret
11790 +ENDPROC(aesni_dec)
11791
11792 /*
11793 * _aesni_dec1: internal ABI
11794 @@ -2146,6 +2163,7 @@ _aesni_dec1:
11795 AESDEC KEY STATE
11796 movaps 0x70(TKEYP), KEY
11797 AESDECLAST KEY STATE
11798 + pax_force_retaddr_bts
11799 ret
11800
11801 /*
11802 @@ -2254,6 +2272,7 @@ _aesni_dec4:
11803 AESDECLAST KEY STATE2
11804 AESDECLAST KEY STATE3
11805 AESDECLAST KEY STATE4
11806 + pax_force_retaddr_bts
11807 ret
11808
11809 /*
11810 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
11811 popl KEYP
11812 popl LEN
11813 #endif
11814 + pax_force_retaddr 0, 1
11815 ret
11816 +ENDPROC(aesni_ecb_enc)
11817
11818 /*
11819 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11820 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
11821 popl KEYP
11822 popl LEN
11823 #endif
11824 + pax_force_retaddr 0, 1
11825 ret
11826 +ENDPROC(aesni_ecb_dec)
11827
11828 /*
11829 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11830 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
11831 popl LEN
11832 popl IVP
11833 #endif
11834 + pax_force_retaddr 0, 1
11835 ret
11836 +ENDPROC(aesni_cbc_enc)
11837
11838 /*
11839 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11840 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
11841 popl LEN
11842 popl IVP
11843 #endif
11844 + pax_force_retaddr 0, 1
11845 ret
11846 +ENDPROC(aesni_cbc_dec)
11847
11848 #ifdef __x86_64__
11849 .align 16
11850 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
11851 mov $1, TCTR_LOW
11852 MOVQ_R64_XMM TCTR_LOW INC
11853 MOVQ_R64_XMM CTR TCTR_LOW
11854 + pax_force_retaddr_bts
11855 ret
11856
11857 /*
11858 @@ -2554,6 +2582,7 @@ _aesni_inc:
11859 .Linc_low:
11860 movaps CTR, IV
11861 PSHUFB_XMM BSWAP_MASK IV
11862 + pax_force_retaddr_bts
11863 ret
11864
11865 /*
11866 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
11867 .Lctr_enc_ret:
11868 movups IV, (IVP)
11869 .Lctr_enc_just_ret:
11870 + pax_force_retaddr 0, 1
11871 ret
11872 +ENDPROC(aesni_ctr_enc)
11873 #endif
11874 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11875 index 391d245..67f35c2 100644
11876 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11877 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11878 @@ -20,6 +20,8 @@
11879 *
11880 */
11881
11882 +#include <asm/alternative-asm.h>
11883 +
11884 .file "blowfish-x86_64-asm.S"
11885 .text
11886
11887 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
11888 jnz __enc_xor;
11889
11890 write_block();
11891 + pax_force_retaddr 0, 1
11892 ret;
11893 __enc_xor:
11894 xor_block();
11895 + pax_force_retaddr 0, 1
11896 ret;
11897
11898 .align 8
11899 @@ -188,6 +192,7 @@ blowfish_dec_blk:
11900
11901 movq %r11, %rbp;
11902
11903 + pax_force_retaddr 0, 1
11904 ret;
11905
11906 /**********************************************************************
11907 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
11908
11909 popq %rbx;
11910 popq %rbp;
11911 + pax_force_retaddr 0, 1
11912 ret;
11913
11914 __enc_xor4:
11915 @@ -349,6 +355,7 @@ __enc_xor4:
11916
11917 popq %rbx;
11918 popq %rbp;
11919 + pax_force_retaddr 0, 1
11920 ret;
11921
11922 .align 8
11923 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
11924 popq %rbx;
11925 popq %rbp;
11926
11927 + pax_force_retaddr 0, 1
11928 ret;
11929
11930 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11931 index 0b33743..7a56206 100644
11932 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11933 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11934 @@ -20,6 +20,8 @@
11935 *
11936 */
11937
11938 +#include <asm/alternative-asm.h>
11939 +
11940 .file "camellia-x86_64-asm_64.S"
11941 .text
11942
11943 @@ -229,12 +231,14 @@ __enc_done:
11944 enc_outunpack(mov, RT1);
11945
11946 movq RRBP, %rbp;
11947 + pax_force_retaddr 0, 1
11948 ret;
11949
11950 __enc_xor:
11951 enc_outunpack(xor, RT1);
11952
11953 movq RRBP, %rbp;
11954 + pax_force_retaddr 0, 1
11955 ret;
11956
11957 .global camellia_dec_blk;
11958 @@ -275,6 +279,7 @@ __dec_rounds16:
11959 dec_outunpack();
11960
11961 movq RRBP, %rbp;
11962 + pax_force_retaddr 0, 1
11963 ret;
11964
11965 /**********************************************************************
11966 @@ -468,6 +473,7 @@ __enc2_done:
11967
11968 movq RRBP, %rbp;
11969 popq %rbx;
11970 + pax_force_retaddr 0, 1
11971 ret;
11972
11973 __enc2_xor:
11974 @@ -475,6 +481,7 @@ __enc2_xor:
11975
11976 movq RRBP, %rbp;
11977 popq %rbx;
11978 + pax_force_retaddr 0, 1
11979 ret;
11980
11981 .global camellia_dec_blk_2way;
11982 @@ -517,4 +524,5 @@ __dec2_rounds16:
11983
11984 movq RRBP, %rbp;
11985 movq RXOR, %rbx;
11986 + pax_force_retaddr 0, 1
11987 ret;
11988 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11989 index 15b00ac..2071784 100644
11990 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11991 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11992 @@ -23,6 +23,8 @@
11993 *
11994 */
11995
11996 +#include <asm/alternative-asm.h>
11997 +
11998 .file "cast5-avx-x86_64-asm_64.S"
11999
12000 .extern cast_s1
12001 @@ -281,6 +283,7 @@ __skip_enc:
12002 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12003 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12004
12005 + pax_force_retaddr 0, 1
12006 ret;
12007
12008 .align 16
12009 @@ -353,6 +356,7 @@ __dec_tail:
12010 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12011 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12012
12013 + pax_force_retaddr 0, 1
12014 ret;
12015
12016 __skip_dec:
12017 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
12018 vmovdqu RR4, (6*4*4)(%r11);
12019 vmovdqu RL4, (7*4*4)(%r11);
12020
12021 + pax_force_retaddr
12022 ret;
12023
12024 .align 16
12025 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
12026 vmovdqu RR4, (6*4*4)(%r11);
12027 vmovdqu RL4, (7*4*4)(%r11);
12028
12029 + pax_force_retaddr
12030 ret;
12031
12032 .align 16
12033 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
12034
12035 popq %r12;
12036
12037 + pax_force_retaddr
12038 ret;
12039
12040 .align 16
12041 @@ -555,4 +562,5 @@ cast5_ctr_16way:
12042
12043 popq %r12;
12044
12045 + pax_force_retaddr
12046 ret;
12047 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12048 index 2569d0d..637c289 100644
12049 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12050 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12051 @@ -23,6 +23,8 @@
12052 *
12053 */
12054
12055 +#include <asm/alternative-asm.h>
12056 +
12057 #include "glue_helper-asm-avx.S"
12058
12059 .file "cast6-avx-x86_64-asm_64.S"
12060 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
12061 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12062 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12063
12064 + pax_force_retaddr 0, 1
12065 ret;
12066
12067 .align 8
12068 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
12069 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12070 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12071
12072 + pax_force_retaddr 0, 1
12073 ret;
12074
12075 .align 8
12076 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
12077
12078 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12079
12080 + pax_force_retaddr
12081 ret;
12082
12083 .align 8
12084 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
12085
12086 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12087
12088 + pax_force_retaddr
12089 ret;
12090
12091 .align 8
12092 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
12093
12094 popq %r12;
12095
12096 + pax_force_retaddr
12097 ret;
12098
12099 .align 8
12100 @@ -436,4 +443,5 @@ cast6_ctr_8way:
12101
12102 popq %r12;
12103
12104 + pax_force_retaddr
12105 ret;
12106 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12107 index 6214a9b..1f4fc9a 100644
12108 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12109 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12110 @@ -1,3 +1,5 @@
12111 +#include <asm/alternative-asm.h>
12112 +
12113 # enter ECRYPT_encrypt_bytes
12114 .text
12115 .p2align 5
12116 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
12117 add %r11,%rsp
12118 mov %rdi,%rax
12119 mov %rsi,%rdx
12120 + pax_force_retaddr 0, 1
12121 ret
12122 # bytesatleast65:
12123 ._bytesatleast65:
12124 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
12125 add %r11,%rsp
12126 mov %rdi,%rax
12127 mov %rsi,%rdx
12128 + pax_force_retaddr
12129 ret
12130 # enter ECRYPT_ivsetup
12131 .text
12132 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
12133 add %r11,%rsp
12134 mov %rdi,%rax
12135 mov %rsi,%rdx
12136 + pax_force_retaddr
12137 ret
12138 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12139 index 02b0e9f..cf4cf5c 100644
12140 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12141 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12142 @@ -24,6 +24,8 @@
12143 *
12144 */
12145
12146 +#include <asm/alternative-asm.h>
12147 +
12148 #include "glue_helper-asm-avx.S"
12149
12150 .file "serpent-avx-x86_64-asm_64.S"
12151 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
12152 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12153 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12154
12155 + pax_force_retaddr
12156 ret;
12157
12158 .align 8
12159 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
12160 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12161 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12162
12163 + pax_force_retaddr
12164 ret;
12165
12166 .align 8
12167 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
12168
12169 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12170
12171 + pax_force_retaddr
12172 ret;
12173
12174 .align 8
12175 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
12176
12177 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12178
12179 + pax_force_retaddr
12180 ret;
12181
12182 .align 8
12183 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
12184
12185 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12186
12187 + pax_force_retaddr
12188 ret;
12189
12190 .align 8
12191 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
12192
12193 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12194
12195 + pax_force_retaddr
12196 ret;
12197 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12198 index 3ee1ff0..cbc568b 100644
12199 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12200 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12201 @@ -24,6 +24,8 @@
12202 *
12203 */
12204
12205 +#include <asm/alternative-asm.h>
12206 +
12207 .file "serpent-sse2-x86_64-asm_64.S"
12208 .text
12209
12210 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
12211 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12212 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12213
12214 + pax_force_retaddr
12215 ret;
12216
12217 __enc_xor8:
12218 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12219 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12220
12221 + pax_force_retaddr
12222 ret;
12223
12224 .align 8
12225 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
12226 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12227 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12228
12229 + pax_force_retaddr
12230 ret;
12231 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12232 index 49d6987..df66bd4 100644
12233 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12234 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12235 @@ -28,6 +28,8 @@
12236 * (at your option) any later version.
12237 */
12238
12239 +#include <asm/alternative-asm.h>
12240 +
12241 #define CTX %rdi // arg1
12242 #define BUF %rsi // arg2
12243 #define CNT %rdx // arg3
12244 @@ -104,6 +106,7 @@
12245 pop %r12
12246 pop %rbp
12247 pop %rbx
12248 + pax_force_retaddr 0, 1
12249 ret
12250
12251 .size \name, .-\name
12252 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
12253 index ebac16b..8092eb9 100644
12254 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
12255 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
12256 @@ -23,6 +23,8 @@
12257 *
12258 */
12259
12260 +#include <asm/alternative-asm.h>
12261 +
12262 #include "glue_helper-asm-avx.S"
12263
12264 .file "twofish-avx-x86_64-asm_64.S"
12265 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
12266 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
12267 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
12268
12269 + pax_force_retaddr 0, 1
12270 ret;
12271
12272 .align 8
12273 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
12274 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
12275 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
12276
12277 + pax_force_retaddr 0, 1
12278 ret;
12279
12280 .align 8
12281 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
12282
12283 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
12284
12285 + pax_force_retaddr 0, 1
12286 ret;
12287
12288 .align 8
12289 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
12290
12291 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12292
12293 + pax_force_retaddr 0, 1
12294 ret;
12295
12296 .align 8
12297 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
12298
12299 popq %r12;
12300
12301 + pax_force_retaddr 0, 1
12302 ret;
12303
12304 .align 8
12305 @@ -420,4 +427,5 @@ twofish_ctr_8way:
12306
12307 popq %r12;
12308
12309 + pax_force_retaddr 0, 1
12310 ret;
12311 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
12312 index 5b012a2..36d5364 100644
12313 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
12314 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
12315 @@ -20,6 +20,8 @@
12316 *
12317 */
12318
12319 +#include <asm/alternative-asm.h>
12320 +
12321 .file "twofish-x86_64-asm-3way.S"
12322 .text
12323
12324 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
12325 popq %r13;
12326 popq %r14;
12327 popq %r15;
12328 + pax_force_retaddr 0, 1
12329 ret;
12330
12331 __enc_xor3:
12332 @@ -271,6 +274,7 @@ __enc_xor3:
12333 popq %r13;
12334 popq %r14;
12335 popq %r15;
12336 + pax_force_retaddr 0, 1
12337 ret;
12338
12339 .global twofish_dec_blk_3way
12340 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
12341 popq %r13;
12342 popq %r14;
12343 popq %r15;
12344 + pax_force_retaddr 0, 1
12345 ret;
12346
12347 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
12348 index 7bcf3fc..f53832f 100644
12349 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
12350 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
12351 @@ -21,6 +21,7 @@
12352 .text
12353
12354 #include <asm/asm-offsets.h>
12355 +#include <asm/alternative-asm.h>
12356
12357 #define a_offset 0
12358 #define b_offset 4
12359 @@ -268,6 +269,7 @@ twofish_enc_blk:
12360
12361 popq R1
12362 movq $1,%rax
12363 + pax_force_retaddr 0, 1
12364 ret
12365
12366 twofish_dec_blk:
12367 @@ -319,4 +321,5 @@ twofish_dec_blk:
12368
12369 popq R1
12370 movq $1,%rax
12371 + pax_force_retaddr 0, 1
12372 ret
12373 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
12374 index a703af1..f5b9c36 100644
12375 --- a/arch/x86/ia32/ia32_aout.c
12376 +++ b/arch/x86/ia32/ia32_aout.c
12377 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
12378 unsigned long dump_start, dump_size;
12379 struct user32 dump;
12380
12381 + memset(&dump, 0, sizeof(dump));
12382 +
12383 fs = get_fs();
12384 set_fs(KERNEL_DS);
12385 has_dumped = 1;
12386 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
12387 index a1daf4a..f8c4537 100644
12388 --- a/arch/x86/ia32/ia32_signal.c
12389 +++ b/arch/x86/ia32/ia32_signal.c
12390 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
12391 sp -= frame_size;
12392 /* Align the stack pointer according to the i386 ABI,
12393 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
12394 - sp = ((sp + 4) & -16ul) - 4;
12395 + sp = ((sp - 12) & -16ul) - 4;
12396 return (void __user *) sp;
12397 }
12398
12399 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
12400 * These are actually not used anymore, but left because some
12401 * gdb versions depend on them as a marker.
12402 */
12403 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
12404 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
12405 } put_user_catch(err);
12406
12407 if (err)
12408 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
12409 0xb8,
12410 __NR_ia32_rt_sigreturn,
12411 0x80cd,
12412 - 0,
12413 + 0
12414 };
12415
12416 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
12417 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
12418
12419 if (ka->sa.sa_flags & SA_RESTORER)
12420 restorer = ka->sa.sa_restorer;
12421 + else if (current->mm->context.vdso)
12422 + /* Return stub is in 32bit vsyscall page */
12423 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
12424 else
12425 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
12426 - rt_sigreturn);
12427 + restorer = &frame->retcode;
12428 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
12429
12430 /*
12431 * Not actually used anymore, but left because some gdb
12432 * versions need it.
12433 */
12434 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
12435 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
12436 } put_user_catch(err);
12437
12438 err |= copy_siginfo_to_user32(&frame->info, info);
12439 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
12440 index 142c4ce..19b683f 100644
12441 --- a/arch/x86/ia32/ia32entry.S
12442 +++ b/arch/x86/ia32/ia32entry.S
12443 @@ -15,8 +15,10 @@
12444 #include <asm/irqflags.h>
12445 #include <asm/asm.h>
12446 #include <asm/smap.h>
12447 +#include <asm/pgtable.h>
12448 #include <linux/linkage.h>
12449 #include <linux/err.h>
12450 +#include <asm/alternative-asm.h>
12451
12452 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
12453 #include <linux/elf-em.h>
12454 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
12455 ENDPROC(native_irq_enable_sysexit)
12456 #endif
12457
12458 + .macro pax_enter_kernel_user
12459 + pax_set_fptr_mask
12460 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12461 + call pax_enter_kernel_user
12462 +#endif
12463 + .endm
12464 +
12465 + .macro pax_exit_kernel_user
12466 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12467 + call pax_exit_kernel_user
12468 +#endif
12469 +#ifdef CONFIG_PAX_RANDKSTACK
12470 + pushq %rax
12471 + pushq %r11
12472 + call pax_randomize_kstack
12473 + popq %r11
12474 + popq %rax
12475 +#endif
12476 + .endm
12477 +
12478 +.macro pax_erase_kstack
12479 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
12480 + call pax_erase_kstack
12481 +#endif
12482 +.endm
12483 +
12484 /*
12485 * 32bit SYSENTER instruction entry.
12486 *
12487 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
12488 CFI_REGISTER rsp,rbp
12489 SWAPGS_UNSAFE_STACK
12490 movq PER_CPU_VAR(kernel_stack), %rsp
12491 - addq $(KERNEL_STACK_OFFSET),%rsp
12492 - /*
12493 - * No need to follow this irqs on/off section: the syscall
12494 - * disabled irqs, here we enable it straight after entry:
12495 - */
12496 - ENABLE_INTERRUPTS(CLBR_NONE)
12497 movl %ebp,%ebp /* zero extension */
12498 pushq_cfi $__USER32_DS
12499 /*CFI_REL_OFFSET ss,0*/
12500 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
12501 CFI_REL_OFFSET rsp,0
12502 pushfq_cfi
12503 /*CFI_REL_OFFSET rflags,0*/
12504 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
12505 - CFI_REGISTER rip,r10
12506 + orl $X86_EFLAGS_IF,(%rsp)
12507 + GET_THREAD_INFO(%r11)
12508 + movl TI_sysenter_return(%r11), %r11d
12509 + CFI_REGISTER rip,r11
12510 pushq_cfi $__USER32_CS
12511 /*CFI_REL_OFFSET cs,0*/
12512 movl %eax, %eax
12513 - pushq_cfi %r10
12514 + pushq_cfi %r11
12515 CFI_REL_OFFSET rip,0
12516 pushq_cfi %rax
12517 cld
12518 SAVE_ARGS 0,1,0
12519 + pax_enter_kernel_user
12520 +
12521 +#ifdef CONFIG_PAX_RANDKSTACK
12522 + pax_erase_kstack
12523 +#endif
12524 +
12525 + /*
12526 + * No need to follow this irqs on/off section: the syscall
12527 + * disabled irqs, here we enable it straight after entry:
12528 + */
12529 + ENABLE_INTERRUPTS(CLBR_NONE)
12530 /* no need to do an access_ok check here because rbp has been
12531 32bit zero extended */
12532 +
12533 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12534 + mov $PAX_USER_SHADOW_BASE,%r11
12535 + add %r11,%rbp
12536 +#endif
12537 +
12538 ASM_STAC
12539 1: movl (%rbp),%ebp
12540 _ASM_EXTABLE(1b,ia32_badarg)
12541 ASM_CLAC
12542 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12543 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12544 + GET_THREAD_INFO(%r11)
12545 + orl $TS_COMPAT,TI_status(%r11)
12546 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12547 CFI_REMEMBER_STATE
12548 jnz sysenter_tracesys
12549 cmpq $(IA32_NR_syscalls-1),%rax
12550 @@ -162,12 +204,15 @@ sysenter_do_call:
12551 sysenter_dispatch:
12552 call *ia32_sys_call_table(,%rax,8)
12553 movq %rax,RAX-ARGOFFSET(%rsp)
12554 + GET_THREAD_INFO(%r11)
12555 DISABLE_INTERRUPTS(CLBR_NONE)
12556 TRACE_IRQS_OFF
12557 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12558 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12559 jnz sysexit_audit
12560 sysexit_from_sys_call:
12561 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12562 + pax_exit_kernel_user
12563 + pax_erase_kstack
12564 + andl $~TS_COMPAT,TI_status(%r11)
12565 /* clear IF, that popfq doesn't enable interrupts early */
12566 andl $~0x200,EFLAGS-R11(%rsp)
12567 movl RIP-R11(%rsp),%edx /* User %eip */
12568 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
12569 movl %eax,%esi /* 2nd arg: syscall number */
12570 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
12571 call __audit_syscall_entry
12572 +
12573 + pax_erase_kstack
12574 +
12575 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
12576 cmpq $(IA32_NR_syscalls-1),%rax
12577 ja ia32_badsys
12578 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
12579 .endm
12580
12581 .macro auditsys_exit exit
12582 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12583 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12584 jnz ia32_ret_from_sys_call
12585 TRACE_IRQS_ON
12586 ENABLE_INTERRUPTS(CLBR_NONE)
12587 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
12588 1: setbe %al /* 1 if error, 0 if not */
12589 movzbl %al,%edi /* zero-extend that into %edi */
12590 call __audit_syscall_exit
12591 + GET_THREAD_INFO(%r11)
12592 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
12593 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
12594 DISABLE_INTERRUPTS(CLBR_NONE)
12595 TRACE_IRQS_OFF
12596 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12597 + testl %edi,TI_flags(%r11)
12598 jz \exit
12599 CLEAR_RREGS -ARGOFFSET
12600 jmp int_with_check
12601 @@ -237,7 +286,7 @@ sysexit_audit:
12602
12603 sysenter_tracesys:
12604 #ifdef CONFIG_AUDITSYSCALL
12605 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12606 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12607 jz sysenter_auditsys
12608 #endif
12609 SAVE_REST
12610 @@ -249,6 +298,9 @@ sysenter_tracesys:
12611 RESTORE_REST
12612 cmpq $(IA32_NR_syscalls-1),%rax
12613 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
12614 +
12615 + pax_erase_kstack
12616 +
12617 jmp sysenter_do_call
12618 CFI_ENDPROC
12619 ENDPROC(ia32_sysenter_target)
12620 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
12621 ENTRY(ia32_cstar_target)
12622 CFI_STARTPROC32 simple
12623 CFI_SIGNAL_FRAME
12624 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
12625 + CFI_DEF_CFA rsp,0
12626 CFI_REGISTER rip,rcx
12627 /*CFI_REGISTER rflags,r11*/
12628 SWAPGS_UNSAFE_STACK
12629 movl %esp,%r8d
12630 CFI_REGISTER rsp,r8
12631 movq PER_CPU_VAR(kernel_stack),%rsp
12632 + SAVE_ARGS 8*6,0,0
12633 + pax_enter_kernel_user
12634 +
12635 +#ifdef CONFIG_PAX_RANDKSTACK
12636 + pax_erase_kstack
12637 +#endif
12638 +
12639 /*
12640 * No need to follow this irqs on/off section: the syscall
12641 * disabled irqs and here we enable it straight after entry:
12642 */
12643 ENABLE_INTERRUPTS(CLBR_NONE)
12644 - SAVE_ARGS 8,0,0
12645 movl %eax,%eax /* zero extension */
12646 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
12647 movq %rcx,RIP-ARGOFFSET(%rsp)
12648 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
12649 /* no need to do an access_ok check here because r8 has been
12650 32bit zero extended */
12651 /* hardware stack frame is complete now */
12652 +
12653 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12654 + mov $PAX_USER_SHADOW_BASE,%r11
12655 + add %r11,%r8
12656 +#endif
12657 +
12658 ASM_STAC
12659 1: movl (%r8),%r9d
12660 _ASM_EXTABLE(1b,ia32_badarg)
12661 ASM_CLAC
12662 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12663 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12664 + GET_THREAD_INFO(%r11)
12665 + orl $TS_COMPAT,TI_status(%r11)
12666 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12667 CFI_REMEMBER_STATE
12668 jnz cstar_tracesys
12669 cmpq $IA32_NR_syscalls-1,%rax
12670 @@ -319,12 +384,15 @@ cstar_do_call:
12671 cstar_dispatch:
12672 call *ia32_sys_call_table(,%rax,8)
12673 movq %rax,RAX-ARGOFFSET(%rsp)
12674 + GET_THREAD_INFO(%r11)
12675 DISABLE_INTERRUPTS(CLBR_NONE)
12676 TRACE_IRQS_OFF
12677 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12678 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12679 jnz sysretl_audit
12680 sysretl_from_sys_call:
12681 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12682 + pax_exit_kernel_user
12683 + pax_erase_kstack
12684 + andl $~TS_COMPAT,TI_status(%r11)
12685 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
12686 movl RIP-ARGOFFSET(%rsp),%ecx
12687 CFI_REGISTER rip,rcx
12688 @@ -352,7 +420,7 @@ sysretl_audit:
12689
12690 cstar_tracesys:
12691 #ifdef CONFIG_AUDITSYSCALL
12692 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12693 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12694 jz cstar_auditsys
12695 #endif
12696 xchgl %r9d,%ebp
12697 @@ -366,6 +434,9 @@ cstar_tracesys:
12698 xchgl %ebp,%r9d
12699 cmpq $(IA32_NR_syscalls-1),%rax
12700 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
12701 +
12702 + pax_erase_kstack
12703 +
12704 jmp cstar_do_call
12705 END(ia32_cstar_target)
12706
12707 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
12708 CFI_REL_OFFSET rip,RIP-RIP
12709 PARAVIRT_ADJUST_EXCEPTION_FRAME
12710 SWAPGS
12711 - /*
12712 - * No need to follow this irqs on/off section: the syscall
12713 - * disabled irqs and here we enable it straight after entry:
12714 - */
12715 - ENABLE_INTERRUPTS(CLBR_NONE)
12716 movl %eax,%eax
12717 pushq_cfi %rax
12718 cld
12719 /* note the registers are not zero extended to the sf.
12720 this could be a problem. */
12721 SAVE_ARGS 0,1,0
12722 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12723 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12724 + pax_enter_kernel_user
12725 +
12726 +#ifdef CONFIG_PAX_RANDKSTACK
12727 + pax_erase_kstack
12728 +#endif
12729 +
12730 + /*
12731 + * No need to follow this irqs on/off section: the syscall
12732 + * disabled irqs and here we enable it straight after entry:
12733 + */
12734 + ENABLE_INTERRUPTS(CLBR_NONE)
12735 + GET_THREAD_INFO(%r11)
12736 + orl $TS_COMPAT,TI_status(%r11)
12737 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12738 jnz ia32_tracesys
12739 cmpq $(IA32_NR_syscalls-1),%rax
12740 ja ia32_badsys
12741 @@ -442,6 +520,9 @@ ia32_tracesys:
12742 RESTORE_REST
12743 cmpq $(IA32_NR_syscalls-1),%rax
12744 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
12745 +
12746 + pax_erase_kstack
12747 +
12748 jmp ia32_do_call
12749 END(ia32_syscall)
12750
12751 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
12752 index d0b689b..6811ddc 100644
12753 --- a/arch/x86/ia32/sys_ia32.c
12754 +++ b/arch/x86/ia32/sys_ia32.c
12755 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
12756 */
12757 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
12758 {
12759 - typeof(ubuf->st_uid) uid = 0;
12760 - typeof(ubuf->st_gid) gid = 0;
12761 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
12762 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
12763 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
12764 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
12765 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
12766 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12767 mm_segment_t old_fs = get_fs();
12768
12769 set_fs(KERNEL_DS);
12770 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
12771 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
12772 set_fs(old_fs);
12773 if (put_compat_timespec(&t, interval))
12774 return -EFAULT;
12775 @@ -313,13 +313,13 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12776 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
12777 compat_size_t sigsetsize)
12778 {
12779 - sigset_t s;
12780 + sigset_t s = { };
12781 compat_sigset_t s32;
12782 int ret;
12783 mm_segment_t old_fs = get_fs();
12784
12785 set_fs(KERNEL_DS);
12786 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
12787 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
12788 set_fs(old_fs);
12789 if (!ret) {
12790 switch (_NSIG_WORDS) {
12791 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
12792 if (copy_siginfo_from_user32(&info, uinfo))
12793 return -EFAULT;
12794 set_fs(KERNEL_DS);
12795 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
12796 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
12797 set_fs(old_fs);
12798 return ret;
12799 }
12800 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
12801 return -EFAULT;
12802
12803 set_fs(KERNEL_DS);
12804 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
12805 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
12806 count);
12807 set_fs(old_fs);
12808
12809 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
12810 index 372231c..a5aa1a1 100644
12811 --- a/arch/x86/include/asm/alternative-asm.h
12812 +++ b/arch/x86/include/asm/alternative-asm.h
12813 @@ -18,6 +18,45 @@
12814 .endm
12815 #endif
12816
12817 +#ifdef KERNEXEC_PLUGIN
12818 + .macro pax_force_retaddr_bts rip=0
12819 + btsq $63,\rip(%rsp)
12820 + .endm
12821 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
12822 + .macro pax_force_retaddr rip=0, reload=0
12823 + btsq $63,\rip(%rsp)
12824 + .endm
12825 + .macro pax_force_fptr ptr
12826 + btsq $63,\ptr
12827 + .endm
12828 + .macro pax_set_fptr_mask
12829 + .endm
12830 +#endif
12831 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
12832 + .macro pax_force_retaddr rip=0, reload=0
12833 + .if \reload
12834 + pax_set_fptr_mask
12835 + .endif
12836 + orq %r10,\rip(%rsp)
12837 + .endm
12838 + .macro pax_force_fptr ptr
12839 + orq %r10,\ptr
12840 + .endm
12841 + .macro pax_set_fptr_mask
12842 + movabs $0x8000000000000000,%r10
12843 + .endm
12844 +#endif
12845 +#else
12846 + .macro pax_force_retaddr rip=0, reload=0
12847 + .endm
12848 + .macro pax_force_fptr ptr
12849 + .endm
12850 + .macro pax_force_retaddr_bts rip=0
12851 + .endm
12852 + .macro pax_set_fptr_mask
12853 + .endm
12854 +#endif
12855 +
12856 .macro altinstruction_entry orig alt feature orig_len alt_len
12857 .long \orig - .
12858 .long \alt - .
12859 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
12860 index 58ed6d9..f1cbe58 100644
12861 --- a/arch/x86/include/asm/alternative.h
12862 +++ b/arch/x86/include/asm/alternative.h
12863 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12864 ".pushsection .discard,\"aw\",@progbits\n" \
12865 DISCARD_ENTRY(1) \
12866 ".popsection\n" \
12867 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12868 + ".pushsection .altinstr_replacement, \"a\"\n" \
12869 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
12870 ".popsection"
12871
12872 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12873 DISCARD_ENTRY(1) \
12874 DISCARD_ENTRY(2) \
12875 ".popsection\n" \
12876 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12877 + ".pushsection .altinstr_replacement, \"a\"\n" \
12878 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
12879 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
12880 ".popsection"
12881 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
12882 index 3388034..050f0b9 100644
12883 --- a/arch/x86/include/asm/apic.h
12884 +++ b/arch/x86/include/asm/apic.h
12885 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
12886
12887 #ifdef CONFIG_X86_LOCAL_APIC
12888
12889 -extern unsigned int apic_verbosity;
12890 +extern int apic_verbosity;
12891 extern int local_apic_timer_c2_ok;
12892
12893 extern int disable_apic;
12894 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
12895 index 20370c6..a2eb9b0 100644
12896 --- a/arch/x86/include/asm/apm.h
12897 +++ b/arch/x86/include/asm/apm.h
12898 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12899 __asm__ __volatile__(APM_DO_ZERO_SEGS
12900 "pushl %%edi\n\t"
12901 "pushl %%ebp\n\t"
12902 - "lcall *%%cs:apm_bios_entry\n\t"
12903 + "lcall *%%ss:apm_bios_entry\n\t"
12904 "setc %%al\n\t"
12905 "popl %%ebp\n\t"
12906 "popl %%edi\n\t"
12907 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12908 __asm__ __volatile__(APM_DO_ZERO_SEGS
12909 "pushl %%edi\n\t"
12910 "pushl %%ebp\n\t"
12911 - "lcall *%%cs:apm_bios_entry\n\t"
12912 + "lcall *%%ss:apm_bios_entry\n\t"
12913 "setc %%bl\n\t"
12914 "popl %%ebp\n\t"
12915 "popl %%edi\n\t"
12916 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12917 index 722aa3b..3a0bb27 100644
12918 --- a/arch/x86/include/asm/atomic.h
12919 +++ b/arch/x86/include/asm/atomic.h
12920 @@ -22,7 +22,18 @@
12921 */
12922 static inline int atomic_read(const atomic_t *v)
12923 {
12924 - return (*(volatile int *)&(v)->counter);
12925 + return (*(volatile const int *)&(v)->counter);
12926 +}
12927 +
12928 +/**
12929 + * atomic_read_unchecked - read atomic variable
12930 + * @v: pointer of type atomic_unchecked_t
12931 + *
12932 + * Atomically reads the value of @v.
12933 + */
12934 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12935 +{
12936 + return (*(volatile const int *)&(v)->counter);
12937 }
12938
12939 /**
12940 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12941 }
12942
12943 /**
12944 + * atomic_set_unchecked - set atomic variable
12945 + * @v: pointer of type atomic_unchecked_t
12946 + * @i: required value
12947 + *
12948 + * Atomically sets the value of @v to @i.
12949 + */
12950 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12951 +{
12952 + v->counter = i;
12953 +}
12954 +
12955 +/**
12956 * atomic_add - add integer to atomic variable
12957 * @i: integer value to add
12958 * @v: pointer of type atomic_t
12959 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12960 */
12961 static inline void atomic_add(int i, atomic_t *v)
12962 {
12963 - asm volatile(LOCK_PREFIX "addl %1,%0"
12964 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12965 +
12966 +#ifdef CONFIG_PAX_REFCOUNT
12967 + "jno 0f\n"
12968 + LOCK_PREFIX "subl %1,%0\n"
12969 + "int $4\n0:\n"
12970 + _ASM_EXTABLE(0b, 0b)
12971 +#endif
12972 +
12973 + : "+m" (v->counter)
12974 + : "ir" (i));
12975 +}
12976 +
12977 +/**
12978 + * atomic_add_unchecked - add integer to atomic variable
12979 + * @i: integer value to add
12980 + * @v: pointer of type atomic_unchecked_t
12981 + *
12982 + * Atomically adds @i to @v.
12983 + */
12984 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12985 +{
12986 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12987 : "+m" (v->counter)
12988 : "ir" (i));
12989 }
12990 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12991 */
12992 static inline void atomic_sub(int i, atomic_t *v)
12993 {
12994 - asm volatile(LOCK_PREFIX "subl %1,%0"
12995 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12996 +
12997 +#ifdef CONFIG_PAX_REFCOUNT
12998 + "jno 0f\n"
12999 + LOCK_PREFIX "addl %1,%0\n"
13000 + "int $4\n0:\n"
13001 + _ASM_EXTABLE(0b, 0b)
13002 +#endif
13003 +
13004 + : "+m" (v->counter)
13005 + : "ir" (i));
13006 +}
13007 +
13008 +/**
13009 + * atomic_sub_unchecked - subtract integer from atomic variable
13010 + * @i: integer value to subtract
13011 + * @v: pointer of type atomic_unchecked_t
13012 + *
13013 + * Atomically subtracts @i from @v.
13014 + */
13015 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13016 +{
13017 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13018 : "+m" (v->counter)
13019 : "ir" (i));
13020 }
13021 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13022 {
13023 unsigned char c;
13024
13025 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13026 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13027 +
13028 +#ifdef CONFIG_PAX_REFCOUNT
13029 + "jno 0f\n"
13030 + LOCK_PREFIX "addl %2,%0\n"
13031 + "int $4\n0:\n"
13032 + _ASM_EXTABLE(0b, 0b)
13033 +#endif
13034 +
13035 + "sete %1\n"
13036 : "+m" (v->counter), "=qm" (c)
13037 : "ir" (i) : "memory");
13038 return c;
13039 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13040 */
13041 static inline void atomic_inc(atomic_t *v)
13042 {
13043 - asm volatile(LOCK_PREFIX "incl %0"
13044 + asm volatile(LOCK_PREFIX "incl %0\n"
13045 +
13046 +#ifdef CONFIG_PAX_REFCOUNT
13047 + "jno 0f\n"
13048 + LOCK_PREFIX "decl %0\n"
13049 + "int $4\n0:\n"
13050 + _ASM_EXTABLE(0b, 0b)
13051 +#endif
13052 +
13053 + : "+m" (v->counter));
13054 +}
13055 +
13056 +/**
13057 + * atomic_inc_unchecked - increment atomic variable
13058 + * @v: pointer of type atomic_unchecked_t
13059 + *
13060 + * Atomically increments @v by 1.
13061 + */
13062 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13063 +{
13064 + asm volatile(LOCK_PREFIX "incl %0\n"
13065 : "+m" (v->counter));
13066 }
13067
13068 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13069 */
13070 static inline void atomic_dec(atomic_t *v)
13071 {
13072 - asm volatile(LOCK_PREFIX "decl %0"
13073 + asm volatile(LOCK_PREFIX "decl %0\n"
13074 +
13075 +#ifdef CONFIG_PAX_REFCOUNT
13076 + "jno 0f\n"
13077 + LOCK_PREFIX "incl %0\n"
13078 + "int $4\n0:\n"
13079 + _ASM_EXTABLE(0b, 0b)
13080 +#endif
13081 +
13082 + : "+m" (v->counter));
13083 +}
13084 +
13085 +/**
13086 + * atomic_dec_unchecked - decrement atomic variable
13087 + * @v: pointer of type atomic_unchecked_t
13088 + *
13089 + * Atomically decrements @v by 1.
13090 + */
13091 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13092 +{
13093 + asm volatile(LOCK_PREFIX "decl %0\n"
13094 : "+m" (v->counter));
13095 }
13096
13097 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13098 {
13099 unsigned char c;
13100
13101 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13102 + asm volatile(LOCK_PREFIX "decl %0\n"
13103 +
13104 +#ifdef CONFIG_PAX_REFCOUNT
13105 + "jno 0f\n"
13106 + LOCK_PREFIX "incl %0\n"
13107 + "int $4\n0:\n"
13108 + _ASM_EXTABLE(0b, 0b)
13109 +#endif
13110 +
13111 + "sete %1\n"
13112 : "+m" (v->counter), "=qm" (c)
13113 : : "memory");
13114 return c != 0;
13115 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13116 {
13117 unsigned char c;
13118
13119 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13120 + asm volatile(LOCK_PREFIX "incl %0\n"
13121 +
13122 +#ifdef CONFIG_PAX_REFCOUNT
13123 + "jno 0f\n"
13124 + LOCK_PREFIX "decl %0\n"
13125 + "int $4\n0:\n"
13126 + _ASM_EXTABLE(0b, 0b)
13127 +#endif
13128 +
13129 + "sete %1\n"
13130 + : "+m" (v->counter), "=qm" (c)
13131 + : : "memory");
13132 + return c != 0;
13133 +}
13134 +
13135 +/**
13136 + * atomic_inc_and_test_unchecked - increment and test
13137 + * @v: pointer of type atomic_unchecked_t
13138 + *
13139 + * Atomically increments @v by 1
13140 + * and returns true if the result is zero, or false for all
13141 + * other cases.
13142 + */
13143 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
13144 +{
13145 + unsigned char c;
13146 +
13147 + asm volatile(LOCK_PREFIX "incl %0\n"
13148 + "sete %1\n"
13149 : "+m" (v->counter), "=qm" (c)
13150 : : "memory");
13151 return c != 0;
13152 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13153 {
13154 unsigned char c;
13155
13156 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
13157 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
13158 +
13159 +#ifdef CONFIG_PAX_REFCOUNT
13160 + "jno 0f\n"
13161 + LOCK_PREFIX "subl %2,%0\n"
13162 + "int $4\n0:\n"
13163 + _ASM_EXTABLE(0b, 0b)
13164 +#endif
13165 +
13166 + "sets %1\n"
13167 : "+m" (v->counter), "=qm" (c)
13168 : "ir" (i) : "memory");
13169 return c;
13170 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13171 */
13172 static inline int atomic_add_return(int i, atomic_t *v)
13173 {
13174 + return i + xadd_check_overflow(&v->counter, i);
13175 +}
13176 +
13177 +/**
13178 + * atomic_add_return_unchecked - add integer and return
13179 + * @i: integer value to add
13180 + * @v: pointer of type atomic_unchecked_t
13181 + *
13182 + * Atomically adds @i to @v and returns @i + @v
13183 + */
13184 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
13185 +{
13186 return i + xadd(&v->counter, i);
13187 }
13188
13189 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
13190 }
13191
13192 #define atomic_inc_return(v) (atomic_add_return(1, v))
13193 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
13194 +{
13195 + return atomic_add_return_unchecked(1, v);
13196 +}
13197 #define atomic_dec_return(v) (atomic_sub_return(1, v))
13198
13199 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
13200 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
13201 return cmpxchg(&v->counter, old, new);
13202 }
13203
13204 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
13205 +{
13206 + return cmpxchg(&v->counter, old, new);
13207 +}
13208 +
13209 static inline int atomic_xchg(atomic_t *v, int new)
13210 {
13211 return xchg(&v->counter, new);
13212 }
13213
13214 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
13215 +{
13216 + return xchg(&v->counter, new);
13217 +}
13218 +
13219 /**
13220 * __atomic_add_unless - add unless the number is already a given value
13221 * @v: pointer of type atomic_t
13222 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
13223 */
13224 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
13225 {
13226 - int c, old;
13227 + int c, old, new;
13228 c = atomic_read(v);
13229 for (;;) {
13230 - if (unlikely(c == (u)))
13231 + if (unlikely(c == u))
13232 break;
13233 - old = atomic_cmpxchg((v), c, c + (a));
13234 +
13235 + asm volatile("addl %2,%0\n"
13236 +
13237 +#ifdef CONFIG_PAX_REFCOUNT
13238 + "jno 0f\n"
13239 + "subl %2,%0\n"
13240 + "int $4\n0:\n"
13241 + _ASM_EXTABLE(0b, 0b)
13242 +#endif
13243 +
13244 + : "=r" (new)
13245 + : "0" (c), "ir" (a));
13246 +
13247 + old = atomic_cmpxchg(v, c, new);
13248 if (likely(old == c))
13249 break;
13250 c = old;
13251 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
13252 }
13253
13254 /**
13255 + * atomic_inc_not_zero_hint - increment if not null
13256 + * @v: pointer of type atomic_t
13257 + * @hint: probable value of the atomic before the increment
13258 + *
13259 + * This version of atomic_inc_not_zero() gives a hint of probable
13260 + * value of the atomic. This helps processor to not read the memory
13261 + * before doing the atomic read/modify/write cycle, lowering
13262 + * number of bus transactions on some arches.
13263 + *
13264 + * Returns: 0 if increment was not done, 1 otherwise.
13265 + */
13266 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
13267 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
13268 +{
13269 + int val, c = hint, new;
13270 +
13271 + /* sanity test, should be removed by compiler if hint is a constant */
13272 + if (!hint)
13273 + return __atomic_add_unless(v, 1, 0);
13274 +
13275 + do {
13276 + asm volatile("incl %0\n"
13277 +
13278 +#ifdef CONFIG_PAX_REFCOUNT
13279 + "jno 0f\n"
13280 + "decl %0\n"
13281 + "int $4\n0:\n"
13282 + _ASM_EXTABLE(0b, 0b)
13283 +#endif
13284 +
13285 + : "=r" (new)
13286 + : "0" (c));
13287 +
13288 + val = atomic_cmpxchg(v, c, new);
13289 + if (val == c)
13290 + return 1;
13291 + c = val;
13292 + } while (c);
13293 +
13294 + return 0;
13295 +}
13296 +
13297 +/**
13298 * atomic_inc_short - increment of a short integer
13299 * @v: pointer to type int
13300 *
13301 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
13302 #endif
13303
13304 /* These are x86-specific, used by some header files */
13305 -#define atomic_clear_mask(mask, addr) \
13306 - asm volatile(LOCK_PREFIX "andl %0,%1" \
13307 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
13308 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
13309 +{
13310 + asm volatile(LOCK_PREFIX "andl %1,%0"
13311 + : "+m" (v->counter)
13312 + : "r" (~(mask))
13313 + : "memory");
13314 +}
13315
13316 -#define atomic_set_mask(mask, addr) \
13317 - asm volatile(LOCK_PREFIX "orl %0,%1" \
13318 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
13319 - : "memory")
13320 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
13321 +{
13322 + asm volatile(LOCK_PREFIX "andl %1,%0"
13323 + : "+m" (v->counter)
13324 + : "r" (~(mask))
13325 + : "memory");
13326 +}
13327 +
13328 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
13329 +{
13330 + asm volatile(LOCK_PREFIX "orl %1,%0"
13331 + : "+m" (v->counter)
13332 + : "r" (mask)
13333 + : "memory");
13334 +}
13335 +
13336 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
13337 +{
13338 + asm volatile(LOCK_PREFIX "orl %1,%0"
13339 + : "+m" (v->counter)
13340 + : "r" (mask)
13341 + : "memory");
13342 +}
13343
13344 /* Atomic operations are already serializing on x86 */
13345 #define smp_mb__before_atomic_dec() barrier()
13346 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
13347 index b154de7..aadebd8 100644
13348 --- a/arch/x86/include/asm/atomic64_32.h
13349 +++ b/arch/x86/include/asm/atomic64_32.h
13350 @@ -12,6 +12,14 @@ typedef struct {
13351 u64 __aligned(8) counter;
13352 } atomic64_t;
13353
13354 +#ifdef CONFIG_PAX_REFCOUNT
13355 +typedef struct {
13356 + u64 __aligned(8) counter;
13357 +} atomic64_unchecked_t;
13358 +#else
13359 +typedef atomic64_t atomic64_unchecked_t;
13360 +#endif
13361 +
13362 #define ATOMIC64_INIT(val) { (val) }
13363
13364 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
13365 @@ -37,21 +45,31 @@ typedef struct {
13366 ATOMIC64_DECL_ONE(sym##_386)
13367
13368 ATOMIC64_DECL_ONE(add_386);
13369 +ATOMIC64_DECL_ONE(add_unchecked_386);
13370 ATOMIC64_DECL_ONE(sub_386);
13371 +ATOMIC64_DECL_ONE(sub_unchecked_386);
13372 ATOMIC64_DECL_ONE(inc_386);
13373 +ATOMIC64_DECL_ONE(inc_unchecked_386);
13374 ATOMIC64_DECL_ONE(dec_386);
13375 +ATOMIC64_DECL_ONE(dec_unchecked_386);
13376 #endif
13377
13378 #define alternative_atomic64(f, out, in...) \
13379 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
13380
13381 ATOMIC64_DECL(read);
13382 +ATOMIC64_DECL(read_unchecked);
13383 ATOMIC64_DECL(set);
13384 +ATOMIC64_DECL(set_unchecked);
13385 ATOMIC64_DECL(xchg);
13386 ATOMIC64_DECL(add_return);
13387 +ATOMIC64_DECL(add_return_unchecked);
13388 ATOMIC64_DECL(sub_return);
13389 +ATOMIC64_DECL(sub_return_unchecked);
13390 ATOMIC64_DECL(inc_return);
13391 +ATOMIC64_DECL(inc_return_unchecked);
13392 ATOMIC64_DECL(dec_return);
13393 +ATOMIC64_DECL(dec_return_unchecked);
13394 ATOMIC64_DECL(dec_if_positive);
13395 ATOMIC64_DECL(inc_not_zero);
13396 ATOMIC64_DECL(add_unless);
13397 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
13398 }
13399
13400 /**
13401 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
13402 + * @p: pointer to type atomic64_unchecked_t
13403 + * @o: expected value
13404 + * @n: new value
13405 + *
13406 + * Atomically sets @v to @n if it was equal to @o and returns
13407 + * the old value.
13408 + */
13409 +
13410 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
13411 +{
13412 + return cmpxchg64(&v->counter, o, n);
13413 +}
13414 +
13415 +/**
13416 * atomic64_xchg - xchg atomic64 variable
13417 * @v: pointer to type atomic64_t
13418 * @n: value to assign
13419 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
13420 }
13421
13422 /**
13423 + * atomic64_set_unchecked - set atomic64 variable
13424 + * @v: pointer to type atomic64_unchecked_t
13425 + * @n: value to assign
13426 + *
13427 + * Atomically sets the value of @v to @n.
13428 + */
13429 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
13430 +{
13431 + unsigned high = (unsigned)(i >> 32);
13432 + unsigned low = (unsigned)i;
13433 + alternative_atomic64(set, /* no output */,
13434 + "S" (v), "b" (low), "c" (high)
13435 + : "eax", "edx", "memory");
13436 +}
13437 +
13438 +/**
13439 * atomic64_read - read atomic64 variable
13440 * @v: pointer to type atomic64_t
13441 *
13442 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
13443 }
13444
13445 /**
13446 + * atomic64_read_unchecked - read atomic64 variable
13447 + * @v: pointer to type atomic64_unchecked_t
13448 + *
13449 + * Atomically reads the value of @v and returns it.
13450 + */
13451 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
13452 +{
13453 + long long r;
13454 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
13455 + return r;
13456 + }
13457 +
13458 +/**
13459 * atomic64_add_return - add and return
13460 * @i: integer value to add
13461 * @v: pointer to type atomic64_t
13462 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
13463 return i;
13464 }
13465
13466 +/**
13467 + * atomic64_add_return_unchecked - add and return
13468 + * @i: integer value to add
13469 + * @v: pointer to type atomic64_unchecked_t
13470 + *
13471 + * Atomically adds @i to @v and returns @i + *@v
13472 + */
13473 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
13474 +{
13475 + alternative_atomic64(add_return_unchecked,
13476 + ASM_OUTPUT2("+A" (i), "+c" (v)),
13477 + ASM_NO_INPUT_CLOBBER("memory"));
13478 + return i;
13479 +}
13480 +
13481 /*
13482 * Other variants with different arithmetic operators:
13483 */
13484 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
13485 return a;
13486 }
13487
13488 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13489 +{
13490 + long long a;
13491 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
13492 + "S" (v) : "memory", "ecx");
13493 + return a;
13494 +}
13495 +
13496 static inline long long atomic64_dec_return(atomic64_t *v)
13497 {
13498 long long a;
13499 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
13500 }
13501
13502 /**
13503 + * atomic64_add_unchecked - add integer to atomic64 variable
13504 + * @i: integer value to add
13505 + * @v: pointer to type atomic64_unchecked_t
13506 + *
13507 + * Atomically adds @i to @v.
13508 + */
13509 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
13510 +{
13511 + __alternative_atomic64(add_unchecked, add_return_unchecked,
13512 + ASM_OUTPUT2("+A" (i), "+c" (v)),
13513 + ASM_NO_INPUT_CLOBBER("memory"));
13514 + return i;
13515 +}
13516 +
13517 +/**
13518 * atomic64_sub - subtract the atomic64 variable
13519 * @i: integer value to subtract
13520 * @v: pointer to type atomic64_t
13521 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
13522 index 0e1cbfc..5623683 100644
13523 --- a/arch/x86/include/asm/atomic64_64.h
13524 +++ b/arch/x86/include/asm/atomic64_64.h
13525 @@ -18,7 +18,19 @@
13526 */
13527 static inline long atomic64_read(const atomic64_t *v)
13528 {
13529 - return (*(volatile long *)&(v)->counter);
13530 + return (*(volatile const long *)&(v)->counter);
13531 +}
13532 +
13533 +/**
13534 + * atomic64_read_unchecked - read atomic64 variable
13535 + * @v: pointer of type atomic64_unchecked_t
13536 + *
13537 + * Atomically reads the value of @v.
13538 + * Doesn't imply a read memory barrier.
13539 + */
13540 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
13541 +{
13542 + return (*(volatile const long *)&(v)->counter);
13543 }
13544
13545 /**
13546 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
13547 }
13548
13549 /**
13550 + * atomic64_set_unchecked - set atomic64 variable
13551 + * @v: pointer to type atomic64_unchecked_t
13552 + * @i: required value
13553 + *
13554 + * Atomically sets the value of @v to @i.
13555 + */
13556 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
13557 +{
13558 + v->counter = i;
13559 +}
13560 +
13561 +/**
13562 * atomic64_add - add integer to atomic64 variable
13563 * @i: integer value to add
13564 * @v: pointer to type atomic64_t
13565 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
13566 */
13567 static inline void atomic64_add(long i, atomic64_t *v)
13568 {
13569 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
13570 +
13571 +#ifdef CONFIG_PAX_REFCOUNT
13572 + "jno 0f\n"
13573 + LOCK_PREFIX "subq %1,%0\n"
13574 + "int $4\n0:\n"
13575 + _ASM_EXTABLE(0b, 0b)
13576 +#endif
13577 +
13578 + : "=m" (v->counter)
13579 + : "er" (i), "m" (v->counter));
13580 +}
13581 +
13582 +/**
13583 + * atomic64_add_unchecked - add integer to atomic64 variable
13584 + * @i: integer value to add
13585 + * @v: pointer to type atomic64_unchecked_t
13586 + *
13587 + * Atomically adds @i to @v.
13588 + */
13589 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
13590 +{
13591 asm volatile(LOCK_PREFIX "addq %1,%0"
13592 : "=m" (v->counter)
13593 : "er" (i), "m" (v->counter));
13594 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
13595 */
13596 static inline void atomic64_sub(long i, atomic64_t *v)
13597 {
13598 - asm volatile(LOCK_PREFIX "subq %1,%0"
13599 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13600 +
13601 +#ifdef CONFIG_PAX_REFCOUNT
13602 + "jno 0f\n"
13603 + LOCK_PREFIX "addq %1,%0\n"
13604 + "int $4\n0:\n"
13605 + _ASM_EXTABLE(0b, 0b)
13606 +#endif
13607 +
13608 + : "=m" (v->counter)
13609 + : "er" (i), "m" (v->counter));
13610 +}
13611 +
13612 +/**
13613 + * atomic64_sub_unchecked - subtract the atomic64 variable
13614 + * @i: integer value to subtract
13615 + * @v: pointer to type atomic64_unchecked_t
13616 + *
13617 + * Atomically subtracts @i from @v.
13618 + */
13619 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
13620 +{
13621 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13622 : "=m" (v->counter)
13623 : "er" (i), "m" (v->counter));
13624 }
13625 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13626 {
13627 unsigned char c;
13628
13629 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
13630 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
13631 +
13632 +#ifdef CONFIG_PAX_REFCOUNT
13633 + "jno 0f\n"
13634 + LOCK_PREFIX "addq %2,%0\n"
13635 + "int $4\n0:\n"
13636 + _ASM_EXTABLE(0b, 0b)
13637 +#endif
13638 +
13639 + "sete %1\n"
13640 : "=m" (v->counter), "=qm" (c)
13641 : "er" (i), "m" (v->counter) : "memory");
13642 return c;
13643 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13644 */
13645 static inline void atomic64_inc(atomic64_t *v)
13646 {
13647 + asm volatile(LOCK_PREFIX "incq %0\n"
13648 +
13649 +#ifdef CONFIG_PAX_REFCOUNT
13650 + "jno 0f\n"
13651 + LOCK_PREFIX "decq %0\n"
13652 + "int $4\n0:\n"
13653 + _ASM_EXTABLE(0b, 0b)
13654 +#endif
13655 +
13656 + : "=m" (v->counter)
13657 + : "m" (v->counter));
13658 +}
13659 +
13660 +/**
13661 + * atomic64_inc_unchecked - increment atomic64 variable
13662 + * @v: pointer to type atomic64_unchecked_t
13663 + *
13664 + * Atomically increments @v by 1.
13665 + */
13666 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
13667 +{
13668 asm volatile(LOCK_PREFIX "incq %0"
13669 : "=m" (v->counter)
13670 : "m" (v->counter));
13671 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
13672 */
13673 static inline void atomic64_dec(atomic64_t *v)
13674 {
13675 - asm volatile(LOCK_PREFIX "decq %0"
13676 + asm volatile(LOCK_PREFIX "decq %0\n"
13677 +
13678 +#ifdef CONFIG_PAX_REFCOUNT
13679 + "jno 0f\n"
13680 + LOCK_PREFIX "incq %0\n"
13681 + "int $4\n0:\n"
13682 + _ASM_EXTABLE(0b, 0b)
13683 +#endif
13684 +
13685 + : "=m" (v->counter)
13686 + : "m" (v->counter));
13687 +}
13688 +
13689 +/**
13690 + * atomic64_dec_unchecked - decrement atomic64 variable
13691 + * @v: pointer to type atomic64_t
13692 + *
13693 + * Atomically decrements @v by 1.
13694 + */
13695 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
13696 +{
13697 + asm volatile(LOCK_PREFIX "decq %0\n"
13698 : "=m" (v->counter)
13699 : "m" (v->counter));
13700 }
13701 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
13702 {
13703 unsigned char c;
13704
13705 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
13706 + asm volatile(LOCK_PREFIX "decq %0\n"
13707 +
13708 +#ifdef CONFIG_PAX_REFCOUNT
13709 + "jno 0f\n"
13710 + LOCK_PREFIX "incq %0\n"
13711 + "int $4\n0:\n"
13712 + _ASM_EXTABLE(0b, 0b)
13713 +#endif
13714 +
13715 + "sete %1\n"
13716 : "=m" (v->counter), "=qm" (c)
13717 : "m" (v->counter) : "memory");
13718 return c != 0;
13719 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
13720 {
13721 unsigned char c;
13722
13723 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
13724 + asm volatile(LOCK_PREFIX "incq %0\n"
13725 +
13726 +#ifdef CONFIG_PAX_REFCOUNT
13727 + "jno 0f\n"
13728 + LOCK_PREFIX "decq %0\n"
13729 + "int $4\n0:\n"
13730 + _ASM_EXTABLE(0b, 0b)
13731 +#endif
13732 +
13733 + "sete %1\n"
13734 : "=m" (v->counter), "=qm" (c)
13735 : "m" (v->counter) : "memory");
13736 return c != 0;
13737 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13738 {
13739 unsigned char c;
13740
13741 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
13742 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
13743 +
13744 +#ifdef CONFIG_PAX_REFCOUNT
13745 + "jno 0f\n"
13746 + LOCK_PREFIX "subq %2,%0\n"
13747 + "int $4\n0:\n"
13748 + _ASM_EXTABLE(0b, 0b)
13749 +#endif
13750 +
13751 + "sets %1\n"
13752 : "=m" (v->counter), "=qm" (c)
13753 : "er" (i), "m" (v->counter) : "memory");
13754 return c;
13755 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13756 */
13757 static inline long atomic64_add_return(long i, atomic64_t *v)
13758 {
13759 + return i + xadd_check_overflow(&v->counter, i);
13760 +}
13761 +
13762 +/**
13763 + * atomic64_add_return_unchecked - add and return
13764 + * @i: integer value to add
13765 + * @v: pointer to type atomic64_unchecked_t
13766 + *
13767 + * Atomically adds @i to @v and returns @i + @v
13768 + */
13769 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
13770 +{
13771 return i + xadd(&v->counter, i);
13772 }
13773
13774 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
13775 }
13776
13777 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
13778 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13779 +{
13780 + return atomic64_add_return_unchecked(1, v);
13781 +}
13782 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
13783
13784 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13785 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13786 return cmpxchg(&v->counter, old, new);
13787 }
13788
13789 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
13790 +{
13791 + return cmpxchg(&v->counter, old, new);
13792 +}
13793 +
13794 static inline long atomic64_xchg(atomic64_t *v, long new)
13795 {
13796 return xchg(&v->counter, new);
13797 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
13798 */
13799 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
13800 {
13801 - long c, old;
13802 + long c, old, new;
13803 c = atomic64_read(v);
13804 for (;;) {
13805 - if (unlikely(c == (u)))
13806 + if (unlikely(c == u))
13807 break;
13808 - old = atomic64_cmpxchg((v), c, c + (a));
13809 +
13810 + asm volatile("add %2,%0\n"
13811 +
13812 +#ifdef CONFIG_PAX_REFCOUNT
13813 + "jno 0f\n"
13814 + "sub %2,%0\n"
13815 + "int $4\n0:\n"
13816 + _ASM_EXTABLE(0b, 0b)
13817 +#endif
13818 +
13819 + : "=r" (new)
13820 + : "0" (c), "ir" (a));
13821 +
13822 + old = atomic64_cmpxchg(v, c, new);
13823 if (likely(old == c))
13824 break;
13825 c = old;
13826 }
13827 - return c != (u);
13828 + return c != u;
13829 }
13830
13831 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
13832 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
13833 index 6dfd019..28e188d 100644
13834 --- a/arch/x86/include/asm/bitops.h
13835 +++ b/arch/x86/include/asm/bitops.h
13836 @@ -40,7 +40,7 @@
13837 * a mask operation on a byte.
13838 */
13839 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
13840 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
13841 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
13842 #define CONST_MASK(nr) (1 << ((nr) & 7))
13843
13844 /**
13845 @@ -486,7 +486,7 @@ static inline int fls(int x)
13846 * at position 64.
13847 */
13848 #ifdef CONFIG_X86_64
13849 -static __always_inline int fls64(__u64 x)
13850 +static __always_inline long fls64(__u64 x)
13851 {
13852 int bitpos = -1;
13853 /*
13854 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
13855 index 4fa687a..60f2d39 100644
13856 --- a/arch/x86/include/asm/boot.h
13857 +++ b/arch/x86/include/asm/boot.h
13858 @@ -6,10 +6,15 @@
13859 #include <uapi/asm/boot.h>
13860
13861 /* Physical address where kernel should be loaded. */
13862 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13863 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13864 + (CONFIG_PHYSICAL_ALIGN - 1)) \
13865 & ~(CONFIG_PHYSICAL_ALIGN - 1))
13866
13867 +#ifndef __ASSEMBLY__
13868 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
13869 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
13870 +#endif
13871 +
13872 /* Minimum kernel alignment, as a power of two */
13873 #ifdef CONFIG_X86_64
13874 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13875 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
13876 index 48f99f1..d78ebf9 100644
13877 --- a/arch/x86/include/asm/cache.h
13878 +++ b/arch/x86/include/asm/cache.h
13879 @@ -5,12 +5,13 @@
13880
13881 /* L1 cache line size */
13882 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
13883 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
13884 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
13885
13886 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
13887 +#define __read_only __attribute__((__section__(".data..read_only")))
13888
13889 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13890 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
13891 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
13892
13893 #ifdef CONFIG_X86_VSMP
13894 #ifdef CONFIG_SMP
13895 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
13896 index 9863ee3..4a1f8e1 100644
13897 --- a/arch/x86/include/asm/cacheflush.h
13898 +++ b/arch/x86/include/asm/cacheflush.h
13899 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13900 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13901
13902 if (pg_flags == _PGMT_DEFAULT)
13903 - return -1;
13904 + return ~0UL;
13905 else if (pg_flags == _PGMT_WC)
13906 return _PAGE_CACHE_WC;
13907 else if (pg_flags == _PGMT_UC_MINUS)
13908 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13909 index 46fc474..b02b0f9 100644
13910 --- a/arch/x86/include/asm/checksum_32.h
13911 +++ b/arch/x86/include/asm/checksum_32.h
13912 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13913 int len, __wsum sum,
13914 int *src_err_ptr, int *dst_err_ptr);
13915
13916 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13917 + int len, __wsum sum,
13918 + int *src_err_ptr, int *dst_err_ptr);
13919 +
13920 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13921 + int len, __wsum sum,
13922 + int *src_err_ptr, int *dst_err_ptr);
13923 +
13924 /*
13925 * Note: when you get a NULL pointer exception here this means someone
13926 * passed in an incorrect kernel address to one of these functions.
13927 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13928 int *err_ptr)
13929 {
13930 might_sleep();
13931 - return csum_partial_copy_generic((__force void *)src, dst,
13932 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13933 len, sum, err_ptr, NULL);
13934 }
13935
13936 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13937 {
13938 might_sleep();
13939 if (access_ok(VERIFY_WRITE, dst, len))
13940 - return csum_partial_copy_generic(src, (__force void *)dst,
13941 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13942 len, sum, NULL, err_ptr);
13943
13944 if (len)
13945 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13946 index 8d871ea..c1a0dc9 100644
13947 --- a/arch/x86/include/asm/cmpxchg.h
13948 +++ b/arch/x86/include/asm/cmpxchg.h
13949 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13950 __compiletime_error("Bad argument size for cmpxchg");
13951 extern void __xadd_wrong_size(void)
13952 __compiletime_error("Bad argument size for xadd");
13953 +extern void __xadd_check_overflow_wrong_size(void)
13954 + __compiletime_error("Bad argument size for xadd_check_overflow");
13955 extern void __add_wrong_size(void)
13956 __compiletime_error("Bad argument size for add");
13957 +extern void __add_check_overflow_wrong_size(void)
13958 + __compiletime_error("Bad argument size for add_check_overflow");
13959
13960 /*
13961 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13962 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13963 __ret; \
13964 })
13965
13966 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13967 + ({ \
13968 + __typeof__ (*(ptr)) __ret = (arg); \
13969 + switch (sizeof(*(ptr))) { \
13970 + case __X86_CASE_L: \
13971 + asm volatile (lock #op "l %0, %1\n" \
13972 + "jno 0f\n" \
13973 + "mov %0,%1\n" \
13974 + "int $4\n0:\n" \
13975 + _ASM_EXTABLE(0b, 0b) \
13976 + : "+r" (__ret), "+m" (*(ptr)) \
13977 + : : "memory", "cc"); \
13978 + break; \
13979 + case __X86_CASE_Q: \
13980 + asm volatile (lock #op "q %q0, %1\n" \
13981 + "jno 0f\n" \
13982 + "mov %0,%1\n" \
13983 + "int $4\n0:\n" \
13984 + _ASM_EXTABLE(0b, 0b) \
13985 + : "+r" (__ret), "+m" (*(ptr)) \
13986 + : : "memory", "cc"); \
13987 + break; \
13988 + default: \
13989 + __ ## op ## _check_overflow_wrong_size(); \
13990 + } \
13991 + __ret; \
13992 + })
13993 +
13994 /*
13995 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13996 * Since this is generally used to protect other memory information, we
13997 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13998 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13999 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14000
14001 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14002 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14003 +
14004 #define __add(ptr, inc, lock) \
14005 ({ \
14006 __typeof__ (*(ptr)) __ret = (inc); \
14007 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14008 index 59c6c40..5e0b22c 100644
14009 --- a/arch/x86/include/asm/compat.h
14010 +++ b/arch/x86/include/asm/compat.h
14011 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14012 typedef u32 compat_uint_t;
14013 typedef u32 compat_ulong_t;
14014 typedef u64 __attribute__((aligned(4))) compat_u64;
14015 -typedef u32 compat_uptr_t;
14016 +typedef u32 __user compat_uptr_t;
14017
14018 struct compat_timespec {
14019 compat_time_t tv_sec;
14020 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14021 index 2d9075e..b75a844 100644
14022 --- a/arch/x86/include/asm/cpufeature.h
14023 +++ b/arch/x86/include/asm/cpufeature.h
14024 @@ -206,7 +206,7 @@
14025 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14026 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14027 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14028 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14029 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14030 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14031 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14032 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14033 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14034 ".section .discard,\"aw\",@progbits\n"
14035 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14036 ".previous\n"
14037 - ".section .altinstr_replacement,\"ax\"\n"
14038 + ".section .altinstr_replacement,\"a\"\n"
14039 "3: movb $1,%0\n"
14040 "4:\n"
14041 ".previous\n"
14042 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14043 index 8bf1c06..b6ae785 100644
14044 --- a/arch/x86/include/asm/desc.h
14045 +++ b/arch/x86/include/asm/desc.h
14046 @@ -4,6 +4,7 @@
14047 #include <asm/desc_defs.h>
14048 #include <asm/ldt.h>
14049 #include <asm/mmu.h>
14050 +#include <asm/pgtable.h>
14051
14052 #include <linux/smp.h>
14053 #include <linux/percpu.h>
14054 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14055
14056 desc->type = (info->read_exec_only ^ 1) << 1;
14057 desc->type |= info->contents << 2;
14058 + desc->type |= info->seg_not_present ^ 1;
14059
14060 desc->s = 1;
14061 desc->dpl = 0x3;
14062 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14063 }
14064
14065 extern struct desc_ptr idt_descr;
14066 -extern gate_desc idt_table[];
14067 extern struct desc_ptr nmi_idt_descr;
14068 -extern gate_desc nmi_idt_table[];
14069 -
14070 -struct gdt_page {
14071 - struct desc_struct gdt[GDT_ENTRIES];
14072 -} __attribute__((aligned(PAGE_SIZE)));
14073 -
14074 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14075 +extern gate_desc idt_table[256];
14076 +extern gate_desc nmi_idt_table[256];
14077
14078 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14079 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14080 {
14081 - return per_cpu(gdt_page, cpu).gdt;
14082 + return cpu_gdt_table[cpu];
14083 }
14084
14085 #ifdef CONFIG_X86_64
14086 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
14087 unsigned long base, unsigned dpl, unsigned flags,
14088 unsigned short seg)
14089 {
14090 - gate->a = (seg << 16) | (base & 0xffff);
14091 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
14092 + gate->gate.offset_low = base;
14093 + gate->gate.seg = seg;
14094 + gate->gate.reserved = 0;
14095 + gate->gate.type = type;
14096 + gate->gate.s = 0;
14097 + gate->gate.dpl = dpl;
14098 + gate->gate.p = 1;
14099 + gate->gate.offset_high = base >> 16;
14100 }
14101
14102 #endif
14103 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
14104
14105 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
14106 {
14107 + pax_open_kernel();
14108 memcpy(&idt[entry], gate, sizeof(*gate));
14109 + pax_close_kernel();
14110 }
14111
14112 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
14113 {
14114 + pax_open_kernel();
14115 memcpy(&ldt[entry], desc, 8);
14116 + pax_close_kernel();
14117 }
14118
14119 static inline void
14120 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
14121 default: size = sizeof(*gdt); break;
14122 }
14123
14124 + pax_open_kernel();
14125 memcpy(&gdt[entry], desc, size);
14126 + pax_close_kernel();
14127 }
14128
14129 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
14130 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
14131
14132 static inline void native_load_tr_desc(void)
14133 {
14134 + pax_open_kernel();
14135 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
14136 + pax_close_kernel();
14137 }
14138
14139 static inline void native_load_gdt(const struct desc_ptr *dtr)
14140 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
14141 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
14142 unsigned int i;
14143
14144 + pax_open_kernel();
14145 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
14146 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
14147 + pax_close_kernel();
14148 }
14149
14150 #define _LDT_empty(info) \
14151 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
14152 preempt_enable();
14153 }
14154
14155 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
14156 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
14157 {
14158 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
14159 }
14160 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
14161 }
14162
14163 #ifdef CONFIG_X86_64
14164 -static inline void set_nmi_gate(int gate, void *addr)
14165 +static inline void set_nmi_gate(int gate, const void *addr)
14166 {
14167 gate_desc s;
14168
14169 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
14170 }
14171 #endif
14172
14173 -static inline void _set_gate(int gate, unsigned type, void *addr,
14174 +static inline void _set_gate(int gate, unsigned type, const void *addr,
14175 unsigned dpl, unsigned ist, unsigned seg)
14176 {
14177 gate_desc s;
14178 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
14179 * Pentium F0 0F bugfix can have resulted in the mapped
14180 * IDT being write-protected.
14181 */
14182 -static inline void set_intr_gate(unsigned int n, void *addr)
14183 +static inline void set_intr_gate(unsigned int n, const void *addr)
14184 {
14185 BUG_ON((unsigned)n > 0xFF);
14186 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
14187 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
14188 /*
14189 * This routine sets up an interrupt gate at directory privilege level 3.
14190 */
14191 -static inline void set_system_intr_gate(unsigned int n, void *addr)
14192 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
14193 {
14194 BUG_ON((unsigned)n > 0xFF);
14195 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
14196 }
14197
14198 -static inline void set_system_trap_gate(unsigned int n, void *addr)
14199 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
14200 {
14201 BUG_ON((unsigned)n > 0xFF);
14202 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
14203 }
14204
14205 -static inline void set_trap_gate(unsigned int n, void *addr)
14206 +static inline void set_trap_gate(unsigned int n, const void *addr)
14207 {
14208 BUG_ON((unsigned)n > 0xFF);
14209 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
14210 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
14211 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
14212 {
14213 BUG_ON((unsigned)n > 0xFF);
14214 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
14215 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
14216 }
14217
14218 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
14219 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
14220 {
14221 BUG_ON((unsigned)n > 0xFF);
14222 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
14223 }
14224
14225 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
14226 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
14227 {
14228 BUG_ON((unsigned)n > 0xFF);
14229 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
14230 }
14231
14232 +#ifdef CONFIG_X86_32
14233 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
14234 +{
14235 + struct desc_struct d;
14236 +
14237 + if (likely(limit))
14238 + limit = (limit - 1UL) >> PAGE_SHIFT;
14239 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
14240 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
14241 +}
14242 +#endif
14243 +
14244 #endif /* _ASM_X86_DESC_H */
14245 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
14246 index 278441f..b95a174 100644
14247 --- a/arch/x86/include/asm/desc_defs.h
14248 +++ b/arch/x86/include/asm/desc_defs.h
14249 @@ -31,6 +31,12 @@ struct desc_struct {
14250 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
14251 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
14252 };
14253 + struct {
14254 + u16 offset_low;
14255 + u16 seg;
14256 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
14257 + unsigned offset_high: 16;
14258 + } gate;
14259 };
14260 } __attribute__((packed));
14261
14262 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
14263 index ced283a..ffe04cc 100644
14264 --- a/arch/x86/include/asm/div64.h
14265 +++ b/arch/x86/include/asm/div64.h
14266 @@ -39,7 +39,7 @@
14267 __mod; \
14268 })
14269
14270 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
14271 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
14272 {
14273 union {
14274 u64 v64;
14275 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
14276 index 9c999c1..3860cb8 100644
14277 --- a/arch/x86/include/asm/elf.h
14278 +++ b/arch/x86/include/asm/elf.h
14279 @@ -243,7 +243,25 @@ extern int force_personality32;
14280 the loader. We need to make sure that it is out of the way of the program
14281 that it will "exec", and that there is sufficient room for the brk. */
14282
14283 +#ifdef CONFIG_PAX_SEGMEXEC
14284 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
14285 +#else
14286 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
14287 +#endif
14288 +
14289 +#ifdef CONFIG_PAX_ASLR
14290 +#ifdef CONFIG_X86_32
14291 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
14292 +
14293 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
14294 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
14295 +#else
14296 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
14297 +
14298 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
14299 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
14300 +#endif
14301 +#endif
14302
14303 /* This yields a mask that user programs can use to figure out what
14304 instruction set this CPU supports. This could be done in user space,
14305 @@ -296,16 +314,12 @@ do { \
14306
14307 #define ARCH_DLINFO \
14308 do { \
14309 - if (vdso_enabled) \
14310 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
14311 - (unsigned long)current->mm->context.vdso); \
14312 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
14313 } while (0)
14314
14315 #define ARCH_DLINFO_X32 \
14316 do { \
14317 - if (vdso_enabled) \
14318 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
14319 - (unsigned long)current->mm->context.vdso); \
14320 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
14321 } while (0)
14322
14323 #define AT_SYSINFO 32
14324 @@ -320,7 +334,7 @@ else \
14325
14326 #endif /* !CONFIG_X86_32 */
14327
14328 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
14329 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
14330
14331 #define VDSO_ENTRY \
14332 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
14333 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
14334 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
14335 #define compat_arch_setup_additional_pages syscall32_setup_pages
14336
14337 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
14338 -#define arch_randomize_brk arch_randomize_brk
14339 -
14340 /*
14341 * True on X86_32 or when emulating IA32 on X86_64
14342 */
14343 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
14344 index 75ce3f4..882e801 100644
14345 --- a/arch/x86/include/asm/emergency-restart.h
14346 +++ b/arch/x86/include/asm/emergency-restart.h
14347 @@ -13,6 +13,6 @@ enum reboot_type {
14348
14349 extern enum reboot_type reboot_type;
14350
14351 -extern void machine_emergency_restart(void);
14352 +extern void machine_emergency_restart(void) __noreturn;
14353
14354 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
14355 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
14356 index 41ab26e..a88c9e6 100644
14357 --- a/arch/x86/include/asm/fpu-internal.h
14358 +++ b/arch/x86/include/asm/fpu-internal.h
14359 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
14360 ({ \
14361 int err; \
14362 asm volatile(ASM_STAC "\n" \
14363 - "1:" #insn "\n\t" \
14364 + "1:" \
14365 + __copyuser_seg \
14366 + #insn "\n\t" \
14367 "2: " ASM_CLAC "\n" \
14368 ".section .fixup,\"ax\"\n" \
14369 "3: movl $-1,%[err]\n" \
14370 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
14371 "emms\n\t" /* clear stack tags */
14372 "fildl %P[addr]", /* set F?P to defined value */
14373 X86_FEATURE_FXSAVE_LEAK,
14374 - [addr] "m" (tsk->thread.fpu.has_fpu));
14375 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
14376
14377 return fpu_restore_checking(&tsk->thread.fpu);
14378 }
14379 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
14380 index be27ba1..8f13ff9 100644
14381 --- a/arch/x86/include/asm/futex.h
14382 +++ b/arch/x86/include/asm/futex.h
14383 @@ -12,6 +12,7 @@
14384 #include <asm/smap.h>
14385
14386 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
14387 + typecheck(u32 __user *, uaddr); \
14388 asm volatile("\t" ASM_STAC "\n" \
14389 "1:\t" insn "\n" \
14390 "2:\t" ASM_CLAC "\n" \
14391 @@ -20,15 +21,16 @@
14392 "\tjmp\t2b\n" \
14393 "\t.previous\n" \
14394 _ASM_EXTABLE(1b, 3b) \
14395 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
14396 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
14397 : "i" (-EFAULT), "0" (oparg), "1" (0))
14398
14399 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
14400 + typecheck(u32 __user *, uaddr); \
14401 asm volatile("\t" ASM_STAC "\n" \
14402 "1:\tmovl %2, %0\n" \
14403 "\tmovl\t%0, %3\n" \
14404 "\t" insn "\n" \
14405 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
14406 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
14407 "\tjnz\t1b\n" \
14408 "3:\t" ASM_CLAC "\n" \
14409 "\t.section .fixup,\"ax\"\n" \
14410 @@ -38,7 +40,7 @@
14411 _ASM_EXTABLE(1b, 4b) \
14412 _ASM_EXTABLE(2b, 4b) \
14413 : "=&a" (oldval), "=&r" (ret), \
14414 - "+m" (*uaddr), "=&r" (tem) \
14415 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
14416 : "r" (oparg), "i" (-EFAULT), "1" (0))
14417
14418 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
14419 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
14420
14421 switch (op) {
14422 case FUTEX_OP_SET:
14423 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
14424 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
14425 break;
14426 case FUTEX_OP_ADD:
14427 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
14428 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
14429 uaddr, oparg);
14430 break;
14431 case FUTEX_OP_OR:
14432 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
14433 return -EFAULT;
14434
14435 asm volatile("\t" ASM_STAC "\n"
14436 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
14437 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
14438 "2:\t" ASM_CLAC "\n"
14439 "\t.section .fixup, \"ax\"\n"
14440 "3:\tmov %3, %0\n"
14441 "\tjmp 2b\n"
14442 "\t.previous\n"
14443 _ASM_EXTABLE(1b, 3b)
14444 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
14445 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
14446 : "i" (-EFAULT), "r" (newval), "1" (oldval)
14447 : "memory"
14448 );
14449 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
14450 index eb92a6e..b98b2f4 100644
14451 --- a/arch/x86/include/asm/hw_irq.h
14452 +++ b/arch/x86/include/asm/hw_irq.h
14453 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
14454 extern void enable_IO_APIC(void);
14455
14456 /* Statistics */
14457 -extern atomic_t irq_err_count;
14458 -extern atomic_t irq_mis_count;
14459 +extern atomic_unchecked_t irq_err_count;
14460 +extern atomic_unchecked_t irq_mis_count;
14461
14462 /* EISA */
14463 extern void eisa_set_level_irq(unsigned int irq);
14464 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
14465 index a203659..9889f1c 100644
14466 --- a/arch/x86/include/asm/i8259.h
14467 +++ b/arch/x86/include/asm/i8259.h
14468 @@ -62,7 +62,7 @@ struct legacy_pic {
14469 void (*init)(int auto_eoi);
14470 int (*irq_pending)(unsigned int irq);
14471 void (*make_irq)(unsigned int irq);
14472 -};
14473 +} __do_const;
14474
14475 extern struct legacy_pic *legacy_pic;
14476 extern struct legacy_pic null_legacy_pic;
14477 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
14478 index d8e8eef..1765f78 100644
14479 --- a/arch/x86/include/asm/io.h
14480 +++ b/arch/x86/include/asm/io.h
14481 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
14482 "m" (*(volatile type __force *)addr) barrier); }
14483
14484 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
14485 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
14486 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
14487 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
14488 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
14489
14490 build_mmio_read(__readb, "b", unsigned char, "=q", )
14491 -build_mmio_read(__readw, "w", unsigned short, "=r", )
14492 -build_mmio_read(__readl, "l", unsigned int, "=r", )
14493 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
14494 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
14495
14496 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
14497 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
14498 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
14499 return ioremap_nocache(offset, size);
14500 }
14501
14502 -extern void iounmap(volatile void __iomem *addr);
14503 +extern void iounmap(const volatile void __iomem *addr);
14504
14505 extern void set_iounmap_nonlazy(void);
14506
14507 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
14508
14509 #include <linux/vmalloc.h>
14510
14511 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
14512 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
14513 +{
14514 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
14515 +}
14516 +
14517 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
14518 +{
14519 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
14520 +}
14521 +
14522 /*
14523 * Convert a virtual cached pointer to an uncached pointer
14524 */
14525 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
14526 index bba3cf8..06bc8da 100644
14527 --- a/arch/x86/include/asm/irqflags.h
14528 +++ b/arch/x86/include/asm/irqflags.h
14529 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
14530 sti; \
14531 sysexit
14532
14533 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
14534 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
14535 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
14536 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
14537 +
14538 #else
14539 #define INTERRUPT_RETURN iret
14540 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
14541 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
14542 index d3ddd17..c9fb0cc 100644
14543 --- a/arch/x86/include/asm/kprobes.h
14544 +++ b/arch/x86/include/asm/kprobes.h
14545 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
14546 #define RELATIVEJUMP_SIZE 5
14547 #define RELATIVECALL_OPCODE 0xe8
14548 #define RELATIVE_ADDR_SIZE 4
14549 -#define MAX_STACK_SIZE 64
14550 -#define MIN_STACK_SIZE(ADDR) \
14551 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
14552 - THREAD_SIZE - (unsigned long)(ADDR))) \
14553 - ? (MAX_STACK_SIZE) \
14554 - : (((unsigned long)current_thread_info()) + \
14555 - THREAD_SIZE - (unsigned long)(ADDR)))
14556 +#define MAX_STACK_SIZE 64UL
14557 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
14558
14559 #define flush_insn_slot(p) do { } while (0)
14560
14561 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
14562 index 2d89e39..baee879 100644
14563 --- a/arch/x86/include/asm/local.h
14564 +++ b/arch/x86/include/asm/local.h
14565 @@ -10,33 +10,97 @@ typedef struct {
14566 atomic_long_t a;
14567 } local_t;
14568
14569 +typedef struct {
14570 + atomic_long_unchecked_t a;
14571 +} local_unchecked_t;
14572 +
14573 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
14574
14575 #define local_read(l) atomic_long_read(&(l)->a)
14576 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
14577 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
14578 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
14579
14580 static inline void local_inc(local_t *l)
14581 {
14582 - asm volatile(_ASM_INC "%0"
14583 + asm volatile(_ASM_INC "%0\n"
14584 +
14585 +#ifdef CONFIG_PAX_REFCOUNT
14586 + "jno 0f\n"
14587 + _ASM_DEC "%0\n"
14588 + "int $4\n0:\n"
14589 + _ASM_EXTABLE(0b, 0b)
14590 +#endif
14591 +
14592 + : "+m" (l->a.counter));
14593 +}
14594 +
14595 +static inline void local_inc_unchecked(local_unchecked_t *l)
14596 +{
14597 + asm volatile(_ASM_INC "%0\n"
14598 : "+m" (l->a.counter));
14599 }
14600
14601 static inline void local_dec(local_t *l)
14602 {
14603 - asm volatile(_ASM_DEC "%0"
14604 + asm volatile(_ASM_DEC "%0\n"
14605 +
14606 +#ifdef CONFIG_PAX_REFCOUNT
14607 + "jno 0f\n"
14608 + _ASM_INC "%0\n"
14609 + "int $4\n0:\n"
14610 + _ASM_EXTABLE(0b, 0b)
14611 +#endif
14612 +
14613 + : "+m" (l->a.counter));
14614 +}
14615 +
14616 +static inline void local_dec_unchecked(local_unchecked_t *l)
14617 +{
14618 + asm volatile(_ASM_DEC "%0\n"
14619 : "+m" (l->a.counter));
14620 }
14621
14622 static inline void local_add(long i, local_t *l)
14623 {
14624 - asm volatile(_ASM_ADD "%1,%0"
14625 + asm volatile(_ASM_ADD "%1,%0\n"
14626 +
14627 +#ifdef CONFIG_PAX_REFCOUNT
14628 + "jno 0f\n"
14629 + _ASM_SUB "%1,%0\n"
14630 + "int $4\n0:\n"
14631 + _ASM_EXTABLE(0b, 0b)
14632 +#endif
14633 +
14634 + : "+m" (l->a.counter)
14635 + : "ir" (i));
14636 +}
14637 +
14638 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
14639 +{
14640 + asm volatile(_ASM_ADD "%1,%0\n"
14641 : "+m" (l->a.counter)
14642 : "ir" (i));
14643 }
14644
14645 static inline void local_sub(long i, local_t *l)
14646 {
14647 - asm volatile(_ASM_SUB "%1,%0"
14648 + asm volatile(_ASM_SUB "%1,%0\n"
14649 +
14650 +#ifdef CONFIG_PAX_REFCOUNT
14651 + "jno 0f\n"
14652 + _ASM_ADD "%1,%0\n"
14653 + "int $4\n0:\n"
14654 + _ASM_EXTABLE(0b, 0b)
14655 +#endif
14656 +
14657 + : "+m" (l->a.counter)
14658 + : "ir" (i));
14659 +}
14660 +
14661 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
14662 +{
14663 + asm volatile(_ASM_SUB "%1,%0\n"
14664 : "+m" (l->a.counter)
14665 : "ir" (i));
14666 }
14667 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
14668 {
14669 unsigned char c;
14670
14671 - asm volatile(_ASM_SUB "%2,%0; sete %1"
14672 + asm volatile(_ASM_SUB "%2,%0\n"
14673 +
14674 +#ifdef CONFIG_PAX_REFCOUNT
14675 + "jno 0f\n"
14676 + _ASM_ADD "%2,%0\n"
14677 + "int $4\n0:\n"
14678 + _ASM_EXTABLE(0b, 0b)
14679 +#endif
14680 +
14681 + "sete %1\n"
14682 : "+m" (l->a.counter), "=qm" (c)
14683 : "ir" (i) : "memory");
14684 return c;
14685 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
14686 {
14687 unsigned char c;
14688
14689 - asm volatile(_ASM_DEC "%0; sete %1"
14690 + asm volatile(_ASM_DEC "%0\n"
14691 +
14692 +#ifdef CONFIG_PAX_REFCOUNT
14693 + "jno 0f\n"
14694 + _ASM_INC "%0\n"
14695 + "int $4\n0:\n"
14696 + _ASM_EXTABLE(0b, 0b)
14697 +#endif
14698 +
14699 + "sete %1\n"
14700 : "+m" (l->a.counter), "=qm" (c)
14701 : : "memory");
14702 return c != 0;
14703 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
14704 {
14705 unsigned char c;
14706
14707 - asm volatile(_ASM_INC "%0; sete %1"
14708 + asm volatile(_ASM_INC "%0\n"
14709 +
14710 +#ifdef CONFIG_PAX_REFCOUNT
14711 + "jno 0f\n"
14712 + _ASM_DEC "%0\n"
14713 + "int $4\n0:\n"
14714 + _ASM_EXTABLE(0b, 0b)
14715 +#endif
14716 +
14717 + "sete %1\n"
14718 : "+m" (l->a.counter), "=qm" (c)
14719 : : "memory");
14720 return c != 0;
14721 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
14722 {
14723 unsigned char c;
14724
14725 - asm volatile(_ASM_ADD "%2,%0; sets %1"
14726 + asm volatile(_ASM_ADD "%2,%0\n"
14727 +
14728 +#ifdef CONFIG_PAX_REFCOUNT
14729 + "jno 0f\n"
14730 + _ASM_SUB "%2,%0\n"
14731 + "int $4\n0:\n"
14732 + _ASM_EXTABLE(0b, 0b)
14733 +#endif
14734 +
14735 + "sets %1\n"
14736 : "+m" (l->a.counter), "=qm" (c)
14737 : "ir" (i) : "memory");
14738 return c;
14739 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
14740 static inline long local_add_return(long i, local_t *l)
14741 {
14742 long __i = i;
14743 + asm volatile(_ASM_XADD "%0, %1\n"
14744 +
14745 +#ifdef CONFIG_PAX_REFCOUNT
14746 + "jno 0f\n"
14747 + _ASM_MOV "%0,%1\n"
14748 + "int $4\n0:\n"
14749 + _ASM_EXTABLE(0b, 0b)
14750 +#endif
14751 +
14752 + : "+r" (i), "+m" (l->a.counter)
14753 + : : "memory");
14754 + return i + __i;
14755 +}
14756 +
14757 +/**
14758 + * local_add_return_unchecked - add and return
14759 + * @i: integer value to add
14760 + * @l: pointer to type local_unchecked_t
14761 + *
14762 + * Atomically adds @i to @l and returns @i + @l
14763 + */
14764 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
14765 +{
14766 + long __i = i;
14767 asm volatile(_ASM_XADD "%0, %1;"
14768 : "+r" (i), "+m" (l->a.counter)
14769 : : "memory");
14770 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
14771
14772 #define local_cmpxchg(l, o, n) \
14773 (cmpxchg_local(&((l)->a.counter), (o), (n)))
14774 +#define local_cmpxchg_unchecked(l, o, n) \
14775 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
14776 /* Always has a lock prefix */
14777 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
14778
14779 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
14780 new file mode 100644
14781 index 0000000..2bfd3ba
14782 --- /dev/null
14783 +++ b/arch/x86/include/asm/mman.h
14784 @@ -0,0 +1,15 @@
14785 +#ifndef _X86_MMAN_H
14786 +#define _X86_MMAN_H
14787 +
14788 +#include <uapi/asm/mman.h>
14789 +
14790 +#ifdef __KERNEL__
14791 +#ifndef __ASSEMBLY__
14792 +#ifdef CONFIG_X86_32
14793 +#define arch_mmap_check i386_mmap_check
14794 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
14795 +#endif
14796 +#endif
14797 +#endif
14798 +
14799 +#endif /* X86_MMAN_H */
14800 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
14801 index 5f55e69..e20bfb1 100644
14802 --- a/arch/x86/include/asm/mmu.h
14803 +++ b/arch/x86/include/asm/mmu.h
14804 @@ -9,7 +9,7 @@
14805 * we put the segment information here.
14806 */
14807 typedef struct {
14808 - void *ldt;
14809 + struct desc_struct *ldt;
14810 int size;
14811
14812 #ifdef CONFIG_X86_64
14813 @@ -18,7 +18,19 @@ typedef struct {
14814 #endif
14815
14816 struct mutex lock;
14817 - void *vdso;
14818 + unsigned long vdso;
14819 +
14820 +#ifdef CONFIG_X86_32
14821 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
14822 + unsigned long user_cs_base;
14823 + unsigned long user_cs_limit;
14824 +
14825 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14826 + cpumask_t cpu_user_cs_mask;
14827 +#endif
14828 +
14829 +#endif
14830 +#endif
14831 } mm_context_t;
14832
14833 #ifdef CONFIG_SMP
14834 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
14835 index cdbf367..adb37ac 100644
14836 --- a/arch/x86/include/asm/mmu_context.h
14837 +++ b/arch/x86/include/asm/mmu_context.h
14838 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
14839
14840 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14841 {
14842 +
14843 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14844 + unsigned int i;
14845 + pgd_t *pgd;
14846 +
14847 + pax_open_kernel();
14848 + pgd = get_cpu_pgd(smp_processor_id());
14849 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
14850 + set_pgd_batched(pgd+i, native_make_pgd(0));
14851 + pax_close_kernel();
14852 +#endif
14853 +
14854 #ifdef CONFIG_SMP
14855 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
14856 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
14857 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14858 struct task_struct *tsk)
14859 {
14860 unsigned cpu = smp_processor_id();
14861 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14862 + int tlbstate = TLBSTATE_OK;
14863 +#endif
14864
14865 if (likely(prev != next)) {
14866 #ifdef CONFIG_SMP
14867 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14868 + tlbstate = this_cpu_read(cpu_tlbstate.state);
14869 +#endif
14870 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14871 this_cpu_write(cpu_tlbstate.active_mm, next);
14872 #endif
14873 cpumask_set_cpu(cpu, mm_cpumask(next));
14874
14875 /* Re-load page tables */
14876 +#ifdef CONFIG_PAX_PER_CPU_PGD
14877 + pax_open_kernel();
14878 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14879 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14880 + pax_close_kernel();
14881 + load_cr3(get_cpu_pgd(cpu));
14882 +#else
14883 load_cr3(next->pgd);
14884 +#endif
14885
14886 /* stop flush ipis for the previous mm */
14887 cpumask_clear_cpu(cpu, mm_cpumask(prev));
14888 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14889 */
14890 if (unlikely(prev->context.ldt != next->context.ldt))
14891 load_LDT_nolock(&next->context);
14892 - }
14893 +
14894 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14895 + if (!(__supported_pte_mask & _PAGE_NX)) {
14896 + smp_mb__before_clear_bit();
14897 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
14898 + smp_mb__after_clear_bit();
14899 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14900 + }
14901 +#endif
14902 +
14903 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14904 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
14905 + prev->context.user_cs_limit != next->context.user_cs_limit))
14906 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14907 #ifdef CONFIG_SMP
14908 + else if (unlikely(tlbstate != TLBSTATE_OK))
14909 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14910 +#endif
14911 +#endif
14912 +
14913 + }
14914 else {
14915 +
14916 +#ifdef CONFIG_PAX_PER_CPU_PGD
14917 + pax_open_kernel();
14918 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14919 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14920 + pax_close_kernel();
14921 + load_cr3(get_cpu_pgd(cpu));
14922 +#endif
14923 +
14924 +#ifdef CONFIG_SMP
14925 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14926 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14927
14928 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14929 * tlb flush IPI delivery. We must reload CR3
14930 * to make sure to use no freed page tables.
14931 */
14932 +
14933 +#ifndef CONFIG_PAX_PER_CPU_PGD
14934 load_cr3(next->pgd);
14935 +#endif
14936 +
14937 load_LDT_nolock(&next->context);
14938 +
14939 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14940 + if (!(__supported_pte_mask & _PAGE_NX))
14941 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14942 +#endif
14943 +
14944 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14945 +#ifdef CONFIG_PAX_PAGEEXEC
14946 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14947 +#endif
14948 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14949 +#endif
14950 +
14951 }
14952 +#endif
14953 }
14954 -#endif
14955 }
14956
14957 #define activate_mm(prev, next) \
14958 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14959 index e3b7819..b257c64 100644
14960 --- a/arch/x86/include/asm/module.h
14961 +++ b/arch/x86/include/asm/module.h
14962 @@ -5,6 +5,7 @@
14963
14964 #ifdef CONFIG_X86_64
14965 /* X86_64 does not define MODULE_PROC_FAMILY */
14966 +#define MODULE_PROC_FAMILY ""
14967 #elif defined CONFIG_M486
14968 #define MODULE_PROC_FAMILY "486 "
14969 #elif defined CONFIG_M586
14970 @@ -57,8 +58,20 @@
14971 #error unknown processor family
14972 #endif
14973
14974 -#ifdef CONFIG_X86_32
14975 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14976 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14977 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14978 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14979 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14980 +#else
14981 +#define MODULE_PAX_KERNEXEC ""
14982 #endif
14983
14984 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14985 +#define MODULE_PAX_UDEREF "UDEREF "
14986 +#else
14987 +#define MODULE_PAX_UDEREF ""
14988 +#endif
14989 +
14990 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14991 +
14992 #endif /* _ASM_X86_MODULE_H */
14993 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14994 index c0fa356..07a498a 100644
14995 --- a/arch/x86/include/asm/nmi.h
14996 +++ b/arch/x86/include/asm/nmi.h
14997 @@ -42,11 +42,11 @@ struct nmiaction {
14998 nmi_handler_t handler;
14999 unsigned long flags;
15000 const char *name;
15001 -};
15002 +} __do_const;
15003
15004 #define register_nmi_handler(t, fn, fg, n, init...) \
15005 ({ \
15006 - static struct nmiaction init fn##_na = { \
15007 + static const struct nmiaction init fn##_na = { \
15008 .handler = (fn), \
15009 .name = (n), \
15010 .flags = (fg), \
15011 @@ -54,7 +54,7 @@ struct nmiaction {
15012 __register_nmi_handler((t), &fn##_na); \
15013 })
15014
15015 -int __register_nmi_handler(unsigned int, struct nmiaction *);
15016 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
15017
15018 void unregister_nmi_handler(unsigned int, const char *);
15019
15020 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
15021 index 320f7bb..e89f8f8 100644
15022 --- a/arch/x86/include/asm/page_64_types.h
15023 +++ b/arch/x86/include/asm/page_64_types.h
15024 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
15025
15026 /* duplicated to the one in bootmem.h */
15027 extern unsigned long max_pfn;
15028 -extern unsigned long phys_base;
15029 +extern const unsigned long phys_base;
15030
15031 extern unsigned long __phys_addr(unsigned long);
15032 #define __phys_reloc_hide(x) (x)
15033 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
15034 index 7361e47..16dc226 100644
15035 --- a/arch/x86/include/asm/paravirt.h
15036 +++ b/arch/x86/include/asm/paravirt.h
15037 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
15038 return (pmd_t) { ret };
15039 }
15040
15041 -static inline pmdval_t pmd_val(pmd_t pmd)
15042 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
15043 {
15044 pmdval_t ret;
15045
15046 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
15047 val);
15048 }
15049
15050 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
15051 +{
15052 + pgdval_t val = native_pgd_val(pgd);
15053 +
15054 + if (sizeof(pgdval_t) > sizeof(long))
15055 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
15056 + val, (u64)val >> 32);
15057 + else
15058 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
15059 + val);
15060 +}
15061 +
15062 static inline void pgd_clear(pgd_t *pgdp)
15063 {
15064 set_pgd(pgdp, __pgd(0));
15065 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
15066 pv_mmu_ops.set_fixmap(idx, phys, flags);
15067 }
15068
15069 +#ifdef CONFIG_PAX_KERNEXEC
15070 +static inline unsigned long pax_open_kernel(void)
15071 +{
15072 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
15073 +}
15074 +
15075 +static inline unsigned long pax_close_kernel(void)
15076 +{
15077 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
15078 +}
15079 +#else
15080 +static inline unsigned long pax_open_kernel(void) { return 0; }
15081 +static inline unsigned long pax_close_kernel(void) { return 0; }
15082 +#endif
15083 +
15084 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
15085
15086 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
15087 @@ -930,7 +957,7 @@ extern void default_banner(void);
15088
15089 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
15090 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
15091 -#define PARA_INDIRECT(addr) *%cs:addr
15092 +#define PARA_INDIRECT(addr) *%ss:addr
15093 #endif
15094
15095 #define INTERRUPT_RETURN \
15096 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
15097 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
15098 CLBR_NONE, \
15099 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
15100 +
15101 +#define GET_CR0_INTO_RDI \
15102 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
15103 + mov %rax,%rdi
15104 +
15105 +#define SET_RDI_INTO_CR0 \
15106 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
15107 +
15108 +#define GET_CR3_INTO_RDI \
15109 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
15110 + mov %rax,%rdi
15111 +
15112 +#define SET_RDI_INTO_CR3 \
15113 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
15114 +
15115 #endif /* CONFIG_X86_32 */
15116
15117 #endif /* __ASSEMBLY__ */
15118 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
15119 index b3b0ec1..b1cd3eb 100644
15120 --- a/arch/x86/include/asm/paravirt_types.h
15121 +++ b/arch/x86/include/asm/paravirt_types.h
15122 @@ -84,7 +84,7 @@ struct pv_init_ops {
15123 */
15124 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
15125 unsigned long addr, unsigned len);
15126 -};
15127 +} __no_const;
15128
15129
15130 struct pv_lazy_ops {
15131 @@ -98,7 +98,7 @@ struct pv_time_ops {
15132 unsigned long long (*sched_clock)(void);
15133 unsigned long long (*steal_clock)(int cpu);
15134 unsigned long (*get_tsc_khz)(void);
15135 -};
15136 +} __no_const;
15137
15138 struct pv_cpu_ops {
15139 /* hooks for various privileged instructions */
15140 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
15141
15142 void (*start_context_switch)(struct task_struct *prev);
15143 void (*end_context_switch)(struct task_struct *next);
15144 -};
15145 +} __no_const;
15146
15147 struct pv_irq_ops {
15148 /*
15149 @@ -223,7 +223,7 @@ struct pv_apic_ops {
15150 unsigned long start_eip,
15151 unsigned long start_esp);
15152 #endif
15153 -};
15154 +} __no_const;
15155
15156 struct pv_mmu_ops {
15157 unsigned long (*read_cr2)(void);
15158 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
15159 struct paravirt_callee_save make_pud;
15160
15161 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
15162 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
15163 #endif /* PAGETABLE_LEVELS == 4 */
15164 #endif /* PAGETABLE_LEVELS >= 3 */
15165
15166 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
15167 an mfn. We can tell which is which from the index. */
15168 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
15169 phys_addr_t phys, pgprot_t flags);
15170 +
15171 +#ifdef CONFIG_PAX_KERNEXEC
15172 + unsigned long (*pax_open_kernel)(void);
15173 + unsigned long (*pax_close_kernel)(void);
15174 +#endif
15175 +
15176 };
15177
15178 struct arch_spinlock;
15179 @@ -334,7 +341,7 @@ struct pv_lock_ops {
15180 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
15181 int (*spin_trylock)(struct arch_spinlock *lock);
15182 void (*spin_unlock)(struct arch_spinlock *lock);
15183 -};
15184 +} __no_const;
15185
15186 /* This contains all the paravirt structures: we get a convenient
15187 * number for each function using the offset which we use to indicate
15188 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
15189 index b4389a4..7024269 100644
15190 --- a/arch/x86/include/asm/pgalloc.h
15191 +++ b/arch/x86/include/asm/pgalloc.h
15192 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
15193 pmd_t *pmd, pte_t *pte)
15194 {
15195 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
15196 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
15197 +}
15198 +
15199 +static inline void pmd_populate_user(struct mm_struct *mm,
15200 + pmd_t *pmd, pte_t *pte)
15201 +{
15202 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
15203 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
15204 }
15205
15206 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
15207
15208 #ifdef CONFIG_X86_PAE
15209 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
15210 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
15211 +{
15212 + pud_populate(mm, pudp, pmd);
15213 +}
15214 #else /* !CONFIG_X86_PAE */
15215 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
15216 {
15217 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
15218 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
15219 }
15220 +
15221 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
15222 +{
15223 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
15224 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
15225 +}
15226 #endif /* CONFIG_X86_PAE */
15227
15228 #if PAGETABLE_LEVELS > 3
15229 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
15230 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
15231 }
15232
15233 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
15234 +{
15235 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
15236 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
15237 +}
15238 +
15239 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
15240 {
15241 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
15242 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
15243 index f2b489c..4f7e2e5 100644
15244 --- a/arch/x86/include/asm/pgtable-2level.h
15245 +++ b/arch/x86/include/asm/pgtable-2level.h
15246 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
15247
15248 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
15249 {
15250 + pax_open_kernel();
15251 *pmdp = pmd;
15252 + pax_close_kernel();
15253 }
15254
15255 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
15256 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
15257 index 4cc9f2b..5fd9226 100644
15258 --- a/arch/x86/include/asm/pgtable-3level.h
15259 +++ b/arch/x86/include/asm/pgtable-3level.h
15260 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
15261
15262 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
15263 {
15264 + pax_open_kernel();
15265 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
15266 + pax_close_kernel();
15267 }
15268
15269 static inline void native_set_pud(pud_t *pudp, pud_t pud)
15270 {
15271 + pax_open_kernel();
15272 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
15273 + pax_close_kernel();
15274 }
15275
15276 /*
15277 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
15278 index 1c1a955..50f828c 100644
15279 --- a/arch/x86/include/asm/pgtable.h
15280 +++ b/arch/x86/include/asm/pgtable.h
15281 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
15282
15283 #ifndef __PAGETABLE_PUD_FOLDED
15284 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
15285 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
15286 #define pgd_clear(pgd) native_pgd_clear(pgd)
15287 #endif
15288
15289 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
15290
15291 #define arch_end_context_switch(prev) do {} while(0)
15292
15293 +#define pax_open_kernel() native_pax_open_kernel()
15294 +#define pax_close_kernel() native_pax_close_kernel()
15295 #endif /* CONFIG_PARAVIRT */
15296
15297 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
15298 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
15299 +
15300 +#ifdef CONFIG_PAX_KERNEXEC
15301 +static inline unsigned long native_pax_open_kernel(void)
15302 +{
15303 + unsigned long cr0;
15304 +
15305 + preempt_disable();
15306 + barrier();
15307 + cr0 = read_cr0() ^ X86_CR0_WP;
15308 + BUG_ON(cr0 & X86_CR0_WP);
15309 + write_cr0(cr0);
15310 + return cr0 ^ X86_CR0_WP;
15311 +}
15312 +
15313 +static inline unsigned long native_pax_close_kernel(void)
15314 +{
15315 + unsigned long cr0;
15316 +
15317 + cr0 = read_cr0() ^ X86_CR0_WP;
15318 + BUG_ON(!(cr0 & X86_CR0_WP));
15319 + write_cr0(cr0);
15320 + barrier();
15321 + preempt_enable_no_resched();
15322 + return cr0 ^ X86_CR0_WP;
15323 +}
15324 +#else
15325 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
15326 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
15327 +#endif
15328 +
15329 /*
15330 * The following only work if pte_present() is true.
15331 * Undefined behaviour if not..
15332 */
15333 +static inline int pte_user(pte_t pte)
15334 +{
15335 + return pte_val(pte) & _PAGE_USER;
15336 +}
15337 +
15338 static inline int pte_dirty(pte_t pte)
15339 {
15340 return pte_flags(pte) & _PAGE_DIRTY;
15341 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
15342 return pte_clear_flags(pte, _PAGE_RW);
15343 }
15344
15345 +static inline pte_t pte_mkread(pte_t pte)
15346 +{
15347 + return __pte(pte_val(pte) | _PAGE_USER);
15348 +}
15349 +
15350 static inline pte_t pte_mkexec(pte_t pte)
15351 {
15352 - return pte_clear_flags(pte, _PAGE_NX);
15353 +#ifdef CONFIG_X86_PAE
15354 + if (__supported_pte_mask & _PAGE_NX)
15355 + return pte_clear_flags(pte, _PAGE_NX);
15356 + else
15357 +#endif
15358 + return pte_set_flags(pte, _PAGE_USER);
15359 +}
15360 +
15361 +static inline pte_t pte_exprotect(pte_t pte)
15362 +{
15363 +#ifdef CONFIG_X86_PAE
15364 + if (__supported_pte_mask & _PAGE_NX)
15365 + return pte_set_flags(pte, _PAGE_NX);
15366 + else
15367 +#endif
15368 + return pte_clear_flags(pte, _PAGE_USER);
15369 }
15370
15371 static inline pte_t pte_mkdirty(pte_t pte)
15372 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
15373 #endif
15374
15375 #ifndef __ASSEMBLY__
15376 +
15377 +#ifdef CONFIG_PAX_PER_CPU_PGD
15378 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
15379 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
15380 +{
15381 + return cpu_pgd[cpu];
15382 +}
15383 +#endif
15384 +
15385 #include <linux/mm_types.h>
15386
15387 static inline int pte_none(pte_t pte)
15388 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
15389
15390 static inline int pgd_bad(pgd_t pgd)
15391 {
15392 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
15393 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
15394 }
15395
15396 static inline int pgd_none(pgd_t pgd)
15397 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
15398 * pgd_offset() returns a (pgd_t *)
15399 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
15400 */
15401 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
15402 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
15403 +
15404 +#ifdef CONFIG_PAX_PER_CPU_PGD
15405 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
15406 +#endif
15407 +
15408 /*
15409 * a shortcut which implies the use of the kernel's pgd, instead
15410 * of a process's
15411 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
15412 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
15413 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
15414
15415 +#ifdef CONFIG_X86_32
15416 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
15417 +#else
15418 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
15419 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
15420 +
15421 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15422 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
15423 +#else
15424 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
15425 +#endif
15426 +
15427 +#endif
15428 +
15429 #ifndef __ASSEMBLY__
15430
15431 extern int direct_gbpages;
15432 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
15433 * dst and src can be on the same page, but the range must not overlap,
15434 * and must not cross a page boundary.
15435 */
15436 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
15437 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
15438 {
15439 - memcpy(dst, src, count * sizeof(pgd_t));
15440 + pax_open_kernel();
15441 + while (count--)
15442 + *dst++ = *src++;
15443 + pax_close_kernel();
15444 }
15445
15446 +#ifdef CONFIG_PAX_PER_CPU_PGD
15447 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
15448 +#endif
15449 +
15450 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15451 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
15452 +#else
15453 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
15454 +#endif
15455
15456 #include <asm-generic/pgtable.h>
15457 #endif /* __ASSEMBLY__ */
15458 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
15459 index 8faa215..a8a17ea 100644
15460 --- a/arch/x86/include/asm/pgtable_32.h
15461 +++ b/arch/x86/include/asm/pgtable_32.h
15462 @@ -25,9 +25,6 @@
15463 struct mm_struct;
15464 struct vm_area_struct;
15465
15466 -extern pgd_t swapper_pg_dir[1024];
15467 -extern pgd_t initial_page_table[1024];
15468 -
15469 static inline void pgtable_cache_init(void) { }
15470 static inline void check_pgt_cache(void) { }
15471 void paging_init(void);
15472 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
15473 # include <asm/pgtable-2level.h>
15474 #endif
15475
15476 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
15477 +extern pgd_t initial_page_table[PTRS_PER_PGD];
15478 +#ifdef CONFIG_X86_PAE
15479 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
15480 +#endif
15481 +
15482 #if defined(CONFIG_HIGHPTE)
15483 #define pte_offset_map(dir, address) \
15484 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
15485 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
15486 /* Clear a kernel PTE and flush it from the TLB */
15487 #define kpte_clear_flush(ptep, vaddr) \
15488 do { \
15489 + pax_open_kernel(); \
15490 pte_clear(&init_mm, (vaddr), (ptep)); \
15491 + pax_close_kernel(); \
15492 __flush_tlb_one((vaddr)); \
15493 } while (0)
15494
15495 @@ -75,6 +80,9 @@ do { \
15496
15497 #endif /* !__ASSEMBLY__ */
15498
15499 +#define HAVE_ARCH_UNMAPPED_AREA
15500 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
15501 +
15502 /*
15503 * kern_addr_valid() is (1) for FLATMEM and (0) for
15504 * SPARSEMEM and DISCONTIGMEM
15505 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
15506 index ed5903b..c7fe163 100644
15507 --- a/arch/x86/include/asm/pgtable_32_types.h
15508 +++ b/arch/x86/include/asm/pgtable_32_types.h
15509 @@ -8,7 +8,7 @@
15510 */
15511 #ifdef CONFIG_X86_PAE
15512 # include <asm/pgtable-3level_types.h>
15513 -# define PMD_SIZE (1UL << PMD_SHIFT)
15514 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
15515 # define PMD_MASK (~(PMD_SIZE - 1))
15516 #else
15517 # include <asm/pgtable-2level_types.h>
15518 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
15519 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
15520 #endif
15521
15522 +#ifdef CONFIG_PAX_KERNEXEC
15523 +#ifndef __ASSEMBLY__
15524 +extern unsigned char MODULES_EXEC_VADDR[];
15525 +extern unsigned char MODULES_EXEC_END[];
15526 +#endif
15527 +#include <asm/boot.h>
15528 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
15529 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
15530 +#else
15531 +#define ktla_ktva(addr) (addr)
15532 +#define ktva_ktla(addr) (addr)
15533 +#endif
15534 +
15535 #define MODULES_VADDR VMALLOC_START
15536 #define MODULES_END VMALLOC_END
15537 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
15538 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
15539 index 47356f9..deb94a2 100644
15540 --- a/arch/x86/include/asm/pgtable_64.h
15541 +++ b/arch/x86/include/asm/pgtable_64.h
15542 @@ -16,10 +16,14 @@
15543
15544 extern pud_t level3_kernel_pgt[512];
15545 extern pud_t level3_ident_pgt[512];
15546 +extern pud_t level3_vmalloc_start_pgt[512];
15547 +extern pud_t level3_vmalloc_end_pgt[512];
15548 +extern pud_t level3_vmemmap_pgt[512];
15549 +extern pud_t level2_vmemmap_pgt[512];
15550 extern pmd_t level2_kernel_pgt[512];
15551 extern pmd_t level2_fixmap_pgt[512];
15552 -extern pmd_t level2_ident_pgt[512];
15553 -extern pgd_t init_level4_pgt[];
15554 +extern pmd_t level2_ident_pgt[512*2];
15555 +extern pgd_t init_level4_pgt[512];
15556
15557 #define swapper_pg_dir init_level4_pgt
15558
15559 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
15560
15561 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
15562 {
15563 + pax_open_kernel();
15564 *pmdp = pmd;
15565 + pax_close_kernel();
15566 }
15567
15568 static inline void native_pmd_clear(pmd_t *pmd)
15569 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
15570
15571 static inline void native_set_pud(pud_t *pudp, pud_t pud)
15572 {
15573 + pax_open_kernel();
15574 *pudp = pud;
15575 + pax_close_kernel();
15576 }
15577
15578 static inline void native_pud_clear(pud_t *pud)
15579 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
15580
15581 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
15582 {
15583 + pax_open_kernel();
15584 + *pgdp = pgd;
15585 + pax_close_kernel();
15586 +}
15587 +
15588 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
15589 +{
15590 *pgdp = pgd;
15591 }
15592
15593 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
15594 index 766ea16..5b96cb3 100644
15595 --- a/arch/x86/include/asm/pgtable_64_types.h
15596 +++ b/arch/x86/include/asm/pgtable_64_types.h
15597 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
15598 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
15599 #define MODULES_END _AC(0xffffffffff000000, UL)
15600 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
15601 +#define MODULES_EXEC_VADDR MODULES_VADDR
15602 +#define MODULES_EXEC_END MODULES_END
15603 +
15604 +#define ktla_ktva(addr) (addr)
15605 +#define ktva_ktla(addr) (addr)
15606
15607 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
15608 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
15609 index 3c32db8..1ddccf5 100644
15610 --- a/arch/x86/include/asm/pgtable_types.h
15611 +++ b/arch/x86/include/asm/pgtable_types.h
15612 @@ -16,13 +16,12 @@
15613 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
15614 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
15615 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
15616 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
15617 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
15618 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
15619 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
15620 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
15621 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
15622 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
15623 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
15624 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
15625 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
15626 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
15627
15628 /* If _PAGE_BIT_PRESENT is clear, we use these: */
15629 @@ -40,7 +39,6 @@
15630 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
15631 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
15632 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
15633 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
15634 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
15635 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
15636 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
15637 @@ -57,8 +55,10 @@
15638
15639 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
15640 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
15641 -#else
15642 +#elif defined(CONFIG_KMEMCHECK)
15643 #define _PAGE_NX (_AT(pteval_t, 0))
15644 +#else
15645 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
15646 #endif
15647
15648 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
15649 @@ -116,6 +116,9 @@
15650 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
15651 _PAGE_ACCESSED)
15652
15653 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
15654 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
15655 +
15656 #define __PAGE_KERNEL_EXEC \
15657 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
15658 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
15659 @@ -126,7 +129,7 @@
15660 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
15661 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
15662 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
15663 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
15664 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
15665 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
15666 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
15667 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
15668 @@ -188,8 +191,8 @@
15669 * bits are combined, this will alow user to access the high address mapped
15670 * VDSO in the presence of CONFIG_COMPAT_VDSO
15671 */
15672 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
15673 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
15674 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15675 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15676 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
15677 #endif
15678
15679 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
15680 {
15681 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
15682 }
15683 +#endif
15684
15685 +#if PAGETABLE_LEVELS == 3
15686 +#include <asm-generic/pgtable-nopud.h>
15687 +#endif
15688 +
15689 +#if PAGETABLE_LEVELS == 2
15690 +#include <asm-generic/pgtable-nopmd.h>
15691 +#endif
15692 +
15693 +#ifndef __ASSEMBLY__
15694 #if PAGETABLE_LEVELS > 3
15695 typedef struct { pudval_t pud; } pud_t;
15696
15697 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
15698 return pud.pud;
15699 }
15700 #else
15701 -#include <asm-generic/pgtable-nopud.h>
15702 -
15703 static inline pudval_t native_pud_val(pud_t pud)
15704 {
15705 return native_pgd_val(pud.pgd);
15706 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
15707 return pmd.pmd;
15708 }
15709 #else
15710 -#include <asm-generic/pgtable-nopmd.h>
15711 -
15712 static inline pmdval_t native_pmd_val(pmd_t pmd)
15713 {
15714 return native_pgd_val(pmd.pud.pgd);
15715 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
15716
15717 extern pteval_t __supported_pte_mask;
15718 extern void set_nx(void);
15719 -extern int nx_enabled;
15720
15721 #define pgprot_writecombine pgprot_writecombine
15722 extern pgprot_t pgprot_writecombine(pgprot_t prot);
15723 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
15724 index 888184b..a07ac89 100644
15725 --- a/arch/x86/include/asm/processor.h
15726 +++ b/arch/x86/include/asm/processor.h
15727 @@ -287,7 +287,7 @@ struct tss_struct {
15728
15729 } ____cacheline_aligned;
15730
15731 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
15732 +extern struct tss_struct init_tss[NR_CPUS];
15733
15734 /*
15735 * Save the original ist values for checking stack pointers during debugging
15736 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
15737 */
15738 #define TASK_SIZE PAGE_OFFSET
15739 #define TASK_SIZE_MAX TASK_SIZE
15740 +
15741 +#ifdef CONFIG_PAX_SEGMEXEC
15742 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
15743 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
15744 +#else
15745 #define STACK_TOP TASK_SIZE
15746 -#define STACK_TOP_MAX STACK_TOP
15747 +#endif
15748 +
15749 +#define STACK_TOP_MAX TASK_SIZE
15750
15751 #define INIT_THREAD { \
15752 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15753 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15754 .vm86_info = NULL, \
15755 .sysenter_cs = __KERNEL_CS, \
15756 .io_bitmap_ptr = NULL, \
15757 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
15758 */
15759 #define INIT_TSS { \
15760 .x86_tss = { \
15761 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15762 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15763 .ss0 = __KERNEL_DS, \
15764 .ss1 = __KERNEL_CS, \
15765 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
15766 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
15767 extern unsigned long thread_saved_pc(struct task_struct *tsk);
15768
15769 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
15770 -#define KSTK_TOP(info) \
15771 -({ \
15772 - unsigned long *__ptr = (unsigned long *)(info); \
15773 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
15774 -})
15775 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
15776
15777 /*
15778 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
15779 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15780 #define task_pt_regs(task) \
15781 ({ \
15782 struct pt_regs *__regs__; \
15783 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
15784 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
15785 __regs__ - 1; \
15786 })
15787
15788 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15789 /*
15790 * User space process size. 47bits minus one guard page.
15791 */
15792 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
15793 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
15794
15795 /* This decides where the kernel will search for a free chunk of vm
15796 * space during mmap's.
15797 */
15798 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
15799 - 0xc0000000 : 0xFFFFe000)
15800 + 0xc0000000 : 0xFFFFf000)
15801
15802 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
15803 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
15804 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15805 #define STACK_TOP_MAX TASK_SIZE_MAX
15806
15807 #define INIT_THREAD { \
15808 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15809 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15810 }
15811
15812 #define INIT_TSS { \
15813 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15814 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15815 }
15816
15817 /*
15818 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
15819 */
15820 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
15821
15822 +#ifdef CONFIG_PAX_SEGMEXEC
15823 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
15824 +#endif
15825 +
15826 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
15827
15828 /* Get/set a process' ability to use the timestamp counter instruction */
15829 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
15830 #define cpu_has_amd_erratum(x) (false)
15831 #endif /* CONFIG_CPU_SUP_AMD */
15832
15833 -extern unsigned long arch_align_stack(unsigned long sp);
15834 +#define arch_align_stack(x) ((x) & ~0xfUL)
15835 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
15836
15837 void default_idle(void);
15838 bool set_pm_idle_to_default(void);
15839
15840 -void stop_this_cpu(void *dummy);
15841 +void stop_this_cpu(void *dummy) __noreturn;
15842
15843 #endif /* _ASM_X86_PROCESSOR_H */
15844 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
15845 index 942a086..6c26446 100644
15846 --- a/arch/x86/include/asm/ptrace.h
15847 +++ b/arch/x86/include/asm/ptrace.h
15848 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
15849 }
15850
15851 /*
15852 - * user_mode_vm(regs) determines whether a register set came from user mode.
15853 + * user_mode(regs) determines whether a register set came from user mode.
15854 * This is true if V8086 mode was enabled OR if the register set was from
15855 * protected mode with RPL-3 CS value. This tricky test checks that with
15856 * one comparison. Many places in the kernel can bypass this full check
15857 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
15858 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
15859 + * be used.
15860 */
15861 -static inline int user_mode(struct pt_regs *regs)
15862 +static inline int user_mode_novm(struct pt_regs *regs)
15863 {
15864 #ifdef CONFIG_X86_32
15865 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15866 #else
15867 - return !!(regs->cs & 3);
15868 + return !!(regs->cs & SEGMENT_RPL_MASK);
15869 #endif
15870 }
15871
15872 -static inline int user_mode_vm(struct pt_regs *regs)
15873 +static inline int user_mode(struct pt_regs *regs)
15874 {
15875 #ifdef CONFIG_X86_32
15876 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15877 USER_RPL;
15878 #else
15879 - return user_mode(regs);
15880 + return user_mode_novm(regs);
15881 #endif
15882 }
15883
15884 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15885 #ifdef CONFIG_X86_64
15886 static inline bool user_64bit_mode(struct pt_regs *regs)
15887 {
15888 + unsigned long cs = regs->cs & 0xffff;
15889 #ifndef CONFIG_PARAVIRT
15890 /*
15891 * On non-paravirt systems, this is the only long mode CPL 3
15892 * selector. We do not allow long mode selectors in the LDT.
15893 */
15894 - return regs->cs == __USER_CS;
15895 + return cs == __USER_CS;
15896 #else
15897 /* Headers are too twisted for this to go in paravirt.h. */
15898 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15899 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15900 #endif
15901 }
15902
15903 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15904 * Traps from the kernel do not save sp and ss.
15905 * Use the helper function to retrieve sp.
15906 */
15907 - if (offset == offsetof(struct pt_regs, sp) &&
15908 - regs->cs == __KERNEL_CS)
15909 - return kernel_stack_pointer(regs);
15910 + if (offset == offsetof(struct pt_regs, sp)) {
15911 + unsigned long cs = regs->cs & 0xffff;
15912 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15913 + return kernel_stack_pointer(regs);
15914 + }
15915 #endif
15916 return *(unsigned long *)((unsigned long)regs + offset);
15917 }
15918 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15919 index fe1ec5b..dc5c3fe 100644
15920 --- a/arch/x86/include/asm/realmode.h
15921 +++ b/arch/x86/include/asm/realmode.h
15922 @@ -22,16 +22,14 @@ struct real_mode_header {
15923 #endif
15924 /* APM/BIOS reboot */
15925 u32 machine_real_restart_asm;
15926 -#ifdef CONFIG_X86_64
15927 u32 machine_real_restart_seg;
15928 -#endif
15929 };
15930
15931 /* This must match data at trampoline_32/64.S */
15932 struct trampoline_header {
15933 #ifdef CONFIG_X86_32
15934 u32 start;
15935 - u16 gdt_pad;
15936 + u16 boot_cs;
15937 u16 gdt_limit;
15938 u32 gdt_base;
15939 #else
15940 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15941 index a82c4f1..ac45053 100644
15942 --- a/arch/x86/include/asm/reboot.h
15943 +++ b/arch/x86/include/asm/reboot.h
15944 @@ -6,13 +6,13 @@
15945 struct pt_regs;
15946
15947 struct machine_ops {
15948 - void (*restart)(char *cmd);
15949 - void (*halt)(void);
15950 - void (*power_off)(void);
15951 + void (* __noreturn restart)(char *cmd);
15952 + void (* __noreturn halt)(void);
15953 + void (* __noreturn power_off)(void);
15954 void (*shutdown)(void);
15955 void (*crash_shutdown)(struct pt_regs *);
15956 - void (*emergency_restart)(void);
15957 -};
15958 + void (* __noreturn emergency_restart)(void);
15959 +} __no_const;
15960
15961 extern struct machine_ops machine_ops;
15962
15963 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15964 index 2dbe4a7..ce1db00 100644
15965 --- a/arch/x86/include/asm/rwsem.h
15966 +++ b/arch/x86/include/asm/rwsem.h
15967 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15968 {
15969 asm volatile("# beginning down_read\n\t"
15970 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15971 +
15972 +#ifdef CONFIG_PAX_REFCOUNT
15973 + "jno 0f\n"
15974 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15975 + "int $4\n0:\n"
15976 + _ASM_EXTABLE(0b, 0b)
15977 +#endif
15978 +
15979 /* adds 0x00000001 */
15980 " jns 1f\n"
15981 " call call_rwsem_down_read_failed\n"
15982 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15983 "1:\n\t"
15984 " mov %1,%2\n\t"
15985 " add %3,%2\n\t"
15986 +
15987 +#ifdef CONFIG_PAX_REFCOUNT
15988 + "jno 0f\n"
15989 + "sub %3,%2\n"
15990 + "int $4\n0:\n"
15991 + _ASM_EXTABLE(0b, 0b)
15992 +#endif
15993 +
15994 " jle 2f\n\t"
15995 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15996 " jnz 1b\n\t"
15997 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15998 long tmp;
15999 asm volatile("# beginning down_write\n\t"
16000 LOCK_PREFIX " xadd %1,(%2)\n\t"
16001 +
16002 +#ifdef CONFIG_PAX_REFCOUNT
16003 + "jno 0f\n"
16004 + "mov %1,(%2)\n"
16005 + "int $4\n0:\n"
16006 + _ASM_EXTABLE(0b, 0b)
16007 +#endif
16008 +
16009 /* adds 0xffff0001, returns the old value */
16010 " test %1,%1\n\t"
16011 /* was the count 0 before? */
16012 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
16013 long tmp;
16014 asm volatile("# beginning __up_read\n\t"
16015 LOCK_PREFIX " xadd %1,(%2)\n\t"
16016 +
16017 +#ifdef CONFIG_PAX_REFCOUNT
16018 + "jno 0f\n"
16019 + "mov %1,(%2)\n"
16020 + "int $4\n0:\n"
16021 + _ASM_EXTABLE(0b, 0b)
16022 +#endif
16023 +
16024 /* subtracts 1, returns the old value */
16025 " jns 1f\n\t"
16026 " call call_rwsem_wake\n" /* expects old value in %edx */
16027 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
16028 long tmp;
16029 asm volatile("# beginning __up_write\n\t"
16030 LOCK_PREFIX " xadd %1,(%2)\n\t"
16031 +
16032 +#ifdef CONFIG_PAX_REFCOUNT
16033 + "jno 0f\n"
16034 + "mov %1,(%2)\n"
16035 + "int $4\n0:\n"
16036 + _ASM_EXTABLE(0b, 0b)
16037 +#endif
16038 +
16039 /* subtracts 0xffff0001, returns the old value */
16040 " jns 1f\n\t"
16041 " call call_rwsem_wake\n" /* expects old value in %edx */
16042 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
16043 {
16044 asm volatile("# beginning __downgrade_write\n\t"
16045 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
16046 +
16047 +#ifdef CONFIG_PAX_REFCOUNT
16048 + "jno 0f\n"
16049 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
16050 + "int $4\n0:\n"
16051 + _ASM_EXTABLE(0b, 0b)
16052 +#endif
16053 +
16054 /*
16055 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
16056 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
16057 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
16058 */
16059 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
16060 {
16061 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
16062 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
16063 +
16064 +#ifdef CONFIG_PAX_REFCOUNT
16065 + "jno 0f\n"
16066 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
16067 + "int $4\n0:\n"
16068 + _ASM_EXTABLE(0b, 0b)
16069 +#endif
16070 +
16071 : "+m" (sem->count)
16072 : "er" (delta));
16073 }
16074 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
16075 */
16076 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
16077 {
16078 - return delta + xadd(&sem->count, delta);
16079 + return delta + xadd_check_overflow(&sem->count, delta);
16080 }
16081
16082 #endif /* __KERNEL__ */
16083 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
16084 index c48a950..c6d7468 100644
16085 --- a/arch/x86/include/asm/segment.h
16086 +++ b/arch/x86/include/asm/segment.h
16087 @@ -64,10 +64,15 @@
16088 * 26 - ESPFIX small SS
16089 * 27 - per-cpu [ offset to per-cpu data area ]
16090 * 28 - stack_canary-20 [ for stack protector ]
16091 - * 29 - unused
16092 - * 30 - unused
16093 + * 29 - PCI BIOS CS
16094 + * 30 - PCI BIOS DS
16095 * 31 - TSS for double fault handler
16096 */
16097 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
16098 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
16099 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
16100 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
16101 +
16102 #define GDT_ENTRY_TLS_MIN 6
16103 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
16104
16105 @@ -79,6 +84,8 @@
16106
16107 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
16108
16109 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
16110 +
16111 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
16112
16113 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
16114 @@ -104,6 +111,12 @@
16115 #define __KERNEL_STACK_CANARY 0
16116 #endif
16117
16118 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
16119 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
16120 +
16121 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
16122 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
16123 +
16124 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
16125
16126 /*
16127 @@ -141,7 +154,7 @@
16128 */
16129
16130 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
16131 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
16132 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
16133
16134
16135 #else
16136 @@ -165,6 +178,8 @@
16137 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
16138 #define __USER32_DS __USER_DS
16139
16140 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
16141 +
16142 #define GDT_ENTRY_TSS 8 /* needs two entries */
16143 #define GDT_ENTRY_LDT 10 /* needs two entries */
16144 #define GDT_ENTRY_TLS_MIN 12
16145 @@ -185,6 +200,7 @@
16146 #endif
16147
16148 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
16149 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
16150 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
16151 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
16152 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
16153 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
16154 {
16155 unsigned long __limit;
16156 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
16157 - return __limit + 1;
16158 + return __limit;
16159 }
16160
16161 #endif /* !__ASSEMBLY__ */
16162 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
16163 index b073aae..39f9bdd 100644
16164 --- a/arch/x86/include/asm/smp.h
16165 +++ b/arch/x86/include/asm/smp.h
16166 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
16167 /* cpus sharing the last level cache: */
16168 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
16169 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
16170 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
16171 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
16172
16173 static inline struct cpumask *cpu_sibling_mask(int cpu)
16174 {
16175 @@ -79,7 +79,7 @@ struct smp_ops {
16176
16177 void (*send_call_func_ipi)(const struct cpumask *mask);
16178 void (*send_call_func_single_ipi)(int cpu);
16179 -};
16180 +} __no_const;
16181
16182 /* Globals due to paravirt */
16183 extern void set_cpu_sibling_map(int cpu);
16184 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
16185 extern int safe_smp_processor_id(void);
16186
16187 #elif defined(CONFIG_X86_64_SMP)
16188 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
16189 -
16190 -#define stack_smp_processor_id() \
16191 -({ \
16192 - struct thread_info *ti; \
16193 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
16194 - ti->cpu; \
16195 -})
16196 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
16197 +#define stack_smp_processor_id() raw_smp_processor_id()
16198 #define safe_smp_processor_id() smp_processor_id()
16199
16200 #endif
16201 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
16202 index 33692ea..350a534 100644
16203 --- a/arch/x86/include/asm/spinlock.h
16204 +++ b/arch/x86/include/asm/spinlock.h
16205 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
16206 static inline void arch_read_lock(arch_rwlock_t *rw)
16207 {
16208 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
16209 +
16210 +#ifdef CONFIG_PAX_REFCOUNT
16211 + "jno 0f\n"
16212 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
16213 + "int $4\n0:\n"
16214 + _ASM_EXTABLE(0b, 0b)
16215 +#endif
16216 +
16217 "jns 1f\n"
16218 "call __read_lock_failed\n\t"
16219 "1:\n"
16220 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
16221 static inline void arch_write_lock(arch_rwlock_t *rw)
16222 {
16223 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
16224 +
16225 +#ifdef CONFIG_PAX_REFCOUNT
16226 + "jno 0f\n"
16227 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
16228 + "int $4\n0:\n"
16229 + _ASM_EXTABLE(0b, 0b)
16230 +#endif
16231 +
16232 "jz 1f\n"
16233 "call __write_lock_failed\n\t"
16234 "1:\n"
16235 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
16236
16237 static inline void arch_read_unlock(arch_rwlock_t *rw)
16238 {
16239 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
16240 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
16241 +
16242 +#ifdef CONFIG_PAX_REFCOUNT
16243 + "jno 0f\n"
16244 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
16245 + "int $4\n0:\n"
16246 + _ASM_EXTABLE(0b, 0b)
16247 +#endif
16248 +
16249 :"+m" (rw->lock) : : "memory");
16250 }
16251
16252 static inline void arch_write_unlock(arch_rwlock_t *rw)
16253 {
16254 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
16255 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
16256 +
16257 +#ifdef CONFIG_PAX_REFCOUNT
16258 + "jno 0f\n"
16259 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
16260 + "int $4\n0:\n"
16261 + _ASM_EXTABLE(0b, 0b)
16262 +#endif
16263 +
16264 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
16265 }
16266
16267 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
16268 index 6a99859..03cb807 100644
16269 --- a/arch/x86/include/asm/stackprotector.h
16270 +++ b/arch/x86/include/asm/stackprotector.h
16271 @@ -47,7 +47,7 @@
16272 * head_32 for boot CPU and setup_per_cpu_areas() for others.
16273 */
16274 #define GDT_STACK_CANARY_INIT \
16275 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
16276 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
16277
16278 /*
16279 * Initialize the stackprotector canary value.
16280 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
16281
16282 static inline void load_stack_canary_segment(void)
16283 {
16284 -#ifdef CONFIG_X86_32
16285 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
16286 asm volatile ("mov %0, %%gs" : : "r" (0));
16287 #endif
16288 }
16289 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
16290 index 70bbe39..4ae2bd4 100644
16291 --- a/arch/x86/include/asm/stacktrace.h
16292 +++ b/arch/x86/include/asm/stacktrace.h
16293 @@ -11,28 +11,20 @@
16294
16295 extern int kstack_depth_to_print;
16296
16297 -struct thread_info;
16298 +struct task_struct;
16299 struct stacktrace_ops;
16300
16301 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
16302 - unsigned long *stack,
16303 - unsigned long bp,
16304 - const struct stacktrace_ops *ops,
16305 - void *data,
16306 - unsigned long *end,
16307 - int *graph);
16308 +typedef unsigned long walk_stack_t(struct task_struct *task,
16309 + void *stack_start,
16310 + unsigned long *stack,
16311 + unsigned long bp,
16312 + const struct stacktrace_ops *ops,
16313 + void *data,
16314 + unsigned long *end,
16315 + int *graph);
16316
16317 -extern unsigned long
16318 -print_context_stack(struct thread_info *tinfo,
16319 - unsigned long *stack, unsigned long bp,
16320 - const struct stacktrace_ops *ops, void *data,
16321 - unsigned long *end, int *graph);
16322 -
16323 -extern unsigned long
16324 -print_context_stack_bp(struct thread_info *tinfo,
16325 - unsigned long *stack, unsigned long bp,
16326 - const struct stacktrace_ops *ops, void *data,
16327 - unsigned long *end, int *graph);
16328 +extern walk_stack_t print_context_stack;
16329 +extern walk_stack_t print_context_stack_bp;
16330
16331 /* Generic stack tracer with callbacks */
16332
16333 @@ -40,7 +32,7 @@ struct stacktrace_ops {
16334 void (*address)(void *data, unsigned long address, int reliable);
16335 /* On negative return stop dumping */
16336 int (*stack)(void *data, char *name);
16337 - walk_stack_t walk_stack;
16338 + walk_stack_t *walk_stack;
16339 };
16340
16341 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
16342 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
16343 index 4ec45b3..a4f0a8a 100644
16344 --- a/arch/x86/include/asm/switch_to.h
16345 +++ b/arch/x86/include/asm/switch_to.h
16346 @@ -108,7 +108,7 @@ do { \
16347 "call __switch_to\n\t" \
16348 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
16349 __switch_canary \
16350 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
16351 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
16352 "movq %%rax,%%rdi\n\t" \
16353 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
16354 "jnz ret_from_fork\n\t" \
16355 @@ -119,7 +119,7 @@ do { \
16356 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
16357 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
16358 [_tif_fork] "i" (_TIF_FORK), \
16359 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
16360 + [thread_info] "m" (current_tinfo), \
16361 [current_task] "m" (current_task) \
16362 __switch_canary_iparam \
16363 : "memory", "cc" __EXTRA_CLOBBER)
16364 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
16365 index 2d946e6..e453ec4 100644
16366 --- a/arch/x86/include/asm/thread_info.h
16367 +++ b/arch/x86/include/asm/thread_info.h
16368 @@ -10,6 +10,7 @@
16369 #include <linux/compiler.h>
16370 #include <asm/page.h>
16371 #include <asm/types.h>
16372 +#include <asm/percpu.h>
16373
16374 /*
16375 * low level task data that entry.S needs immediate access to
16376 @@ -24,7 +25,6 @@ struct exec_domain;
16377 #include <linux/atomic.h>
16378
16379 struct thread_info {
16380 - struct task_struct *task; /* main task structure */
16381 struct exec_domain *exec_domain; /* execution domain */
16382 __u32 flags; /* low level flags */
16383 __u32 status; /* thread synchronous flags */
16384 @@ -34,19 +34,13 @@ struct thread_info {
16385 mm_segment_t addr_limit;
16386 struct restart_block restart_block;
16387 void __user *sysenter_return;
16388 -#ifdef CONFIG_X86_32
16389 - unsigned long previous_esp; /* ESP of the previous stack in
16390 - case of nested (IRQ) stacks
16391 - */
16392 - __u8 supervisor_stack[0];
16393 -#endif
16394 + unsigned long lowest_stack;
16395 unsigned int sig_on_uaccess_error:1;
16396 unsigned int uaccess_err:1; /* uaccess failed */
16397 };
16398
16399 -#define INIT_THREAD_INFO(tsk) \
16400 +#define INIT_THREAD_INFO \
16401 { \
16402 - .task = &tsk, \
16403 .exec_domain = &default_exec_domain, \
16404 .flags = 0, \
16405 .cpu = 0, \
16406 @@ -57,7 +51,7 @@ struct thread_info {
16407 }, \
16408 }
16409
16410 -#define init_thread_info (init_thread_union.thread_info)
16411 +#define init_thread_info (init_thread_union.stack)
16412 #define init_stack (init_thread_union.stack)
16413
16414 #else /* !__ASSEMBLY__ */
16415 @@ -98,6 +92,7 @@ struct thread_info {
16416 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
16417 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
16418 #define TIF_X32 30 /* 32-bit native x86-64 binary */
16419 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
16420
16421 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
16422 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
16423 @@ -122,17 +117,18 @@ struct thread_info {
16424 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
16425 #define _TIF_ADDR32 (1 << TIF_ADDR32)
16426 #define _TIF_X32 (1 << TIF_X32)
16427 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
16428
16429 /* work to do in syscall_trace_enter() */
16430 #define _TIF_WORK_SYSCALL_ENTRY \
16431 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
16432 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
16433 - _TIF_NOHZ)
16434 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
16435
16436 /* work to do in syscall_trace_leave() */
16437 #define _TIF_WORK_SYSCALL_EXIT \
16438 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
16439 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
16440 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
16441
16442 /* work to do on interrupt/exception return */
16443 #define _TIF_WORK_MASK \
16444 @@ -143,7 +139,7 @@ struct thread_info {
16445 /* work to do on any return to user space */
16446 #define _TIF_ALLWORK_MASK \
16447 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
16448 - _TIF_NOHZ)
16449 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
16450
16451 /* Only used for 64 bit */
16452 #define _TIF_DO_NOTIFY_MASK \
16453 @@ -159,45 +155,40 @@ struct thread_info {
16454
16455 #define PREEMPT_ACTIVE 0x10000000
16456
16457 -#ifdef CONFIG_X86_32
16458 -
16459 -#define STACK_WARN (THREAD_SIZE/8)
16460 -/*
16461 - * macros/functions for gaining access to the thread information structure
16462 - *
16463 - * preempt_count needs to be 1 initially, until the scheduler is functional.
16464 - */
16465 -#ifndef __ASSEMBLY__
16466 -
16467 -
16468 -/* how to get the current stack pointer from C */
16469 -register unsigned long current_stack_pointer asm("esp") __used;
16470 -
16471 -/* how to get the thread information struct from C */
16472 -static inline struct thread_info *current_thread_info(void)
16473 -{
16474 - return (struct thread_info *)
16475 - (current_stack_pointer & ~(THREAD_SIZE - 1));
16476 -}
16477 -
16478 -#else /* !__ASSEMBLY__ */
16479 -
16480 +#ifdef __ASSEMBLY__
16481 /* how to get the thread information struct from ASM */
16482 #define GET_THREAD_INFO(reg) \
16483 - movl $-THREAD_SIZE, reg; \
16484 - andl %esp, reg
16485 + mov PER_CPU_VAR(current_tinfo), reg
16486
16487 /* use this one if reg already contains %esp */
16488 -#define GET_THREAD_INFO_WITH_ESP(reg) \
16489 - andl $-THREAD_SIZE, reg
16490 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
16491 +#else
16492 +/* how to get the thread information struct from C */
16493 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
16494 +
16495 +static __always_inline struct thread_info *current_thread_info(void)
16496 +{
16497 + return this_cpu_read_stable(current_tinfo);
16498 +}
16499 +#endif
16500 +
16501 +#ifdef CONFIG_X86_32
16502 +
16503 +#define STACK_WARN (THREAD_SIZE/8)
16504 +/*
16505 + * macros/functions for gaining access to the thread information structure
16506 + *
16507 + * preempt_count needs to be 1 initially, until the scheduler is functional.
16508 + */
16509 +#ifndef __ASSEMBLY__
16510 +
16511 +/* how to get the current stack pointer from C */
16512 +register unsigned long current_stack_pointer asm("esp") __used;
16513
16514 #endif
16515
16516 #else /* X86_32 */
16517
16518 -#include <asm/percpu.h>
16519 -#define KERNEL_STACK_OFFSET (5*8)
16520 -
16521 /*
16522 * macros/functions for gaining access to the thread information structure
16523 * preempt_count needs to be 1 initially, until the scheduler is functional.
16524 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
16525 #ifndef __ASSEMBLY__
16526 DECLARE_PER_CPU(unsigned long, kernel_stack);
16527
16528 -static inline struct thread_info *current_thread_info(void)
16529 -{
16530 - struct thread_info *ti;
16531 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
16532 - KERNEL_STACK_OFFSET - THREAD_SIZE);
16533 - return ti;
16534 -}
16535 -
16536 -#else /* !__ASSEMBLY__ */
16537 -
16538 -/* how to get the thread information struct from ASM */
16539 -#define GET_THREAD_INFO(reg) \
16540 - movq PER_CPU_VAR(kernel_stack),reg ; \
16541 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
16542 -
16543 -/*
16544 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
16545 - * a certain register (to be used in assembler memory operands).
16546 - */
16547 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
16548 -
16549 +/* how to get the current stack pointer from C */
16550 +register unsigned long current_stack_pointer asm("rsp") __used;
16551 #endif
16552
16553 #endif /* !X86_32 */
16554 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
16555 extern void arch_task_cache_init(void);
16556 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
16557 extern void arch_release_task_struct(struct task_struct *tsk);
16558 +
16559 +#define __HAVE_THREAD_FUNCTIONS
16560 +#define task_thread_info(task) (&(task)->tinfo)
16561 +#define task_stack_page(task) ((task)->stack)
16562 +#define setup_thread_stack(p, org) do {} while (0)
16563 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
16564 +
16565 #endif
16566 #endif /* _ASM_X86_THREAD_INFO_H */
16567 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
16568 index 1709801..0a60f2f 100644
16569 --- a/arch/x86/include/asm/uaccess.h
16570 +++ b/arch/x86/include/asm/uaccess.h
16571 @@ -7,6 +7,7 @@
16572 #include <linux/compiler.h>
16573 #include <linux/thread_info.h>
16574 #include <linux/string.h>
16575 +#include <linux/sched.h>
16576 #include <asm/asm.h>
16577 #include <asm/page.h>
16578 #include <asm/smap.h>
16579 @@ -29,7 +30,12 @@
16580
16581 #define get_ds() (KERNEL_DS)
16582 #define get_fs() (current_thread_info()->addr_limit)
16583 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
16584 +void __set_fs(mm_segment_t x);
16585 +void set_fs(mm_segment_t x);
16586 +#else
16587 #define set_fs(x) (current_thread_info()->addr_limit = (x))
16588 +#endif
16589
16590 #define segment_eq(a, b) ((a).seg == (b).seg)
16591
16592 @@ -77,8 +83,33 @@
16593 * checks that the pointer is in the user space range - after calling
16594 * this function, memory access functions may still return -EFAULT.
16595 */
16596 -#define access_ok(type, addr, size) \
16597 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
16598 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
16599 +#define access_ok(type, addr, size) \
16600 +({ \
16601 + long __size = size; \
16602 + unsigned long __addr = (unsigned long)addr; \
16603 + unsigned long __addr_ao = __addr & PAGE_MASK; \
16604 + unsigned long __end_ao = __addr + __size - 1; \
16605 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
16606 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
16607 + while(__addr_ao <= __end_ao) { \
16608 + char __c_ao; \
16609 + __addr_ao += PAGE_SIZE; \
16610 + if (__size > PAGE_SIZE) \
16611 + cond_resched(); \
16612 + if (__get_user(__c_ao, (char __user *)__addr)) \
16613 + break; \
16614 + if (type != VERIFY_WRITE) { \
16615 + __addr = __addr_ao; \
16616 + continue; \
16617 + } \
16618 + if (__put_user(__c_ao, (char __user *)__addr)) \
16619 + break; \
16620 + __addr = __addr_ao; \
16621 + } \
16622 + } \
16623 + __ret_ao; \
16624 +})
16625
16626 /*
16627 * The exception table consists of pairs of addresses relative to the
16628 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
16629 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
16630 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
16631
16632 -
16633 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
16634 +#define __copyuser_seg "gs;"
16635 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
16636 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
16637 +#else
16638 +#define __copyuser_seg
16639 +#define __COPYUSER_SET_ES
16640 +#define __COPYUSER_RESTORE_ES
16641 +#endif
16642
16643 #ifdef CONFIG_X86_32
16644 #define __put_user_asm_u64(x, addr, err, errret) \
16645 asm volatile(ASM_STAC "\n" \
16646 - "1: movl %%eax,0(%2)\n" \
16647 - "2: movl %%edx,4(%2)\n" \
16648 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
16649 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
16650 "3: " ASM_CLAC "\n" \
16651 ".section .fixup,\"ax\"\n" \
16652 "4: movl %3,%0\n" \
16653 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
16654
16655 #define __put_user_asm_ex_u64(x, addr) \
16656 asm volatile(ASM_STAC "\n" \
16657 - "1: movl %%eax,0(%1)\n" \
16658 - "2: movl %%edx,4(%1)\n" \
16659 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
16660 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
16661 "3: " ASM_CLAC "\n" \
16662 _ASM_EXTABLE_EX(1b, 2b) \
16663 _ASM_EXTABLE_EX(2b, 3b) \
16664 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
16665 __typeof__(*(ptr)) __pu_val; \
16666 __chk_user_ptr(ptr); \
16667 might_fault(); \
16668 - __pu_val = x; \
16669 + __pu_val = (x); \
16670 switch (sizeof(*(ptr))) { \
16671 case 1: \
16672 __put_user_x(1, __pu_val, ptr, __ret_pu); \
16673 @@ -358,7 +397,7 @@ do { \
16674
16675 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16676 asm volatile(ASM_STAC "\n" \
16677 - "1: mov"itype" %2,%"rtype"1\n" \
16678 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
16679 "2: " ASM_CLAC "\n" \
16680 ".section .fixup,\"ax\"\n" \
16681 "3: mov %3,%0\n" \
16682 @@ -366,7 +405,7 @@ do { \
16683 " jmp 2b\n" \
16684 ".previous\n" \
16685 _ASM_EXTABLE(1b, 3b) \
16686 - : "=r" (err), ltype(x) \
16687 + : "=r" (err), ltype (x) \
16688 : "m" (__m(addr)), "i" (errret), "0" (err))
16689
16690 #define __get_user_size_ex(x, ptr, size) \
16691 @@ -391,7 +430,7 @@ do { \
16692 } while (0)
16693
16694 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
16695 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
16696 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
16697 "2:\n" \
16698 _ASM_EXTABLE_EX(1b, 2b) \
16699 : ltype(x) : "m" (__m(addr)))
16700 @@ -408,13 +447,24 @@ do { \
16701 int __gu_err; \
16702 unsigned long __gu_val; \
16703 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
16704 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
16705 + (x) = (__typeof__(*(ptr)))__gu_val; \
16706 __gu_err; \
16707 })
16708
16709 /* FIXME: this hack is definitely wrong -AK */
16710 struct __large_struct { unsigned long buf[100]; };
16711 -#define __m(x) (*(struct __large_struct __user *)(x))
16712 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16713 +#define ____m(x) \
16714 +({ \
16715 + unsigned long ____x = (unsigned long)(x); \
16716 + if (____x < PAX_USER_SHADOW_BASE) \
16717 + ____x += PAX_USER_SHADOW_BASE; \
16718 + (void __user *)____x; \
16719 +})
16720 +#else
16721 +#define ____m(x) (x)
16722 +#endif
16723 +#define __m(x) (*(struct __large_struct __user *)____m(x))
16724
16725 /*
16726 * Tell gcc we read from memory instead of writing: this is because
16727 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
16728 */
16729 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16730 asm volatile(ASM_STAC "\n" \
16731 - "1: mov"itype" %"rtype"1,%2\n" \
16732 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
16733 "2: " ASM_CLAC "\n" \
16734 ".section .fixup,\"ax\"\n" \
16735 "3: mov %3,%0\n" \
16736 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
16737 ".previous\n" \
16738 _ASM_EXTABLE(1b, 3b) \
16739 : "=r"(err) \
16740 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
16741 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
16742
16743 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
16744 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
16745 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
16746 "2:\n" \
16747 _ASM_EXTABLE_EX(1b, 2b) \
16748 : : ltype(x), "m" (__m(addr)))
16749 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
16750 * On error, the variable @x is set to zero.
16751 */
16752
16753 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16754 +#define __get_user(x, ptr) get_user((x), (ptr))
16755 +#else
16756 #define __get_user(x, ptr) \
16757 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
16758 +#endif
16759
16760 /**
16761 * __put_user: - Write a simple value into user space, with less checking.
16762 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
16763 * Returns zero on success, or -EFAULT on error.
16764 */
16765
16766 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16767 +#define __put_user(x, ptr) put_user((x), (ptr))
16768 +#else
16769 #define __put_user(x, ptr) \
16770 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
16771 +#endif
16772
16773 #define __get_user_unaligned __get_user
16774 #define __put_user_unaligned __put_user
16775 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
16776 #define get_user_ex(x, ptr) do { \
16777 unsigned long __gue_val; \
16778 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
16779 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
16780 + (x) = (__typeof__(*(ptr)))__gue_val; \
16781 } while (0)
16782
16783 #define put_user_try uaccess_try
16784 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
16785 extern __must_check long strlen_user(const char __user *str);
16786 extern __must_check long strnlen_user(const char __user *str, long n);
16787
16788 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
16789 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
16790 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16791 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16792
16793 /*
16794 * movsl can be slow when source and dest are not both 8-byte aligned
16795 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
16796 index 7f760a9..04b1c65 100644
16797 --- a/arch/x86/include/asm/uaccess_32.h
16798 +++ b/arch/x86/include/asm/uaccess_32.h
16799 @@ -11,15 +11,15 @@
16800 #include <asm/page.h>
16801
16802 unsigned long __must_check __copy_to_user_ll
16803 - (void __user *to, const void *from, unsigned long n);
16804 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
16805 unsigned long __must_check __copy_from_user_ll
16806 - (void *to, const void __user *from, unsigned long n);
16807 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16808 unsigned long __must_check __copy_from_user_ll_nozero
16809 - (void *to, const void __user *from, unsigned long n);
16810 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16811 unsigned long __must_check __copy_from_user_ll_nocache
16812 - (void *to, const void __user *from, unsigned long n);
16813 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16814 unsigned long __must_check __copy_from_user_ll_nocache_nozero
16815 - (void *to, const void __user *from, unsigned long n);
16816 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16817
16818 /**
16819 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
16820 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
16821 static __always_inline unsigned long __must_check
16822 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
16823 {
16824 + if ((long)n < 0)
16825 + return n;
16826 +
16827 + check_object_size(from, n, true);
16828 +
16829 if (__builtin_constant_p(n)) {
16830 unsigned long ret;
16831
16832 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
16833 __copy_to_user(void __user *to, const void *from, unsigned long n)
16834 {
16835 might_fault();
16836 +
16837 return __copy_to_user_inatomic(to, from, n);
16838 }
16839
16840 static __always_inline unsigned long
16841 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
16842 {
16843 + if ((long)n < 0)
16844 + return n;
16845 +
16846 /* Avoid zeroing the tail if the copy fails..
16847 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
16848 * but as the zeroing behaviour is only significant when n is not
16849 @@ -137,6 +146,12 @@ static __always_inline unsigned long
16850 __copy_from_user(void *to, const void __user *from, unsigned long n)
16851 {
16852 might_fault();
16853 +
16854 + if ((long)n < 0)
16855 + return n;
16856 +
16857 + check_object_size(to, n, false);
16858 +
16859 if (__builtin_constant_p(n)) {
16860 unsigned long ret;
16861
16862 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16863 const void __user *from, unsigned long n)
16864 {
16865 might_fault();
16866 +
16867 + if ((long)n < 0)
16868 + return n;
16869 +
16870 if (__builtin_constant_p(n)) {
16871 unsigned long ret;
16872
16873 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16874 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16875 unsigned long n)
16876 {
16877 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16878 + if ((long)n < 0)
16879 + return n;
16880 +
16881 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16882 }
16883
16884 -unsigned long __must_check copy_to_user(void __user *to,
16885 - const void *from, unsigned long n);
16886 -unsigned long __must_check _copy_from_user(void *to,
16887 - const void __user *from,
16888 - unsigned long n);
16889 -
16890 +extern void copy_to_user_overflow(void)
16891 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16892 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16893 +#else
16894 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16895 +#endif
16896 +;
16897
16898 extern void copy_from_user_overflow(void)
16899 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16900 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16901 #endif
16902 ;
16903
16904 -static inline unsigned long __must_check copy_from_user(void *to,
16905 - const void __user *from,
16906 - unsigned long n)
16907 +/**
16908 + * copy_to_user: - Copy a block of data into user space.
16909 + * @to: Destination address, in user space.
16910 + * @from: Source address, in kernel space.
16911 + * @n: Number of bytes to copy.
16912 + *
16913 + * Context: User context only. This function may sleep.
16914 + *
16915 + * Copy data from kernel space to user space.
16916 + *
16917 + * Returns number of bytes that could not be copied.
16918 + * On success, this will be zero.
16919 + */
16920 +static inline unsigned long __must_check
16921 +copy_to_user(void __user *to, const void *from, unsigned long n)
16922 {
16923 - int sz = __compiletime_object_size(to);
16924 + size_t sz = __compiletime_object_size(from);
16925
16926 - if (likely(sz == -1 || sz >= n))
16927 - n = _copy_from_user(to, from, n);
16928 - else
16929 + if (unlikely(sz != (size_t)-1 && sz < n))
16930 + copy_to_user_overflow();
16931 + else if (access_ok(VERIFY_WRITE, to, n))
16932 + n = __copy_to_user(to, from, n);
16933 + return n;
16934 +}
16935 +
16936 +/**
16937 + * copy_from_user: - Copy a block of data from user space.
16938 + * @to: Destination address, in kernel space.
16939 + * @from: Source address, in user space.
16940 + * @n: Number of bytes to copy.
16941 + *
16942 + * Context: User context only. This function may sleep.
16943 + *
16944 + * Copy data from user space to kernel space.
16945 + *
16946 + * Returns number of bytes that could not be copied.
16947 + * On success, this will be zero.
16948 + *
16949 + * If some data could not be copied, this function will pad the copied
16950 + * data to the requested size using zero bytes.
16951 + */
16952 +static inline unsigned long __must_check
16953 +copy_from_user(void *to, const void __user *from, unsigned long n)
16954 +{
16955 + size_t sz = __compiletime_object_size(to);
16956 +
16957 + check_object_size(to, n, false);
16958 +
16959 + if (unlikely(sz != (size_t)-1 && sz < n))
16960 copy_from_user_overflow();
16961 -
16962 + else if (access_ok(VERIFY_READ, from, n))
16963 + n = __copy_from_user(to, from, n);
16964 + else if ((long)n > 0)
16965 + memset(to, 0, n);
16966 return n;
16967 }
16968
16969 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16970 index 142810c..1f2a0a7 100644
16971 --- a/arch/x86/include/asm/uaccess_64.h
16972 +++ b/arch/x86/include/asm/uaccess_64.h
16973 @@ -10,6 +10,9 @@
16974 #include <asm/alternative.h>
16975 #include <asm/cpufeature.h>
16976 #include <asm/page.h>
16977 +#include <asm/pgtable.h>
16978 +
16979 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16980
16981 /*
16982 * Copy To/From Userspace
16983 @@ -17,13 +20,13 @@
16984
16985 /* Handles exceptions in both to and from, but doesn't do access_ok */
16986 __must_check unsigned long
16987 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16988 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16989 __must_check unsigned long
16990 -copy_user_generic_string(void *to, const void *from, unsigned len);
16991 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16992 __must_check unsigned long
16993 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16994 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16995
16996 -static __always_inline __must_check unsigned long
16997 +static __always_inline __must_check __size_overflow(3) unsigned long
16998 copy_user_generic(void *to, const void *from, unsigned len)
16999 {
17000 unsigned ret;
17001 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
17002 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
17003 "=d" (len)),
17004 "1" (to), "2" (from), "3" (len)
17005 - : "memory", "rcx", "r8", "r9", "r10", "r11");
17006 + : "memory", "rcx", "r8", "r9", "r11");
17007 return ret;
17008 }
17009
17010 +static __always_inline __must_check unsigned long
17011 +__copy_to_user(void __user *to, const void *from, unsigned long len);
17012 +static __always_inline __must_check unsigned long
17013 +__copy_from_user(void *to, const void __user *from, unsigned long len);
17014 __must_check unsigned long
17015 -_copy_to_user(void __user *to, const void *from, unsigned len);
17016 -__must_check unsigned long
17017 -_copy_from_user(void *to, const void __user *from, unsigned len);
17018 -__must_check unsigned long
17019 -copy_in_user(void __user *to, const void __user *from, unsigned len);
17020 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
17021 +
17022 +extern void copy_to_user_overflow(void)
17023 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
17024 + __compiletime_error("copy_to_user() buffer size is not provably correct")
17025 +#else
17026 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
17027 +#endif
17028 +;
17029 +
17030 +extern void copy_from_user_overflow(void)
17031 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
17032 + __compiletime_error("copy_from_user() buffer size is not provably correct")
17033 +#else
17034 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
17035 +#endif
17036 +;
17037
17038 static inline unsigned long __must_check copy_from_user(void *to,
17039 const void __user *from,
17040 unsigned long n)
17041 {
17042 - int sz = __compiletime_object_size(to);
17043 -
17044 might_fault();
17045 - if (likely(sz == -1 || sz >= n))
17046 - n = _copy_from_user(to, from, n);
17047 -#ifdef CONFIG_DEBUG_VM
17048 - else
17049 - WARN(1, "Buffer overflow detected!\n");
17050 -#endif
17051 +
17052 + check_object_size(to, n, false);
17053 +
17054 + if (access_ok(VERIFY_READ, from, n))
17055 + n = __copy_from_user(to, from, n);
17056 + else if (n < INT_MAX)
17057 + memset(to, 0, n);
17058 return n;
17059 }
17060
17061 static __always_inline __must_check
17062 -int copy_to_user(void __user *dst, const void *src, unsigned size)
17063 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
17064 {
17065 might_fault();
17066
17067 - return _copy_to_user(dst, src, size);
17068 + if (access_ok(VERIFY_WRITE, dst, size))
17069 + size = __copy_to_user(dst, src, size);
17070 + return size;
17071 }
17072
17073 static __always_inline __must_check
17074 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
17075 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
17076 {
17077 - int ret = 0;
17078 + size_t sz = __compiletime_object_size(dst);
17079 + unsigned ret = 0;
17080
17081 might_fault();
17082 +
17083 + if (size > INT_MAX)
17084 + return size;
17085 +
17086 + check_object_size(dst, size, false);
17087 +
17088 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17089 + if (!__access_ok(VERIFY_READ, src, size))
17090 + return size;
17091 +#endif
17092 +
17093 + if (unlikely(sz != (size_t)-1 && sz < size)) {
17094 + copy_from_user_overflow();
17095 + return size;
17096 + }
17097 +
17098 if (!__builtin_constant_p(size))
17099 - return copy_user_generic(dst, (__force void *)src, size);
17100 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
17101 switch (size) {
17102 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
17103 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
17104 ret, "b", "b", "=q", 1);
17105 return ret;
17106 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
17107 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
17108 ret, "w", "w", "=r", 2);
17109 return ret;
17110 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
17111 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
17112 ret, "l", "k", "=r", 4);
17113 return ret;
17114 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
17115 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
17116 ret, "q", "", "=r", 8);
17117 return ret;
17118 case 10:
17119 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
17120 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
17121 ret, "q", "", "=r", 10);
17122 if (unlikely(ret))
17123 return ret;
17124 __get_user_asm(*(u16 *)(8 + (char *)dst),
17125 - (u16 __user *)(8 + (char __user *)src),
17126 + (const u16 __user *)(8 + (const char __user *)src),
17127 ret, "w", "w", "=r", 2);
17128 return ret;
17129 case 16:
17130 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
17131 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
17132 ret, "q", "", "=r", 16);
17133 if (unlikely(ret))
17134 return ret;
17135 __get_user_asm(*(u64 *)(8 + (char *)dst),
17136 - (u64 __user *)(8 + (char __user *)src),
17137 + (const u64 __user *)(8 + (const char __user *)src),
17138 ret, "q", "", "=r", 8);
17139 return ret;
17140 default:
17141 - return copy_user_generic(dst, (__force void *)src, size);
17142 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
17143 }
17144 }
17145
17146 static __always_inline __must_check
17147 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
17148 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
17149 {
17150 - int ret = 0;
17151 + size_t sz = __compiletime_object_size(src);
17152 + unsigned ret = 0;
17153
17154 might_fault();
17155 +
17156 + if (size > INT_MAX)
17157 + return size;
17158 +
17159 + check_object_size(src, size, true);
17160 +
17161 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17162 + if (!__access_ok(VERIFY_WRITE, dst, size))
17163 + return size;
17164 +#endif
17165 +
17166 + if (unlikely(sz != (size_t)-1 && sz < size)) {
17167 + copy_to_user_overflow();
17168 + return size;
17169 + }
17170 +
17171 if (!__builtin_constant_p(size))
17172 - return copy_user_generic((__force void *)dst, src, size);
17173 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
17174 switch (size) {
17175 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
17176 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
17177 ret, "b", "b", "iq", 1);
17178 return ret;
17179 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
17180 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
17181 ret, "w", "w", "ir", 2);
17182 return ret;
17183 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
17184 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
17185 ret, "l", "k", "ir", 4);
17186 return ret;
17187 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
17188 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
17189 ret, "q", "", "er", 8);
17190 return ret;
17191 case 10:
17192 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
17193 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
17194 ret, "q", "", "er", 10);
17195 if (unlikely(ret))
17196 return ret;
17197 asm("":::"memory");
17198 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
17199 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
17200 ret, "w", "w", "ir", 2);
17201 return ret;
17202 case 16:
17203 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
17204 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
17205 ret, "q", "", "er", 16);
17206 if (unlikely(ret))
17207 return ret;
17208 asm("":::"memory");
17209 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
17210 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
17211 ret, "q", "", "er", 8);
17212 return ret;
17213 default:
17214 - return copy_user_generic((__force void *)dst, src, size);
17215 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
17216 }
17217 }
17218
17219 static __always_inline __must_check
17220 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17221 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
17222 {
17223 - int ret = 0;
17224 + unsigned ret = 0;
17225
17226 might_fault();
17227 +
17228 + if (size > INT_MAX)
17229 + return size;
17230 +
17231 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17232 + if (!__access_ok(VERIFY_READ, src, size))
17233 + return size;
17234 + if (!__access_ok(VERIFY_WRITE, dst, size))
17235 + return size;
17236 +#endif
17237 +
17238 if (!__builtin_constant_p(size))
17239 - return copy_user_generic((__force void *)dst,
17240 - (__force void *)src, size);
17241 + return copy_user_generic((__force_kernel void *)____m(dst),
17242 + (__force_kernel const void *)____m(src), size);
17243 switch (size) {
17244 case 1: {
17245 u8 tmp;
17246 - __get_user_asm(tmp, (u8 __user *)src,
17247 + __get_user_asm(tmp, (const u8 __user *)src,
17248 ret, "b", "b", "=q", 1);
17249 if (likely(!ret))
17250 __put_user_asm(tmp, (u8 __user *)dst,
17251 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17252 }
17253 case 2: {
17254 u16 tmp;
17255 - __get_user_asm(tmp, (u16 __user *)src,
17256 + __get_user_asm(tmp, (const u16 __user *)src,
17257 ret, "w", "w", "=r", 2);
17258 if (likely(!ret))
17259 __put_user_asm(tmp, (u16 __user *)dst,
17260 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17261
17262 case 4: {
17263 u32 tmp;
17264 - __get_user_asm(tmp, (u32 __user *)src,
17265 + __get_user_asm(tmp, (const u32 __user *)src,
17266 ret, "l", "k", "=r", 4);
17267 if (likely(!ret))
17268 __put_user_asm(tmp, (u32 __user *)dst,
17269 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17270 }
17271 case 8: {
17272 u64 tmp;
17273 - __get_user_asm(tmp, (u64 __user *)src,
17274 + __get_user_asm(tmp, (const u64 __user *)src,
17275 ret, "q", "", "=r", 8);
17276 if (likely(!ret))
17277 __put_user_asm(tmp, (u64 __user *)dst,
17278 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17279 return ret;
17280 }
17281 default:
17282 - return copy_user_generic((__force void *)dst,
17283 - (__force void *)src, size);
17284 + return copy_user_generic((__force_kernel void *)____m(dst),
17285 + (__force_kernel const void *)____m(src), size);
17286 }
17287 }
17288
17289 static __must_check __always_inline int
17290 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
17291 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
17292 {
17293 - return copy_user_generic(dst, (__force const void *)src, size);
17294 + if (size > INT_MAX)
17295 + return size;
17296 +
17297 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17298 + if (!__access_ok(VERIFY_READ, src, size))
17299 + return size;
17300 +#endif
17301 +
17302 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
17303 }
17304
17305 -static __must_check __always_inline int
17306 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
17307 +static __must_check __always_inline unsigned long
17308 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
17309 {
17310 - return copy_user_generic((__force void *)dst, src, size);
17311 + if (size > INT_MAX)
17312 + return size;
17313 +
17314 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17315 + if (!__access_ok(VERIFY_WRITE, dst, size))
17316 + return size;
17317 +#endif
17318 +
17319 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
17320 }
17321
17322 -extern long __copy_user_nocache(void *dst, const void __user *src,
17323 - unsigned size, int zerorest);
17324 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
17325 + unsigned long size, int zerorest) __size_overflow(3);
17326
17327 -static inline int
17328 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
17329 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
17330 {
17331 might_sleep();
17332 +
17333 + if (size > INT_MAX)
17334 + return size;
17335 +
17336 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17337 + if (!__access_ok(VERIFY_READ, src, size))
17338 + return size;
17339 +#endif
17340 +
17341 return __copy_user_nocache(dst, src, size, 1);
17342 }
17343
17344 -static inline int
17345 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
17346 - unsigned size)
17347 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
17348 + unsigned long size)
17349 {
17350 + if (size > INT_MAX)
17351 + return size;
17352 +
17353 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17354 + if (!__access_ok(VERIFY_READ, src, size))
17355 + return size;
17356 +#endif
17357 +
17358 return __copy_user_nocache(dst, src, size, 0);
17359 }
17360
17361 -unsigned long
17362 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
17363 +extern unsigned long
17364 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
17365
17366 #endif /* _ASM_X86_UACCESS_64_H */
17367 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
17368 index 5b238981..77fdd78 100644
17369 --- a/arch/x86/include/asm/word-at-a-time.h
17370 +++ b/arch/x86/include/asm/word-at-a-time.h
17371 @@ -11,7 +11,7 @@
17372 * and shift, for example.
17373 */
17374 struct word_at_a_time {
17375 - const unsigned long one_bits, high_bits;
17376 + unsigned long one_bits, high_bits;
17377 };
17378
17379 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
17380 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
17381 index 5769349..a3d3e2a 100644
17382 --- a/arch/x86/include/asm/x86_init.h
17383 +++ b/arch/x86/include/asm/x86_init.h
17384 @@ -141,7 +141,7 @@ struct x86_init_ops {
17385 struct x86_init_timers timers;
17386 struct x86_init_iommu iommu;
17387 struct x86_init_pci pci;
17388 -};
17389 +} __no_const;
17390
17391 /**
17392 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
17393 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
17394 void (*setup_percpu_clockev)(void);
17395 void (*early_percpu_clock_init)(void);
17396 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
17397 -};
17398 +} __no_const;
17399
17400 /**
17401 * struct x86_platform_ops - platform specific runtime functions
17402 @@ -178,7 +178,7 @@ struct x86_platform_ops {
17403 void (*save_sched_clock_state)(void);
17404 void (*restore_sched_clock_state)(void);
17405 void (*apic_post_init)(void);
17406 -};
17407 +} __no_const;
17408
17409 struct pci_dev;
17410
17411 @@ -187,14 +187,14 @@ struct x86_msi_ops {
17412 void (*teardown_msi_irq)(unsigned int irq);
17413 void (*teardown_msi_irqs)(struct pci_dev *dev);
17414 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
17415 -};
17416 +} __no_const;
17417
17418 struct x86_io_apic_ops {
17419 void (*init) (void);
17420 unsigned int (*read) (unsigned int apic, unsigned int reg);
17421 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
17422 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
17423 -};
17424 +} __no_const;
17425
17426 extern struct x86_init_ops x86_init;
17427 extern struct x86_cpuinit_ops x86_cpuinit;
17428 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
17429 index 0415cda..b43d877 100644
17430 --- a/arch/x86/include/asm/xsave.h
17431 +++ b/arch/x86/include/asm/xsave.h
17432 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
17433 return -EFAULT;
17434
17435 __asm__ __volatile__(ASM_STAC "\n"
17436 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
17437 + "1:"
17438 + __copyuser_seg
17439 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
17440 "2: " ASM_CLAC "\n"
17441 ".section .fixup,\"ax\"\n"
17442 "3: movl $-1,%[err]\n"
17443 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
17444 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
17445 {
17446 int err;
17447 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
17448 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
17449 u32 lmask = mask;
17450 u32 hmask = mask >> 32;
17451
17452 __asm__ __volatile__(ASM_STAC "\n"
17453 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
17454 + "1:"
17455 + __copyuser_seg
17456 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
17457 "2: " ASM_CLAC "\n"
17458 ".section .fixup,\"ax\"\n"
17459 "3: movl $-1,%[err]\n"
17460 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
17461 index bbae024..e1528f9 100644
17462 --- a/arch/x86/include/uapi/asm/e820.h
17463 +++ b/arch/x86/include/uapi/asm/e820.h
17464 @@ -63,7 +63,7 @@ struct e820map {
17465 #define ISA_START_ADDRESS 0xa0000
17466 #define ISA_END_ADDRESS 0x100000
17467
17468 -#define BIOS_BEGIN 0x000a0000
17469 +#define BIOS_BEGIN 0x000c0000
17470 #define BIOS_END 0x00100000
17471
17472 #define BIOS_ROM_BASE 0xffe00000
17473 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
17474 index 34e923a..0c6bb6e 100644
17475 --- a/arch/x86/kernel/Makefile
17476 +++ b/arch/x86/kernel/Makefile
17477 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
17478 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
17479 obj-$(CONFIG_IRQ_WORK) += irq_work.o
17480 obj-y += probe_roms.o
17481 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
17482 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
17483 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
17484 obj-y += syscall_$(BITS).o
17485 obj-$(CONFIG_X86_64) += vsyscall_64.o
17486 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
17487 index bacf4b0..4ede72e 100644
17488 --- a/arch/x86/kernel/acpi/boot.c
17489 +++ b/arch/x86/kernel/acpi/boot.c
17490 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
17491 * If your system is blacklisted here, but you find that acpi=force
17492 * works for you, please contact linux-acpi@vger.kernel.org
17493 */
17494 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
17495 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
17496 /*
17497 * Boxes that need ACPI disabled
17498 */
17499 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
17500 };
17501
17502 /* second table for DMI checks that should run after early-quirks */
17503 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
17504 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
17505 /*
17506 * HP laptops which use a DSDT reporting as HP/SB400/10000,
17507 * which includes some code which overrides all temperature
17508 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
17509 index d5e0d71..6533e08 100644
17510 --- a/arch/x86/kernel/acpi/sleep.c
17511 +++ b/arch/x86/kernel/acpi/sleep.c
17512 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
17513 #else /* CONFIG_64BIT */
17514 #ifdef CONFIG_SMP
17515 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
17516 +
17517 + pax_open_kernel();
17518 early_gdt_descr.address =
17519 (unsigned long)get_cpu_gdt_table(smp_processor_id());
17520 + pax_close_kernel();
17521 +
17522 initial_gs = per_cpu_offset(smp_processor_id());
17523 #endif
17524 initial_code = (unsigned long)wakeup_long64;
17525 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
17526 index 13ab720..95d5442 100644
17527 --- a/arch/x86/kernel/acpi/wakeup_32.S
17528 +++ b/arch/x86/kernel/acpi/wakeup_32.S
17529 @@ -30,13 +30,11 @@ wakeup_pmode_return:
17530 # and restore the stack ... but you need gdt for this to work
17531 movl saved_context_esp, %esp
17532
17533 - movl %cs:saved_magic, %eax
17534 - cmpl $0x12345678, %eax
17535 + cmpl $0x12345678, saved_magic
17536 jne bogus_magic
17537
17538 # jump to place where we left off
17539 - movl saved_eip, %eax
17540 - jmp *%eax
17541 + jmp *(saved_eip)
17542
17543 bogus_magic:
17544 jmp bogus_magic
17545 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
17546 index ef5ccca..bd83949 100644
17547 --- a/arch/x86/kernel/alternative.c
17548 +++ b/arch/x86/kernel/alternative.c
17549 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
17550 */
17551 for (a = start; a < end; a++) {
17552 instr = (u8 *)&a->instr_offset + a->instr_offset;
17553 +
17554 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
17555 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17556 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
17557 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17558 +#endif
17559 +
17560 replacement = (u8 *)&a->repl_offset + a->repl_offset;
17561 BUG_ON(a->replacementlen > a->instrlen);
17562 BUG_ON(a->instrlen > sizeof(insnbuf));
17563 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
17564 for (poff = start; poff < end; poff++) {
17565 u8 *ptr = (u8 *)poff + *poff;
17566
17567 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
17568 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17569 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
17570 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17571 +#endif
17572 +
17573 if (!*poff || ptr < text || ptr >= text_end)
17574 continue;
17575 /* turn DS segment override prefix into lock prefix */
17576 - if (*ptr == 0x3e)
17577 + if (*ktla_ktva(ptr) == 0x3e)
17578 text_poke(ptr, ((unsigned char []){0xf0}), 1);
17579 }
17580 mutex_unlock(&text_mutex);
17581 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
17582 for (poff = start; poff < end; poff++) {
17583 u8 *ptr = (u8 *)poff + *poff;
17584
17585 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
17586 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17587 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
17588 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17589 +#endif
17590 +
17591 if (!*poff || ptr < text || ptr >= text_end)
17592 continue;
17593 /* turn lock prefix into DS segment override prefix */
17594 - if (*ptr == 0xf0)
17595 + if (*ktla_ktva(ptr) == 0xf0)
17596 text_poke(ptr, ((unsigned char []){0x3E}), 1);
17597 }
17598 mutex_unlock(&text_mutex);
17599 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
17600
17601 BUG_ON(p->len > MAX_PATCH_LEN);
17602 /* prep the buffer with the original instructions */
17603 - memcpy(insnbuf, p->instr, p->len);
17604 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
17605 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
17606 (unsigned long)p->instr, p->len);
17607
17608 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
17609 if (!uniproc_patched || num_possible_cpus() == 1)
17610 free_init_pages("SMP alternatives",
17611 (unsigned long)__smp_locks,
17612 - (unsigned long)__smp_locks_end);
17613 + PAGE_ALIGN((unsigned long)__smp_locks_end));
17614 #endif
17615
17616 apply_paravirt(__parainstructions, __parainstructions_end);
17617 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
17618 * instructions. And on the local CPU you need to be protected again NMI or MCE
17619 * handlers seeing an inconsistent instruction while you patch.
17620 */
17621 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
17622 +void *__kprobes text_poke_early(void *addr, const void *opcode,
17623 size_t len)
17624 {
17625 unsigned long flags;
17626 local_irq_save(flags);
17627 - memcpy(addr, opcode, len);
17628 +
17629 + pax_open_kernel();
17630 + memcpy(ktla_ktva(addr), opcode, len);
17631 sync_core();
17632 + pax_close_kernel();
17633 +
17634 local_irq_restore(flags);
17635 /* Could also do a CLFLUSH here to speed up CPU recovery; but
17636 that causes hangs on some VIA CPUs. */
17637 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
17638 */
17639 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
17640 {
17641 - unsigned long flags;
17642 - char *vaddr;
17643 + unsigned char *vaddr = ktla_ktva(addr);
17644 struct page *pages[2];
17645 - int i;
17646 + size_t i;
17647
17648 if (!core_kernel_text((unsigned long)addr)) {
17649 - pages[0] = vmalloc_to_page(addr);
17650 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
17651 + pages[0] = vmalloc_to_page(vaddr);
17652 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
17653 } else {
17654 - pages[0] = virt_to_page(addr);
17655 + pages[0] = virt_to_page(vaddr);
17656 WARN_ON(!PageReserved(pages[0]));
17657 - pages[1] = virt_to_page(addr + PAGE_SIZE);
17658 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
17659 }
17660 BUG_ON(!pages[0]);
17661 - local_irq_save(flags);
17662 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
17663 - if (pages[1])
17664 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
17665 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
17666 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
17667 - clear_fixmap(FIX_TEXT_POKE0);
17668 - if (pages[1])
17669 - clear_fixmap(FIX_TEXT_POKE1);
17670 - local_flush_tlb();
17671 - sync_core();
17672 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
17673 - that causes hangs on some VIA CPUs. */
17674 + text_poke_early(addr, opcode, len);
17675 for (i = 0; i < len; i++)
17676 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
17677 - local_irq_restore(flags);
17678 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
17679 return addr;
17680 }
17681
17682 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
17683 index cbf5121..812b537 100644
17684 --- a/arch/x86/kernel/apic/apic.c
17685 +++ b/arch/x86/kernel/apic/apic.c
17686 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
17687 /*
17688 * Debug level, exported for io_apic.c
17689 */
17690 -unsigned int apic_verbosity;
17691 +int apic_verbosity;
17692
17693 int pic_mode;
17694
17695 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
17696 apic_write(APIC_ESR, 0);
17697 v1 = apic_read(APIC_ESR);
17698 ack_APIC_irq();
17699 - atomic_inc(&irq_err_count);
17700 + atomic_inc_unchecked(&irq_err_count);
17701
17702 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
17703 smp_processor_id(), v0 , v1);
17704 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
17705 index 00c77cf..2dc6a2d 100644
17706 --- a/arch/x86/kernel/apic/apic_flat_64.c
17707 +++ b/arch/x86/kernel/apic/apic_flat_64.c
17708 @@ -157,7 +157,7 @@ static int flat_probe(void)
17709 return 1;
17710 }
17711
17712 -static struct apic apic_flat = {
17713 +static struct apic apic_flat __read_only = {
17714 .name = "flat",
17715 .probe = flat_probe,
17716 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
17717 @@ -271,7 +271,7 @@ static int physflat_probe(void)
17718 return 0;
17719 }
17720
17721 -static struct apic apic_physflat = {
17722 +static struct apic apic_physflat __read_only = {
17723
17724 .name = "physical flat",
17725 .probe = physflat_probe,
17726 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
17727 index e145f28..2752888 100644
17728 --- a/arch/x86/kernel/apic/apic_noop.c
17729 +++ b/arch/x86/kernel/apic/apic_noop.c
17730 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
17731 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
17732 }
17733
17734 -struct apic apic_noop = {
17735 +struct apic apic_noop __read_only = {
17736 .name = "noop",
17737 .probe = noop_probe,
17738 .acpi_madt_oem_check = NULL,
17739 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
17740 index d50e364..543bee3 100644
17741 --- a/arch/x86/kernel/apic/bigsmp_32.c
17742 +++ b/arch/x86/kernel/apic/bigsmp_32.c
17743 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
17744 return dmi_bigsmp;
17745 }
17746
17747 -static struct apic apic_bigsmp = {
17748 +static struct apic apic_bigsmp __read_only = {
17749
17750 .name = "bigsmp",
17751 .probe = probe_bigsmp,
17752 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
17753 index 0874799..a7a7892 100644
17754 --- a/arch/x86/kernel/apic/es7000_32.c
17755 +++ b/arch/x86/kernel/apic/es7000_32.c
17756 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
17757 return ret && es7000_apic_is_cluster();
17758 }
17759
17760 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
17761 -static struct apic __refdata apic_es7000_cluster = {
17762 +static struct apic apic_es7000_cluster __read_only = {
17763
17764 .name = "es7000",
17765 .probe = probe_es7000,
17766 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
17767 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
17768 };
17769
17770 -static struct apic __refdata apic_es7000 = {
17771 +static struct apic apic_es7000 __read_only = {
17772
17773 .name = "es7000",
17774 .probe = probe_es7000,
17775 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
17776 index b739d39..aebc14c 100644
17777 --- a/arch/x86/kernel/apic/io_apic.c
17778 +++ b/arch/x86/kernel/apic/io_apic.c
17779 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
17780 }
17781 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
17782
17783 -void lock_vector_lock(void)
17784 +void lock_vector_lock(void) __acquires(vector_lock)
17785 {
17786 /* Used to the online set of cpus does not change
17787 * during assign_irq_vector.
17788 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
17789 raw_spin_lock(&vector_lock);
17790 }
17791
17792 -void unlock_vector_lock(void)
17793 +void unlock_vector_lock(void) __releases(vector_lock)
17794 {
17795 raw_spin_unlock(&vector_lock);
17796 }
17797 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
17798 ack_APIC_irq();
17799 }
17800
17801 -atomic_t irq_mis_count;
17802 +atomic_unchecked_t irq_mis_count;
17803
17804 #ifdef CONFIG_GENERIC_PENDING_IRQ
17805 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
17806 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
17807 * at the cpu.
17808 */
17809 if (!(v & (1 << (i & 0x1f)))) {
17810 - atomic_inc(&irq_mis_count);
17811 + atomic_inc_unchecked(&irq_mis_count);
17812
17813 eoi_ioapic_irq(irq, cfg);
17814 }
17815 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
17816
17817 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
17818 {
17819 - chip->irq_print_chip = ir_print_prefix;
17820 - chip->irq_ack = ir_ack_apic_edge;
17821 - chip->irq_eoi = ir_ack_apic_level;
17822 + pax_open_kernel();
17823 + *(void **)&chip->irq_print_chip = ir_print_prefix;
17824 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
17825 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
17826
17827 - chip->irq_set_affinity = set_remapped_irq_affinity;
17828 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
17829 + pax_close_kernel();
17830 }
17831 #endif /* CONFIG_IRQ_REMAP */
17832
17833 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
17834 index d661ee9..791fd33 100644
17835 --- a/arch/x86/kernel/apic/numaq_32.c
17836 +++ b/arch/x86/kernel/apic/numaq_32.c
17837 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
17838 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
17839 }
17840
17841 -/* Use __refdata to keep false positive warning calm. */
17842 -static struct apic __refdata apic_numaq = {
17843 +static struct apic apic_numaq __read_only = {
17844
17845 .name = "NUMAQ",
17846 .probe = probe_numaq,
17847 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
17848 index eb35ef9..f184a21 100644
17849 --- a/arch/x86/kernel/apic/probe_32.c
17850 +++ b/arch/x86/kernel/apic/probe_32.c
17851 @@ -72,7 +72,7 @@ static int probe_default(void)
17852 return 1;
17853 }
17854
17855 -static struct apic apic_default = {
17856 +static struct apic apic_default __read_only = {
17857
17858 .name = "default",
17859 .probe = probe_default,
17860 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
17861 index 77c95c0..434f8a4 100644
17862 --- a/arch/x86/kernel/apic/summit_32.c
17863 +++ b/arch/x86/kernel/apic/summit_32.c
17864 @@ -486,7 +486,7 @@ void setup_summit(void)
17865 }
17866 #endif
17867
17868 -static struct apic apic_summit = {
17869 +static struct apic apic_summit __read_only = {
17870
17871 .name = "summit",
17872 .probe = probe_summit,
17873 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
17874 index c88baa4..757aee1 100644
17875 --- a/arch/x86/kernel/apic/x2apic_cluster.c
17876 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17877 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17878 return notifier_from_errno(err);
17879 }
17880
17881 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17882 +static struct notifier_block x2apic_cpu_notifier = {
17883 .notifier_call = update_clusterinfo,
17884 };
17885
17886 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17887 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17888 }
17889
17890 -static struct apic apic_x2apic_cluster = {
17891 +static struct apic apic_x2apic_cluster __read_only = {
17892
17893 .name = "cluster x2apic",
17894 .probe = x2apic_cluster_probe,
17895 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17896 index 562a76d..a003c0f 100644
17897 --- a/arch/x86/kernel/apic/x2apic_phys.c
17898 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17899 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17900 return apic == &apic_x2apic_phys;
17901 }
17902
17903 -static struct apic apic_x2apic_phys = {
17904 +static struct apic apic_x2apic_phys __read_only = {
17905
17906 .name = "physical x2apic",
17907 .probe = x2apic_phys_probe,
17908 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17909 index 8cfade9..b9d04fc 100644
17910 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17911 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17912 @@ -333,7 +333,7 @@ static int uv_probe(void)
17913 return apic == &apic_x2apic_uv_x;
17914 }
17915
17916 -static struct apic __refdata apic_x2apic_uv_x = {
17917 +static struct apic apic_x2apic_uv_x __read_only = {
17918
17919 .name = "UV large system",
17920 .probe = uv_probe,
17921 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17922 index d65464e..1035d31 100644
17923 --- a/arch/x86/kernel/apm_32.c
17924 +++ b/arch/x86/kernel/apm_32.c
17925 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
17926 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17927 * even though they are called in protected mode.
17928 */
17929 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17930 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17931 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17932
17933 static const char driver_version[] = "1.16ac"; /* no spaces */
17934 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
17935 BUG_ON(cpu != 0);
17936 gdt = get_cpu_gdt_table(cpu);
17937 save_desc_40 = gdt[0x40 / 8];
17938 +
17939 + pax_open_kernel();
17940 gdt[0x40 / 8] = bad_bios_desc;
17941 + pax_close_kernel();
17942
17943 apm_irq_save(flags);
17944 APM_DO_SAVE_SEGS;
17945 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
17946 &call->esi);
17947 APM_DO_RESTORE_SEGS;
17948 apm_irq_restore(flags);
17949 +
17950 + pax_open_kernel();
17951 gdt[0x40 / 8] = save_desc_40;
17952 + pax_close_kernel();
17953 +
17954 put_cpu();
17955
17956 return call->eax & 0xff;
17957 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
17958 BUG_ON(cpu != 0);
17959 gdt = get_cpu_gdt_table(cpu);
17960 save_desc_40 = gdt[0x40 / 8];
17961 +
17962 + pax_open_kernel();
17963 gdt[0x40 / 8] = bad_bios_desc;
17964 + pax_close_kernel();
17965
17966 apm_irq_save(flags);
17967 APM_DO_SAVE_SEGS;
17968 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
17969 &call->eax);
17970 APM_DO_RESTORE_SEGS;
17971 apm_irq_restore(flags);
17972 +
17973 + pax_open_kernel();
17974 gdt[0x40 / 8] = save_desc_40;
17975 + pax_close_kernel();
17976 +
17977 put_cpu();
17978 return error;
17979 }
17980 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
17981 * code to that CPU.
17982 */
17983 gdt = get_cpu_gdt_table(0);
17984 +
17985 + pax_open_kernel();
17986 set_desc_base(&gdt[APM_CS >> 3],
17987 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17988 set_desc_base(&gdt[APM_CS_16 >> 3],
17989 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17990 set_desc_base(&gdt[APM_DS >> 3],
17991 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17992 + pax_close_kernel();
17993
17994 proc_create("apm", 0, NULL, &apm_file_ops);
17995
17996 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17997 index 2861082..6d4718e 100644
17998 --- a/arch/x86/kernel/asm-offsets.c
17999 +++ b/arch/x86/kernel/asm-offsets.c
18000 @@ -33,6 +33,8 @@ void common(void) {
18001 OFFSET(TI_status, thread_info, status);
18002 OFFSET(TI_addr_limit, thread_info, addr_limit);
18003 OFFSET(TI_preempt_count, thread_info, preempt_count);
18004 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
18005 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
18006
18007 BLANK();
18008 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
18009 @@ -53,8 +55,26 @@ void common(void) {
18010 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
18011 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
18012 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
18013 +
18014 +#ifdef CONFIG_PAX_KERNEXEC
18015 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
18016 #endif
18017
18018 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18019 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
18020 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
18021 +#ifdef CONFIG_X86_64
18022 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
18023 +#endif
18024 +#endif
18025 +
18026 +#endif
18027 +
18028 + BLANK();
18029 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
18030 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
18031 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
18032 +
18033 #ifdef CONFIG_XEN
18034 BLANK();
18035 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
18036 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
18037 index 1b4754f..fbb4227 100644
18038 --- a/arch/x86/kernel/asm-offsets_64.c
18039 +++ b/arch/x86/kernel/asm-offsets_64.c
18040 @@ -76,6 +76,7 @@ int main(void)
18041 BLANK();
18042 #undef ENTRY
18043
18044 + DEFINE(TSS_size, sizeof(struct tss_struct));
18045 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
18046 BLANK();
18047
18048 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
18049 index a0e067d..9c7db16 100644
18050 --- a/arch/x86/kernel/cpu/Makefile
18051 +++ b/arch/x86/kernel/cpu/Makefile
18052 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
18053 CFLAGS_REMOVE_perf_event.o = -pg
18054 endif
18055
18056 -# Make sure load_percpu_segment has no stackprotector
18057 -nostackp := $(call cc-option, -fno-stack-protector)
18058 -CFLAGS_common.o := $(nostackp)
18059 -
18060 obj-y := intel_cacheinfo.o scattered.o topology.o
18061 obj-y += proc.o capflags.o powerflags.o common.o
18062 obj-y += vmware.o hypervisor.o mshyperv.o
18063 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
18064 index 15239ff..e23e04e 100644
18065 --- a/arch/x86/kernel/cpu/amd.c
18066 +++ b/arch/x86/kernel/cpu/amd.c
18067 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
18068 unsigned int size)
18069 {
18070 /* AMD errata T13 (order #21922) */
18071 - if ((c->x86 == 6)) {
18072 + if (c->x86 == 6) {
18073 /* Duron Rev A0 */
18074 if (c->x86_model == 3 && c->x86_mask == 0)
18075 size = 64;
18076 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
18077 index 9c3ab43..51e6366 100644
18078 --- a/arch/x86/kernel/cpu/common.c
18079 +++ b/arch/x86/kernel/cpu/common.c
18080 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
18081
18082 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
18083
18084 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
18085 -#ifdef CONFIG_X86_64
18086 - /*
18087 - * We need valid kernel segments for data and code in long mode too
18088 - * IRET will check the segment types kkeil 2000/10/28
18089 - * Also sysret mandates a special GDT layout
18090 - *
18091 - * TLS descriptors are currently at a different place compared to i386.
18092 - * Hopefully nobody expects them at a fixed place (Wine?)
18093 - */
18094 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
18095 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
18096 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
18097 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
18098 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
18099 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
18100 -#else
18101 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
18102 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
18103 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
18104 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
18105 - /*
18106 - * Segments used for calling PnP BIOS have byte granularity.
18107 - * They code segments and data segments have fixed 64k limits,
18108 - * the transfer segment sizes are set at run time.
18109 - */
18110 - /* 32-bit code */
18111 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
18112 - /* 16-bit code */
18113 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
18114 - /* 16-bit data */
18115 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
18116 - /* 16-bit data */
18117 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
18118 - /* 16-bit data */
18119 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
18120 - /*
18121 - * The APM segments have byte granularity and their bases
18122 - * are set at run time. All have 64k limits.
18123 - */
18124 - /* 32-bit code */
18125 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
18126 - /* 16-bit code */
18127 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
18128 - /* data */
18129 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
18130 -
18131 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
18132 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
18133 - GDT_STACK_CANARY_INIT
18134 -#endif
18135 -} };
18136 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
18137 -
18138 static int __init x86_xsave_setup(char *s)
18139 {
18140 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
18141 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
18142 {
18143 struct desc_ptr gdt_descr;
18144
18145 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
18146 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
18147 gdt_descr.size = GDT_SIZE - 1;
18148 load_gdt(&gdt_descr);
18149 /* Reload the per-cpu base */
18150 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
18151 /* Filter out anything that depends on CPUID levels we don't have */
18152 filter_cpuid_features(c, true);
18153
18154 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
18155 + setup_clear_cpu_cap(X86_FEATURE_SEP);
18156 +#endif
18157 +
18158 /* If the model name is still unset, do table lookup. */
18159 if (!c->x86_model_id[0]) {
18160 const char *p;
18161 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
18162 }
18163 __setup("clearcpuid=", setup_disablecpuid);
18164
18165 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
18166 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
18167 +
18168 #ifdef CONFIG_X86_64
18169 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
18170 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
18171 - (unsigned long) nmi_idt_table };
18172 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
18173
18174 DEFINE_PER_CPU_FIRST(union irq_stack_union,
18175 irq_stack_union) __aligned(PAGE_SIZE);
18176 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
18177 EXPORT_PER_CPU_SYMBOL(current_task);
18178
18179 DEFINE_PER_CPU(unsigned long, kernel_stack) =
18180 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
18181 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
18182 EXPORT_PER_CPU_SYMBOL(kernel_stack);
18183
18184 DEFINE_PER_CPU(char *, irq_stack_ptr) =
18185 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
18186 int i;
18187
18188 cpu = stack_smp_processor_id();
18189 - t = &per_cpu(init_tss, cpu);
18190 + t = init_tss + cpu;
18191 oist = &per_cpu(orig_ist, cpu);
18192
18193 #ifdef CONFIG_NUMA
18194 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
18195 switch_to_new_gdt(cpu);
18196 loadsegment(fs, 0);
18197
18198 - load_idt((const struct desc_ptr *)&idt_descr);
18199 + load_idt(&idt_descr);
18200
18201 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
18202 syscall_init();
18203 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
18204 wrmsrl(MSR_KERNEL_GS_BASE, 0);
18205 barrier();
18206
18207 - x86_configure_nx();
18208 enable_x2apic();
18209
18210 /*
18211 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
18212 {
18213 int cpu = smp_processor_id();
18214 struct task_struct *curr = current;
18215 - struct tss_struct *t = &per_cpu(init_tss, cpu);
18216 + struct tss_struct *t = init_tss + cpu;
18217 struct thread_struct *thread = &curr->thread;
18218
18219 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
18220 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
18221 index fcaabd0..7b55a26 100644
18222 --- a/arch/x86/kernel/cpu/intel.c
18223 +++ b/arch/x86/kernel/cpu/intel.c
18224 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
18225 * Update the IDT descriptor and reload the IDT so that
18226 * it uses the read-only mapped virtual address.
18227 */
18228 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
18229 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
18230 load_idt(&idt_descr);
18231 }
18232 #endif
18233 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
18234 index 84c1309..39b7224 100644
18235 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
18236 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
18237 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
18238 };
18239
18240 #ifdef CONFIG_AMD_NB
18241 +static struct attribute *default_attrs_amd_nb[] = {
18242 + &type.attr,
18243 + &level.attr,
18244 + &coherency_line_size.attr,
18245 + &physical_line_partition.attr,
18246 + &ways_of_associativity.attr,
18247 + &number_of_sets.attr,
18248 + &size.attr,
18249 + &shared_cpu_map.attr,
18250 + &shared_cpu_list.attr,
18251 + NULL,
18252 + NULL,
18253 + NULL,
18254 + NULL
18255 +};
18256 +
18257 static struct attribute ** __cpuinit amd_l3_attrs(void)
18258 {
18259 static struct attribute **attrs;
18260 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
18261
18262 n = ARRAY_SIZE(default_attrs);
18263
18264 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
18265 - n += 2;
18266 -
18267 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
18268 - n += 1;
18269 -
18270 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
18271 - if (attrs == NULL)
18272 - return attrs = default_attrs;
18273 -
18274 - for (n = 0; default_attrs[n]; n++)
18275 - attrs[n] = default_attrs[n];
18276 + attrs = default_attrs_amd_nb;
18277
18278 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
18279 attrs[n++] = &cache_disable_0.attr;
18280 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
18281 .default_attrs = default_attrs,
18282 };
18283
18284 +#ifdef CONFIG_AMD_NB
18285 +static struct kobj_type ktype_cache_amd_nb = {
18286 + .sysfs_ops = &sysfs_ops,
18287 + .default_attrs = default_attrs_amd_nb,
18288 +};
18289 +#endif
18290 +
18291 static struct kobj_type ktype_percpu_entry = {
18292 .sysfs_ops = &sysfs_ops,
18293 };
18294 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
18295 return retval;
18296 }
18297
18298 +#ifdef CONFIG_AMD_NB
18299 + amd_l3_attrs();
18300 +#endif
18301 +
18302 for (i = 0; i < num_cache_leaves; i++) {
18303 + struct kobj_type *ktype;
18304 +
18305 this_object = INDEX_KOBJECT_PTR(cpu, i);
18306 this_object->cpu = cpu;
18307 this_object->index = i;
18308
18309 this_leaf = CPUID4_INFO_IDX(cpu, i);
18310
18311 - ktype_cache.default_attrs = default_attrs;
18312 + ktype = &ktype_cache;
18313 #ifdef CONFIG_AMD_NB
18314 if (this_leaf->base.nb)
18315 - ktype_cache.default_attrs = amd_l3_attrs();
18316 + ktype = &ktype_cache_amd_nb;
18317 #endif
18318 retval = kobject_init_and_add(&(this_object->kobj),
18319 - &ktype_cache,
18320 + ktype,
18321 per_cpu(ici_cache_kobject, cpu),
18322 "index%1lu", i);
18323 if (unlikely(retval)) {
18324 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
18325 return NOTIFY_OK;
18326 }
18327
18328 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
18329 +static struct notifier_block cacheinfo_cpu_notifier = {
18330 .notifier_call = cacheinfo_cpu_callback,
18331 };
18332
18333 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
18334 index 80dbda8..be16652 100644
18335 --- a/arch/x86/kernel/cpu/mcheck/mce.c
18336 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
18337 @@ -45,6 +45,7 @@
18338 #include <asm/processor.h>
18339 #include <asm/mce.h>
18340 #include <asm/msr.h>
18341 +#include <asm/local.h>
18342
18343 #include "mce-internal.h"
18344
18345 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
18346 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
18347 m->cs, m->ip);
18348
18349 - if (m->cs == __KERNEL_CS)
18350 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
18351 print_symbol("{%s}", m->ip);
18352 pr_cont("\n");
18353 }
18354 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
18355
18356 #define PANIC_TIMEOUT 5 /* 5 seconds */
18357
18358 -static atomic_t mce_paniced;
18359 +static atomic_unchecked_t mce_paniced;
18360
18361 static int fake_panic;
18362 -static atomic_t mce_fake_paniced;
18363 +static atomic_unchecked_t mce_fake_paniced;
18364
18365 /* Panic in progress. Enable interrupts and wait for final IPI */
18366 static void wait_for_panic(void)
18367 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
18368 /*
18369 * Make sure only one CPU runs in machine check panic
18370 */
18371 - if (atomic_inc_return(&mce_paniced) > 1)
18372 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
18373 wait_for_panic();
18374 barrier();
18375
18376 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
18377 console_verbose();
18378 } else {
18379 /* Don't log too much for fake panic */
18380 - if (atomic_inc_return(&mce_fake_paniced) > 1)
18381 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
18382 return;
18383 }
18384 /* First print corrected ones that are still unlogged */
18385 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
18386 * might have been modified by someone else.
18387 */
18388 rmb();
18389 - if (atomic_read(&mce_paniced))
18390 + if (atomic_read_unchecked(&mce_paniced))
18391 wait_for_panic();
18392 if (!mca_cfg.monarch_timeout)
18393 goto out;
18394 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
18395 }
18396
18397 /* Call the installed machine check handler for this CPU setup. */
18398 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
18399 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
18400 unexpected_machine_check;
18401
18402 /*
18403 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
18404 return;
18405 }
18406
18407 + pax_open_kernel();
18408 machine_check_vector = do_machine_check;
18409 + pax_close_kernel();
18410
18411 __mcheck_cpu_init_generic();
18412 __mcheck_cpu_init_vendor(c);
18413 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
18414 */
18415
18416 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
18417 -static int mce_chrdev_open_count; /* #times opened */
18418 +static local_t mce_chrdev_open_count; /* #times opened */
18419 static int mce_chrdev_open_exclu; /* already open exclusive? */
18420
18421 static int mce_chrdev_open(struct inode *inode, struct file *file)
18422 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
18423 spin_lock(&mce_chrdev_state_lock);
18424
18425 if (mce_chrdev_open_exclu ||
18426 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
18427 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
18428 spin_unlock(&mce_chrdev_state_lock);
18429
18430 return -EBUSY;
18431 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
18432
18433 if (file->f_flags & O_EXCL)
18434 mce_chrdev_open_exclu = 1;
18435 - mce_chrdev_open_count++;
18436 + local_inc(&mce_chrdev_open_count);
18437
18438 spin_unlock(&mce_chrdev_state_lock);
18439
18440 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
18441 {
18442 spin_lock(&mce_chrdev_state_lock);
18443
18444 - mce_chrdev_open_count--;
18445 + local_dec(&mce_chrdev_open_count);
18446 mce_chrdev_open_exclu = 0;
18447
18448 spin_unlock(&mce_chrdev_state_lock);
18449 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
18450 return NOTIFY_OK;
18451 }
18452
18453 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
18454 +static struct notifier_block mce_cpu_notifier = {
18455 .notifier_call = mce_cpu_callback,
18456 };
18457
18458 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
18459
18460 for (i = 0; i < mca_cfg.banks; i++) {
18461 struct mce_bank *b = &mce_banks[i];
18462 - struct device_attribute *a = &b->attr;
18463 + device_attribute_no_const *a = &b->attr;
18464
18465 sysfs_attr_init(&a->attr);
18466 a->attr.name = b->attrname;
18467 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
18468 static void mce_reset(void)
18469 {
18470 cpu_missing = 0;
18471 - atomic_set(&mce_fake_paniced, 0);
18472 + atomic_set_unchecked(&mce_fake_paniced, 0);
18473 atomic_set(&mce_executing, 0);
18474 atomic_set(&mce_callin, 0);
18475 atomic_set(&global_nwo, 0);
18476 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
18477 index 2d5454c..51987eb 100644
18478 --- a/arch/x86/kernel/cpu/mcheck/p5.c
18479 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
18480 @@ -11,6 +11,7 @@
18481 #include <asm/processor.h>
18482 #include <asm/mce.h>
18483 #include <asm/msr.h>
18484 +#include <asm/pgtable.h>
18485
18486 /* By default disabled */
18487 int mce_p5_enabled __read_mostly;
18488 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
18489 if (!cpu_has(c, X86_FEATURE_MCE))
18490 return;
18491
18492 + pax_open_kernel();
18493 machine_check_vector = pentium_machine_check;
18494 + pax_close_kernel();
18495 /* Make sure the vector pointer is visible before we enable MCEs: */
18496 wmb();
18497
18498 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
18499 index 47a1870..8c019a7 100644
18500 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
18501 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
18502 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
18503 return notifier_from_errno(err);
18504 }
18505
18506 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
18507 +static struct notifier_block thermal_throttle_cpu_notifier =
18508 {
18509 .notifier_call = thermal_throttle_cpu_callback,
18510 };
18511 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
18512 index 2d7998f..17c9de1 100644
18513 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
18514 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
18515 @@ -10,6 +10,7 @@
18516 #include <asm/processor.h>
18517 #include <asm/mce.h>
18518 #include <asm/msr.h>
18519 +#include <asm/pgtable.h>
18520
18521 /* Machine check handler for WinChip C6: */
18522 static void winchip_machine_check(struct pt_regs *regs, long error_code)
18523 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
18524 {
18525 u32 lo, hi;
18526
18527 + pax_open_kernel();
18528 machine_check_vector = winchip_machine_check;
18529 + pax_close_kernel();
18530 /* Make sure the vector pointer is visible before we enable MCEs: */
18531 wmb();
18532
18533 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
18534 index 726bf96..81f0526 100644
18535 --- a/arch/x86/kernel/cpu/mtrr/main.c
18536 +++ b/arch/x86/kernel/cpu/mtrr/main.c
18537 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
18538 u64 size_or_mask, size_and_mask;
18539 static bool mtrr_aps_delayed_init;
18540
18541 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
18542 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
18543
18544 const struct mtrr_ops *mtrr_if;
18545
18546 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
18547 index df5e41f..816c719 100644
18548 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
18549 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
18550 @@ -25,7 +25,7 @@ struct mtrr_ops {
18551 int (*validate_add_page)(unsigned long base, unsigned long size,
18552 unsigned int type);
18553 int (*have_wrcomb)(void);
18554 -};
18555 +} __do_const;
18556
18557 extern int generic_get_free_region(unsigned long base, unsigned long size,
18558 int replace_reg);
18559 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
18560 index 6774c17..72c1b22 100644
18561 --- a/arch/x86/kernel/cpu/perf_event.c
18562 +++ b/arch/x86/kernel/cpu/perf_event.c
18563 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
18564 pr_info("no hardware sampling interrupt available.\n");
18565 }
18566
18567 -static struct attribute_group x86_pmu_format_group = {
18568 +static attribute_group_no_const x86_pmu_format_group = {
18569 .name = "format",
18570 .attrs = NULL,
18571 };
18572 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
18573 struct perf_pmu_events_attr {
18574 struct device_attribute attr;
18575 u64 id;
18576 -};
18577 +} __do_const;
18578
18579 /*
18580 * Remove all undefined events (x86_pmu.event_map(id) == 0)
18581 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
18582 NULL,
18583 };
18584
18585 -static struct attribute_group x86_pmu_events_group = {
18586 +static attribute_group_no_const x86_pmu_events_group = {
18587 .name = "events",
18588 .attrs = events_attr,
18589 };
18590 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
18591 if (idx > GDT_ENTRIES)
18592 return 0;
18593
18594 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
18595 + desc = get_cpu_gdt_table(smp_processor_id());
18596 }
18597
18598 return get_desc_base(desc + idx);
18599 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
18600 break;
18601
18602 perf_callchain_store(entry, frame.return_address);
18603 - fp = frame.next_frame;
18604 + fp = (const void __force_user *)frame.next_frame;
18605 }
18606 }
18607
18608 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
18609 index 70602f8..9d9edb7 100644
18610 --- a/arch/x86/kernel/cpu/perf_event_intel.c
18611 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
18612 @@ -1964,10 +1964,10 @@ __init int intel_pmu_init(void)
18613 * v2 and above have a perf capabilities MSR
18614 */
18615 if (version > 1) {
18616 - u64 capabilities;
18617 + u64 capabilities = x86_pmu.intel_cap.capabilities;
18618
18619 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
18620 - x86_pmu.intel_cap.capabilities = capabilities;
18621 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
18622 + x86_pmu.intel_cap.capabilities = capabilities;
18623 }
18624
18625 intel_ds_init();
18626 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18627 index b43200d..d235b3e 100644
18628 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18629 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18630 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
18631 static int __init uncore_type_init(struct intel_uncore_type *type)
18632 {
18633 struct intel_uncore_pmu *pmus;
18634 - struct attribute_group *events_group;
18635 + attribute_group_no_const *attr_group;
18636 struct attribute **attrs;
18637 int i, j;
18638
18639 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
18640 while (type->event_descs[i].attr.attr.name)
18641 i++;
18642
18643 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
18644 - sizeof(*events_group), GFP_KERNEL);
18645 - if (!events_group)
18646 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
18647 + sizeof(*attr_group), GFP_KERNEL);
18648 + if (!attr_group)
18649 goto fail;
18650
18651 - attrs = (struct attribute **)(events_group + 1);
18652 - events_group->name = "events";
18653 - events_group->attrs = attrs;
18654 + attrs = (struct attribute **)(attr_group + 1);
18655 + attr_group->name = "events";
18656 + attr_group->attrs = attrs;
18657
18658 for (j = 0; j < i; j++)
18659 attrs[j] = &type->event_descs[j].attr.attr;
18660
18661 - type->events_group = events_group;
18662 + type->events_group = attr_group;
18663 }
18664
18665 type->pmu_group = &uncore_pmu_attr_group;
18666 @@ -2826,7 +2826,7 @@ static int
18667 return NOTIFY_OK;
18668 }
18669
18670 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
18671 +static struct notifier_block uncore_cpu_nb = {
18672 .notifier_call = uncore_cpu_notifier,
18673 /*
18674 * to migrate uncore events, our notifier should be executed
18675 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18676 index e68a455..975a932 100644
18677 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18678 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18679 @@ -428,7 +428,7 @@ struct intel_uncore_box {
18680 struct uncore_event_desc {
18681 struct kobj_attribute attr;
18682 const char *config;
18683 -};
18684 +} __do_const;
18685
18686 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
18687 { \
18688 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
18689 index 60c7891..9e911d3 100644
18690 --- a/arch/x86/kernel/cpuid.c
18691 +++ b/arch/x86/kernel/cpuid.c
18692 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
18693 return notifier_from_errno(err);
18694 }
18695
18696 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
18697 +static struct notifier_block cpuid_class_cpu_notifier =
18698 {
18699 .notifier_call = cpuid_class_cpu_callback,
18700 };
18701 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
18702 index 74467fe..18793d5 100644
18703 --- a/arch/x86/kernel/crash.c
18704 +++ b/arch/x86/kernel/crash.c
18705 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
18706 {
18707 #ifdef CONFIG_X86_32
18708 struct pt_regs fixed_regs;
18709 -#endif
18710
18711 -#ifdef CONFIG_X86_32
18712 - if (!user_mode_vm(regs)) {
18713 + if (!user_mode(regs)) {
18714 crash_fixup_ss_esp(&fixed_regs, regs);
18715 regs = &fixed_regs;
18716 }
18717 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
18718 index 37250fe..bf2ec74 100644
18719 --- a/arch/x86/kernel/doublefault_32.c
18720 +++ b/arch/x86/kernel/doublefault_32.c
18721 @@ -11,7 +11,7 @@
18722
18723 #define DOUBLEFAULT_STACKSIZE (1024)
18724 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
18725 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
18726 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
18727
18728 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
18729
18730 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
18731 unsigned long gdt, tss;
18732
18733 store_gdt(&gdt_desc);
18734 - gdt = gdt_desc.address;
18735 + gdt = (unsigned long)gdt_desc.address;
18736
18737 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
18738
18739 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
18740 /* 0x2 bit is always set */
18741 .flags = X86_EFLAGS_SF | 0x2,
18742 .sp = STACK_START,
18743 - .es = __USER_DS,
18744 + .es = __KERNEL_DS,
18745 .cs = __KERNEL_CS,
18746 .ss = __KERNEL_DS,
18747 - .ds = __USER_DS,
18748 + .ds = __KERNEL_DS,
18749 .fs = __KERNEL_PERCPU,
18750
18751 .__cr3 = __pa_nodebug(swapper_pg_dir),
18752 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
18753 index ae42418b..787c16b 100644
18754 --- a/arch/x86/kernel/dumpstack.c
18755 +++ b/arch/x86/kernel/dumpstack.c
18756 @@ -2,6 +2,9 @@
18757 * Copyright (C) 1991, 1992 Linus Torvalds
18758 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
18759 */
18760 +#ifdef CONFIG_GRKERNSEC_HIDESYM
18761 +#define __INCLUDED_BY_HIDESYM 1
18762 +#endif
18763 #include <linux/kallsyms.h>
18764 #include <linux/kprobes.h>
18765 #include <linux/uaccess.h>
18766 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
18767 static void
18768 print_ftrace_graph_addr(unsigned long addr, void *data,
18769 const struct stacktrace_ops *ops,
18770 - struct thread_info *tinfo, int *graph)
18771 + struct task_struct *task, int *graph)
18772 {
18773 - struct task_struct *task;
18774 unsigned long ret_addr;
18775 int index;
18776
18777 if (addr != (unsigned long)return_to_handler)
18778 return;
18779
18780 - task = tinfo->task;
18781 index = task->curr_ret_stack;
18782
18783 if (!task->ret_stack || index < *graph)
18784 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18785 static inline void
18786 print_ftrace_graph_addr(unsigned long addr, void *data,
18787 const struct stacktrace_ops *ops,
18788 - struct thread_info *tinfo, int *graph)
18789 + struct task_struct *task, int *graph)
18790 { }
18791 #endif
18792
18793 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18794 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
18795 */
18796
18797 -static inline int valid_stack_ptr(struct thread_info *tinfo,
18798 - void *p, unsigned int size, void *end)
18799 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
18800 {
18801 - void *t = tinfo;
18802 if (end) {
18803 if (p < end && p >= (end-THREAD_SIZE))
18804 return 1;
18805 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
18806 }
18807
18808 unsigned long
18809 -print_context_stack(struct thread_info *tinfo,
18810 +print_context_stack(struct task_struct *task, void *stack_start,
18811 unsigned long *stack, unsigned long bp,
18812 const struct stacktrace_ops *ops, void *data,
18813 unsigned long *end, int *graph)
18814 {
18815 struct stack_frame *frame = (struct stack_frame *)bp;
18816
18817 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
18818 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
18819 unsigned long addr;
18820
18821 addr = *stack;
18822 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
18823 } else {
18824 ops->address(data, addr, 0);
18825 }
18826 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18827 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18828 }
18829 stack++;
18830 }
18831 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
18832 EXPORT_SYMBOL_GPL(print_context_stack);
18833
18834 unsigned long
18835 -print_context_stack_bp(struct thread_info *tinfo,
18836 +print_context_stack_bp(struct task_struct *task, void *stack_start,
18837 unsigned long *stack, unsigned long bp,
18838 const struct stacktrace_ops *ops, void *data,
18839 unsigned long *end, int *graph)
18840 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18841 struct stack_frame *frame = (struct stack_frame *)bp;
18842 unsigned long *ret_addr = &frame->return_address;
18843
18844 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
18845 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
18846 unsigned long addr = *ret_addr;
18847
18848 if (!__kernel_text_address(addr))
18849 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18850 ops->address(data, addr, 1);
18851 frame = frame->next_frame;
18852 ret_addr = &frame->return_address;
18853 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18854 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18855 }
18856
18857 return (unsigned long)frame;
18858 @@ -189,7 +188,7 @@ void dump_stack(void)
18859
18860 bp = stack_frame(current, NULL);
18861 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
18862 - current->pid, current->comm, print_tainted(),
18863 + task_pid_nr(current), current->comm, print_tainted(),
18864 init_utsname()->release,
18865 (int)strcspn(init_utsname()->version, " "),
18866 init_utsname()->version);
18867 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
18868 }
18869 EXPORT_SYMBOL_GPL(oops_begin);
18870
18871 +extern void gr_handle_kernel_exploit(void);
18872 +
18873 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18874 {
18875 if (regs && kexec_should_crash(current))
18876 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18877 panic("Fatal exception in interrupt");
18878 if (panic_on_oops)
18879 panic("Fatal exception");
18880 - do_exit(signr);
18881 +
18882 + gr_handle_kernel_exploit();
18883 +
18884 + do_group_exit(signr);
18885 }
18886
18887 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18888 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18889 print_modules();
18890 show_regs(regs);
18891 #ifdef CONFIG_X86_32
18892 - if (user_mode_vm(regs)) {
18893 + if (user_mode(regs)) {
18894 sp = regs->sp;
18895 ss = regs->ss & 0xffff;
18896 } else {
18897 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18898 unsigned long flags = oops_begin();
18899 int sig = SIGSEGV;
18900
18901 - if (!user_mode_vm(regs))
18902 + if (!user_mode(regs))
18903 report_bug(regs->ip, regs);
18904
18905 if (__die(str, regs, err))
18906 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18907 index 1038a41..db2c12b 100644
18908 --- a/arch/x86/kernel/dumpstack_32.c
18909 +++ b/arch/x86/kernel/dumpstack_32.c
18910 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18911 bp = stack_frame(task, regs);
18912
18913 for (;;) {
18914 - struct thread_info *context;
18915 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18916
18917 - context = (struct thread_info *)
18918 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18919 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18920 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18921
18922 - stack = (unsigned long *)context->previous_esp;
18923 - if (!stack)
18924 + if (stack_start == task_stack_page(task))
18925 break;
18926 + stack = *(unsigned long **)stack_start;
18927 if (ops->stack(data, "IRQ") < 0)
18928 break;
18929 touch_nmi_watchdog();
18930 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18931 {
18932 int i;
18933
18934 - __show_regs(regs, !user_mode_vm(regs));
18935 + __show_regs(regs, !user_mode(regs));
18936
18937 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18938 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18939 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18940 * When in-kernel, we also print out the stack and code at the
18941 * time of the fault..
18942 */
18943 - if (!user_mode_vm(regs)) {
18944 + if (!user_mode(regs)) {
18945 unsigned int code_prologue = code_bytes * 43 / 64;
18946 unsigned int code_len = code_bytes;
18947 unsigned char c;
18948 u8 *ip;
18949 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18950
18951 pr_emerg("Stack:\n");
18952 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18953
18954 pr_emerg("Code:");
18955
18956 - ip = (u8 *)regs->ip - code_prologue;
18957 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18958 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18959 /* try starting at IP */
18960 - ip = (u8 *)regs->ip;
18961 + ip = (u8 *)regs->ip + cs_base;
18962 code_len = code_len - code_prologue + 1;
18963 }
18964 for (i = 0; i < code_len; i++, ip++) {
18965 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18966 pr_cont(" Bad EIP value.");
18967 break;
18968 }
18969 - if (ip == (u8 *)regs->ip)
18970 + if (ip == (u8 *)regs->ip + cs_base)
18971 pr_cont(" <%02x>", c);
18972 else
18973 pr_cont(" %02x", c);
18974 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18975 {
18976 unsigned short ud2;
18977
18978 + ip = ktla_ktva(ip);
18979 if (ip < PAGE_OFFSET)
18980 return 0;
18981 if (probe_kernel_address((unsigned short *)ip, ud2))
18982 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18983
18984 return ud2 == 0x0b0f;
18985 }
18986 +
18987 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18988 +void pax_check_alloca(unsigned long size)
18989 +{
18990 + unsigned long sp = (unsigned long)&sp, stack_left;
18991 +
18992 + /* all kernel stacks are of the same size */
18993 + stack_left = sp & (THREAD_SIZE - 1);
18994 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18995 +}
18996 +EXPORT_SYMBOL(pax_check_alloca);
18997 +#endif
18998 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18999 index b653675..51cc8c0 100644
19000 --- a/arch/x86/kernel/dumpstack_64.c
19001 +++ b/arch/x86/kernel/dumpstack_64.c
19002 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19003 unsigned long *irq_stack_end =
19004 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
19005 unsigned used = 0;
19006 - struct thread_info *tinfo;
19007 int graph = 0;
19008 unsigned long dummy;
19009 + void *stack_start;
19010
19011 if (!task)
19012 task = current;
19013 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19014 * current stack address. If the stacks consist of nested
19015 * exceptions
19016 */
19017 - tinfo = task_thread_info(task);
19018 for (;;) {
19019 char *id;
19020 unsigned long *estack_end;
19021 +
19022 estack_end = in_exception_stack(cpu, (unsigned long)stack,
19023 &used, &id);
19024
19025 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19026 if (ops->stack(data, id) < 0)
19027 break;
19028
19029 - bp = ops->walk_stack(tinfo, stack, bp, ops,
19030 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
19031 data, estack_end, &graph);
19032 ops->stack(data, "<EOE>");
19033 /*
19034 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19035 * second-to-last pointer (index -2 to end) in the
19036 * exception stack:
19037 */
19038 + if ((u16)estack_end[-1] != __KERNEL_DS)
19039 + goto out;
19040 stack = (unsigned long *) estack_end[-2];
19041 continue;
19042 }
19043 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19044 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
19045 if (ops->stack(data, "IRQ") < 0)
19046 break;
19047 - bp = ops->walk_stack(tinfo, stack, bp,
19048 + bp = ops->walk_stack(task, irq_stack, stack, bp,
19049 ops, data, irq_stack_end, &graph);
19050 /*
19051 * We link to the next stack (which would be
19052 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19053 /*
19054 * This handles the process stack:
19055 */
19056 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
19057 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
19058 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
19059 +out:
19060 put_cpu();
19061 }
19062 EXPORT_SYMBOL(dump_trace);
19063 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
19064 {
19065 int i;
19066 unsigned long sp;
19067 - const int cpu = smp_processor_id();
19068 + const int cpu = raw_smp_processor_id();
19069 struct task_struct *cur = current;
19070
19071 sp = regs->sp;
19072 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
19073
19074 return ud2 == 0x0b0f;
19075 }
19076 +
19077 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19078 +void pax_check_alloca(unsigned long size)
19079 +{
19080 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
19081 + unsigned cpu, used;
19082 + char *id;
19083 +
19084 + /* check the process stack first */
19085 + stack_start = (unsigned long)task_stack_page(current);
19086 + stack_end = stack_start + THREAD_SIZE;
19087 + if (likely(stack_start <= sp && sp < stack_end)) {
19088 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
19089 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19090 + return;
19091 + }
19092 +
19093 + cpu = get_cpu();
19094 +
19095 + /* check the irq stacks */
19096 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
19097 + stack_start = stack_end - IRQ_STACK_SIZE;
19098 + if (stack_start <= sp && sp < stack_end) {
19099 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
19100 + put_cpu();
19101 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19102 + return;
19103 + }
19104 +
19105 + /* check the exception stacks */
19106 + used = 0;
19107 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
19108 + stack_start = stack_end - EXCEPTION_STKSZ;
19109 + if (stack_end && stack_start <= sp && sp < stack_end) {
19110 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
19111 + put_cpu();
19112 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19113 + return;
19114 + }
19115 +
19116 + put_cpu();
19117 +
19118 + /* unknown stack */
19119 + BUG();
19120 +}
19121 +EXPORT_SYMBOL(pax_check_alloca);
19122 +#endif
19123 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
19124 index 9b9f18b..9fcaa04 100644
19125 --- a/arch/x86/kernel/early_printk.c
19126 +++ b/arch/x86/kernel/early_printk.c
19127 @@ -7,6 +7,7 @@
19128 #include <linux/pci_regs.h>
19129 #include <linux/pci_ids.h>
19130 #include <linux/errno.h>
19131 +#include <linux/sched.h>
19132 #include <asm/io.h>
19133 #include <asm/processor.h>
19134 #include <asm/fcntl.h>
19135 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
19136 index 6ed91d9..6cc365b 100644
19137 --- a/arch/x86/kernel/entry_32.S
19138 +++ b/arch/x86/kernel/entry_32.S
19139 @@ -177,13 +177,153 @@
19140 /*CFI_REL_OFFSET gs, PT_GS*/
19141 .endm
19142 .macro SET_KERNEL_GS reg
19143 +
19144 +#ifdef CONFIG_CC_STACKPROTECTOR
19145 movl $(__KERNEL_STACK_CANARY), \reg
19146 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
19147 + movl $(__USER_DS), \reg
19148 +#else
19149 + xorl \reg, \reg
19150 +#endif
19151 +
19152 movl \reg, %gs
19153 .endm
19154
19155 #endif /* CONFIG_X86_32_LAZY_GS */
19156
19157 -.macro SAVE_ALL
19158 +.macro pax_enter_kernel
19159 +#ifdef CONFIG_PAX_KERNEXEC
19160 + call pax_enter_kernel
19161 +#endif
19162 +.endm
19163 +
19164 +.macro pax_exit_kernel
19165 +#ifdef CONFIG_PAX_KERNEXEC
19166 + call pax_exit_kernel
19167 +#endif
19168 +.endm
19169 +
19170 +#ifdef CONFIG_PAX_KERNEXEC
19171 +ENTRY(pax_enter_kernel)
19172 +#ifdef CONFIG_PARAVIRT
19173 + pushl %eax
19174 + pushl %ecx
19175 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
19176 + mov %eax, %esi
19177 +#else
19178 + mov %cr0, %esi
19179 +#endif
19180 + bts $16, %esi
19181 + jnc 1f
19182 + mov %cs, %esi
19183 + cmp $__KERNEL_CS, %esi
19184 + jz 3f
19185 + ljmp $__KERNEL_CS, $3f
19186 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
19187 +2:
19188 +#ifdef CONFIG_PARAVIRT
19189 + mov %esi, %eax
19190 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
19191 +#else
19192 + mov %esi, %cr0
19193 +#endif
19194 +3:
19195 +#ifdef CONFIG_PARAVIRT
19196 + popl %ecx
19197 + popl %eax
19198 +#endif
19199 + ret
19200 +ENDPROC(pax_enter_kernel)
19201 +
19202 +ENTRY(pax_exit_kernel)
19203 +#ifdef CONFIG_PARAVIRT
19204 + pushl %eax
19205 + pushl %ecx
19206 +#endif
19207 + mov %cs, %esi
19208 + cmp $__KERNEXEC_KERNEL_CS, %esi
19209 + jnz 2f
19210 +#ifdef CONFIG_PARAVIRT
19211 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
19212 + mov %eax, %esi
19213 +#else
19214 + mov %cr0, %esi
19215 +#endif
19216 + btr $16, %esi
19217 + ljmp $__KERNEL_CS, $1f
19218 +1:
19219 +#ifdef CONFIG_PARAVIRT
19220 + mov %esi, %eax
19221 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
19222 +#else
19223 + mov %esi, %cr0
19224 +#endif
19225 +2:
19226 +#ifdef CONFIG_PARAVIRT
19227 + popl %ecx
19228 + popl %eax
19229 +#endif
19230 + ret
19231 +ENDPROC(pax_exit_kernel)
19232 +#endif
19233 +
19234 +.macro pax_erase_kstack
19235 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19236 + call pax_erase_kstack
19237 +#endif
19238 +.endm
19239 +
19240 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19241 +/*
19242 + * ebp: thread_info
19243 + */
19244 +ENTRY(pax_erase_kstack)
19245 + pushl %edi
19246 + pushl %ecx
19247 + pushl %eax
19248 +
19249 + mov TI_lowest_stack(%ebp), %edi
19250 + mov $-0xBEEF, %eax
19251 + std
19252 +
19253 +1: mov %edi, %ecx
19254 + and $THREAD_SIZE_asm - 1, %ecx
19255 + shr $2, %ecx
19256 + repne scasl
19257 + jecxz 2f
19258 +
19259 + cmp $2*16, %ecx
19260 + jc 2f
19261 +
19262 + mov $2*16, %ecx
19263 + repe scasl
19264 + jecxz 2f
19265 + jne 1b
19266 +
19267 +2: cld
19268 + mov %esp, %ecx
19269 + sub %edi, %ecx
19270 +
19271 + cmp $THREAD_SIZE_asm, %ecx
19272 + jb 3f
19273 + ud2
19274 +3:
19275 +
19276 + shr $2, %ecx
19277 + rep stosl
19278 +
19279 + mov TI_task_thread_sp0(%ebp), %edi
19280 + sub $128, %edi
19281 + mov %edi, TI_lowest_stack(%ebp)
19282 +
19283 + popl %eax
19284 + popl %ecx
19285 + popl %edi
19286 + ret
19287 +ENDPROC(pax_erase_kstack)
19288 +#endif
19289 +
19290 +.macro __SAVE_ALL _DS
19291 cld
19292 PUSH_GS
19293 pushl_cfi %fs
19294 @@ -206,7 +346,7 @@
19295 CFI_REL_OFFSET ecx, 0
19296 pushl_cfi %ebx
19297 CFI_REL_OFFSET ebx, 0
19298 - movl $(__USER_DS), %edx
19299 + movl $\_DS, %edx
19300 movl %edx, %ds
19301 movl %edx, %es
19302 movl $(__KERNEL_PERCPU), %edx
19303 @@ -214,6 +354,15 @@
19304 SET_KERNEL_GS %edx
19305 .endm
19306
19307 +.macro SAVE_ALL
19308 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
19309 + __SAVE_ALL __KERNEL_DS
19310 + pax_enter_kernel
19311 +#else
19312 + __SAVE_ALL __USER_DS
19313 +#endif
19314 +.endm
19315 +
19316 .macro RESTORE_INT_REGS
19317 popl_cfi %ebx
19318 CFI_RESTORE ebx
19319 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
19320 popfl_cfi
19321 jmp syscall_exit
19322 CFI_ENDPROC
19323 -END(ret_from_fork)
19324 +ENDPROC(ret_from_fork)
19325
19326 ENTRY(ret_from_kernel_thread)
19327 CFI_STARTPROC
19328 @@ -344,7 +493,15 @@ ret_from_intr:
19329 andl $SEGMENT_RPL_MASK, %eax
19330 #endif
19331 cmpl $USER_RPL, %eax
19332 +
19333 +#ifdef CONFIG_PAX_KERNEXEC
19334 + jae resume_userspace
19335 +
19336 + pax_exit_kernel
19337 + jmp resume_kernel
19338 +#else
19339 jb resume_kernel # not returning to v8086 or userspace
19340 +#endif
19341
19342 ENTRY(resume_userspace)
19343 LOCKDEP_SYS_EXIT
19344 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
19345 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
19346 # int/exception return?
19347 jne work_pending
19348 - jmp restore_all
19349 -END(ret_from_exception)
19350 + jmp restore_all_pax
19351 +ENDPROC(ret_from_exception)
19352
19353 #ifdef CONFIG_PREEMPT
19354 ENTRY(resume_kernel)
19355 @@ -372,7 +529,7 @@ need_resched:
19356 jz restore_all
19357 call preempt_schedule_irq
19358 jmp need_resched
19359 -END(resume_kernel)
19360 +ENDPROC(resume_kernel)
19361 #endif
19362 CFI_ENDPROC
19363 /*
19364 @@ -406,30 +563,45 @@ sysenter_past_esp:
19365 /*CFI_REL_OFFSET cs, 0*/
19366 /*
19367 * Push current_thread_info()->sysenter_return to the stack.
19368 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
19369 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
19370 */
19371 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
19372 + pushl_cfi $0
19373 CFI_REL_OFFSET eip, 0
19374
19375 pushl_cfi %eax
19376 SAVE_ALL
19377 + GET_THREAD_INFO(%ebp)
19378 + movl TI_sysenter_return(%ebp),%ebp
19379 + movl %ebp,PT_EIP(%esp)
19380 ENABLE_INTERRUPTS(CLBR_NONE)
19381
19382 /*
19383 * Load the potential sixth argument from user stack.
19384 * Careful about security.
19385 */
19386 + movl PT_OLDESP(%esp),%ebp
19387 +
19388 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19389 + mov PT_OLDSS(%esp),%ds
19390 +1: movl %ds:(%ebp),%ebp
19391 + push %ss
19392 + pop %ds
19393 +#else
19394 cmpl $__PAGE_OFFSET-3,%ebp
19395 jae syscall_fault
19396 ASM_STAC
19397 1: movl (%ebp),%ebp
19398 ASM_CLAC
19399 +#endif
19400 +
19401 movl %ebp,PT_EBP(%esp)
19402 _ASM_EXTABLE(1b,syscall_fault)
19403
19404 GET_THREAD_INFO(%ebp)
19405
19406 +#ifdef CONFIG_PAX_RANDKSTACK
19407 + pax_erase_kstack
19408 +#endif
19409 +
19410 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
19411 jnz sysenter_audit
19412 sysenter_do_call:
19413 @@ -444,12 +616,24 @@ sysenter_do_call:
19414 testl $_TIF_ALLWORK_MASK, %ecx
19415 jne sysexit_audit
19416 sysenter_exit:
19417 +
19418 +#ifdef CONFIG_PAX_RANDKSTACK
19419 + pushl_cfi %eax
19420 + movl %esp, %eax
19421 + call pax_randomize_kstack
19422 + popl_cfi %eax
19423 +#endif
19424 +
19425 + pax_erase_kstack
19426 +
19427 /* if something modifies registers it must also disable sysexit */
19428 movl PT_EIP(%esp), %edx
19429 movl PT_OLDESP(%esp), %ecx
19430 xorl %ebp,%ebp
19431 TRACE_IRQS_ON
19432 1: mov PT_FS(%esp), %fs
19433 +2: mov PT_DS(%esp), %ds
19434 +3: mov PT_ES(%esp), %es
19435 PTGS_TO_GS
19436 ENABLE_INTERRUPTS_SYSEXIT
19437
19438 @@ -466,6 +650,9 @@ sysenter_audit:
19439 movl %eax,%edx /* 2nd arg: syscall number */
19440 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
19441 call __audit_syscall_entry
19442 +
19443 + pax_erase_kstack
19444 +
19445 pushl_cfi %ebx
19446 movl PT_EAX(%esp),%eax /* reload syscall number */
19447 jmp sysenter_do_call
19448 @@ -491,10 +678,16 @@ sysexit_audit:
19449
19450 CFI_ENDPROC
19451 .pushsection .fixup,"ax"
19452 -2: movl $0,PT_FS(%esp)
19453 +4: movl $0,PT_FS(%esp)
19454 + jmp 1b
19455 +5: movl $0,PT_DS(%esp)
19456 + jmp 1b
19457 +6: movl $0,PT_ES(%esp)
19458 jmp 1b
19459 .popsection
19460 - _ASM_EXTABLE(1b,2b)
19461 + _ASM_EXTABLE(1b,4b)
19462 + _ASM_EXTABLE(2b,5b)
19463 + _ASM_EXTABLE(3b,6b)
19464 PTGS_TO_GS_EX
19465 ENDPROC(ia32_sysenter_target)
19466
19467 @@ -509,6 +702,11 @@ ENTRY(system_call)
19468 pushl_cfi %eax # save orig_eax
19469 SAVE_ALL
19470 GET_THREAD_INFO(%ebp)
19471 +
19472 +#ifdef CONFIG_PAX_RANDKSTACK
19473 + pax_erase_kstack
19474 +#endif
19475 +
19476 # system call tracing in operation / emulation
19477 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
19478 jnz syscall_trace_entry
19479 @@ -527,6 +725,15 @@ syscall_exit:
19480 testl $_TIF_ALLWORK_MASK, %ecx # current->work
19481 jne syscall_exit_work
19482
19483 +restore_all_pax:
19484 +
19485 +#ifdef CONFIG_PAX_RANDKSTACK
19486 + movl %esp, %eax
19487 + call pax_randomize_kstack
19488 +#endif
19489 +
19490 + pax_erase_kstack
19491 +
19492 restore_all:
19493 TRACE_IRQS_IRET
19494 restore_all_notrace:
19495 @@ -583,14 +790,34 @@ ldt_ss:
19496 * compensating for the offset by changing to the ESPFIX segment with
19497 * a base address that matches for the difference.
19498 */
19499 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
19500 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
19501 mov %esp, %edx /* load kernel esp */
19502 mov PT_OLDESP(%esp), %eax /* load userspace esp */
19503 mov %dx, %ax /* eax: new kernel esp */
19504 sub %eax, %edx /* offset (low word is 0) */
19505 +#ifdef CONFIG_SMP
19506 + movl PER_CPU_VAR(cpu_number), %ebx
19507 + shll $PAGE_SHIFT_asm, %ebx
19508 + addl $cpu_gdt_table, %ebx
19509 +#else
19510 + movl $cpu_gdt_table, %ebx
19511 +#endif
19512 shr $16, %edx
19513 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
19514 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
19515 +
19516 +#ifdef CONFIG_PAX_KERNEXEC
19517 + mov %cr0, %esi
19518 + btr $16, %esi
19519 + mov %esi, %cr0
19520 +#endif
19521 +
19522 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
19523 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
19524 +
19525 +#ifdef CONFIG_PAX_KERNEXEC
19526 + bts $16, %esi
19527 + mov %esi, %cr0
19528 +#endif
19529 +
19530 pushl_cfi $__ESPFIX_SS
19531 pushl_cfi %eax /* new kernel esp */
19532 /* Disable interrupts, but do not irqtrace this section: we
19533 @@ -619,20 +846,18 @@ work_resched:
19534 movl TI_flags(%ebp), %ecx
19535 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
19536 # than syscall tracing?
19537 - jz restore_all
19538 + jz restore_all_pax
19539 testb $_TIF_NEED_RESCHED, %cl
19540 jnz work_resched
19541
19542 work_notifysig: # deal with pending signals and
19543 # notify-resume requests
19544 + movl %esp, %eax
19545 #ifdef CONFIG_VM86
19546 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
19547 - movl %esp, %eax
19548 jne work_notifysig_v86 # returning to kernel-space or
19549 # vm86-space
19550 1:
19551 -#else
19552 - movl %esp, %eax
19553 #endif
19554 TRACE_IRQS_ON
19555 ENABLE_INTERRUPTS(CLBR_NONE)
19556 @@ -653,7 +878,7 @@ work_notifysig_v86:
19557 movl %eax, %esp
19558 jmp 1b
19559 #endif
19560 -END(work_pending)
19561 +ENDPROC(work_pending)
19562
19563 # perform syscall exit tracing
19564 ALIGN
19565 @@ -661,11 +886,14 @@ syscall_trace_entry:
19566 movl $-ENOSYS,PT_EAX(%esp)
19567 movl %esp, %eax
19568 call syscall_trace_enter
19569 +
19570 + pax_erase_kstack
19571 +
19572 /* What it returned is what we'll actually use. */
19573 cmpl $(NR_syscalls), %eax
19574 jnae syscall_call
19575 jmp syscall_exit
19576 -END(syscall_trace_entry)
19577 +ENDPROC(syscall_trace_entry)
19578
19579 # perform syscall exit tracing
19580 ALIGN
19581 @@ -678,21 +906,25 @@ syscall_exit_work:
19582 movl %esp, %eax
19583 call syscall_trace_leave
19584 jmp resume_userspace
19585 -END(syscall_exit_work)
19586 +ENDPROC(syscall_exit_work)
19587 CFI_ENDPROC
19588
19589 RING0_INT_FRAME # can't unwind into user space anyway
19590 syscall_fault:
19591 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19592 + push %ss
19593 + pop %ds
19594 +#endif
19595 ASM_CLAC
19596 GET_THREAD_INFO(%ebp)
19597 movl $-EFAULT,PT_EAX(%esp)
19598 jmp resume_userspace
19599 -END(syscall_fault)
19600 +ENDPROC(syscall_fault)
19601
19602 syscall_badsys:
19603 movl $-ENOSYS,PT_EAX(%esp)
19604 jmp resume_userspace
19605 -END(syscall_badsys)
19606 +ENDPROC(syscall_badsys)
19607 CFI_ENDPROC
19608 /*
19609 * End of kprobes section
19610 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
19611 * normal stack and adjusts ESP with the matching offset.
19612 */
19613 /* fixup the stack */
19614 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
19615 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
19616 +#ifdef CONFIG_SMP
19617 + movl PER_CPU_VAR(cpu_number), %ebx
19618 + shll $PAGE_SHIFT_asm, %ebx
19619 + addl $cpu_gdt_table, %ebx
19620 +#else
19621 + movl $cpu_gdt_table, %ebx
19622 +#endif
19623 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
19624 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
19625 shl $16, %eax
19626 addl %esp, %eax /* the adjusted stack pointer */
19627 pushl_cfi $__KERNEL_DS
19628 @@ -807,7 +1046,7 @@ vector=vector+1
19629 .endr
19630 2: jmp common_interrupt
19631 .endr
19632 -END(irq_entries_start)
19633 +ENDPROC(irq_entries_start)
19634
19635 .previous
19636 END(interrupt)
19637 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
19638 pushl_cfi $do_coprocessor_error
19639 jmp error_code
19640 CFI_ENDPROC
19641 -END(coprocessor_error)
19642 +ENDPROC(coprocessor_error)
19643
19644 ENTRY(simd_coprocessor_error)
19645 RING0_INT_FRAME
19646 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
19647 #endif
19648 jmp error_code
19649 CFI_ENDPROC
19650 -END(simd_coprocessor_error)
19651 +ENDPROC(simd_coprocessor_error)
19652
19653 ENTRY(device_not_available)
19654 RING0_INT_FRAME
19655 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
19656 pushl_cfi $do_device_not_available
19657 jmp error_code
19658 CFI_ENDPROC
19659 -END(device_not_available)
19660 +ENDPROC(device_not_available)
19661
19662 #ifdef CONFIG_PARAVIRT
19663 ENTRY(native_iret)
19664 iret
19665 _ASM_EXTABLE(native_iret, iret_exc)
19666 -END(native_iret)
19667 +ENDPROC(native_iret)
19668
19669 ENTRY(native_irq_enable_sysexit)
19670 sti
19671 sysexit
19672 -END(native_irq_enable_sysexit)
19673 +ENDPROC(native_irq_enable_sysexit)
19674 #endif
19675
19676 ENTRY(overflow)
19677 @@ -910,7 +1149,7 @@ ENTRY(overflow)
19678 pushl_cfi $do_overflow
19679 jmp error_code
19680 CFI_ENDPROC
19681 -END(overflow)
19682 +ENDPROC(overflow)
19683
19684 ENTRY(bounds)
19685 RING0_INT_FRAME
19686 @@ -919,7 +1158,7 @@ ENTRY(bounds)
19687 pushl_cfi $do_bounds
19688 jmp error_code
19689 CFI_ENDPROC
19690 -END(bounds)
19691 +ENDPROC(bounds)
19692
19693 ENTRY(invalid_op)
19694 RING0_INT_FRAME
19695 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
19696 pushl_cfi $do_invalid_op
19697 jmp error_code
19698 CFI_ENDPROC
19699 -END(invalid_op)
19700 +ENDPROC(invalid_op)
19701
19702 ENTRY(coprocessor_segment_overrun)
19703 RING0_INT_FRAME
19704 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
19705 pushl_cfi $do_coprocessor_segment_overrun
19706 jmp error_code
19707 CFI_ENDPROC
19708 -END(coprocessor_segment_overrun)
19709 +ENDPROC(coprocessor_segment_overrun)
19710
19711 ENTRY(invalid_TSS)
19712 RING0_EC_FRAME
19713 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
19714 pushl_cfi $do_invalid_TSS
19715 jmp error_code
19716 CFI_ENDPROC
19717 -END(invalid_TSS)
19718 +ENDPROC(invalid_TSS)
19719
19720 ENTRY(segment_not_present)
19721 RING0_EC_FRAME
19722 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
19723 pushl_cfi $do_segment_not_present
19724 jmp error_code
19725 CFI_ENDPROC
19726 -END(segment_not_present)
19727 +ENDPROC(segment_not_present)
19728
19729 ENTRY(stack_segment)
19730 RING0_EC_FRAME
19731 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
19732 pushl_cfi $do_stack_segment
19733 jmp error_code
19734 CFI_ENDPROC
19735 -END(stack_segment)
19736 +ENDPROC(stack_segment)
19737
19738 ENTRY(alignment_check)
19739 RING0_EC_FRAME
19740 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
19741 pushl_cfi $do_alignment_check
19742 jmp error_code
19743 CFI_ENDPROC
19744 -END(alignment_check)
19745 +ENDPROC(alignment_check)
19746
19747 ENTRY(divide_error)
19748 RING0_INT_FRAME
19749 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
19750 pushl_cfi $do_divide_error
19751 jmp error_code
19752 CFI_ENDPROC
19753 -END(divide_error)
19754 +ENDPROC(divide_error)
19755
19756 #ifdef CONFIG_X86_MCE
19757 ENTRY(machine_check)
19758 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
19759 pushl_cfi machine_check_vector
19760 jmp error_code
19761 CFI_ENDPROC
19762 -END(machine_check)
19763 +ENDPROC(machine_check)
19764 #endif
19765
19766 ENTRY(spurious_interrupt_bug)
19767 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
19768 pushl_cfi $do_spurious_interrupt_bug
19769 jmp error_code
19770 CFI_ENDPROC
19771 -END(spurious_interrupt_bug)
19772 +ENDPROC(spurious_interrupt_bug)
19773 /*
19774 * End of kprobes section
19775 */
19776 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
19777
19778 ENTRY(mcount)
19779 ret
19780 -END(mcount)
19781 +ENDPROC(mcount)
19782
19783 ENTRY(ftrace_caller)
19784 cmpl $0, function_trace_stop
19785 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
19786 .globl ftrace_stub
19787 ftrace_stub:
19788 ret
19789 -END(ftrace_caller)
19790 +ENDPROC(ftrace_caller)
19791
19792 ENTRY(ftrace_regs_caller)
19793 pushf /* push flags before compare (in cs location) */
19794 @@ -1235,7 +1474,7 @@ trace:
19795 popl %ecx
19796 popl %eax
19797 jmp ftrace_stub
19798 -END(mcount)
19799 +ENDPROC(mcount)
19800 #endif /* CONFIG_DYNAMIC_FTRACE */
19801 #endif /* CONFIG_FUNCTION_TRACER */
19802
19803 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
19804 popl %ecx
19805 popl %eax
19806 ret
19807 -END(ftrace_graph_caller)
19808 +ENDPROC(ftrace_graph_caller)
19809
19810 .globl return_to_handler
19811 return_to_handler:
19812 @@ -1309,15 +1548,18 @@ error_code:
19813 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
19814 REG_TO_PTGS %ecx
19815 SET_KERNEL_GS %ecx
19816 - movl $(__USER_DS), %ecx
19817 + movl $(__KERNEL_DS), %ecx
19818 movl %ecx, %ds
19819 movl %ecx, %es
19820 +
19821 + pax_enter_kernel
19822 +
19823 TRACE_IRQS_OFF
19824 movl %esp,%eax # pt_regs pointer
19825 call *%edi
19826 jmp ret_from_exception
19827 CFI_ENDPROC
19828 -END(page_fault)
19829 +ENDPROC(page_fault)
19830
19831 /*
19832 * Debug traps and NMI can happen at the one SYSENTER instruction
19833 @@ -1360,7 +1602,7 @@ debug_stack_correct:
19834 call do_debug
19835 jmp ret_from_exception
19836 CFI_ENDPROC
19837 -END(debug)
19838 +ENDPROC(debug)
19839
19840 /*
19841 * NMI is doubly nasty. It can happen _while_ we're handling
19842 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
19843 xorl %edx,%edx # zero error code
19844 movl %esp,%eax # pt_regs pointer
19845 call do_nmi
19846 +
19847 + pax_exit_kernel
19848 +
19849 jmp restore_all_notrace
19850 CFI_ENDPROC
19851
19852 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
19853 FIXUP_ESPFIX_STACK # %eax == %esp
19854 xorl %edx,%edx # zero error code
19855 call do_nmi
19856 +
19857 + pax_exit_kernel
19858 +
19859 RESTORE_REGS
19860 lss 12+4(%esp), %esp # back to espfix stack
19861 CFI_ADJUST_CFA_OFFSET -24
19862 jmp irq_return
19863 CFI_ENDPROC
19864 -END(nmi)
19865 +ENDPROC(nmi)
19866
19867 ENTRY(int3)
19868 RING0_INT_FRAME
19869 @@ -1452,14 +1700,14 @@ ENTRY(int3)
19870 call do_int3
19871 jmp ret_from_exception
19872 CFI_ENDPROC
19873 -END(int3)
19874 +ENDPROC(int3)
19875
19876 ENTRY(general_protection)
19877 RING0_EC_FRAME
19878 pushl_cfi $do_general_protection
19879 jmp error_code
19880 CFI_ENDPROC
19881 -END(general_protection)
19882 +ENDPROC(general_protection)
19883
19884 #ifdef CONFIG_KVM_GUEST
19885 ENTRY(async_page_fault)
19886 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
19887 pushl_cfi $do_async_page_fault
19888 jmp error_code
19889 CFI_ENDPROC
19890 -END(async_page_fault)
19891 +ENDPROC(async_page_fault)
19892 #endif
19893
19894 /*
19895 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19896 index cb3c591..7ba137c 100644
19897 --- a/arch/x86/kernel/entry_64.S
19898 +++ b/arch/x86/kernel/entry_64.S
19899 @@ -59,6 +59,8 @@
19900 #include <asm/context_tracking.h>
19901 #include <asm/smap.h>
19902 #include <linux/err.h>
19903 +#include <asm/pgtable.h>
19904 +#include <asm/alternative-asm.h>
19905
19906 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19907 #include <linux/elf-em.h>
19908 @@ -80,8 +82,9 @@
19909 #ifdef CONFIG_DYNAMIC_FTRACE
19910
19911 ENTRY(function_hook)
19912 + pax_force_retaddr
19913 retq
19914 -END(function_hook)
19915 +ENDPROC(function_hook)
19916
19917 /* skip is set if stack has been adjusted */
19918 .macro ftrace_caller_setup skip=0
19919 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19920 #endif
19921
19922 GLOBAL(ftrace_stub)
19923 + pax_force_retaddr
19924 retq
19925 -END(ftrace_caller)
19926 +ENDPROC(ftrace_caller)
19927
19928 ENTRY(ftrace_regs_caller)
19929 /* Save the current flags before compare (in SS location)*/
19930 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19931 popfq
19932 jmp ftrace_stub
19933
19934 -END(ftrace_regs_caller)
19935 +ENDPROC(ftrace_regs_caller)
19936
19937
19938 #else /* ! CONFIG_DYNAMIC_FTRACE */
19939 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19940 #endif
19941
19942 GLOBAL(ftrace_stub)
19943 + pax_force_retaddr
19944 retq
19945
19946 trace:
19947 @@ -225,12 +230,13 @@ trace:
19948 #endif
19949 subq $MCOUNT_INSN_SIZE, %rdi
19950
19951 + pax_force_fptr ftrace_trace_function
19952 call *ftrace_trace_function
19953
19954 MCOUNT_RESTORE_FRAME
19955
19956 jmp ftrace_stub
19957 -END(function_hook)
19958 +ENDPROC(function_hook)
19959 #endif /* CONFIG_DYNAMIC_FTRACE */
19960 #endif /* CONFIG_FUNCTION_TRACER */
19961
19962 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19963
19964 MCOUNT_RESTORE_FRAME
19965
19966 + pax_force_retaddr
19967 retq
19968 -END(ftrace_graph_caller)
19969 +ENDPROC(ftrace_graph_caller)
19970
19971 GLOBAL(return_to_handler)
19972 subq $24, %rsp
19973 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19974 movq 8(%rsp), %rdx
19975 movq (%rsp), %rax
19976 addq $24, %rsp
19977 + pax_force_fptr %rdi
19978 jmp *%rdi
19979 +ENDPROC(return_to_handler)
19980 #endif
19981
19982
19983 @@ -284,6 +293,273 @@ ENTRY(native_usergs_sysret64)
19984 ENDPROC(native_usergs_sysret64)
19985 #endif /* CONFIG_PARAVIRT */
19986
19987 + .macro ljmpq sel, off
19988 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19989 + .byte 0x48; ljmp *1234f(%rip)
19990 + .pushsection .rodata
19991 + .align 16
19992 + 1234: .quad \off; .word \sel
19993 + .popsection
19994 +#else
19995 + pushq $\sel
19996 + pushq $\off
19997 + lretq
19998 +#endif
19999 + .endm
20000 +
20001 + .macro pax_enter_kernel
20002 + pax_set_fptr_mask
20003 +#ifdef CONFIG_PAX_KERNEXEC
20004 + call pax_enter_kernel
20005 +#endif
20006 + .endm
20007 +
20008 + .macro pax_exit_kernel
20009 +#ifdef CONFIG_PAX_KERNEXEC
20010 + call pax_exit_kernel
20011 +#endif
20012 + .endm
20013 +
20014 +#ifdef CONFIG_PAX_KERNEXEC
20015 +ENTRY(pax_enter_kernel)
20016 + pushq %rdi
20017 +
20018 +#ifdef CONFIG_PARAVIRT
20019 + PV_SAVE_REGS(CLBR_RDI)
20020 +#endif
20021 +
20022 + GET_CR0_INTO_RDI
20023 + bts $16,%rdi
20024 + jnc 3f
20025 + mov %cs,%edi
20026 + cmp $__KERNEL_CS,%edi
20027 + jnz 2f
20028 +1:
20029 +
20030 +#ifdef CONFIG_PARAVIRT
20031 + PV_RESTORE_REGS(CLBR_RDI)
20032 +#endif
20033 +
20034 + popq %rdi
20035 + pax_force_retaddr
20036 + retq
20037 +
20038 +2: ljmpq __KERNEL_CS,1b
20039 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
20040 +4: SET_RDI_INTO_CR0
20041 + jmp 1b
20042 +ENDPROC(pax_enter_kernel)
20043 +
20044 +ENTRY(pax_exit_kernel)
20045 + pushq %rdi
20046 +
20047 +#ifdef CONFIG_PARAVIRT
20048 + PV_SAVE_REGS(CLBR_RDI)
20049 +#endif
20050 +
20051 + mov %cs,%rdi
20052 + cmp $__KERNEXEC_KERNEL_CS,%edi
20053 + jz 2f
20054 +1:
20055 +
20056 +#ifdef CONFIG_PARAVIRT
20057 + PV_RESTORE_REGS(CLBR_RDI);
20058 +#endif
20059 +
20060 + popq %rdi
20061 + pax_force_retaddr
20062 + retq
20063 +
20064 +2: GET_CR0_INTO_RDI
20065 + btr $16,%rdi
20066 + ljmpq __KERNEL_CS,3f
20067 +3: SET_RDI_INTO_CR0
20068 + jmp 1b
20069 +ENDPROC(pax_exit_kernel)
20070 +#endif
20071 +
20072 + .macro pax_enter_kernel_user
20073 + pax_set_fptr_mask
20074 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20075 + call pax_enter_kernel_user
20076 +#endif
20077 + .endm
20078 +
20079 + .macro pax_exit_kernel_user
20080 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20081 + call pax_exit_kernel_user
20082 +#endif
20083 +#ifdef CONFIG_PAX_RANDKSTACK
20084 + pushq %rax
20085 + call pax_randomize_kstack
20086 + popq %rax
20087 +#endif
20088 + .endm
20089 +
20090 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20091 +ENTRY(pax_enter_kernel_user)
20092 + pushq %rdi
20093 + pushq %rbx
20094 +
20095 +#ifdef CONFIG_PARAVIRT
20096 + PV_SAVE_REGS(CLBR_RDI)
20097 +#endif
20098 +
20099 + GET_CR3_INTO_RDI
20100 + mov %rdi,%rbx
20101 + add $__START_KERNEL_map,%rbx
20102 + sub phys_base(%rip),%rbx
20103 +
20104 +#ifdef CONFIG_PARAVIRT
20105 + pushq %rdi
20106 + cmpl $0, pv_info+PARAVIRT_enabled
20107 + jz 1f
20108 + i = 0
20109 + .rept USER_PGD_PTRS
20110 + mov i*8(%rbx),%rsi
20111 + mov $0,%sil
20112 + lea i*8(%rbx),%rdi
20113 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
20114 + i = i + 1
20115 + .endr
20116 + jmp 2f
20117 +1:
20118 +#endif
20119 +
20120 + i = 0
20121 + .rept USER_PGD_PTRS
20122 + movb $0,i*8(%rbx)
20123 + i = i + 1
20124 + .endr
20125 +
20126 +#ifdef CONFIG_PARAVIRT
20127 +2: popq %rdi
20128 +#endif
20129 + SET_RDI_INTO_CR3
20130 +
20131 +#ifdef CONFIG_PAX_KERNEXEC
20132 + GET_CR0_INTO_RDI
20133 + bts $16,%rdi
20134 + SET_RDI_INTO_CR0
20135 +#endif
20136 +
20137 +#ifdef CONFIG_PARAVIRT
20138 + PV_RESTORE_REGS(CLBR_RDI)
20139 +#endif
20140 +
20141 + popq %rbx
20142 + popq %rdi
20143 + pax_force_retaddr
20144 + retq
20145 +ENDPROC(pax_enter_kernel_user)
20146 +
20147 +ENTRY(pax_exit_kernel_user)
20148 + push %rdi
20149 +
20150 +#ifdef CONFIG_PARAVIRT
20151 + pushq %rbx
20152 + PV_SAVE_REGS(CLBR_RDI)
20153 +#endif
20154 +
20155 +#ifdef CONFIG_PAX_KERNEXEC
20156 + GET_CR0_INTO_RDI
20157 + btr $16,%rdi
20158 + SET_RDI_INTO_CR0
20159 +#endif
20160 +
20161 + GET_CR3_INTO_RDI
20162 + add $__START_KERNEL_map,%rdi
20163 + sub phys_base(%rip),%rdi
20164 +
20165 +#ifdef CONFIG_PARAVIRT
20166 + cmpl $0, pv_info+PARAVIRT_enabled
20167 + jz 1f
20168 + mov %rdi,%rbx
20169 + i = 0
20170 + .rept USER_PGD_PTRS
20171 + mov i*8(%rbx),%rsi
20172 + mov $0x67,%sil
20173 + lea i*8(%rbx),%rdi
20174 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
20175 + i = i + 1
20176 + .endr
20177 + jmp 2f
20178 +1:
20179 +#endif
20180 +
20181 + i = 0
20182 + .rept USER_PGD_PTRS
20183 + movb $0x67,i*8(%rdi)
20184 + i = i + 1
20185 + .endr
20186 +
20187 +#ifdef CONFIG_PARAVIRT
20188 +2: PV_RESTORE_REGS(CLBR_RDI)
20189 + popq %rbx
20190 +#endif
20191 +
20192 + popq %rdi
20193 + pax_force_retaddr
20194 + retq
20195 +ENDPROC(pax_exit_kernel_user)
20196 +#endif
20197 +
20198 +.macro pax_erase_kstack
20199 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20200 + call pax_erase_kstack
20201 +#endif
20202 +.endm
20203 +
20204 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20205 +ENTRY(pax_erase_kstack)
20206 + pushq %rdi
20207 + pushq %rcx
20208 + pushq %rax
20209 + pushq %r11
20210 +
20211 + GET_THREAD_INFO(%r11)
20212 + mov TI_lowest_stack(%r11), %rdi
20213 + mov $-0xBEEF, %rax
20214 + std
20215 +
20216 +1: mov %edi, %ecx
20217 + and $THREAD_SIZE_asm - 1, %ecx
20218 + shr $3, %ecx
20219 + repne scasq
20220 + jecxz 2f
20221 +
20222 + cmp $2*8, %ecx
20223 + jc 2f
20224 +
20225 + mov $2*8, %ecx
20226 + repe scasq
20227 + jecxz 2f
20228 + jne 1b
20229 +
20230 +2: cld
20231 + mov %esp, %ecx
20232 + sub %edi, %ecx
20233 +
20234 + cmp $THREAD_SIZE_asm, %rcx
20235 + jb 3f
20236 + ud2
20237 +3:
20238 +
20239 + shr $3, %ecx
20240 + rep stosq
20241 +
20242 + mov TI_task_thread_sp0(%r11), %rdi
20243 + sub $256, %rdi
20244 + mov %rdi, TI_lowest_stack(%r11)
20245 +
20246 + popq %r11
20247 + popq %rax
20248 + popq %rcx
20249 + popq %rdi
20250 + pax_force_retaddr
20251 + ret
20252 +ENDPROC(pax_erase_kstack)
20253 +#endif
20254
20255 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
20256 #ifdef CONFIG_TRACE_IRQFLAGS
20257 @@ -375,8 +651,8 @@ ENDPROC(native_usergs_sysret64)
20258 .endm
20259
20260 .macro UNFAKE_STACK_FRAME
20261 - addq $8*6, %rsp
20262 - CFI_ADJUST_CFA_OFFSET -(6*8)
20263 + addq $8*6 + ARG_SKIP, %rsp
20264 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
20265 .endm
20266
20267 /*
20268 @@ -463,7 +739,7 @@ ENDPROC(native_usergs_sysret64)
20269 movq %rsp, %rsi
20270
20271 leaq -RBP(%rsp),%rdi /* arg1 for handler */
20272 - testl $3, CS-RBP(%rsi)
20273 + testb $3, CS-RBP(%rsi)
20274 je 1f
20275 SWAPGS
20276 /*
20277 @@ -498,9 +774,10 @@ ENTRY(save_rest)
20278 movq_cfi r15, R15+16
20279 movq %r11, 8(%rsp) /* return address */
20280 FIXUP_TOP_OF_STACK %r11, 16
20281 + pax_force_retaddr
20282 ret
20283 CFI_ENDPROC
20284 -END(save_rest)
20285 +ENDPROC(save_rest)
20286
20287 /* save complete stack frame */
20288 .pushsection .kprobes.text, "ax"
20289 @@ -529,9 +806,10 @@ ENTRY(save_paranoid)
20290 js 1f /* negative -> in kernel */
20291 SWAPGS
20292 xorl %ebx,%ebx
20293 -1: ret
20294 +1: pax_force_retaddr_bts
20295 + ret
20296 CFI_ENDPROC
20297 -END(save_paranoid)
20298 +ENDPROC(save_paranoid)
20299 .popsection
20300
20301 /*
20302 @@ -553,7 +831,7 @@ ENTRY(ret_from_fork)
20303
20304 RESTORE_REST
20305
20306 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
20307 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
20308 jz 1f
20309
20310 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
20311 @@ -571,7 +849,7 @@ ENTRY(ret_from_fork)
20312 RESTORE_REST
20313 jmp int_ret_from_sys_call
20314 CFI_ENDPROC
20315 -END(ret_from_fork)
20316 +ENDPROC(ret_from_fork)
20317
20318 /*
20319 * System call entry. Up to 6 arguments in registers are supported.
20320 @@ -608,7 +886,7 @@ END(ret_from_fork)
20321 ENTRY(system_call)
20322 CFI_STARTPROC simple
20323 CFI_SIGNAL_FRAME
20324 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
20325 + CFI_DEF_CFA rsp,0
20326 CFI_REGISTER rip,rcx
20327 /*CFI_REGISTER rflags,r11*/
20328 SWAPGS_UNSAFE_STACK
20329 @@ -621,16 +899,23 @@ GLOBAL(system_call_after_swapgs)
20330
20331 movq %rsp,PER_CPU_VAR(old_rsp)
20332 movq PER_CPU_VAR(kernel_stack),%rsp
20333 + SAVE_ARGS 8*6,0
20334 + pax_enter_kernel_user
20335 +
20336 +#ifdef CONFIG_PAX_RANDKSTACK
20337 + pax_erase_kstack
20338 +#endif
20339 +
20340 /*
20341 * No need to follow this irqs off/on section - it's straight
20342 * and short:
20343 */
20344 ENABLE_INTERRUPTS(CLBR_NONE)
20345 - SAVE_ARGS 8,0
20346 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
20347 movq %rcx,RIP-ARGOFFSET(%rsp)
20348 CFI_REL_OFFSET rip,RIP-ARGOFFSET
20349 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
20350 + GET_THREAD_INFO(%rcx)
20351 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
20352 jnz tracesys
20353 system_call_fastpath:
20354 #if __SYSCALL_MASK == ~0
20355 @@ -640,7 +925,7 @@ system_call_fastpath:
20356 cmpl $__NR_syscall_max,%eax
20357 #endif
20358 ja badsys
20359 - movq %r10,%rcx
20360 + movq R10-ARGOFFSET(%rsp),%rcx
20361 call *sys_call_table(,%rax,8) # XXX: rip relative
20362 movq %rax,RAX-ARGOFFSET(%rsp)
20363 /*
20364 @@ -654,10 +939,13 @@ sysret_check:
20365 LOCKDEP_SYS_EXIT
20366 DISABLE_INTERRUPTS(CLBR_NONE)
20367 TRACE_IRQS_OFF
20368 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
20369 + GET_THREAD_INFO(%rcx)
20370 + movl TI_flags(%rcx),%edx
20371 andl %edi,%edx
20372 jnz sysret_careful
20373 CFI_REMEMBER_STATE
20374 + pax_exit_kernel_user
20375 + pax_erase_kstack
20376 /*
20377 * sysretq will re-enable interrupts:
20378 */
20379 @@ -709,14 +997,18 @@ badsys:
20380 * jump back to the normal fast path.
20381 */
20382 auditsys:
20383 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
20384 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
20385 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
20386 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
20387 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
20388 movq %rax,%rsi /* 2nd arg: syscall number */
20389 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
20390 call __audit_syscall_entry
20391 +
20392 + pax_erase_kstack
20393 +
20394 LOAD_ARGS 0 /* reload call-clobbered registers */
20395 + pax_set_fptr_mask
20396 jmp system_call_fastpath
20397
20398 /*
20399 @@ -737,7 +1029,7 @@ sysret_audit:
20400 /* Do syscall tracing */
20401 tracesys:
20402 #ifdef CONFIG_AUDITSYSCALL
20403 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
20404 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
20405 jz auditsys
20406 #endif
20407 SAVE_REST
20408 @@ -745,12 +1037,16 @@ tracesys:
20409 FIXUP_TOP_OF_STACK %rdi
20410 movq %rsp,%rdi
20411 call syscall_trace_enter
20412 +
20413 + pax_erase_kstack
20414 +
20415 /*
20416 * Reload arg registers from stack in case ptrace changed them.
20417 * We don't reload %rax because syscall_trace_enter() returned
20418 * the value it wants us to use in the table lookup.
20419 */
20420 LOAD_ARGS ARGOFFSET, 1
20421 + pax_set_fptr_mask
20422 RESTORE_REST
20423 #if __SYSCALL_MASK == ~0
20424 cmpq $__NR_syscall_max,%rax
20425 @@ -759,7 +1055,7 @@ tracesys:
20426 cmpl $__NR_syscall_max,%eax
20427 #endif
20428 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
20429 - movq %r10,%rcx /* fixup for C */
20430 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
20431 call *sys_call_table(,%rax,8)
20432 movq %rax,RAX-ARGOFFSET(%rsp)
20433 /* Use IRET because user could have changed frame */
20434 @@ -780,7 +1076,9 @@ GLOBAL(int_with_check)
20435 andl %edi,%edx
20436 jnz int_careful
20437 andl $~TS_COMPAT,TI_status(%rcx)
20438 - jmp retint_swapgs
20439 + pax_exit_kernel_user
20440 + pax_erase_kstack
20441 + jmp retint_swapgs_pax
20442
20443 /* Either reschedule or signal or syscall exit tracking needed. */
20444 /* First do a reschedule test. */
20445 @@ -826,7 +1124,7 @@ int_restore_rest:
20446 TRACE_IRQS_OFF
20447 jmp int_with_check
20448 CFI_ENDPROC
20449 -END(system_call)
20450 +ENDPROC(system_call)
20451
20452 /*
20453 * Certain special system calls that need to save a complete full stack frame.
20454 @@ -842,7 +1140,7 @@ ENTRY(\label)
20455 call \func
20456 jmp ptregscall_common
20457 CFI_ENDPROC
20458 -END(\label)
20459 +ENDPROC(\label)
20460 .endm
20461
20462 .macro FORK_LIKE func
20463 @@ -856,9 +1154,10 @@ ENTRY(stub_\func)
20464 DEFAULT_FRAME 0 8 /* offset 8: return address */
20465 call sys_\func
20466 RESTORE_TOP_OF_STACK %r11, 8
20467 + pax_force_retaddr
20468 ret $REST_SKIP /* pop extended registers */
20469 CFI_ENDPROC
20470 -END(stub_\func)
20471 +ENDPROC(stub_\func)
20472 .endm
20473
20474 FORK_LIKE clone
20475 @@ -875,9 +1174,10 @@ ENTRY(ptregscall_common)
20476 movq_cfi_restore R12+8, r12
20477 movq_cfi_restore RBP+8, rbp
20478 movq_cfi_restore RBX+8, rbx
20479 + pax_force_retaddr
20480 ret $REST_SKIP /* pop extended registers */
20481 CFI_ENDPROC
20482 -END(ptregscall_common)
20483 +ENDPROC(ptregscall_common)
20484
20485 ENTRY(stub_execve)
20486 CFI_STARTPROC
20487 @@ -891,7 +1191,7 @@ ENTRY(stub_execve)
20488 RESTORE_REST
20489 jmp int_ret_from_sys_call
20490 CFI_ENDPROC
20491 -END(stub_execve)
20492 +ENDPROC(stub_execve)
20493
20494 /*
20495 * sigreturn is special because it needs to restore all registers on return.
20496 @@ -909,7 +1209,7 @@ ENTRY(stub_rt_sigreturn)
20497 RESTORE_REST
20498 jmp int_ret_from_sys_call
20499 CFI_ENDPROC
20500 -END(stub_rt_sigreturn)
20501 +ENDPROC(stub_rt_sigreturn)
20502
20503 #ifdef CONFIG_X86_X32_ABI
20504 ENTRY(stub_x32_rt_sigreturn)
20505 @@ -975,7 +1275,7 @@ vector=vector+1
20506 2: jmp common_interrupt
20507 .endr
20508 CFI_ENDPROC
20509 -END(irq_entries_start)
20510 +ENDPROC(irq_entries_start)
20511
20512 .previous
20513 END(interrupt)
20514 @@ -995,6 +1295,16 @@ END(interrupt)
20515 subq $ORIG_RAX-RBP, %rsp
20516 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
20517 SAVE_ARGS_IRQ
20518 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20519 + testb $3, CS(%rdi)
20520 + jnz 1f
20521 + pax_enter_kernel
20522 + jmp 2f
20523 +1: pax_enter_kernel_user
20524 +2:
20525 +#else
20526 + pax_enter_kernel
20527 +#endif
20528 call \func
20529 .endm
20530
20531 @@ -1027,7 +1337,7 @@ ret_from_intr:
20532
20533 exit_intr:
20534 GET_THREAD_INFO(%rcx)
20535 - testl $3,CS-ARGOFFSET(%rsp)
20536 + testb $3,CS-ARGOFFSET(%rsp)
20537 je retint_kernel
20538
20539 /* Interrupt came from user space */
20540 @@ -1049,12 +1359,16 @@ retint_swapgs: /* return to user-space */
20541 * The iretq could re-enable interrupts:
20542 */
20543 DISABLE_INTERRUPTS(CLBR_ANY)
20544 + pax_exit_kernel_user
20545 +retint_swapgs_pax:
20546 TRACE_IRQS_IRETQ
20547 SWAPGS
20548 jmp restore_args
20549
20550 retint_restore_args: /* return to kernel space */
20551 DISABLE_INTERRUPTS(CLBR_ANY)
20552 + pax_exit_kernel
20553 + pax_force_retaddr (RIP-ARGOFFSET)
20554 /*
20555 * The iretq could re-enable interrupts:
20556 */
20557 @@ -1137,7 +1451,7 @@ ENTRY(retint_kernel)
20558 #endif
20559
20560 CFI_ENDPROC
20561 -END(common_interrupt)
20562 +ENDPROC(common_interrupt)
20563 /*
20564 * End of kprobes section
20565 */
20566 @@ -1155,7 +1469,7 @@ ENTRY(\sym)
20567 interrupt \do_sym
20568 jmp ret_from_intr
20569 CFI_ENDPROC
20570 -END(\sym)
20571 +ENDPROC(\sym)
20572 .endm
20573
20574 #ifdef CONFIG_SMP
20575 @@ -1211,12 +1525,22 @@ ENTRY(\sym)
20576 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20577 call error_entry
20578 DEFAULT_FRAME 0
20579 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20580 + testb $3, CS(%rsp)
20581 + jnz 1f
20582 + pax_enter_kernel
20583 + jmp 2f
20584 +1: pax_enter_kernel_user
20585 +2:
20586 +#else
20587 + pax_enter_kernel
20588 +#endif
20589 movq %rsp,%rdi /* pt_regs pointer */
20590 xorl %esi,%esi /* no error code */
20591 call \do_sym
20592 jmp error_exit /* %ebx: no swapgs flag */
20593 CFI_ENDPROC
20594 -END(\sym)
20595 +ENDPROC(\sym)
20596 .endm
20597
20598 .macro paranoidzeroentry sym do_sym
20599 @@ -1229,15 +1553,25 @@ ENTRY(\sym)
20600 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20601 call save_paranoid
20602 TRACE_IRQS_OFF
20603 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20604 + testb $3, CS(%rsp)
20605 + jnz 1f
20606 + pax_enter_kernel
20607 + jmp 2f
20608 +1: pax_enter_kernel_user
20609 +2:
20610 +#else
20611 + pax_enter_kernel
20612 +#endif
20613 movq %rsp,%rdi /* pt_regs pointer */
20614 xorl %esi,%esi /* no error code */
20615 call \do_sym
20616 jmp paranoid_exit /* %ebx: no swapgs flag */
20617 CFI_ENDPROC
20618 -END(\sym)
20619 +ENDPROC(\sym)
20620 .endm
20621
20622 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
20623 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
20624 .macro paranoidzeroentry_ist sym do_sym ist
20625 ENTRY(\sym)
20626 INTR_FRAME
20627 @@ -1248,14 +1582,30 @@ ENTRY(\sym)
20628 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20629 call save_paranoid
20630 TRACE_IRQS_OFF_DEBUG
20631 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20632 + testb $3, CS(%rsp)
20633 + jnz 1f
20634 + pax_enter_kernel
20635 + jmp 2f
20636 +1: pax_enter_kernel_user
20637 +2:
20638 +#else
20639 + pax_enter_kernel
20640 +#endif
20641 movq %rsp,%rdi /* pt_regs pointer */
20642 xorl %esi,%esi /* no error code */
20643 +#ifdef CONFIG_SMP
20644 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
20645 + lea init_tss(%r12), %r12
20646 +#else
20647 + lea init_tss(%rip), %r12
20648 +#endif
20649 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20650 call \do_sym
20651 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20652 jmp paranoid_exit /* %ebx: no swapgs flag */
20653 CFI_ENDPROC
20654 -END(\sym)
20655 +ENDPROC(\sym)
20656 .endm
20657
20658 .macro errorentry sym do_sym
20659 @@ -1267,13 +1617,23 @@ ENTRY(\sym)
20660 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20661 call error_entry
20662 DEFAULT_FRAME 0
20663 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20664 + testb $3, CS(%rsp)
20665 + jnz 1f
20666 + pax_enter_kernel
20667 + jmp 2f
20668 +1: pax_enter_kernel_user
20669 +2:
20670 +#else
20671 + pax_enter_kernel
20672 +#endif
20673 movq %rsp,%rdi /* pt_regs pointer */
20674 movq ORIG_RAX(%rsp),%rsi /* get error code */
20675 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20676 call \do_sym
20677 jmp error_exit /* %ebx: no swapgs flag */
20678 CFI_ENDPROC
20679 -END(\sym)
20680 +ENDPROC(\sym)
20681 .endm
20682
20683 /* error code is on the stack already */
20684 @@ -1287,13 +1647,23 @@ ENTRY(\sym)
20685 call save_paranoid
20686 DEFAULT_FRAME 0
20687 TRACE_IRQS_OFF
20688 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20689 + testb $3, CS(%rsp)
20690 + jnz 1f
20691 + pax_enter_kernel
20692 + jmp 2f
20693 +1: pax_enter_kernel_user
20694 +2:
20695 +#else
20696 + pax_enter_kernel
20697 +#endif
20698 movq %rsp,%rdi /* pt_regs pointer */
20699 movq ORIG_RAX(%rsp),%rsi /* get error code */
20700 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20701 call \do_sym
20702 jmp paranoid_exit /* %ebx: no swapgs flag */
20703 CFI_ENDPROC
20704 -END(\sym)
20705 +ENDPROC(\sym)
20706 .endm
20707
20708 zeroentry divide_error do_divide_error
20709 @@ -1323,9 +1693,10 @@ gs_change:
20710 2: mfence /* workaround */
20711 SWAPGS
20712 popfq_cfi
20713 + pax_force_retaddr
20714 ret
20715 CFI_ENDPROC
20716 -END(native_load_gs_index)
20717 +ENDPROC(native_load_gs_index)
20718
20719 _ASM_EXTABLE(gs_change,bad_gs)
20720 .section .fixup,"ax"
20721 @@ -1353,9 +1724,10 @@ ENTRY(call_softirq)
20722 CFI_DEF_CFA_REGISTER rsp
20723 CFI_ADJUST_CFA_OFFSET -8
20724 decl PER_CPU_VAR(irq_count)
20725 + pax_force_retaddr
20726 ret
20727 CFI_ENDPROC
20728 -END(call_softirq)
20729 +ENDPROC(call_softirq)
20730
20731 #ifdef CONFIG_XEN
20732 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
20733 @@ -1393,7 +1765,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
20734 decl PER_CPU_VAR(irq_count)
20735 jmp error_exit
20736 CFI_ENDPROC
20737 -END(xen_do_hypervisor_callback)
20738 +ENDPROC(xen_do_hypervisor_callback)
20739
20740 /*
20741 * Hypervisor uses this for application faults while it executes.
20742 @@ -1452,7 +1824,7 @@ ENTRY(xen_failsafe_callback)
20743 SAVE_ALL
20744 jmp error_exit
20745 CFI_ENDPROC
20746 -END(xen_failsafe_callback)
20747 +ENDPROC(xen_failsafe_callback)
20748
20749 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
20750 xen_hvm_callback_vector xen_evtchn_do_upcall
20751 @@ -1501,16 +1873,31 @@ ENTRY(paranoid_exit)
20752 TRACE_IRQS_OFF_DEBUG
20753 testl %ebx,%ebx /* swapgs needed? */
20754 jnz paranoid_restore
20755 - testl $3,CS(%rsp)
20756 + testb $3,CS(%rsp)
20757 jnz paranoid_userspace
20758 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20759 + pax_exit_kernel
20760 + TRACE_IRQS_IRETQ 0
20761 + SWAPGS_UNSAFE_STACK
20762 + RESTORE_ALL 8
20763 + pax_force_retaddr_bts
20764 + jmp irq_return
20765 +#endif
20766 paranoid_swapgs:
20767 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20768 + pax_exit_kernel_user
20769 +#else
20770 + pax_exit_kernel
20771 +#endif
20772 TRACE_IRQS_IRETQ 0
20773 SWAPGS_UNSAFE_STACK
20774 RESTORE_ALL 8
20775 jmp irq_return
20776 paranoid_restore:
20777 + pax_exit_kernel
20778 TRACE_IRQS_IRETQ_DEBUG 0
20779 RESTORE_ALL 8
20780 + pax_force_retaddr_bts
20781 jmp irq_return
20782 paranoid_userspace:
20783 GET_THREAD_INFO(%rcx)
20784 @@ -1539,7 +1926,7 @@ paranoid_schedule:
20785 TRACE_IRQS_OFF
20786 jmp paranoid_userspace
20787 CFI_ENDPROC
20788 -END(paranoid_exit)
20789 +ENDPROC(paranoid_exit)
20790
20791 /*
20792 * Exception entry point. This expects an error code/orig_rax on the stack.
20793 @@ -1566,12 +1953,13 @@ ENTRY(error_entry)
20794 movq_cfi r14, R14+8
20795 movq_cfi r15, R15+8
20796 xorl %ebx,%ebx
20797 - testl $3,CS+8(%rsp)
20798 + testb $3,CS+8(%rsp)
20799 je error_kernelspace
20800 error_swapgs:
20801 SWAPGS
20802 error_sti:
20803 TRACE_IRQS_OFF
20804 + pax_force_retaddr_bts
20805 ret
20806
20807 /*
20808 @@ -1598,7 +1986,7 @@ bstep_iret:
20809 movq %rcx,RIP+8(%rsp)
20810 jmp error_swapgs
20811 CFI_ENDPROC
20812 -END(error_entry)
20813 +ENDPROC(error_entry)
20814
20815
20816 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
20817 @@ -1618,7 +2006,7 @@ ENTRY(error_exit)
20818 jnz retint_careful
20819 jmp retint_swapgs
20820 CFI_ENDPROC
20821 -END(error_exit)
20822 +ENDPROC(error_exit)
20823
20824 /*
20825 * Test if a given stack is an NMI stack or not.
20826 @@ -1676,9 +2064,11 @@ ENTRY(nmi)
20827 * If %cs was not the kernel segment, then the NMI triggered in user
20828 * space, which means it is definitely not nested.
20829 */
20830 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20831 + je 1f
20832 cmpl $__KERNEL_CS, 16(%rsp)
20833 jne first_nmi
20834 -
20835 +1:
20836 /*
20837 * Check the special variable on the stack to see if NMIs are
20838 * executing.
20839 @@ -1712,14 +2102,13 @@ nested_nmi:
20840
20841 1:
20842 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
20843 - leaq -1*8(%rsp), %rdx
20844 - movq %rdx, %rsp
20845 + subq $8, %rsp
20846 CFI_ADJUST_CFA_OFFSET 1*8
20847 leaq -10*8(%rsp), %rdx
20848 pushq_cfi $__KERNEL_DS
20849 pushq_cfi %rdx
20850 pushfq_cfi
20851 - pushq_cfi $__KERNEL_CS
20852 + pushq_cfi 6*8(%rsp)
20853 pushq_cfi $repeat_nmi
20854
20855 /* Put stack back */
20856 @@ -1731,6 +2120,7 @@ nested_nmi_out:
20857 CFI_RESTORE rdx
20858
20859 /* No need to check faults here */
20860 + pax_force_retaddr_bts
20861 INTERRUPT_RETURN
20862
20863 CFI_RESTORE_STATE
20864 @@ -1847,6 +2237,17 @@ end_repeat_nmi:
20865 */
20866 movq %cr2, %r12
20867
20868 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20869 + testb $3, CS(%rsp)
20870 + jnz 1f
20871 + pax_enter_kernel
20872 + jmp 2f
20873 +1: pax_enter_kernel_user
20874 +2:
20875 +#else
20876 + pax_enter_kernel
20877 +#endif
20878 +
20879 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20880 movq %rsp,%rdi
20881 movq $-1,%rsi
20882 @@ -1862,23 +2263,34 @@ end_repeat_nmi:
20883 testl %ebx,%ebx /* swapgs needed? */
20884 jnz nmi_restore
20885 nmi_swapgs:
20886 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20887 + pax_exit_kernel_user
20888 +#else
20889 + pax_exit_kernel
20890 +#endif
20891 SWAPGS_UNSAFE_STACK
20892 + RESTORE_ALL 6*8
20893 + /* Clear the NMI executing stack variable */
20894 + movq $0, 5*8(%rsp)
20895 + jmp irq_return
20896 nmi_restore:
20897 + pax_exit_kernel
20898 /* Pop the extra iret frame at once */
20899 RESTORE_ALL 6*8
20900 + pax_force_retaddr_bts
20901
20902 /* Clear the NMI executing stack variable */
20903 movq $0, 5*8(%rsp)
20904 jmp irq_return
20905 CFI_ENDPROC
20906 -END(nmi)
20907 +ENDPROC(nmi)
20908
20909 ENTRY(ignore_sysret)
20910 CFI_STARTPROC
20911 mov $-ENOSYS,%eax
20912 sysret
20913 CFI_ENDPROC
20914 -END(ignore_sysret)
20915 +ENDPROC(ignore_sysret)
20916
20917 /*
20918 * End of kprobes section
20919 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20920 index 1d41402..af9a46a 100644
20921 --- a/arch/x86/kernel/ftrace.c
20922 +++ b/arch/x86/kernel/ftrace.c
20923 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20924 {
20925 unsigned char replaced[MCOUNT_INSN_SIZE];
20926
20927 + ip = ktla_ktva(ip);
20928 +
20929 /*
20930 * Note: Due to modules and __init, code can
20931 * disappear and change, we need to protect against faulting
20932 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20933 unsigned char old[MCOUNT_INSN_SIZE], *new;
20934 int ret;
20935
20936 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20937 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20938 new = ftrace_call_replace(ip, (unsigned long)func);
20939
20940 /* See comment above by declaration of modifying_ftrace_code */
20941 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20942 /* Also update the regs callback function */
20943 if (!ret) {
20944 ip = (unsigned long)(&ftrace_regs_call);
20945 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20946 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20947 new = ftrace_call_replace(ip, (unsigned long)func);
20948 ret = ftrace_modify_code(ip, old, new);
20949 }
20950 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20951 * kernel identity mapping to modify code.
20952 */
20953 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20954 - ip = (unsigned long)__va(__pa(ip));
20955 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
20956
20957 return probe_kernel_write((void *)ip, val, size);
20958 }
20959 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20960 unsigned char replaced[MCOUNT_INSN_SIZE];
20961 unsigned char brk = BREAKPOINT_INSTRUCTION;
20962
20963 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20964 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20965 return -EFAULT;
20966
20967 /* Make sure it is what we expect it to be */
20968 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20969 return ret;
20970
20971 fail_update:
20972 - probe_kernel_write((void *)ip, &old_code[0], 1);
20973 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20974 goto out;
20975 }
20976
20977 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20978 {
20979 unsigned char code[MCOUNT_INSN_SIZE];
20980
20981 + ip = ktla_ktva(ip);
20982 +
20983 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20984 return -EFAULT;
20985
20986 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
20987 index c18f59d..9c0c9f6 100644
20988 --- a/arch/x86/kernel/head32.c
20989 +++ b/arch/x86/kernel/head32.c
20990 @@ -18,6 +18,7 @@
20991 #include <asm/io_apic.h>
20992 #include <asm/bios_ebda.h>
20993 #include <asm/tlbflush.h>
20994 +#include <asm/boot.h>
20995
20996 static void __init i386_default_early_setup(void)
20997 {
20998 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
20999
21000 void __init i386_start_kernel(void)
21001 {
21002 - memblock_reserve(__pa_symbol(&_text),
21003 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
21004 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
21005
21006 #ifdef CONFIG_BLK_DEV_INITRD
21007 /* Reserve INITRD */
21008 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
21009 index c8932c7..d56b622 100644
21010 --- a/arch/x86/kernel/head_32.S
21011 +++ b/arch/x86/kernel/head_32.S
21012 @@ -26,6 +26,12 @@
21013 /* Physical address */
21014 #define pa(X) ((X) - __PAGE_OFFSET)
21015
21016 +#ifdef CONFIG_PAX_KERNEXEC
21017 +#define ta(X) (X)
21018 +#else
21019 +#define ta(X) ((X) - __PAGE_OFFSET)
21020 +#endif
21021 +
21022 /*
21023 * References to members of the new_cpu_data structure.
21024 */
21025 @@ -55,11 +61,7 @@
21026 * and small than max_low_pfn, otherwise will waste some page table entries
21027 */
21028
21029 -#if PTRS_PER_PMD > 1
21030 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
21031 -#else
21032 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
21033 -#endif
21034 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
21035
21036 /* Number of possible pages in the lowmem region */
21037 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
21038 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
21039 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
21040
21041 /*
21042 + * Real beginning of normal "text" segment
21043 + */
21044 +ENTRY(stext)
21045 +ENTRY(_stext)
21046 +
21047 +/*
21048 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
21049 * %esi points to the real-mode code as a 32-bit pointer.
21050 * CS and DS must be 4 GB flat segments, but we don't depend on
21051 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
21052 * can.
21053 */
21054 __HEAD
21055 +
21056 +#ifdef CONFIG_PAX_KERNEXEC
21057 + jmp startup_32
21058 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
21059 +.fill PAGE_SIZE-5,1,0xcc
21060 +#endif
21061 +
21062 ENTRY(startup_32)
21063 movl pa(stack_start),%ecx
21064
21065 @@ -106,6 +121,59 @@ ENTRY(startup_32)
21066 2:
21067 leal -__PAGE_OFFSET(%ecx),%esp
21068
21069 +#ifdef CONFIG_SMP
21070 + movl $pa(cpu_gdt_table),%edi
21071 + movl $__per_cpu_load,%eax
21072 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
21073 + rorl $16,%eax
21074 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
21075 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
21076 + movl $__per_cpu_end - 1,%eax
21077 + subl $__per_cpu_start,%eax
21078 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
21079 +#endif
21080 +
21081 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21082 + movl $NR_CPUS,%ecx
21083 + movl $pa(cpu_gdt_table),%edi
21084 +1:
21085 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
21086 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
21087 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
21088 + addl $PAGE_SIZE_asm,%edi
21089 + loop 1b
21090 +#endif
21091 +
21092 +#ifdef CONFIG_PAX_KERNEXEC
21093 + movl $pa(boot_gdt),%edi
21094 + movl $__LOAD_PHYSICAL_ADDR,%eax
21095 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
21096 + rorl $16,%eax
21097 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
21098 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
21099 + rorl $16,%eax
21100 +
21101 + ljmp $(__BOOT_CS),$1f
21102 +1:
21103 +
21104 + movl $NR_CPUS,%ecx
21105 + movl $pa(cpu_gdt_table),%edi
21106 + addl $__PAGE_OFFSET,%eax
21107 +1:
21108 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
21109 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
21110 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
21111 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
21112 + rorl $16,%eax
21113 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
21114 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
21115 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
21116 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
21117 + rorl $16,%eax
21118 + addl $PAGE_SIZE_asm,%edi
21119 + loop 1b
21120 +#endif
21121 +
21122 /*
21123 * Clear BSS first so that there are no surprises...
21124 */
21125 @@ -196,8 +264,11 @@ ENTRY(startup_32)
21126 movl %eax, pa(max_pfn_mapped)
21127
21128 /* Do early initialization of the fixmap area */
21129 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
21130 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
21131 +#ifdef CONFIG_COMPAT_VDSO
21132 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
21133 +#else
21134 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
21135 +#endif
21136 #else /* Not PAE */
21137
21138 page_pde_offset = (__PAGE_OFFSET >> 20);
21139 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
21140 movl %eax, pa(max_pfn_mapped)
21141
21142 /* Do early initialization of the fixmap area */
21143 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
21144 - movl %eax,pa(initial_page_table+0xffc)
21145 +#ifdef CONFIG_COMPAT_VDSO
21146 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
21147 +#else
21148 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
21149 +#endif
21150 #endif
21151
21152 #ifdef CONFIG_PARAVIRT
21153 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
21154 cmpl $num_subarch_entries, %eax
21155 jae bad_subarch
21156
21157 - movl pa(subarch_entries)(,%eax,4), %eax
21158 - subl $__PAGE_OFFSET, %eax
21159 - jmp *%eax
21160 + jmp *pa(subarch_entries)(,%eax,4)
21161
21162 bad_subarch:
21163 WEAK(lguest_entry)
21164 @@ -256,10 +328,10 @@ WEAK(xen_entry)
21165 __INITDATA
21166
21167 subarch_entries:
21168 - .long default_entry /* normal x86/PC */
21169 - .long lguest_entry /* lguest hypervisor */
21170 - .long xen_entry /* Xen hypervisor */
21171 - .long default_entry /* Moorestown MID */
21172 + .long ta(default_entry) /* normal x86/PC */
21173 + .long ta(lguest_entry) /* lguest hypervisor */
21174 + .long ta(xen_entry) /* Xen hypervisor */
21175 + .long ta(default_entry) /* Moorestown MID */
21176 num_subarch_entries = (. - subarch_entries) / 4
21177 .previous
21178 #else
21179 @@ -335,6 +407,7 @@ default_entry:
21180 movl pa(mmu_cr4_features),%eax
21181 movl %eax,%cr4
21182
21183 +#ifdef CONFIG_X86_PAE
21184 testb $X86_CR4_PAE, %al # check if PAE is enabled
21185 jz 6f
21186
21187 @@ -363,6 +436,9 @@ default_entry:
21188 /* Make changes effective */
21189 wrmsr
21190
21191 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
21192 +#endif
21193 +
21194 6:
21195
21196 /*
21197 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
21198 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
21199 movl %eax,%ss # after changing gdt.
21200
21201 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
21202 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
21203 movl %eax,%ds
21204 movl %eax,%es
21205
21206 movl $(__KERNEL_PERCPU), %eax
21207 movl %eax,%fs # set this cpu's percpu
21208
21209 +#ifdef CONFIG_CC_STACKPROTECTOR
21210 movl $(__KERNEL_STACK_CANARY),%eax
21211 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
21212 + movl $(__USER_DS),%eax
21213 +#else
21214 + xorl %eax,%eax
21215 +#endif
21216 movl %eax,%gs
21217
21218 xorl %eax,%eax # Clear LDT
21219 @@ -544,8 +626,11 @@ setup_once:
21220 * relocation. Manually set base address in stack canary
21221 * segment descriptor.
21222 */
21223 - movl $gdt_page,%eax
21224 + movl $cpu_gdt_table,%eax
21225 movl $stack_canary,%ecx
21226 +#ifdef CONFIG_SMP
21227 + addl $__per_cpu_load,%ecx
21228 +#endif
21229 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
21230 shrl $16, %ecx
21231 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
21232 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
21233 /* This is global to keep gas from relaxing the jumps */
21234 ENTRY(early_idt_handler)
21235 cld
21236 - cmpl $2,%ss:early_recursion_flag
21237 + cmpl $1,%ss:early_recursion_flag
21238 je hlt_loop
21239 incl %ss:early_recursion_flag
21240
21241 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
21242 pushl (20+6*4)(%esp) /* trapno */
21243 pushl $fault_msg
21244 call printk
21245 -#endif
21246 call dump_stack
21247 +#endif
21248 hlt_loop:
21249 hlt
21250 jmp hlt_loop
21251 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
21252 /* This is the default interrupt "handler" :-) */
21253 ALIGN
21254 ignore_int:
21255 - cld
21256 #ifdef CONFIG_PRINTK
21257 + cmpl $2,%ss:early_recursion_flag
21258 + je hlt_loop
21259 + incl %ss:early_recursion_flag
21260 + cld
21261 pushl %eax
21262 pushl %ecx
21263 pushl %edx
21264 @@ -644,9 +732,6 @@ ignore_int:
21265 movl $(__KERNEL_DS),%eax
21266 movl %eax,%ds
21267 movl %eax,%es
21268 - cmpl $2,early_recursion_flag
21269 - je hlt_loop
21270 - incl early_recursion_flag
21271 pushl 16(%esp)
21272 pushl 24(%esp)
21273 pushl 32(%esp)
21274 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
21275 /*
21276 * BSS section
21277 */
21278 -__PAGE_ALIGNED_BSS
21279 - .align PAGE_SIZE
21280 #ifdef CONFIG_X86_PAE
21281 +.section .initial_pg_pmd,"a",@progbits
21282 initial_pg_pmd:
21283 .fill 1024*KPMDS,4,0
21284 #else
21285 +.section .initial_page_table,"a",@progbits
21286 ENTRY(initial_page_table)
21287 .fill 1024,4,0
21288 #endif
21289 +.section .initial_pg_fixmap,"a",@progbits
21290 initial_pg_fixmap:
21291 .fill 1024,4,0
21292 +.section .empty_zero_page,"a",@progbits
21293 ENTRY(empty_zero_page)
21294 .fill 4096,1,0
21295 +.section .swapper_pg_dir,"a",@progbits
21296 ENTRY(swapper_pg_dir)
21297 +#ifdef CONFIG_X86_PAE
21298 + .fill 4,8,0
21299 +#else
21300 .fill 1024,4,0
21301 +#endif
21302 +
21303 +/*
21304 + * The IDT has to be page-aligned to simplify the Pentium
21305 + * F0 0F bug workaround.. We have a special link segment
21306 + * for this.
21307 + */
21308 +.section .idt,"a",@progbits
21309 +ENTRY(idt_table)
21310 + .fill 256,8,0
21311
21312 /*
21313 * This starts the data section.
21314 */
21315 #ifdef CONFIG_X86_PAE
21316 -__PAGE_ALIGNED_DATA
21317 - /* Page-aligned for the benefit of paravirt? */
21318 - .align PAGE_SIZE
21319 +.section .initial_page_table,"a",@progbits
21320 ENTRY(initial_page_table)
21321 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
21322 # if KPMDS == 3
21323 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
21324 # error "Kernel PMDs should be 1, 2 or 3"
21325 # endif
21326 .align PAGE_SIZE /* needs to be page-sized too */
21327 +
21328 +#ifdef CONFIG_PAX_PER_CPU_PGD
21329 +ENTRY(cpu_pgd)
21330 + .rept NR_CPUS
21331 + .fill 4,8,0
21332 + .endr
21333 +#endif
21334 +
21335 #endif
21336
21337 .data
21338 .balign 4
21339 ENTRY(stack_start)
21340 - .long init_thread_union+THREAD_SIZE
21341 + .long init_thread_union+THREAD_SIZE-8
21342
21343 __INITRODATA
21344 int_msg:
21345 @@ -754,7 +861,7 @@ fault_msg:
21346 * segment size, and 32-bit linear address value:
21347 */
21348
21349 - .data
21350 +.section .rodata,"a",@progbits
21351 .globl boot_gdt_descr
21352 .globl idt_descr
21353
21354 @@ -763,7 +870,7 @@ fault_msg:
21355 .word 0 # 32 bit align gdt_desc.address
21356 boot_gdt_descr:
21357 .word __BOOT_DS+7
21358 - .long boot_gdt - __PAGE_OFFSET
21359 + .long pa(boot_gdt)
21360
21361 .word 0 # 32-bit align idt_desc.address
21362 idt_descr:
21363 @@ -774,7 +881,7 @@ idt_descr:
21364 .word 0 # 32 bit align gdt_desc.address
21365 ENTRY(early_gdt_descr)
21366 .word GDT_ENTRIES*8-1
21367 - .long gdt_page /* Overwritten for secondary CPUs */
21368 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
21369
21370 /*
21371 * The boot_gdt must mirror the equivalent in setup.S and is
21372 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
21373 .align L1_CACHE_BYTES
21374 ENTRY(boot_gdt)
21375 .fill GDT_ENTRY_BOOT_CS,8,0
21376 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
21377 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
21378 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
21379 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
21380 +
21381 + .align PAGE_SIZE_asm
21382 +ENTRY(cpu_gdt_table)
21383 + .rept NR_CPUS
21384 + .quad 0x0000000000000000 /* NULL descriptor */
21385 + .quad 0x0000000000000000 /* 0x0b reserved */
21386 + .quad 0x0000000000000000 /* 0x13 reserved */
21387 + .quad 0x0000000000000000 /* 0x1b reserved */
21388 +
21389 +#ifdef CONFIG_PAX_KERNEXEC
21390 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
21391 +#else
21392 + .quad 0x0000000000000000 /* 0x20 unused */
21393 +#endif
21394 +
21395 + .quad 0x0000000000000000 /* 0x28 unused */
21396 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
21397 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
21398 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
21399 + .quad 0x0000000000000000 /* 0x4b reserved */
21400 + .quad 0x0000000000000000 /* 0x53 reserved */
21401 + .quad 0x0000000000000000 /* 0x5b reserved */
21402 +
21403 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
21404 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
21405 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
21406 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
21407 +
21408 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
21409 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
21410 +
21411 + /*
21412 + * Segments used for calling PnP BIOS have byte granularity.
21413 + * The code segments and data segments have fixed 64k limits,
21414 + * the transfer segment sizes are set at run time.
21415 + */
21416 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
21417 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
21418 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
21419 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
21420 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
21421 +
21422 + /*
21423 + * The APM segments have byte granularity and their bases
21424 + * are set at run time. All have 64k limits.
21425 + */
21426 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
21427 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
21428 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
21429 +
21430 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
21431 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
21432 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
21433 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
21434 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
21435 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
21436 +
21437 + /* Be sure this is zeroed to avoid false validations in Xen */
21438 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
21439 + .endr
21440 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
21441 index 980053c..74d3b44 100644
21442 --- a/arch/x86/kernel/head_64.S
21443 +++ b/arch/x86/kernel/head_64.S
21444 @@ -20,6 +20,8 @@
21445 #include <asm/processor-flags.h>
21446 #include <asm/percpu.h>
21447 #include <asm/nops.h>
21448 +#include <asm/cpufeature.h>
21449 +#include <asm/alternative-asm.h>
21450
21451 #ifdef CONFIG_PARAVIRT
21452 #include <asm/asm-offsets.h>
21453 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
21454 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
21455 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
21456 L3_START_KERNEL = pud_index(__START_KERNEL_map)
21457 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
21458 +L3_VMALLOC_START = pud_index(VMALLOC_START)
21459 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
21460 +L3_VMALLOC_END = pud_index(VMALLOC_END)
21461 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
21462 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
21463
21464 .text
21465 __HEAD
21466 @@ -88,35 +96,23 @@ startup_64:
21467 */
21468 addq %rbp, init_level4_pgt + 0(%rip)
21469 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
21470 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
21471 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
21472 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
21473 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
21474
21475 addq %rbp, level3_ident_pgt + 0(%rip)
21476 +#ifndef CONFIG_XEN
21477 + addq %rbp, level3_ident_pgt + 8(%rip)
21478 +#endif
21479
21480 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
21481 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
21482 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
21483 +
21484 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
21485 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
21486
21487 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
21488 -
21489 - /* Add an Identity mapping if I am above 1G */
21490 - leaq _text(%rip), %rdi
21491 - andq $PMD_PAGE_MASK, %rdi
21492 -
21493 - movq %rdi, %rax
21494 - shrq $PUD_SHIFT, %rax
21495 - andq $(PTRS_PER_PUD - 1), %rax
21496 - jz ident_complete
21497 -
21498 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
21499 - leaq level3_ident_pgt(%rip), %rbx
21500 - movq %rdx, 0(%rbx, %rax, 8)
21501 -
21502 - movq %rdi, %rax
21503 - shrq $PMD_SHIFT, %rax
21504 - andq $(PTRS_PER_PMD - 1), %rax
21505 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
21506 - leaq level2_spare_pgt(%rip), %rbx
21507 - movq %rdx, 0(%rbx, %rax, 8)
21508 -ident_complete:
21509 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
21510
21511 /*
21512 * Fixup the kernel text+data virtual addresses. Note that
21513 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
21514 * after the boot processor executes this code.
21515 */
21516
21517 - /* Enable PAE mode and PGE */
21518 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
21519 + /* Enable PAE mode and PSE/PGE */
21520 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
21521 movq %rax, %cr4
21522
21523 /* Setup early boot stage 4 level pagetables. */
21524 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
21525 movl $MSR_EFER, %ecx
21526 rdmsr
21527 btsl $_EFER_SCE, %eax /* Enable System Call */
21528 - btl $20,%edi /* No Execute supported? */
21529 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
21530 jnc 1f
21531 btsl $_EFER_NX, %eax
21532 + leaq init_level4_pgt(%rip), %rdi
21533 +#ifndef CONFIG_EFI
21534 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
21535 +#endif
21536 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
21537 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
21538 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
21539 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
21540 1: wrmsr /* Make changes effective */
21541
21542 /* Setup cr0 */
21543 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
21544 * jump. In addition we need to ensure %cs is set so we make this
21545 * a far return.
21546 */
21547 + pax_set_fptr_mask
21548 movq initial_code(%rip),%rax
21549 pushq $0 # fake return address to stop unwinder
21550 pushq $__KERNEL_CS # set correct cs
21551 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
21552 bad_address:
21553 jmp bad_address
21554
21555 - .section ".init.text","ax"
21556 + __INIT
21557 .globl early_idt_handlers
21558 early_idt_handlers:
21559 # 104(%rsp) %rflags
21560 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
21561 call dump_stack
21562 #ifdef CONFIG_KALLSYMS
21563 leaq early_idt_ripmsg(%rip),%rdi
21564 - movq 40(%rsp),%rsi # %rip again
21565 + movq 88(%rsp),%rsi # %rip again
21566 call __print_symbol
21567 #endif
21568 #endif /* EARLY_PRINTK */
21569 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
21570 addq $16,%rsp # drop vector number and error code
21571 decl early_recursion_flag(%rip)
21572 INTERRUPT_RETURN
21573 + .previous
21574
21575 + __INITDATA
21576 .balign 4
21577 early_recursion_flag:
21578 .long 0
21579 + .previous
21580
21581 + .section .rodata,"a",@progbits
21582 #ifdef CONFIG_EARLY_PRINTK
21583 early_idt_msg:
21584 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
21585 @@ -376,6 +385,7 @@ early_idt_ripmsg:
21586 #endif /* CONFIG_EARLY_PRINTK */
21587 .previous
21588
21589 + .section .rodata,"a",@progbits
21590 #define NEXT_PAGE(name) \
21591 .balign PAGE_SIZE; \
21592 ENTRY(name)
21593 @@ -388,7 +398,6 @@ ENTRY(name)
21594 i = i + 1 ; \
21595 .endr
21596
21597 - .data
21598 /*
21599 * This default setting generates an ident mapping at address 0x100000
21600 * and a mapping for the kernel that precisely maps virtual address
21601 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
21602 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21603 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
21604 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21605 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
21606 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
21607 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
21608 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
21609 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
21610 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
21611 .org init_level4_pgt + L4_START_KERNEL*8, 0
21612 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
21613 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
21614
21615 +#ifdef CONFIG_PAX_PER_CPU_PGD
21616 +NEXT_PAGE(cpu_pgd)
21617 + .rept NR_CPUS
21618 + .fill 512,8,0
21619 + .endr
21620 +#endif
21621 +
21622 NEXT_PAGE(level3_ident_pgt)
21623 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21624 +#ifdef CONFIG_XEN
21625 .fill 511,8,0
21626 +#else
21627 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
21628 + .fill 510,8,0
21629 +#endif
21630 +
21631 +NEXT_PAGE(level3_vmalloc_start_pgt)
21632 + .fill 512,8,0
21633 +
21634 +NEXT_PAGE(level3_vmalloc_end_pgt)
21635 + .fill 512,8,0
21636 +
21637 +NEXT_PAGE(level3_vmemmap_pgt)
21638 + .fill L3_VMEMMAP_START,8,0
21639 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
21640
21641 NEXT_PAGE(level3_kernel_pgt)
21642 .fill L3_START_KERNEL,8,0
21643 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
21644 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
21645 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21646
21647 +NEXT_PAGE(level2_vmemmap_pgt)
21648 + .fill 512,8,0
21649 +
21650 NEXT_PAGE(level2_fixmap_pgt)
21651 - .fill 506,8,0
21652 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21653 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
21654 - .fill 5,8,0
21655 + .fill 507,8,0
21656 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
21657 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
21658 + .fill 4,8,0
21659
21660 -NEXT_PAGE(level1_fixmap_pgt)
21661 +NEXT_PAGE(level1_vsyscall_pgt)
21662 .fill 512,8,0
21663
21664 -NEXT_PAGE(level2_ident_pgt)
21665 - /* Since I easily can, map the first 1G.
21666 + /* Since I easily can, map the first 2G.
21667 * Don't set NX because code runs from these pages.
21668 */
21669 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
21670 +NEXT_PAGE(level2_ident_pgt)
21671 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
21672
21673 NEXT_PAGE(level2_kernel_pgt)
21674 /*
21675 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
21676 * If you want to increase this then increase MODULES_VADDR
21677 * too.)
21678 */
21679 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
21680 - KERNEL_IMAGE_SIZE/PMD_SIZE)
21681 -
21682 -NEXT_PAGE(level2_spare_pgt)
21683 - .fill 512, 8, 0
21684 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
21685
21686 #undef PMDS
21687 #undef NEXT_PAGE
21688
21689 - .data
21690 + .align PAGE_SIZE
21691 +ENTRY(cpu_gdt_table)
21692 + .rept NR_CPUS
21693 + .quad 0x0000000000000000 /* NULL descriptor */
21694 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
21695 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
21696 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
21697 + .quad 0x00cffb000000ffff /* __USER32_CS */
21698 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
21699 + .quad 0x00affb000000ffff /* __USER_CS */
21700 +
21701 +#ifdef CONFIG_PAX_KERNEXEC
21702 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
21703 +#else
21704 + .quad 0x0 /* unused */
21705 +#endif
21706 +
21707 + .quad 0,0 /* TSS */
21708 + .quad 0,0 /* LDT */
21709 + .quad 0,0,0 /* three TLS descriptors */
21710 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
21711 + /* asm/segment.h:GDT_ENTRIES must match this */
21712 +
21713 + /* zero the remaining page */
21714 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
21715 + .endr
21716 +
21717 .align 16
21718 .globl early_gdt_descr
21719 early_gdt_descr:
21720 .word GDT_ENTRIES*8-1
21721 early_gdt_descr_base:
21722 - .quad INIT_PER_CPU_VAR(gdt_page)
21723 + .quad cpu_gdt_table
21724
21725 ENTRY(phys_base)
21726 /* This must match the first entry in level2_kernel_pgt */
21727 .quad 0x0000000000000000
21728
21729 #include "../../x86/xen/xen-head.S"
21730 -
21731 - .section .bss, "aw", @nobits
21732 +
21733 + .section .rodata,"a",@progbits
21734 .align L1_CACHE_BYTES
21735 ENTRY(idt_table)
21736 - .skip IDT_ENTRIES * 16
21737 + .fill 512,8,0
21738
21739 .align L1_CACHE_BYTES
21740 ENTRY(nmi_idt_table)
21741 - .skip IDT_ENTRIES * 16
21742 + .fill 512,8,0
21743
21744 __PAGE_ALIGNED_BSS
21745 .align PAGE_SIZE
21746 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
21747 index 9c3bd4a..e1d9b35 100644
21748 --- a/arch/x86/kernel/i386_ksyms_32.c
21749 +++ b/arch/x86/kernel/i386_ksyms_32.c
21750 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
21751 EXPORT_SYMBOL(cmpxchg8b_emu);
21752 #endif
21753
21754 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
21755 +
21756 /* Networking helper routines. */
21757 EXPORT_SYMBOL(csum_partial_copy_generic);
21758 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
21759 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
21760
21761 EXPORT_SYMBOL(__get_user_1);
21762 EXPORT_SYMBOL(__get_user_2);
21763 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
21764
21765 EXPORT_SYMBOL(csum_partial);
21766 EXPORT_SYMBOL(empty_zero_page);
21767 +
21768 +#ifdef CONFIG_PAX_KERNEXEC
21769 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
21770 +#endif
21771 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
21772 index 245a71d..89d9ce4 100644
21773 --- a/arch/x86/kernel/i387.c
21774 +++ b/arch/x86/kernel/i387.c
21775 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
21776 static inline bool interrupted_user_mode(void)
21777 {
21778 struct pt_regs *regs = get_irq_regs();
21779 - return regs && user_mode_vm(regs);
21780 + return regs && user_mode(regs);
21781 }
21782
21783 /*
21784 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
21785 index 9a5c460..b332a4b 100644
21786 --- a/arch/x86/kernel/i8259.c
21787 +++ b/arch/x86/kernel/i8259.c
21788 @@ -209,7 +209,7 @@ spurious_8259A_irq:
21789 "spurious 8259A interrupt: IRQ%d.\n", irq);
21790 spurious_irq_mask |= irqmask;
21791 }
21792 - atomic_inc(&irq_err_count);
21793 + atomic_inc_unchecked(&irq_err_count);
21794 /*
21795 * Theoretically we do not have to handle this IRQ,
21796 * but in Linux this does not cause problems and is
21797 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
21798 /* (slave's support for AEOI in flat mode is to be investigated) */
21799 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
21800
21801 + pax_open_kernel();
21802 if (auto_eoi)
21803 /*
21804 * In AEOI mode we just have to mask the interrupt
21805 * when acking.
21806 */
21807 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
21808 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
21809 else
21810 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21811 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21812 + pax_close_kernel();
21813
21814 udelay(100); /* wait for 8259A to initialize */
21815
21816 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
21817 index a979b5b..1d6db75 100644
21818 --- a/arch/x86/kernel/io_delay.c
21819 +++ b/arch/x86/kernel/io_delay.c
21820 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
21821 * Quirk table for systems that misbehave (lock up, etc.) if port
21822 * 0x80 is used:
21823 */
21824 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
21825 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
21826 {
21827 .callback = dmi_io_delay_0xed_port,
21828 .ident = "Compaq Presario V6000",
21829 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
21830 index 8c96897..be66bfa 100644
21831 --- a/arch/x86/kernel/ioport.c
21832 +++ b/arch/x86/kernel/ioport.c
21833 @@ -6,6 +6,7 @@
21834 #include <linux/sched.h>
21835 #include <linux/kernel.h>
21836 #include <linux/capability.h>
21837 +#include <linux/security.h>
21838 #include <linux/errno.h>
21839 #include <linux/types.h>
21840 #include <linux/ioport.h>
21841 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21842
21843 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
21844 return -EINVAL;
21845 +#ifdef CONFIG_GRKERNSEC_IO
21846 + if (turn_on && grsec_disable_privio) {
21847 + gr_handle_ioperm();
21848 + return -EPERM;
21849 + }
21850 +#endif
21851 if (turn_on && !capable(CAP_SYS_RAWIO))
21852 return -EPERM;
21853
21854 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21855 * because the ->io_bitmap_max value must match the bitmap
21856 * contents:
21857 */
21858 - tss = &per_cpu(init_tss, get_cpu());
21859 + tss = init_tss + get_cpu();
21860
21861 if (turn_on)
21862 bitmap_clear(t->io_bitmap_ptr, from, num);
21863 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
21864 return -EINVAL;
21865 /* Trying to gain more privileges? */
21866 if (level > old) {
21867 +#ifdef CONFIG_GRKERNSEC_IO
21868 + if (grsec_disable_privio) {
21869 + gr_handle_iopl();
21870 + return -EPERM;
21871 + }
21872 +#endif
21873 if (!capable(CAP_SYS_RAWIO))
21874 return -EPERM;
21875 }
21876 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21877 index e4595f1..ee3bfb8 100644
21878 --- a/arch/x86/kernel/irq.c
21879 +++ b/arch/x86/kernel/irq.c
21880 @@ -18,7 +18,7 @@
21881 #include <asm/mce.h>
21882 #include <asm/hw_irq.h>
21883
21884 -atomic_t irq_err_count;
21885 +atomic_unchecked_t irq_err_count;
21886
21887 /* Function pointer for generic interrupt vector handling */
21888 void (*x86_platform_ipi_callback)(void) = NULL;
21889 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21890 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21891 seq_printf(p, " Machine check polls\n");
21892 #endif
21893 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21894 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21895 #if defined(CONFIG_X86_IO_APIC)
21896 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21897 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21898 #endif
21899 return 0;
21900 }
21901 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21902
21903 u64 arch_irq_stat(void)
21904 {
21905 - u64 sum = atomic_read(&irq_err_count);
21906 + u64 sum = atomic_read_unchecked(&irq_err_count);
21907
21908 #ifdef CONFIG_X86_IO_APIC
21909 - sum += atomic_read(&irq_mis_count);
21910 + sum += atomic_read_unchecked(&irq_mis_count);
21911 #endif
21912 return sum;
21913 }
21914 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21915 index 344faf8..355f60d 100644
21916 --- a/arch/x86/kernel/irq_32.c
21917 +++ b/arch/x86/kernel/irq_32.c
21918 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21919 __asm__ __volatile__("andl %%esp,%0" :
21920 "=r" (sp) : "0" (THREAD_SIZE - 1));
21921
21922 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21923 + return sp < STACK_WARN;
21924 }
21925
21926 static void print_stack_overflow(void)
21927 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21928 * per-CPU IRQ handling contexts (thread information and stack)
21929 */
21930 union irq_ctx {
21931 - struct thread_info tinfo;
21932 - u32 stack[THREAD_SIZE/sizeof(u32)];
21933 + unsigned long previous_esp;
21934 + u32 stack[THREAD_SIZE/sizeof(u32)];
21935 } __attribute__((aligned(THREAD_SIZE)));
21936
21937 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21938 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21939 static inline int
21940 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21941 {
21942 - union irq_ctx *curctx, *irqctx;
21943 + union irq_ctx *irqctx;
21944 u32 *isp, arg1, arg2;
21945
21946 - curctx = (union irq_ctx *) current_thread_info();
21947 irqctx = __this_cpu_read(hardirq_ctx);
21948
21949 /*
21950 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21951 * handler) we can't do that and just have to keep using the
21952 * current stack (which is the irq stack already after all)
21953 */
21954 - if (unlikely(curctx == irqctx))
21955 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21956 return 0;
21957
21958 /* build the stack frame on the IRQ stack */
21959 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21960 - irqctx->tinfo.task = curctx->tinfo.task;
21961 - irqctx->tinfo.previous_esp = current_stack_pointer;
21962 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21963 + irqctx->previous_esp = current_stack_pointer;
21964
21965 - /* Copy the preempt_count so that the [soft]irq checks work. */
21966 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21967 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21968 + __set_fs(MAKE_MM_SEG(0));
21969 +#endif
21970
21971 if (unlikely(overflow))
21972 call_on_stack(print_stack_overflow, isp);
21973 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21974 : "0" (irq), "1" (desc), "2" (isp),
21975 "D" (desc->handle_irq)
21976 : "memory", "cc", "ecx");
21977 +
21978 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21979 + __set_fs(current_thread_info()->addr_limit);
21980 +#endif
21981 +
21982 return 1;
21983 }
21984
21985 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21986 */
21987 void __cpuinit irq_ctx_init(int cpu)
21988 {
21989 - union irq_ctx *irqctx;
21990 -
21991 if (per_cpu(hardirq_ctx, cpu))
21992 return;
21993
21994 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21995 - THREADINFO_GFP,
21996 - THREAD_SIZE_ORDER));
21997 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21998 - irqctx->tinfo.cpu = cpu;
21999 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
22000 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
22001 -
22002 - per_cpu(hardirq_ctx, cpu) = irqctx;
22003 -
22004 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
22005 - THREADINFO_GFP,
22006 - THREAD_SIZE_ORDER));
22007 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
22008 - irqctx->tinfo.cpu = cpu;
22009 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
22010 -
22011 - per_cpu(softirq_ctx, cpu) = irqctx;
22012 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
22013 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
22014 +
22015 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
22016 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
22017
22018 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
22019 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
22020 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
22021 asmlinkage void do_softirq(void)
22022 {
22023 unsigned long flags;
22024 - struct thread_info *curctx;
22025 union irq_ctx *irqctx;
22026 u32 *isp;
22027
22028 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
22029 local_irq_save(flags);
22030
22031 if (local_softirq_pending()) {
22032 - curctx = current_thread_info();
22033 irqctx = __this_cpu_read(softirq_ctx);
22034 - irqctx->tinfo.task = curctx->task;
22035 - irqctx->tinfo.previous_esp = current_stack_pointer;
22036 + irqctx->previous_esp = current_stack_pointer;
22037
22038 /* build the stack frame on the softirq stack */
22039 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
22040 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
22041 +
22042 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22043 + __set_fs(MAKE_MM_SEG(0));
22044 +#endif
22045
22046 call_on_stack(__do_softirq, isp);
22047 +
22048 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22049 + __set_fs(current_thread_info()->addr_limit);
22050 +#endif
22051 +
22052 /*
22053 * Shouldn't happen, we returned above if in_interrupt():
22054 */
22055 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
22056 if (unlikely(!desc))
22057 return false;
22058
22059 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
22060 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
22061 if (unlikely(overflow))
22062 print_stack_overflow();
22063 desc->handle_irq(irq, desc);
22064 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
22065 index d04d3ec..ea4b374 100644
22066 --- a/arch/x86/kernel/irq_64.c
22067 +++ b/arch/x86/kernel/irq_64.c
22068 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
22069 u64 estack_top, estack_bottom;
22070 u64 curbase = (u64)task_stack_page(current);
22071
22072 - if (user_mode_vm(regs))
22073 + if (user_mode(regs))
22074 return;
22075
22076 if (regs->sp >= curbase + sizeof(struct thread_info) +
22077 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
22078 index dc1404b..bbc43e7 100644
22079 --- a/arch/x86/kernel/kdebugfs.c
22080 +++ b/arch/x86/kernel/kdebugfs.c
22081 @@ -27,7 +27,7 @@ struct setup_data_node {
22082 u32 len;
22083 };
22084
22085 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
22086 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
22087 size_t count, loff_t *ppos)
22088 {
22089 struct setup_data_node *node = file->private_data;
22090 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
22091 index 836f832..a8bda67 100644
22092 --- a/arch/x86/kernel/kgdb.c
22093 +++ b/arch/x86/kernel/kgdb.c
22094 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
22095 #ifdef CONFIG_X86_32
22096 switch (regno) {
22097 case GDB_SS:
22098 - if (!user_mode_vm(regs))
22099 + if (!user_mode(regs))
22100 *(unsigned long *)mem = __KERNEL_DS;
22101 break;
22102 case GDB_SP:
22103 - if (!user_mode_vm(regs))
22104 + if (!user_mode(regs))
22105 *(unsigned long *)mem = kernel_stack_pointer(regs);
22106 break;
22107 case GDB_GS:
22108 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
22109 bp->attr.bp_addr = breakinfo[breakno].addr;
22110 bp->attr.bp_len = breakinfo[breakno].len;
22111 bp->attr.bp_type = breakinfo[breakno].type;
22112 - info->address = breakinfo[breakno].addr;
22113 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
22114 + info->address = ktla_ktva(breakinfo[breakno].addr);
22115 + else
22116 + info->address = breakinfo[breakno].addr;
22117 info->len = breakinfo[breakno].len;
22118 info->type = breakinfo[breakno].type;
22119 val = arch_install_hw_breakpoint(bp);
22120 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
22121 case 'k':
22122 /* clear the trace bit */
22123 linux_regs->flags &= ~X86_EFLAGS_TF;
22124 - atomic_set(&kgdb_cpu_doing_single_step, -1);
22125 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
22126
22127 /* set the trace bit if we're stepping */
22128 if (remcomInBuffer[0] == 's') {
22129 linux_regs->flags |= X86_EFLAGS_TF;
22130 - atomic_set(&kgdb_cpu_doing_single_step,
22131 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
22132 raw_smp_processor_id());
22133 }
22134
22135 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
22136
22137 switch (cmd) {
22138 case DIE_DEBUG:
22139 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
22140 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
22141 if (user_mode(regs))
22142 return single_step_cont(regs, args);
22143 break;
22144 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
22145 #endif /* CONFIG_DEBUG_RODATA */
22146
22147 bpt->type = BP_BREAKPOINT;
22148 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
22149 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
22150 BREAK_INSTR_SIZE);
22151 if (err)
22152 return err;
22153 - err = probe_kernel_write((char *)bpt->bpt_addr,
22154 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
22155 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
22156 #ifdef CONFIG_DEBUG_RODATA
22157 if (!err)
22158 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
22159 return -EBUSY;
22160 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
22161 BREAK_INSTR_SIZE);
22162 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
22163 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
22164 if (err)
22165 return err;
22166 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
22167 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
22168 if (mutex_is_locked(&text_mutex))
22169 goto knl_write;
22170 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
22171 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
22172 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
22173 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
22174 goto knl_write;
22175 return err;
22176 knl_write:
22177 #endif /* CONFIG_DEBUG_RODATA */
22178 - return probe_kernel_write((char *)bpt->bpt_addr,
22179 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
22180 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
22181 }
22182
22183 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
22184 index c5e410e..ed5a7f0 100644
22185 --- a/arch/x86/kernel/kprobes-opt.c
22186 +++ b/arch/x86/kernel/kprobes-opt.c
22187 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
22188 * Verify if the address gap is in 2GB range, because this uses
22189 * a relative jump.
22190 */
22191 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
22192 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
22193 if (abs(rel) > 0x7fffffff)
22194 return -ERANGE;
22195
22196 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
22197 op->optinsn.size = ret;
22198
22199 /* Copy arch-dep-instance from template */
22200 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
22201 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
22202
22203 /* Set probe information */
22204 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
22205
22206 /* Set probe function call */
22207 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
22208 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
22209
22210 /* Set returning jmp instruction at the tail of out-of-line buffer */
22211 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
22212 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
22213 (u8 *)op->kp.addr + op->optinsn.size);
22214
22215 flush_icache_range((unsigned long) buf,
22216 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
22217 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
22218
22219 /* Backup instructions which will be replaced by jump address */
22220 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
22221 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
22222 RELATIVE_ADDR_SIZE);
22223
22224 insn_buf[0] = RELATIVEJUMP_OPCODE;
22225 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
22226 /* This kprobe is really able to run optimized path. */
22227 op = container_of(p, struct optimized_kprobe, kp);
22228 /* Detour through copied instructions */
22229 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
22230 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
22231 if (!reenter)
22232 reset_current_kprobe();
22233 preempt_enable_no_resched();
22234 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
22235 index 57916c0..9e0b9d0 100644
22236 --- a/arch/x86/kernel/kprobes.c
22237 +++ b/arch/x86/kernel/kprobes.c
22238 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
22239 s32 raddr;
22240 } __attribute__((packed)) *insn;
22241
22242 - insn = (struct __arch_relative_insn *)from;
22243 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
22244 +
22245 + pax_open_kernel();
22246 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
22247 insn->op = op;
22248 + pax_close_kernel();
22249 }
22250
22251 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
22252 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
22253 kprobe_opcode_t opcode;
22254 kprobe_opcode_t *orig_opcodes = opcodes;
22255
22256 - if (search_exception_tables((unsigned long)opcodes))
22257 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
22258 return 0; /* Page fault may occur on this address. */
22259
22260 retry:
22261 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
22262 * for the first byte, we can recover the original instruction
22263 * from it and kp->opcode.
22264 */
22265 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
22266 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
22267 buf[0] = kp->opcode;
22268 - return (unsigned long)buf;
22269 + return ktva_ktla((unsigned long)buf);
22270 }
22271
22272 /*
22273 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
22274 /* Another subsystem puts a breakpoint, failed to recover */
22275 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
22276 return 0;
22277 + pax_open_kernel();
22278 memcpy(dest, insn.kaddr, insn.length);
22279 + pax_close_kernel();
22280
22281 #ifdef CONFIG_X86_64
22282 if (insn_rip_relative(&insn)) {
22283 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
22284 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
22285 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
22286 disp = (u8 *) dest + insn_offset_displacement(&insn);
22287 + pax_open_kernel();
22288 *(s32 *) disp = (s32) newdisp;
22289 + pax_close_kernel();
22290 }
22291 #endif
22292 return insn.length;
22293 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
22294 * nor set current_kprobe, because it doesn't use single
22295 * stepping.
22296 */
22297 - regs->ip = (unsigned long)p->ainsn.insn;
22298 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
22299 preempt_enable_no_resched();
22300 return;
22301 }
22302 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
22303 regs->flags &= ~X86_EFLAGS_IF;
22304 /* single step inline if the instruction is an int3 */
22305 if (p->opcode == BREAKPOINT_INSTRUCTION)
22306 - regs->ip = (unsigned long)p->addr;
22307 + regs->ip = ktla_ktva((unsigned long)p->addr);
22308 else
22309 - regs->ip = (unsigned long)p->ainsn.insn;
22310 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
22311 }
22312
22313 /*
22314 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
22315 setup_singlestep(p, regs, kcb, 0);
22316 return 1;
22317 }
22318 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
22319 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
22320 /*
22321 * The breakpoint instruction was removed right
22322 * after we hit it. Another cpu has removed
22323 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
22324 " movq %rax, 152(%rsp)\n"
22325 RESTORE_REGS_STRING
22326 " popfq\n"
22327 +#ifdef KERNEXEC_PLUGIN
22328 + " btsq $63,(%rsp)\n"
22329 +#endif
22330 #else
22331 " pushf\n"
22332 SAVE_REGS_STRING
22333 @@ -788,7 +798,7 @@ static void __kprobes
22334 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
22335 {
22336 unsigned long *tos = stack_addr(regs);
22337 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
22338 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
22339 unsigned long orig_ip = (unsigned long)p->addr;
22340 kprobe_opcode_t *insn = p->ainsn.insn;
22341
22342 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
22343 struct die_args *args = data;
22344 int ret = NOTIFY_DONE;
22345
22346 - if (args->regs && user_mode_vm(args->regs))
22347 + if (args->regs && user_mode(args->regs))
22348 return ret;
22349
22350 switch (val) {
22351 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
22352 index 9c2bd8b..bb1131c 100644
22353 --- a/arch/x86/kernel/kvm.c
22354 +++ b/arch/x86/kernel/kvm.c
22355 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
22356 return NOTIFY_OK;
22357 }
22358
22359 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
22360 +static struct notifier_block kvm_cpu_notifier = {
22361 .notifier_call = kvm_cpu_notify,
22362 };
22363 #endif
22364 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
22365 index ebc9873..1b9724b 100644
22366 --- a/arch/x86/kernel/ldt.c
22367 +++ b/arch/x86/kernel/ldt.c
22368 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
22369 if (reload) {
22370 #ifdef CONFIG_SMP
22371 preempt_disable();
22372 - load_LDT(pc);
22373 + load_LDT_nolock(pc);
22374 if (!cpumask_equal(mm_cpumask(current->mm),
22375 cpumask_of(smp_processor_id())))
22376 smp_call_function(flush_ldt, current->mm, 1);
22377 preempt_enable();
22378 #else
22379 - load_LDT(pc);
22380 + load_LDT_nolock(pc);
22381 #endif
22382 }
22383 if (oldsize) {
22384 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
22385 return err;
22386
22387 for (i = 0; i < old->size; i++)
22388 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
22389 + write_ldt_entry(new->ldt, i, old->ldt + i);
22390 return 0;
22391 }
22392
22393 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
22394 retval = copy_ldt(&mm->context, &old_mm->context);
22395 mutex_unlock(&old_mm->context.lock);
22396 }
22397 +
22398 + if (tsk == current) {
22399 + mm->context.vdso = 0;
22400 +
22401 +#ifdef CONFIG_X86_32
22402 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
22403 + mm->context.user_cs_base = 0UL;
22404 + mm->context.user_cs_limit = ~0UL;
22405 +
22406 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
22407 + cpus_clear(mm->context.cpu_user_cs_mask);
22408 +#endif
22409 +
22410 +#endif
22411 +#endif
22412 +
22413 + }
22414 +
22415 return retval;
22416 }
22417
22418 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
22419 }
22420 }
22421
22422 +#ifdef CONFIG_PAX_SEGMEXEC
22423 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
22424 + error = -EINVAL;
22425 + goto out_unlock;
22426 + }
22427 +#endif
22428 +
22429 fill_ldt(&ldt, &ldt_info);
22430 if (oldmode)
22431 ldt.avl = 0;
22432 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
22433 index 5b19e4d..6476a76 100644
22434 --- a/arch/x86/kernel/machine_kexec_32.c
22435 +++ b/arch/x86/kernel/machine_kexec_32.c
22436 @@ -26,7 +26,7 @@
22437 #include <asm/cacheflush.h>
22438 #include <asm/debugreg.h>
22439
22440 -static void set_idt(void *newidt, __u16 limit)
22441 +static void set_idt(struct desc_struct *newidt, __u16 limit)
22442 {
22443 struct desc_ptr curidt;
22444
22445 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
22446 }
22447
22448
22449 -static void set_gdt(void *newgdt, __u16 limit)
22450 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
22451 {
22452 struct desc_ptr curgdt;
22453
22454 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
22455 }
22456
22457 control_page = page_address(image->control_code_page);
22458 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
22459 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
22460
22461 relocate_kernel_ptr = control_page;
22462 page_list[PA_CONTROL_PAGE] = __pa(control_page);
22463 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
22464 index 3a04b22..1d2eb09 100644
22465 --- a/arch/x86/kernel/microcode_core.c
22466 +++ b/arch/x86/kernel/microcode_core.c
22467 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
22468 return NOTIFY_OK;
22469 }
22470
22471 -static struct notifier_block __refdata mc_cpu_notifier = {
22472 +static struct notifier_block mc_cpu_notifier = {
22473 .notifier_call = mc_cpu_callback,
22474 };
22475
22476 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
22477 index 3544aed..01ddc1c 100644
22478 --- a/arch/x86/kernel/microcode_intel.c
22479 +++ b/arch/x86/kernel/microcode_intel.c
22480 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
22481
22482 static int get_ucode_user(void *to, const void *from, size_t n)
22483 {
22484 - return copy_from_user(to, from, n);
22485 + return copy_from_user(to, (const void __force_user *)from, n);
22486 }
22487
22488 static enum ucode_state
22489 request_microcode_user(int cpu, const void __user *buf, size_t size)
22490 {
22491 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
22492 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
22493 }
22494
22495 static void microcode_fini_cpu(int cpu)
22496 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
22497 index 216a4d7..228255a 100644
22498 --- a/arch/x86/kernel/module.c
22499 +++ b/arch/x86/kernel/module.c
22500 @@ -43,15 +43,60 @@ do { \
22501 } while (0)
22502 #endif
22503
22504 -void *module_alloc(unsigned long size)
22505 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
22506 {
22507 - if (PAGE_ALIGN(size) > MODULES_LEN)
22508 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
22509 return NULL;
22510 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
22511 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
22512 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
22513 -1, __builtin_return_address(0));
22514 }
22515
22516 +void *module_alloc(unsigned long size)
22517 +{
22518 +
22519 +#ifdef CONFIG_PAX_KERNEXEC
22520 + return __module_alloc(size, PAGE_KERNEL);
22521 +#else
22522 + return __module_alloc(size, PAGE_KERNEL_EXEC);
22523 +#endif
22524 +
22525 +}
22526 +
22527 +#ifdef CONFIG_PAX_KERNEXEC
22528 +#ifdef CONFIG_X86_32
22529 +void *module_alloc_exec(unsigned long size)
22530 +{
22531 + struct vm_struct *area;
22532 +
22533 + if (size == 0)
22534 + return NULL;
22535 +
22536 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
22537 + return area ? area->addr : NULL;
22538 +}
22539 +EXPORT_SYMBOL(module_alloc_exec);
22540 +
22541 +void module_free_exec(struct module *mod, void *module_region)
22542 +{
22543 + vunmap(module_region);
22544 +}
22545 +EXPORT_SYMBOL(module_free_exec);
22546 +#else
22547 +void module_free_exec(struct module *mod, void *module_region)
22548 +{
22549 + module_free(mod, module_region);
22550 +}
22551 +EXPORT_SYMBOL(module_free_exec);
22552 +
22553 +void *module_alloc_exec(unsigned long size)
22554 +{
22555 + return __module_alloc(size, PAGE_KERNEL_RX);
22556 +}
22557 +EXPORT_SYMBOL(module_alloc_exec);
22558 +#endif
22559 +#endif
22560 +
22561 #ifdef CONFIG_X86_32
22562 int apply_relocate(Elf32_Shdr *sechdrs,
22563 const char *strtab,
22564 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
22565 unsigned int i;
22566 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
22567 Elf32_Sym *sym;
22568 - uint32_t *location;
22569 + uint32_t *plocation, location;
22570
22571 DEBUGP("Applying relocate section %u to %u\n",
22572 relsec, sechdrs[relsec].sh_info);
22573 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
22574 /* This is where to make the change */
22575 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
22576 - + rel[i].r_offset;
22577 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
22578 + location = (uint32_t)plocation;
22579 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
22580 + plocation = ktla_ktva((void *)plocation);
22581 /* This is the symbol it is referring to. Note that all
22582 undefined symbols have been resolved. */
22583 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
22584 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
22585 switch (ELF32_R_TYPE(rel[i].r_info)) {
22586 case R_386_32:
22587 /* We add the value into the location given */
22588 - *location += sym->st_value;
22589 + pax_open_kernel();
22590 + *plocation += sym->st_value;
22591 + pax_close_kernel();
22592 break;
22593 case R_386_PC32:
22594 /* Add the value, subtract its position */
22595 - *location += sym->st_value - (uint32_t)location;
22596 + pax_open_kernel();
22597 + *plocation += sym->st_value - location;
22598 + pax_close_kernel();
22599 break;
22600 default:
22601 pr_err("%s: Unknown relocation: %u\n",
22602 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
22603 case R_X86_64_NONE:
22604 break;
22605 case R_X86_64_64:
22606 + pax_open_kernel();
22607 *(u64 *)loc = val;
22608 + pax_close_kernel();
22609 break;
22610 case R_X86_64_32:
22611 + pax_open_kernel();
22612 *(u32 *)loc = val;
22613 + pax_close_kernel();
22614 if (val != *(u32 *)loc)
22615 goto overflow;
22616 break;
22617 case R_X86_64_32S:
22618 + pax_open_kernel();
22619 *(s32 *)loc = val;
22620 + pax_close_kernel();
22621 if ((s64)val != *(s32 *)loc)
22622 goto overflow;
22623 break;
22624 case R_X86_64_PC32:
22625 val -= (u64)loc;
22626 + pax_open_kernel();
22627 *(u32 *)loc = val;
22628 + pax_close_kernel();
22629 +
22630 #if 0
22631 if ((s64)val != *(s32 *)loc)
22632 goto overflow;
22633 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
22634 index 4929502..686c291 100644
22635 --- a/arch/x86/kernel/msr.c
22636 +++ b/arch/x86/kernel/msr.c
22637 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
22638 return notifier_from_errno(err);
22639 }
22640
22641 -static struct notifier_block __refdata msr_class_cpu_notifier = {
22642 +static struct notifier_block msr_class_cpu_notifier = {
22643 .notifier_call = msr_class_cpu_callback,
22644 };
22645
22646 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
22647 index f84f5c5..f404e81 100644
22648 --- a/arch/x86/kernel/nmi.c
22649 +++ b/arch/x86/kernel/nmi.c
22650 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
22651 return handled;
22652 }
22653
22654 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22655 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
22656 {
22657 struct nmi_desc *desc = nmi_to_desc(type);
22658 unsigned long flags;
22659 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22660 * event confuses some handlers (kdump uses this flag)
22661 */
22662 if (action->flags & NMI_FLAG_FIRST)
22663 - list_add_rcu(&action->list, &desc->head);
22664 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
22665 else
22666 - list_add_tail_rcu(&action->list, &desc->head);
22667 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
22668
22669 spin_unlock_irqrestore(&desc->lock, flags);
22670 return 0;
22671 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
22672 if (!strcmp(n->name, name)) {
22673 WARN(in_nmi(),
22674 "Trying to free NMI (%s) from NMI context!\n", n->name);
22675 - list_del_rcu(&n->list);
22676 + pax_list_del_rcu((struct list_head *)&n->list);
22677 break;
22678 }
22679 }
22680 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
22681 dotraplinkage notrace __kprobes void
22682 do_nmi(struct pt_regs *regs, long error_code)
22683 {
22684 +
22685 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
22686 + if (!user_mode(regs)) {
22687 + unsigned long cs = regs->cs & 0xFFFF;
22688 + unsigned long ip = ktva_ktla(regs->ip);
22689 +
22690 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
22691 + regs->ip = ip;
22692 + }
22693 +#endif
22694 +
22695 nmi_nesting_preprocess(regs);
22696
22697 nmi_enter();
22698 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
22699 index 6d9582e..f746287 100644
22700 --- a/arch/x86/kernel/nmi_selftest.c
22701 +++ b/arch/x86/kernel/nmi_selftest.c
22702 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
22703 {
22704 /* trap all the unknown NMIs we may generate */
22705 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
22706 - __initdata);
22707 + __initconst);
22708 }
22709
22710 static void __init cleanup_nmi_testsuite(void)
22711 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
22712 unsigned long timeout;
22713
22714 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
22715 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
22716 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
22717 nmi_fail = FAILURE;
22718 return;
22719 }
22720 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
22721 index 676b8c7..870ba04 100644
22722 --- a/arch/x86/kernel/paravirt-spinlocks.c
22723 +++ b/arch/x86/kernel/paravirt-spinlocks.c
22724 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
22725 arch_spin_lock(lock);
22726 }
22727
22728 -struct pv_lock_ops pv_lock_ops = {
22729 +struct pv_lock_ops pv_lock_ops __read_only = {
22730 #ifdef CONFIG_SMP
22731 .spin_is_locked = __ticket_spin_is_locked,
22732 .spin_is_contended = __ticket_spin_is_contended,
22733 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
22734 index 8bfb335..c1463c6 100644
22735 --- a/arch/x86/kernel/paravirt.c
22736 +++ b/arch/x86/kernel/paravirt.c
22737 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
22738 {
22739 return x;
22740 }
22741 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22742 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
22743 +#endif
22744
22745 void __init default_banner(void)
22746 {
22747 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
22748 if (opfunc == NULL)
22749 /* If there's no function, patch it with a ud2a (BUG) */
22750 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
22751 - else if (opfunc == _paravirt_nop)
22752 + else if (opfunc == (void *)_paravirt_nop)
22753 /* If the operation is a nop, then nop the callsite */
22754 ret = paravirt_patch_nop();
22755
22756 /* identity functions just return their single argument */
22757 - else if (opfunc == _paravirt_ident_32)
22758 + else if (opfunc == (void *)_paravirt_ident_32)
22759 ret = paravirt_patch_ident_32(insnbuf, len);
22760 - else if (opfunc == _paravirt_ident_64)
22761 + else if (opfunc == (void *)_paravirt_ident_64)
22762 ret = paravirt_patch_ident_64(insnbuf, len);
22763 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22764 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
22765 + ret = paravirt_patch_ident_64(insnbuf, len);
22766 +#endif
22767
22768 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
22769 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
22770 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
22771 if (insn_len > len || start == NULL)
22772 insn_len = len;
22773 else
22774 - memcpy(insnbuf, start, insn_len);
22775 + memcpy(insnbuf, ktla_ktva(start), insn_len);
22776
22777 return insn_len;
22778 }
22779 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
22780 return this_cpu_read(paravirt_lazy_mode);
22781 }
22782
22783 -struct pv_info pv_info = {
22784 +struct pv_info pv_info __read_only = {
22785 .name = "bare hardware",
22786 .paravirt_enabled = 0,
22787 .kernel_rpl = 0,
22788 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
22789 #endif
22790 };
22791
22792 -struct pv_init_ops pv_init_ops = {
22793 +struct pv_init_ops pv_init_ops __read_only = {
22794 .patch = native_patch,
22795 };
22796
22797 -struct pv_time_ops pv_time_ops = {
22798 +struct pv_time_ops pv_time_ops __read_only = {
22799 .sched_clock = native_sched_clock,
22800 .steal_clock = native_steal_clock,
22801 };
22802
22803 -struct pv_irq_ops pv_irq_ops = {
22804 +struct pv_irq_ops pv_irq_ops __read_only = {
22805 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
22806 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
22807 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
22808 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
22809 #endif
22810 };
22811
22812 -struct pv_cpu_ops pv_cpu_ops = {
22813 +struct pv_cpu_ops pv_cpu_ops __read_only = {
22814 .cpuid = native_cpuid,
22815 .get_debugreg = native_get_debugreg,
22816 .set_debugreg = native_set_debugreg,
22817 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
22818 .end_context_switch = paravirt_nop,
22819 };
22820
22821 -struct pv_apic_ops pv_apic_ops = {
22822 +struct pv_apic_ops pv_apic_ops __read_only= {
22823 #ifdef CONFIG_X86_LOCAL_APIC
22824 .startup_ipi_hook = paravirt_nop,
22825 #endif
22826 };
22827
22828 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
22829 +#ifdef CONFIG_X86_32
22830 +#ifdef CONFIG_X86_PAE
22831 +/* 64-bit pagetable entries */
22832 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
22833 +#else
22834 /* 32-bit pagetable entries */
22835 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
22836 +#endif
22837 #else
22838 /* 64-bit pagetable entries */
22839 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22840 #endif
22841
22842 -struct pv_mmu_ops pv_mmu_ops = {
22843 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22844
22845 .read_cr2 = native_read_cr2,
22846 .write_cr2 = native_write_cr2,
22847 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22848 .make_pud = PTE_IDENT,
22849
22850 .set_pgd = native_set_pgd,
22851 + .set_pgd_batched = native_set_pgd_batched,
22852 #endif
22853 #endif /* PAGETABLE_LEVELS >= 3 */
22854
22855 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22856 },
22857
22858 .set_fixmap = native_set_fixmap,
22859 +
22860 +#ifdef CONFIG_PAX_KERNEXEC
22861 + .pax_open_kernel = native_pax_open_kernel,
22862 + .pax_close_kernel = native_pax_close_kernel,
22863 +#endif
22864 +
22865 };
22866
22867 EXPORT_SYMBOL_GPL(pv_time_ops);
22868 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22869 index 35ccf75..7a15747 100644
22870 --- a/arch/x86/kernel/pci-iommu_table.c
22871 +++ b/arch/x86/kernel/pci-iommu_table.c
22872 @@ -2,7 +2,7 @@
22873 #include <asm/iommu_table.h>
22874 #include <linux/string.h>
22875 #include <linux/kallsyms.h>
22876 -
22877 +#include <linux/sched.h>
22878
22879 #define DEBUG 1
22880
22881 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22882 index 6c483ba..d10ce2f 100644
22883 --- a/arch/x86/kernel/pci-swiotlb.c
22884 +++ b/arch/x86/kernel/pci-swiotlb.c
22885 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22886 void *vaddr, dma_addr_t dma_addr,
22887 struct dma_attrs *attrs)
22888 {
22889 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22890 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22891 }
22892
22893 static struct dma_map_ops swiotlb_dma_ops = {
22894 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22895 index 2ed787f..f70c9f6 100644
22896 --- a/arch/x86/kernel/process.c
22897 +++ b/arch/x86/kernel/process.c
22898 @@ -36,7 +36,8 @@
22899 * section. Since TSS's are completely CPU-local, we want them
22900 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22901 */
22902 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22903 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22904 +EXPORT_SYMBOL(init_tss);
22905
22906 #ifdef CONFIG_X86_64
22907 static DEFINE_PER_CPU(unsigned char, is_idle);
22908 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22909 task_xstate_cachep =
22910 kmem_cache_create("task_xstate", xstate_size,
22911 __alignof__(union thread_xstate),
22912 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22913 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22914 }
22915
22916 /*
22917 @@ -105,7 +106,7 @@ void exit_thread(void)
22918 unsigned long *bp = t->io_bitmap_ptr;
22919
22920 if (bp) {
22921 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22922 + struct tss_struct *tss = init_tss + get_cpu();
22923
22924 t->io_bitmap_ptr = NULL;
22925 clear_thread_flag(TIF_IO_BITMAP);
22926 @@ -136,7 +137,7 @@ void show_regs_common(void)
22927 board = dmi_get_system_info(DMI_BOARD_NAME);
22928
22929 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22930 - current->pid, current->comm, print_tainted(),
22931 + task_pid_nr(current), current->comm, print_tainted(),
22932 init_utsname()->release,
22933 (int)strcspn(init_utsname()->version, " "),
22934 init_utsname()->version,
22935 @@ -149,6 +150,9 @@ void flush_thread(void)
22936 {
22937 struct task_struct *tsk = current;
22938
22939 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22940 + loadsegment(gs, 0);
22941 +#endif
22942 flush_ptrace_hw_breakpoint(tsk);
22943 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22944 drop_init_fpu(tsk);
22945 @@ -301,7 +305,7 @@ static void __exit_idle(void)
22946 void exit_idle(void)
22947 {
22948 /* idle loop has pid 0 */
22949 - if (current->pid)
22950 + if (task_pid_nr(current))
22951 return;
22952 __exit_idle();
22953 }
22954 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
22955
22956 return ret;
22957 }
22958 -void stop_this_cpu(void *dummy)
22959 +__noreturn void stop_this_cpu(void *dummy)
22960 {
22961 local_irq_disable();
22962 /*
22963 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
22964 }
22965 early_param("idle", idle_setup);
22966
22967 -unsigned long arch_align_stack(unsigned long sp)
22968 +#ifdef CONFIG_PAX_RANDKSTACK
22969 +void pax_randomize_kstack(struct pt_regs *regs)
22970 {
22971 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22972 - sp -= get_random_int() % 8192;
22973 - return sp & ~0xf;
22974 -}
22975 + struct thread_struct *thread = &current->thread;
22976 + unsigned long time;
22977
22978 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22979 -{
22980 - unsigned long range_end = mm->brk + 0x02000000;
22981 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22982 -}
22983 + if (!randomize_va_space)
22984 + return;
22985 +
22986 + if (v8086_mode(regs))
22987 + return;
22988
22989 + rdtscl(time);
22990 +
22991 + /* P4 seems to return a 0 LSB, ignore it */
22992 +#ifdef CONFIG_MPENTIUM4
22993 + time &= 0x3EUL;
22994 + time <<= 2;
22995 +#elif defined(CONFIG_X86_64)
22996 + time &= 0xFUL;
22997 + time <<= 4;
22998 +#else
22999 + time &= 0x1FUL;
23000 + time <<= 3;
23001 +#endif
23002 +
23003 + thread->sp0 ^= time;
23004 + load_sp0(init_tss + smp_processor_id(), thread);
23005 +
23006 +#ifdef CONFIG_X86_64
23007 + this_cpu_write(kernel_stack, thread->sp0);
23008 +#endif
23009 +}
23010 +#endif
23011 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
23012 index b5a8905..d9cacac 100644
23013 --- a/arch/x86/kernel/process_32.c
23014 +++ b/arch/x86/kernel/process_32.c
23015 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
23016 unsigned long thread_saved_pc(struct task_struct *tsk)
23017 {
23018 return ((unsigned long *)tsk->thread.sp)[3];
23019 +//XXX return tsk->thread.eip;
23020 }
23021
23022 void __show_regs(struct pt_regs *regs, int all)
23023 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
23024 unsigned long sp;
23025 unsigned short ss, gs;
23026
23027 - if (user_mode_vm(regs)) {
23028 + if (user_mode(regs)) {
23029 sp = regs->sp;
23030 ss = regs->ss & 0xffff;
23031 - gs = get_user_gs(regs);
23032 } else {
23033 sp = kernel_stack_pointer(regs);
23034 savesegment(ss, ss);
23035 - savesegment(gs, gs);
23036 }
23037 + gs = get_user_gs(regs);
23038
23039 show_regs_common();
23040
23041 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
23042 (u16)regs->cs, regs->ip, regs->flags,
23043 - smp_processor_id());
23044 + raw_smp_processor_id());
23045 print_symbol("EIP is at %s\n", regs->ip);
23046
23047 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
23048 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
23049 int copy_thread(unsigned long clone_flags, unsigned long sp,
23050 unsigned long arg, struct task_struct *p)
23051 {
23052 - struct pt_regs *childregs = task_pt_regs(p);
23053 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
23054 struct task_struct *tsk;
23055 int err;
23056
23057 p->thread.sp = (unsigned long) childregs;
23058 p->thread.sp0 = (unsigned long) (childregs+1);
23059 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
23060
23061 if (unlikely(p->flags & PF_KTHREAD)) {
23062 /* kernel thread */
23063 memset(childregs, 0, sizeof(struct pt_regs));
23064 p->thread.ip = (unsigned long) ret_from_kernel_thread;
23065 - task_user_gs(p) = __KERNEL_STACK_CANARY;
23066 - childregs->ds = __USER_DS;
23067 - childregs->es = __USER_DS;
23068 + savesegment(gs, childregs->gs);
23069 + childregs->ds = __KERNEL_DS;
23070 + childregs->es = __KERNEL_DS;
23071 childregs->fs = __KERNEL_PERCPU;
23072 childregs->bx = sp; /* function */
23073 childregs->bp = arg;
23074 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23075 struct thread_struct *prev = &prev_p->thread,
23076 *next = &next_p->thread;
23077 int cpu = smp_processor_id();
23078 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
23079 + struct tss_struct *tss = init_tss + cpu;
23080 fpu_switch_t fpu;
23081
23082 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
23083 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23084 */
23085 lazy_save_gs(prev->gs);
23086
23087 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23088 + __set_fs(task_thread_info(next_p)->addr_limit);
23089 +#endif
23090 +
23091 /*
23092 * Load the per-thread Thread-Local Storage descriptor.
23093 */
23094 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23095 */
23096 arch_end_context_switch(next_p);
23097
23098 + this_cpu_write(current_task, next_p);
23099 + this_cpu_write(current_tinfo, &next_p->tinfo);
23100 +
23101 /*
23102 * Restore %gs if needed (which is common)
23103 */
23104 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23105
23106 switch_fpu_finish(next_p, fpu);
23107
23108 - this_cpu_write(current_task, next_p);
23109 -
23110 return prev_p;
23111 }
23112
23113 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
23114 } while (count++ < 16);
23115 return 0;
23116 }
23117 -
23118 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
23119 index 6e68a61..955a9a5 100644
23120 --- a/arch/x86/kernel/process_64.c
23121 +++ b/arch/x86/kernel/process_64.c
23122 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
23123 struct pt_regs *childregs;
23124 struct task_struct *me = current;
23125
23126 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
23127 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
23128 childregs = task_pt_regs(p);
23129 p->thread.sp = (unsigned long) childregs;
23130 p->thread.usersp = me->thread.usersp;
23131 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
23132 set_tsk_thread_flag(p, TIF_FORK);
23133 p->fpu_counter = 0;
23134 p->thread.io_bitmap_ptr = NULL;
23135 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23136 struct thread_struct *prev = &prev_p->thread;
23137 struct thread_struct *next = &next_p->thread;
23138 int cpu = smp_processor_id();
23139 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
23140 + struct tss_struct *tss = init_tss + cpu;
23141 unsigned fsindex, gsindex;
23142 fpu_switch_t fpu;
23143
23144 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23145 prev->usersp = this_cpu_read(old_rsp);
23146 this_cpu_write(old_rsp, next->usersp);
23147 this_cpu_write(current_task, next_p);
23148 + this_cpu_write(current_tinfo, &next_p->tinfo);
23149
23150 - this_cpu_write(kernel_stack,
23151 - (unsigned long)task_stack_page(next_p) +
23152 - THREAD_SIZE - KERNEL_STACK_OFFSET);
23153 + this_cpu_write(kernel_stack, next->sp0);
23154
23155 /*
23156 * Now maybe reload the debug registers and handle I/O bitmaps
23157 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
23158 if (!p || p == current || p->state == TASK_RUNNING)
23159 return 0;
23160 stack = (unsigned long)task_stack_page(p);
23161 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
23162 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
23163 return 0;
23164 fp = *(u64 *)(p->thread.sp);
23165 do {
23166 - if (fp < (unsigned long)stack ||
23167 - fp >= (unsigned long)stack+THREAD_SIZE)
23168 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
23169 return 0;
23170 ip = *(u64 *)(fp+8);
23171 if (!in_sched_functions(ip))
23172 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
23173 index b629bbe..0fa615a 100644
23174 --- a/arch/x86/kernel/ptrace.c
23175 +++ b/arch/x86/kernel/ptrace.c
23176 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
23177 {
23178 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
23179 unsigned long sp = (unsigned long)&regs->sp;
23180 - struct thread_info *tinfo;
23181
23182 - if (context == (sp & ~(THREAD_SIZE - 1)))
23183 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
23184 return sp;
23185
23186 - tinfo = (struct thread_info *)context;
23187 - if (tinfo->previous_esp)
23188 - return tinfo->previous_esp;
23189 + sp = *(unsigned long *)context;
23190 + if (sp)
23191 + return sp;
23192
23193 return (unsigned long)regs;
23194 }
23195 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
23196 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
23197 {
23198 int i;
23199 - int dr7 = 0;
23200 + unsigned long dr7 = 0;
23201 struct arch_hw_breakpoint *info;
23202
23203 for (i = 0; i < HBP_NUM; i++) {
23204 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
23205 unsigned long addr, unsigned long data)
23206 {
23207 int ret;
23208 - unsigned long __user *datap = (unsigned long __user *)data;
23209 + unsigned long __user *datap = (__force unsigned long __user *)data;
23210
23211 switch (request) {
23212 /* read the word at location addr in the USER area. */
23213 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
23214 if ((int) addr < 0)
23215 return -EIO;
23216 ret = do_get_thread_area(child, addr,
23217 - (struct user_desc __user *)data);
23218 + (__force struct user_desc __user *) data);
23219 break;
23220
23221 case PTRACE_SET_THREAD_AREA:
23222 if ((int) addr < 0)
23223 return -EIO;
23224 ret = do_set_thread_area(child, addr,
23225 - (struct user_desc __user *)data, 0);
23226 + (__force struct user_desc __user *) data, 0);
23227 break;
23228 #endif
23229
23230 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
23231
23232 #ifdef CONFIG_X86_64
23233
23234 -static struct user_regset x86_64_regsets[] __read_mostly = {
23235 +static user_regset_no_const x86_64_regsets[] __read_only = {
23236 [REGSET_GENERAL] = {
23237 .core_note_type = NT_PRSTATUS,
23238 .n = sizeof(struct user_regs_struct) / sizeof(long),
23239 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
23240 #endif /* CONFIG_X86_64 */
23241
23242 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
23243 -static struct user_regset x86_32_regsets[] __read_mostly = {
23244 +static user_regset_no_const x86_32_regsets[] __read_only = {
23245 [REGSET_GENERAL] = {
23246 .core_note_type = NT_PRSTATUS,
23247 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
23248 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
23249 */
23250 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
23251
23252 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
23253 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
23254 {
23255 #ifdef CONFIG_X86_64
23256 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
23257 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
23258 memset(info, 0, sizeof(*info));
23259 info->si_signo = SIGTRAP;
23260 info->si_code = si_code;
23261 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
23262 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
23263 }
23264
23265 void user_single_step_siginfo(struct task_struct *tsk,
23266 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
23267 # define IS_IA32 0
23268 #endif
23269
23270 +#ifdef CONFIG_GRKERNSEC_SETXID
23271 +extern void gr_delayed_cred_worker(void);
23272 +#endif
23273 +
23274 /*
23275 * We must return the syscall number to actually look up in the table.
23276 * This can be -1L to skip running any syscall at all.
23277 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
23278
23279 user_exit();
23280
23281 +#ifdef CONFIG_GRKERNSEC_SETXID
23282 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
23283 + gr_delayed_cred_worker();
23284 +#endif
23285 +
23286 /*
23287 * If we stepped into a sysenter/syscall insn, it trapped in
23288 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
23289 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
23290 */
23291 user_exit();
23292
23293 +#ifdef CONFIG_GRKERNSEC_SETXID
23294 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
23295 + gr_delayed_cred_worker();
23296 +#endif
23297 +
23298 audit_syscall_exit(regs);
23299
23300 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
23301 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
23302 index 2cb9470..ff1fd80 100644
23303 --- a/arch/x86/kernel/pvclock.c
23304 +++ b/arch/x86/kernel/pvclock.c
23305 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
23306 return pv_tsc_khz;
23307 }
23308
23309 -static atomic64_t last_value = ATOMIC64_INIT(0);
23310 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
23311
23312 void pvclock_resume(void)
23313 {
23314 - atomic64_set(&last_value, 0);
23315 + atomic64_set_unchecked(&last_value, 0);
23316 }
23317
23318 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
23319 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
23320 * updating at the same time, and one of them could be slightly behind,
23321 * making the assumption that last_value always go forward fail to hold.
23322 */
23323 - last = atomic64_read(&last_value);
23324 + last = atomic64_read_unchecked(&last_value);
23325 do {
23326 if (ret < last)
23327 return last;
23328 - last = atomic64_cmpxchg(&last_value, last, ret);
23329 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
23330 } while (unlikely(last != ret));
23331
23332 return ret;
23333 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
23334 index 76fa1e9..abf09ea 100644
23335 --- a/arch/x86/kernel/reboot.c
23336 +++ b/arch/x86/kernel/reboot.c
23337 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
23338 EXPORT_SYMBOL(pm_power_off);
23339
23340 static const struct desc_ptr no_idt = {};
23341 -static int reboot_mode;
23342 +static unsigned short reboot_mode;
23343 enum reboot_type reboot_type = BOOT_ACPI;
23344 int reboot_force;
23345
23346 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
23347
23348 void __noreturn machine_real_restart(unsigned int type)
23349 {
23350 +
23351 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
23352 + struct desc_struct *gdt;
23353 +#endif
23354 +
23355 local_irq_disable();
23356
23357 /*
23358 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
23359
23360 /* Jump to the identity-mapped low memory code */
23361 #ifdef CONFIG_X86_32
23362 - asm volatile("jmpl *%0" : :
23363 +
23364 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
23365 + gdt = get_cpu_gdt_table(smp_processor_id());
23366 + pax_open_kernel();
23367 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23368 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
23369 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
23370 + loadsegment(ds, __KERNEL_DS);
23371 + loadsegment(es, __KERNEL_DS);
23372 + loadsegment(ss, __KERNEL_DS);
23373 +#endif
23374 +#ifdef CONFIG_PAX_KERNEXEC
23375 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
23376 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
23377 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
23378 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
23379 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
23380 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
23381 +#endif
23382 + pax_close_kernel();
23383 +#endif
23384 +
23385 + asm volatile("ljmpl *%0" : :
23386 "rm" (real_mode_header->machine_real_restart_asm),
23387 "a" (type));
23388 #else
23389 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
23390 * try to force a triple fault and then cycle between hitting the keyboard
23391 * controller and doing that
23392 */
23393 -static void native_machine_emergency_restart(void)
23394 +static void __noreturn native_machine_emergency_restart(void)
23395 {
23396 int i;
23397 int attempt = 0;
23398 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
23399 #endif
23400 }
23401
23402 -static void __machine_emergency_restart(int emergency)
23403 +static void __noreturn __machine_emergency_restart(int emergency)
23404 {
23405 reboot_emergency = emergency;
23406 machine_ops.emergency_restart();
23407 }
23408
23409 -static void native_machine_restart(char *__unused)
23410 +static void __noreturn native_machine_restart(char *__unused)
23411 {
23412 pr_notice("machine restart\n");
23413
23414 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
23415 __machine_emergency_restart(0);
23416 }
23417
23418 -static void native_machine_halt(void)
23419 +static void __noreturn native_machine_halt(void)
23420 {
23421 /* Stop other cpus and apics */
23422 machine_shutdown();
23423 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
23424 stop_this_cpu(NULL);
23425 }
23426
23427 -static void native_machine_power_off(void)
23428 +static void __noreturn native_machine_power_off(void)
23429 {
23430 if (pm_power_off) {
23431 if (!reboot_force)
23432 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
23433 }
23434 /* A fallback in case there is no PM info available */
23435 tboot_shutdown(TB_SHUTDOWN_HALT);
23436 + unreachable();
23437 }
23438
23439 -struct machine_ops machine_ops = {
23440 +struct machine_ops machine_ops __read_only = {
23441 .power_off = native_machine_power_off,
23442 .shutdown = native_machine_shutdown,
23443 .emergency_restart = native_machine_emergency_restart,
23444 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
23445 index 7a6f3b3..bed145d7 100644
23446 --- a/arch/x86/kernel/relocate_kernel_64.S
23447 +++ b/arch/x86/kernel/relocate_kernel_64.S
23448 @@ -11,6 +11,7 @@
23449 #include <asm/kexec.h>
23450 #include <asm/processor-flags.h>
23451 #include <asm/pgtable_types.h>
23452 +#include <asm/alternative-asm.h>
23453
23454 /*
23455 * Must be relocatable PIC code callable as a C function
23456 @@ -160,13 +161,14 @@ identity_mapped:
23457 xorq %rbp, %rbp
23458 xorq %r8, %r8
23459 xorq %r9, %r9
23460 - xorq %r10, %r9
23461 + xorq %r10, %r10
23462 xorq %r11, %r11
23463 xorq %r12, %r12
23464 xorq %r13, %r13
23465 xorq %r14, %r14
23466 xorq %r15, %r15
23467
23468 + pax_force_retaddr 0, 1
23469 ret
23470
23471 1:
23472 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
23473 index 8b24289..d37b58b 100644
23474 --- a/arch/x86/kernel/setup.c
23475 +++ b/arch/x86/kernel/setup.c
23476 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
23477
23478 switch (data->type) {
23479 case SETUP_E820_EXT:
23480 - parse_e820_ext(data);
23481 + parse_e820_ext((struct setup_data __force_kernel *)data);
23482 break;
23483 case SETUP_DTB:
23484 add_dtb(pa_data);
23485 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
23486 * area (640->1Mb) as ram even though it is not.
23487 * take them out.
23488 */
23489 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
23490 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
23491
23492 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
23493 }
23494 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
23495
23496 if (!boot_params.hdr.root_flags)
23497 root_mountflags &= ~MS_RDONLY;
23498 - init_mm.start_code = (unsigned long) _text;
23499 - init_mm.end_code = (unsigned long) _etext;
23500 + init_mm.start_code = ktla_ktva((unsigned long) _text);
23501 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
23502 init_mm.end_data = (unsigned long) _edata;
23503 init_mm.brk = _brk_end;
23504
23505 - code_resource.start = virt_to_phys(_text);
23506 - code_resource.end = virt_to_phys(_etext)-1;
23507 - data_resource.start = virt_to_phys(_etext);
23508 + code_resource.start = virt_to_phys(ktla_ktva(_text));
23509 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
23510 + data_resource.start = virt_to_phys(_sdata);
23511 data_resource.end = virt_to_phys(_edata)-1;
23512 bss_resource.start = virt_to_phys(&__bss_start);
23513 bss_resource.end = virt_to_phys(&__bss_stop)-1;
23514 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
23515 index 5cdff03..80fa283 100644
23516 --- a/arch/x86/kernel/setup_percpu.c
23517 +++ b/arch/x86/kernel/setup_percpu.c
23518 @@ -21,19 +21,17 @@
23519 #include <asm/cpu.h>
23520 #include <asm/stackprotector.h>
23521
23522 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
23523 +#ifdef CONFIG_SMP
23524 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
23525 EXPORT_PER_CPU_SYMBOL(cpu_number);
23526 +#endif
23527
23528 -#ifdef CONFIG_X86_64
23529 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
23530 -#else
23531 -#define BOOT_PERCPU_OFFSET 0
23532 -#endif
23533
23534 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
23535 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
23536
23537 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
23538 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
23539 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
23540 };
23541 EXPORT_SYMBOL(__per_cpu_offset);
23542 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
23543 {
23544 #ifdef CONFIG_NEED_MULTIPLE_NODES
23545 pg_data_t *last = NULL;
23546 - unsigned int cpu;
23547 + int cpu;
23548
23549 for_each_possible_cpu(cpu) {
23550 int node = early_cpu_to_node(cpu);
23551 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
23552 {
23553 #ifdef CONFIG_X86_32
23554 struct desc_struct gdt;
23555 + unsigned long base = per_cpu_offset(cpu);
23556
23557 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
23558 - 0x2 | DESCTYPE_S, 0x8);
23559 - gdt.s = 1;
23560 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
23561 + 0x83 | DESCTYPE_S, 0xC);
23562 write_gdt_entry(get_cpu_gdt_table(cpu),
23563 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
23564 #endif
23565 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
23566 /* alrighty, percpu areas up and running */
23567 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
23568 for_each_possible_cpu(cpu) {
23569 +#ifdef CONFIG_CC_STACKPROTECTOR
23570 +#ifdef CONFIG_X86_32
23571 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
23572 +#endif
23573 +#endif
23574 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
23575 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
23576 per_cpu(cpu_number, cpu) = cpu;
23577 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
23578 */
23579 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
23580 #endif
23581 +#ifdef CONFIG_CC_STACKPROTECTOR
23582 +#ifdef CONFIG_X86_32
23583 + if (!cpu)
23584 + per_cpu(stack_canary.canary, cpu) = canary;
23585 +#endif
23586 +#endif
23587 /*
23588 * Up to this point, the boot CPU has been using .init.data
23589 * area. Reload any changed state for the boot CPU.
23590 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
23591 index d6bf1f3..3ffce5a 100644
23592 --- a/arch/x86/kernel/signal.c
23593 +++ b/arch/x86/kernel/signal.c
23594 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
23595 * Align the stack pointer according to the i386 ABI,
23596 * i.e. so that on function entry ((sp + 4) & 15) == 0.
23597 */
23598 - sp = ((sp + 4) & -16ul) - 4;
23599 + sp = ((sp - 12) & -16ul) - 4;
23600 #else /* !CONFIG_X86_32 */
23601 sp = round_down(sp, 16) - 8;
23602 #endif
23603 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
23604 }
23605
23606 if (current->mm->context.vdso)
23607 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
23608 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
23609 else
23610 - restorer = &frame->retcode;
23611 + restorer = (void __user *)&frame->retcode;
23612 if (ka->sa.sa_flags & SA_RESTORER)
23613 restorer = ka->sa.sa_restorer;
23614
23615 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
23616 * reasons and because gdb uses it as a signature to notice
23617 * signal handler stack frames.
23618 */
23619 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
23620 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
23621
23622 if (err)
23623 return -EFAULT;
23624 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
23625 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
23626
23627 /* Set up to return from userspace. */
23628 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
23629 + if (current->mm->context.vdso)
23630 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
23631 + else
23632 + restorer = (void __user *)&frame->retcode;
23633 if (ka->sa.sa_flags & SA_RESTORER)
23634 restorer = ka->sa.sa_restorer;
23635 put_user_ex(restorer, &frame->pretcode);
23636 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
23637 * reasons and because gdb uses it as a signature to notice
23638 * signal handler stack frames.
23639 */
23640 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
23641 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
23642 } put_user_catch(err);
23643
23644 err |= copy_siginfo_to_user(&frame->info, info);
23645 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
23646 index 48d2b7d..90d328a 100644
23647 --- a/arch/x86/kernel/smp.c
23648 +++ b/arch/x86/kernel/smp.c
23649 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
23650
23651 __setup("nonmi_ipi", nonmi_ipi_setup);
23652
23653 -struct smp_ops smp_ops = {
23654 +struct smp_ops smp_ops __read_only = {
23655 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
23656 .smp_prepare_cpus = native_smp_prepare_cpus,
23657 .smp_cpus_done = native_smp_cpus_done,
23658 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
23659 index ed0fe38..87fc692 100644
23660 --- a/arch/x86/kernel/smpboot.c
23661 +++ b/arch/x86/kernel/smpboot.c
23662 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23663 idle->thread.sp = (unsigned long) (((struct pt_regs *)
23664 (THREAD_SIZE + task_stack_page(idle))) - 1);
23665 per_cpu(current_task, cpu) = idle;
23666 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
23667
23668 #ifdef CONFIG_X86_32
23669 /* Stack for startup_32 can be just as for start_secondary onwards */
23670 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23671 #else
23672 clear_tsk_thread_flag(idle, TIF_FORK);
23673 initial_gs = per_cpu_offset(cpu);
23674 - per_cpu(kernel_stack, cpu) =
23675 - (unsigned long)task_stack_page(idle) -
23676 - KERNEL_STACK_OFFSET + THREAD_SIZE;
23677 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
23678 #endif
23679 +
23680 + pax_open_kernel();
23681 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23682 + pax_close_kernel();
23683 +
23684 initial_code = (unsigned long)start_secondary;
23685 stack_start = idle->thread.sp;
23686
23687 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
23688 /* the FPU context is blank, nobody can own it */
23689 __cpu_disable_lazy_restore(cpu);
23690
23691 +#ifdef CONFIG_PAX_PER_CPU_PGD
23692 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
23693 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
23694 + KERNEL_PGD_PTRS);
23695 +#endif
23696 +
23697 + /* the FPU context is blank, nobody can own it */
23698 + __cpu_disable_lazy_restore(cpu);
23699 +
23700 err = do_boot_cpu(apicid, cpu, tidle);
23701 if (err) {
23702 pr_debug("do_boot_cpu failed %d\n", err);
23703 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
23704 index 9b4d51d..5d28b58 100644
23705 --- a/arch/x86/kernel/step.c
23706 +++ b/arch/x86/kernel/step.c
23707 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23708 struct desc_struct *desc;
23709 unsigned long base;
23710
23711 - seg &= ~7UL;
23712 + seg >>= 3;
23713
23714 mutex_lock(&child->mm->context.lock);
23715 - if (unlikely((seg >> 3) >= child->mm->context.size))
23716 + if (unlikely(seg >= child->mm->context.size))
23717 addr = -1L; /* bogus selector, access would fault */
23718 else {
23719 desc = child->mm->context.ldt + seg;
23720 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23721 addr += base;
23722 }
23723 mutex_unlock(&child->mm->context.lock);
23724 - }
23725 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
23726 + addr = ktla_ktva(addr);
23727
23728 return addr;
23729 }
23730 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
23731 unsigned char opcode[15];
23732 unsigned long addr = convert_ip_to_linear(child, regs);
23733
23734 + if (addr == -EINVAL)
23735 + return 0;
23736 +
23737 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
23738 for (i = 0; i < copied; i++) {
23739 switch (opcode[i]) {
23740 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
23741 new file mode 100644
23742 index 0000000..207bec6
23743 --- /dev/null
23744 +++ b/arch/x86/kernel/sys_i386_32.c
23745 @@ -0,0 +1,250 @@
23746 +/*
23747 + * This file contains various random system calls that
23748 + * have a non-standard calling sequence on the Linux/i386
23749 + * platform.
23750 + */
23751 +
23752 +#include <linux/errno.h>
23753 +#include <linux/sched.h>
23754 +#include <linux/mm.h>
23755 +#include <linux/fs.h>
23756 +#include <linux/smp.h>
23757 +#include <linux/sem.h>
23758 +#include <linux/msg.h>
23759 +#include <linux/shm.h>
23760 +#include <linux/stat.h>
23761 +#include <linux/syscalls.h>
23762 +#include <linux/mman.h>
23763 +#include <linux/file.h>
23764 +#include <linux/utsname.h>
23765 +#include <linux/ipc.h>
23766 +
23767 +#include <linux/uaccess.h>
23768 +#include <linux/unistd.h>
23769 +
23770 +#include <asm/syscalls.h>
23771 +
23772 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
23773 +{
23774 + unsigned long pax_task_size = TASK_SIZE;
23775 +
23776 +#ifdef CONFIG_PAX_SEGMEXEC
23777 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
23778 + pax_task_size = SEGMEXEC_TASK_SIZE;
23779 +#endif
23780 +
23781 + if (flags & MAP_FIXED)
23782 + if (len > pax_task_size || addr > pax_task_size - len)
23783 + return -EINVAL;
23784 +
23785 + return 0;
23786 +}
23787 +
23788 +unsigned long
23789 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23790 + unsigned long len, unsigned long pgoff, unsigned long flags)
23791 +{
23792 + struct mm_struct *mm = current->mm;
23793 + struct vm_area_struct *vma;
23794 + unsigned long start_addr, pax_task_size = TASK_SIZE;
23795 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23796 +
23797 +#ifdef CONFIG_PAX_SEGMEXEC
23798 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23799 + pax_task_size = SEGMEXEC_TASK_SIZE;
23800 +#endif
23801 +
23802 + pax_task_size -= PAGE_SIZE;
23803 +
23804 + if (len > pax_task_size)
23805 + return -ENOMEM;
23806 +
23807 + if (flags & MAP_FIXED)
23808 + return addr;
23809 +
23810 +#ifdef CONFIG_PAX_RANDMMAP
23811 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23812 +#endif
23813 +
23814 + if (addr) {
23815 + addr = PAGE_ALIGN(addr);
23816 + if (pax_task_size - len >= addr) {
23817 + vma = find_vma(mm, addr);
23818 + if (check_heap_stack_gap(vma, addr, len, offset))
23819 + return addr;
23820 + }
23821 + }
23822 + if (len > mm->cached_hole_size) {
23823 + start_addr = addr = mm->free_area_cache;
23824 + } else {
23825 + start_addr = addr = mm->mmap_base;
23826 + mm->cached_hole_size = 0;
23827 + }
23828 +
23829 +#ifdef CONFIG_PAX_PAGEEXEC
23830 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
23831 + start_addr = 0x00110000UL;
23832 +
23833 +#ifdef CONFIG_PAX_RANDMMAP
23834 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23835 + start_addr += mm->delta_mmap & 0x03FFF000UL;
23836 +#endif
23837 +
23838 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
23839 + start_addr = addr = mm->mmap_base;
23840 + else
23841 + addr = start_addr;
23842 + }
23843 +#endif
23844 +
23845 +full_search:
23846 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
23847 + /* At this point: (!vma || addr < vma->vm_end). */
23848 + if (pax_task_size - len < addr) {
23849 + /*
23850 + * Start a new search - just in case we missed
23851 + * some holes.
23852 + */
23853 + if (start_addr != mm->mmap_base) {
23854 + start_addr = addr = mm->mmap_base;
23855 + mm->cached_hole_size = 0;
23856 + goto full_search;
23857 + }
23858 + return -ENOMEM;
23859 + }
23860 + if (check_heap_stack_gap(vma, addr, len, offset))
23861 + break;
23862 + if (addr + mm->cached_hole_size < vma->vm_start)
23863 + mm->cached_hole_size = vma->vm_start - addr;
23864 + addr = vma->vm_end;
23865 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
23866 + start_addr = addr = mm->mmap_base;
23867 + mm->cached_hole_size = 0;
23868 + goto full_search;
23869 + }
23870 + }
23871 +
23872 + /*
23873 + * Remember the place where we stopped the search:
23874 + */
23875 + mm->free_area_cache = addr + len;
23876 + return addr;
23877 +}
23878 +
23879 +unsigned long
23880 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23881 + const unsigned long len, const unsigned long pgoff,
23882 + const unsigned long flags)
23883 +{
23884 + struct vm_area_struct *vma;
23885 + struct mm_struct *mm = current->mm;
23886 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
23887 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23888 +
23889 +#ifdef CONFIG_PAX_SEGMEXEC
23890 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23891 + pax_task_size = SEGMEXEC_TASK_SIZE;
23892 +#endif
23893 +
23894 + pax_task_size -= PAGE_SIZE;
23895 +
23896 + /* requested length too big for entire address space */
23897 + if (len > pax_task_size)
23898 + return -ENOMEM;
23899 +
23900 + if (flags & MAP_FIXED)
23901 + return addr;
23902 +
23903 +#ifdef CONFIG_PAX_PAGEEXEC
23904 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23905 + goto bottomup;
23906 +#endif
23907 +
23908 +#ifdef CONFIG_PAX_RANDMMAP
23909 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23910 +#endif
23911 +
23912 + /* requesting a specific address */
23913 + if (addr) {
23914 + addr = PAGE_ALIGN(addr);
23915 + if (pax_task_size - len >= addr) {
23916 + vma = find_vma(mm, addr);
23917 + if (check_heap_stack_gap(vma, addr, len, offset))
23918 + return addr;
23919 + }
23920 + }
23921 +
23922 + /* check if free_area_cache is useful for us */
23923 + if (len <= mm->cached_hole_size) {
23924 + mm->cached_hole_size = 0;
23925 + mm->free_area_cache = mm->mmap_base;
23926 + }
23927 +
23928 + /* either no address requested or can't fit in requested address hole */
23929 + addr = mm->free_area_cache;
23930 +
23931 + /* make sure it can fit in the remaining address space */
23932 + if (addr > len) {
23933 + vma = find_vma(mm, addr-len);
23934 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23935 + /* remember the address as a hint for next time */
23936 + return (mm->free_area_cache = addr-len);
23937 + }
23938 +
23939 + if (mm->mmap_base < len)
23940 + goto bottomup;
23941 +
23942 + addr = mm->mmap_base-len;
23943 +
23944 + do {
23945 + /*
23946 + * Lookup failure means no vma is above this address,
23947 + * else if new region fits below vma->vm_start,
23948 + * return with success:
23949 + */
23950 + vma = find_vma(mm, addr);
23951 + if (check_heap_stack_gap(vma, addr, len, offset))
23952 + /* remember the address as a hint for next time */
23953 + return (mm->free_area_cache = addr);
23954 +
23955 + /* remember the largest hole we saw so far */
23956 + if (addr + mm->cached_hole_size < vma->vm_start)
23957 + mm->cached_hole_size = vma->vm_start - addr;
23958 +
23959 + /* try just below the current vma->vm_start */
23960 + addr = skip_heap_stack_gap(vma, len, offset);
23961 + } while (!IS_ERR_VALUE(addr));
23962 +
23963 +bottomup:
23964 + /*
23965 + * A failed mmap() very likely causes application failure,
23966 + * so fall back to the bottom-up function here. This scenario
23967 + * can happen with large stack limits and large mmap()
23968 + * allocations.
23969 + */
23970 +
23971 +#ifdef CONFIG_PAX_SEGMEXEC
23972 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23973 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23974 + else
23975 +#endif
23976 +
23977 + mm->mmap_base = TASK_UNMAPPED_BASE;
23978 +
23979 +#ifdef CONFIG_PAX_RANDMMAP
23980 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23981 + mm->mmap_base += mm->delta_mmap;
23982 +#endif
23983 +
23984 + mm->free_area_cache = mm->mmap_base;
23985 + mm->cached_hole_size = ~0UL;
23986 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23987 + /*
23988 + * Restore the topdown base:
23989 + */
23990 + mm->mmap_base = base;
23991 + mm->free_area_cache = base;
23992 + mm->cached_hole_size = ~0UL;
23993 +
23994 + return addr;
23995 +}
23996 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23997 index 97ef74b..57a1882 100644
23998 --- a/arch/x86/kernel/sys_x86_64.c
23999 +++ b/arch/x86/kernel/sys_x86_64.c
24000 @@ -81,8 +81,8 @@ out:
24001 return error;
24002 }
24003
24004 -static void find_start_end(unsigned long flags, unsigned long *begin,
24005 - unsigned long *end)
24006 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
24007 + unsigned long *begin, unsigned long *end)
24008 {
24009 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
24010 unsigned long new_begin;
24011 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
24012 *begin = new_begin;
24013 }
24014 } else {
24015 - *begin = TASK_UNMAPPED_BASE;
24016 + *begin = mm->mmap_base;
24017 *end = TASK_SIZE;
24018 }
24019 }
24020 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
24021 struct vm_area_struct *vma;
24022 struct vm_unmapped_area_info info;
24023 unsigned long begin, end;
24024 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
24025
24026 if (flags & MAP_FIXED)
24027 return addr;
24028
24029 - find_start_end(flags, &begin, &end);
24030 + find_start_end(mm, flags, &begin, &end);
24031
24032 if (len > end)
24033 return -ENOMEM;
24034
24035 +#ifdef CONFIG_PAX_RANDMMAP
24036 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
24037 +#endif
24038 +
24039 if (addr) {
24040 addr = PAGE_ALIGN(addr);
24041 vma = find_vma(mm, addr);
24042 - if (end - len >= addr &&
24043 - (!vma || addr + len <= vma->vm_start))
24044 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
24045 return addr;
24046 }
24047
24048 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
24049 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
24050 goto bottomup;
24051
24052 +#ifdef CONFIG_PAX_RANDMMAP
24053 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
24054 +#endif
24055 +
24056 /* requesting a specific address */
24057 if (addr) {
24058 addr = PAGE_ALIGN(addr);
24059 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
24060 index f84fe00..f41d9f1 100644
24061 --- a/arch/x86/kernel/tboot.c
24062 +++ b/arch/x86/kernel/tboot.c
24063 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
24064
24065 void tboot_shutdown(u32 shutdown_type)
24066 {
24067 - void (*shutdown)(void);
24068 + void (* __noreturn shutdown)(void);
24069
24070 if (!tboot_enabled())
24071 return;
24072 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
24073
24074 switch_to_tboot_pt();
24075
24076 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
24077 + shutdown = (void *)tboot->shutdown_entry;
24078 shutdown();
24079
24080 /* should not reach here */
24081 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
24082 return 0;
24083 }
24084
24085 -static atomic_t ap_wfs_count;
24086 +static atomic_unchecked_t ap_wfs_count;
24087
24088 static int tboot_wait_for_aps(int num_aps)
24089 {
24090 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
24091 {
24092 switch (action) {
24093 case CPU_DYING:
24094 - atomic_inc(&ap_wfs_count);
24095 + atomic_inc_unchecked(&ap_wfs_count);
24096 if (num_online_cpus() == 1)
24097 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
24098 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
24099 return NOTIFY_BAD;
24100 break;
24101 }
24102 return NOTIFY_OK;
24103 }
24104
24105 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
24106 +static struct notifier_block tboot_cpu_notifier =
24107 {
24108 .notifier_call = tboot_cpu_callback,
24109 };
24110 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
24111
24112 tboot_create_trampoline();
24113
24114 - atomic_set(&ap_wfs_count, 0);
24115 + atomic_set_unchecked(&ap_wfs_count, 0);
24116 register_hotcpu_notifier(&tboot_cpu_notifier);
24117
24118 acpi_os_set_prepare_sleep(&tboot_sleep);
24119 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
24120 index 24d3c91..d06b473 100644
24121 --- a/arch/x86/kernel/time.c
24122 +++ b/arch/x86/kernel/time.c
24123 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
24124 {
24125 unsigned long pc = instruction_pointer(regs);
24126
24127 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
24128 + if (!user_mode(regs) && in_lock_functions(pc)) {
24129 #ifdef CONFIG_FRAME_POINTER
24130 - return *(unsigned long *)(regs->bp + sizeof(long));
24131 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
24132 #else
24133 unsigned long *sp =
24134 (unsigned long *)kernel_stack_pointer(regs);
24135 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
24136 * or above a saved flags. Eflags has bits 22-31 zero,
24137 * kernel addresses don't.
24138 */
24139 +
24140 +#ifdef CONFIG_PAX_KERNEXEC
24141 + return ktla_ktva(sp[0]);
24142 +#else
24143 if (sp[0] >> 22)
24144 return sp[0];
24145 if (sp[1] >> 22)
24146 return sp[1];
24147 #endif
24148 +
24149 +#endif
24150 }
24151 return pc;
24152 }
24153 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
24154 index 9d9d2f9..cad418a 100644
24155 --- a/arch/x86/kernel/tls.c
24156 +++ b/arch/x86/kernel/tls.c
24157 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
24158 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
24159 return -EINVAL;
24160
24161 +#ifdef CONFIG_PAX_SEGMEXEC
24162 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
24163 + return -EINVAL;
24164 +#endif
24165 +
24166 set_tls_desc(p, idx, &info, 1);
24167
24168 return 0;
24169 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
24170
24171 if (kbuf)
24172 info = kbuf;
24173 - else if (__copy_from_user(infobuf, ubuf, count))
24174 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
24175 return -EFAULT;
24176 else
24177 info = infobuf;
24178 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
24179 index ecffca1..95c4d13 100644
24180 --- a/arch/x86/kernel/traps.c
24181 +++ b/arch/x86/kernel/traps.c
24182 @@ -68,12 +68,6 @@
24183 #include <asm/setup.h>
24184
24185 asmlinkage int system_call(void);
24186 -
24187 -/*
24188 - * The IDT has to be page-aligned to simplify the Pentium
24189 - * F0 0F bug workaround.
24190 - */
24191 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
24192 #endif
24193
24194 DECLARE_BITMAP(used_vectors, NR_VECTORS);
24195 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
24196 }
24197
24198 static int __kprobes
24199 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
24200 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
24201 struct pt_regs *regs, long error_code)
24202 {
24203 #ifdef CONFIG_X86_32
24204 - if (regs->flags & X86_VM_MASK) {
24205 + if (v8086_mode(regs)) {
24206 /*
24207 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
24208 * On nmi (interrupt 2), do_trap should not be called.
24209 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
24210 return -1;
24211 }
24212 #endif
24213 - if (!user_mode(regs)) {
24214 + if (!user_mode_novm(regs)) {
24215 if (!fixup_exception(regs)) {
24216 tsk->thread.error_code = error_code;
24217 tsk->thread.trap_nr = trapnr;
24218 +
24219 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24220 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
24221 + str = "PAX: suspicious stack segment fault";
24222 +#endif
24223 +
24224 die(str, regs, error_code);
24225 }
24226 +
24227 +#ifdef CONFIG_PAX_REFCOUNT
24228 + if (trapnr == 4)
24229 + pax_report_refcount_overflow(regs);
24230 +#endif
24231 +
24232 return 0;
24233 }
24234
24235 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
24236 }
24237
24238 static void __kprobes
24239 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
24240 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
24241 long error_code, siginfo_t *info)
24242 {
24243 struct task_struct *tsk = current;
24244 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
24245 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
24246 printk_ratelimit()) {
24247 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
24248 - tsk->comm, tsk->pid, str,
24249 + tsk->comm, task_pid_nr(tsk), str,
24250 regs->ip, regs->sp, error_code);
24251 print_vma_addr(" in ", regs->ip);
24252 pr_cont("\n");
24253 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
24254 conditional_sti(regs);
24255
24256 #ifdef CONFIG_X86_32
24257 - if (regs->flags & X86_VM_MASK) {
24258 + if (v8086_mode(regs)) {
24259 local_irq_enable();
24260 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
24261 goto exit;
24262 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
24263 #endif
24264
24265 tsk = current;
24266 - if (!user_mode(regs)) {
24267 + if (!user_mode_novm(regs)) {
24268 if (fixup_exception(regs))
24269 goto exit;
24270
24271 tsk->thread.error_code = error_code;
24272 tsk->thread.trap_nr = X86_TRAP_GP;
24273 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
24274 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
24275 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
24276 +
24277 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24278 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
24279 + die("PAX: suspicious general protection fault", regs, error_code);
24280 + else
24281 +#endif
24282 +
24283 die("general protection fault", regs, error_code);
24284 + }
24285 goto exit;
24286 }
24287
24288 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
24289 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
24290 + struct mm_struct *mm = tsk->mm;
24291 + unsigned long limit;
24292 +
24293 + down_write(&mm->mmap_sem);
24294 + limit = mm->context.user_cs_limit;
24295 + if (limit < TASK_SIZE) {
24296 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
24297 + up_write(&mm->mmap_sem);
24298 + return;
24299 + }
24300 + up_write(&mm->mmap_sem);
24301 + }
24302 +#endif
24303 +
24304 tsk->thread.error_code = error_code;
24305 tsk->thread.trap_nr = X86_TRAP_GP;
24306
24307 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
24308 /* It's safe to allow irq's after DR6 has been saved */
24309 preempt_conditional_sti(regs);
24310
24311 - if (regs->flags & X86_VM_MASK) {
24312 + if (v8086_mode(regs)) {
24313 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
24314 X86_TRAP_DB);
24315 preempt_conditional_cli(regs);
24316 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
24317 * We already checked v86 mode above, so we can check for kernel mode
24318 * by just checking the CPL of CS.
24319 */
24320 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
24321 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
24322 tsk->thread.debugreg6 &= ~DR_STEP;
24323 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
24324 regs->flags &= ~X86_EFLAGS_TF;
24325 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
24326 return;
24327 conditional_sti(regs);
24328
24329 - if (!user_mode_vm(regs))
24330 + if (!user_mode(regs))
24331 {
24332 if (!fixup_exception(regs)) {
24333 task->thread.error_code = error_code;
24334 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
24335 index c71025b..b117501 100644
24336 --- a/arch/x86/kernel/uprobes.c
24337 +++ b/arch/x86/kernel/uprobes.c
24338 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
24339 int ret = NOTIFY_DONE;
24340
24341 /* We are only interested in userspace traps */
24342 - if (regs && !user_mode_vm(regs))
24343 + if (regs && !user_mode(regs))
24344 return NOTIFY_DONE;
24345
24346 switch (val) {
24347 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
24348 index b9242ba..50c5edd 100644
24349 --- a/arch/x86/kernel/verify_cpu.S
24350 +++ b/arch/x86/kernel/verify_cpu.S
24351 @@ -20,6 +20,7 @@
24352 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
24353 * arch/x86/kernel/trampoline_64.S: secondary processor verification
24354 * arch/x86/kernel/head_32.S: processor startup
24355 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
24356 *
24357 * verify_cpu, returns the status of longmode and SSE in register %eax.
24358 * 0: Success 1: Failure
24359 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
24360 index 1dfe69c..a3df6f6 100644
24361 --- a/arch/x86/kernel/vm86_32.c
24362 +++ b/arch/x86/kernel/vm86_32.c
24363 @@ -43,6 +43,7 @@
24364 #include <linux/ptrace.h>
24365 #include <linux/audit.h>
24366 #include <linux/stddef.h>
24367 +#include <linux/grsecurity.h>
24368
24369 #include <asm/uaccess.h>
24370 #include <asm/io.h>
24371 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
24372 do_exit(SIGSEGV);
24373 }
24374
24375 - tss = &per_cpu(init_tss, get_cpu());
24376 + tss = init_tss + get_cpu();
24377 current->thread.sp0 = current->thread.saved_sp0;
24378 current->thread.sysenter_cs = __KERNEL_CS;
24379 load_sp0(tss, &current->thread);
24380 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
24381 struct task_struct *tsk;
24382 int tmp, ret = -EPERM;
24383
24384 +#ifdef CONFIG_GRKERNSEC_VM86
24385 + if (!capable(CAP_SYS_RAWIO)) {
24386 + gr_handle_vm86();
24387 + goto out;
24388 + }
24389 +#endif
24390 +
24391 tsk = current;
24392 if (tsk->thread.saved_sp0)
24393 goto out;
24394 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
24395 int tmp, ret;
24396 struct vm86plus_struct __user *v86;
24397
24398 +#ifdef CONFIG_GRKERNSEC_VM86
24399 + if (!capable(CAP_SYS_RAWIO)) {
24400 + gr_handle_vm86();
24401 + ret = -EPERM;
24402 + goto out;
24403 + }
24404 +#endif
24405 +
24406 tsk = current;
24407 switch (cmd) {
24408 case VM86_REQUEST_IRQ:
24409 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
24410 tsk->thread.saved_fs = info->regs32->fs;
24411 tsk->thread.saved_gs = get_user_gs(info->regs32);
24412
24413 - tss = &per_cpu(init_tss, get_cpu());
24414 + tss = init_tss + get_cpu();
24415 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
24416 if (cpu_has_sep)
24417 tsk->thread.sysenter_cs = 0;
24418 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
24419 goto cannot_handle;
24420 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
24421 goto cannot_handle;
24422 - intr_ptr = (unsigned long __user *) (i << 2);
24423 + intr_ptr = (__force unsigned long __user *) (i << 2);
24424 if (get_user(segoffs, intr_ptr))
24425 goto cannot_handle;
24426 if ((segoffs >> 16) == BIOSSEG)
24427 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
24428 index 22a1530..8fbaaad 100644
24429 --- a/arch/x86/kernel/vmlinux.lds.S
24430 +++ b/arch/x86/kernel/vmlinux.lds.S
24431 @@ -26,6 +26,13 @@
24432 #include <asm/page_types.h>
24433 #include <asm/cache.h>
24434 #include <asm/boot.h>
24435 +#include <asm/segment.h>
24436 +
24437 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24438 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
24439 +#else
24440 +#define __KERNEL_TEXT_OFFSET 0
24441 +#endif
24442
24443 #undef i386 /* in case the preprocessor is a 32bit one */
24444
24445 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
24446
24447 PHDRS {
24448 text PT_LOAD FLAGS(5); /* R_E */
24449 +#ifdef CONFIG_X86_32
24450 + module PT_LOAD FLAGS(5); /* R_E */
24451 +#endif
24452 +#ifdef CONFIG_XEN
24453 + rodata PT_LOAD FLAGS(5); /* R_E */
24454 +#else
24455 + rodata PT_LOAD FLAGS(4); /* R__ */
24456 +#endif
24457 data PT_LOAD FLAGS(6); /* RW_ */
24458 -#ifdef CONFIG_X86_64
24459 + init.begin PT_LOAD FLAGS(6); /* RW_ */
24460 #ifdef CONFIG_SMP
24461 percpu PT_LOAD FLAGS(6); /* RW_ */
24462 #endif
24463 + text.init PT_LOAD FLAGS(5); /* R_E */
24464 + text.exit PT_LOAD FLAGS(5); /* R_E */
24465 init PT_LOAD FLAGS(7); /* RWE */
24466 -#endif
24467 note PT_NOTE FLAGS(0); /* ___ */
24468 }
24469
24470 SECTIONS
24471 {
24472 #ifdef CONFIG_X86_32
24473 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
24474 - phys_startup_32 = startup_32 - LOAD_OFFSET;
24475 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
24476 #else
24477 - . = __START_KERNEL;
24478 - phys_startup_64 = startup_64 - LOAD_OFFSET;
24479 + . = __START_KERNEL;
24480 #endif
24481
24482 /* Text and read-only data */
24483 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
24484 - _text = .;
24485 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
24486 /* bootstrapping code */
24487 +#ifdef CONFIG_X86_32
24488 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
24489 +#else
24490 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
24491 +#endif
24492 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
24493 + _text = .;
24494 HEAD_TEXT
24495 #ifdef CONFIG_X86_32
24496 . = ALIGN(PAGE_SIZE);
24497 @@ -108,13 +128,48 @@ SECTIONS
24498 IRQENTRY_TEXT
24499 *(.fixup)
24500 *(.gnu.warning)
24501 - /* End of text section */
24502 - _etext = .;
24503 } :text = 0x9090
24504
24505 - NOTES :text :note
24506 + . += __KERNEL_TEXT_OFFSET;
24507
24508 - EXCEPTION_TABLE(16) :text = 0x9090
24509 +#ifdef CONFIG_X86_32
24510 + . = ALIGN(PAGE_SIZE);
24511 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
24512 +
24513 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
24514 + MODULES_EXEC_VADDR = .;
24515 + BYTE(0)
24516 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
24517 + . = ALIGN(HPAGE_SIZE) - 1;
24518 + MODULES_EXEC_END = .;
24519 +#endif
24520 +
24521 + } :module
24522 +#endif
24523 +
24524 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
24525 + /* End of text section */
24526 + BYTE(0)
24527 + _etext = . - __KERNEL_TEXT_OFFSET;
24528 + }
24529 +
24530 +#ifdef CONFIG_X86_32
24531 + . = ALIGN(PAGE_SIZE);
24532 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
24533 + *(.idt)
24534 + . = ALIGN(PAGE_SIZE);
24535 + *(.empty_zero_page)
24536 + *(.initial_pg_fixmap)
24537 + *(.initial_pg_pmd)
24538 + *(.initial_page_table)
24539 + *(.swapper_pg_dir)
24540 + } :rodata
24541 +#endif
24542 +
24543 + . = ALIGN(PAGE_SIZE);
24544 + NOTES :rodata :note
24545 +
24546 + EXCEPTION_TABLE(16) :rodata
24547
24548 #if defined(CONFIG_DEBUG_RODATA)
24549 /* .text should occupy whole number of pages */
24550 @@ -126,16 +181,20 @@ SECTIONS
24551
24552 /* Data */
24553 .data : AT(ADDR(.data) - LOAD_OFFSET) {
24554 +
24555 +#ifdef CONFIG_PAX_KERNEXEC
24556 + . = ALIGN(HPAGE_SIZE);
24557 +#else
24558 + . = ALIGN(PAGE_SIZE);
24559 +#endif
24560 +
24561 /* Start of data section */
24562 _sdata = .;
24563
24564 /* init_task */
24565 INIT_TASK_DATA(THREAD_SIZE)
24566
24567 -#ifdef CONFIG_X86_32
24568 - /* 32 bit has nosave before _edata */
24569 NOSAVE_DATA
24570 -#endif
24571
24572 PAGE_ALIGNED_DATA(PAGE_SIZE)
24573
24574 @@ -176,12 +235,19 @@ SECTIONS
24575 #endif /* CONFIG_X86_64 */
24576
24577 /* Init code and data - will be freed after init */
24578 - . = ALIGN(PAGE_SIZE);
24579 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
24580 + BYTE(0)
24581 +
24582 +#ifdef CONFIG_PAX_KERNEXEC
24583 + . = ALIGN(HPAGE_SIZE);
24584 +#else
24585 + . = ALIGN(PAGE_SIZE);
24586 +#endif
24587 +
24588 __init_begin = .; /* paired with __init_end */
24589 - }
24590 + } :init.begin
24591
24592 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
24593 +#ifdef CONFIG_SMP
24594 /*
24595 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
24596 * output PHDR, so the next output section - .init.text - should
24597 @@ -190,12 +256,27 @@ SECTIONS
24598 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
24599 #endif
24600
24601 - INIT_TEXT_SECTION(PAGE_SIZE)
24602 -#ifdef CONFIG_X86_64
24603 - :init
24604 -#endif
24605 + . = ALIGN(PAGE_SIZE);
24606 + init_begin = .;
24607 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
24608 + VMLINUX_SYMBOL(_sinittext) = .;
24609 + INIT_TEXT
24610 + VMLINUX_SYMBOL(_einittext) = .;
24611 + . = ALIGN(PAGE_SIZE);
24612 + } :text.init
24613
24614 - INIT_DATA_SECTION(16)
24615 + /*
24616 + * .exit.text is discard at runtime, not link time, to deal with
24617 + * references from .altinstructions and .eh_frame
24618 + */
24619 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
24620 + EXIT_TEXT
24621 + . = ALIGN(16);
24622 + } :text.exit
24623 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
24624 +
24625 + . = ALIGN(PAGE_SIZE);
24626 + INIT_DATA_SECTION(16) :init
24627
24628 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
24629 __x86_cpu_dev_start = .;
24630 @@ -257,19 +338,12 @@ SECTIONS
24631 }
24632
24633 . = ALIGN(8);
24634 - /*
24635 - * .exit.text is discard at runtime, not link time, to deal with
24636 - * references from .altinstructions and .eh_frame
24637 - */
24638 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
24639 - EXIT_TEXT
24640 - }
24641
24642 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
24643 EXIT_DATA
24644 }
24645
24646 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
24647 +#ifndef CONFIG_SMP
24648 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
24649 #endif
24650
24651 @@ -288,16 +362,10 @@ SECTIONS
24652 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
24653 __smp_locks = .;
24654 *(.smp_locks)
24655 - . = ALIGN(PAGE_SIZE);
24656 __smp_locks_end = .;
24657 + . = ALIGN(PAGE_SIZE);
24658 }
24659
24660 -#ifdef CONFIG_X86_64
24661 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
24662 - NOSAVE_DATA
24663 - }
24664 -#endif
24665 -
24666 /* BSS */
24667 . = ALIGN(PAGE_SIZE);
24668 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
24669 @@ -313,6 +381,7 @@ SECTIONS
24670 __brk_base = .;
24671 . += 64 * 1024; /* 64k alignment slop space */
24672 *(.brk_reservation) /* areas brk users have reserved */
24673 + . = ALIGN(HPAGE_SIZE);
24674 __brk_limit = .;
24675 }
24676
24677 @@ -339,13 +408,12 @@ SECTIONS
24678 * for the boot processor.
24679 */
24680 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
24681 -INIT_PER_CPU(gdt_page);
24682 INIT_PER_CPU(irq_stack_union);
24683
24684 /*
24685 * Build-time check on the image size:
24686 */
24687 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
24688 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
24689 "kernel image bigger than KERNEL_IMAGE_SIZE");
24690
24691 #ifdef CONFIG_SMP
24692 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
24693 index 9a907a6..f83f921 100644
24694 --- a/arch/x86/kernel/vsyscall_64.c
24695 +++ b/arch/x86/kernel/vsyscall_64.c
24696 @@ -56,15 +56,13 @@
24697 DEFINE_VVAR(int, vgetcpu_mode);
24698 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
24699
24700 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
24701 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
24702
24703 static int __init vsyscall_setup(char *str)
24704 {
24705 if (str) {
24706 if (!strcmp("emulate", str))
24707 vsyscall_mode = EMULATE;
24708 - else if (!strcmp("native", str))
24709 - vsyscall_mode = NATIVE;
24710 else if (!strcmp("none", str))
24711 vsyscall_mode = NONE;
24712 else
24713 @@ -323,8 +321,7 @@ do_ret:
24714 return true;
24715
24716 sigsegv:
24717 - force_sig(SIGSEGV, current);
24718 - return true;
24719 + do_group_exit(SIGKILL);
24720 }
24721
24722 /*
24723 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
24724 extern char __vvar_page;
24725 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
24726
24727 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
24728 - vsyscall_mode == NATIVE
24729 - ? PAGE_KERNEL_VSYSCALL
24730 - : PAGE_KERNEL_VVAR);
24731 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
24732 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
24733 (unsigned long)VSYSCALL_START);
24734
24735 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
24736 index 1330dd1..d220b99 100644
24737 --- a/arch/x86/kernel/x8664_ksyms_64.c
24738 +++ b/arch/x86/kernel/x8664_ksyms_64.c
24739 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
24740 EXPORT_SYMBOL(copy_user_generic_unrolled);
24741 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
24742 EXPORT_SYMBOL(__copy_user_nocache);
24743 -EXPORT_SYMBOL(_copy_from_user);
24744 -EXPORT_SYMBOL(_copy_to_user);
24745
24746 EXPORT_SYMBOL(copy_page);
24747 EXPORT_SYMBOL(clear_page);
24748 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
24749 index 7a3d075..6cb373d 100644
24750 --- a/arch/x86/kernel/x86_init.c
24751 +++ b/arch/x86/kernel/x86_init.c
24752 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
24753 },
24754 };
24755
24756 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24757 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
24758 .early_percpu_clock_init = x86_init_noop,
24759 .setup_percpu_clockev = setup_secondary_APIC_clock,
24760 };
24761 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24762 static void default_nmi_init(void) { };
24763 static int default_i8042_detect(void) { return 1; };
24764
24765 -struct x86_platform_ops x86_platform = {
24766 +struct x86_platform_ops x86_platform __read_only = {
24767 .calibrate_tsc = native_calibrate_tsc,
24768 .get_wallclock = mach_get_cmos_time,
24769 .set_wallclock = mach_set_rtc_mmss,
24770 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
24771 };
24772
24773 EXPORT_SYMBOL_GPL(x86_platform);
24774 -struct x86_msi_ops x86_msi = {
24775 +struct x86_msi_ops x86_msi __read_only = {
24776 .setup_msi_irqs = native_setup_msi_irqs,
24777 .teardown_msi_irq = native_teardown_msi_irq,
24778 .teardown_msi_irqs = default_teardown_msi_irqs,
24779 .restore_msi_irqs = default_restore_msi_irqs,
24780 };
24781
24782 -struct x86_io_apic_ops x86_io_apic_ops = {
24783 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
24784 .init = native_io_apic_init_mappings,
24785 .read = native_io_apic_read,
24786 .write = native_io_apic_write,
24787 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
24788 index ada87a3..afea76d 100644
24789 --- a/arch/x86/kernel/xsave.c
24790 +++ b/arch/x86/kernel/xsave.c
24791 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
24792 {
24793 int err;
24794
24795 + buf = (struct xsave_struct __user *)____m(buf);
24796 if (use_xsave())
24797 err = xsave_user(buf);
24798 else if (use_fxsr())
24799 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24800 */
24801 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24802 {
24803 + buf = (void __user *)____m(buf);
24804 if (use_xsave()) {
24805 if ((unsigned long)buf % 64 || fx_only) {
24806 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24807 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24808 index a20ecb5..d0e2194 100644
24809 --- a/arch/x86/kvm/cpuid.c
24810 +++ b/arch/x86/kvm/cpuid.c
24811 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24812 struct kvm_cpuid2 *cpuid,
24813 struct kvm_cpuid_entry2 __user *entries)
24814 {
24815 - int r;
24816 + int r, i;
24817
24818 r = -E2BIG;
24819 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24820 goto out;
24821 r = -EFAULT;
24822 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24823 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24824 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24825 goto out;
24826 + for (i = 0; i < cpuid->nent; ++i) {
24827 + struct kvm_cpuid_entry2 cpuid_entry;
24828 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24829 + goto out;
24830 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24831 + }
24832 vcpu->arch.cpuid_nent = cpuid->nent;
24833 kvm_apic_set_version(vcpu);
24834 kvm_x86_ops->cpuid_update(vcpu);
24835 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24836 struct kvm_cpuid2 *cpuid,
24837 struct kvm_cpuid_entry2 __user *entries)
24838 {
24839 - int r;
24840 + int r, i;
24841
24842 r = -E2BIG;
24843 if (cpuid->nent < vcpu->arch.cpuid_nent)
24844 goto out;
24845 r = -EFAULT;
24846 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24847 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24848 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24849 goto out;
24850 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24851 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24852 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24853 + goto out;
24854 + }
24855 return 0;
24856
24857 out:
24858 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24859 index a27e763..54bfe43 100644
24860 --- a/arch/x86/kvm/emulate.c
24861 +++ b/arch/x86/kvm/emulate.c
24862 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24863
24864 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24865 do { \
24866 + unsigned long _tmp; \
24867 __asm__ __volatile__ ( \
24868 _PRE_EFLAGS("0", "4", "2") \
24869 _op _suffix " %"_x"3,%1; " \
24870 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24871 /* Raw emulation: instruction has two explicit operands. */
24872 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24873 do { \
24874 - unsigned long _tmp; \
24875 - \
24876 switch ((ctxt)->dst.bytes) { \
24877 case 2: \
24878 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24879 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24880
24881 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24882 do { \
24883 - unsigned long _tmp; \
24884 switch ((ctxt)->dst.bytes) { \
24885 case 1: \
24886 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24887 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24888 index a2f492c..899e107 100644
24889 --- a/arch/x86/kvm/lapic.c
24890 +++ b/arch/x86/kvm/lapic.c
24891 @@ -55,7 +55,7 @@
24892 #define APIC_BUS_CYCLE_NS 1
24893
24894 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24895 -#define apic_debug(fmt, arg...)
24896 +#define apic_debug(fmt, arg...) do {} while (0)
24897
24898 #define APIC_LVT_NUM 6
24899 /* 14 is the version for Xeon and Pentium 8.4.8*/
24900 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24901 index 891eb6d..e027900 100644
24902 --- a/arch/x86/kvm/paging_tmpl.h
24903 +++ b/arch/x86/kvm/paging_tmpl.h
24904 @@ -208,7 +208,7 @@ retry_walk:
24905 if (unlikely(kvm_is_error_hva(host_addr)))
24906 goto error;
24907
24908 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24909 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24910 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24911 goto error;
24912 walker->ptep_user[walker->level - 1] = ptep_user;
24913 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24914 index d29d3cd..ec9d522 100644
24915 --- a/arch/x86/kvm/svm.c
24916 +++ b/arch/x86/kvm/svm.c
24917 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24918 int cpu = raw_smp_processor_id();
24919
24920 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24921 +
24922 + pax_open_kernel();
24923 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24924 + pax_close_kernel();
24925 +
24926 load_TR_desc();
24927 }
24928
24929 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24930 #endif
24931 #endif
24932
24933 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24934 + __set_fs(current_thread_info()->addr_limit);
24935 +#endif
24936 +
24937 reload_tss(vcpu);
24938
24939 local_irq_disable();
24940 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24941 index 9120ae1..238abc0 100644
24942 --- a/arch/x86/kvm/vmx.c
24943 +++ b/arch/x86/kvm/vmx.c
24944 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
24945 struct desc_struct *descs;
24946
24947 descs = (void *)gdt->address;
24948 +
24949 + pax_open_kernel();
24950 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24951 + pax_close_kernel();
24952 +
24953 load_TR_desc();
24954 }
24955
24956 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24957 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24958 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24959
24960 +#ifdef CONFIG_PAX_PER_CPU_PGD
24961 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24962 +#endif
24963 +
24964 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24965 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24966 vmx->loaded_vmcs->cpu = cpu;
24967 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
24968 if (!cpu_has_vmx_flexpriority())
24969 flexpriority_enabled = 0;
24970
24971 - if (!cpu_has_vmx_tpr_shadow())
24972 - kvm_x86_ops->update_cr8_intercept = NULL;
24973 + if (!cpu_has_vmx_tpr_shadow()) {
24974 + pax_open_kernel();
24975 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24976 + pax_close_kernel();
24977 + }
24978
24979 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24980 kvm_disable_largepages();
24981 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
24982
24983 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24984 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24985 +
24986 +#ifndef CONFIG_PAX_PER_CPU_PGD
24987 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24988 +#endif
24989
24990 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24991 #ifdef CONFIG_X86_64
24992 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
24993 native_store_idt(&dt);
24994 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24995
24996 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24997 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24998
24999 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
25000 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
25001 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25002 "jmp 2f \n\t"
25003 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
25004 "2: "
25005 +
25006 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25007 + "ljmp %[cs],$3f\n\t"
25008 + "3: "
25009 +#endif
25010 +
25011 /* Save guest registers, load host registers, keep flags */
25012 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
25013 "pop %0 \n\t"
25014 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25015 #endif
25016 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
25017 [wordsize]"i"(sizeof(ulong))
25018 +
25019 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25020 + ,[cs]"i"(__KERNEL_CS)
25021 +#endif
25022 +
25023 : "cc", "memory"
25024 #ifdef CONFIG_X86_64
25025 , "rax", "rbx", "rdi", "rsi"
25026 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25027 if (debugctlmsr)
25028 update_debugctlmsr(debugctlmsr);
25029
25030 -#ifndef CONFIG_X86_64
25031 +#ifdef CONFIG_X86_32
25032 /*
25033 * The sysexit path does not restore ds/es, so we must set them to
25034 * a reasonable value ourselves.
25035 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25036 * may be executed in interrupt context, which saves and restore segments
25037 * around it, nullifying its effect.
25038 */
25039 - loadsegment(ds, __USER_DS);
25040 - loadsegment(es, __USER_DS);
25041 + loadsegment(ds, __KERNEL_DS);
25042 + loadsegment(es, __KERNEL_DS);
25043 + loadsegment(ss, __KERNEL_DS);
25044 +
25045 +#ifdef CONFIG_PAX_KERNEXEC
25046 + loadsegment(fs, __KERNEL_PERCPU);
25047 +#endif
25048 +
25049 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25050 + __set_fs(current_thread_info()->addr_limit);
25051 +#endif
25052 +
25053 #endif
25054
25055 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
25056 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
25057 index 9a51121..f739a79 100644
25058 --- a/arch/x86/kvm/x86.c
25059 +++ b/arch/x86/kvm/x86.c
25060 @@ -1688,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
25061 {
25062 struct kvm *kvm = vcpu->kvm;
25063 int lm = is_long_mode(vcpu);
25064 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
25065 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
25066 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
25067 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
25068 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
25069 : kvm->arch.xen_hvm_config.blob_size_32;
25070 u32 page_num = data & ~PAGE_MASK;
25071 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
25072 if (n < msr_list.nmsrs)
25073 goto out;
25074 r = -EFAULT;
25075 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
25076 + goto out;
25077 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
25078 num_msrs_to_save * sizeof(u32)))
25079 goto out;
25080 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
25081 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
25082 struct kvm_interrupt *irq)
25083 {
25084 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
25085 + if (irq->irq >= KVM_NR_INTERRUPTS)
25086 return -EINVAL;
25087 if (irqchip_in_kernel(vcpu->kvm))
25088 return -ENXIO;
25089 @@ -5209,7 +5211,7 @@ static struct notifier_block pvclock_gtod_notifier = {
25090 };
25091 #endif
25092
25093 -int kvm_arch_init(void *opaque)
25094 +int kvm_arch_init(const void *opaque)
25095 {
25096 int r;
25097 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
25098 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
25099 index 20a4fd4..d806083 100644
25100 --- a/arch/x86/lguest/boot.c
25101 +++ b/arch/x86/lguest/boot.c
25102 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
25103 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
25104 * Launcher to reboot us.
25105 */
25106 -static void lguest_restart(char *reason)
25107 +static __noreturn void lguest_restart(char *reason)
25108 {
25109 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
25110 + BUG();
25111 }
25112
25113 /*G:050
25114 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
25115 index 00933d5..3a64af9 100644
25116 --- a/arch/x86/lib/atomic64_386_32.S
25117 +++ b/arch/x86/lib/atomic64_386_32.S
25118 @@ -48,6 +48,10 @@ BEGIN(read)
25119 movl (v), %eax
25120 movl 4(v), %edx
25121 RET_ENDP
25122 +BEGIN(read_unchecked)
25123 + movl (v), %eax
25124 + movl 4(v), %edx
25125 +RET_ENDP
25126 #undef v
25127
25128 #define v %esi
25129 @@ -55,6 +59,10 @@ BEGIN(set)
25130 movl %ebx, (v)
25131 movl %ecx, 4(v)
25132 RET_ENDP
25133 +BEGIN(set_unchecked)
25134 + movl %ebx, (v)
25135 + movl %ecx, 4(v)
25136 +RET_ENDP
25137 #undef v
25138
25139 #define v %esi
25140 @@ -70,6 +78,20 @@ RET_ENDP
25141 BEGIN(add)
25142 addl %eax, (v)
25143 adcl %edx, 4(v)
25144 +
25145 +#ifdef CONFIG_PAX_REFCOUNT
25146 + jno 0f
25147 + subl %eax, (v)
25148 + sbbl %edx, 4(v)
25149 + int $4
25150 +0:
25151 + _ASM_EXTABLE(0b, 0b)
25152 +#endif
25153 +
25154 +RET_ENDP
25155 +BEGIN(add_unchecked)
25156 + addl %eax, (v)
25157 + adcl %edx, 4(v)
25158 RET_ENDP
25159 #undef v
25160
25161 @@ -77,6 +99,24 @@ RET_ENDP
25162 BEGIN(add_return)
25163 addl (v), %eax
25164 adcl 4(v), %edx
25165 +
25166 +#ifdef CONFIG_PAX_REFCOUNT
25167 + into
25168 +1234:
25169 + _ASM_EXTABLE(1234b, 2f)
25170 +#endif
25171 +
25172 + movl %eax, (v)
25173 + movl %edx, 4(v)
25174 +
25175 +#ifdef CONFIG_PAX_REFCOUNT
25176 +2:
25177 +#endif
25178 +
25179 +RET_ENDP
25180 +BEGIN(add_return_unchecked)
25181 + addl (v), %eax
25182 + adcl 4(v), %edx
25183 movl %eax, (v)
25184 movl %edx, 4(v)
25185 RET_ENDP
25186 @@ -86,6 +126,20 @@ RET_ENDP
25187 BEGIN(sub)
25188 subl %eax, (v)
25189 sbbl %edx, 4(v)
25190 +
25191 +#ifdef CONFIG_PAX_REFCOUNT
25192 + jno 0f
25193 + addl %eax, (v)
25194 + adcl %edx, 4(v)
25195 + int $4
25196 +0:
25197 + _ASM_EXTABLE(0b, 0b)
25198 +#endif
25199 +
25200 +RET_ENDP
25201 +BEGIN(sub_unchecked)
25202 + subl %eax, (v)
25203 + sbbl %edx, 4(v)
25204 RET_ENDP
25205 #undef v
25206
25207 @@ -96,6 +150,27 @@ BEGIN(sub_return)
25208 sbbl $0, %edx
25209 addl (v), %eax
25210 adcl 4(v), %edx
25211 +
25212 +#ifdef CONFIG_PAX_REFCOUNT
25213 + into
25214 +1234:
25215 + _ASM_EXTABLE(1234b, 2f)
25216 +#endif
25217 +
25218 + movl %eax, (v)
25219 + movl %edx, 4(v)
25220 +
25221 +#ifdef CONFIG_PAX_REFCOUNT
25222 +2:
25223 +#endif
25224 +
25225 +RET_ENDP
25226 +BEGIN(sub_return_unchecked)
25227 + negl %edx
25228 + negl %eax
25229 + sbbl $0, %edx
25230 + addl (v), %eax
25231 + adcl 4(v), %edx
25232 movl %eax, (v)
25233 movl %edx, 4(v)
25234 RET_ENDP
25235 @@ -105,6 +180,20 @@ RET_ENDP
25236 BEGIN(inc)
25237 addl $1, (v)
25238 adcl $0, 4(v)
25239 +
25240 +#ifdef CONFIG_PAX_REFCOUNT
25241 + jno 0f
25242 + subl $1, (v)
25243 + sbbl $0, 4(v)
25244 + int $4
25245 +0:
25246 + _ASM_EXTABLE(0b, 0b)
25247 +#endif
25248 +
25249 +RET_ENDP
25250 +BEGIN(inc_unchecked)
25251 + addl $1, (v)
25252 + adcl $0, 4(v)
25253 RET_ENDP
25254 #undef v
25255
25256 @@ -114,6 +203,26 @@ BEGIN(inc_return)
25257 movl 4(v), %edx
25258 addl $1, %eax
25259 adcl $0, %edx
25260 +
25261 +#ifdef CONFIG_PAX_REFCOUNT
25262 + into
25263 +1234:
25264 + _ASM_EXTABLE(1234b, 2f)
25265 +#endif
25266 +
25267 + movl %eax, (v)
25268 + movl %edx, 4(v)
25269 +
25270 +#ifdef CONFIG_PAX_REFCOUNT
25271 +2:
25272 +#endif
25273 +
25274 +RET_ENDP
25275 +BEGIN(inc_return_unchecked)
25276 + movl (v), %eax
25277 + movl 4(v), %edx
25278 + addl $1, %eax
25279 + adcl $0, %edx
25280 movl %eax, (v)
25281 movl %edx, 4(v)
25282 RET_ENDP
25283 @@ -123,6 +232,20 @@ RET_ENDP
25284 BEGIN(dec)
25285 subl $1, (v)
25286 sbbl $0, 4(v)
25287 +
25288 +#ifdef CONFIG_PAX_REFCOUNT
25289 + jno 0f
25290 + addl $1, (v)
25291 + adcl $0, 4(v)
25292 + int $4
25293 +0:
25294 + _ASM_EXTABLE(0b, 0b)
25295 +#endif
25296 +
25297 +RET_ENDP
25298 +BEGIN(dec_unchecked)
25299 + subl $1, (v)
25300 + sbbl $0, 4(v)
25301 RET_ENDP
25302 #undef v
25303
25304 @@ -132,6 +255,26 @@ BEGIN(dec_return)
25305 movl 4(v), %edx
25306 subl $1, %eax
25307 sbbl $0, %edx
25308 +
25309 +#ifdef CONFIG_PAX_REFCOUNT
25310 + into
25311 +1234:
25312 + _ASM_EXTABLE(1234b, 2f)
25313 +#endif
25314 +
25315 + movl %eax, (v)
25316 + movl %edx, 4(v)
25317 +
25318 +#ifdef CONFIG_PAX_REFCOUNT
25319 +2:
25320 +#endif
25321 +
25322 +RET_ENDP
25323 +BEGIN(dec_return_unchecked)
25324 + movl (v), %eax
25325 + movl 4(v), %edx
25326 + subl $1, %eax
25327 + sbbl $0, %edx
25328 movl %eax, (v)
25329 movl %edx, 4(v)
25330 RET_ENDP
25331 @@ -143,6 +286,13 @@ BEGIN(add_unless)
25332 adcl %edx, %edi
25333 addl (v), %eax
25334 adcl 4(v), %edx
25335 +
25336 +#ifdef CONFIG_PAX_REFCOUNT
25337 + into
25338 +1234:
25339 + _ASM_EXTABLE(1234b, 2f)
25340 +#endif
25341 +
25342 cmpl %eax, %ecx
25343 je 3f
25344 1:
25345 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
25346 1:
25347 addl $1, %eax
25348 adcl $0, %edx
25349 +
25350 +#ifdef CONFIG_PAX_REFCOUNT
25351 + into
25352 +1234:
25353 + _ASM_EXTABLE(1234b, 2f)
25354 +#endif
25355 +
25356 movl %eax, (v)
25357 movl %edx, 4(v)
25358 movl $1, %eax
25359 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
25360 movl 4(v), %edx
25361 subl $1, %eax
25362 sbbl $0, %edx
25363 +
25364 +#ifdef CONFIG_PAX_REFCOUNT
25365 + into
25366 +1234:
25367 + _ASM_EXTABLE(1234b, 1f)
25368 +#endif
25369 +
25370 js 1f
25371 movl %eax, (v)
25372 movl %edx, 4(v)
25373 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
25374 index f5cc9eb..51fa319 100644
25375 --- a/arch/x86/lib/atomic64_cx8_32.S
25376 +++ b/arch/x86/lib/atomic64_cx8_32.S
25377 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
25378 CFI_STARTPROC
25379
25380 read64 %ecx
25381 + pax_force_retaddr
25382 ret
25383 CFI_ENDPROC
25384 ENDPROC(atomic64_read_cx8)
25385
25386 +ENTRY(atomic64_read_unchecked_cx8)
25387 + CFI_STARTPROC
25388 +
25389 + read64 %ecx
25390 + pax_force_retaddr
25391 + ret
25392 + CFI_ENDPROC
25393 +ENDPROC(atomic64_read_unchecked_cx8)
25394 +
25395 ENTRY(atomic64_set_cx8)
25396 CFI_STARTPROC
25397
25398 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
25399 cmpxchg8b (%esi)
25400 jne 1b
25401
25402 + pax_force_retaddr
25403 ret
25404 CFI_ENDPROC
25405 ENDPROC(atomic64_set_cx8)
25406
25407 +ENTRY(atomic64_set_unchecked_cx8)
25408 + CFI_STARTPROC
25409 +
25410 +1:
25411 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
25412 + * are atomic on 586 and newer */
25413 + cmpxchg8b (%esi)
25414 + jne 1b
25415 +
25416 + pax_force_retaddr
25417 + ret
25418 + CFI_ENDPROC
25419 +ENDPROC(atomic64_set_unchecked_cx8)
25420 +
25421 ENTRY(atomic64_xchg_cx8)
25422 CFI_STARTPROC
25423
25424 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
25425 cmpxchg8b (%esi)
25426 jne 1b
25427
25428 + pax_force_retaddr
25429 ret
25430 CFI_ENDPROC
25431 ENDPROC(atomic64_xchg_cx8)
25432
25433 -.macro addsub_return func ins insc
25434 -ENTRY(atomic64_\func\()_return_cx8)
25435 +.macro addsub_return func ins insc unchecked=""
25436 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
25437 CFI_STARTPROC
25438 SAVE ebp
25439 SAVE ebx
25440 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
25441 movl %edx, %ecx
25442 \ins\()l %esi, %ebx
25443 \insc\()l %edi, %ecx
25444 +
25445 +.ifb \unchecked
25446 +#ifdef CONFIG_PAX_REFCOUNT
25447 + into
25448 +2:
25449 + _ASM_EXTABLE(2b, 3f)
25450 +#endif
25451 +.endif
25452 +
25453 LOCK_PREFIX
25454 cmpxchg8b (%ebp)
25455 jne 1b
25456 -
25457 -10:
25458 movl %ebx, %eax
25459 movl %ecx, %edx
25460 +
25461 +.ifb \unchecked
25462 +#ifdef CONFIG_PAX_REFCOUNT
25463 +3:
25464 +#endif
25465 +.endif
25466 +
25467 RESTORE edi
25468 RESTORE esi
25469 RESTORE ebx
25470 RESTORE ebp
25471 + pax_force_retaddr
25472 ret
25473 CFI_ENDPROC
25474 -ENDPROC(atomic64_\func\()_return_cx8)
25475 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
25476 .endm
25477
25478 addsub_return add add adc
25479 addsub_return sub sub sbb
25480 +addsub_return add add adc _unchecked
25481 +addsub_return sub sub sbb _unchecked
25482
25483 -.macro incdec_return func ins insc
25484 -ENTRY(atomic64_\func\()_return_cx8)
25485 +.macro incdec_return func ins insc unchecked=""
25486 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
25487 CFI_STARTPROC
25488 SAVE ebx
25489
25490 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
25491 movl %edx, %ecx
25492 \ins\()l $1, %ebx
25493 \insc\()l $0, %ecx
25494 +
25495 +.ifb \unchecked
25496 +#ifdef CONFIG_PAX_REFCOUNT
25497 + into
25498 +2:
25499 + _ASM_EXTABLE(2b, 3f)
25500 +#endif
25501 +.endif
25502 +
25503 LOCK_PREFIX
25504 cmpxchg8b (%esi)
25505 jne 1b
25506
25507 -10:
25508 movl %ebx, %eax
25509 movl %ecx, %edx
25510 +
25511 +.ifb \unchecked
25512 +#ifdef CONFIG_PAX_REFCOUNT
25513 +3:
25514 +#endif
25515 +.endif
25516 +
25517 RESTORE ebx
25518 + pax_force_retaddr
25519 ret
25520 CFI_ENDPROC
25521 -ENDPROC(atomic64_\func\()_return_cx8)
25522 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
25523 .endm
25524
25525 incdec_return inc add adc
25526 incdec_return dec sub sbb
25527 +incdec_return inc add adc _unchecked
25528 +incdec_return dec sub sbb _unchecked
25529
25530 ENTRY(atomic64_dec_if_positive_cx8)
25531 CFI_STARTPROC
25532 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
25533 movl %edx, %ecx
25534 subl $1, %ebx
25535 sbb $0, %ecx
25536 +
25537 +#ifdef CONFIG_PAX_REFCOUNT
25538 + into
25539 +1234:
25540 + _ASM_EXTABLE(1234b, 2f)
25541 +#endif
25542 +
25543 js 2f
25544 LOCK_PREFIX
25545 cmpxchg8b (%esi)
25546 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
25547 movl %ebx, %eax
25548 movl %ecx, %edx
25549 RESTORE ebx
25550 + pax_force_retaddr
25551 ret
25552 CFI_ENDPROC
25553 ENDPROC(atomic64_dec_if_positive_cx8)
25554 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
25555 movl %edx, %ecx
25556 addl %ebp, %ebx
25557 adcl %edi, %ecx
25558 +
25559 +#ifdef CONFIG_PAX_REFCOUNT
25560 + into
25561 +1234:
25562 + _ASM_EXTABLE(1234b, 3f)
25563 +#endif
25564 +
25565 LOCK_PREFIX
25566 cmpxchg8b (%esi)
25567 jne 1b
25568 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
25569 CFI_ADJUST_CFA_OFFSET -8
25570 RESTORE ebx
25571 RESTORE ebp
25572 + pax_force_retaddr
25573 ret
25574 4:
25575 cmpl %edx, 4(%esp)
25576 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
25577 xorl %ecx, %ecx
25578 addl $1, %ebx
25579 adcl %edx, %ecx
25580 +
25581 +#ifdef CONFIG_PAX_REFCOUNT
25582 + into
25583 +1234:
25584 + _ASM_EXTABLE(1234b, 3f)
25585 +#endif
25586 +
25587 LOCK_PREFIX
25588 cmpxchg8b (%esi)
25589 jne 1b
25590 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
25591 movl $1, %eax
25592 3:
25593 RESTORE ebx
25594 + pax_force_retaddr
25595 ret
25596 CFI_ENDPROC
25597 ENDPROC(atomic64_inc_not_zero_cx8)
25598 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
25599 index 2af5df3..62b1a5a 100644
25600 --- a/arch/x86/lib/checksum_32.S
25601 +++ b/arch/x86/lib/checksum_32.S
25602 @@ -29,7 +29,8 @@
25603 #include <asm/dwarf2.h>
25604 #include <asm/errno.h>
25605 #include <asm/asm.h>
25606 -
25607 +#include <asm/segment.h>
25608 +
25609 /*
25610 * computes a partial checksum, e.g. for TCP/UDP fragments
25611 */
25612 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
25613
25614 #define ARGBASE 16
25615 #define FP 12
25616 -
25617 -ENTRY(csum_partial_copy_generic)
25618 +
25619 +ENTRY(csum_partial_copy_generic_to_user)
25620 CFI_STARTPROC
25621 +
25622 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25623 + pushl_cfi %gs
25624 + popl_cfi %es
25625 + jmp csum_partial_copy_generic
25626 +#endif
25627 +
25628 +ENTRY(csum_partial_copy_generic_from_user)
25629 +
25630 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25631 + pushl_cfi %gs
25632 + popl_cfi %ds
25633 +#endif
25634 +
25635 +ENTRY(csum_partial_copy_generic)
25636 subl $4,%esp
25637 CFI_ADJUST_CFA_OFFSET 4
25638 pushl_cfi %edi
25639 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
25640 jmp 4f
25641 SRC(1: movw (%esi), %bx )
25642 addl $2, %esi
25643 -DST( movw %bx, (%edi) )
25644 +DST( movw %bx, %es:(%edi) )
25645 addl $2, %edi
25646 addw %bx, %ax
25647 adcl $0, %eax
25648 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
25649 SRC(1: movl (%esi), %ebx )
25650 SRC( movl 4(%esi), %edx )
25651 adcl %ebx, %eax
25652 -DST( movl %ebx, (%edi) )
25653 +DST( movl %ebx, %es:(%edi) )
25654 adcl %edx, %eax
25655 -DST( movl %edx, 4(%edi) )
25656 +DST( movl %edx, %es:4(%edi) )
25657
25658 SRC( movl 8(%esi), %ebx )
25659 SRC( movl 12(%esi), %edx )
25660 adcl %ebx, %eax
25661 -DST( movl %ebx, 8(%edi) )
25662 +DST( movl %ebx, %es:8(%edi) )
25663 adcl %edx, %eax
25664 -DST( movl %edx, 12(%edi) )
25665 +DST( movl %edx, %es:12(%edi) )
25666
25667 SRC( movl 16(%esi), %ebx )
25668 SRC( movl 20(%esi), %edx )
25669 adcl %ebx, %eax
25670 -DST( movl %ebx, 16(%edi) )
25671 +DST( movl %ebx, %es:16(%edi) )
25672 adcl %edx, %eax
25673 -DST( movl %edx, 20(%edi) )
25674 +DST( movl %edx, %es:20(%edi) )
25675
25676 SRC( movl 24(%esi), %ebx )
25677 SRC( movl 28(%esi), %edx )
25678 adcl %ebx, %eax
25679 -DST( movl %ebx, 24(%edi) )
25680 +DST( movl %ebx, %es:24(%edi) )
25681 adcl %edx, %eax
25682 -DST( movl %edx, 28(%edi) )
25683 +DST( movl %edx, %es:28(%edi) )
25684
25685 lea 32(%esi), %esi
25686 lea 32(%edi), %edi
25687 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
25688 shrl $2, %edx # This clears CF
25689 SRC(3: movl (%esi), %ebx )
25690 adcl %ebx, %eax
25691 -DST( movl %ebx, (%edi) )
25692 +DST( movl %ebx, %es:(%edi) )
25693 lea 4(%esi), %esi
25694 lea 4(%edi), %edi
25695 dec %edx
25696 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
25697 jb 5f
25698 SRC( movw (%esi), %cx )
25699 leal 2(%esi), %esi
25700 -DST( movw %cx, (%edi) )
25701 +DST( movw %cx, %es:(%edi) )
25702 leal 2(%edi), %edi
25703 je 6f
25704 shll $16,%ecx
25705 SRC(5: movb (%esi), %cl )
25706 -DST( movb %cl, (%edi) )
25707 +DST( movb %cl, %es:(%edi) )
25708 6: addl %ecx, %eax
25709 adcl $0, %eax
25710 7:
25711 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
25712
25713 6001:
25714 movl ARGBASE+20(%esp), %ebx # src_err_ptr
25715 - movl $-EFAULT, (%ebx)
25716 + movl $-EFAULT, %ss:(%ebx)
25717
25718 # zero the complete destination - computing the rest
25719 # is too much work
25720 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
25721
25722 6002:
25723 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25724 - movl $-EFAULT,(%ebx)
25725 + movl $-EFAULT,%ss:(%ebx)
25726 jmp 5000b
25727
25728 .previous
25729
25730 + pushl_cfi %ss
25731 + popl_cfi %ds
25732 + pushl_cfi %ss
25733 + popl_cfi %es
25734 popl_cfi %ebx
25735 CFI_RESTORE ebx
25736 popl_cfi %esi
25737 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
25738 popl_cfi %ecx # equivalent to addl $4,%esp
25739 ret
25740 CFI_ENDPROC
25741 -ENDPROC(csum_partial_copy_generic)
25742 +ENDPROC(csum_partial_copy_generic_to_user)
25743
25744 #else
25745
25746 /* Version for PentiumII/PPro */
25747
25748 #define ROUND1(x) \
25749 + nop; nop; nop; \
25750 SRC(movl x(%esi), %ebx ) ; \
25751 addl %ebx, %eax ; \
25752 - DST(movl %ebx, x(%edi) ) ;
25753 + DST(movl %ebx, %es:x(%edi)) ;
25754
25755 #define ROUND(x) \
25756 + nop; nop; nop; \
25757 SRC(movl x(%esi), %ebx ) ; \
25758 adcl %ebx, %eax ; \
25759 - DST(movl %ebx, x(%edi) ) ;
25760 + DST(movl %ebx, %es:x(%edi)) ;
25761
25762 #define ARGBASE 12
25763 -
25764 -ENTRY(csum_partial_copy_generic)
25765 +
25766 +ENTRY(csum_partial_copy_generic_to_user)
25767 CFI_STARTPROC
25768 +
25769 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25770 + pushl_cfi %gs
25771 + popl_cfi %es
25772 + jmp csum_partial_copy_generic
25773 +#endif
25774 +
25775 +ENTRY(csum_partial_copy_generic_from_user)
25776 +
25777 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25778 + pushl_cfi %gs
25779 + popl_cfi %ds
25780 +#endif
25781 +
25782 +ENTRY(csum_partial_copy_generic)
25783 pushl_cfi %ebx
25784 CFI_REL_OFFSET ebx, 0
25785 pushl_cfi %edi
25786 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25787 subl %ebx, %edi
25788 lea -1(%esi),%edx
25789 andl $-32,%edx
25790 - lea 3f(%ebx,%ebx), %ebx
25791 + lea 3f(%ebx,%ebx,2), %ebx
25792 testl %esi, %esi
25793 jmp *%ebx
25794 1: addl $64,%esi
25795 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25796 jb 5f
25797 SRC( movw (%esi), %dx )
25798 leal 2(%esi), %esi
25799 -DST( movw %dx, (%edi) )
25800 +DST( movw %dx, %es:(%edi) )
25801 leal 2(%edi), %edi
25802 je 6f
25803 shll $16,%edx
25804 5:
25805 SRC( movb (%esi), %dl )
25806 -DST( movb %dl, (%edi) )
25807 +DST( movb %dl, %es:(%edi) )
25808 6: addl %edx, %eax
25809 adcl $0, %eax
25810 7:
25811 .section .fixup, "ax"
25812 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25813 - movl $-EFAULT, (%ebx)
25814 + movl $-EFAULT, %ss:(%ebx)
25815 # zero the complete destination (computing the rest is too much work)
25816 movl ARGBASE+8(%esp),%edi # dst
25817 movl ARGBASE+12(%esp),%ecx # len
25818 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25819 rep; stosb
25820 jmp 7b
25821 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25822 - movl $-EFAULT, (%ebx)
25823 + movl $-EFAULT, %ss:(%ebx)
25824 jmp 7b
25825 .previous
25826
25827 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25828 + pushl_cfi %ss
25829 + popl_cfi %ds
25830 + pushl_cfi %ss
25831 + popl_cfi %es
25832 +#endif
25833 +
25834 popl_cfi %esi
25835 CFI_RESTORE esi
25836 popl_cfi %edi
25837 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25838 CFI_RESTORE ebx
25839 ret
25840 CFI_ENDPROC
25841 -ENDPROC(csum_partial_copy_generic)
25842 +ENDPROC(csum_partial_copy_generic_to_user)
25843
25844 #undef ROUND
25845 #undef ROUND1
25846 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25847 index f2145cf..cea889d 100644
25848 --- a/arch/x86/lib/clear_page_64.S
25849 +++ b/arch/x86/lib/clear_page_64.S
25850 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25851 movl $4096/8,%ecx
25852 xorl %eax,%eax
25853 rep stosq
25854 + pax_force_retaddr
25855 ret
25856 CFI_ENDPROC
25857 ENDPROC(clear_page_c)
25858 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25859 movl $4096,%ecx
25860 xorl %eax,%eax
25861 rep stosb
25862 + pax_force_retaddr
25863 ret
25864 CFI_ENDPROC
25865 ENDPROC(clear_page_c_e)
25866 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25867 leaq 64(%rdi),%rdi
25868 jnz .Lloop
25869 nop
25870 + pax_force_retaddr
25871 ret
25872 CFI_ENDPROC
25873 .Lclear_page_end:
25874 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25875
25876 #include <asm/cpufeature.h>
25877
25878 - .section .altinstr_replacement,"ax"
25879 + .section .altinstr_replacement,"a"
25880 1: .byte 0xeb /* jmp <disp8> */
25881 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25882 2: .byte 0xeb /* jmp <disp8> */
25883 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25884 index 1e572c5..2a162cd 100644
25885 --- a/arch/x86/lib/cmpxchg16b_emu.S
25886 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25887 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25888
25889 popf
25890 mov $1, %al
25891 + pax_force_retaddr
25892 ret
25893
25894 not_same:
25895 popf
25896 xor %al,%al
25897 + pax_force_retaddr
25898 ret
25899
25900 CFI_ENDPROC
25901 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25902 index 176cca6..1166c50 100644
25903 --- a/arch/x86/lib/copy_page_64.S
25904 +++ b/arch/x86/lib/copy_page_64.S
25905 @@ -9,6 +9,7 @@ copy_page_rep:
25906 CFI_STARTPROC
25907 movl $4096/8, %ecx
25908 rep movsq
25909 + pax_force_retaddr
25910 ret
25911 CFI_ENDPROC
25912 ENDPROC(copy_page_rep)
25913 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25914
25915 ENTRY(copy_page)
25916 CFI_STARTPROC
25917 - subq $2*8, %rsp
25918 - CFI_ADJUST_CFA_OFFSET 2*8
25919 + subq $3*8, %rsp
25920 + CFI_ADJUST_CFA_OFFSET 3*8
25921 movq %rbx, (%rsp)
25922 CFI_REL_OFFSET rbx, 0
25923 movq %r12, 1*8(%rsp)
25924 CFI_REL_OFFSET r12, 1*8
25925 + movq %r13, 2*8(%rsp)
25926 + CFI_REL_OFFSET r13, 2*8
25927
25928 movl $(4096/64)-5, %ecx
25929 .p2align 4
25930 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25931 movq 0x8*2(%rsi), %rdx
25932 movq 0x8*3(%rsi), %r8
25933 movq 0x8*4(%rsi), %r9
25934 - movq 0x8*5(%rsi), %r10
25935 + movq 0x8*5(%rsi), %r13
25936 movq 0x8*6(%rsi), %r11
25937 movq 0x8*7(%rsi), %r12
25938
25939 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25940 movq %rdx, 0x8*2(%rdi)
25941 movq %r8, 0x8*3(%rdi)
25942 movq %r9, 0x8*4(%rdi)
25943 - movq %r10, 0x8*5(%rdi)
25944 + movq %r13, 0x8*5(%rdi)
25945 movq %r11, 0x8*6(%rdi)
25946 movq %r12, 0x8*7(%rdi)
25947
25948 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25949 movq 0x8*2(%rsi), %rdx
25950 movq 0x8*3(%rsi), %r8
25951 movq 0x8*4(%rsi), %r9
25952 - movq 0x8*5(%rsi), %r10
25953 + movq 0x8*5(%rsi), %r13
25954 movq 0x8*6(%rsi), %r11
25955 movq 0x8*7(%rsi), %r12
25956
25957 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25958 movq %rdx, 0x8*2(%rdi)
25959 movq %r8, 0x8*3(%rdi)
25960 movq %r9, 0x8*4(%rdi)
25961 - movq %r10, 0x8*5(%rdi)
25962 + movq %r13, 0x8*5(%rdi)
25963 movq %r11, 0x8*6(%rdi)
25964 movq %r12, 0x8*7(%rdi)
25965
25966 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25967 CFI_RESTORE rbx
25968 movq 1*8(%rsp), %r12
25969 CFI_RESTORE r12
25970 - addq $2*8, %rsp
25971 - CFI_ADJUST_CFA_OFFSET -2*8
25972 + movq 2*8(%rsp), %r13
25973 + CFI_RESTORE r13
25974 + addq $3*8, %rsp
25975 + CFI_ADJUST_CFA_OFFSET -3*8
25976 + pax_force_retaddr
25977 ret
25978 .Lcopy_page_end:
25979 CFI_ENDPROC
25980 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25981
25982 #include <asm/cpufeature.h>
25983
25984 - .section .altinstr_replacement,"ax"
25985 + .section .altinstr_replacement,"a"
25986 1: .byte 0xeb /* jmp <disp8> */
25987 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25988 2:
25989 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25990 index a30ca15..d25fab6 100644
25991 --- a/arch/x86/lib/copy_user_64.S
25992 +++ b/arch/x86/lib/copy_user_64.S
25993 @@ -18,6 +18,7 @@
25994 #include <asm/alternative-asm.h>
25995 #include <asm/asm.h>
25996 #include <asm/smap.h>
25997 +#include <asm/pgtable.h>
25998
25999 /*
26000 * By placing feature2 after feature1 in altinstructions section, we logically
26001 @@ -31,7 +32,7 @@
26002 .byte 0xe9 /* 32bit jump */
26003 .long \orig-1f /* by default jump to orig */
26004 1:
26005 - .section .altinstr_replacement,"ax"
26006 + .section .altinstr_replacement,"a"
26007 2: .byte 0xe9 /* near jump with 32bit immediate */
26008 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
26009 3: .byte 0xe9 /* near jump with 32bit immediate */
26010 @@ -70,47 +71,20 @@
26011 #endif
26012 .endm
26013
26014 -/* Standard copy_to_user with segment limit checking */
26015 -ENTRY(_copy_to_user)
26016 - CFI_STARTPROC
26017 - GET_THREAD_INFO(%rax)
26018 - movq %rdi,%rcx
26019 - addq %rdx,%rcx
26020 - jc bad_to_user
26021 - cmpq TI_addr_limit(%rax),%rcx
26022 - ja bad_to_user
26023 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
26024 - copy_user_generic_unrolled,copy_user_generic_string, \
26025 - copy_user_enhanced_fast_string
26026 - CFI_ENDPROC
26027 -ENDPROC(_copy_to_user)
26028 -
26029 -/* Standard copy_from_user with segment limit checking */
26030 -ENTRY(_copy_from_user)
26031 - CFI_STARTPROC
26032 - GET_THREAD_INFO(%rax)
26033 - movq %rsi,%rcx
26034 - addq %rdx,%rcx
26035 - jc bad_from_user
26036 - cmpq TI_addr_limit(%rax),%rcx
26037 - ja bad_from_user
26038 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
26039 - copy_user_generic_unrolled,copy_user_generic_string, \
26040 - copy_user_enhanced_fast_string
26041 - CFI_ENDPROC
26042 -ENDPROC(_copy_from_user)
26043 -
26044 .section .fixup,"ax"
26045 /* must zero dest */
26046 ENTRY(bad_from_user)
26047 bad_from_user:
26048 CFI_STARTPROC
26049 + testl %edx,%edx
26050 + js bad_to_user
26051 movl %edx,%ecx
26052 xorl %eax,%eax
26053 rep
26054 stosb
26055 bad_to_user:
26056 movl %edx,%eax
26057 + pax_force_retaddr
26058 ret
26059 CFI_ENDPROC
26060 ENDPROC(bad_from_user)
26061 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
26062 jz 17f
26063 1: movq (%rsi),%r8
26064 2: movq 1*8(%rsi),%r9
26065 -3: movq 2*8(%rsi),%r10
26066 +3: movq 2*8(%rsi),%rax
26067 4: movq 3*8(%rsi),%r11
26068 5: movq %r8,(%rdi)
26069 6: movq %r9,1*8(%rdi)
26070 -7: movq %r10,2*8(%rdi)
26071 +7: movq %rax,2*8(%rdi)
26072 8: movq %r11,3*8(%rdi)
26073 9: movq 4*8(%rsi),%r8
26074 10: movq 5*8(%rsi),%r9
26075 -11: movq 6*8(%rsi),%r10
26076 +11: movq 6*8(%rsi),%rax
26077 12: movq 7*8(%rsi),%r11
26078 13: movq %r8,4*8(%rdi)
26079 14: movq %r9,5*8(%rdi)
26080 -15: movq %r10,6*8(%rdi)
26081 +15: movq %rax,6*8(%rdi)
26082 16: movq %r11,7*8(%rdi)
26083 leaq 64(%rsi),%rsi
26084 leaq 64(%rdi),%rdi
26085 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
26086 jnz 21b
26087 23: xor %eax,%eax
26088 ASM_CLAC
26089 + pax_force_retaddr
26090 ret
26091
26092 .section .fixup,"ax"
26093 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
26094 movsb
26095 4: xorl %eax,%eax
26096 ASM_CLAC
26097 + pax_force_retaddr
26098 ret
26099
26100 .section .fixup,"ax"
26101 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
26102 movsb
26103 2: xorl %eax,%eax
26104 ASM_CLAC
26105 + pax_force_retaddr
26106 ret
26107
26108 .section .fixup,"ax"
26109 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
26110 index 6a4f43c..f5f9e26 100644
26111 --- a/arch/x86/lib/copy_user_nocache_64.S
26112 +++ b/arch/x86/lib/copy_user_nocache_64.S
26113 @@ -8,6 +8,7 @@
26114
26115 #include <linux/linkage.h>
26116 #include <asm/dwarf2.h>
26117 +#include <asm/alternative-asm.h>
26118
26119 #define FIX_ALIGNMENT 1
26120
26121 @@ -16,6 +17,7 @@
26122 #include <asm/thread_info.h>
26123 #include <asm/asm.h>
26124 #include <asm/smap.h>
26125 +#include <asm/pgtable.h>
26126
26127 .macro ALIGN_DESTINATION
26128 #ifdef FIX_ALIGNMENT
26129 @@ -49,6 +51,15 @@
26130 */
26131 ENTRY(__copy_user_nocache)
26132 CFI_STARTPROC
26133 +
26134 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26135 + mov $PAX_USER_SHADOW_BASE,%rcx
26136 + cmp %rcx,%rsi
26137 + jae 1f
26138 + add %rcx,%rsi
26139 +1:
26140 +#endif
26141 +
26142 ASM_STAC
26143 cmpl $8,%edx
26144 jb 20f /* less then 8 bytes, go to byte copy loop */
26145 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
26146 jz 17f
26147 1: movq (%rsi),%r8
26148 2: movq 1*8(%rsi),%r9
26149 -3: movq 2*8(%rsi),%r10
26150 +3: movq 2*8(%rsi),%rax
26151 4: movq 3*8(%rsi),%r11
26152 5: movnti %r8,(%rdi)
26153 6: movnti %r9,1*8(%rdi)
26154 -7: movnti %r10,2*8(%rdi)
26155 +7: movnti %rax,2*8(%rdi)
26156 8: movnti %r11,3*8(%rdi)
26157 9: movq 4*8(%rsi),%r8
26158 10: movq 5*8(%rsi),%r9
26159 -11: movq 6*8(%rsi),%r10
26160 +11: movq 6*8(%rsi),%rax
26161 12: movq 7*8(%rsi),%r11
26162 13: movnti %r8,4*8(%rdi)
26163 14: movnti %r9,5*8(%rdi)
26164 -15: movnti %r10,6*8(%rdi)
26165 +15: movnti %rax,6*8(%rdi)
26166 16: movnti %r11,7*8(%rdi)
26167 leaq 64(%rsi),%rsi
26168 leaq 64(%rdi),%rdi
26169 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
26170 23: xorl %eax,%eax
26171 ASM_CLAC
26172 sfence
26173 + pax_force_retaddr
26174 ret
26175
26176 .section .fixup,"ax"
26177 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
26178 index 2419d5f..953ee51 100644
26179 --- a/arch/x86/lib/csum-copy_64.S
26180 +++ b/arch/x86/lib/csum-copy_64.S
26181 @@ -9,6 +9,7 @@
26182 #include <asm/dwarf2.h>
26183 #include <asm/errno.h>
26184 #include <asm/asm.h>
26185 +#include <asm/alternative-asm.h>
26186
26187 /*
26188 * Checksum copy with exception handling.
26189 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
26190 CFI_RESTORE rbp
26191 addq $7*8, %rsp
26192 CFI_ADJUST_CFA_OFFSET -7*8
26193 + pax_force_retaddr 0, 1
26194 ret
26195 CFI_RESTORE_STATE
26196
26197 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
26198 index 25b7ae8..169fafc 100644
26199 --- a/arch/x86/lib/csum-wrappers_64.c
26200 +++ b/arch/x86/lib/csum-wrappers_64.c
26201 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
26202 len -= 2;
26203 }
26204 }
26205 - isum = csum_partial_copy_generic((__force const void *)src,
26206 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
26207 dst, len, isum, errp, NULL);
26208 if (unlikely(*errp))
26209 goto out_err;
26210 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
26211 }
26212
26213 *errp = 0;
26214 - return csum_partial_copy_generic(src, (void __force *)dst,
26215 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
26216 len, isum, NULL, errp);
26217 }
26218 EXPORT_SYMBOL(csum_partial_copy_to_user);
26219 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
26220 index 156b9c8..b144132 100644
26221 --- a/arch/x86/lib/getuser.S
26222 +++ b/arch/x86/lib/getuser.S
26223 @@ -34,17 +34,40 @@
26224 #include <asm/thread_info.h>
26225 #include <asm/asm.h>
26226 #include <asm/smap.h>
26227 +#include <asm/segment.h>
26228 +#include <asm/pgtable.h>
26229 +#include <asm/alternative-asm.h>
26230 +
26231 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26232 +#define __copyuser_seg gs;
26233 +#else
26234 +#define __copyuser_seg
26235 +#endif
26236
26237 .text
26238 ENTRY(__get_user_1)
26239 CFI_STARTPROC
26240 +
26241 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26242 GET_THREAD_INFO(%_ASM_DX)
26243 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
26244 jae bad_get_user
26245 ASM_STAC
26246 -1: movzb (%_ASM_AX),%edx
26247 +
26248 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26249 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
26250 + cmp %_ASM_DX,%_ASM_AX
26251 + jae 1234f
26252 + add %_ASM_DX,%_ASM_AX
26253 +1234:
26254 +#endif
26255 +
26256 +#endif
26257 +
26258 +1: __copyuser_seg movzb (%_ASM_AX),%edx
26259 xor %eax,%eax
26260 ASM_CLAC
26261 + pax_force_retaddr
26262 ret
26263 CFI_ENDPROC
26264 ENDPROC(__get_user_1)
26265 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
26266 ENTRY(__get_user_2)
26267 CFI_STARTPROC
26268 add $1,%_ASM_AX
26269 +
26270 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26271 jc bad_get_user
26272 GET_THREAD_INFO(%_ASM_DX)
26273 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
26274 jae bad_get_user
26275 ASM_STAC
26276 -2: movzwl -1(%_ASM_AX),%edx
26277 +
26278 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26279 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
26280 + cmp %_ASM_DX,%_ASM_AX
26281 + jae 1234f
26282 + add %_ASM_DX,%_ASM_AX
26283 +1234:
26284 +#endif
26285 +
26286 +#endif
26287 +
26288 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
26289 xor %eax,%eax
26290 ASM_CLAC
26291 + pax_force_retaddr
26292 ret
26293 CFI_ENDPROC
26294 ENDPROC(__get_user_2)
26295 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
26296 ENTRY(__get_user_4)
26297 CFI_STARTPROC
26298 add $3,%_ASM_AX
26299 +
26300 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26301 jc bad_get_user
26302 GET_THREAD_INFO(%_ASM_DX)
26303 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
26304 jae bad_get_user
26305 ASM_STAC
26306 -3: mov -3(%_ASM_AX),%edx
26307 +
26308 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26309 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
26310 + cmp %_ASM_DX,%_ASM_AX
26311 + jae 1234f
26312 + add %_ASM_DX,%_ASM_AX
26313 +1234:
26314 +#endif
26315 +
26316 +#endif
26317 +
26318 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
26319 xor %eax,%eax
26320 ASM_CLAC
26321 + pax_force_retaddr
26322 ret
26323 CFI_ENDPROC
26324 ENDPROC(__get_user_4)
26325 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
26326 GET_THREAD_INFO(%_ASM_DX)
26327 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
26328 jae bad_get_user
26329 +
26330 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26331 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
26332 + cmp %_ASM_DX,%_ASM_AX
26333 + jae 1234f
26334 + add %_ASM_DX,%_ASM_AX
26335 +1234:
26336 +#endif
26337 +
26338 ASM_STAC
26339 4: movq -7(%_ASM_AX),%_ASM_DX
26340 xor %eax,%eax
26341 ASM_CLAC
26342 + pax_force_retaddr
26343 ret
26344 CFI_ENDPROC
26345 ENDPROC(__get_user_8)
26346 @@ -101,6 +162,7 @@ bad_get_user:
26347 xor %edx,%edx
26348 mov $(-EFAULT),%_ASM_AX
26349 ASM_CLAC
26350 + pax_force_retaddr
26351 ret
26352 CFI_ENDPROC
26353 END(bad_get_user)
26354 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
26355 index 54fcffe..7be149e 100644
26356 --- a/arch/x86/lib/insn.c
26357 +++ b/arch/x86/lib/insn.c
26358 @@ -20,8 +20,10 @@
26359
26360 #ifdef __KERNEL__
26361 #include <linux/string.h>
26362 +#include <asm/pgtable_types.h>
26363 #else
26364 #include <string.h>
26365 +#define ktla_ktva(addr) addr
26366 #endif
26367 #include <asm/inat.h>
26368 #include <asm/insn.h>
26369 @@ -53,8 +55,8 @@
26370 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
26371 {
26372 memset(insn, 0, sizeof(*insn));
26373 - insn->kaddr = kaddr;
26374 - insn->next_byte = kaddr;
26375 + insn->kaddr = ktla_ktva(kaddr);
26376 + insn->next_byte = ktla_ktva(kaddr);
26377 insn->x86_64 = x86_64 ? 1 : 0;
26378 insn->opnd_bytes = 4;
26379 if (x86_64)
26380 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
26381 index 05a95e7..326f2fa 100644
26382 --- a/arch/x86/lib/iomap_copy_64.S
26383 +++ b/arch/x86/lib/iomap_copy_64.S
26384 @@ -17,6 +17,7 @@
26385
26386 #include <linux/linkage.h>
26387 #include <asm/dwarf2.h>
26388 +#include <asm/alternative-asm.h>
26389
26390 /*
26391 * override generic version in lib/iomap_copy.c
26392 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
26393 CFI_STARTPROC
26394 movl %edx,%ecx
26395 rep movsd
26396 + pax_force_retaddr
26397 ret
26398 CFI_ENDPROC
26399 ENDPROC(__iowrite32_copy)
26400 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
26401 index 1c273be..da9cc0e 100644
26402 --- a/arch/x86/lib/memcpy_64.S
26403 +++ b/arch/x86/lib/memcpy_64.S
26404 @@ -33,6 +33,7 @@
26405 rep movsq
26406 movl %edx, %ecx
26407 rep movsb
26408 + pax_force_retaddr
26409 ret
26410 .Lmemcpy_e:
26411 .previous
26412 @@ -49,6 +50,7 @@
26413 movq %rdi, %rax
26414 movq %rdx, %rcx
26415 rep movsb
26416 + pax_force_retaddr
26417 ret
26418 .Lmemcpy_e_e:
26419 .previous
26420 @@ -76,13 +78,13 @@ ENTRY(memcpy)
26421 */
26422 movq 0*8(%rsi), %r8
26423 movq 1*8(%rsi), %r9
26424 - movq 2*8(%rsi), %r10
26425 + movq 2*8(%rsi), %rcx
26426 movq 3*8(%rsi), %r11
26427 leaq 4*8(%rsi), %rsi
26428
26429 movq %r8, 0*8(%rdi)
26430 movq %r9, 1*8(%rdi)
26431 - movq %r10, 2*8(%rdi)
26432 + movq %rcx, 2*8(%rdi)
26433 movq %r11, 3*8(%rdi)
26434 leaq 4*8(%rdi), %rdi
26435 jae .Lcopy_forward_loop
26436 @@ -105,12 +107,12 @@ ENTRY(memcpy)
26437 subq $0x20, %rdx
26438 movq -1*8(%rsi), %r8
26439 movq -2*8(%rsi), %r9
26440 - movq -3*8(%rsi), %r10
26441 + movq -3*8(%rsi), %rcx
26442 movq -4*8(%rsi), %r11
26443 leaq -4*8(%rsi), %rsi
26444 movq %r8, -1*8(%rdi)
26445 movq %r9, -2*8(%rdi)
26446 - movq %r10, -3*8(%rdi)
26447 + movq %rcx, -3*8(%rdi)
26448 movq %r11, -4*8(%rdi)
26449 leaq -4*8(%rdi), %rdi
26450 jae .Lcopy_backward_loop
26451 @@ -130,12 +132,13 @@ ENTRY(memcpy)
26452 */
26453 movq 0*8(%rsi), %r8
26454 movq 1*8(%rsi), %r9
26455 - movq -2*8(%rsi, %rdx), %r10
26456 + movq -2*8(%rsi, %rdx), %rcx
26457 movq -1*8(%rsi, %rdx), %r11
26458 movq %r8, 0*8(%rdi)
26459 movq %r9, 1*8(%rdi)
26460 - movq %r10, -2*8(%rdi, %rdx)
26461 + movq %rcx, -2*8(%rdi, %rdx)
26462 movq %r11, -1*8(%rdi, %rdx)
26463 + pax_force_retaddr
26464 retq
26465 .p2align 4
26466 .Lless_16bytes:
26467 @@ -148,6 +151,7 @@ ENTRY(memcpy)
26468 movq -1*8(%rsi, %rdx), %r9
26469 movq %r8, 0*8(%rdi)
26470 movq %r9, -1*8(%rdi, %rdx)
26471 + pax_force_retaddr
26472 retq
26473 .p2align 4
26474 .Lless_8bytes:
26475 @@ -161,6 +165,7 @@ ENTRY(memcpy)
26476 movl -4(%rsi, %rdx), %r8d
26477 movl %ecx, (%rdi)
26478 movl %r8d, -4(%rdi, %rdx)
26479 + pax_force_retaddr
26480 retq
26481 .p2align 4
26482 .Lless_3bytes:
26483 @@ -179,6 +184,7 @@ ENTRY(memcpy)
26484 movb %cl, (%rdi)
26485
26486 .Lend:
26487 + pax_force_retaddr
26488 retq
26489 CFI_ENDPROC
26490 ENDPROC(memcpy)
26491 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
26492 index ee16461..c39c199 100644
26493 --- a/arch/x86/lib/memmove_64.S
26494 +++ b/arch/x86/lib/memmove_64.S
26495 @@ -61,13 +61,13 @@ ENTRY(memmove)
26496 5:
26497 sub $0x20, %rdx
26498 movq 0*8(%rsi), %r11
26499 - movq 1*8(%rsi), %r10
26500 + movq 1*8(%rsi), %rcx
26501 movq 2*8(%rsi), %r9
26502 movq 3*8(%rsi), %r8
26503 leaq 4*8(%rsi), %rsi
26504
26505 movq %r11, 0*8(%rdi)
26506 - movq %r10, 1*8(%rdi)
26507 + movq %rcx, 1*8(%rdi)
26508 movq %r9, 2*8(%rdi)
26509 movq %r8, 3*8(%rdi)
26510 leaq 4*8(%rdi), %rdi
26511 @@ -81,10 +81,10 @@ ENTRY(memmove)
26512 4:
26513 movq %rdx, %rcx
26514 movq -8(%rsi, %rdx), %r11
26515 - lea -8(%rdi, %rdx), %r10
26516 + lea -8(%rdi, %rdx), %r9
26517 shrq $3, %rcx
26518 rep movsq
26519 - movq %r11, (%r10)
26520 + movq %r11, (%r9)
26521 jmp 13f
26522 .Lmemmove_end_forward:
26523
26524 @@ -95,14 +95,14 @@ ENTRY(memmove)
26525 7:
26526 movq %rdx, %rcx
26527 movq (%rsi), %r11
26528 - movq %rdi, %r10
26529 + movq %rdi, %r9
26530 leaq -8(%rsi, %rdx), %rsi
26531 leaq -8(%rdi, %rdx), %rdi
26532 shrq $3, %rcx
26533 std
26534 rep movsq
26535 cld
26536 - movq %r11, (%r10)
26537 + movq %r11, (%r9)
26538 jmp 13f
26539
26540 /*
26541 @@ -127,13 +127,13 @@ ENTRY(memmove)
26542 8:
26543 subq $0x20, %rdx
26544 movq -1*8(%rsi), %r11
26545 - movq -2*8(%rsi), %r10
26546 + movq -2*8(%rsi), %rcx
26547 movq -3*8(%rsi), %r9
26548 movq -4*8(%rsi), %r8
26549 leaq -4*8(%rsi), %rsi
26550
26551 movq %r11, -1*8(%rdi)
26552 - movq %r10, -2*8(%rdi)
26553 + movq %rcx, -2*8(%rdi)
26554 movq %r9, -3*8(%rdi)
26555 movq %r8, -4*8(%rdi)
26556 leaq -4*8(%rdi), %rdi
26557 @@ -151,11 +151,11 @@ ENTRY(memmove)
26558 * Move data from 16 bytes to 31 bytes.
26559 */
26560 movq 0*8(%rsi), %r11
26561 - movq 1*8(%rsi), %r10
26562 + movq 1*8(%rsi), %rcx
26563 movq -2*8(%rsi, %rdx), %r9
26564 movq -1*8(%rsi, %rdx), %r8
26565 movq %r11, 0*8(%rdi)
26566 - movq %r10, 1*8(%rdi)
26567 + movq %rcx, 1*8(%rdi)
26568 movq %r9, -2*8(%rdi, %rdx)
26569 movq %r8, -1*8(%rdi, %rdx)
26570 jmp 13f
26571 @@ -167,9 +167,9 @@ ENTRY(memmove)
26572 * Move data from 8 bytes to 15 bytes.
26573 */
26574 movq 0*8(%rsi), %r11
26575 - movq -1*8(%rsi, %rdx), %r10
26576 + movq -1*8(%rsi, %rdx), %r9
26577 movq %r11, 0*8(%rdi)
26578 - movq %r10, -1*8(%rdi, %rdx)
26579 + movq %r9, -1*8(%rdi, %rdx)
26580 jmp 13f
26581 10:
26582 cmpq $4, %rdx
26583 @@ -178,9 +178,9 @@ ENTRY(memmove)
26584 * Move data from 4 bytes to 7 bytes.
26585 */
26586 movl (%rsi), %r11d
26587 - movl -4(%rsi, %rdx), %r10d
26588 + movl -4(%rsi, %rdx), %r9d
26589 movl %r11d, (%rdi)
26590 - movl %r10d, -4(%rdi, %rdx)
26591 + movl %r9d, -4(%rdi, %rdx)
26592 jmp 13f
26593 11:
26594 cmp $2, %rdx
26595 @@ -189,9 +189,9 @@ ENTRY(memmove)
26596 * Move data from 2 bytes to 3 bytes.
26597 */
26598 movw (%rsi), %r11w
26599 - movw -2(%rsi, %rdx), %r10w
26600 + movw -2(%rsi, %rdx), %r9w
26601 movw %r11w, (%rdi)
26602 - movw %r10w, -2(%rdi, %rdx)
26603 + movw %r9w, -2(%rdi, %rdx)
26604 jmp 13f
26605 12:
26606 cmp $1, %rdx
26607 @@ -202,6 +202,7 @@ ENTRY(memmove)
26608 movb (%rsi), %r11b
26609 movb %r11b, (%rdi)
26610 13:
26611 + pax_force_retaddr
26612 retq
26613 CFI_ENDPROC
26614
26615 @@ -210,6 +211,7 @@ ENTRY(memmove)
26616 /* Forward moving data. */
26617 movq %rdx, %rcx
26618 rep movsb
26619 + pax_force_retaddr
26620 retq
26621 .Lmemmove_end_forward_efs:
26622 .previous
26623 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
26624 index 2dcb380..963660a 100644
26625 --- a/arch/x86/lib/memset_64.S
26626 +++ b/arch/x86/lib/memset_64.S
26627 @@ -30,6 +30,7 @@
26628 movl %edx,%ecx
26629 rep stosb
26630 movq %r9,%rax
26631 + pax_force_retaddr
26632 ret
26633 .Lmemset_e:
26634 .previous
26635 @@ -52,6 +53,7 @@
26636 movq %rdx,%rcx
26637 rep stosb
26638 movq %r9,%rax
26639 + pax_force_retaddr
26640 ret
26641 .Lmemset_e_e:
26642 .previous
26643 @@ -59,7 +61,7 @@
26644 ENTRY(memset)
26645 ENTRY(__memset)
26646 CFI_STARTPROC
26647 - movq %rdi,%r10
26648 + movq %rdi,%r11
26649
26650 /* expand byte value */
26651 movzbl %sil,%ecx
26652 @@ -117,7 +119,8 @@ ENTRY(__memset)
26653 jnz .Lloop_1
26654
26655 .Lende:
26656 - movq %r10,%rax
26657 + movq %r11,%rax
26658 + pax_force_retaddr
26659 ret
26660
26661 CFI_RESTORE_STATE
26662 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
26663 index c9f2d9b..e7fd2c0 100644
26664 --- a/arch/x86/lib/mmx_32.c
26665 +++ b/arch/x86/lib/mmx_32.c
26666 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26667 {
26668 void *p;
26669 int i;
26670 + unsigned long cr0;
26671
26672 if (unlikely(in_interrupt()))
26673 return __memcpy(to, from, len);
26674 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26675 kernel_fpu_begin();
26676
26677 __asm__ __volatile__ (
26678 - "1: prefetch (%0)\n" /* This set is 28 bytes */
26679 - " prefetch 64(%0)\n"
26680 - " prefetch 128(%0)\n"
26681 - " prefetch 192(%0)\n"
26682 - " prefetch 256(%0)\n"
26683 + "1: prefetch (%1)\n" /* This set is 28 bytes */
26684 + " prefetch 64(%1)\n"
26685 + " prefetch 128(%1)\n"
26686 + " prefetch 192(%1)\n"
26687 + " prefetch 256(%1)\n"
26688 "2: \n"
26689 ".section .fixup, \"ax\"\n"
26690 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26691 + "3: \n"
26692 +
26693 +#ifdef CONFIG_PAX_KERNEXEC
26694 + " movl %%cr0, %0\n"
26695 + " movl %0, %%eax\n"
26696 + " andl $0xFFFEFFFF, %%eax\n"
26697 + " movl %%eax, %%cr0\n"
26698 +#endif
26699 +
26700 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26701 +
26702 +#ifdef CONFIG_PAX_KERNEXEC
26703 + " movl %0, %%cr0\n"
26704 +#endif
26705 +
26706 " jmp 2b\n"
26707 ".previous\n"
26708 _ASM_EXTABLE(1b, 3b)
26709 - : : "r" (from));
26710 + : "=&r" (cr0) : "r" (from) : "ax");
26711
26712 for ( ; i > 5; i--) {
26713 __asm__ __volatile__ (
26714 - "1: prefetch 320(%0)\n"
26715 - "2: movq (%0), %%mm0\n"
26716 - " movq 8(%0), %%mm1\n"
26717 - " movq 16(%0), %%mm2\n"
26718 - " movq 24(%0), %%mm3\n"
26719 - " movq %%mm0, (%1)\n"
26720 - " movq %%mm1, 8(%1)\n"
26721 - " movq %%mm2, 16(%1)\n"
26722 - " movq %%mm3, 24(%1)\n"
26723 - " movq 32(%0), %%mm0\n"
26724 - " movq 40(%0), %%mm1\n"
26725 - " movq 48(%0), %%mm2\n"
26726 - " movq 56(%0), %%mm3\n"
26727 - " movq %%mm0, 32(%1)\n"
26728 - " movq %%mm1, 40(%1)\n"
26729 - " movq %%mm2, 48(%1)\n"
26730 - " movq %%mm3, 56(%1)\n"
26731 + "1: prefetch 320(%1)\n"
26732 + "2: movq (%1), %%mm0\n"
26733 + " movq 8(%1), %%mm1\n"
26734 + " movq 16(%1), %%mm2\n"
26735 + " movq 24(%1), %%mm3\n"
26736 + " movq %%mm0, (%2)\n"
26737 + " movq %%mm1, 8(%2)\n"
26738 + " movq %%mm2, 16(%2)\n"
26739 + " movq %%mm3, 24(%2)\n"
26740 + " movq 32(%1), %%mm0\n"
26741 + " movq 40(%1), %%mm1\n"
26742 + " movq 48(%1), %%mm2\n"
26743 + " movq 56(%1), %%mm3\n"
26744 + " movq %%mm0, 32(%2)\n"
26745 + " movq %%mm1, 40(%2)\n"
26746 + " movq %%mm2, 48(%2)\n"
26747 + " movq %%mm3, 56(%2)\n"
26748 ".section .fixup, \"ax\"\n"
26749 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26750 + "3:\n"
26751 +
26752 +#ifdef CONFIG_PAX_KERNEXEC
26753 + " movl %%cr0, %0\n"
26754 + " movl %0, %%eax\n"
26755 + " andl $0xFFFEFFFF, %%eax\n"
26756 + " movl %%eax, %%cr0\n"
26757 +#endif
26758 +
26759 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26760 +
26761 +#ifdef CONFIG_PAX_KERNEXEC
26762 + " movl %0, %%cr0\n"
26763 +#endif
26764 +
26765 " jmp 2b\n"
26766 ".previous\n"
26767 _ASM_EXTABLE(1b, 3b)
26768 - : : "r" (from), "r" (to) : "memory");
26769 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26770
26771 from += 64;
26772 to += 64;
26773 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26774 static void fast_copy_page(void *to, void *from)
26775 {
26776 int i;
26777 + unsigned long cr0;
26778
26779 kernel_fpu_begin();
26780
26781 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26782 * but that is for later. -AV
26783 */
26784 __asm__ __volatile__(
26785 - "1: prefetch (%0)\n"
26786 - " prefetch 64(%0)\n"
26787 - " prefetch 128(%0)\n"
26788 - " prefetch 192(%0)\n"
26789 - " prefetch 256(%0)\n"
26790 + "1: prefetch (%1)\n"
26791 + " prefetch 64(%1)\n"
26792 + " prefetch 128(%1)\n"
26793 + " prefetch 192(%1)\n"
26794 + " prefetch 256(%1)\n"
26795 "2: \n"
26796 ".section .fixup, \"ax\"\n"
26797 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26798 + "3: \n"
26799 +
26800 +#ifdef CONFIG_PAX_KERNEXEC
26801 + " movl %%cr0, %0\n"
26802 + " movl %0, %%eax\n"
26803 + " andl $0xFFFEFFFF, %%eax\n"
26804 + " movl %%eax, %%cr0\n"
26805 +#endif
26806 +
26807 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26808 +
26809 +#ifdef CONFIG_PAX_KERNEXEC
26810 + " movl %0, %%cr0\n"
26811 +#endif
26812 +
26813 " jmp 2b\n"
26814 ".previous\n"
26815 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26816 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26817
26818 for (i = 0; i < (4096-320)/64; i++) {
26819 __asm__ __volatile__ (
26820 - "1: prefetch 320(%0)\n"
26821 - "2: movq (%0), %%mm0\n"
26822 - " movntq %%mm0, (%1)\n"
26823 - " movq 8(%0), %%mm1\n"
26824 - " movntq %%mm1, 8(%1)\n"
26825 - " movq 16(%0), %%mm2\n"
26826 - " movntq %%mm2, 16(%1)\n"
26827 - " movq 24(%0), %%mm3\n"
26828 - " movntq %%mm3, 24(%1)\n"
26829 - " movq 32(%0), %%mm4\n"
26830 - " movntq %%mm4, 32(%1)\n"
26831 - " movq 40(%0), %%mm5\n"
26832 - " movntq %%mm5, 40(%1)\n"
26833 - " movq 48(%0), %%mm6\n"
26834 - " movntq %%mm6, 48(%1)\n"
26835 - " movq 56(%0), %%mm7\n"
26836 - " movntq %%mm7, 56(%1)\n"
26837 + "1: prefetch 320(%1)\n"
26838 + "2: movq (%1), %%mm0\n"
26839 + " movntq %%mm0, (%2)\n"
26840 + " movq 8(%1), %%mm1\n"
26841 + " movntq %%mm1, 8(%2)\n"
26842 + " movq 16(%1), %%mm2\n"
26843 + " movntq %%mm2, 16(%2)\n"
26844 + " movq 24(%1), %%mm3\n"
26845 + " movntq %%mm3, 24(%2)\n"
26846 + " movq 32(%1), %%mm4\n"
26847 + " movntq %%mm4, 32(%2)\n"
26848 + " movq 40(%1), %%mm5\n"
26849 + " movntq %%mm5, 40(%2)\n"
26850 + " movq 48(%1), %%mm6\n"
26851 + " movntq %%mm6, 48(%2)\n"
26852 + " movq 56(%1), %%mm7\n"
26853 + " movntq %%mm7, 56(%2)\n"
26854 ".section .fixup, \"ax\"\n"
26855 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26856 + "3:\n"
26857 +
26858 +#ifdef CONFIG_PAX_KERNEXEC
26859 + " movl %%cr0, %0\n"
26860 + " movl %0, %%eax\n"
26861 + " andl $0xFFFEFFFF, %%eax\n"
26862 + " movl %%eax, %%cr0\n"
26863 +#endif
26864 +
26865 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26866 +
26867 +#ifdef CONFIG_PAX_KERNEXEC
26868 + " movl %0, %%cr0\n"
26869 +#endif
26870 +
26871 " jmp 2b\n"
26872 ".previous\n"
26873 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26874 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26875
26876 from += 64;
26877 to += 64;
26878 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26879 static void fast_copy_page(void *to, void *from)
26880 {
26881 int i;
26882 + unsigned long cr0;
26883
26884 kernel_fpu_begin();
26885
26886 __asm__ __volatile__ (
26887 - "1: prefetch (%0)\n"
26888 - " prefetch 64(%0)\n"
26889 - " prefetch 128(%0)\n"
26890 - " prefetch 192(%0)\n"
26891 - " prefetch 256(%0)\n"
26892 + "1: prefetch (%1)\n"
26893 + " prefetch 64(%1)\n"
26894 + " prefetch 128(%1)\n"
26895 + " prefetch 192(%1)\n"
26896 + " prefetch 256(%1)\n"
26897 "2: \n"
26898 ".section .fixup, \"ax\"\n"
26899 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26900 + "3: \n"
26901 +
26902 +#ifdef CONFIG_PAX_KERNEXEC
26903 + " movl %%cr0, %0\n"
26904 + " movl %0, %%eax\n"
26905 + " andl $0xFFFEFFFF, %%eax\n"
26906 + " movl %%eax, %%cr0\n"
26907 +#endif
26908 +
26909 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26910 +
26911 +#ifdef CONFIG_PAX_KERNEXEC
26912 + " movl %0, %%cr0\n"
26913 +#endif
26914 +
26915 " jmp 2b\n"
26916 ".previous\n"
26917 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26918 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26919
26920 for (i = 0; i < 4096/64; i++) {
26921 __asm__ __volatile__ (
26922 - "1: prefetch 320(%0)\n"
26923 - "2: movq (%0), %%mm0\n"
26924 - " movq 8(%0), %%mm1\n"
26925 - " movq 16(%0), %%mm2\n"
26926 - " movq 24(%0), %%mm3\n"
26927 - " movq %%mm0, (%1)\n"
26928 - " movq %%mm1, 8(%1)\n"
26929 - " movq %%mm2, 16(%1)\n"
26930 - " movq %%mm3, 24(%1)\n"
26931 - " movq 32(%0), %%mm0\n"
26932 - " movq 40(%0), %%mm1\n"
26933 - " movq 48(%0), %%mm2\n"
26934 - " movq 56(%0), %%mm3\n"
26935 - " movq %%mm0, 32(%1)\n"
26936 - " movq %%mm1, 40(%1)\n"
26937 - " movq %%mm2, 48(%1)\n"
26938 - " movq %%mm3, 56(%1)\n"
26939 + "1: prefetch 320(%1)\n"
26940 + "2: movq (%1), %%mm0\n"
26941 + " movq 8(%1), %%mm1\n"
26942 + " movq 16(%1), %%mm2\n"
26943 + " movq 24(%1), %%mm3\n"
26944 + " movq %%mm0, (%2)\n"
26945 + " movq %%mm1, 8(%2)\n"
26946 + " movq %%mm2, 16(%2)\n"
26947 + " movq %%mm3, 24(%2)\n"
26948 + " movq 32(%1), %%mm0\n"
26949 + " movq 40(%1), %%mm1\n"
26950 + " movq 48(%1), %%mm2\n"
26951 + " movq 56(%1), %%mm3\n"
26952 + " movq %%mm0, 32(%2)\n"
26953 + " movq %%mm1, 40(%2)\n"
26954 + " movq %%mm2, 48(%2)\n"
26955 + " movq %%mm3, 56(%2)\n"
26956 ".section .fixup, \"ax\"\n"
26957 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26958 + "3:\n"
26959 +
26960 +#ifdef CONFIG_PAX_KERNEXEC
26961 + " movl %%cr0, %0\n"
26962 + " movl %0, %%eax\n"
26963 + " andl $0xFFFEFFFF, %%eax\n"
26964 + " movl %%eax, %%cr0\n"
26965 +#endif
26966 +
26967 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26968 +
26969 +#ifdef CONFIG_PAX_KERNEXEC
26970 + " movl %0, %%cr0\n"
26971 +#endif
26972 +
26973 " jmp 2b\n"
26974 ".previous\n"
26975 _ASM_EXTABLE(1b, 3b)
26976 - : : "r" (from), "r" (to) : "memory");
26977 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26978
26979 from += 64;
26980 to += 64;
26981 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26982 index f6d13ee..aca5f0b 100644
26983 --- a/arch/x86/lib/msr-reg.S
26984 +++ b/arch/x86/lib/msr-reg.S
26985 @@ -3,6 +3,7 @@
26986 #include <asm/dwarf2.h>
26987 #include <asm/asm.h>
26988 #include <asm/msr.h>
26989 +#include <asm/alternative-asm.h>
26990
26991 #ifdef CONFIG_X86_64
26992 /*
26993 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26994 CFI_STARTPROC
26995 pushq_cfi %rbx
26996 pushq_cfi %rbp
26997 - movq %rdi, %r10 /* Save pointer */
26998 + movq %rdi, %r9 /* Save pointer */
26999 xorl %r11d, %r11d /* Return value */
27000 movl (%rdi), %eax
27001 movl 4(%rdi), %ecx
27002 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
27003 movl 28(%rdi), %edi
27004 CFI_REMEMBER_STATE
27005 1: \op
27006 -2: movl %eax, (%r10)
27007 +2: movl %eax, (%r9)
27008 movl %r11d, %eax /* Return value */
27009 - movl %ecx, 4(%r10)
27010 - movl %edx, 8(%r10)
27011 - movl %ebx, 12(%r10)
27012 - movl %ebp, 20(%r10)
27013 - movl %esi, 24(%r10)
27014 - movl %edi, 28(%r10)
27015 + movl %ecx, 4(%r9)
27016 + movl %edx, 8(%r9)
27017 + movl %ebx, 12(%r9)
27018 + movl %ebp, 20(%r9)
27019 + movl %esi, 24(%r9)
27020 + movl %edi, 28(%r9)
27021 popq_cfi %rbp
27022 popq_cfi %rbx
27023 + pax_force_retaddr
27024 ret
27025 3:
27026 CFI_RESTORE_STATE
27027 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
27028 index fc6ba17..04471c5 100644
27029 --- a/arch/x86/lib/putuser.S
27030 +++ b/arch/x86/lib/putuser.S
27031 @@ -16,7 +16,9 @@
27032 #include <asm/errno.h>
27033 #include <asm/asm.h>
27034 #include <asm/smap.h>
27035 -
27036 +#include <asm/segment.h>
27037 +#include <asm/pgtable.h>
27038 +#include <asm/alternative-asm.h>
27039
27040 /*
27041 * __put_user_X
27042 @@ -30,57 +32,125 @@
27043 * as they get called from within inline assembly.
27044 */
27045
27046 -#define ENTER CFI_STARTPROC ; \
27047 - GET_THREAD_INFO(%_ASM_BX)
27048 -#define EXIT ASM_CLAC ; \
27049 - ret ; \
27050 +#define ENTER CFI_STARTPROC
27051 +#define EXIT ASM_CLAC ; \
27052 + pax_force_retaddr ; \
27053 + ret ; \
27054 CFI_ENDPROC
27055
27056 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27057 +#define _DEST %_ASM_CX,%_ASM_BX
27058 +#else
27059 +#define _DEST %_ASM_CX
27060 +#endif
27061 +
27062 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27063 +#define __copyuser_seg gs;
27064 +#else
27065 +#define __copyuser_seg
27066 +#endif
27067 +
27068 .text
27069 ENTRY(__put_user_1)
27070 ENTER
27071 +
27072 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27073 + GET_THREAD_INFO(%_ASM_BX)
27074 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
27075 jae bad_put_user
27076 ASM_STAC
27077 -1: movb %al,(%_ASM_CX)
27078 +
27079 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27080 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
27081 + cmp %_ASM_BX,%_ASM_CX
27082 + jb 1234f
27083 + xor %ebx,%ebx
27084 +1234:
27085 +#endif
27086 +
27087 +#endif
27088 +
27089 +1: __copyuser_seg movb %al,(_DEST)
27090 xor %eax,%eax
27091 EXIT
27092 ENDPROC(__put_user_1)
27093
27094 ENTRY(__put_user_2)
27095 ENTER
27096 +
27097 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27098 + GET_THREAD_INFO(%_ASM_BX)
27099 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
27100 sub $1,%_ASM_BX
27101 cmp %_ASM_BX,%_ASM_CX
27102 jae bad_put_user
27103 ASM_STAC
27104 -2: movw %ax,(%_ASM_CX)
27105 +
27106 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27107 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
27108 + cmp %_ASM_BX,%_ASM_CX
27109 + jb 1234f
27110 + xor %ebx,%ebx
27111 +1234:
27112 +#endif
27113 +
27114 +#endif
27115 +
27116 +2: __copyuser_seg movw %ax,(_DEST)
27117 xor %eax,%eax
27118 EXIT
27119 ENDPROC(__put_user_2)
27120
27121 ENTRY(__put_user_4)
27122 ENTER
27123 +
27124 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27125 + GET_THREAD_INFO(%_ASM_BX)
27126 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
27127 sub $3,%_ASM_BX
27128 cmp %_ASM_BX,%_ASM_CX
27129 jae bad_put_user
27130 ASM_STAC
27131 -3: movl %eax,(%_ASM_CX)
27132 +
27133 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27134 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
27135 + cmp %_ASM_BX,%_ASM_CX
27136 + jb 1234f
27137 + xor %ebx,%ebx
27138 +1234:
27139 +#endif
27140 +
27141 +#endif
27142 +
27143 +3: __copyuser_seg movl %eax,(_DEST)
27144 xor %eax,%eax
27145 EXIT
27146 ENDPROC(__put_user_4)
27147
27148 ENTRY(__put_user_8)
27149 ENTER
27150 +
27151 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27152 + GET_THREAD_INFO(%_ASM_BX)
27153 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
27154 sub $7,%_ASM_BX
27155 cmp %_ASM_BX,%_ASM_CX
27156 jae bad_put_user
27157 ASM_STAC
27158 -4: mov %_ASM_AX,(%_ASM_CX)
27159 +
27160 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27161 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
27162 + cmp %_ASM_BX,%_ASM_CX
27163 + jb 1234f
27164 + xor %ebx,%ebx
27165 +1234:
27166 +#endif
27167 +
27168 +#endif
27169 +
27170 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
27171 #ifdef CONFIG_X86_32
27172 -5: movl %edx,4(%_ASM_CX)
27173 +5: __copyuser_seg movl %edx,4(_DEST)
27174 #endif
27175 xor %eax,%eax
27176 EXIT
27177 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
27178 index 1cad221..de671ee 100644
27179 --- a/arch/x86/lib/rwlock.S
27180 +++ b/arch/x86/lib/rwlock.S
27181 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
27182 FRAME
27183 0: LOCK_PREFIX
27184 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
27185 +
27186 +#ifdef CONFIG_PAX_REFCOUNT
27187 + jno 1234f
27188 + LOCK_PREFIX
27189 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
27190 + int $4
27191 +1234:
27192 + _ASM_EXTABLE(1234b, 1234b)
27193 +#endif
27194 +
27195 1: rep; nop
27196 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
27197 jne 1b
27198 LOCK_PREFIX
27199 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
27200 +
27201 +#ifdef CONFIG_PAX_REFCOUNT
27202 + jno 1234f
27203 + LOCK_PREFIX
27204 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
27205 + int $4
27206 +1234:
27207 + _ASM_EXTABLE(1234b, 1234b)
27208 +#endif
27209 +
27210 jnz 0b
27211 ENDFRAME
27212 + pax_force_retaddr
27213 ret
27214 CFI_ENDPROC
27215 END(__write_lock_failed)
27216 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
27217 FRAME
27218 0: LOCK_PREFIX
27219 READ_LOCK_SIZE(inc) (%__lock_ptr)
27220 +
27221 +#ifdef CONFIG_PAX_REFCOUNT
27222 + jno 1234f
27223 + LOCK_PREFIX
27224 + READ_LOCK_SIZE(dec) (%__lock_ptr)
27225 + int $4
27226 +1234:
27227 + _ASM_EXTABLE(1234b, 1234b)
27228 +#endif
27229 +
27230 1: rep; nop
27231 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
27232 js 1b
27233 LOCK_PREFIX
27234 READ_LOCK_SIZE(dec) (%__lock_ptr)
27235 +
27236 +#ifdef CONFIG_PAX_REFCOUNT
27237 + jno 1234f
27238 + LOCK_PREFIX
27239 + READ_LOCK_SIZE(inc) (%__lock_ptr)
27240 + int $4
27241 +1234:
27242 + _ASM_EXTABLE(1234b, 1234b)
27243 +#endif
27244 +
27245 js 0b
27246 ENDFRAME
27247 + pax_force_retaddr
27248 ret
27249 CFI_ENDPROC
27250 END(__read_lock_failed)
27251 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
27252 index 5dff5f0..cadebf4 100644
27253 --- a/arch/x86/lib/rwsem.S
27254 +++ b/arch/x86/lib/rwsem.S
27255 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
27256 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
27257 CFI_RESTORE __ASM_REG(dx)
27258 restore_common_regs
27259 + pax_force_retaddr
27260 ret
27261 CFI_ENDPROC
27262 ENDPROC(call_rwsem_down_read_failed)
27263 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
27264 movq %rax,%rdi
27265 call rwsem_down_write_failed
27266 restore_common_regs
27267 + pax_force_retaddr
27268 ret
27269 CFI_ENDPROC
27270 ENDPROC(call_rwsem_down_write_failed)
27271 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
27272 movq %rax,%rdi
27273 call rwsem_wake
27274 restore_common_regs
27275 -1: ret
27276 +1: pax_force_retaddr
27277 + ret
27278 CFI_ENDPROC
27279 ENDPROC(call_rwsem_wake)
27280
27281 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
27282 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
27283 CFI_RESTORE __ASM_REG(dx)
27284 restore_common_regs
27285 + pax_force_retaddr
27286 ret
27287 CFI_ENDPROC
27288 ENDPROC(call_rwsem_downgrade_wake)
27289 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
27290 index a63efd6..ccecad8 100644
27291 --- a/arch/x86/lib/thunk_64.S
27292 +++ b/arch/x86/lib/thunk_64.S
27293 @@ -8,6 +8,7 @@
27294 #include <linux/linkage.h>
27295 #include <asm/dwarf2.h>
27296 #include <asm/calling.h>
27297 +#include <asm/alternative-asm.h>
27298
27299 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
27300 .macro THUNK name, func, put_ret_addr_in_rdi=0
27301 @@ -41,5 +42,6 @@
27302 SAVE_ARGS
27303 restore:
27304 RESTORE_ARGS
27305 + pax_force_retaddr
27306 ret
27307 CFI_ENDPROC
27308 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
27309 index f0312d7..9c39d63 100644
27310 --- a/arch/x86/lib/usercopy_32.c
27311 +++ b/arch/x86/lib/usercopy_32.c
27312 @@ -42,11 +42,13 @@ do { \
27313 int __d0; \
27314 might_fault(); \
27315 __asm__ __volatile__( \
27316 + __COPYUSER_SET_ES \
27317 ASM_STAC "\n" \
27318 "0: rep; stosl\n" \
27319 " movl %2,%0\n" \
27320 "1: rep; stosb\n" \
27321 "2: " ASM_CLAC "\n" \
27322 + __COPYUSER_RESTORE_ES \
27323 ".section .fixup,\"ax\"\n" \
27324 "3: lea 0(%2,%0,4),%0\n" \
27325 " jmp 2b\n" \
27326 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
27327
27328 #ifdef CONFIG_X86_INTEL_USERCOPY
27329 static unsigned long
27330 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
27331 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
27332 {
27333 int d0, d1;
27334 __asm__ __volatile__(
27335 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
27336 " .align 2,0x90\n"
27337 "3: movl 0(%4), %%eax\n"
27338 "4: movl 4(%4), %%edx\n"
27339 - "5: movl %%eax, 0(%3)\n"
27340 - "6: movl %%edx, 4(%3)\n"
27341 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
27342 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
27343 "7: movl 8(%4), %%eax\n"
27344 "8: movl 12(%4),%%edx\n"
27345 - "9: movl %%eax, 8(%3)\n"
27346 - "10: movl %%edx, 12(%3)\n"
27347 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
27348 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
27349 "11: movl 16(%4), %%eax\n"
27350 "12: movl 20(%4), %%edx\n"
27351 - "13: movl %%eax, 16(%3)\n"
27352 - "14: movl %%edx, 20(%3)\n"
27353 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
27354 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
27355 "15: movl 24(%4), %%eax\n"
27356 "16: movl 28(%4), %%edx\n"
27357 - "17: movl %%eax, 24(%3)\n"
27358 - "18: movl %%edx, 28(%3)\n"
27359 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
27360 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
27361 "19: movl 32(%4), %%eax\n"
27362 "20: movl 36(%4), %%edx\n"
27363 - "21: movl %%eax, 32(%3)\n"
27364 - "22: movl %%edx, 36(%3)\n"
27365 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
27366 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
27367 "23: movl 40(%4), %%eax\n"
27368 "24: movl 44(%4), %%edx\n"
27369 - "25: movl %%eax, 40(%3)\n"
27370 - "26: movl %%edx, 44(%3)\n"
27371 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
27372 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
27373 "27: movl 48(%4), %%eax\n"
27374 "28: movl 52(%4), %%edx\n"
27375 - "29: movl %%eax, 48(%3)\n"
27376 - "30: movl %%edx, 52(%3)\n"
27377 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
27378 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
27379 "31: movl 56(%4), %%eax\n"
27380 "32: movl 60(%4), %%edx\n"
27381 - "33: movl %%eax, 56(%3)\n"
27382 - "34: movl %%edx, 60(%3)\n"
27383 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
27384 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
27385 " addl $-64, %0\n"
27386 " addl $64, %4\n"
27387 " addl $64, %3\n"
27388 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
27389 " shrl $2, %0\n"
27390 " andl $3, %%eax\n"
27391 " cld\n"
27392 + __COPYUSER_SET_ES
27393 "99: rep; movsl\n"
27394 "36: movl %%eax, %0\n"
27395 "37: rep; movsb\n"
27396 "100:\n"
27397 + __COPYUSER_RESTORE_ES
27398 ".section .fixup,\"ax\"\n"
27399 "101: lea 0(%%eax,%0,4),%0\n"
27400 " jmp 100b\n"
27401 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
27402 }
27403
27404 static unsigned long
27405 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
27406 +{
27407 + int d0, d1;
27408 + __asm__ __volatile__(
27409 + " .align 2,0x90\n"
27410 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
27411 + " cmpl $67, %0\n"
27412 + " jbe 3f\n"
27413 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
27414 + " .align 2,0x90\n"
27415 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
27416 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
27417 + "5: movl %%eax, 0(%3)\n"
27418 + "6: movl %%edx, 4(%3)\n"
27419 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
27420 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
27421 + "9: movl %%eax, 8(%3)\n"
27422 + "10: movl %%edx, 12(%3)\n"
27423 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
27424 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
27425 + "13: movl %%eax, 16(%3)\n"
27426 + "14: movl %%edx, 20(%3)\n"
27427 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
27428 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
27429 + "17: movl %%eax, 24(%3)\n"
27430 + "18: movl %%edx, 28(%3)\n"
27431 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
27432 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
27433 + "21: movl %%eax, 32(%3)\n"
27434 + "22: movl %%edx, 36(%3)\n"
27435 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
27436 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
27437 + "25: movl %%eax, 40(%3)\n"
27438 + "26: movl %%edx, 44(%3)\n"
27439 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
27440 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
27441 + "29: movl %%eax, 48(%3)\n"
27442 + "30: movl %%edx, 52(%3)\n"
27443 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
27444 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
27445 + "33: movl %%eax, 56(%3)\n"
27446 + "34: movl %%edx, 60(%3)\n"
27447 + " addl $-64, %0\n"
27448 + " addl $64, %4\n"
27449 + " addl $64, %3\n"
27450 + " cmpl $63, %0\n"
27451 + " ja 1b\n"
27452 + "35: movl %0, %%eax\n"
27453 + " shrl $2, %0\n"
27454 + " andl $3, %%eax\n"
27455 + " cld\n"
27456 + "99: rep; "__copyuser_seg" movsl\n"
27457 + "36: movl %%eax, %0\n"
27458 + "37: rep; "__copyuser_seg" movsb\n"
27459 + "100:\n"
27460 + ".section .fixup,\"ax\"\n"
27461 + "101: lea 0(%%eax,%0,4),%0\n"
27462 + " jmp 100b\n"
27463 + ".previous\n"
27464 + _ASM_EXTABLE(1b,100b)
27465 + _ASM_EXTABLE(2b,100b)
27466 + _ASM_EXTABLE(3b,100b)
27467 + _ASM_EXTABLE(4b,100b)
27468 + _ASM_EXTABLE(5b,100b)
27469 + _ASM_EXTABLE(6b,100b)
27470 + _ASM_EXTABLE(7b,100b)
27471 + _ASM_EXTABLE(8b,100b)
27472 + _ASM_EXTABLE(9b,100b)
27473 + _ASM_EXTABLE(10b,100b)
27474 + _ASM_EXTABLE(11b,100b)
27475 + _ASM_EXTABLE(12b,100b)
27476 + _ASM_EXTABLE(13b,100b)
27477 + _ASM_EXTABLE(14b,100b)
27478 + _ASM_EXTABLE(15b,100b)
27479 + _ASM_EXTABLE(16b,100b)
27480 + _ASM_EXTABLE(17b,100b)
27481 + _ASM_EXTABLE(18b,100b)
27482 + _ASM_EXTABLE(19b,100b)
27483 + _ASM_EXTABLE(20b,100b)
27484 + _ASM_EXTABLE(21b,100b)
27485 + _ASM_EXTABLE(22b,100b)
27486 + _ASM_EXTABLE(23b,100b)
27487 + _ASM_EXTABLE(24b,100b)
27488 + _ASM_EXTABLE(25b,100b)
27489 + _ASM_EXTABLE(26b,100b)
27490 + _ASM_EXTABLE(27b,100b)
27491 + _ASM_EXTABLE(28b,100b)
27492 + _ASM_EXTABLE(29b,100b)
27493 + _ASM_EXTABLE(30b,100b)
27494 + _ASM_EXTABLE(31b,100b)
27495 + _ASM_EXTABLE(32b,100b)
27496 + _ASM_EXTABLE(33b,100b)
27497 + _ASM_EXTABLE(34b,100b)
27498 + _ASM_EXTABLE(35b,100b)
27499 + _ASM_EXTABLE(36b,100b)
27500 + _ASM_EXTABLE(37b,100b)
27501 + _ASM_EXTABLE(99b,101b)
27502 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
27503 + : "1"(to), "2"(from), "0"(size)
27504 + : "eax", "edx", "memory");
27505 + return size;
27506 +}
27507 +
27508 +static unsigned long __size_overflow(3)
27509 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27510 {
27511 int d0, d1;
27512 __asm__ __volatile__(
27513 " .align 2,0x90\n"
27514 - "0: movl 32(%4), %%eax\n"
27515 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27516 " cmpl $67, %0\n"
27517 " jbe 2f\n"
27518 - "1: movl 64(%4), %%eax\n"
27519 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27520 " .align 2,0x90\n"
27521 - "2: movl 0(%4), %%eax\n"
27522 - "21: movl 4(%4), %%edx\n"
27523 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27524 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27525 " movl %%eax, 0(%3)\n"
27526 " movl %%edx, 4(%3)\n"
27527 - "3: movl 8(%4), %%eax\n"
27528 - "31: movl 12(%4),%%edx\n"
27529 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27530 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27531 " movl %%eax, 8(%3)\n"
27532 " movl %%edx, 12(%3)\n"
27533 - "4: movl 16(%4), %%eax\n"
27534 - "41: movl 20(%4), %%edx\n"
27535 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27536 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27537 " movl %%eax, 16(%3)\n"
27538 " movl %%edx, 20(%3)\n"
27539 - "10: movl 24(%4), %%eax\n"
27540 - "51: movl 28(%4), %%edx\n"
27541 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27542 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27543 " movl %%eax, 24(%3)\n"
27544 " movl %%edx, 28(%3)\n"
27545 - "11: movl 32(%4), %%eax\n"
27546 - "61: movl 36(%4), %%edx\n"
27547 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27548 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27549 " movl %%eax, 32(%3)\n"
27550 " movl %%edx, 36(%3)\n"
27551 - "12: movl 40(%4), %%eax\n"
27552 - "71: movl 44(%4), %%edx\n"
27553 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27554 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27555 " movl %%eax, 40(%3)\n"
27556 " movl %%edx, 44(%3)\n"
27557 - "13: movl 48(%4), %%eax\n"
27558 - "81: movl 52(%4), %%edx\n"
27559 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27560 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27561 " movl %%eax, 48(%3)\n"
27562 " movl %%edx, 52(%3)\n"
27563 - "14: movl 56(%4), %%eax\n"
27564 - "91: movl 60(%4), %%edx\n"
27565 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27566 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27567 " movl %%eax, 56(%3)\n"
27568 " movl %%edx, 60(%3)\n"
27569 " addl $-64, %0\n"
27570 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27571 " shrl $2, %0\n"
27572 " andl $3, %%eax\n"
27573 " cld\n"
27574 - "6: rep; movsl\n"
27575 + "6: rep; "__copyuser_seg" movsl\n"
27576 " movl %%eax,%0\n"
27577 - "7: rep; movsb\n"
27578 + "7: rep; "__copyuser_seg" movsb\n"
27579 "8:\n"
27580 ".section .fixup,\"ax\"\n"
27581 "9: lea 0(%%eax,%0,4),%0\n"
27582 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27583 * hyoshiok@miraclelinux.com
27584 */
27585
27586 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27587 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
27588 const void __user *from, unsigned long size)
27589 {
27590 int d0, d1;
27591
27592 __asm__ __volatile__(
27593 " .align 2,0x90\n"
27594 - "0: movl 32(%4), %%eax\n"
27595 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27596 " cmpl $67, %0\n"
27597 " jbe 2f\n"
27598 - "1: movl 64(%4), %%eax\n"
27599 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27600 " .align 2,0x90\n"
27601 - "2: movl 0(%4), %%eax\n"
27602 - "21: movl 4(%4), %%edx\n"
27603 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27604 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27605 " movnti %%eax, 0(%3)\n"
27606 " movnti %%edx, 4(%3)\n"
27607 - "3: movl 8(%4), %%eax\n"
27608 - "31: movl 12(%4),%%edx\n"
27609 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27610 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27611 " movnti %%eax, 8(%3)\n"
27612 " movnti %%edx, 12(%3)\n"
27613 - "4: movl 16(%4), %%eax\n"
27614 - "41: movl 20(%4), %%edx\n"
27615 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27616 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27617 " movnti %%eax, 16(%3)\n"
27618 " movnti %%edx, 20(%3)\n"
27619 - "10: movl 24(%4), %%eax\n"
27620 - "51: movl 28(%4), %%edx\n"
27621 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27622 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27623 " movnti %%eax, 24(%3)\n"
27624 " movnti %%edx, 28(%3)\n"
27625 - "11: movl 32(%4), %%eax\n"
27626 - "61: movl 36(%4), %%edx\n"
27627 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27628 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27629 " movnti %%eax, 32(%3)\n"
27630 " movnti %%edx, 36(%3)\n"
27631 - "12: movl 40(%4), %%eax\n"
27632 - "71: movl 44(%4), %%edx\n"
27633 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27634 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27635 " movnti %%eax, 40(%3)\n"
27636 " movnti %%edx, 44(%3)\n"
27637 - "13: movl 48(%4), %%eax\n"
27638 - "81: movl 52(%4), %%edx\n"
27639 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27640 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27641 " movnti %%eax, 48(%3)\n"
27642 " movnti %%edx, 52(%3)\n"
27643 - "14: movl 56(%4), %%eax\n"
27644 - "91: movl 60(%4), %%edx\n"
27645 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27646 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27647 " movnti %%eax, 56(%3)\n"
27648 " movnti %%edx, 60(%3)\n"
27649 " addl $-64, %0\n"
27650 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27651 " shrl $2, %0\n"
27652 " andl $3, %%eax\n"
27653 " cld\n"
27654 - "6: rep; movsl\n"
27655 + "6: rep; "__copyuser_seg" movsl\n"
27656 " movl %%eax,%0\n"
27657 - "7: rep; movsb\n"
27658 + "7: rep; "__copyuser_seg" movsb\n"
27659 "8:\n"
27660 ".section .fixup,\"ax\"\n"
27661 "9: lea 0(%%eax,%0,4),%0\n"
27662 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27663 return size;
27664 }
27665
27666 -static unsigned long __copy_user_intel_nocache(void *to,
27667 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
27668 const void __user *from, unsigned long size)
27669 {
27670 int d0, d1;
27671
27672 __asm__ __volatile__(
27673 " .align 2,0x90\n"
27674 - "0: movl 32(%4), %%eax\n"
27675 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27676 " cmpl $67, %0\n"
27677 " jbe 2f\n"
27678 - "1: movl 64(%4), %%eax\n"
27679 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27680 " .align 2,0x90\n"
27681 - "2: movl 0(%4), %%eax\n"
27682 - "21: movl 4(%4), %%edx\n"
27683 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27684 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27685 " movnti %%eax, 0(%3)\n"
27686 " movnti %%edx, 4(%3)\n"
27687 - "3: movl 8(%4), %%eax\n"
27688 - "31: movl 12(%4),%%edx\n"
27689 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27690 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27691 " movnti %%eax, 8(%3)\n"
27692 " movnti %%edx, 12(%3)\n"
27693 - "4: movl 16(%4), %%eax\n"
27694 - "41: movl 20(%4), %%edx\n"
27695 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27696 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27697 " movnti %%eax, 16(%3)\n"
27698 " movnti %%edx, 20(%3)\n"
27699 - "10: movl 24(%4), %%eax\n"
27700 - "51: movl 28(%4), %%edx\n"
27701 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27702 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27703 " movnti %%eax, 24(%3)\n"
27704 " movnti %%edx, 28(%3)\n"
27705 - "11: movl 32(%4), %%eax\n"
27706 - "61: movl 36(%4), %%edx\n"
27707 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27708 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27709 " movnti %%eax, 32(%3)\n"
27710 " movnti %%edx, 36(%3)\n"
27711 - "12: movl 40(%4), %%eax\n"
27712 - "71: movl 44(%4), %%edx\n"
27713 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27714 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27715 " movnti %%eax, 40(%3)\n"
27716 " movnti %%edx, 44(%3)\n"
27717 - "13: movl 48(%4), %%eax\n"
27718 - "81: movl 52(%4), %%edx\n"
27719 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27720 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27721 " movnti %%eax, 48(%3)\n"
27722 " movnti %%edx, 52(%3)\n"
27723 - "14: movl 56(%4), %%eax\n"
27724 - "91: movl 60(%4), %%edx\n"
27725 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27726 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27727 " movnti %%eax, 56(%3)\n"
27728 " movnti %%edx, 60(%3)\n"
27729 " addl $-64, %0\n"
27730 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
27731 " shrl $2, %0\n"
27732 " andl $3, %%eax\n"
27733 " cld\n"
27734 - "6: rep; movsl\n"
27735 + "6: rep; "__copyuser_seg" movsl\n"
27736 " movl %%eax,%0\n"
27737 - "7: rep; movsb\n"
27738 + "7: rep; "__copyuser_seg" movsb\n"
27739 "8:\n"
27740 ".section .fixup,\"ax\"\n"
27741 "9: lea 0(%%eax,%0,4),%0\n"
27742 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
27743 */
27744 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
27745 unsigned long size);
27746 -unsigned long __copy_user_intel(void __user *to, const void *from,
27747 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
27748 + unsigned long size);
27749 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27750 unsigned long size);
27751 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27752 const void __user *from, unsigned long size);
27753 #endif /* CONFIG_X86_INTEL_USERCOPY */
27754
27755 /* Generic arbitrary sized copy. */
27756 -#define __copy_user(to, from, size) \
27757 +#define __copy_user(to, from, size, prefix, set, restore) \
27758 do { \
27759 int __d0, __d1, __d2; \
27760 __asm__ __volatile__( \
27761 + set \
27762 " cmp $7,%0\n" \
27763 " jbe 1f\n" \
27764 " movl %1,%0\n" \
27765 " negl %0\n" \
27766 " andl $7,%0\n" \
27767 " subl %0,%3\n" \
27768 - "4: rep; movsb\n" \
27769 + "4: rep; "prefix"movsb\n" \
27770 " movl %3,%0\n" \
27771 " shrl $2,%0\n" \
27772 " andl $3,%3\n" \
27773 " .align 2,0x90\n" \
27774 - "0: rep; movsl\n" \
27775 + "0: rep; "prefix"movsl\n" \
27776 " movl %3,%0\n" \
27777 - "1: rep; movsb\n" \
27778 + "1: rep; "prefix"movsb\n" \
27779 "2:\n" \
27780 + restore \
27781 ".section .fixup,\"ax\"\n" \
27782 "5: addl %3,%0\n" \
27783 " jmp 2b\n" \
27784 @@ -538,14 +650,14 @@ do { \
27785 " negl %0\n" \
27786 " andl $7,%0\n" \
27787 " subl %0,%3\n" \
27788 - "4: rep; movsb\n" \
27789 + "4: rep; "__copyuser_seg"movsb\n" \
27790 " movl %3,%0\n" \
27791 " shrl $2,%0\n" \
27792 " andl $3,%3\n" \
27793 " .align 2,0x90\n" \
27794 - "0: rep; movsl\n" \
27795 + "0: rep; "__copyuser_seg"movsl\n" \
27796 " movl %3,%0\n" \
27797 - "1: rep; movsb\n" \
27798 + "1: rep; "__copyuser_seg"movsb\n" \
27799 "2:\n" \
27800 ".section .fixup,\"ax\"\n" \
27801 "5: addl %3,%0\n" \
27802 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27803 {
27804 stac();
27805 if (movsl_is_ok(to, from, n))
27806 - __copy_user(to, from, n);
27807 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27808 else
27809 - n = __copy_user_intel(to, from, n);
27810 + n = __generic_copy_to_user_intel(to, from, n);
27811 clac();
27812 return n;
27813 }
27814 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27815 {
27816 stac();
27817 if (movsl_is_ok(to, from, n))
27818 - __copy_user(to, from, n);
27819 + __copy_user(to, from, n, __copyuser_seg, "", "");
27820 else
27821 - n = __copy_user_intel((void __user *)to,
27822 - (const void *)from, n);
27823 + n = __generic_copy_from_user_intel(to, from, n);
27824 clac();
27825 return n;
27826 }
27827 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27828 if (n > 64 && cpu_has_xmm2)
27829 n = __copy_user_intel_nocache(to, from, n);
27830 else
27831 - __copy_user(to, from, n);
27832 + __copy_user(to, from, n, __copyuser_seg, "", "");
27833 #else
27834 - __copy_user(to, from, n);
27835 + __copy_user(to, from, n, __copyuser_seg, "", "");
27836 #endif
27837 clac();
27838 return n;
27839 }
27840 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27841
27842 -/**
27843 - * copy_to_user: - Copy a block of data into user space.
27844 - * @to: Destination address, in user space.
27845 - * @from: Source address, in kernel space.
27846 - * @n: Number of bytes to copy.
27847 - *
27848 - * Context: User context only. This function may sleep.
27849 - *
27850 - * Copy data from kernel space to user space.
27851 - *
27852 - * Returns number of bytes that could not be copied.
27853 - * On success, this will be zero.
27854 - */
27855 -unsigned long
27856 -copy_to_user(void __user *to, const void *from, unsigned long n)
27857 -{
27858 - if (access_ok(VERIFY_WRITE, to, n))
27859 - n = __copy_to_user(to, from, n);
27860 - return n;
27861 -}
27862 -EXPORT_SYMBOL(copy_to_user);
27863 -
27864 -/**
27865 - * copy_from_user: - Copy a block of data from user space.
27866 - * @to: Destination address, in kernel space.
27867 - * @from: Source address, in user space.
27868 - * @n: Number of bytes to copy.
27869 - *
27870 - * Context: User context only. This function may sleep.
27871 - *
27872 - * Copy data from user space to kernel space.
27873 - *
27874 - * Returns number of bytes that could not be copied.
27875 - * On success, this will be zero.
27876 - *
27877 - * If some data could not be copied, this function will pad the copied
27878 - * data to the requested size using zero bytes.
27879 - */
27880 -unsigned long
27881 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27882 -{
27883 - if (access_ok(VERIFY_READ, from, n))
27884 - n = __copy_from_user(to, from, n);
27885 - else
27886 - memset(to, 0, n);
27887 - return n;
27888 -}
27889 -EXPORT_SYMBOL(_copy_from_user);
27890 -
27891 void copy_from_user_overflow(void)
27892 {
27893 WARN(1, "Buffer overflow detected!\n");
27894 }
27895 EXPORT_SYMBOL(copy_from_user_overflow);
27896 +
27897 +void copy_to_user_overflow(void)
27898 +{
27899 + WARN(1, "Buffer overflow detected!\n");
27900 +}
27901 +EXPORT_SYMBOL(copy_to_user_overflow);
27902 +
27903 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27904 +void __set_fs(mm_segment_t x)
27905 +{
27906 + switch (x.seg) {
27907 + case 0:
27908 + loadsegment(gs, 0);
27909 + break;
27910 + case TASK_SIZE_MAX:
27911 + loadsegment(gs, __USER_DS);
27912 + break;
27913 + case -1UL:
27914 + loadsegment(gs, __KERNEL_DS);
27915 + break;
27916 + default:
27917 + BUG();
27918 + }
27919 + return;
27920 +}
27921 +EXPORT_SYMBOL(__set_fs);
27922 +
27923 +void set_fs(mm_segment_t x)
27924 +{
27925 + current_thread_info()->addr_limit = x;
27926 + __set_fs(x);
27927 +}
27928 +EXPORT_SYMBOL(set_fs);
27929 +#endif
27930 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27931 index 906fea3..ee8a097 100644
27932 --- a/arch/x86/lib/usercopy_64.c
27933 +++ b/arch/x86/lib/usercopy_64.c
27934 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27935 _ASM_EXTABLE(0b,3b)
27936 _ASM_EXTABLE(1b,2b)
27937 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27938 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27939 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27940 [zero] "r" (0UL), [eight] "r" (8UL));
27941 clac();
27942 return size;
27943 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27944 }
27945 EXPORT_SYMBOL(clear_user);
27946
27947 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27948 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27949 {
27950 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27951 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27952 - }
27953 - return len;
27954 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27955 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27956 + return len;
27957 }
27958 EXPORT_SYMBOL(copy_in_user);
27959
27960 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27961 * it is not necessary to optimize tail handling.
27962 */
27963 unsigned long
27964 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27965 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27966 {
27967 char c;
27968 unsigned zero_len;
27969 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27970 clac();
27971 return len;
27972 }
27973 +
27974 +void copy_from_user_overflow(void)
27975 +{
27976 + WARN(1, "Buffer overflow detected!\n");
27977 +}
27978 +EXPORT_SYMBOL(copy_from_user_overflow);
27979 +
27980 +void copy_to_user_overflow(void)
27981 +{
27982 + WARN(1, "Buffer overflow detected!\n");
27983 +}
27984 +EXPORT_SYMBOL(copy_to_user_overflow);
27985 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27986 index 903ec1e..c4166b2 100644
27987 --- a/arch/x86/mm/extable.c
27988 +++ b/arch/x86/mm/extable.c
27989 @@ -6,12 +6,24 @@
27990 static inline unsigned long
27991 ex_insn_addr(const struct exception_table_entry *x)
27992 {
27993 - return (unsigned long)&x->insn + x->insn;
27994 + unsigned long reloc = 0;
27995 +
27996 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27997 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27998 +#endif
27999 +
28000 + return (unsigned long)&x->insn + x->insn + reloc;
28001 }
28002 static inline unsigned long
28003 ex_fixup_addr(const struct exception_table_entry *x)
28004 {
28005 - return (unsigned long)&x->fixup + x->fixup;
28006 + unsigned long reloc = 0;
28007 +
28008 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
28009 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
28010 +#endif
28011 +
28012 + return (unsigned long)&x->fixup + x->fixup + reloc;
28013 }
28014
28015 int fixup_exception(struct pt_regs *regs)
28016 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
28017 unsigned long new_ip;
28018
28019 #ifdef CONFIG_PNPBIOS
28020 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
28021 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
28022 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
28023 extern u32 pnp_bios_is_utter_crap;
28024 pnp_bios_is_utter_crap = 1;
28025 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
28026 i += 4;
28027 p->fixup -= i;
28028 i += 4;
28029 +
28030 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
28031 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
28032 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
28033 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
28034 +#endif
28035 +
28036 }
28037 }
28038
28039 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
28040 index 4f7d793..165a8be 100644
28041 --- a/arch/x86/mm/fault.c
28042 +++ b/arch/x86/mm/fault.c
28043 @@ -13,12 +13,19 @@
28044 #include <linux/perf_event.h> /* perf_sw_event */
28045 #include <linux/hugetlb.h> /* hstate_index_to_shift */
28046 #include <linux/prefetch.h> /* prefetchw */
28047 +#include <linux/unistd.h>
28048 +#include <linux/compiler.h>
28049
28050 #include <asm/traps.h> /* dotraplinkage, ... */
28051 #include <asm/pgalloc.h> /* pgd_*(), ... */
28052 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
28053 #include <asm/fixmap.h> /* VSYSCALL_START */
28054 #include <asm/context_tracking.h> /* exception_enter(), ... */
28055 +#include <asm/tlbflush.h>
28056 +
28057 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28058 +#include <asm/stacktrace.h>
28059 +#endif
28060
28061 /*
28062 * Page fault error code bits:
28063 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
28064 int ret = 0;
28065
28066 /* kprobe_running() needs smp_processor_id() */
28067 - if (kprobes_built_in() && !user_mode_vm(regs)) {
28068 + if (kprobes_built_in() && !user_mode(regs)) {
28069 preempt_disable();
28070 if (kprobe_running() && kprobe_fault_handler(regs, 14))
28071 ret = 1;
28072 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
28073 return !instr_lo || (instr_lo>>1) == 1;
28074 case 0x00:
28075 /* Prefetch instruction is 0x0F0D or 0x0F18 */
28076 - if (probe_kernel_address(instr, opcode))
28077 + if (user_mode(regs)) {
28078 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
28079 + return 0;
28080 + } else if (probe_kernel_address(instr, opcode))
28081 return 0;
28082
28083 *prefetch = (instr_lo == 0xF) &&
28084 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
28085 while (instr < max_instr) {
28086 unsigned char opcode;
28087
28088 - if (probe_kernel_address(instr, opcode))
28089 + if (user_mode(regs)) {
28090 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
28091 + break;
28092 + } else if (probe_kernel_address(instr, opcode))
28093 break;
28094
28095 instr++;
28096 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
28097 force_sig_info(si_signo, &info, tsk);
28098 }
28099
28100 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28101 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
28102 +#endif
28103 +
28104 +#ifdef CONFIG_PAX_EMUTRAMP
28105 +static int pax_handle_fetch_fault(struct pt_regs *regs);
28106 +#endif
28107 +
28108 +#ifdef CONFIG_PAX_PAGEEXEC
28109 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
28110 +{
28111 + pgd_t *pgd;
28112 + pud_t *pud;
28113 + pmd_t *pmd;
28114 +
28115 + pgd = pgd_offset(mm, address);
28116 + if (!pgd_present(*pgd))
28117 + return NULL;
28118 + pud = pud_offset(pgd, address);
28119 + if (!pud_present(*pud))
28120 + return NULL;
28121 + pmd = pmd_offset(pud, address);
28122 + if (!pmd_present(*pmd))
28123 + return NULL;
28124 + return pmd;
28125 +}
28126 +#endif
28127 +
28128 DEFINE_SPINLOCK(pgd_lock);
28129 LIST_HEAD(pgd_list);
28130
28131 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
28132 for (address = VMALLOC_START & PMD_MASK;
28133 address >= TASK_SIZE && address < FIXADDR_TOP;
28134 address += PMD_SIZE) {
28135 +
28136 +#ifdef CONFIG_PAX_PER_CPU_PGD
28137 + unsigned long cpu;
28138 +#else
28139 struct page *page;
28140 +#endif
28141
28142 spin_lock(&pgd_lock);
28143 +
28144 +#ifdef CONFIG_PAX_PER_CPU_PGD
28145 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28146 + pgd_t *pgd = get_cpu_pgd(cpu);
28147 + pmd_t *ret;
28148 +#else
28149 list_for_each_entry(page, &pgd_list, lru) {
28150 + pgd_t *pgd;
28151 spinlock_t *pgt_lock;
28152 pmd_t *ret;
28153
28154 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
28155 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28156
28157 spin_lock(pgt_lock);
28158 - ret = vmalloc_sync_one(page_address(page), address);
28159 + pgd = page_address(page);
28160 +#endif
28161 +
28162 + ret = vmalloc_sync_one(pgd, address);
28163 +
28164 +#ifndef CONFIG_PAX_PER_CPU_PGD
28165 spin_unlock(pgt_lock);
28166 +#endif
28167
28168 if (!ret)
28169 break;
28170 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
28171 * an interrupt in the middle of a task switch..
28172 */
28173 pgd_paddr = read_cr3();
28174 +
28175 +#ifdef CONFIG_PAX_PER_CPU_PGD
28176 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
28177 +#endif
28178 +
28179 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
28180 if (!pmd_k)
28181 return -1;
28182 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
28183 * happen within a race in page table update. In the later
28184 * case just flush:
28185 */
28186 +
28187 +#ifdef CONFIG_PAX_PER_CPU_PGD
28188 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
28189 + pgd = pgd_offset_cpu(smp_processor_id(), address);
28190 +#else
28191 pgd = pgd_offset(current->active_mm, address);
28192 +#endif
28193 +
28194 pgd_ref = pgd_offset_k(address);
28195 if (pgd_none(*pgd_ref))
28196 return -1;
28197 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
28198 static int is_errata100(struct pt_regs *regs, unsigned long address)
28199 {
28200 #ifdef CONFIG_X86_64
28201 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
28202 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
28203 return 1;
28204 #endif
28205 return 0;
28206 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
28207 }
28208
28209 static const char nx_warning[] = KERN_CRIT
28210 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
28211 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
28212
28213 static void
28214 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
28215 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
28216 if (!oops_may_print())
28217 return;
28218
28219 - if (error_code & PF_INSTR) {
28220 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
28221 unsigned int level;
28222
28223 pte_t *pte = lookup_address(address, &level);
28224
28225 if (pte && pte_present(*pte) && !pte_exec(*pte))
28226 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
28227 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
28228 }
28229
28230 +#ifdef CONFIG_PAX_KERNEXEC
28231 + if (init_mm.start_code <= address && address < init_mm.end_code) {
28232 + if (current->signal->curr_ip)
28233 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
28234 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
28235 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
28236 + else
28237 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
28238 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
28239 + }
28240 +#endif
28241 +
28242 printk(KERN_ALERT "BUG: unable to handle kernel ");
28243 if (address < PAGE_SIZE)
28244 printk(KERN_CONT "NULL pointer dereference");
28245 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
28246 return;
28247 }
28248 #endif
28249 +
28250 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28251 + if (pax_is_fetch_fault(regs, error_code, address)) {
28252 +
28253 +#ifdef CONFIG_PAX_EMUTRAMP
28254 + switch (pax_handle_fetch_fault(regs)) {
28255 + case 2:
28256 + return;
28257 + }
28258 +#endif
28259 +
28260 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
28261 + do_group_exit(SIGKILL);
28262 + }
28263 +#endif
28264 +
28265 /* Kernel addresses are always protection faults: */
28266 if (address >= TASK_SIZE)
28267 error_code |= PF_PROT;
28268 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
28269 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
28270 printk(KERN_ERR
28271 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
28272 - tsk->comm, tsk->pid, address);
28273 + tsk->comm, task_pid_nr(tsk), address);
28274 code = BUS_MCEERR_AR;
28275 }
28276 #endif
28277 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
28278 return 1;
28279 }
28280
28281 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
28282 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
28283 +{
28284 + pte_t *pte;
28285 + pmd_t *pmd;
28286 + spinlock_t *ptl;
28287 + unsigned char pte_mask;
28288 +
28289 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
28290 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
28291 + return 0;
28292 +
28293 + /* PaX: it's our fault, let's handle it if we can */
28294 +
28295 + /* PaX: take a look at read faults before acquiring any locks */
28296 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
28297 + /* instruction fetch attempt from a protected page in user mode */
28298 + up_read(&mm->mmap_sem);
28299 +
28300 +#ifdef CONFIG_PAX_EMUTRAMP
28301 + switch (pax_handle_fetch_fault(regs)) {
28302 + case 2:
28303 + return 1;
28304 + }
28305 +#endif
28306 +
28307 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
28308 + do_group_exit(SIGKILL);
28309 + }
28310 +
28311 + pmd = pax_get_pmd(mm, address);
28312 + if (unlikely(!pmd))
28313 + return 0;
28314 +
28315 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
28316 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
28317 + pte_unmap_unlock(pte, ptl);
28318 + return 0;
28319 + }
28320 +
28321 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
28322 + /* write attempt to a protected page in user mode */
28323 + pte_unmap_unlock(pte, ptl);
28324 + return 0;
28325 + }
28326 +
28327 +#ifdef CONFIG_SMP
28328 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
28329 +#else
28330 + if (likely(address > get_limit(regs->cs)))
28331 +#endif
28332 + {
28333 + set_pte(pte, pte_mkread(*pte));
28334 + __flush_tlb_one(address);
28335 + pte_unmap_unlock(pte, ptl);
28336 + up_read(&mm->mmap_sem);
28337 + return 1;
28338 + }
28339 +
28340 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
28341 +
28342 + /*
28343 + * PaX: fill DTLB with user rights and retry
28344 + */
28345 + __asm__ __volatile__ (
28346 + "orb %2,(%1)\n"
28347 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
28348 +/*
28349 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
28350 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
28351 + * page fault when examined during a TLB load attempt. this is true not only
28352 + * for PTEs holding a non-present entry but also present entries that will
28353 + * raise a page fault (such as those set up by PaX, or the copy-on-write
28354 + * mechanism). in effect it means that we do *not* need to flush the TLBs
28355 + * for our target pages since their PTEs are simply not in the TLBs at all.
28356 +
28357 + * the best thing in omitting it is that we gain around 15-20% speed in the
28358 + * fast path of the page fault handler and can get rid of tracing since we
28359 + * can no longer flush unintended entries.
28360 + */
28361 + "invlpg (%0)\n"
28362 +#endif
28363 + __copyuser_seg"testb $0,(%0)\n"
28364 + "xorb %3,(%1)\n"
28365 + :
28366 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
28367 + : "memory", "cc");
28368 + pte_unmap_unlock(pte, ptl);
28369 + up_read(&mm->mmap_sem);
28370 + return 1;
28371 +}
28372 +#endif
28373 +
28374 /*
28375 * Handle a spurious fault caused by a stale TLB entry.
28376 *
28377 @@ -970,6 +1162,9 @@ int show_unhandled_signals = 1;
28378 static inline int
28379 access_error(unsigned long error_code, struct vm_area_struct *vma)
28380 {
28381 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
28382 + return 1;
28383 +
28384 if (error_code & PF_WRITE) {
28385 /* write, present and write, not present: */
28386 if (unlikely(!(vma->vm_flags & VM_WRITE)))
28387 @@ -998,7 +1193,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
28388 if (error_code & PF_USER)
28389 return false;
28390
28391 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
28392 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
28393 return false;
28394
28395 return true;
28396 @@ -1014,18 +1209,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
28397 {
28398 struct vm_area_struct *vma;
28399 struct task_struct *tsk;
28400 - unsigned long address;
28401 struct mm_struct *mm;
28402 int fault;
28403 int write = error_code & PF_WRITE;
28404 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
28405 (write ? FAULT_FLAG_WRITE : 0);
28406
28407 - tsk = current;
28408 - mm = tsk->mm;
28409 -
28410 /* Get the faulting address: */
28411 - address = read_cr2();
28412 + unsigned long address = read_cr2();
28413 +
28414 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28415 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
28416 + if (!search_exception_tables(regs->ip)) {
28417 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
28418 + bad_area_nosemaphore(regs, error_code, address);
28419 + return;
28420 + }
28421 + if (address < PAX_USER_SHADOW_BASE) {
28422 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
28423 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
28424 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
28425 + } else
28426 + address -= PAX_USER_SHADOW_BASE;
28427 + }
28428 +#endif
28429 +
28430 + tsk = current;
28431 + mm = tsk->mm;
28432
28433 /*
28434 * Detect and handle instructions that would cause a page fault for
28435 @@ -1086,7 +1296,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
28436 * User-mode registers count as a user access even for any
28437 * potential system fault or CPU buglet:
28438 */
28439 - if (user_mode_vm(regs)) {
28440 + if (user_mode(regs)) {
28441 local_irq_enable();
28442 error_code |= PF_USER;
28443 } else {
28444 @@ -1148,6 +1358,11 @@ retry:
28445 might_sleep();
28446 }
28447
28448 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
28449 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
28450 + return;
28451 +#endif
28452 +
28453 vma = find_vma(mm, address);
28454 if (unlikely(!vma)) {
28455 bad_area(regs, error_code, address);
28456 @@ -1159,18 +1374,24 @@ retry:
28457 bad_area(regs, error_code, address);
28458 return;
28459 }
28460 - if (error_code & PF_USER) {
28461 - /*
28462 - * Accessing the stack below %sp is always a bug.
28463 - * The large cushion allows instructions like enter
28464 - * and pusha to work. ("enter $65535, $31" pushes
28465 - * 32 pointers and then decrements %sp by 65535.)
28466 - */
28467 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
28468 - bad_area(regs, error_code, address);
28469 - return;
28470 - }
28471 + /*
28472 + * Accessing the stack below %sp is always a bug.
28473 + * The large cushion allows instructions like enter
28474 + * and pusha to work. ("enter $65535, $31" pushes
28475 + * 32 pointers and then decrements %sp by 65535.)
28476 + */
28477 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
28478 + bad_area(regs, error_code, address);
28479 + return;
28480 }
28481 +
28482 +#ifdef CONFIG_PAX_SEGMEXEC
28483 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
28484 + bad_area(regs, error_code, address);
28485 + return;
28486 + }
28487 +#endif
28488 +
28489 if (unlikely(expand_stack(vma, address))) {
28490 bad_area(regs, error_code, address);
28491 return;
28492 @@ -1234,3 +1455,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
28493 __do_page_fault(regs, error_code);
28494 exception_exit(regs);
28495 }
28496 +
28497 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28498 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
28499 +{
28500 + struct mm_struct *mm = current->mm;
28501 + unsigned long ip = regs->ip;
28502 +
28503 + if (v8086_mode(regs))
28504 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
28505 +
28506 +#ifdef CONFIG_PAX_PAGEEXEC
28507 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
28508 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
28509 + return true;
28510 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
28511 + return true;
28512 + return false;
28513 + }
28514 +#endif
28515 +
28516 +#ifdef CONFIG_PAX_SEGMEXEC
28517 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
28518 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
28519 + return true;
28520 + return false;
28521 + }
28522 +#endif
28523 +
28524 + return false;
28525 +}
28526 +#endif
28527 +
28528 +#ifdef CONFIG_PAX_EMUTRAMP
28529 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
28530 +{
28531 + int err;
28532 +
28533 + do { /* PaX: libffi trampoline emulation */
28534 + unsigned char mov, jmp;
28535 + unsigned int addr1, addr2;
28536 +
28537 +#ifdef CONFIG_X86_64
28538 + if ((regs->ip + 9) >> 32)
28539 + break;
28540 +#endif
28541 +
28542 + err = get_user(mov, (unsigned char __user *)regs->ip);
28543 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28544 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28545 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28546 +
28547 + if (err)
28548 + break;
28549 +
28550 + if (mov == 0xB8 && jmp == 0xE9) {
28551 + regs->ax = addr1;
28552 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28553 + return 2;
28554 + }
28555 + } while (0);
28556 +
28557 + do { /* PaX: gcc trampoline emulation #1 */
28558 + unsigned char mov1, mov2;
28559 + unsigned short jmp;
28560 + unsigned int addr1, addr2;
28561 +
28562 +#ifdef CONFIG_X86_64
28563 + if ((regs->ip + 11) >> 32)
28564 + break;
28565 +#endif
28566 +
28567 + err = get_user(mov1, (unsigned char __user *)regs->ip);
28568 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28569 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
28570 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28571 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
28572 +
28573 + if (err)
28574 + break;
28575 +
28576 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
28577 + regs->cx = addr1;
28578 + regs->ax = addr2;
28579 + regs->ip = addr2;
28580 + return 2;
28581 + }
28582 + } while (0);
28583 +
28584 + do { /* PaX: gcc trampoline emulation #2 */
28585 + unsigned char mov, jmp;
28586 + unsigned int addr1, addr2;
28587 +
28588 +#ifdef CONFIG_X86_64
28589 + if ((regs->ip + 9) >> 32)
28590 + break;
28591 +#endif
28592 +
28593 + err = get_user(mov, (unsigned char __user *)regs->ip);
28594 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28595 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28596 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28597 +
28598 + if (err)
28599 + break;
28600 +
28601 + if (mov == 0xB9 && jmp == 0xE9) {
28602 + regs->cx = addr1;
28603 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28604 + return 2;
28605 + }
28606 + } while (0);
28607 +
28608 + return 1; /* PaX in action */
28609 +}
28610 +
28611 +#ifdef CONFIG_X86_64
28612 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
28613 +{
28614 + int err;
28615 +
28616 + do { /* PaX: libffi trampoline emulation */
28617 + unsigned short mov1, mov2, jmp1;
28618 + unsigned char stcclc, jmp2;
28619 + unsigned long addr1, addr2;
28620 +
28621 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28622 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28623 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28624 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28625 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
28626 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
28627 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
28628 +
28629 + if (err)
28630 + break;
28631 +
28632 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28633 + regs->r11 = addr1;
28634 + regs->r10 = addr2;
28635 + if (stcclc == 0xF8)
28636 + regs->flags &= ~X86_EFLAGS_CF;
28637 + else
28638 + regs->flags |= X86_EFLAGS_CF;
28639 + regs->ip = addr1;
28640 + return 2;
28641 + }
28642 + } while (0);
28643 +
28644 + do { /* PaX: gcc trampoline emulation #1 */
28645 + unsigned short mov1, mov2, jmp1;
28646 + unsigned char jmp2;
28647 + unsigned int addr1;
28648 + unsigned long addr2;
28649 +
28650 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28651 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
28652 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
28653 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
28654 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
28655 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
28656 +
28657 + if (err)
28658 + break;
28659 +
28660 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28661 + regs->r11 = addr1;
28662 + regs->r10 = addr2;
28663 + regs->ip = addr1;
28664 + return 2;
28665 + }
28666 + } while (0);
28667 +
28668 + do { /* PaX: gcc trampoline emulation #2 */
28669 + unsigned short mov1, mov2, jmp1;
28670 + unsigned char jmp2;
28671 + unsigned long addr1, addr2;
28672 +
28673 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28674 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28675 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28676 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28677 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
28678 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
28679 +
28680 + if (err)
28681 + break;
28682 +
28683 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28684 + regs->r11 = addr1;
28685 + regs->r10 = addr2;
28686 + regs->ip = addr1;
28687 + return 2;
28688 + }
28689 + } while (0);
28690 +
28691 + return 1; /* PaX in action */
28692 +}
28693 +#endif
28694 +
28695 +/*
28696 + * PaX: decide what to do with offenders (regs->ip = fault address)
28697 + *
28698 + * returns 1 when task should be killed
28699 + * 2 when gcc trampoline was detected
28700 + */
28701 +static int pax_handle_fetch_fault(struct pt_regs *regs)
28702 +{
28703 + if (v8086_mode(regs))
28704 + return 1;
28705 +
28706 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
28707 + return 1;
28708 +
28709 +#ifdef CONFIG_X86_32
28710 + return pax_handle_fetch_fault_32(regs);
28711 +#else
28712 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
28713 + return pax_handle_fetch_fault_32(regs);
28714 + else
28715 + return pax_handle_fetch_fault_64(regs);
28716 +#endif
28717 +}
28718 +#endif
28719 +
28720 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28721 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
28722 +{
28723 + long i;
28724 +
28725 + printk(KERN_ERR "PAX: bytes at PC: ");
28726 + for (i = 0; i < 20; i++) {
28727 + unsigned char c;
28728 + if (get_user(c, (unsigned char __force_user *)pc+i))
28729 + printk(KERN_CONT "?? ");
28730 + else
28731 + printk(KERN_CONT "%02x ", c);
28732 + }
28733 + printk("\n");
28734 +
28735 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
28736 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
28737 + unsigned long c;
28738 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
28739 +#ifdef CONFIG_X86_32
28740 + printk(KERN_CONT "???????? ");
28741 +#else
28742 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
28743 + printk(KERN_CONT "???????? ???????? ");
28744 + else
28745 + printk(KERN_CONT "???????????????? ");
28746 +#endif
28747 + } else {
28748 +#ifdef CONFIG_X86_64
28749 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
28750 + printk(KERN_CONT "%08x ", (unsigned int)c);
28751 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
28752 + } else
28753 +#endif
28754 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
28755 + }
28756 + }
28757 + printk("\n");
28758 +}
28759 +#endif
28760 +
28761 +/**
28762 + * probe_kernel_write(): safely attempt to write to a location
28763 + * @dst: address to write to
28764 + * @src: pointer to the data that shall be written
28765 + * @size: size of the data chunk
28766 + *
28767 + * Safely write to address @dst from the buffer at @src. If a kernel fault
28768 + * happens, handle that and return -EFAULT.
28769 + */
28770 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
28771 +{
28772 + long ret;
28773 + mm_segment_t old_fs = get_fs();
28774 +
28775 + set_fs(KERNEL_DS);
28776 + pagefault_disable();
28777 + pax_open_kernel();
28778 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
28779 + pax_close_kernel();
28780 + pagefault_enable();
28781 + set_fs(old_fs);
28782 +
28783 + return ret ? -EFAULT : 0;
28784 +}
28785 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28786 index dd74e46..7d26398 100644
28787 --- a/arch/x86/mm/gup.c
28788 +++ b/arch/x86/mm/gup.c
28789 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28790 addr = start;
28791 len = (unsigned long) nr_pages << PAGE_SHIFT;
28792 end = start + len;
28793 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28794 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28795 (void __user *)start, len)))
28796 return 0;
28797
28798 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28799 index 6f31ee5..8ee4164 100644
28800 --- a/arch/x86/mm/highmem_32.c
28801 +++ b/arch/x86/mm/highmem_32.c
28802 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28803 idx = type + KM_TYPE_NR*smp_processor_id();
28804 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28805 BUG_ON(!pte_none(*(kmap_pte-idx)));
28806 +
28807 + pax_open_kernel();
28808 set_pte(kmap_pte-idx, mk_pte(page, prot));
28809 + pax_close_kernel();
28810 +
28811 arch_flush_lazy_mmu_mode();
28812
28813 return (void *)vaddr;
28814 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28815 index ae1aa71..56316db 100644
28816 --- a/arch/x86/mm/hugetlbpage.c
28817 +++ b/arch/x86/mm/hugetlbpage.c
28818 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28819 info.flags = 0;
28820 info.length = len;
28821 info.low_limit = TASK_UNMAPPED_BASE;
28822 +
28823 +#ifdef CONFIG_PAX_RANDMMAP
28824 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28825 + info.low_limit += current->mm->delta_mmap;
28826 +#endif
28827 +
28828 info.high_limit = TASK_SIZE;
28829 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28830 info.align_offset = 0;
28831 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28832 VM_BUG_ON(addr != -ENOMEM);
28833 info.flags = 0;
28834 info.low_limit = TASK_UNMAPPED_BASE;
28835 +
28836 +#ifdef CONFIG_PAX_RANDMMAP
28837 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28838 + info.low_limit += current->mm->delta_mmap;
28839 +#endif
28840 +
28841 info.high_limit = TASK_SIZE;
28842 addr = vm_unmapped_area(&info);
28843 }
28844 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28845 struct hstate *h = hstate_file(file);
28846 struct mm_struct *mm = current->mm;
28847 struct vm_area_struct *vma;
28848 + unsigned long pax_task_size = TASK_SIZE;
28849 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28850
28851 if (len & ~huge_page_mask(h))
28852 return -EINVAL;
28853 - if (len > TASK_SIZE)
28854 +
28855 +#ifdef CONFIG_PAX_SEGMEXEC
28856 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28857 + pax_task_size = SEGMEXEC_TASK_SIZE;
28858 +#endif
28859 +
28860 + pax_task_size -= PAGE_SIZE;
28861 +
28862 + if (len > pax_task_size)
28863 return -ENOMEM;
28864
28865 if (flags & MAP_FIXED) {
28866 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28867 return addr;
28868 }
28869
28870 +#ifdef CONFIG_PAX_RANDMMAP
28871 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28872 +#endif
28873 +
28874 if (addr) {
28875 addr = ALIGN(addr, huge_page_size(h));
28876 vma = find_vma(mm, addr);
28877 - if (TASK_SIZE - len >= addr &&
28878 - (!vma || addr + len <= vma->vm_start))
28879 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28880 return addr;
28881 }
28882 if (mm->get_unmapped_area == arch_get_unmapped_area)
28883 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28884 index d7aea41..0fc945b 100644
28885 --- a/arch/x86/mm/init.c
28886 +++ b/arch/x86/mm/init.c
28887 @@ -4,6 +4,7 @@
28888 #include <linux/swap.h>
28889 #include <linux/memblock.h>
28890 #include <linux/bootmem.h> /* for max_low_pfn */
28891 +#include <linux/tboot.h>
28892
28893 #include <asm/cacheflush.h>
28894 #include <asm/e820.h>
28895 @@ -16,6 +17,8 @@
28896 #include <asm/tlb.h>
28897 #include <asm/proto.h>
28898 #include <asm/dma.h> /* for MAX_DMA_PFN */
28899 +#include <asm/desc.h>
28900 +#include <asm/bios_ebda.h>
28901
28902 unsigned long __initdata pgt_buf_start;
28903 unsigned long __meminitdata pgt_buf_end;
28904 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
28905 {
28906 int i;
28907 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
28908 - unsigned long start = 0, good_end;
28909 + unsigned long start = 0x100000, good_end;
28910 phys_addr_t base;
28911
28912 for (i = 0; i < nr_range; i++) {
28913 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
28914 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28915 * mmio resources as well as potential bios/acpi data regions.
28916 */
28917 +
28918 +#ifdef CONFIG_GRKERNSEC_KMEM
28919 +static unsigned int ebda_start __read_only;
28920 +static unsigned int ebda_end __read_only;
28921 +#endif
28922 +
28923 int devmem_is_allowed(unsigned long pagenr)
28924 {
28925 - if (pagenr < 256)
28926 +#ifdef CONFIG_GRKERNSEC_KMEM
28927 + /* allow BDA */
28928 + if (!pagenr)
28929 return 1;
28930 + /* allow EBDA */
28931 + if (pagenr >= ebda_start && pagenr < ebda_end)
28932 + return 1;
28933 + /* if tboot is in use, allow access to its hardcoded serial log range */
28934 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28935 + return 1;
28936 +#else
28937 + if (!pagenr)
28938 + return 1;
28939 +#ifdef CONFIG_VM86
28940 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28941 + return 1;
28942 +#endif
28943 +#endif
28944 +
28945 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28946 + return 1;
28947 +#ifdef CONFIG_GRKERNSEC_KMEM
28948 + /* throw out everything else below 1MB */
28949 + if (pagenr <= 256)
28950 + return 0;
28951 +#endif
28952 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28953 return 0;
28954 if (!page_is_ram(pagenr))
28955 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28956 #endif
28957 }
28958
28959 +#ifdef CONFIG_GRKERNSEC_KMEM
28960 +static inline void gr_init_ebda(void)
28961 +{
28962 + unsigned int ebda_addr;
28963 + unsigned int ebda_size = 0;
28964 +
28965 + ebda_addr = get_bios_ebda();
28966 + if (ebda_addr) {
28967 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28968 + ebda_size <<= 10;
28969 + }
28970 + if (ebda_addr && ebda_size) {
28971 + ebda_start = ebda_addr >> PAGE_SHIFT;
28972 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28973 + } else {
28974 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28975 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28976 + }
28977 +}
28978 +#else
28979 +static inline void gr_init_ebda(void) { }
28980 +#endif
28981 +
28982 void free_initmem(void)
28983 {
28984 +#ifdef CONFIG_PAX_KERNEXEC
28985 +#ifdef CONFIG_X86_32
28986 + /* PaX: limit KERNEL_CS to actual size */
28987 + unsigned long addr, limit;
28988 + struct desc_struct d;
28989 + int cpu;
28990 +#else
28991 + pgd_t *pgd;
28992 + pud_t *pud;
28993 + pmd_t *pmd;
28994 + unsigned long addr, end;
28995 +#endif
28996 +#endif
28997 +
28998 + gr_init_ebda();
28999 +
29000 +#ifdef CONFIG_PAX_KERNEXEC
29001 +#ifdef CONFIG_X86_32
29002 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
29003 + limit = (limit - 1UL) >> PAGE_SHIFT;
29004 +
29005 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
29006 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
29007 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
29008 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
29009 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
29010 + }
29011 +
29012 + /* PaX: make KERNEL_CS read-only */
29013 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
29014 + if (!paravirt_enabled())
29015 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
29016 +/*
29017 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
29018 + pgd = pgd_offset_k(addr);
29019 + pud = pud_offset(pgd, addr);
29020 + pmd = pmd_offset(pud, addr);
29021 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
29022 + }
29023 +*/
29024 +#ifdef CONFIG_X86_PAE
29025 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
29026 +/*
29027 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
29028 + pgd = pgd_offset_k(addr);
29029 + pud = pud_offset(pgd, addr);
29030 + pmd = pmd_offset(pud, addr);
29031 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
29032 + }
29033 +*/
29034 +#endif
29035 +
29036 +#ifdef CONFIG_MODULES
29037 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
29038 +#endif
29039 +
29040 +#else
29041 + /* PaX: make kernel code/rodata read-only, rest non-executable */
29042 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
29043 + pgd = pgd_offset_k(addr);
29044 + pud = pud_offset(pgd, addr);
29045 + pmd = pmd_offset(pud, addr);
29046 + if (!pmd_present(*pmd))
29047 + continue;
29048 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
29049 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
29050 + else
29051 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
29052 + }
29053 +
29054 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
29055 + end = addr + KERNEL_IMAGE_SIZE;
29056 + for (; addr < end; addr += PMD_SIZE) {
29057 + pgd = pgd_offset_k(addr);
29058 + pud = pud_offset(pgd, addr);
29059 + pmd = pmd_offset(pud, addr);
29060 + if (!pmd_present(*pmd))
29061 + continue;
29062 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
29063 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
29064 + }
29065 +#endif
29066 +
29067 + flush_tlb_all();
29068 +#endif
29069 +
29070 free_init_pages("unused kernel memory",
29071 (unsigned long)(&__init_begin),
29072 (unsigned long)(&__init_end));
29073 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
29074 index 745d66b..56bf568 100644
29075 --- a/arch/x86/mm/init_32.c
29076 +++ b/arch/x86/mm/init_32.c
29077 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
29078 }
29079
29080 /*
29081 - * Creates a middle page table and puts a pointer to it in the
29082 - * given global directory entry. This only returns the gd entry
29083 - * in non-PAE compilation mode, since the middle layer is folded.
29084 - */
29085 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
29086 -{
29087 - pud_t *pud;
29088 - pmd_t *pmd_table;
29089 -
29090 -#ifdef CONFIG_X86_PAE
29091 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
29092 - if (after_bootmem)
29093 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
29094 - else
29095 - pmd_table = (pmd_t *)alloc_low_page();
29096 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
29097 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
29098 - pud = pud_offset(pgd, 0);
29099 - BUG_ON(pmd_table != pmd_offset(pud, 0));
29100 -
29101 - return pmd_table;
29102 - }
29103 -#endif
29104 - pud = pud_offset(pgd, 0);
29105 - pmd_table = pmd_offset(pud, 0);
29106 -
29107 - return pmd_table;
29108 -}
29109 -
29110 -/*
29111 * Create a page table and place a pointer to it in a middle page
29112 * directory entry:
29113 */
29114 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
29115 page_table = (pte_t *)alloc_low_page();
29116
29117 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
29118 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29119 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
29120 +#else
29121 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
29122 +#endif
29123 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
29124 }
29125
29126 return pte_offset_kernel(pmd, 0);
29127 }
29128
29129 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
29130 +{
29131 + pud_t *pud;
29132 + pmd_t *pmd_table;
29133 +
29134 + pud = pud_offset(pgd, 0);
29135 + pmd_table = pmd_offset(pud, 0);
29136 +
29137 + return pmd_table;
29138 +}
29139 +
29140 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
29141 {
29142 int pgd_idx = pgd_index(vaddr);
29143 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
29144 int pgd_idx, pmd_idx;
29145 unsigned long vaddr;
29146 pgd_t *pgd;
29147 + pud_t *pud;
29148 pmd_t *pmd;
29149 pte_t *pte = NULL;
29150
29151 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
29152 pgd = pgd_base + pgd_idx;
29153
29154 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
29155 - pmd = one_md_table_init(pgd);
29156 - pmd = pmd + pmd_index(vaddr);
29157 + pud = pud_offset(pgd, vaddr);
29158 + pmd = pmd_offset(pud, vaddr);
29159 +
29160 +#ifdef CONFIG_X86_PAE
29161 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
29162 +#endif
29163 +
29164 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
29165 pmd++, pmd_idx++) {
29166 pte = page_table_kmap_check(one_page_table_init(pmd),
29167 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
29168 }
29169 }
29170
29171 -static inline int is_kernel_text(unsigned long addr)
29172 +static inline int is_kernel_text(unsigned long start, unsigned long end)
29173 {
29174 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
29175 - return 1;
29176 - return 0;
29177 + if ((start > ktla_ktva((unsigned long)_etext) ||
29178 + end <= ktla_ktva((unsigned long)_stext)) &&
29179 + (start > ktla_ktva((unsigned long)_einittext) ||
29180 + end <= ktla_ktva((unsigned long)_sinittext)) &&
29181 +
29182 +#ifdef CONFIG_ACPI_SLEEP
29183 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
29184 +#endif
29185 +
29186 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
29187 + return 0;
29188 + return 1;
29189 }
29190
29191 /*
29192 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
29193 unsigned long last_map_addr = end;
29194 unsigned long start_pfn, end_pfn;
29195 pgd_t *pgd_base = swapper_pg_dir;
29196 - int pgd_idx, pmd_idx, pte_ofs;
29197 + unsigned int pgd_idx, pmd_idx, pte_ofs;
29198 unsigned long pfn;
29199 pgd_t *pgd;
29200 + pud_t *pud;
29201 pmd_t *pmd;
29202 pte_t *pte;
29203 unsigned pages_2m, pages_4k;
29204 @@ -280,8 +281,13 @@ repeat:
29205 pfn = start_pfn;
29206 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
29207 pgd = pgd_base + pgd_idx;
29208 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
29209 - pmd = one_md_table_init(pgd);
29210 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
29211 + pud = pud_offset(pgd, 0);
29212 + pmd = pmd_offset(pud, 0);
29213 +
29214 +#ifdef CONFIG_X86_PAE
29215 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
29216 +#endif
29217
29218 if (pfn >= end_pfn)
29219 continue;
29220 @@ -293,14 +299,13 @@ repeat:
29221 #endif
29222 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
29223 pmd++, pmd_idx++) {
29224 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
29225 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
29226
29227 /*
29228 * Map with big pages if possible, otherwise
29229 * create normal page tables:
29230 */
29231 if (use_pse) {
29232 - unsigned int addr2;
29233 pgprot_t prot = PAGE_KERNEL_LARGE;
29234 /*
29235 * first pass will use the same initial
29236 @@ -310,11 +315,7 @@ repeat:
29237 __pgprot(PTE_IDENT_ATTR |
29238 _PAGE_PSE);
29239
29240 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
29241 - PAGE_OFFSET + PAGE_SIZE-1;
29242 -
29243 - if (is_kernel_text(addr) ||
29244 - is_kernel_text(addr2))
29245 + if (is_kernel_text(address, address + PMD_SIZE))
29246 prot = PAGE_KERNEL_LARGE_EXEC;
29247
29248 pages_2m++;
29249 @@ -331,7 +332,7 @@ repeat:
29250 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
29251 pte += pte_ofs;
29252 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
29253 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
29254 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
29255 pgprot_t prot = PAGE_KERNEL;
29256 /*
29257 * first pass will use the same initial
29258 @@ -339,7 +340,7 @@ repeat:
29259 */
29260 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
29261
29262 - if (is_kernel_text(addr))
29263 + if (is_kernel_text(address, address + PAGE_SIZE))
29264 prot = PAGE_KERNEL_EXEC;
29265
29266 pages_4k++;
29267 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
29268
29269 pud = pud_offset(pgd, va);
29270 pmd = pmd_offset(pud, va);
29271 - if (!pmd_present(*pmd))
29272 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
29273 break;
29274
29275 pte = pte_offset_kernel(pmd, va);
29276 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
29277
29278 static void __init pagetable_init(void)
29279 {
29280 - pgd_t *pgd_base = swapper_pg_dir;
29281 -
29282 - permanent_kmaps_init(pgd_base);
29283 + permanent_kmaps_init(swapper_pg_dir);
29284 }
29285
29286 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
29287 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
29288 EXPORT_SYMBOL_GPL(__supported_pte_mask);
29289
29290 /* user-defined highmem size */
29291 @@ -728,6 +727,12 @@ void __init mem_init(void)
29292
29293 pci_iommu_alloc();
29294
29295 +#ifdef CONFIG_PAX_PER_CPU_PGD
29296 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
29297 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
29298 + KERNEL_PGD_PTRS);
29299 +#endif
29300 +
29301 #ifdef CONFIG_FLATMEM
29302 BUG_ON(!mem_map);
29303 #endif
29304 @@ -754,7 +759,7 @@ void __init mem_init(void)
29305 reservedpages++;
29306
29307 codesize = (unsigned long) &_etext - (unsigned long) &_text;
29308 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
29309 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
29310 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
29311
29312 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
29313 @@ -795,10 +800,10 @@ void __init mem_init(void)
29314 ((unsigned long)&__init_end -
29315 (unsigned long)&__init_begin) >> 10,
29316
29317 - (unsigned long)&_etext, (unsigned long)&_edata,
29318 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
29319 + (unsigned long)&_sdata, (unsigned long)&_edata,
29320 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
29321
29322 - (unsigned long)&_text, (unsigned long)&_etext,
29323 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
29324 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
29325
29326 /*
29327 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
29328 if (!kernel_set_to_readonly)
29329 return;
29330
29331 + start = ktla_ktva(start);
29332 pr_debug("Set kernel text: %lx - %lx for read write\n",
29333 start, start+size);
29334
29335 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
29336 if (!kernel_set_to_readonly)
29337 return;
29338
29339 + start = ktla_ktva(start);
29340 pr_debug("Set kernel text: %lx - %lx for read only\n",
29341 start, start+size);
29342
29343 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
29344 unsigned long start = PFN_ALIGN(_text);
29345 unsigned long size = PFN_ALIGN(_etext) - start;
29346
29347 + start = ktla_ktva(start);
29348 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
29349 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
29350 size >> 10);
29351 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
29352 index 75c9a6a..498d677 100644
29353 --- a/arch/x86/mm/init_64.c
29354 +++ b/arch/x86/mm/init_64.c
29355 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
29356 * around without checking the pgd every time.
29357 */
29358
29359 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
29360 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
29361 EXPORT_SYMBOL_GPL(__supported_pte_mask);
29362
29363 int force_personality32;
29364 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
29365
29366 for (address = start; address <= end; address += PGDIR_SIZE) {
29367 const pgd_t *pgd_ref = pgd_offset_k(address);
29368 +
29369 +#ifdef CONFIG_PAX_PER_CPU_PGD
29370 + unsigned long cpu;
29371 +#else
29372 struct page *page;
29373 +#endif
29374
29375 if (pgd_none(*pgd_ref))
29376 continue;
29377
29378 spin_lock(&pgd_lock);
29379 +
29380 +#ifdef CONFIG_PAX_PER_CPU_PGD
29381 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29382 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
29383 +#else
29384 list_for_each_entry(page, &pgd_list, lru) {
29385 pgd_t *pgd;
29386 spinlock_t *pgt_lock;
29387 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
29388 /* the pgt_lock only for Xen */
29389 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29390 spin_lock(pgt_lock);
29391 +#endif
29392
29393 if (pgd_none(*pgd))
29394 set_pgd(pgd, *pgd_ref);
29395 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
29396 BUG_ON(pgd_page_vaddr(*pgd)
29397 != pgd_page_vaddr(*pgd_ref));
29398
29399 +#ifndef CONFIG_PAX_PER_CPU_PGD
29400 spin_unlock(pgt_lock);
29401 +#endif
29402 +
29403 }
29404 spin_unlock(&pgd_lock);
29405 }
29406 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
29407 {
29408 if (pgd_none(*pgd)) {
29409 pud_t *pud = (pud_t *)spp_getpage();
29410 - pgd_populate(&init_mm, pgd, pud);
29411 + pgd_populate_kernel(&init_mm, pgd, pud);
29412 if (pud != pud_offset(pgd, 0))
29413 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
29414 pud, pud_offset(pgd, 0));
29415 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
29416 {
29417 if (pud_none(*pud)) {
29418 pmd_t *pmd = (pmd_t *) spp_getpage();
29419 - pud_populate(&init_mm, pud, pmd);
29420 + pud_populate_kernel(&init_mm, pud, pmd);
29421 if (pmd != pmd_offset(pud, 0))
29422 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
29423 pmd, pmd_offset(pud, 0));
29424 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
29425 pmd = fill_pmd(pud, vaddr);
29426 pte = fill_pte(pmd, vaddr);
29427
29428 + pax_open_kernel();
29429 set_pte(pte, new_pte);
29430 + pax_close_kernel();
29431
29432 /*
29433 * It's enough to flush this one mapping.
29434 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
29435 pgd = pgd_offset_k((unsigned long)__va(phys));
29436 if (pgd_none(*pgd)) {
29437 pud = (pud_t *) spp_getpage();
29438 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
29439 - _PAGE_USER));
29440 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
29441 }
29442 pud = pud_offset(pgd, (unsigned long)__va(phys));
29443 if (pud_none(*pud)) {
29444 pmd = (pmd_t *) spp_getpage();
29445 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
29446 - _PAGE_USER));
29447 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
29448 }
29449 pmd = pmd_offset(pud, phys);
29450 BUG_ON(!pmd_none(*pmd));
29451 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
29452 if (pfn >= pgt_buf_top)
29453 panic("alloc_low_page: ran out of memory");
29454
29455 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
29456 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
29457 clear_page(adr);
29458 *phys = pfn * PAGE_SIZE;
29459 return adr;
29460 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
29461
29462 phys = __pa(virt);
29463 left = phys & (PAGE_SIZE - 1);
29464 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
29465 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
29466 adr = (void *)(((unsigned long)adr) | left);
29467
29468 return adr;
29469 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
29470 unmap_low_page(pmd);
29471
29472 spin_lock(&init_mm.page_table_lock);
29473 - pud_populate(&init_mm, pud, __va(pmd_phys));
29474 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
29475 spin_unlock(&init_mm.page_table_lock);
29476 }
29477 __flush_tlb_all();
29478 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
29479 unmap_low_page(pud);
29480
29481 spin_lock(&init_mm.page_table_lock);
29482 - pgd_populate(&init_mm, pgd, __va(pud_phys));
29483 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
29484 spin_unlock(&init_mm.page_table_lock);
29485 pgd_changed = true;
29486 }
29487 @@ -693,6 +707,12 @@ void __init mem_init(void)
29488
29489 pci_iommu_alloc();
29490
29491 +#ifdef CONFIG_PAX_PER_CPU_PGD
29492 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
29493 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
29494 + KERNEL_PGD_PTRS);
29495 +#endif
29496 +
29497 /* clear_bss() already clear the empty_zero_page */
29498
29499 reservedpages = 0;
29500 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
29501 static struct vm_area_struct gate_vma = {
29502 .vm_start = VSYSCALL_START,
29503 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
29504 - .vm_page_prot = PAGE_READONLY_EXEC,
29505 - .vm_flags = VM_READ | VM_EXEC
29506 + .vm_page_prot = PAGE_READONLY,
29507 + .vm_flags = VM_READ
29508 };
29509
29510 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
29511 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
29512
29513 const char *arch_vma_name(struct vm_area_struct *vma)
29514 {
29515 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
29516 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
29517 return "[vdso]";
29518 if (vma == &gate_vma)
29519 return "[vsyscall]";
29520 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
29521 index 7b179b4..6bd17777 100644
29522 --- a/arch/x86/mm/iomap_32.c
29523 +++ b/arch/x86/mm/iomap_32.c
29524 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
29525 type = kmap_atomic_idx_push();
29526 idx = type + KM_TYPE_NR * smp_processor_id();
29527 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
29528 +
29529 + pax_open_kernel();
29530 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
29531 + pax_close_kernel();
29532 +
29533 arch_flush_lazy_mmu_mode();
29534
29535 return (void *)vaddr;
29536 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
29537 index 78fe3f1..73b95e2 100644
29538 --- a/arch/x86/mm/ioremap.c
29539 +++ b/arch/x86/mm/ioremap.c
29540 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
29541 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
29542 int is_ram = page_is_ram(pfn);
29543
29544 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
29545 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
29546 return NULL;
29547 WARN_ON_ONCE(is_ram);
29548 }
29549 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
29550 *
29551 * Caller must ensure there is only one unmapping for the same pointer.
29552 */
29553 -void iounmap(volatile void __iomem *addr)
29554 +void iounmap(const volatile void __iomem *addr)
29555 {
29556 struct vm_struct *p, *o;
29557
29558 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29559
29560 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
29561 if (page_is_ram(start >> PAGE_SHIFT))
29562 +#ifdef CONFIG_HIGHMEM
29563 + if ((start >> PAGE_SHIFT) < max_low_pfn)
29564 +#endif
29565 return __va(phys);
29566
29567 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
29568 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29569 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
29570 {
29571 if (page_is_ram(phys >> PAGE_SHIFT))
29572 +#ifdef CONFIG_HIGHMEM
29573 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
29574 +#endif
29575 return;
29576
29577 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
29578 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
29579 early_param("early_ioremap_debug", early_ioremap_debug_setup);
29580
29581 static __initdata int after_paging_init;
29582 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
29583 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
29584
29585 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
29586 {
29587 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
29588 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
29589
29590 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
29591 - memset(bm_pte, 0, sizeof(bm_pte));
29592 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
29593 + pmd_populate_user(&init_mm, pmd, bm_pte);
29594
29595 /*
29596 * The boot-ioremap range spans multiple pmds, for which
29597 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
29598 index d87dd6d..bf3fa66 100644
29599 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
29600 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
29601 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
29602 * memory (e.g. tracked pages)? For now, we need this to avoid
29603 * invoking kmemcheck for PnP BIOS calls.
29604 */
29605 - if (regs->flags & X86_VM_MASK)
29606 + if (v8086_mode(regs))
29607 return false;
29608 - if (regs->cs != __KERNEL_CS)
29609 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
29610 return false;
29611
29612 pte = kmemcheck_pte_lookup(address);
29613 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
29614 index 845df68..1d8d29f 100644
29615 --- a/arch/x86/mm/mmap.c
29616 +++ b/arch/x86/mm/mmap.c
29617 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
29618 * Leave an at least ~128 MB hole with possible stack randomization.
29619 */
29620 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
29621 -#define MAX_GAP (TASK_SIZE/6*5)
29622 +#define MAX_GAP (pax_task_size/6*5)
29623
29624 static int mmap_is_legacy(void)
29625 {
29626 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
29627 return rnd << PAGE_SHIFT;
29628 }
29629
29630 -static unsigned long mmap_base(void)
29631 +static unsigned long mmap_base(struct mm_struct *mm)
29632 {
29633 unsigned long gap = rlimit(RLIMIT_STACK);
29634 + unsigned long pax_task_size = TASK_SIZE;
29635 +
29636 +#ifdef CONFIG_PAX_SEGMEXEC
29637 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29638 + pax_task_size = SEGMEXEC_TASK_SIZE;
29639 +#endif
29640
29641 if (gap < MIN_GAP)
29642 gap = MIN_GAP;
29643 else if (gap > MAX_GAP)
29644 gap = MAX_GAP;
29645
29646 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
29647 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
29648 }
29649
29650 /*
29651 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
29652 * does, but not when emulating X86_32
29653 */
29654 -static unsigned long mmap_legacy_base(void)
29655 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
29656 {
29657 - if (mmap_is_ia32())
29658 + if (mmap_is_ia32()) {
29659 +
29660 +#ifdef CONFIG_PAX_SEGMEXEC
29661 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29662 + return SEGMEXEC_TASK_UNMAPPED_BASE;
29663 + else
29664 +#endif
29665 +
29666 return TASK_UNMAPPED_BASE;
29667 - else
29668 + } else
29669 return TASK_UNMAPPED_BASE + mmap_rnd();
29670 }
29671
29672 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
29673 void arch_pick_mmap_layout(struct mm_struct *mm)
29674 {
29675 if (mmap_is_legacy()) {
29676 - mm->mmap_base = mmap_legacy_base();
29677 + mm->mmap_base = mmap_legacy_base(mm);
29678 +
29679 +#ifdef CONFIG_PAX_RANDMMAP
29680 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29681 + mm->mmap_base += mm->delta_mmap;
29682 +#endif
29683 +
29684 mm->get_unmapped_area = arch_get_unmapped_area;
29685 mm->unmap_area = arch_unmap_area;
29686 } else {
29687 - mm->mmap_base = mmap_base();
29688 + mm->mmap_base = mmap_base(mm);
29689 +
29690 +#ifdef CONFIG_PAX_RANDMMAP
29691 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29692 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
29693 +#endif
29694 +
29695 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
29696 mm->unmap_area = arch_unmap_area_topdown;
29697 }
29698 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
29699 index dc0b727..f612039 100644
29700 --- a/arch/x86/mm/mmio-mod.c
29701 +++ b/arch/x86/mm/mmio-mod.c
29702 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
29703 break;
29704 default:
29705 {
29706 - unsigned char *ip = (unsigned char *)instptr;
29707 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
29708 my_trace->opcode = MMIO_UNKNOWN_OP;
29709 my_trace->width = 0;
29710 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
29711 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
29712 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29713 void __iomem *addr)
29714 {
29715 - static atomic_t next_id;
29716 + static atomic_unchecked_t next_id;
29717 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
29718 /* These are page-unaligned. */
29719 struct mmiotrace_map map = {
29720 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29721 .private = trace
29722 },
29723 .phys = offset,
29724 - .id = atomic_inc_return(&next_id)
29725 + .id = atomic_inc_return_unchecked(&next_id)
29726 };
29727 map.map_id = trace->id;
29728
29729 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
29730 ioremap_trace_core(offset, size, addr);
29731 }
29732
29733 -static void iounmap_trace_core(volatile void __iomem *addr)
29734 +static void iounmap_trace_core(const volatile void __iomem *addr)
29735 {
29736 struct mmiotrace_map map = {
29737 .phys = 0,
29738 @@ -328,7 +328,7 @@ not_enabled:
29739 }
29740 }
29741
29742 -void mmiotrace_iounmap(volatile void __iomem *addr)
29743 +void mmiotrace_iounmap(const volatile void __iomem *addr)
29744 {
29745 might_sleep();
29746 if (is_enabled()) /* recheck and proper locking in *_core() */
29747 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
29748 index 8504f36..5fc68f2 100644
29749 --- a/arch/x86/mm/numa.c
29750 +++ b/arch/x86/mm/numa.c
29751 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
29752 return true;
29753 }
29754
29755 -static int __init numa_register_memblks(struct numa_meminfo *mi)
29756 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
29757 {
29758 unsigned long uninitialized_var(pfn_align);
29759 int i, nid;
29760 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
29761 index b008656..773eac2 100644
29762 --- a/arch/x86/mm/pageattr-test.c
29763 +++ b/arch/x86/mm/pageattr-test.c
29764 @@ -36,7 +36,7 @@ enum {
29765
29766 static int pte_testbit(pte_t pte)
29767 {
29768 - return pte_flags(pte) & _PAGE_UNUSED1;
29769 + return pte_flags(pte) & _PAGE_CPA_TEST;
29770 }
29771
29772 struct split_state {
29773 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
29774 index a718e0d..77419bc 100644
29775 --- a/arch/x86/mm/pageattr.c
29776 +++ b/arch/x86/mm/pageattr.c
29777 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29778 */
29779 #ifdef CONFIG_PCI_BIOS
29780 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
29781 - pgprot_val(forbidden) |= _PAGE_NX;
29782 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29783 #endif
29784
29785 /*
29786 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29787 * Does not cover __inittext since that is gone later on. On
29788 * 64bit we do not enforce !NX on the low mapping
29789 */
29790 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29791 - pgprot_val(forbidden) |= _PAGE_NX;
29792 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29793 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29794
29795 +#ifdef CONFIG_DEBUG_RODATA
29796 /*
29797 * The .rodata section needs to be read-only. Using the pfn
29798 * catches all aliases.
29799 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29800 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
29801 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
29802 pgprot_val(forbidden) |= _PAGE_RW;
29803 +#endif
29804
29805 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29806 /*
29807 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29808 }
29809 #endif
29810
29811 +#ifdef CONFIG_PAX_KERNEXEC
29812 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29813 + pgprot_val(forbidden) |= _PAGE_RW;
29814 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29815 + }
29816 +#endif
29817 +
29818 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29819
29820 return prot;
29821 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
29822 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29823 {
29824 /* change init_mm */
29825 + pax_open_kernel();
29826 set_pte_atomic(kpte, pte);
29827 +
29828 #ifdef CONFIG_X86_32
29829 if (!SHARED_KERNEL_PMD) {
29830 +
29831 +#ifdef CONFIG_PAX_PER_CPU_PGD
29832 + unsigned long cpu;
29833 +#else
29834 struct page *page;
29835 +#endif
29836
29837 +#ifdef CONFIG_PAX_PER_CPU_PGD
29838 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29839 + pgd_t *pgd = get_cpu_pgd(cpu);
29840 +#else
29841 list_for_each_entry(page, &pgd_list, lru) {
29842 - pgd_t *pgd;
29843 + pgd_t *pgd = (pgd_t *)page_address(page);
29844 +#endif
29845 +
29846 pud_t *pud;
29847 pmd_t *pmd;
29848
29849 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29850 + pgd += pgd_index(address);
29851 pud = pud_offset(pgd, address);
29852 pmd = pmd_offset(pud, address);
29853 set_pte_atomic((pte_t *)pmd, pte);
29854 }
29855 }
29856 #endif
29857 + pax_close_kernel();
29858 }
29859
29860 static int
29861 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29862 index 0eb572e..92f5c1e 100644
29863 --- a/arch/x86/mm/pat.c
29864 +++ b/arch/x86/mm/pat.c
29865 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29866
29867 if (!entry) {
29868 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29869 - current->comm, current->pid, start, end - 1);
29870 + current->comm, task_pid_nr(current), start, end - 1);
29871 return -EINVAL;
29872 }
29873
29874 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29875
29876 while (cursor < to) {
29877 if (!devmem_is_allowed(pfn)) {
29878 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29879 - current->comm, from, to - 1);
29880 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29881 + current->comm, from, to - 1, cursor);
29882 return 0;
29883 }
29884 cursor += PAGE_SIZE;
29885 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29886 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29887 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29888 "for [mem %#010Lx-%#010Lx]\n",
29889 - current->comm, current->pid,
29890 + current->comm, task_pid_nr(current),
29891 cattr_name(flags),
29892 base, (unsigned long long)(base + size-1));
29893 return -EINVAL;
29894 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29895 flags = lookup_memtype(paddr);
29896 if (want_flags != flags) {
29897 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29898 - current->comm, current->pid,
29899 + current->comm, task_pid_nr(current),
29900 cattr_name(want_flags),
29901 (unsigned long long)paddr,
29902 (unsigned long long)(paddr + size - 1),
29903 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29904 free_memtype(paddr, paddr + size);
29905 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29906 " for [mem %#010Lx-%#010Lx], got %s\n",
29907 - current->comm, current->pid,
29908 + current->comm, task_pid_nr(current),
29909 cattr_name(want_flags),
29910 (unsigned long long)paddr,
29911 (unsigned long long)(paddr + size - 1),
29912 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29913 index 9f0614d..92ae64a 100644
29914 --- a/arch/x86/mm/pf_in.c
29915 +++ b/arch/x86/mm/pf_in.c
29916 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29917 int i;
29918 enum reason_type rv = OTHERS;
29919
29920 - p = (unsigned char *)ins_addr;
29921 + p = (unsigned char *)ktla_ktva(ins_addr);
29922 p += skip_prefix(p, &prf);
29923 p += get_opcode(p, &opcode);
29924
29925 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29926 struct prefix_bits prf;
29927 int i;
29928
29929 - p = (unsigned char *)ins_addr;
29930 + p = (unsigned char *)ktla_ktva(ins_addr);
29931 p += skip_prefix(p, &prf);
29932 p += get_opcode(p, &opcode);
29933
29934 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29935 struct prefix_bits prf;
29936 int i;
29937
29938 - p = (unsigned char *)ins_addr;
29939 + p = (unsigned char *)ktla_ktva(ins_addr);
29940 p += skip_prefix(p, &prf);
29941 p += get_opcode(p, &opcode);
29942
29943 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29944 struct prefix_bits prf;
29945 int i;
29946
29947 - p = (unsigned char *)ins_addr;
29948 + p = (unsigned char *)ktla_ktva(ins_addr);
29949 p += skip_prefix(p, &prf);
29950 p += get_opcode(p, &opcode);
29951 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29952 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29953 struct prefix_bits prf;
29954 int i;
29955
29956 - p = (unsigned char *)ins_addr;
29957 + p = (unsigned char *)ktla_ktva(ins_addr);
29958 p += skip_prefix(p, &prf);
29959 p += get_opcode(p, &opcode);
29960 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29961 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29962 index 395b3b4a..213e72b 100644
29963 --- a/arch/x86/mm/pgtable.c
29964 +++ b/arch/x86/mm/pgtable.c
29965 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29966 list_del(&page->lru);
29967 }
29968
29969 -#define UNSHARED_PTRS_PER_PGD \
29970 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29971 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29972 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29973
29974 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29975 +{
29976 + unsigned int count = USER_PGD_PTRS;
29977
29978 + while (count--)
29979 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29980 +}
29981 +#endif
29982 +
29983 +#ifdef CONFIG_PAX_PER_CPU_PGD
29984 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29985 +{
29986 + unsigned int count = USER_PGD_PTRS;
29987 +
29988 + while (count--) {
29989 + pgd_t pgd;
29990 +
29991 +#ifdef CONFIG_X86_64
29992 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29993 +#else
29994 + pgd = *src++;
29995 +#endif
29996 +
29997 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29998 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29999 +#endif
30000 +
30001 + *dst++ = pgd;
30002 + }
30003 +
30004 +}
30005 +#endif
30006 +
30007 +#ifdef CONFIG_X86_64
30008 +#define pxd_t pud_t
30009 +#define pyd_t pgd_t
30010 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
30011 +#define pxd_free(mm, pud) pud_free((mm), (pud))
30012 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
30013 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
30014 +#define PYD_SIZE PGDIR_SIZE
30015 +#else
30016 +#define pxd_t pmd_t
30017 +#define pyd_t pud_t
30018 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
30019 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
30020 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
30021 +#define pyd_offset(mm, address) pud_offset((mm), (address))
30022 +#define PYD_SIZE PUD_SIZE
30023 +#endif
30024 +
30025 +#ifdef CONFIG_PAX_PER_CPU_PGD
30026 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
30027 +static inline void pgd_dtor(pgd_t *pgd) {}
30028 +#else
30029 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
30030 {
30031 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
30032 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
30033 pgd_list_del(pgd);
30034 spin_unlock(&pgd_lock);
30035 }
30036 +#endif
30037
30038 /*
30039 * List of all pgd's needed for non-PAE so it can invalidate entries
30040 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
30041 * -- nyc
30042 */
30043
30044 -#ifdef CONFIG_X86_PAE
30045 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
30046 /*
30047 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
30048 * updating the top-level pagetable entries to guarantee the
30049 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
30050 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
30051 * and initialize the kernel pmds here.
30052 */
30053 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
30054 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
30055
30056 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
30057 {
30058 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
30059 */
30060 flush_tlb_mm(mm);
30061 }
30062 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
30063 +#define PREALLOCATED_PXDS USER_PGD_PTRS
30064 #else /* !CONFIG_X86_PAE */
30065
30066 /* No need to prepopulate any pagetable entries in non-PAE modes. */
30067 -#define PREALLOCATED_PMDS 0
30068 +#define PREALLOCATED_PXDS 0
30069
30070 #endif /* CONFIG_X86_PAE */
30071
30072 -static void free_pmds(pmd_t *pmds[])
30073 +static void free_pxds(pxd_t *pxds[])
30074 {
30075 int i;
30076
30077 - for(i = 0; i < PREALLOCATED_PMDS; i++)
30078 - if (pmds[i])
30079 - free_page((unsigned long)pmds[i]);
30080 + for(i = 0; i < PREALLOCATED_PXDS; i++)
30081 + if (pxds[i])
30082 + free_page((unsigned long)pxds[i]);
30083 }
30084
30085 -static int preallocate_pmds(pmd_t *pmds[])
30086 +static int preallocate_pxds(pxd_t *pxds[])
30087 {
30088 int i;
30089 bool failed = false;
30090
30091 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
30092 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
30093 - if (pmd == NULL)
30094 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
30095 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
30096 + if (pxd == NULL)
30097 failed = true;
30098 - pmds[i] = pmd;
30099 + pxds[i] = pxd;
30100 }
30101
30102 if (failed) {
30103 - free_pmds(pmds);
30104 + free_pxds(pxds);
30105 return -ENOMEM;
30106 }
30107
30108 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
30109 * preallocate which never got a corresponding vma will need to be
30110 * freed manually.
30111 */
30112 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
30113 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
30114 {
30115 int i;
30116
30117 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
30118 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
30119 pgd_t pgd = pgdp[i];
30120
30121 if (pgd_val(pgd) != 0) {
30122 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
30123 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
30124
30125 - pgdp[i] = native_make_pgd(0);
30126 + set_pgd(pgdp + i, native_make_pgd(0));
30127
30128 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
30129 - pmd_free(mm, pmd);
30130 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
30131 + pxd_free(mm, pxd);
30132 }
30133 }
30134 }
30135
30136 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
30137 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
30138 {
30139 - pud_t *pud;
30140 + pyd_t *pyd;
30141 unsigned long addr;
30142 int i;
30143
30144 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
30145 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
30146 return;
30147
30148 - pud = pud_offset(pgd, 0);
30149 +#ifdef CONFIG_X86_64
30150 + pyd = pyd_offset(mm, 0L);
30151 +#else
30152 + pyd = pyd_offset(pgd, 0L);
30153 +#endif
30154
30155 - for (addr = i = 0; i < PREALLOCATED_PMDS;
30156 - i++, pud++, addr += PUD_SIZE) {
30157 - pmd_t *pmd = pmds[i];
30158 + for (addr = i = 0; i < PREALLOCATED_PXDS;
30159 + i++, pyd++, addr += PYD_SIZE) {
30160 + pxd_t *pxd = pxds[i];
30161
30162 if (i >= KERNEL_PGD_BOUNDARY)
30163 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
30164 - sizeof(pmd_t) * PTRS_PER_PMD);
30165 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
30166 + sizeof(pxd_t) * PTRS_PER_PMD);
30167
30168 - pud_populate(mm, pud, pmd);
30169 + pyd_populate(mm, pyd, pxd);
30170 }
30171 }
30172
30173 pgd_t *pgd_alloc(struct mm_struct *mm)
30174 {
30175 pgd_t *pgd;
30176 - pmd_t *pmds[PREALLOCATED_PMDS];
30177 + pxd_t *pxds[PREALLOCATED_PXDS];
30178
30179 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
30180
30181 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
30182
30183 mm->pgd = pgd;
30184
30185 - if (preallocate_pmds(pmds) != 0)
30186 + if (preallocate_pxds(pxds) != 0)
30187 goto out_free_pgd;
30188
30189 if (paravirt_pgd_alloc(mm) != 0)
30190 - goto out_free_pmds;
30191 + goto out_free_pxds;
30192
30193 /*
30194 * Make sure that pre-populating the pmds is atomic with
30195 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
30196 spin_lock(&pgd_lock);
30197
30198 pgd_ctor(mm, pgd);
30199 - pgd_prepopulate_pmd(mm, pgd, pmds);
30200 + pgd_prepopulate_pxd(mm, pgd, pxds);
30201
30202 spin_unlock(&pgd_lock);
30203
30204 return pgd;
30205
30206 -out_free_pmds:
30207 - free_pmds(pmds);
30208 +out_free_pxds:
30209 + free_pxds(pxds);
30210 out_free_pgd:
30211 free_page((unsigned long)pgd);
30212 out:
30213 @@ -302,7 +363,7 @@ out:
30214
30215 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
30216 {
30217 - pgd_mop_up_pmds(mm, pgd);
30218 + pgd_mop_up_pxds(mm, pgd);
30219 pgd_dtor(pgd);
30220 paravirt_pgd_free(mm, pgd);
30221 free_page((unsigned long)pgd);
30222 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
30223 index a69bcb8..19068ab 100644
30224 --- a/arch/x86/mm/pgtable_32.c
30225 +++ b/arch/x86/mm/pgtable_32.c
30226 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
30227 return;
30228 }
30229 pte = pte_offset_kernel(pmd, vaddr);
30230 +
30231 + pax_open_kernel();
30232 if (pte_val(pteval))
30233 set_pte_at(&init_mm, vaddr, pte, pteval);
30234 else
30235 pte_clear(&init_mm, vaddr, pte);
30236 + pax_close_kernel();
30237
30238 /*
30239 * It's enough to flush this one mapping.
30240 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
30241 index d2e2735..5c6586f 100644
30242 --- a/arch/x86/mm/physaddr.c
30243 +++ b/arch/x86/mm/physaddr.c
30244 @@ -8,7 +8,7 @@
30245
30246 #ifdef CONFIG_X86_64
30247
30248 -unsigned long __phys_addr(unsigned long x)
30249 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
30250 {
30251 if (x >= __START_KERNEL_map) {
30252 x -= __START_KERNEL_map;
30253 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
30254 #else
30255
30256 #ifdef CONFIG_DEBUG_VIRTUAL
30257 -unsigned long __phys_addr(unsigned long x)
30258 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
30259 {
30260 /* VMALLOC_* aren't constants */
30261 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
30262 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
30263 index 410531d..0f16030 100644
30264 --- a/arch/x86/mm/setup_nx.c
30265 +++ b/arch/x86/mm/setup_nx.c
30266 @@ -5,8 +5,10 @@
30267 #include <asm/pgtable.h>
30268 #include <asm/proto.h>
30269
30270 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
30271 static int disable_nx __cpuinitdata;
30272
30273 +#ifndef CONFIG_PAX_PAGEEXEC
30274 /*
30275 * noexec = on|off
30276 *
30277 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
30278 return 0;
30279 }
30280 early_param("noexec", noexec_setup);
30281 +#endif
30282 +
30283 +#endif
30284
30285 void __cpuinit x86_configure_nx(void)
30286 {
30287 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
30288 if (cpu_has_nx && !disable_nx)
30289 __supported_pte_mask |= _PAGE_NX;
30290 else
30291 +#endif
30292 __supported_pte_mask &= ~_PAGE_NX;
30293 }
30294
30295 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
30296 index 13a6b29..c2fff23 100644
30297 --- a/arch/x86/mm/tlb.c
30298 +++ b/arch/x86/mm/tlb.c
30299 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
30300 BUG();
30301 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
30302 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
30303 +
30304 +#ifndef CONFIG_PAX_PER_CPU_PGD
30305 load_cr3(swapper_pg_dir);
30306 +#endif
30307 +
30308 }
30309 }
30310 EXPORT_SYMBOL_GPL(leave_mm);
30311 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
30312 index 877b9a1..a8ecf42 100644
30313 --- a/arch/x86/net/bpf_jit.S
30314 +++ b/arch/x86/net/bpf_jit.S
30315 @@ -9,6 +9,7 @@
30316 */
30317 #include <linux/linkage.h>
30318 #include <asm/dwarf2.h>
30319 +#include <asm/alternative-asm.h>
30320
30321 /*
30322 * Calling convention :
30323 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
30324 jle bpf_slow_path_word
30325 mov (SKBDATA,%rsi),%eax
30326 bswap %eax /* ntohl() */
30327 + pax_force_retaddr
30328 ret
30329
30330 sk_load_half:
30331 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
30332 jle bpf_slow_path_half
30333 movzwl (SKBDATA,%rsi),%eax
30334 rol $8,%ax # ntohs()
30335 + pax_force_retaddr
30336 ret
30337
30338 sk_load_byte:
30339 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
30340 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
30341 jle bpf_slow_path_byte
30342 movzbl (SKBDATA,%rsi),%eax
30343 + pax_force_retaddr
30344 ret
30345
30346 /**
30347 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
30348 movzbl (SKBDATA,%rsi),%ebx
30349 and $15,%bl
30350 shl $2,%bl
30351 + pax_force_retaddr
30352 ret
30353
30354 /* rsi contains offset and can be scratched */
30355 @@ -109,6 +114,7 @@ bpf_slow_path_word:
30356 js bpf_error
30357 mov -12(%rbp),%eax
30358 bswap %eax
30359 + pax_force_retaddr
30360 ret
30361
30362 bpf_slow_path_half:
30363 @@ -117,12 +123,14 @@ bpf_slow_path_half:
30364 mov -12(%rbp),%ax
30365 rol $8,%ax
30366 movzwl %ax,%eax
30367 + pax_force_retaddr
30368 ret
30369
30370 bpf_slow_path_byte:
30371 bpf_slow_path_common(1)
30372 js bpf_error
30373 movzbl -12(%rbp),%eax
30374 + pax_force_retaddr
30375 ret
30376
30377 bpf_slow_path_byte_msh:
30378 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
30379 and $15,%al
30380 shl $2,%al
30381 xchg %eax,%ebx
30382 + pax_force_retaddr
30383 ret
30384
30385 #define sk_negative_common(SIZE) \
30386 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
30387 sk_negative_common(4)
30388 mov (%rax), %eax
30389 bswap %eax
30390 + pax_force_retaddr
30391 ret
30392
30393 bpf_slow_path_half_neg:
30394 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
30395 mov (%rax),%ax
30396 rol $8,%ax
30397 movzwl %ax,%eax
30398 + pax_force_retaddr
30399 ret
30400
30401 bpf_slow_path_byte_neg:
30402 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
30403 .globl sk_load_byte_negative_offset
30404 sk_negative_common(1)
30405 movzbl (%rax), %eax
30406 + pax_force_retaddr
30407 ret
30408
30409 bpf_slow_path_byte_msh_neg:
30410 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
30411 and $15,%al
30412 shl $2,%al
30413 xchg %eax,%ebx
30414 + pax_force_retaddr
30415 ret
30416
30417 bpf_error:
30418 @@ -197,4 +210,5 @@ bpf_error:
30419 xor %eax,%eax
30420 mov -8(%rbp),%rbx
30421 leaveq
30422 + pax_force_retaddr
30423 ret
30424 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
30425 index d11a470..3f9adff3 100644
30426 --- a/arch/x86/net/bpf_jit_comp.c
30427 +++ b/arch/x86/net/bpf_jit_comp.c
30428 @@ -12,6 +12,7 @@
30429 #include <linux/netdevice.h>
30430 #include <linux/filter.h>
30431 #include <linux/if_vlan.h>
30432 +#include <linux/random.h>
30433
30434 /*
30435 * Conventions :
30436 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
30437 return ptr + len;
30438 }
30439
30440 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30441 +#define MAX_INSTR_CODE_SIZE 96
30442 +#else
30443 +#define MAX_INSTR_CODE_SIZE 64
30444 +#endif
30445 +
30446 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
30447
30448 #define EMIT1(b1) EMIT(b1, 1)
30449 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
30450 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
30451 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
30452 +
30453 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30454 +/* original constant will appear in ecx */
30455 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
30456 +do { \
30457 + /* mov ecx, randkey */ \
30458 + EMIT1(0xb9); \
30459 + EMIT(_key, 4); \
30460 + /* xor ecx, randkey ^ off */ \
30461 + EMIT2(0x81, 0xf1); \
30462 + EMIT((_key) ^ (_off), 4); \
30463 +} while (0)
30464 +
30465 +#define EMIT1_off32(b1, _off) \
30466 +do { \
30467 + switch (b1) { \
30468 + case 0x05: /* add eax, imm32 */ \
30469 + case 0x2d: /* sub eax, imm32 */ \
30470 + case 0x25: /* and eax, imm32 */ \
30471 + case 0x0d: /* or eax, imm32 */ \
30472 + case 0xb8: /* mov eax, imm32 */ \
30473 + case 0x3d: /* cmp eax, imm32 */ \
30474 + case 0xa9: /* test eax, imm32 */ \
30475 + DILUTE_CONST_SEQUENCE(_off, randkey); \
30476 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
30477 + break; \
30478 + case 0xbb: /* mov ebx, imm32 */ \
30479 + DILUTE_CONST_SEQUENCE(_off, randkey); \
30480 + /* mov ebx, ecx */ \
30481 + EMIT2(0x89, 0xcb); \
30482 + break; \
30483 + case 0xbe: /* mov esi, imm32 */ \
30484 + DILUTE_CONST_SEQUENCE(_off, randkey); \
30485 + /* mov esi, ecx */ \
30486 + EMIT2(0x89, 0xce); \
30487 + break; \
30488 + case 0xe9: /* jmp rel imm32 */ \
30489 + EMIT1(b1); \
30490 + EMIT(_off, 4); \
30491 + /* prevent fall-through, we're not called if off = 0 */ \
30492 + EMIT(0xcccccccc, 4); \
30493 + EMIT(0xcccccccc, 4); \
30494 + break; \
30495 + default: \
30496 + EMIT1(b1); \
30497 + EMIT(_off, 4); \
30498 + } \
30499 +} while (0)
30500 +
30501 +#define EMIT2_off32(b1, b2, _off) \
30502 +do { \
30503 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
30504 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
30505 + EMIT(randkey, 4); \
30506 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
30507 + EMIT((_off) - randkey, 4); \
30508 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
30509 + DILUTE_CONST_SEQUENCE(_off, randkey); \
30510 + /* imul eax, ecx */ \
30511 + EMIT3(0x0f, 0xaf, 0xc1); \
30512 + } else { \
30513 + EMIT2(b1, b2); \
30514 + EMIT(_off, 4); \
30515 + } \
30516 +} while (0)
30517 +#else
30518 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
30519 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
30520 +#endif
30521
30522 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
30523 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
30524 @@ -90,6 +165,24 @@ do { \
30525 #define X86_JBE 0x76
30526 #define X86_JA 0x77
30527
30528 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30529 +#define APPEND_FLOW_VERIFY() \
30530 +do { \
30531 + /* mov ecx, randkey */ \
30532 + EMIT1(0xb9); \
30533 + EMIT(randkey, 4); \
30534 + /* cmp ecx, randkey */ \
30535 + EMIT2(0x81, 0xf9); \
30536 + EMIT(randkey, 4); \
30537 + /* jz after 8 int 3s */ \
30538 + EMIT2(0x74, 0x08); \
30539 + EMIT(0xcccccccc, 4); \
30540 + EMIT(0xcccccccc, 4); \
30541 +} while (0)
30542 +#else
30543 +#define APPEND_FLOW_VERIFY() do { } while (0)
30544 +#endif
30545 +
30546 #define EMIT_COND_JMP(op, offset) \
30547 do { \
30548 if (is_near(offset)) \
30549 @@ -97,6 +190,7 @@ do { \
30550 else { \
30551 EMIT2(0x0f, op + 0x10); \
30552 EMIT(offset, 4); /* jxx .+off32 */ \
30553 + APPEND_FLOW_VERIFY(); \
30554 } \
30555 } while (0)
30556
30557 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
30558 set_fs(old_fs);
30559 }
30560
30561 +struct bpf_jit_work {
30562 + struct work_struct work;
30563 + void *image;
30564 +};
30565 +
30566 #define CHOOSE_LOAD_FUNC(K, func) \
30567 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
30568
30569 void bpf_jit_compile(struct sk_filter *fp)
30570 {
30571 - u8 temp[64];
30572 + u8 temp[MAX_INSTR_CODE_SIZE];
30573 u8 *prog;
30574 unsigned int proglen, oldproglen = 0;
30575 int ilen, i;
30576 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
30577 unsigned int *addrs;
30578 const struct sock_filter *filter = fp->insns;
30579 int flen = fp->len;
30580 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30581 + unsigned int randkey;
30582 +#endif
30583
30584 if (!bpf_jit_enable)
30585 return;
30586 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
30587 if (addrs == NULL)
30588 return;
30589
30590 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
30591 + if (!fp->work)
30592 + goto out;
30593 +
30594 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30595 + randkey = get_random_int();
30596 +#endif
30597 +
30598 /* Before first pass, make a rough estimation of addrs[]
30599 - * each bpf instruction is translated to less than 64 bytes
30600 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
30601 */
30602 for (proglen = 0, i = 0; i < flen; i++) {
30603 - proglen += 64;
30604 + proglen += MAX_INSTR_CODE_SIZE;
30605 addrs[i] = proglen;
30606 }
30607 cleanup_addr = proglen; /* epilogue address */
30608 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
30609 case BPF_S_ALU_MUL_K: /* A *= K */
30610 if (is_imm8(K))
30611 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
30612 - else {
30613 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
30614 - EMIT(K, 4);
30615 - }
30616 + else
30617 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
30618 break;
30619 case BPF_S_ALU_DIV_X: /* A /= X; */
30620 seen |= SEEN_XREG;
30621 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
30622 break;
30623 case BPF_S_ALU_MOD_K: /* A %= K; */
30624 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
30625 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30626 + DILUTE_CONST_SEQUENCE(K, randkey);
30627 +#else
30628 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
30629 +#endif
30630 EMIT2(0xf7, 0xf1); /* div %ecx */
30631 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
30632 break;
30633 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
30634 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30635 + DILUTE_CONST_SEQUENCE(K, randkey);
30636 + // imul rax, rcx
30637 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
30638 +#else
30639 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
30640 EMIT(K, 4);
30641 +#endif
30642 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
30643 break;
30644 case BPF_S_ALU_AND_X:
30645 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
30646 if (is_imm8(K)) {
30647 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
30648 } else {
30649 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
30650 - EMIT(K, 4);
30651 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
30652 }
30653 } else {
30654 EMIT2(0x89,0xde); /* mov %ebx,%esi */
30655 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30656 break;
30657 default:
30658 /* hmm, too complex filter, give up with jit compiler */
30659 - goto out;
30660 + goto error;
30661 }
30662 ilen = prog - temp;
30663 if (image) {
30664 if (unlikely(proglen + ilen > oldproglen)) {
30665 pr_err("bpb_jit_compile fatal error\n");
30666 - kfree(addrs);
30667 - module_free(NULL, image);
30668 - return;
30669 + module_free_exec(NULL, image);
30670 + goto error;
30671 }
30672 + pax_open_kernel();
30673 memcpy(image + proglen, temp, ilen);
30674 + pax_close_kernel();
30675 }
30676 proglen += ilen;
30677 addrs[i] = proglen;
30678 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30679 break;
30680 }
30681 if (proglen == oldproglen) {
30682 - image = module_alloc(max_t(unsigned int,
30683 - proglen,
30684 - sizeof(struct work_struct)));
30685 + image = module_alloc_exec(proglen);
30686 if (!image)
30687 - goto out;
30688 + goto error;
30689 }
30690 oldproglen = proglen;
30691 }
30692 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30693 bpf_flush_icache(image, image + proglen);
30694
30695 fp->bpf_func = (void *)image;
30696 - }
30697 + } else
30698 +error:
30699 + kfree(fp->work);
30700 +
30701 out:
30702 kfree(addrs);
30703 return;
30704 @@ -707,18 +826,20 @@ out:
30705
30706 static void jit_free_defer(struct work_struct *arg)
30707 {
30708 - module_free(NULL, arg);
30709 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
30710 + kfree(arg);
30711 }
30712
30713 /* run from softirq, we must use a work_struct to call
30714 - * module_free() from process context
30715 + * module_free_exec() from process context
30716 */
30717 void bpf_jit_free(struct sk_filter *fp)
30718 {
30719 if (fp->bpf_func != sk_run_filter) {
30720 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
30721 + struct work_struct *work = &fp->work->work;
30722
30723 INIT_WORK(work, jit_free_defer);
30724 + fp->work->image = fp->bpf_func;
30725 schedule_work(work);
30726 }
30727 }
30728 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
30729 index d6aa6e8..266395a 100644
30730 --- a/arch/x86/oprofile/backtrace.c
30731 +++ b/arch/x86/oprofile/backtrace.c
30732 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
30733 struct stack_frame_ia32 *fp;
30734 unsigned long bytes;
30735
30736 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30737 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30738 if (bytes != sizeof(bufhead))
30739 return NULL;
30740
30741 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
30742 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
30743
30744 oprofile_add_trace(bufhead[0].return_address);
30745
30746 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
30747 struct stack_frame bufhead[2];
30748 unsigned long bytes;
30749
30750 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30751 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30752 if (bytes != sizeof(bufhead))
30753 return NULL;
30754
30755 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
30756 {
30757 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
30758
30759 - if (!user_mode_vm(regs)) {
30760 + if (!user_mode(regs)) {
30761 unsigned long stack = kernel_stack_pointer(regs);
30762 if (depth)
30763 dump_trace(NULL, regs, (unsigned long *)stack, 0,
30764 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
30765 index 48768df..ba9143c 100644
30766 --- a/arch/x86/oprofile/nmi_int.c
30767 +++ b/arch/x86/oprofile/nmi_int.c
30768 @@ -23,6 +23,7 @@
30769 #include <asm/nmi.h>
30770 #include <asm/msr.h>
30771 #include <asm/apic.h>
30772 +#include <asm/pgtable.h>
30773
30774 #include "op_counter.h"
30775 #include "op_x86_model.h"
30776 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30777 if (ret)
30778 return ret;
30779
30780 - if (!model->num_virt_counters)
30781 - model->num_virt_counters = model->num_counters;
30782 + if (!model->num_virt_counters) {
30783 + pax_open_kernel();
30784 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30785 + pax_close_kernel();
30786 + }
30787
30788 mux_init(ops);
30789
30790 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30791 index b2b9443..be58856 100644
30792 --- a/arch/x86/oprofile/op_model_amd.c
30793 +++ b/arch/x86/oprofile/op_model_amd.c
30794 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30795 num_counters = AMD64_NUM_COUNTERS;
30796 }
30797
30798 - op_amd_spec.num_counters = num_counters;
30799 - op_amd_spec.num_controls = num_counters;
30800 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30801 + pax_open_kernel();
30802 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30803 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30804 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30805 + pax_close_kernel();
30806
30807 return 0;
30808 }
30809 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30810 index d90528e..0127e2b 100644
30811 --- a/arch/x86/oprofile/op_model_ppro.c
30812 +++ b/arch/x86/oprofile/op_model_ppro.c
30813 @@ -19,6 +19,7 @@
30814 #include <asm/msr.h>
30815 #include <asm/apic.h>
30816 #include <asm/nmi.h>
30817 +#include <asm/pgtable.h>
30818
30819 #include "op_x86_model.h"
30820 #include "op_counter.h"
30821 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30822
30823 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30824
30825 - op_arch_perfmon_spec.num_counters = num_counters;
30826 - op_arch_perfmon_spec.num_controls = num_counters;
30827 + pax_open_kernel();
30828 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30829 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30830 + pax_close_kernel();
30831 }
30832
30833 static int arch_perfmon_init(struct oprofile_operations *ignore)
30834 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30835 index 71e8a67..6a313bb 100644
30836 --- a/arch/x86/oprofile/op_x86_model.h
30837 +++ b/arch/x86/oprofile/op_x86_model.h
30838 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30839 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30840 struct op_msrs const * const msrs);
30841 #endif
30842 -};
30843 +} __do_const;
30844
30845 struct op_counter_config;
30846
30847 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30848 index e9e6ed5..e47ae67 100644
30849 --- a/arch/x86/pci/amd_bus.c
30850 +++ b/arch/x86/pci/amd_bus.c
30851 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30852 return NOTIFY_OK;
30853 }
30854
30855 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30856 +static struct notifier_block amd_cpu_notifier = {
30857 .notifier_call = amd_cpu_notify,
30858 };
30859
30860 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30861 index 372e9b8..e775a6c 100644
30862 --- a/arch/x86/pci/irq.c
30863 +++ b/arch/x86/pci/irq.c
30864 @@ -50,7 +50,7 @@ struct irq_router {
30865 struct irq_router_handler {
30866 u16 vendor;
30867 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30868 -};
30869 +} __do_const;
30870
30871 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30872 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30873 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30874 return 0;
30875 }
30876
30877 -static __initdata struct irq_router_handler pirq_routers[] = {
30878 +static __initconst const struct irq_router_handler pirq_routers[] = {
30879 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30880 { PCI_VENDOR_ID_AL, ali_router_probe },
30881 { PCI_VENDOR_ID_ITE, ite_router_probe },
30882 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30883 static void __init pirq_find_router(struct irq_router *r)
30884 {
30885 struct irq_routing_table *rt = pirq_table;
30886 - struct irq_router_handler *h;
30887 + const struct irq_router_handler *h;
30888
30889 #ifdef CONFIG_PCI_BIOS
30890 if (!rt->signature) {
30891 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30892 return 0;
30893 }
30894
30895 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30896 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30897 {
30898 .callback = fix_broken_hp_bios_irq9,
30899 .ident = "HP Pavilion N5400 Series Laptop",
30900 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30901 index 6eb18c4..20d83de 100644
30902 --- a/arch/x86/pci/mrst.c
30903 +++ b/arch/x86/pci/mrst.c
30904 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30905 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30906 pci_mmcfg_late_init();
30907 pcibios_enable_irq = mrst_pci_irq_enable;
30908 - pci_root_ops = pci_mrst_ops;
30909 + pax_open_kernel();
30910 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30911 + pax_close_kernel();
30912 pci_soc_mode = 1;
30913 /* Continue with standard init */
30914 return 1;
30915 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30916 index c77b24a..c979855 100644
30917 --- a/arch/x86/pci/pcbios.c
30918 +++ b/arch/x86/pci/pcbios.c
30919 @@ -79,7 +79,7 @@ union bios32 {
30920 static struct {
30921 unsigned long address;
30922 unsigned short segment;
30923 -} bios32_indirect = { 0, __KERNEL_CS };
30924 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30925
30926 /*
30927 * Returns the entry point for the given service, NULL on error
30928 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30929 unsigned long length; /* %ecx */
30930 unsigned long entry; /* %edx */
30931 unsigned long flags;
30932 + struct desc_struct d, *gdt;
30933
30934 local_irq_save(flags);
30935 - __asm__("lcall *(%%edi); cld"
30936 +
30937 + gdt = get_cpu_gdt_table(smp_processor_id());
30938 +
30939 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30940 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30941 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30942 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30943 +
30944 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30945 : "=a" (return_code),
30946 "=b" (address),
30947 "=c" (length),
30948 "=d" (entry)
30949 : "0" (service),
30950 "1" (0),
30951 - "D" (&bios32_indirect));
30952 + "D" (&bios32_indirect),
30953 + "r"(__PCIBIOS_DS)
30954 + : "memory");
30955 +
30956 + pax_open_kernel();
30957 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30958 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30959 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30960 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30961 + pax_close_kernel();
30962 +
30963 local_irq_restore(flags);
30964
30965 switch (return_code) {
30966 - case 0:
30967 - return address + entry;
30968 - case 0x80: /* Not present */
30969 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30970 - return 0;
30971 - default: /* Shouldn't happen */
30972 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30973 - service, return_code);
30974 + case 0: {
30975 + int cpu;
30976 + unsigned char flags;
30977 +
30978 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30979 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30980 + printk(KERN_WARNING "bios32_service: not valid\n");
30981 return 0;
30982 + }
30983 + address = address + PAGE_OFFSET;
30984 + length += 16UL; /* some BIOSs underreport this... */
30985 + flags = 4;
30986 + if (length >= 64*1024*1024) {
30987 + length >>= PAGE_SHIFT;
30988 + flags |= 8;
30989 + }
30990 +
30991 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30992 + gdt = get_cpu_gdt_table(cpu);
30993 + pack_descriptor(&d, address, length, 0x9b, flags);
30994 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30995 + pack_descriptor(&d, address, length, 0x93, flags);
30996 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30997 + }
30998 + return entry;
30999 + }
31000 + case 0x80: /* Not present */
31001 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
31002 + return 0;
31003 + default: /* Shouldn't happen */
31004 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
31005 + service, return_code);
31006 + return 0;
31007 }
31008 }
31009
31010 static struct {
31011 unsigned long address;
31012 unsigned short segment;
31013 -} pci_indirect = { 0, __KERNEL_CS };
31014 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
31015
31016 -static int pci_bios_present;
31017 +static int pci_bios_present __read_only;
31018
31019 static int check_pcibios(void)
31020 {
31021 @@ -131,11 +174,13 @@ static int check_pcibios(void)
31022 unsigned long flags, pcibios_entry;
31023
31024 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
31025 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
31026 + pci_indirect.address = pcibios_entry;
31027
31028 local_irq_save(flags);
31029 - __asm__(
31030 - "lcall *(%%edi); cld\n\t"
31031 + __asm__("movw %w6, %%ds\n\t"
31032 + "lcall *%%ss:(%%edi); cld\n\t"
31033 + "push %%ss\n\t"
31034 + "pop %%ds\n\t"
31035 "jc 1f\n\t"
31036 "xor %%ah, %%ah\n"
31037 "1:"
31038 @@ -144,7 +189,8 @@ static int check_pcibios(void)
31039 "=b" (ebx),
31040 "=c" (ecx)
31041 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
31042 - "D" (&pci_indirect)
31043 + "D" (&pci_indirect),
31044 + "r" (__PCIBIOS_DS)
31045 : "memory");
31046 local_irq_restore(flags);
31047
31048 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
31049
31050 switch (len) {
31051 case 1:
31052 - __asm__("lcall *(%%esi); cld\n\t"
31053 + __asm__("movw %w6, %%ds\n\t"
31054 + "lcall *%%ss:(%%esi); cld\n\t"
31055 + "push %%ss\n\t"
31056 + "pop %%ds\n\t"
31057 "jc 1f\n\t"
31058 "xor %%ah, %%ah\n"
31059 "1:"
31060 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
31061 : "1" (PCIBIOS_READ_CONFIG_BYTE),
31062 "b" (bx),
31063 "D" ((long)reg),
31064 - "S" (&pci_indirect));
31065 + "S" (&pci_indirect),
31066 + "r" (__PCIBIOS_DS));
31067 /*
31068 * Zero-extend the result beyond 8 bits, do not trust the
31069 * BIOS having done it:
31070 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
31071 *value &= 0xff;
31072 break;
31073 case 2:
31074 - __asm__("lcall *(%%esi); cld\n\t"
31075 + __asm__("movw %w6, %%ds\n\t"
31076 + "lcall *%%ss:(%%esi); cld\n\t"
31077 + "push %%ss\n\t"
31078 + "pop %%ds\n\t"
31079 "jc 1f\n\t"
31080 "xor %%ah, %%ah\n"
31081 "1:"
31082 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
31083 : "1" (PCIBIOS_READ_CONFIG_WORD),
31084 "b" (bx),
31085 "D" ((long)reg),
31086 - "S" (&pci_indirect));
31087 + "S" (&pci_indirect),
31088 + "r" (__PCIBIOS_DS));
31089 /*
31090 * Zero-extend the result beyond 16 bits, do not trust the
31091 * BIOS having done it:
31092 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
31093 *value &= 0xffff;
31094 break;
31095 case 4:
31096 - __asm__("lcall *(%%esi); cld\n\t"
31097 + __asm__("movw %w6, %%ds\n\t"
31098 + "lcall *%%ss:(%%esi); cld\n\t"
31099 + "push %%ss\n\t"
31100 + "pop %%ds\n\t"
31101 "jc 1f\n\t"
31102 "xor %%ah, %%ah\n"
31103 "1:"
31104 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
31105 : "1" (PCIBIOS_READ_CONFIG_DWORD),
31106 "b" (bx),
31107 "D" ((long)reg),
31108 - "S" (&pci_indirect));
31109 + "S" (&pci_indirect),
31110 + "r" (__PCIBIOS_DS));
31111 break;
31112 }
31113
31114 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
31115
31116 switch (len) {
31117 case 1:
31118 - __asm__("lcall *(%%esi); cld\n\t"
31119 + __asm__("movw %w6, %%ds\n\t"
31120 + "lcall *%%ss:(%%esi); cld\n\t"
31121 + "push %%ss\n\t"
31122 + "pop %%ds\n\t"
31123 "jc 1f\n\t"
31124 "xor %%ah, %%ah\n"
31125 "1:"
31126 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
31127 "c" (value),
31128 "b" (bx),
31129 "D" ((long)reg),
31130 - "S" (&pci_indirect));
31131 + "S" (&pci_indirect),
31132 + "r" (__PCIBIOS_DS));
31133 break;
31134 case 2:
31135 - __asm__("lcall *(%%esi); cld\n\t"
31136 + __asm__("movw %w6, %%ds\n\t"
31137 + "lcall *%%ss:(%%esi); cld\n\t"
31138 + "push %%ss\n\t"
31139 + "pop %%ds\n\t"
31140 "jc 1f\n\t"
31141 "xor %%ah, %%ah\n"
31142 "1:"
31143 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
31144 "c" (value),
31145 "b" (bx),
31146 "D" ((long)reg),
31147 - "S" (&pci_indirect));
31148 + "S" (&pci_indirect),
31149 + "r" (__PCIBIOS_DS));
31150 break;
31151 case 4:
31152 - __asm__("lcall *(%%esi); cld\n\t"
31153 + __asm__("movw %w6, %%ds\n\t"
31154 + "lcall *%%ss:(%%esi); cld\n\t"
31155 + "push %%ss\n\t"
31156 + "pop %%ds\n\t"
31157 "jc 1f\n\t"
31158 "xor %%ah, %%ah\n"
31159 "1:"
31160 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
31161 "c" (value),
31162 "b" (bx),
31163 "D" ((long)reg),
31164 - "S" (&pci_indirect));
31165 + "S" (&pci_indirect),
31166 + "r" (__PCIBIOS_DS));
31167 break;
31168 }
31169
31170 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
31171
31172 DBG("PCI: Fetching IRQ routing table... ");
31173 __asm__("push %%es\n\t"
31174 + "movw %w8, %%ds\n\t"
31175 "push %%ds\n\t"
31176 "pop %%es\n\t"
31177 - "lcall *(%%esi); cld\n\t"
31178 + "lcall *%%ss:(%%esi); cld\n\t"
31179 "pop %%es\n\t"
31180 + "push %%ss\n\t"
31181 + "pop %%ds\n"
31182 "jc 1f\n\t"
31183 "xor %%ah, %%ah\n"
31184 "1:"
31185 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
31186 "1" (0),
31187 "D" ((long) &opt),
31188 "S" (&pci_indirect),
31189 - "m" (opt)
31190 + "m" (opt),
31191 + "r" (__PCIBIOS_DS)
31192 : "memory");
31193 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
31194 if (ret & 0xff00)
31195 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
31196 {
31197 int ret;
31198
31199 - __asm__("lcall *(%%esi); cld\n\t"
31200 + __asm__("movw %w5, %%ds\n\t"
31201 + "lcall *%%ss:(%%esi); cld\n\t"
31202 + "push %%ss\n\t"
31203 + "pop %%ds\n"
31204 "jc 1f\n\t"
31205 "xor %%ah, %%ah\n"
31206 "1:"
31207 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
31208 : "0" (PCIBIOS_SET_PCI_HW_INT),
31209 "b" ((dev->bus->number << 8) | dev->devfn),
31210 "c" ((irq << 8) | (pin + 10)),
31211 - "S" (&pci_indirect));
31212 + "S" (&pci_indirect),
31213 + "r" (__PCIBIOS_DS));
31214 return !(ret & 0xff00);
31215 }
31216 EXPORT_SYMBOL(pcibios_set_irq_routing);
31217 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
31218 index 40e4469..1ab536e 100644
31219 --- a/arch/x86/platform/efi/efi_32.c
31220 +++ b/arch/x86/platform/efi/efi_32.c
31221 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
31222 {
31223 struct desc_ptr gdt_descr;
31224
31225 +#ifdef CONFIG_PAX_KERNEXEC
31226 + struct desc_struct d;
31227 +#endif
31228 +
31229 local_irq_save(efi_rt_eflags);
31230
31231 load_cr3(initial_page_table);
31232 __flush_tlb_all();
31233
31234 +#ifdef CONFIG_PAX_KERNEXEC
31235 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
31236 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
31237 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
31238 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
31239 +#endif
31240 +
31241 gdt_descr.address = __pa(get_cpu_gdt_table(0));
31242 gdt_descr.size = GDT_SIZE - 1;
31243 load_gdt(&gdt_descr);
31244 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
31245 {
31246 struct desc_ptr gdt_descr;
31247
31248 +#ifdef CONFIG_PAX_KERNEXEC
31249 + struct desc_struct d;
31250 +
31251 + memset(&d, 0, sizeof d);
31252 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
31253 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
31254 +#endif
31255 +
31256 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
31257 gdt_descr.size = GDT_SIZE - 1;
31258 load_gdt(&gdt_descr);
31259 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
31260 index fbe66e6..eae5e38 100644
31261 --- a/arch/x86/platform/efi/efi_stub_32.S
31262 +++ b/arch/x86/platform/efi/efi_stub_32.S
31263 @@ -6,7 +6,9 @@
31264 */
31265
31266 #include <linux/linkage.h>
31267 +#include <linux/init.h>
31268 #include <asm/page_types.h>
31269 +#include <asm/segment.h>
31270
31271 /*
31272 * efi_call_phys(void *, ...) is a function with variable parameters.
31273 @@ -20,7 +22,7 @@
31274 * service functions will comply with gcc calling convention, too.
31275 */
31276
31277 -.text
31278 +__INIT
31279 ENTRY(efi_call_phys)
31280 /*
31281 * 0. The function can only be called in Linux kernel. So CS has been
31282 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
31283 * The mapping of lower virtual memory has been created in prelog and
31284 * epilog.
31285 */
31286 - movl $1f, %edx
31287 - subl $__PAGE_OFFSET, %edx
31288 - jmp *%edx
31289 +#ifdef CONFIG_PAX_KERNEXEC
31290 + movl $(__KERNEXEC_EFI_DS), %edx
31291 + mov %edx, %ds
31292 + mov %edx, %es
31293 + mov %edx, %ss
31294 + addl $2f,(1f)
31295 + ljmp *(1f)
31296 +
31297 +__INITDATA
31298 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
31299 +.previous
31300 +
31301 +2:
31302 + subl $2b,(1b)
31303 +#else
31304 + jmp 1f-__PAGE_OFFSET
31305 1:
31306 +#endif
31307
31308 /*
31309 * 2. Now on the top of stack is the return
31310 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
31311 * parameter 2, ..., param n. To make things easy, we save the return
31312 * address of efi_call_phys in a global variable.
31313 */
31314 - popl %edx
31315 - movl %edx, saved_return_addr
31316 - /* get the function pointer into ECX*/
31317 - popl %ecx
31318 - movl %ecx, efi_rt_function_ptr
31319 - movl $2f, %edx
31320 - subl $__PAGE_OFFSET, %edx
31321 - pushl %edx
31322 + popl (saved_return_addr)
31323 + popl (efi_rt_function_ptr)
31324
31325 /*
31326 * 3. Clear PG bit in %CR0.
31327 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
31328 /*
31329 * 5. Call the physical function.
31330 */
31331 - jmp *%ecx
31332 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
31333
31334 -2:
31335 /*
31336 * 6. After EFI runtime service returns, control will return to
31337 * following instruction. We'd better readjust stack pointer first.
31338 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
31339 movl %cr0, %edx
31340 orl $0x80000000, %edx
31341 movl %edx, %cr0
31342 - jmp 1f
31343 -1:
31344 +
31345 /*
31346 * 8. Now restore the virtual mode from flat mode by
31347 * adding EIP with PAGE_OFFSET.
31348 */
31349 - movl $1f, %edx
31350 - jmp *%edx
31351 +#ifdef CONFIG_PAX_KERNEXEC
31352 + movl $(__KERNEL_DS), %edx
31353 + mov %edx, %ds
31354 + mov %edx, %es
31355 + mov %edx, %ss
31356 + ljmp $(__KERNEL_CS),$1f
31357 +#else
31358 + jmp 1f+__PAGE_OFFSET
31359 +#endif
31360 1:
31361
31362 /*
31363 * 9. Balance the stack. And because EAX contain the return value,
31364 * we'd better not clobber it.
31365 */
31366 - leal efi_rt_function_ptr, %edx
31367 - movl (%edx), %ecx
31368 - pushl %ecx
31369 + pushl (efi_rt_function_ptr)
31370
31371 /*
31372 - * 10. Push the saved return address onto the stack and return.
31373 + * 10. Return to the saved return address.
31374 */
31375 - leal saved_return_addr, %edx
31376 - movl (%edx), %ecx
31377 - pushl %ecx
31378 - ret
31379 + jmpl *(saved_return_addr)
31380 ENDPROC(efi_call_phys)
31381 .previous
31382
31383 -.data
31384 +__INITDATA
31385 saved_return_addr:
31386 .long 0
31387 efi_rt_function_ptr:
31388 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
31389 index 4c07cca..2c8427d 100644
31390 --- a/arch/x86/platform/efi/efi_stub_64.S
31391 +++ b/arch/x86/platform/efi/efi_stub_64.S
31392 @@ -7,6 +7,7 @@
31393 */
31394
31395 #include <linux/linkage.h>
31396 +#include <asm/alternative-asm.h>
31397
31398 #define SAVE_XMM \
31399 mov %rsp, %rax; \
31400 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
31401 call *%rdi
31402 addq $32, %rsp
31403 RESTORE_XMM
31404 + pax_force_retaddr 0, 1
31405 ret
31406 ENDPROC(efi_call0)
31407
31408 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
31409 call *%rdi
31410 addq $32, %rsp
31411 RESTORE_XMM
31412 + pax_force_retaddr 0, 1
31413 ret
31414 ENDPROC(efi_call1)
31415
31416 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
31417 call *%rdi
31418 addq $32, %rsp
31419 RESTORE_XMM
31420 + pax_force_retaddr 0, 1
31421 ret
31422 ENDPROC(efi_call2)
31423
31424 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
31425 call *%rdi
31426 addq $32, %rsp
31427 RESTORE_XMM
31428 + pax_force_retaddr 0, 1
31429 ret
31430 ENDPROC(efi_call3)
31431
31432 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
31433 call *%rdi
31434 addq $32, %rsp
31435 RESTORE_XMM
31436 + pax_force_retaddr 0, 1
31437 ret
31438 ENDPROC(efi_call4)
31439
31440 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
31441 call *%rdi
31442 addq $48, %rsp
31443 RESTORE_XMM
31444 + pax_force_retaddr 0, 1
31445 ret
31446 ENDPROC(efi_call5)
31447
31448 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
31449 call *%rdi
31450 addq $48, %rsp
31451 RESTORE_XMM
31452 + pax_force_retaddr 0, 1
31453 ret
31454 ENDPROC(efi_call6)
31455 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
31456 index e31bcd8..f12dc46 100644
31457 --- a/arch/x86/platform/mrst/mrst.c
31458 +++ b/arch/x86/platform/mrst/mrst.c
31459 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
31460 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
31461 int sfi_mrtc_num;
31462
31463 -static void mrst_power_off(void)
31464 +static __noreturn void mrst_power_off(void)
31465 {
31466 + BUG();
31467 }
31468
31469 -static void mrst_reboot(void)
31470 +static __noreturn void mrst_reboot(void)
31471 {
31472 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
31473 + BUG();
31474 }
31475
31476 /* parse all the mtimer info to a static mtimer array */
31477 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
31478 index d6ee929..3637cb5 100644
31479 --- a/arch/x86/platform/olpc/olpc_dt.c
31480 +++ b/arch/x86/platform/olpc/olpc_dt.c
31481 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
31482 return res;
31483 }
31484
31485 -static struct of_pdt_ops prom_olpc_ops __initdata = {
31486 +static struct of_pdt_ops prom_olpc_ops __initconst = {
31487 .nextprop = olpc_dt_nextprop,
31488 .getproplen = olpc_dt_getproplen,
31489 .getproperty = olpc_dt_getproperty,
31490 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
31491 index 3c68768..07e82b8 100644
31492 --- a/arch/x86/power/cpu.c
31493 +++ b/arch/x86/power/cpu.c
31494 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
31495 static void fix_processor_context(void)
31496 {
31497 int cpu = smp_processor_id();
31498 - struct tss_struct *t = &per_cpu(init_tss, cpu);
31499 + struct tss_struct *t = init_tss + cpu;
31500
31501 set_tss_desc(cpu, t); /*
31502 * This just modifies memory; should not be
31503 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
31504 */
31505
31506 #ifdef CONFIG_X86_64
31507 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
31508 -
31509 syscall_init(); /* This sets MSR_*STAR and related */
31510 #endif
31511 load_TR_desc(); /* This does ltr */
31512 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
31513 index cbca565..bae7133 100644
31514 --- a/arch/x86/realmode/init.c
31515 +++ b/arch/x86/realmode/init.c
31516 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
31517 __va(real_mode_header->trampoline_header);
31518
31519 #ifdef CONFIG_X86_32
31520 - trampoline_header->start = __pa(startup_32_smp);
31521 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
31522 +
31523 +#ifdef CONFIG_PAX_KERNEXEC
31524 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
31525 +#endif
31526 +
31527 + trampoline_header->boot_cs = __BOOT_CS;
31528 trampoline_header->gdt_limit = __BOOT_DS + 7;
31529 trampoline_header->gdt_base = __pa(boot_gdt);
31530 #else
31531 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
31532 index 8869287..d577672 100644
31533 --- a/arch/x86/realmode/rm/Makefile
31534 +++ b/arch/x86/realmode/rm/Makefile
31535 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
31536 $(call cc-option, -fno-unit-at-a-time)) \
31537 $(call cc-option, -fno-stack-protector) \
31538 $(call cc-option, -mpreferred-stack-boundary=2)
31539 +ifdef CONSTIFY_PLUGIN
31540 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
31541 +endif
31542 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
31543 GCOV_PROFILE := n
31544 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
31545 index a28221d..93c40f1 100644
31546 --- a/arch/x86/realmode/rm/header.S
31547 +++ b/arch/x86/realmode/rm/header.S
31548 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
31549 #endif
31550 /* APM/BIOS reboot */
31551 .long pa_machine_real_restart_asm
31552 -#ifdef CONFIG_X86_64
31553 +#ifdef CONFIG_X86_32
31554 + .long __KERNEL_CS
31555 +#else
31556 .long __KERNEL32_CS
31557 #endif
31558 END(real_mode_header)
31559 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
31560 index c1b2791..f9e31c7 100644
31561 --- a/arch/x86/realmode/rm/trampoline_32.S
31562 +++ b/arch/x86/realmode/rm/trampoline_32.S
31563 @@ -25,6 +25,12 @@
31564 #include <asm/page_types.h>
31565 #include "realmode.h"
31566
31567 +#ifdef CONFIG_PAX_KERNEXEC
31568 +#define ta(X) (X)
31569 +#else
31570 +#define ta(X) (pa_ ## X)
31571 +#endif
31572 +
31573 .text
31574 .code16
31575
31576 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
31577
31578 cli # We should be safe anyway
31579
31580 - movl tr_start, %eax # where we need to go
31581 -
31582 movl $0xA5A5A5A5, trampoline_status
31583 # write marker for master knows we're running
31584
31585 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
31586 movw $1, %dx # protected mode (PE) bit
31587 lmsw %dx # into protected mode
31588
31589 - ljmpl $__BOOT_CS, $pa_startup_32
31590 + ljmpl *(trampoline_header)
31591
31592 .section ".text32","ax"
31593 .code32
31594 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
31595 .balign 8
31596 GLOBAL(trampoline_header)
31597 tr_start: .space 4
31598 - tr_gdt_pad: .space 2
31599 + tr_boot_cs: .space 2
31600 tr_gdt: .space 6
31601 END(trampoline_header)
31602
31603 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
31604 index bb360dc..3e5945f 100644
31605 --- a/arch/x86/realmode/rm/trampoline_64.S
31606 +++ b/arch/x86/realmode/rm/trampoline_64.S
31607 @@ -107,7 +107,7 @@ ENTRY(startup_32)
31608 wrmsr
31609
31610 # Enable paging and in turn activate Long Mode
31611 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
31612 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
31613 movl %eax, %cr0
31614
31615 /*
31616 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
31617 index 79d67bd..c7e1b90 100644
31618 --- a/arch/x86/tools/relocs.c
31619 +++ b/arch/x86/tools/relocs.c
31620 @@ -12,10 +12,13 @@
31621 #include <regex.h>
31622 #include <tools/le_byteshift.h>
31623
31624 +#include "../../../include/generated/autoconf.h"
31625 +
31626 static void die(char *fmt, ...);
31627
31628 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
31629 static Elf32_Ehdr ehdr;
31630 +static Elf32_Phdr *phdr;
31631 static unsigned long reloc_count, reloc_idx;
31632 static unsigned long *relocs;
31633 static unsigned long reloc16_count, reloc16_idx;
31634 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
31635 }
31636 }
31637
31638 +static void read_phdrs(FILE *fp)
31639 +{
31640 + unsigned int i;
31641 +
31642 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
31643 + if (!phdr) {
31644 + die("Unable to allocate %d program headers\n",
31645 + ehdr.e_phnum);
31646 + }
31647 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
31648 + die("Seek to %d failed: %s\n",
31649 + ehdr.e_phoff, strerror(errno));
31650 + }
31651 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
31652 + die("Cannot read ELF program headers: %s\n",
31653 + strerror(errno));
31654 + }
31655 + for(i = 0; i < ehdr.e_phnum; i++) {
31656 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
31657 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
31658 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
31659 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
31660 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
31661 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
31662 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
31663 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
31664 + }
31665 +
31666 +}
31667 +
31668 static void read_shdrs(FILE *fp)
31669 {
31670 - int i;
31671 + unsigned int i;
31672 Elf32_Shdr shdr;
31673
31674 secs = calloc(ehdr.e_shnum, sizeof(struct section));
31675 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
31676
31677 static void read_strtabs(FILE *fp)
31678 {
31679 - int i;
31680 + unsigned int i;
31681 for (i = 0; i < ehdr.e_shnum; i++) {
31682 struct section *sec = &secs[i];
31683 if (sec->shdr.sh_type != SHT_STRTAB) {
31684 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
31685
31686 static void read_symtabs(FILE *fp)
31687 {
31688 - int i,j;
31689 + unsigned int i,j;
31690 for (i = 0; i < ehdr.e_shnum; i++) {
31691 struct section *sec = &secs[i];
31692 if (sec->shdr.sh_type != SHT_SYMTAB) {
31693 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
31694 }
31695
31696
31697 -static void read_relocs(FILE *fp)
31698 +static void read_relocs(FILE *fp, int use_real_mode)
31699 {
31700 - int i,j;
31701 + unsigned int i,j;
31702 + uint32_t base;
31703 +
31704 for (i = 0; i < ehdr.e_shnum; i++) {
31705 struct section *sec = &secs[i];
31706 if (sec->shdr.sh_type != SHT_REL) {
31707 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
31708 die("Cannot read symbol table: %s\n",
31709 strerror(errno));
31710 }
31711 + base = 0;
31712 +
31713 +#ifdef CONFIG_X86_32
31714 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31715 + if (phdr[j].p_type != PT_LOAD )
31716 + continue;
31717 + 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)
31718 + continue;
31719 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31720 + break;
31721 + }
31722 +#endif
31723 +
31724 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
31725 Elf32_Rel *rel = &sec->reltab[j];
31726 - rel->r_offset = elf32_to_cpu(rel->r_offset);
31727 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
31728 rel->r_info = elf32_to_cpu(rel->r_info);
31729 }
31730 }
31731 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
31732
31733 static void print_absolute_symbols(void)
31734 {
31735 - int i;
31736 + unsigned int i;
31737 printf("Absolute symbols\n");
31738 printf(" Num: Value Size Type Bind Visibility Name\n");
31739 for (i = 0; i < ehdr.e_shnum; i++) {
31740 struct section *sec = &secs[i];
31741 char *sym_strtab;
31742 - int j;
31743 + unsigned int j;
31744
31745 if (sec->shdr.sh_type != SHT_SYMTAB) {
31746 continue;
31747 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
31748
31749 static void print_absolute_relocs(void)
31750 {
31751 - int i, printed = 0;
31752 + unsigned int i, printed = 0;
31753
31754 for (i = 0; i < ehdr.e_shnum; i++) {
31755 struct section *sec = &secs[i];
31756 struct section *sec_applies, *sec_symtab;
31757 char *sym_strtab;
31758 Elf32_Sym *sh_symtab;
31759 - int j;
31760 + unsigned int j;
31761 if (sec->shdr.sh_type != SHT_REL) {
31762 continue;
31763 }
31764 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
31765 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31766 int use_real_mode)
31767 {
31768 - int i;
31769 + unsigned int i;
31770 /* Walk through the relocations */
31771 for (i = 0; i < ehdr.e_shnum; i++) {
31772 char *sym_strtab;
31773 Elf32_Sym *sh_symtab;
31774 struct section *sec_applies, *sec_symtab;
31775 - int j;
31776 + unsigned int j;
31777 struct section *sec = &secs[i];
31778
31779 if (sec->shdr.sh_type != SHT_REL) {
31780 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31781 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
31782 r_type = ELF32_R_TYPE(rel->r_info);
31783
31784 + if (!use_real_mode) {
31785 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31786 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31787 + continue;
31788 +
31789 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
31790 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31791 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31792 + continue;
31793 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31794 + continue;
31795 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31796 + continue;
31797 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31798 + continue;
31799 +#endif
31800 + }
31801 +
31802 shn_abs = sym->st_shndx == SHN_ABS;
31803
31804 switch (r_type) {
31805 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
31806
31807 static void emit_relocs(int as_text, int use_real_mode)
31808 {
31809 - int i;
31810 + unsigned int i;
31811 /* Count how many relocations I have and allocate space for them. */
31812 reloc_count = 0;
31813 walk_relocs(count_reloc, use_real_mode);
31814 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
31815 fname, strerror(errno));
31816 }
31817 read_ehdr(fp);
31818 + read_phdrs(fp);
31819 read_shdrs(fp);
31820 read_strtabs(fp);
31821 read_symtabs(fp);
31822 - read_relocs(fp);
31823 + read_relocs(fp, use_real_mode);
31824 if (show_absolute_syms) {
31825 print_absolute_symbols();
31826 goto out;
31827 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31828 index fd14be1..e3c79c0 100644
31829 --- a/arch/x86/vdso/Makefile
31830 +++ b/arch/x86/vdso/Makefile
31831 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31832 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31833 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31834
31835 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31836 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31837 GCOV_PROFILE := n
31838
31839 #
31840 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31841 index 0faad64..39ef157 100644
31842 --- a/arch/x86/vdso/vdso32-setup.c
31843 +++ b/arch/x86/vdso/vdso32-setup.c
31844 @@ -25,6 +25,7 @@
31845 #include <asm/tlbflush.h>
31846 #include <asm/vdso.h>
31847 #include <asm/proto.h>
31848 +#include <asm/mman.h>
31849
31850 enum {
31851 VDSO_DISABLED = 0,
31852 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31853 void enable_sep_cpu(void)
31854 {
31855 int cpu = get_cpu();
31856 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31857 + struct tss_struct *tss = init_tss + cpu;
31858
31859 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31860 put_cpu();
31861 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31862 gate_vma.vm_start = FIXADDR_USER_START;
31863 gate_vma.vm_end = FIXADDR_USER_END;
31864 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31865 - gate_vma.vm_page_prot = __P101;
31866 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31867
31868 return 0;
31869 }
31870 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31871 if (compat)
31872 addr = VDSO_HIGH_BASE;
31873 else {
31874 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31875 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31876 if (IS_ERR_VALUE(addr)) {
31877 ret = addr;
31878 goto up_fail;
31879 }
31880 }
31881
31882 - current->mm->context.vdso = (void *)addr;
31883 + current->mm->context.vdso = addr;
31884
31885 if (compat_uses_vma || !compat) {
31886 /*
31887 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31888 }
31889
31890 current_thread_info()->sysenter_return =
31891 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31892 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31893
31894 up_fail:
31895 if (ret)
31896 - current->mm->context.vdso = NULL;
31897 + current->mm->context.vdso = 0;
31898
31899 up_write(&mm->mmap_sem);
31900
31901 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31902
31903 const char *arch_vma_name(struct vm_area_struct *vma)
31904 {
31905 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31906 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31907 return "[vdso]";
31908 +
31909 +#ifdef CONFIG_PAX_SEGMEXEC
31910 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31911 + return "[vdso]";
31912 +#endif
31913 +
31914 return NULL;
31915 }
31916
31917 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31918 * Check to see if the corresponding task was created in compat vdso
31919 * mode.
31920 */
31921 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31922 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31923 return &gate_vma;
31924 return NULL;
31925 }
31926 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31927 index 431e875..cbb23f3 100644
31928 --- a/arch/x86/vdso/vma.c
31929 +++ b/arch/x86/vdso/vma.c
31930 @@ -16,8 +16,6 @@
31931 #include <asm/vdso.h>
31932 #include <asm/page.h>
31933
31934 -unsigned int __read_mostly vdso_enabled = 1;
31935 -
31936 extern char vdso_start[], vdso_end[];
31937 extern unsigned short vdso_sync_cpuid;
31938
31939 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31940 * unaligned here as a result of stack start randomization.
31941 */
31942 addr = PAGE_ALIGN(addr);
31943 - addr = align_vdso_addr(addr);
31944
31945 return addr;
31946 }
31947 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31948 unsigned size)
31949 {
31950 struct mm_struct *mm = current->mm;
31951 - unsigned long addr;
31952 + unsigned long addr = 0;
31953 int ret;
31954
31955 - if (!vdso_enabled)
31956 - return 0;
31957 -
31958 down_write(&mm->mmap_sem);
31959 +
31960 +#ifdef CONFIG_PAX_RANDMMAP
31961 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31962 +#endif
31963 +
31964 addr = vdso_addr(mm->start_stack, size);
31965 + addr = align_vdso_addr(addr);
31966 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31967 if (IS_ERR_VALUE(addr)) {
31968 ret = addr;
31969 goto up_fail;
31970 }
31971
31972 - current->mm->context.vdso = (void *)addr;
31973 + mm->context.vdso = addr;
31974
31975 ret = install_special_mapping(mm, addr, size,
31976 VM_READ|VM_EXEC|
31977 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31978 pages);
31979 - if (ret) {
31980 - current->mm->context.vdso = NULL;
31981 - goto up_fail;
31982 - }
31983 + if (ret)
31984 + mm->context.vdso = 0;
31985
31986 up_fail:
31987 up_write(&mm->mmap_sem);
31988 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31989 vdsox32_size);
31990 }
31991 #endif
31992 -
31993 -static __init int vdso_setup(char *s)
31994 -{
31995 - vdso_enabled = simple_strtoul(s, NULL, 0);
31996 - return 0;
31997 -}
31998 -__setup("vdso=", vdso_setup);
31999 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
32000 index 2262003..3ee61cf 100644
32001 --- a/arch/x86/xen/enlighten.c
32002 +++ b/arch/x86/xen/enlighten.c
32003 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
32004
32005 struct shared_info xen_dummy_shared_info;
32006
32007 -void *xen_initial_gdt;
32008 -
32009 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
32010 __read_mostly int xen_have_vector_callback;
32011 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
32012 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
32013 {
32014 unsigned long va = dtr->address;
32015 unsigned int size = dtr->size + 1;
32016 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
32017 - unsigned long frames[pages];
32018 + unsigned long frames[65536 / PAGE_SIZE];
32019 int f;
32020
32021 /*
32022 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
32023 {
32024 unsigned long va = dtr->address;
32025 unsigned int size = dtr->size + 1;
32026 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
32027 - unsigned long frames[pages];
32028 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
32029 int f;
32030
32031 /*
32032 @@ -554,7 +550,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
32033 * 8-byte entries, or 16 4k pages..
32034 */
32035
32036 - BUG_ON(size > 65536);
32037 + BUG_ON(size > GDT_SIZE);
32038 BUG_ON(va & ~PAGE_MASK);
32039
32040 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
32041 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
32042 return 0;
32043 }
32044
32045 -static void set_xen_basic_apic_ops(void)
32046 +static void __init set_xen_basic_apic_ops(void)
32047 {
32048 apic->read = xen_apic_read;
32049 apic->write = xen_apic_write;
32050 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
32051 #endif
32052 };
32053
32054 -static void xen_reboot(int reason)
32055 +static __noreturn void xen_reboot(int reason)
32056 {
32057 struct sched_shutdown r = { .reason = reason };
32058
32059 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
32060 - BUG();
32061 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
32062 + BUG();
32063 }
32064
32065 -static void xen_restart(char *msg)
32066 +static __noreturn void xen_restart(char *msg)
32067 {
32068 xen_reboot(SHUTDOWN_reboot);
32069 }
32070
32071 -static void xen_emergency_restart(void)
32072 +static __noreturn void xen_emergency_restart(void)
32073 {
32074 xen_reboot(SHUTDOWN_reboot);
32075 }
32076
32077 -static void xen_machine_halt(void)
32078 +static __noreturn void xen_machine_halt(void)
32079 {
32080 xen_reboot(SHUTDOWN_poweroff);
32081 }
32082
32083 -static void xen_machine_power_off(void)
32084 +static __noreturn void xen_machine_power_off(void)
32085 {
32086 if (pm_power_off)
32087 pm_power_off();
32088 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
32089 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
32090
32091 /* Work out if we support NX */
32092 - x86_configure_nx();
32093 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32094 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
32095 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
32096 + unsigned l, h;
32097 +
32098 + __supported_pte_mask |= _PAGE_NX;
32099 + rdmsr(MSR_EFER, l, h);
32100 + l |= EFER_NX;
32101 + wrmsr(MSR_EFER, l, h);
32102 + }
32103 +#endif
32104
32105 xen_setup_features();
32106
32107 @@ -1401,13 +1407,6 @@ asmlinkage void __init xen_start_kernel(void)
32108
32109 machine_ops = xen_machine_ops;
32110
32111 - /*
32112 - * The only reliable way to retain the initial address of the
32113 - * percpu gdt_page is to remember it here, so we can go and
32114 - * mark it RW later, when the initial percpu area is freed.
32115 - */
32116 - xen_initial_gdt = &per_cpu(gdt_page, 0);
32117 -
32118 xen_smp_init();
32119
32120 #ifdef CONFIG_ACPI_NUMA
32121 @@ -1598,7 +1597,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
32122 return NOTIFY_OK;
32123 }
32124
32125 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
32126 +static struct notifier_block xen_hvm_cpu_notifier = {
32127 .notifier_call = xen_hvm_cpu_notify,
32128 };
32129
32130 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
32131 index cab96b6..8c629ba 100644
32132 --- a/arch/x86/xen/mmu.c
32133 +++ b/arch/x86/xen/mmu.c
32134 @@ -1739,14 +1739,18 @@ static void *m2v(phys_addr_t maddr)
32135 }
32136
32137 /* Set the page permissions on an identity-mapped pages */
32138 -static void set_page_prot(void *addr, pgprot_t prot)
32139 +static void set_page_prot_flags(void *addr, pgprot_t prot, unsigned long flags)
32140 {
32141 unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
32142 pte_t pte = pfn_pte(pfn, prot);
32143
32144 - if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0))
32145 + if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, flags))
32146 BUG();
32147 }
32148 +static void set_page_prot(void *addr, pgprot_t prot)
32149 +{
32150 + return set_page_prot_flags(addr, prot, UVMF_NONE);
32151 +}
32152 #ifdef CONFIG_X86_32
32153 static void __init xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
32154 {
32155 @@ -1830,12 +1834,12 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
32156 unsigned long addr)
32157 {
32158 if (*pt_base == PFN_DOWN(__pa(addr))) {
32159 - set_page_prot((void *)addr, PAGE_KERNEL);
32160 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
32161 clear_page((void *)addr);
32162 (*pt_base)++;
32163 }
32164 if (*pt_end == PFN_DOWN(__pa(addr))) {
32165 - set_page_prot((void *)addr, PAGE_KERNEL);
32166 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
32167 clear_page((void *)addr);
32168 (*pt_end)--;
32169 }
32170 @@ -1881,6 +1885,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
32171 /* L3_k[510] -> level2_kernel_pgt
32172 * L3_i[511] -> level2_fixmap_pgt */
32173 convert_pfn_mfn(level3_kernel_pgt);
32174 + convert_pfn_mfn(level3_vmalloc_start_pgt);
32175 + convert_pfn_mfn(level3_vmalloc_end_pgt);
32176 + convert_pfn_mfn(level3_vmemmap_pgt);
32177
32178 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
32179 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
32180 @@ -1910,8 +1917,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
32181 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
32182 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
32183 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
32184 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
32185 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
32186 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
32187 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
32188 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
32189 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
32190 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
32191 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
32192
32193 @@ -2097,6 +2108,7 @@ static void __init xen_post_allocator_init(void)
32194 pv_mmu_ops.set_pud = xen_set_pud;
32195 #if PAGETABLE_LEVELS == 4
32196 pv_mmu_ops.set_pgd = xen_set_pgd;
32197 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
32198 #endif
32199
32200 /* This will work as long as patching hasn't happened yet
32201 @@ -2178,6 +2190,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
32202 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
32203 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
32204 .set_pgd = xen_set_pgd_hyper,
32205 + .set_pgd_batched = xen_set_pgd_hyper,
32206
32207 .alloc_pud = xen_alloc_pmd_init,
32208 .release_pud = xen_release_pmd_init,
32209 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
32210 index 34bc4ce..c34aa24 100644
32211 --- a/arch/x86/xen/smp.c
32212 +++ b/arch/x86/xen/smp.c
32213 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
32214 {
32215 BUG_ON(smp_processor_id() != 0);
32216 native_smp_prepare_boot_cpu();
32217 -
32218 - /* We've switched to the "real" per-cpu gdt, so make sure the
32219 - old memory can be recycled */
32220 - make_lowmem_page_readwrite(xen_initial_gdt);
32221 -
32222 xen_filter_cpu_maps();
32223 xen_setup_vcpu_info_placement();
32224 }
32225 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
32226 gdt = get_cpu_gdt_table(cpu);
32227
32228 ctxt->flags = VGCF_IN_KERNEL;
32229 - ctxt->user_regs.ds = __USER_DS;
32230 - ctxt->user_regs.es = __USER_DS;
32231 + ctxt->user_regs.ds = __KERNEL_DS;
32232 + ctxt->user_regs.es = __KERNEL_DS;
32233 ctxt->user_regs.ss = __KERNEL_DS;
32234 #ifdef CONFIG_X86_32
32235 ctxt->user_regs.fs = __KERNEL_PERCPU;
32236 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
32237 + savesegment(gs, ctxt->user_regs.gs);
32238 #else
32239 ctxt->gs_base_kernel = per_cpu_offset(cpu);
32240 #endif
32241 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
32242 int rc;
32243
32244 per_cpu(current_task, cpu) = idle;
32245 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
32246 #ifdef CONFIG_X86_32
32247 irq_ctx_init(cpu);
32248 #else
32249 clear_tsk_thread_flag(idle, TIF_FORK);
32250 - per_cpu(kernel_stack, cpu) =
32251 - (unsigned long)task_stack_page(idle) -
32252 - KERNEL_STACK_OFFSET + THREAD_SIZE;
32253 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
32254 #endif
32255 xen_setup_runstate_info(cpu);
32256 xen_setup_timer(cpu);
32257 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
32258
32259 void __init xen_smp_init(void)
32260 {
32261 - smp_ops = xen_smp_ops;
32262 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
32263 xen_fill_possible_map();
32264 xen_init_spinlocks();
32265 }
32266 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
32267 index 33ca6e4..0ded929 100644
32268 --- a/arch/x86/xen/xen-asm_32.S
32269 +++ b/arch/x86/xen/xen-asm_32.S
32270 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
32271 ESP_OFFSET=4 # bytes pushed onto stack
32272
32273 /*
32274 - * Store vcpu_info pointer for easy access. Do it this way to
32275 - * avoid having to reload %fs
32276 + * Store vcpu_info pointer for easy access.
32277 */
32278 #ifdef CONFIG_SMP
32279 - GET_THREAD_INFO(%eax)
32280 - movl %ss:TI_cpu(%eax), %eax
32281 - movl %ss:__per_cpu_offset(,%eax,4), %eax
32282 - mov %ss:xen_vcpu(%eax), %eax
32283 + push %fs
32284 + mov $(__KERNEL_PERCPU), %eax
32285 + mov %eax, %fs
32286 + mov PER_CPU_VAR(xen_vcpu), %eax
32287 + pop %fs
32288 #else
32289 movl %ss:xen_vcpu, %eax
32290 #endif
32291 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
32292 index 7faed58..ba4427c 100644
32293 --- a/arch/x86/xen/xen-head.S
32294 +++ b/arch/x86/xen/xen-head.S
32295 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
32296 #ifdef CONFIG_X86_32
32297 mov %esi,xen_start_info
32298 mov $init_thread_union+THREAD_SIZE,%esp
32299 +#ifdef CONFIG_SMP
32300 + movl $cpu_gdt_table,%edi
32301 + movl $__per_cpu_load,%eax
32302 + movw %ax,__KERNEL_PERCPU + 2(%edi)
32303 + rorl $16,%eax
32304 + movb %al,__KERNEL_PERCPU + 4(%edi)
32305 + movb %ah,__KERNEL_PERCPU + 7(%edi)
32306 + movl $__per_cpu_end - 1,%eax
32307 + subl $__per_cpu_start,%eax
32308 + movw %ax,__KERNEL_PERCPU + 0(%edi)
32309 +#endif
32310 #else
32311 mov %rsi,xen_start_info
32312 mov $init_thread_union+THREAD_SIZE,%rsp
32313 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
32314 index a95b417..b6dbd0b 100644
32315 --- a/arch/x86/xen/xen-ops.h
32316 +++ b/arch/x86/xen/xen-ops.h
32317 @@ -10,8 +10,6 @@
32318 extern const char xen_hypervisor_callback[];
32319 extern const char xen_failsafe_callback[];
32320
32321 -extern void *xen_initial_gdt;
32322 -
32323 struct trap_info;
32324 void xen_copy_trap_info(struct trap_info *traps);
32325
32326 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
32327 index 525bd3d..ef888b1 100644
32328 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
32329 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
32330 @@ -119,9 +119,9 @@
32331 ----------------------------------------------------------------------*/
32332
32333 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
32334 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
32335 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
32336 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
32337 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
32338
32339 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
32340 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
32341 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
32342 index 2f33760..835e50a 100644
32343 --- a/arch/xtensa/variants/fsf/include/variant/core.h
32344 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
32345 @@ -11,6 +11,7 @@
32346 #ifndef _XTENSA_CORE_H
32347 #define _XTENSA_CORE_H
32348
32349 +#include <linux/const.h>
32350
32351 /****************************************************************************
32352 Parameters Useful for Any Code, USER or PRIVILEGED
32353 @@ -112,9 +113,9 @@
32354 ----------------------------------------------------------------------*/
32355
32356 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
32357 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
32358 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
32359 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
32360 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
32361
32362 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
32363 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
32364 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
32365 index af00795..2bb8105 100644
32366 --- a/arch/xtensa/variants/s6000/include/variant/core.h
32367 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
32368 @@ -11,6 +11,7 @@
32369 #ifndef _XTENSA_CORE_CONFIGURATION_H
32370 #define _XTENSA_CORE_CONFIGURATION_H
32371
32372 +#include <linux/const.h>
32373
32374 /****************************************************************************
32375 Parameters Useful for Any Code, USER or PRIVILEGED
32376 @@ -118,9 +119,9 @@
32377 ----------------------------------------------------------------------*/
32378
32379 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
32380 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
32381 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
32382 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
32383 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
32384
32385 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
32386 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
32387 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
32388 index 58916af..eb9dbcf6 100644
32389 --- a/block/blk-iopoll.c
32390 +++ b/block/blk-iopoll.c
32391 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
32392 }
32393 EXPORT_SYMBOL(blk_iopoll_complete);
32394
32395 -static void blk_iopoll_softirq(struct softirq_action *h)
32396 +static void blk_iopoll_softirq(void)
32397 {
32398 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
32399 int rearm = 0, budget = blk_iopoll_budget;
32400 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
32401 return NOTIFY_OK;
32402 }
32403
32404 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
32405 +static struct notifier_block blk_iopoll_cpu_notifier = {
32406 .notifier_call = blk_iopoll_cpu_notify,
32407 };
32408
32409 diff --git a/block/blk-map.c b/block/blk-map.c
32410 index 623e1cd..ca1e109 100644
32411 --- a/block/blk-map.c
32412 +++ b/block/blk-map.c
32413 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
32414 if (!len || !kbuf)
32415 return -EINVAL;
32416
32417 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
32418 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
32419 if (do_copy)
32420 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
32421 else
32422 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
32423 index 467c8de..f3628c5 100644
32424 --- a/block/blk-softirq.c
32425 +++ b/block/blk-softirq.c
32426 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
32427 * Softirq action handler - move entries to local list and loop over them
32428 * while passing them to the queue registered handler.
32429 */
32430 -static void blk_done_softirq(struct softirq_action *h)
32431 +static void blk_done_softirq(void)
32432 {
32433 struct list_head *cpu_list, local_list;
32434
32435 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
32436 return NOTIFY_OK;
32437 }
32438
32439 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
32440 +static struct notifier_block blk_cpu_notifier = {
32441 .notifier_call = blk_cpu_notify,
32442 };
32443
32444 diff --git a/block/bsg.c b/block/bsg.c
32445 index ff64ae3..593560c 100644
32446 --- a/block/bsg.c
32447 +++ b/block/bsg.c
32448 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
32449 struct sg_io_v4 *hdr, struct bsg_device *bd,
32450 fmode_t has_write_perm)
32451 {
32452 + unsigned char tmpcmd[sizeof(rq->__cmd)];
32453 + unsigned char *cmdptr;
32454 +
32455 if (hdr->request_len > BLK_MAX_CDB) {
32456 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
32457 if (!rq->cmd)
32458 return -ENOMEM;
32459 - }
32460 + cmdptr = rq->cmd;
32461 + } else
32462 + cmdptr = tmpcmd;
32463
32464 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
32465 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
32466 hdr->request_len))
32467 return -EFAULT;
32468
32469 + if (cmdptr != rq->cmd)
32470 + memcpy(rq->cmd, cmdptr, hdr->request_len);
32471 +
32472 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
32473 if (blk_verify_command(rq->cmd, has_write_perm))
32474 return -EPERM;
32475 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
32476 index 7c668c8..db3521c 100644
32477 --- a/block/compat_ioctl.c
32478 +++ b/block/compat_ioctl.c
32479 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
32480 err |= __get_user(f->spec1, &uf->spec1);
32481 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
32482 err |= __get_user(name, &uf->name);
32483 - f->name = compat_ptr(name);
32484 + f->name = (void __force_kernel *)compat_ptr(name);
32485 if (err) {
32486 err = -EFAULT;
32487 goto out;
32488 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
32489 index b62fb88..bdab4c4 100644
32490 --- a/block/partitions/efi.c
32491 +++ b/block/partitions/efi.c
32492 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
32493 if (!gpt)
32494 return NULL;
32495
32496 + if (!le32_to_cpu(gpt->num_partition_entries))
32497 + return NULL;
32498 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
32499 + if (!pte)
32500 + return NULL;
32501 +
32502 count = le32_to_cpu(gpt->num_partition_entries) *
32503 le32_to_cpu(gpt->sizeof_partition_entry);
32504 - if (!count)
32505 - return NULL;
32506 - pte = kzalloc(count, GFP_KERNEL);
32507 - if (!pte)
32508 - return NULL;
32509 -
32510 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
32511 (u8 *) pte,
32512 count) < count) {
32513 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
32514 index 9a87daa..fb17486 100644
32515 --- a/block/scsi_ioctl.c
32516 +++ b/block/scsi_ioctl.c
32517 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
32518 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
32519 struct sg_io_hdr *hdr, fmode_t mode)
32520 {
32521 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
32522 + unsigned char tmpcmd[sizeof(rq->__cmd)];
32523 + unsigned char *cmdptr;
32524 +
32525 + if (rq->cmd != rq->__cmd)
32526 + cmdptr = rq->cmd;
32527 + else
32528 + cmdptr = tmpcmd;
32529 +
32530 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
32531 return -EFAULT;
32532 +
32533 + if (cmdptr != rq->cmd)
32534 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
32535 +
32536 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
32537 return -EPERM;
32538
32539 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
32540 int err;
32541 unsigned int in_len, out_len, bytes, opcode, cmdlen;
32542 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
32543 + unsigned char tmpcmd[sizeof(rq->__cmd)];
32544 + unsigned char *cmdptr;
32545
32546 if (!sic)
32547 return -EINVAL;
32548 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
32549 */
32550 err = -EFAULT;
32551 rq->cmd_len = cmdlen;
32552 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
32553 +
32554 + if (rq->cmd != rq->__cmd)
32555 + cmdptr = rq->cmd;
32556 + else
32557 + cmdptr = tmpcmd;
32558 +
32559 + if (copy_from_user(cmdptr, sic->data, cmdlen))
32560 goto error;
32561
32562 + if (rq->cmd != cmdptr)
32563 + memcpy(rq->cmd, cmdptr, cmdlen);
32564 +
32565 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
32566 goto error;
32567
32568 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
32569 index 7bdd61b..afec999 100644
32570 --- a/crypto/cryptd.c
32571 +++ b/crypto/cryptd.c
32572 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
32573
32574 struct cryptd_blkcipher_request_ctx {
32575 crypto_completion_t complete;
32576 -};
32577 +} __no_const;
32578
32579 struct cryptd_hash_ctx {
32580 struct crypto_shash *child;
32581 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
32582
32583 struct cryptd_aead_request_ctx {
32584 crypto_completion_t complete;
32585 -};
32586 +} __no_const;
32587
32588 static void cryptd_queue_worker(struct work_struct *work);
32589
32590 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
32591 index f6d9baf..dfd511f 100644
32592 --- a/crypto/crypto_user.c
32593 +++ b/crypto/crypto_user.c
32594 @@ -30,6 +30,8 @@
32595
32596 #include "internal.h"
32597
32598 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
32599 +
32600 static DEFINE_MUTEX(crypto_cfg_mutex);
32601
32602 /* The crypto netlink socket */
32603 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
32604 struct crypto_dump_info info;
32605 int err;
32606
32607 - if (!p->cru_driver_name)
32608 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32609 + return -EINVAL;
32610 +
32611 + if (!p->cru_driver_name[0])
32612 return -EINVAL;
32613
32614 alg = crypto_alg_match(p, 1);
32615 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32616 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32617 LIST_HEAD(list);
32618
32619 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32620 + return -EINVAL;
32621 +
32622 if (priority && !strlen(p->cru_driver_name))
32623 return -EINVAL;
32624
32625 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32626 struct crypto_alg *alg;
32627 struct crypto_user_alg *p = nlmsg_data(nlh);
32628
32629 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32630 + return -EINVAL;
32631 +
32632 alg = crypto_alg_match(p, 1);
32633 if (!alg)
32634 return -ENOENT;
32635 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32636 struct crypto_user_alg *p = nlmsg_data(nlh);
32637 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32638
32639 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32640 + return -EINVAL;
32641 +
32642 if (strlen(p->cru_driver_name))
32643 exact = 1;
32644
32645 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
32646 index f220d64..d359ad6 100644
32647 --- a/drivers/acpi/apei/apei-internal.h
32648 +++ b/drivers/acpi/apei/apei-internal.h
32649 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
32650 struct apei_exec_ins_type {
32651 u32 flags;
32652 apei_exec_ins_func_t run;
32653 -};
32654 +} __do_const;
32655
32656 struct apei_exec_context {
32657 u32 ip;
32658 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
32659 index e6defd8..c26a225 100644
32660 --- a/drivers/acpi/apei/cper.c
32661 +++ b/drivers/acpi/apei/cper.c
32662 @@ -38,12 +38,12 @@
32663 */
32664 u64 cper_next_record_id(void)
32665 {
32666 - static atomic64_t seq;
32667 + static atomic64_unchecked_t seq;
32668
32669 - if (!atomic64_read(&seq))
32670 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
32671 + if (!atomic64_read_unchecked(&seq))
32672 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
32673
32674 - return atomic64_inc_return(&seq);
32675 + return atomic64_inc_return_unchecked(&seq);
32676 }
32677 EXPORT_SYMBOL_GPL(cper_next_record_id);
32678
32679 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
32680 index be60399..778b33e8 100644
32681 --- a/drivers/acpi/bgrt.c
32682 +++ b/drivers/acpi/bgrt.c
32683 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
32684 return -ENODEV;
32685
32686 sysfs_bin_attr_init(&image_attr);
32687 - image_attr.private = bgrt_image;
32688 - image_attr.size = bgrt_image_size;
32689 + pax_open_kernel();
32690 + *(void **)&image_attr.private = bgrt_image;
32691 + *(size_t *)&image_attr.size = bgrt_image_size;
32692 + pax_close_kernel();
32693
32694 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
32695 if (!bgrt_kobj)
32696 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
32697 index cb96296..b81293b 100644
32698 --- a/drivers/acpi/blacklist.c
32699 +++ b/drivers/acpi/blacklist.c
32700 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
32701 u32 is_critical_error;
32702 };
32703
32704 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
32705 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
32706
32707 /*
32708 * POLICY: If *anything* doesn't work, put it on the blacklist.
32709 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
32710 return 0;
32711 }
32712
32713 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
32714 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
32715 {
32716 .callback = dmi_disable_osi_vista,
32717 .ident = "Fujitsu Siemens",
32718 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32719 index 7586544..636a2f0 100644
32720 --- a/drivers/acpi/ec_sys.c
32721 +++ b/drivers/acpi/ec_sys.c
32722 @@ -12,6 +12,7 @@
32723 #include <linux/acpi.h>
32724 #include <linux/debugfs.h>
32725 #include <linux/module.h>
32726 +#include <linux/uaccess.h>
32727 #include "internal.h"
32728
32729 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32730 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32731 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32732 */
32733 unsigned int size = EC_SPACE_SIZE;
32734 - u8 *data = (u8 *) buf;
32735 + u8 data;
32736 loff_t init_off = *off;
32737 int err = 0;
32738
32739 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32740 size = count;
32741
32742 while (size) {
32743 - err = ec_read(*off, &data[*off - init_off]);
32744 + err = ec_read(*off, &data);
32745 if (err)
32746 return err;
32747 + if (put_user(data, &buf[*off - init_off]))
32748 + return -EFAULT;
32749 *off += 1;
32750 size--;
32751 }
32752 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32753
32754 unsigned int size = count;
32755 loff_t init_off = *off;
32756 - u8 *data = (u8 *) buf;
32757 int err = 0;
32758
32759 if (*off >= EC_SPACE_SIZE)
32760 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32761 }
32762
32763 while (size) {
32764 - u8 byte_write = data[*off - init_off];
32765 + u8 byte_write;
32766 + if (get_user(byte_write, &buf[*off - init_off]))
32767 + return -EFAULT;
32768 err = ec_write(*off, byte_write);
32769 if (err)
32770 return err;
32771 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
32772 index e83311b..142b5cc 100644
32773 --- a/drivers/acpi/processor_driver.c
32774 +++ b/drivers/acpi/processor_driver.c
32775 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
32776 return 0;
32777 #endif
32778
32779 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
32780 + BUG_ON(pr->id >= nr_cpu_ids);
32781
32782 /*
32783 * Buggy BIOS check
32784 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32785 index ed9a1cc..f4a354c 100644
32786 --- a/drivers/acpi/processor_idle.c
32787 +++ b/drivers/acpi/processor_idle.c
32788 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32789 {
32790 int i, count = CPUIDLE_DRIVER_STATE_START;
32791 struct acpi_processor_cx *cx;
32792 - struct cpuidle_state *state;
32793 + cpuidle_state_no_const *state;
32794 struct cpuidle_driver *drv = &acpi_idle_driver;
32795
32796 if (!pr->flags.power_setup_done)
32797 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32798 index ea61ca9..3fdd70d 100644
32799 --- a/drivers/acpi/sysfs.c
32800 +++ b/drivers/acpi/sysfs.c
32801 @@ -420,11 +420,11 @@ static u32 num_counters;
32802 static struct attribute **all_attrs;
32803 static u32 acpi_gpe_count;
32804
32805 -static struct attribute_group interrupt_stats_attr_group = {
32806 +static attribute_group_no_const interrupt_stats_attr_group = {
32807 .name = "interrupts",
32808 };
32809
32810 -static struct kobj_attribute *counter_attrs;
32811 +static kobj_attribute_no_const *counter_attrs;
32812
32813 static void delete_gpe_attr_array(void)
32814 {
32815 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32816 index 6cd7805..07facb3 100644
32817 --- a/drivers/ata/libahci.c
32818 +++ b/drivers/ata/libahci.c
32819 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32820 }
32821 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32822
32823 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32824 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32825 struct ata_taskfile *tf, int is_cmd, u16 flags,
32826 unsigned long timeout_msec)
32827 {
32828 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32829 index 501c209..5f28b4d 100644
32830 --- a/drivers/ata/libata-core.c
32831 +++ b/drivers/ata/libata-core.c
32832 @@ -4784,7 +4784,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32833 struct ata_port *ap;
32834 unsigned int tag;
32835
32836 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32837 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32838 ap = qc->ap;
32839
32840 qc->flags = 0;
32841 @@ -4800,7 +4800,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32842 struct ata_port *ap;
32843 struct ata_link *link;
32844
32845 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32846 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32847 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32848 ap = qc->ap;
32849 link = qc->dev->link;
32850 @@ -5896,6 +5896,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32851 return;
32852
32853 spin_lock(&lock);
32854 + pax_open_kernel();
32855
32856 for (cur = ops->inherits; cur; cur = cur->inherits) {
32857 void **inherit = (void **)cur;
32858 @@ -5909,8 +5910,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32859 if (IS_ERR(*pp))
32860 *pp = NULL;
32861
32862 - ops->inherits = NULL;
32863 + *(struct ata_port_operations **)&ops->inherits = NULL;
32864
32865 + pax_close_kernel();
32866 spin_unlock(&lock);
32867 }
32868
32869 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32870 index 405022d..fb70e53 100644
32871 --- a/drivers/ata/pata_arasan_cf.c
32872 +++ b/drivers/ata/pata_arasan_cf.c
32873 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32874 /* Handle platform specific quirks */
32875 if (pdata->quirk) {
32876 if (pdata->quirk & CF_BROKEN_PIO) {
32877 - ap->ops->set_piomode = NULL;
32878 + pax_open_kernel();
32879 + *(void **)&ap->ops->set_piomode = NULL;
32880 + pax_close_kernel();
32881 ap->pio_mask = 0;
32882 }
32883 if (pdata->quirk & CF_BROKEN_MWDMA)
32884 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32885 index f9b983a..887b9d8 100644
32886 --- a/drivers/atm/adummy.c
32887 +++ b/drivers/atm/adummy.c
32888 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32889 vcc->pop(vcc, skb);
32890 else
32891 dev_kfree_skb_any(skb);
32892 - atomic_inc(&vcc->stats->tx);
32893 + atomic_inc_unchecked(&vcc->stats->tx);
32894
32895 return 0;
32896 }
32897 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32898 index 77a7480..05cde58 100644
32899 --- a/drivers/atm/ambassador.c
32900 +++ b/drivers/atm/ambassador.c
32901 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32902 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32903
32904 // VC layer stats
32905 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32906 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32907
32908 // free the descriptor
32909 kfree (tx_descr);
32910 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32911 dump_skb ("<<<", vc, skb);
32912
32913 // VC layer stats
32914 - atomic_inc(&atm_vcc->stats->rx);
32915 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32916 __net_timestamp(skb);
32917 // end of our responsibility
32918 atm_vcc->push (atm_vcc, skb);
32919 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32920 } else {
32921 PRINTK (KERN_INFO, "dropped over-size frame");
32922 // should we count this?
32923 - atomic_inc(&atm_vcc->stats->rx_drop);
32924 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32925 }
32926
32927 } else {
32928 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32929 }
32930
32931 if (check_area (skb->data, skb->len)) {
32932 - atomic_inc(&atm_vcc->stats->tx_err);
32933 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32934 return -ENOMEM; // ?
32935 }
32936
32937 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32938 index b22d71c..d6e1049 100644
32939 --- a/drivers/atm/atmtcp.c
32940 +++ b/drivers/atm/atmtcp.c
32941 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32942 if (vcc->pop) vcc->pop(vcc,skb);
32943 else dev_kfree_skb(skb);
32944 if (dev_data) return 0;
32945 - atomic_inc(&vcc->stats->tx_err);
32946 + atomic_inc_unchecked(&vcc->stats->tx_err);
32947 return -ENOLINK;
32948 }
32949 size = skb->len+sizeof(struct atmtcp_hdr);
32950 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32951 if (!new_skb) {
32952 if (vcc->pop) vcc->pop(vcc,skb);
32953 else dev_kfree_skb(skb);
32954 - atomic_inc(&vcc->stats->tx_err);
32955 + atomic_inc_unchecked(&vcc->stats->tx_err);
32956 return -ENOBUFS;
32957 }
32958 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32959 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32960 if (vcc->pop) vcc->pop(vcc,skb);
32961 else dev_kfree_skb(skb);
32962 out_vcc->push(out_vcc,new_skb);
32963 - atomic_inc(&vcc->stats->tx);
32964 - atomic_inc(&out_vcc->stats->rx);
32965 + atomic_inc_unchecked(&vcc->stats->tx);
32966 + atomic_inc_unchecked(&out_vcc->stats->rx);
32967 return 0;
32968 }
32969
32970 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32971 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32972 read_unlock(&vcc_sklist_lock);
32973 if (!out_vcc) {
32974 - atomic_inc(&vcc->stats->tx_err);
32975 + atomic_inc_unchecked(&vcc->stats->tx_err);
32976 goto done;
32977 }
32978 skb_pull(skb,sizeof(struct atmtcp_hdr));
32979 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32980 __net_timestamp(new_skb);
32981 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32982 out_vcc->push(out_vcc,new_skb);
32983 - atomic_inc(&vcc->stats->tx);
32984 - atomic_inc(&out_vcc->stats->rx);
32985 + atomic_inc_unchecked(&vcc->stats->tx);
32986 + atomic_inc_unchecked(&out_vcc->stats->rx);
32987 done:
32988 if (vcc->pop) vcc->pop(vcc,skb);
32989 else dev_kfree_skb(skb);
32990 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32991 index c1eb6fa..4c71be9 100644
32992 --- a/drivers/atm/eni.c
32993 +++ b/drivers/atm/eni.c
32994 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32995 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32996 vcc->dev->number);
32997 length = 0;
32998 - atomic_inc(&vcc->stats->rx_err);
32999 + atomic_inc_unchecked(&vcc->stats->rx_err);
33000 }
33001 else {
33002 length = ATM_CELL_SIZE-1; /* no HEC */
33003 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
33004 size);
33005 }
33006 eff = length = 0;
33007 - atomic_inc(&vcc->stats->rx_err);
33008 + atomic_inc_unchecked(&vcc->stats->rx_err);
33009 }
33010 else {
33011 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
33012 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
33013 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
33014 vcc->dev->number,vcc->vci,length,size << 2,descr);
33015 length = eff = 0;
33016 - atomic_inc(&vcc->stats->rx_err);
33017 + atomic_inc_unchecked(&vcc->stats->rx_err);
33018 }
33019 }
33020 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
33021 @@ -767,7 +767,7 @@ rx_dequeued++;
33022 vcc->push(vcc,skb);
33023 pushed++;
33024 }
33025 - atomic_inc(&vcc->stats->rx);
33026 + atomic_inc_unchecked(&vcc->stats->rx);
33027 }
33028 wake_up(&eni_dev->rx_wait);
33029 }
33030 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
33031 PCI_DMA_TODEVICE);
33032 if (vcc->pop) vcc->pop(vcc,skb);
33033 else dev_kfree_skb_irq(skb);
33034 - atomic_inc(&vcc->stats->tx);
33035 + atomic_inc_unchecked(&vcc->stats->tx);
33036 wake_up(&eni_dev->tx_wait);
33037 dma_complete++;
33038 }
33039 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
33040 index b41c948..a002b17 100644
33041 --- a/drivers/atm/firestream.c
33042 +++ b/drivers/atm/firestream.c
33043 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
33044 }
33045 }
33046
33047 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
33048 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
33049
33050 fs_dprintk (FS_DEBUG_TXMEM, "i");
33051 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
33052 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
33053 #endif
33054 skb_put (skb, qe->p1 & 0xffff);
33055 ATM_SKB(skb)->vcc = atm_vcc;
33056 - atomic_inc(&atm_vcc->stats->rx);
33057 + atomic_inc_unchecked(&atm_vcc->stats->rx);
33058 __net_timestamp(skb);
33059 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
33060 atm_vcc->push (atm_vcc, skb);
33061 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
33062 kfree (pe);
33063 }
33064 if (atm_vcc)
33065 - atomic_inc(&atm_vcc->stats->rx_drop);
33066 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
33067 break;
33068 case 0x1f: /* Reassembly abort: no buffers. */
33069 /* Silently increment error counter. */
33070 if (atm_vcc)
33071 - atomic_inc(&atm_vcc->stats->rx_drop);
33072 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
33073 break;
33074 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
33075 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
33076 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
33077 index 204814e..cede831 100644
33078 --- a/drivers/atm/fore200e.c
33079 +++ b/drivers/atm/fore200e.c
33080 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
33081 #endif
33082 /* check error condition */
33083 if (*entry->status & STATUS_ERROR)
33084 - atomic_inc(&vcc->stats->tx_err);
33085 + atomic_inc_unchecked(&vcc->stats->tx_err);
33086 else
33087 - atomic_inc(&vcc->stats->tx);
33088 + atomic_inc_unchecked(&vcc->stats->tx);
33089 }
33090 }
33091
33092 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
33093 if (skb == NULL) {
33094 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
33095
33096 - atomic_inc(&vcc->stats->rx_drop);
33097 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33098 return -ENOMEM;
33099 }
33100
33101 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
33102
33103 dev_kfree_skb_any(skb);
33104
33105 - atomic_inc(&vcc->stats->rx_drop);
33106 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33107 return -ENOMEM;
33108 }
33109
33110 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
33111
33112 vcc->push(vcc, skb);
33113 - atomic_inc(&vcc->stats->rx);
33114 + atomic_inc_unchecked(&vcc->stats->rx);
33115
33116 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
33117
33118 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
33119 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
33120 fore200e->atm_dev->number,
33121 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
33122 - atomic_inc(&vcc->stats->rx_err);
33123 + atomic_inc_unchecked(&vcc->stats->rx_err);
33124 }
33125 }
33126
33127 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
33128 goto retry_here;
33129 }
33130
33131 - atomic_inc(&vcc->stats->tx_err);
33132 + atomic_inc_unchecked(&vcc->stats->tx_err);
33133
33134 fore200e->tx_sat++;
33135 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
33136 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
33137 index 72b6960..cf9167a 100644
33138 --- a/drivers/atm/he.c
33139 +++ b/drivers/atm/he.c
33140 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
33141
33142 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
33143 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
33144 - atomic_inc(&vcc->stats->rx_drop);
33145 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33146 goto return_host_buffers;
33147 }
33148
33149 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
33150 RBRQ_LEN_ERR(he_dev->rbrq_head)
33151 ? "LEN_ERR" : "",
33152 vcc->vpi, vcc->vci);
33153 - atomic_inc(&vcc->stats->rx_err);
33154 + atomic_inc_unchecked(&vcc->stats->rx_err);
33155 goto return_host_buffers;
33156 }
33157
33158 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
33159 vcc->push(vcc, skb);
33160 spin_lock(&he_dev->global_lock);
33161
33162 - atomic_inc(&vcc->stats->rx);
33163 + atomic_inc_unchecked(&vcc->stats->rx);
33164
33165 return_host_buffers:
33166 ++pdus_assembled;
33167 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
33168 tpd->vcc->pop(tpd->vcc, tpd->skb);
33169 else
33170 dev_kfree_skb_any(tpd->skb);
33171 - atomic_inc(&tpd->vcc->stats->tx_err);
33172 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
33173 }
33174 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
33175 return;
33176 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
33177 vcc->pop(vcc, skb);
33178 else
33179 dev_kfree_skb_any(skb);
33180 - atomic_inc(&vcc->stats->tx_err);
33181 + atomic_inc_unchecked(&vcc->stats->tx_err);
33182 return -EINVAL;
33183 }
33184
33185 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
33186 vcc->pop(vcc, skb);
33187 else
33188 dev_kfree_skb_any(skb);
33189 - atomic_inc(&vcc->stats->tx_err);
33190 + atomic_inc_unchecked(&vcc->stats->tx_err);
33191 return -EINVAL;
33192 }
33193 #endif
33194 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
33195 vcc->pop(vcc, skb);
33196 else
33197 dev_kfree_skb_any(skb);
33198 - atomic_inc(&vcc->stats->tx_err);
33199 + atomic_inc_unchecked(&vcc->stats->tx_err);
33200 spin_unlock_irqrestore(&he_dev->global_lock, flags);
33201 return -ENOMEM;
33202 }
33203 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
33204 vcc->pop(vcc, skb);
33205 else
33206 dev_kfree_skb_any(skb);
33207 - atomic_inc(&vcc->stats->tx_err);
33208 + atomic_inc_unchecked(&vcc->stats->tx_err);
33209 spin_unlock_irqrestore(&he_dev->global_lock, flags);
33210 return -ENOMEM;
33211 }
33212 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
33213 __enqueue_tpd(he_dev, tpd, cid);
33214 spin_unlock_irqrestore(&he_dev->global_lock, flags);
33215
33216 - atomic_inc(&vcc->stats->tx);
33217 + atomic_inc_unchecked(&vcc->stats->tx);
33218
33219 return 0;
33220 }
33221 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
33222 index 1dc0519..1aadaf7 100644
33223 --- a/drivers/atm/horizon.c
33224 +++ b/drivers/atm/horizon.c
33225 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
33226 {
33227 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
33228 // VC layer stats
33229 - atomic_inc(&vcc->stats->rx);
33230 + atomic_inc_unchecked(&vcc->stats->rx);
33231 __net_timestamp(skb);
33232 // end of our responsibility
33233 vcc->push (vcc, skb);
33234 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
33235 dev->tx_iovec = NULL;
33236
33237 // VC layer stats
33238 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
33239 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
33240
33241 // free the skb
33242 hrz_kfree_skb (skb);
33243 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
33244 index 272f009..a18ba55 100644
33245 --- a/drivers/atm/idt77252.c
33246 +++ b/drivers/atm/idt77252.c
33247 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
33248 else
33249 dev_kfree_skb(skb);
33250
33251 - atomic_inc(&vcc->stats->tx);
33252 + atomic_inc_unchecked(&vcc->stats->tx);
33253 }
33254
33255 atomic_dec(&scq->used);
33256 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
33257 if ((sb = dev_alloc_skb(64)) == NULL) {
33258 printk("%s: Can't allocate buffers for aal0.\n",
33259 card->name);
33260 - atomic_add(i, &vcc->stats->rx_drop);
33261 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
33262 break;
33263 }
33264 if (!atm_charge(vcc, sb->truesize)) {
33265 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
33266 card->name);
33267 - atomic_add(i - 1, &vcc->stats->rx_drop);
33268 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
33269 dev_kfree_skb(sb);
33270 break;
33271 }
33272 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
33273 ATM_SKB(sb)->vcc = vcc;
33274 __net_timestamp(sb);
33275 vcc->push(vcc, sb);
33276 - atomic_inc(&vcc->stats->rx);
33277 + atomic_inc_unchecked(&vcc->stats->rx);
33278
33279 cell += ATM_CELL_PAYLOAD;
33280 }
33281 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
33282 "(CDC: %08x)\n",
33283 card->name, len, rpp->len, readl(SAR_REG_CDC));
33284 recycle_rx_pool_skb(card, rpp);
33285 - atomic_inc(&vcc->stats->rx_err);
33286 + atomic_inc_unchecked(&vcc->stats->rx_err);
33287 return;
33288 }
33289 if (stat & SAR_RSQE_CRC) {
33290 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
33291 recycle_rx_pool_skb(card, rpp);
33292 - atomic_inc(&vcc->stats->rx_err);
33293 + atomic_inc_unchecked(&vcc->stats->rx_err);
33294 return;
33295 }
33296 if (skb_queue_len(&rpp->queue) > 1) {
33297 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
33298 RXPRINTK("%s: Can't alloc RX skb.\n",
33299 card->name);
33300 recycle_rx_pool_skb(card, rpp);
33301 - atomic_inc(&vcc->stats->rx_err);
33302 + atomic_inc_unchecked(&vcc->stats->rx_err);
33303 return;
33304 }
33305 if (!atm_charge(vcc, skb->truesize)) {
33306 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
33307 __net_timestamp(skb);
33308
33309 vcc->push(vcc, skb);
33310 - atomic_inc(&vcc->stats->rx);
33311 + atomic_inc_unchecked(&vcc->stats->rx);
33312
33313 return;
33314 }
33315 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
33316 __net_timestamp(skb);
33317
33318 vcc->push(vcc, skb);
33319 - atomic_inc(&vcc->stats->rx);
33320 + atomic_inc_unchecked(&vcc->stats->rx);
33321
33322 if (skb->truesize > SAR_FB_SIZE_3)
33323 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
33324 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
33325 if (vcc->qos.aal != ATM_AAL0) {
33326 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
33327 card->name, vpi, vci);
33328 - atomic_inc(&vcc->stats->rx_drop);
33329 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33330 goto drop;
33331 }
33332
33333 if ((sb = dev_alloc_skb(64)) == NULL) {
33334 printk("%s: Can't allocate buffers for AAL0.\n",
33335 card->name);
33336 - atomic_inc(&vcc->stats->rx_err);
33337 + atomic_inc_unchecked(&vcc->stats->rx_err);
33338 goto drop;
33339 }
33340
33341 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
33342 ATM_SKB(sb)->vcc = vcc;
33343 __net_timestamp(sb);
33344 vcc->push(vcc, sb);
33345 - atomic_inc(&vcc->stats->rx);
33346 + atomic_inc_unchecked(&vcc->stats->rx);
33347
33348 drop:
33349 skb_pull(queue, 64);
33350 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
33351
33352 if (vc == NULL) {
33353 printk("%s: NULL connection in send().\n", card->name);
33354 - atomic_inc(&vcc->stats->tx_err);
33355 + atomic_inc_unchecked(&vcc->stats->tx_err);
33356 dev_kfree_skb(skb);
33357 return -EINVAL;
33358 }
33359 if (!test_bit(VCF_TX, &vc->flags)) {
33360 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
33361 - atomic_inc(&vcc->stats->tx_err);
33362 + atomic_inc_unchecked(&vcc->stats->tx_err);
33363 dev_kfree_skb(skb);
33364 return -EINVAL;
33365 }
33366 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
33367 break;
33368 default:
33369 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
33370 - atomic_inc(&vcc->stats->tx_err);
33371 + atomic_inc_unchecked(&vcc->stats->tx_err);
33372 dev_kfree_skb(skb);
33373 return -EINVAL;
33374 }
33375
33376 if (skb_shinfo(skb)->nr_frags != 0) {
33377 printk("%s: No scatter-gather yet.\n", card->name);
33378 - atomic_inc(&vcc->stats->tx_err);
33379 + atomic_inc_unchecked(&vcc->stats->tx_err);
33380 dev_kfree_skb(skb);
33381 return -EINVAL;
33382 }
33383 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
33384
33385 err = queue_skb(card, vc, skb, oam);
33386 if (err) {
33387 - atomic_inc(&vcc->stats->tx_err);
33388 + atomic_inc_unchecked(&vcc->stats->tx_err);
33389 dev_kfree_skb(skb);
33390 return err;
33391 }
33392 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
33393 skb = dev_alloc_skb(64);
33394 if (!skb) {
33395 printk("%s: Out of memory in send_oam().\n", card->name);
33396 - atomic_inc(&vcc->stats->tx_err);
33397 + atomic_inc_unchecked(&vcc->stats->tx_err);
33398 return -ENOMEM;
33399 }
33400 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
33401 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
33402 index 4217f29..88f547a 100644
33403 --- a/drivers/atm/iphase.c
33404 +++ b/drivers/atm/iphase.c
33405 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
33406 status = (u_short) (buf_desc_ptr->desc_mode);
33407 if (status & (RX_CER | RX_PTE | RX_OFL))
33408 {
33409 - atomic_inc(&vcc->stats->rx_err);
33410 + atomic_inc_unchecked(&vcc->stats->rx_err);
33411 IF_ERR(printk("IA: bad packet, dropping it");)
33412 if (status & RX_CER) {
33413 IF_ERR(printk(" cause: packet CRC error\n");)
33414 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
33415 len = dma_addr - buf_addr;
33416 if (len > iadev->rx_buf_sz) {
33417 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
33418 - atomic_inc(&vcc->stats->rx_err);
33419 + atomic_inc_unchecked(&vcc->stats->rx_err);
33420 goto out_free_desc;
33421 }
33422
33423 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
33424 ia_vcc = INPH_IA_VCC(vcc);
33425 if (ia_vcc == NULL)
33426 {
33427 - atomic_inc(&vcc->stats->rx_err);
33428 + atomic_inc_unchecked(&vcc->stats->rx_err);
33429 atm_return(vcc, skb->truesize);
33430 dev_kfree_skb_any(skb);
33431 goto INCR_DLE;
33432 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
33433 if ((length > iadev->rx_buf_sz) || (length >
33434 (skb->len - sizeof(struct cpcs_trailer))))
33435 {
33436 - atomic_inc(&vcc->stats->rx_err);
33437 + atomic_inc_unchecked(&vcc->stats->rx_err);
33438 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
33439 length, skb->len);)
33440 atm_return(vcc, skb->truesize);
33441 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
33442
33443 IF_RX(printk("rx_dle_intr: skb push");)
33444 vcc->push(vcc,skb);
33445 - atomic_inc(&vcc->stats->rx);
33446 + atomic_inc_unchecked(&vcc->stats->rx);
33447 iadev->rx_pkt_cnt++;
33448 }
33449 INCR_DLE:
33450 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
33451 {
33452 struct k_sonet_stats *stats;
33453 stats = &PRIV(_ia_dev[board])->sonet_stats;
33454 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
33455 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
33456 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
33457 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
33458 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
33459 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
33460 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
33461 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
33462 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
33463 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
33464 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
33465 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
33466 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
33467 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
33468 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
33469 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
33470 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
33471 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
33472 }
33473 ia_cmds.status = 0;
33474 break;
33475 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
33476 if ((desc == 0) || (desc > iadev->num_tx_desc))
33477 {
33478 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
33479 - atomic_inc(&vcc->stats->tx);
33480 + atomic_inc_unchecked(&vcc->stats->tx);
33481 if (vcc->pop)
33482 vcc->pop(vcc, skb);
33483 else
33484 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
33485 ATM_DESC(skb) = vcc->vci;
33486 skb_queue_tail(&iadev->tx_dma_q, skb);
33487
33488 - atomic_inc(&vcc->stats->tx);
33489 + atomic_inc_unchecked(&vcc->stats->tx);
33490 iadev->tx_pkt_cnt++;
33491 /* Increment transaction counter */
33492 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
33493
33494 #if 0
33495 /* add flow control logic */
33496 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
33497 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
33498 if (iavcc->vc_desc_cnt > 10) {
33499 vcc->tx_quota = vcc->tx_quota * 3 / 4;
33500 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
33501 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
33502 index fa7d701..1e404c7 100644
33503 --- a/drivers/atm/lanai.c
33504 +++ b/drivers/atm/lanai.c
33505 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
33506 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
33507 lanai_endtx(lanai, lvcc);
33508 lanai_free_skb(lvcc->tx.atmvcc, skb);
33509 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
33510 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
33511 }
33512
33513 /* Try to fill the buffer - don't call unless there is backlog */
33514 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
33515 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
33516 __net_timestamp(skb);
33517 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
33518 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
33519 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
33520 out:
33521 lvcc->rx.buf.ptr = end;
33522 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
33523 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33524 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
33525 "vcc %d\n", lanai->number, (unsigned int) s, vci);
33526 lanai->stats.service_rxnotaal5++;
33527 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33528 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33529 return 0;
33530 }
33531 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
33532 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33533 int bytes;
33534 read_unlock(&vcc_sklist_lock);
33535 DPRINTK("got trashed rx pdu on vci %d\n", vci);
33536 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33537 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33538 lvcc->stats.x.aal5.service_trash++;
33539 bytes = (SERVICE_GET_END(s) * 16) -
33540 (((unsigned long) lvcc->rx.buf.ptr) -
33541 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33542 }
33543 if (s & SERVICE_STREAM) {
33544 read_unlock(&vcc_sklist_lock);
33545 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33546 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33547 lvcc->stats.x.aal5.service_stream++;
33548 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
33549 "PDU on VCI %d!\n", lanai->number, vci);
33550 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33551 return 0;
33552 }
33553 DPRINTK("got rx crc error on vci %d\n", vci);
33554 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33555 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33556 lvcc->stats.x.aal5.service_rxcrc++;
33557 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
33558 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
33559 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
33560 index ed1d2b7..8cffc1f 100644
33561 --- a/drivers/atm/nicstar.c
33562 +++ b/drivers/atm/nicstar.c
33563 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33564 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
33565 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
33566 card->index);
33567 - atomic_inc(&vcc->stats->tx_err);
33568 + atomic_inc_unchecked(&vcc->stats->tx_err);
33569 dev_kfree_skb_any(skb);
33570 return -EINVAL;
33571 }
33572 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33573 if (!vc->tx) {
33574 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
33575 card->index);
33576 - atomic_inc(&vcc->stats->tx_err);
33577 + atomic_inc_unchecked(&vcc->stats->tx_err);
33578 dev_kfree_skb_any(skb);
33579 return -EINVAL;
33580 }
33581 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33582 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
33583 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
33584 card->index);
33585 - atomic_inc(&vcc->stats->tx_err);
33586 + atomic_inc_unchecked(&vcc->stats->tx_err);
33587 dev_kfree_skb_any(skb);
33588 return -EINVAL;
33589 }
33590
33591 if (skb_shinfo(skb)->nr_frags != 0) {
33592 printk("nicstar%d: No scatter-gather yet.\n", card->index);
33593 - atomic_inc(&vcc->stats->tx_err);
33594 + atomic_inc_unchecked(&vcc->stats->tx_err);
33595 dev_kfree_skb_any(skb);
33596 return -EINVAL;
33597 }
33598 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33599 }
33600
33601 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
33602 - atomic_inc(&vcc->stats->tx_err);
33603 + atomic_inc_unchecked(&vcc->stats->tx_err);
33604 dev_kfree_skb_any(skb);
33605 return -EIO;
33606 }
33607 - atomic_inc(&vcc->stats->tx);
33608 + atomic_inc_unchecked(&vcc->stats->tx);
33609
33610 return 0;
33611 }
33612 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33613 printk
33614 ("nicstar%d: Can't allocate buffers for aal0.\n",
33615 card->index);
33616 - atomic_add(i, &vcc->stats->rx_drop);
33617 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
33618 break;
33619 }
33620 if (!atm_charge(vcc, sb->truesize)) {
33621 RXPRINTK
33622 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
33623 card->index);
33624 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33625 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33626 dev_kfree_skb_any(sb);
33627 break;
33628 }
33629 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33630 ATM_SKB(sb)->vcc = vcc;
33631 __net_timestamp(sb);
33632 vcc->push(vcc, sb);
33633 - atomic_inc(&vcc->stats->rx);
33634 + atomic_inc_unchecked(&vcc->stats->rx);
33635 cell += ATM_CELL_PAYLOAD;
33636 }
33637
33638 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33639 if (iovb == NULL) {
33640 printk("nicstar%d: Out of iovec buffers.\n",
33641 card->index);
33642 - atomic_inc(&vcc->stats->rx_drop);
33643 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33644 recycle_rx_buf(card, skb);
33645 return;
33646 }
33647 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33648 small or large buffer itself. */
33649 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
33650 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
33651 - atomic_inc(&vcc->stats->rx_err);
33652 + atomic_inc_unchecked(&vcc->stats->rx_err);
33653 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33654 NS_MAX_IOVECS);
33655 NS_PRV_IOVCNT(iovb) = 0;
33656 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33657 ("nicstar%d: Expected a small buffer, and this is not one.\n",
33658 card->index);
33659 which_list(card, skb);
33660 - atomic_inc(&vcc->stats->rx_err);
33661 + atomic_inc_unchecked(&vcc->stats->rx_err);
33662 recycle_rx_buf(card, skb);
33663 vc->rx_iov = NULL;
33664 recycle_iov_buf(card, iovb);
33665 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33666 ("nicstar%d: Expected a large buffer, and this is not one.\n",
33667 card->index);
33668 which_list(card, skb);
33669 - atomic_inc(&vcc->stats->rx_err);
33670 + atomic_inc_unchecked(&vcc->stats->rx_err);
33671 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33672 NS_PRV_IOVCNT(iovb));
33673 vc->rx_iov = NULL;
33674 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33675 printk(" - PDU size mismatch.\n");
33676 else
33677 printk(".\n");
33678 - atomic_inc(&vcc->stats->rx_err);
33679 + atomic_inc_unchecked(&vcc->stats->rx_err);
33680 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33681 NS_PRV_IOVCNT(iovb));
33682 vc->rx_iov = NULL;
33683 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33684 /* skb points to a small buffer */
33685 if (!atm_charge(vcc, skb->truesize)) {
33686 push_rxbufs(card, skb);
33687 - atomic_inc(&vcc->stats->rx_drop);
33688 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33689 } else {
33690 skb_put(skb, len);
33691 dequeue_sm_buf(card, skb);
33692 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33693 ATM_SKB(skb)->vcc = vcc;
33694 __net_timestamp(skb);
33695 vcc->push(vcc, skb);
33696 - atomic_inc(&vcc->stats->rx);
33697 + atomic_inc_unchecked(&vcc->stats->rx);
33698 }
33699 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
33700 struct sk_buff *sb;
33701 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33702 if (len <= NS_SMBUFSIZE) {
33703 if (!atm_charge(vcc, sb->truesize)) {
33704 push_rxbufs(card, sb);
33705 - atomic_inc(&vcc->stats->rx_drop);
33706 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33707 } else {
33708 skb_put(sb, len);
33709 dequeue_sm_buf(card, sb);
33710 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33711 ATM_SKB(sb)->vcc = vcc;
33712 __net_timestamp(sb);
33713 vcc->push(vcc, sb);
33714 - atomic_inc(&vcc->stats->rx);
33715 + atomic_inc_unchecked(&vcc->stats->rx);
33716 }
33717
33718 push_rxbufs(card, skb);
33719 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33720
33721 if (!atm_charge(vcc, skb->truesize)) {
33722 push_rxbufs(card, skb);
33723 - atomic_inc(&vcc->stats->rx_drop);
33724 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33725 } else {
33726 dequeue_lg_buf(card, skb);
33727 #ifdef NS_USE_DESTRUCTORS
33728 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33729 ATM_SKB(skb)->vcc = vcc;
33730 __net_timestamp(skb);
33731 vcc->push(vcc, skb);
33732 - atomic_inc(&vcc->stats->rx);
33733 + atomic_inc_unchecked(&vcc->stats->rx);
33734 }
33735
33736 push_rxbufs(card, sb);
33737 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33738 printk
33739 ("nicstar%d: Out of huge buffers.\n",
33740 card->index);
33741 - atomic_inc(&vcc->stats->rx_drop);
33742 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33743 recycle_iovec_rx_bufs(card,
33744 (struct iovec *)
33745 iovb->data,
33746 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33747 card->hbpool.count++;
33748 } else
33749 dev_kfree_skb_any(hb);
33750 - atomic_inc(&vcc->stats->rx_drop);
33751 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33752 } else {
33753 /* Copy the small buffer to the huge buffer */
33754 sb = (struct sk_buff *)iov->iov_base;
33755 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33756 #endif /* NS_USE_DESTRUCTORS */
33757 __net_timestamp(hb);
33758 vcc->push(vcc, hb);
33759 - atomic_inc(&vcc->stats->rx);
33760 + atomic_inc_unchecked(&vcc->stats->rx);
33761 }
33762 }
33763
33764 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33765 index 0474a89..06ea4a1 100644
33766 --- a/drivers/atm/solos-pci.c
33767 +++ b/drivers/atm/solos-pci.c
33768 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33769 }
33770 atm_charge(vcc, skb->truesize);
33771 vcc->push(vcc, skb);
33772 - atomic_inc(&vcc->stats->rx);
33773 + atomic_inc_unchecked(&vcc->stats->rx);
33774 break;
33775
33776 case PKT_STATUS:
33777 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33778 vcc = SKB_CB(oldskb)->vcc;
33779
33780 if (vcc) {
33781 - atomic_inc(&vcc->stats->tx);
33782 + atomic_inc_unchecked(&vcc->stats->tx);
33783 solos_pop(vcc, oldskb);
33784 } else {
33785 dev_kfree_skb_irq(oldskb);
33786 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33787 index 0215934..ce9f5b1 100644
33788 --- a/drivers/atm/suni.c
33789 +++ b/drivers/atm/suni.c
33790 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33791
33792
33793 #define ADD_LIMITED(s,v) \
33794 - atomic_add((v),&stats->s); \
33795 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33796 + atomic_add_unchecked((v),&stats->s); \
33797 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33798
33799
33800 static void suni_hz(unsigned long from_timer)
33801 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33802 index 5120a96..e2572bd 100644
33803 --- a/drivers/atm/uPD98402.c
33804 +++ b/drivers/atm/uPD98402.c
33805 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33806 struct sonet_stats tmp;
33807 int error = 0;
33808
33809 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33810 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33811 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33812 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33813 if (zero && !error) {
33814 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33815
33816
33817 #define ADD_LIMITED(s,v) \
33818 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33819 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33820 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33821 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33822 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33823 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33824
33825
33826 static void stat_event(struct atm_dev *dev)
33827 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33828 if (reason & uPD98402_INT_PFM) stat_event(dev);
33829 if (reason & uPD98402_INT_PCO) {
33830 (void) GET(PCOCR); /* clear interrupt cause */
33831 - atomic_add(GET(HECCT),
33832 + atomic_add_unchecked(GET(HECCT),
33833 &PRIV(dev)->sonet_stats.uncorr_hcs);
33834 }
33835 if ((reason & uPD98402_INT_RFO) &&
33836 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33837 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33838 uPD98402_INT_LOS),PIMR); /* enable them */
33839 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33840 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33841 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33842 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33843 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33844 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33845 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33846 return 0;
33847 }
33848
33849 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33850 index 969c3c2..9b72956 100644
33851 --- a/drivers/atm/zatm.c
33852 +++ b/drivers/atm/zatm.c
33853 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33854 }
33855 if (!size) {
33856 dev_kfree_skb_irq(skb);
33857 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33858 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33859 continue;
33860 }
33861 if (!atm_charge(vcc,skb->truesize)) {
33862 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33863 skb->len = size;
33864 ATM_SKB(skb)->vcc = vcc;
33865 vcc->push(vcc,skb);
33866 - atomic_inc(&vcc->stats->rx);
33867 + atomic_inc_unchecked(&vcc->stats->rx);
33868 }
33869 zout(pos & 0xffff,MTA(mbx));
33870 #if 0 /* probably a stupid idea */
33871 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33872 skb_queue_head(&zatm_vcc->backlog,skb);
33873 break;
33874 }
33875 - atomic_inc(&vcc->stats->tx);
33876 + atomic_inc_unchecked(&vcc->stats->tx);
33877 wake_up(&zatm_vcc->tx_wait);
33878 }
33879
33880 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33881 index 6856303..0602d70 100644
33882 --- a/drivers/base/bus.c
33883 +++ b/drivers/base/bus.c
33884 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33885 return -EINVAL;
33886
33887 mutex_lock(&subsys->p->mutex);
33888 - list_add_tail(&sif->node, &subsys->p->interfaces);
33889 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33890 if (sif->add_dev) {
33891 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33892 while ((dev = subsys_dev_iter_next(&iter)))
33893 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33894 subsys = sif->subsys;
33895
33896 mutex_lock(&subsys->p->mutex);
33897 - list_del_init(&sif->node);
33898 + pax_list_del_init((struct list_head *)&sif->node);
33899 if (sif->remove_dev) {
33900 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33901 while ((dev = subsys_dev_iter_next(&iter)))
33902 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33903 index 17cf7ca..7e553e1 100644
33904 --- a/drivers/base/devtmpfs.c
33905 +++ b/drivers/base/devtmpfs.c
33906 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
33907 if (!thread)
33908 return 0;
33909
33910 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33911 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33912 if (err)
33913 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33914 else
33915 diff --git a/drivers/base/node.c b/drivers/base/node.c
33916 index fac124a..66bd4ab 100644
33917 --- a/drivers/base/node.c
33918 +++ b/drivers/base/node.c
33919 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33920 struct node_attr {
33921 struct device_attribute attr;
33922 enum node_states state;
33923 -};
33924 +} __do_const;
33925
33926 static ssize_t show_node_state(struct device *dev,
33927 struct device_attribute *attr, char *buf)
33928 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33929 index acc3a8d..981c236 100644
33930 --- a/drivers/base/power/domain.c
33931 +++ b/drivers/base/power/domain.c
33932 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33933 {
33934 struct cpuidle_driver *cpuidle_drv;
33935 struct gpd_cpu_data *cpu_data;
33936 - struct cpuidle_state *idle_state;
33937 + cpuidle_state_no_const *idle_state;
33938 int ret = 0;
33939
33940 if (IS_ERR_OR_NULL(genpd) || state < 0)
33941 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33942 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33943 {
33944 struct gpd_cpu_data *cpu_data;
33945 - struct cpuidle_state *idle_state;
33946 + cpuidle_state_no_const *idle_state;
33947 int ret = 0;
33948
33949 if (IS_ERR_OR_NULL(genpd))
33950 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33951 index e6ee5e8..98ad7fc 100644
33952 --- a/drivers/base/power/wakeup.c
33953 +++ b/drivers/base/power/wakeup.c
33954 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33955 * They need to be modified together atomically, so it's better to use one
33956 * atomic variable to hold them both.
33957 */
33958 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33959 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33960
33961 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33962 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33963
33964 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33965 {
33966 - unsigned int comb = atomic_read(&combined_event_count);
33967 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33968
33969 *cnt = (comb >> IN_PROGRESS_BITS);
33970 *inpr = comb & MAX_IN_PROGRESS;
33971 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33972 ws->start_prevent_time = ws->last_time;
33973
33974 /* Increment the counter of events in progress. */
33975 - cec = atomic_inc_return(&combined_event_count);
33976 + cec = atomic_inc_return_unchecked(&combined_event_count);
33977
33978 trace_wakeup_source_activate(ws->name, cec);
33979 }
33980 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33981 * Increment the counter of registered wakeup events and decrement the
33982 * couter of wakeup events in progress simultaneously.
33983 */
33984 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33985 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33986 trace_wakeup_source_deactivate(ws->name, cec);
33987
33988 split_counters(&cnt, &inpr);
33989 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33990 index e8d11b6..7b1b36f 100644
33991 --- a/drivers/base/syscore.c
33992 +++ b/drivers/base/syscore.c
33993 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33994 void register_syscore_ops(struct syscore_ops *ops)
33995 {
33996 mutex_lock(&syscore_ops_lock);
33997 - list_add_tail(&ops->node, &syscore_ops_list);
33998 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33999 mutex_unlock(&syscore_ops_lock);
34000 }
34001 EXPORT_SYMBOL_GPL(register_syscore_ops);
34002 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
34003 void unregister_syscore_ops(struct syscore_ops *ops)
34004 {
34005 mutex_lock(&syscore_ops_lock);
34006 - list_del(&ops->node);
34007 + pax_list_del((struct list_head *)&ops->node);
34008 mutex_unlock(&syscore_ops_lock);
34009 }
34010 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
34011 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
34012 index ade58bc..867143d 100644
34013 --- a/drivers/block/cciss.c
34014 +++ b/drivers/block/cciss.c
34015 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
34016 int err;
34017 u32 cp;
34018
34019 + memset(&arg64, 0, sizeof(arg64));
34020 +
34021 err = 0;
34022 err |=
34023 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
34024 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
34025 while (!list_empty(&h->reqQ)) {
34026 c = list_entry(h->reqQ.next, CommandList_struct, list);
34027 /* can't do anything if fifo is full */
34028 - if ((h->access.fifo_full(h))) {
34029 + if ((h->access->fifo_full(h))) {
34030 dev_warn(&h->pdev->dev, "fifo full\n");
34031 break;
34032 }
34033 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
34034 h->Qdepth--;
34035
34036 /* Tell the controller execute command */
34037 - h->access.submit_command(h, c);
34038 + h->access->submit_command(h, c);
34039
34040 /* Put job onto the completed Q */
34041 addQ(&h->cmpQ, c);
34042 @@ -3441,17 +3443,17 @@ startio:
34043
34044 static inline unsigned long get_next_completion(ctlr_info_t *h)
34045 {
34046 - return h->access.command_completed(h);
34047 + return h->access->command_completed(h);
34048 }
34049
34050 static inline int interrupt_pending(ctlr_info_t *h)
34051 {
34052 - return h->access.intr_pending(h);
34053 + return h->access->intr_pending(h);
34054 }
34055
34056 static inline long interrupt_not_for_us(ctlr_info_t *h)
34057 {
34058 - return ((h->access.intr_pending(h) == 0) ||
34059 + return ((h->access->intr_pending(h) == 0) ||
34060 (h->interrupts_enabled == 0));
34061 }
34062
34063 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
34064 u32 a;
34065
34066 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
34067 - return h->access.command_completed(h);
34068 + return h->access->command_completed(h);
34069
34070 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
34071 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
34072 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
34073 trans_support & CFGTBL_Trans_use_short_tags);
34074
34075 /* Change the access methods to the performant access methods */
34076 - h->access = SA5_performant_access;
34077 + h->access = &SA5_performant_access;
34078 h->transMethod = CFGTBL_Trans_Performant;
34079
34080 return;
34081 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
34082 if (prod_index < 0)
34083 return -ENODEV;
34084 h->product_name = products[prod_index].product_name;
34085 - h->access = *(products[prod_index].access);
34086 + h->access = products[prod_index].access;
34087
34088 if (cciss_board_disabled(h)) {
34089 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
34090 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
34091 }
34092
34093 /* make sure the board interrupts are off */
34094 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
34095 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
34096 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
34097 if (rc)
34098 goto clean2;
34099 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
34100 * fake ones to scoop up any residual completions.
34101 */
34102 spin_lock_irqsave(&h->lock, flags);
34103 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
34104 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
34105 spin_unlock_irqrestore(&h->lock, flags);
34106 free_irq(h->intr[h->intr_mode], h);
34107 rc = cciss_request_irq(h, cciss_msix_discard_completions,
34108 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
34109 dev_info(&h->pdev->dev, "Board READY.\n");
34110 dev_info(&h->pdev->dev,
34111 "Waiting for stale completions to drain.\n");
34112 - h->access.set_intr_mask(h, CCISS_INTR_ON);
34113 + h->access->set_intr_mask(h, CCISS_INTR_ON);
34114 msleep(10000);
34115 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
34116 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
34117
34118 rc = controller_reset_failed(h->cfgtable);
34119 if (rc)
34120 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
34121 cciss_scsi_setup(h);
34122
34123 /* Turn the interrupts on so we can service requests */
34124 - h->access.set_intr_mask(h, CCISS_INTR_ON);
34125 + h->access->set_intr_mask(h, CCISS_INTR_ON);
34126
34127 /* Get the firmware version */
34128 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
34129 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
34130 kfree(flush_buf);
34131 if (return_code != IO_OK)
34132 dev_warn(&h->pdev->dev, "Error flushing cache\n");
34133 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
34134 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
34135 free_irq(h->intr[h->intr_mode], h);
34136 }
34137
34138 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
34139 index 7fda30e..eb5dfe0 100644
34140 --- a/drivers/block/cciss.h
34141 +++ b/drivers/block/cciss.h
34142 @@ -101,7 +101,7 @@ struct ctlr_info
34143 /* information about each logical volume */
34144 drive_info_struct *drv[CISS_MAX_LUN];
34145
34146 - struct access_method access;
34147 + struct access_method *access;
34148
34149 /* queue and queue Info */
34150 struct list_head reqQ;
34151 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
34152 index 3f08713..56a586a 100644
34153 --- a/drivers/block/cpqarray.c
34154 +++ b/drivers/block/cpqarray.c
34155 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
34156 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
34157 goto Enomem4;
34158 }
34159 - hba[i]->access.set_intr_mask(hba[i], 0);
34160 + hba[i]->access->set_intr_mask(hba[i], 0);
34161 if (request_irq(hba[i]->intr, do_ida_intr,
34162 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
34163 {
34164 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
34165 add_timer(&hba[i]->timer);
34166
34167 /* Enable IRQ now that spinlock and rate limit timer are set up */
34168 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
34169 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
34170
34171 for(j=0; j<NWD; j++) {
34172 struct gendisk *disk = ida_gendisk[i][j];
34173 @@ -694,7 +694,7 @@ DBGINFO(
34174 for(i=0; i<NR_PRODUCTS; i++) {
34175 if (board_id == products[i].board_id) {
34176 c->product_name = products[i].product_name;
34177 - c->access = *(products[i].access);
34178 + c->access = products[i].access;
34179 break;
34180 }
34181 }
34182 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
34183 hba[ctlr]->intr = intr;
34184 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
34185 hba[ctlr]->product_name = products[j].product_name;
34186 - hba[ctlr]->access = *(products[j].access);
34187 + hba[ctlr]->access = products[j].access;
34188 hba[ctlr]->ctlr = ctlr;
34189 hba[ctlr]->board_id = board_id;
34190 hba[ctlr]->pci_dev = NULL; /* not PCI */
34191 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
34192
34193 while((c = h->reqQ) != NULL) {
34194 /* Can't do anything if we're busy */
34195 - if (h->access.fifo_full(h) == 0)
34196 + if (h->access->fifo_full(h) == 0)
34197 return;
34198
34199 /* Get the first entry from the request Q */
34200 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
34201 h->Qdepth--;
34202
34203 /* Tell the controller to do our bidding */
34204 - h->access.submit_command(h, c);
34205 + h->access->submit_command(h, c);
34206
34207 /* Get onto the completion Q */
34208 addQ(&h->cmpQ, c);
34209 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
34210 unsigned long flags;
34211 __u32 a,a1;
34212
34213 - istat = h->access.intr_pending(h);
34214 + istat = h->access->intr_pending(h);
34215 /* Is this interrupt for us? */
34216 if (istat == 0)
34217 return IRQ_NONE;
34218 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
34219 */
34220 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
34221 if (istat & FIFO_NOT_EMPTY) {
34222 - while((a = h->access.command_completed(h))) {
34223 + while((a = h->access->command_completed(h))) {
34224 a1 = a; a &= ~3;
34225 if ((c = h->cmpQ) == NULL)
34226 {
34227 @@ -1449,11 +1449,11 @@ static int sendcmd(
34228 /*
34229 * Disable interrupt
34230 */
34231 - info_p->access.set_intr_mask(info_p, 0);
34232 + info_p->access->set_intr_mask(info_p, 0);
34233 /* Make sure there is room in the command FIFO */
34234 /* Actually it should be completely empty at this time. */
34235 for (i = 200000; i > 0; i--) {
34236 - temp = info_p->access.fifo_full(info_p);
34237 + temp = info_p->access->fifo_full(info_p);
34238 if (temp != 0) {
34239 break;
34240 }
34241 @@ -1466,7 +1466,7 @@ DBG(
34242 /*
34243 * Send the cmd
34244 */
34245 - info_p->access.submit_command(info_p, c);
34246 + info_p->access->submit_command(info_p, c);
34247 complete = pollcomplete(ctlr);
34248
34249 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
34250 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
34251 * we check the new geometry. Then turn interrupts back on when
34252 * we're done.
34253 */
34254 - host->access.set_intr_mask(host, 0);
34255 + host->access->set_intr_mask(host, 0);
34256 getgeometry(ctlr);
34257 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
34258 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
34259
34260 for(i=0; i<NWD; i++) {
34261 struct gendisk *disk = ida_gendisk[ctlr][i];
34262 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
34263 /* Wait (up to 2 seconds) for a command to complete */
34264
34265 for (i = 200000; i > 0; i--) {
34266 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
34267 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
34268 if (done == 0) {
34269 udelay(10); /* a short fixed delay */
34270 } else
34271 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
34272 index be73e9d..7fbf140 100644
34273 --- a/drivers/block/cpqarray.h
34274 +++ b/drivers/block/cpqarray.h
34275 @@ -99,7 +99,7 @@ struct ctlr_info {
34276 drv_info_t drv[NWD];
34277 struct proc_dir_entry *proc;
34278
34279 - struct access_method access;
34280 + struct access_method *access;
34281
34282 cmdlist_t *reqQ;
34283 cmdlist_t *cmpQ;
34284 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
34285 index 6b51afa..17e1191 100644
34286 --- a/drivers/block/drbd/drbd_int.h
34287 +++ b/drivers/block/drbd/drbd_int.h
34288 @@ -582,7 +582,7 @@ struct drbd_epoch {
34289 struct drbd_tconn *tconn;
34290 struct list_head list;
34291 unsigned int barrier_nr;
34292 - atomic_t epoch_size; /* increased on every request added. */
34293 + atomic_unchecked_t epoch_size; /* increased on every request added. */
34294 atomic_t active; /* increased on every req. added, and dec on every finished. */
34295 unsigned long flags;
34296 };
34297 @@ -1011,7 +1011,7 @@ struct drbd_conf {
34298 int al_tr_cycle;
34299 int al_tr_pos; /* position of the next transaction in the journal */
34300 wait_queue_head_t seq_wait;
34301 - atomic_t packet_seq;
34302 + atomic_unchecked_t packet_seq;
34303 unsigned int peer_seq;
34304 spinlock_t peer_seq_lock;
34305 unsigned int minor;
34306 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
34307 char __user *uoptval;
34308 int err;
34309
34310 - uoptval = (char __user __force *)optval;
34311 + uoptval = (char __force_user *)optval;
34312
34313 set_fs(KERNEL_DS);
34314 if (level == SOL_SOCKET)
34315 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
34316 index 8c13eeb..217adee 100644
34317 --- a/drivers/block/drbd/drbd_main.c
34318 +++ b/drivers/block/drbd/drbd_main.c
34319 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
34320 p->sector = sector;
34321 p->block_id = block_id;
34322 p->blksize = blksize;
34323 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
34324 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
34325 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
34326 }
34327
34328 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
34329 return -EIO;
34330 p->sector = cpu_to_be64(req->i.sector);
34331 p->block_id = (unsigned long)req;
34332 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
34333 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
34334 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
34335 if (mdev->state.conn >= C_SYNC_SOURCE &&
34336 mdev->state.conn <= C_PAUSED_SYNC_T)
34337 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
34338 {
34339 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
34340
34341 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
34342 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
34343 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
34344 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
34345 kfree(tconn->current_epoch);
34346
34347 idr_destroy(&tconn->volumes);
34348 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
34349 index a9eccfc..f5efe87 100644
34350 --- a/drivers/block/drbd/drbd_receiver.c
34351 +++ b/drivers/block/drbd/drbd_receiver.c
34352 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
34353 {
34354 int err;
34355
34356 - atomic_set(&mdev->packet_seq, 0);
34357 + atomic_set_unchecked(&mdev->packet_seq, 0);
34358 mdev->peer_seq = 0;
34359
34360 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
34361 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
34362 do {
34363 next_epoch = NULL;
34364
34365 - epoch_size = atomic_read(&epoch->epoch_size);
34366 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
34367
34368 switch (ev & ~EV_CLEANUP) {
34369 case EV_PUT:
34370 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
34371 rv = FE_DESTROYED;
34372 } else {
34373 epoch->flags = 0;
34374 - atomic_set(&epoch->epoch_size, 0);
34375 + atomic_set_unchecked(&epoch->epoch_size, 0);
34376 /* atomic_set(&epoch->active, 0); is already zero */
34377 if (rv == FE_STILL_LIVE)
34378 rv = FE_RECYCLED;
34379 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
34380 conn_wait_active_ee_empty(tconn);
34381 drbd_flush(tconn);
34382
34383 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
34384 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
34385 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
34386 if (epoch)
34387 break;
34388 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
34389 }
34390
34391 epoch->flags = 0;
34392 - atomic_set(&epoch->epoch_size, 0);
34393 + atomic_set_unchecked(&epoch->epoch_size, 0);
34394 atomic_set(&epoch->active, 0);
34395
34396 spin_lock(&tconn->epoch_lock);
34397 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
34398 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
34399 list_add(&epoch->list, &tconn->current_epoch->list);
34400 tconn->current_epoch = epoch;
34401 tconn->epochs++;
34402 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
34403
34404 err = wait_for_and_update_peer_seq(mdev, peer_seq);
34405 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
34406 - atomic_inc(&tconn->current_epoch->epoch_size);
34407 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
34408 err2 = drbd_drain_block(mdev, pi->size);
34409 if (!err)
34410 err = err2;
34411 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
34412
34413 spin_lock(&tconn->epoch_lock);
34414 peer_req->epoch = tconn->current_epoch;
34415 - atomic_inc(&peer_req->epoch->epoch_size);
34416 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
34417 atomic_inc(&peer_req->epoch->active);
34418 spin_unlock(&tconn->epoch_lock);
34419
34420 @@ -4346,7 +4346,7 @@ struct data_cmd {
34421 int expect_payload;
34422 size_t pkt_size;
34423 int (*fn)(struct drbd_tconn *, struct packet_info *);
34424 -};
34425 +} __do_const;
34426
34427 static struct data_cmd drbd_cmd_handler[] = {
34428 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
34429 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
34430 if (!list_empty(&tconn->current_epoch->list))
34431 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
34432 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
34433 - atomic_set(&tconn->current_epoch->epoch_size, 0);
34434 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
34435 tconn->send.seen_any_write_yet = false;
34436
34437 conn_info(tconn, "Connection closed\n");
34438 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
34439 struct asender_cmd {
34440 size_t pkt_size;
34441 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
34442 -};
34443 +} __do_const;
34444
34445 static struct asender_cmd asender_tbl[] = {
34446 [P_PING] = { 0, got_Ping },
34447 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
34448 index f74f2c0..bb668af 100644
34449 --- a/drivers/block/loop.c
34450 +++ b/drivers/block/loop.c
34451 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
34452 mm_segment_t old_fs = get_fs();
34453
34454 set_fs(get_ds());
34455 - bw = file->f_op->write(file, buf, len, &pos);
34456 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
34457 set_fs(old_fs);
34458 if (likely(bw == len))
34459 return 0;
34460 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
34461 index d620b44..587561e 100644
34462 --- a/drivers/cdrom/cdrom.c
34463 +++ b/drivers/cdrom/cdrom.c
34464 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
34465 ENSURE(reset, CDC_RESET);
34466 ENSURE(generic_packet, CDC_GENERIC_PACKET);
34467 cdi->mc_flags = 0;
34468 - cdo->n_minors = 0;
34469 cdi->options = CDO_USE_FFLAGS;
34470
34471 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
34472 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
34473 else
34474 cdi->cdda_method = CDDA_OLD;
34475
34476 - if (!cdo->generic_packet)
34477 - cdo->generic_packet = cdrom_dummy_generic_packet;
34478 + if (!cdo->generic_packet) {
34479 + pax_open_kernel();
34480 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
34481 + pax_close_kernel();
34482 + }
34483
34484 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
34485 mutex_lock(&cdrom_mutex);
34486 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
34487 if (cdi->exit)
34488 cdi->exit(cdi);
34489
34490 - cdi->ops->n_minors--;
34491 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
34492 }
34493
34494 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
34495 index d59cdcb..11afddf 100644
34496 --- a/drivers/cdrom/gdrom.c
34497 +++ b/drivers/cdrom/gdrom.c
34498 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
34499 .audio_ioctl = gdrom_audio_ioctl,
34500 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
34501 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
34502 - .n_minors = 1,
34503 };
34504
34505 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
34506 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
34507 index 72bedad..8181ce1 100644
34508 --- a/drivers/char/Kconfig
34509 +++ b/drivers/char/Kconfig
34510 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
34511
34512 config DEVKMEM
34513 bool "/dev/kmem virtual device support"
34514 - default y
34515 + default n
34516 + depends on !GRKERNSEC_KMEM
34517 help
34518 Say Y here if you want to support the /dev/kmem device. The
34519 /dev/kmem device is rarely used, but can be used for certain
34520 @@ -581,6 +582,7 @@ config DEVPORT
34521 bool
34522 depends on !M68K
34523 depends on ISA || PCI
34524 + depends on !GRKERNSEC_KMEM
34525 default y
34526
34527 source "drivers/s390/char/Kconfig"
34528 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
34529 index 2e04433..22afc64 100644
34530 --- a/drivers/char/agp/frontend.c
34531 +++ b/drivers/char/agp/frontend.c
34532 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
34533 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
34534 return -EFAULT;
34535
34536 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
34537 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
34538 return -EFAULT;
34539
34540 client = agp_find_client_by_pid(reserve.pid);
34541 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
34542 index 21cb980..f15107c 100644
34543 --- a/drivers/char/genrtc.c
34544 +++ b/drivers/char/genrtc.c
34545 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
34546 switch (cmd) {
34547
34548 case RTC_PLL_GET:
34549 + memset(&pll, 0, sizeof(pll));
34550 if (get_rtc_pll(&pll))
34551 return -EINVAL;
34552 else
34553 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
34554 index 615d262..15d5c9d 100644
34555 --- a/drivers/char/hpet.c
34556 +++ b/drivers/char/hpet.c
34557 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
34558 }
34559
34560 static int
34561 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
34562 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
34563 struct hpet_info *info)
34564 {
34565 struct hpet_timer __iomem *timer;
34566 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
34567 index 053201b0..8335cce 100644
34568 --- a/drivers/char/ipmi/ipmi_msghandler.c
34569 +++ b/drivers/char/ipmi/ipmi_msghandler.c
34570 @@ -420,7 +420,7 @@ struct ipmi_smi {
34571 struct proc_dir_entry *proc_dir;
34572 char proc_dir_name[10];
34573
34574 - atomic_t stats[IPMI_NUM_STATS];
34575 + atomic_unchecked_t stats[IPMI_NUM_STATS];
34576
34577 /*
34578 * run_to_completion duplicate of smb_info, smi_info
34579 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
34580
34581
34582 #define ipmi_inc_stat(intf, stat) \
34583 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
34584 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
34585 #define ipmi_get_stat(intf, stat) \
34586 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
34587 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
34588
34589 static int is_lan_addr(struct ipmi_addr *addr)
34590 {
34591 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
34592 INIT_LIST_HEAD(&intf->cmd_rcvrs);
34593 init_waitqueue_head(&intf->waitq);
34594 for (i = 0; i < IPMI_NUM_STATS; i++)
34595 - atomic_set(&intf->stats[i], 0);
34596 + atomic_set_unchecked(&intf->stats[i], 0);
34597
34598 intf->proc_dir = NULL;
34599
34600 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
34601 index 1c7fdcd..4899100 100644
34602 --- a/drivers/char/ipmi/ipmi_si_intf.c
34603 +++ b/drivers/char/ipmi/ipmi_si_intf.c
34604 @@ -275,7 +275,7 @@ struct smi_info {
34605 unsigned char slave_addr;
34606
34607 /* Counters and things for the proc filesystem. */
34608 - atomic_t stats[SI_NUM_STATS];
34609 + atomic_unchecked_t stats[SI_NUM_STATS];
34610
34611 struct task_struct *thread;
34612
34613 @@ -284,9 +284,9 @@ struct smi_info {
34614 };
34615
34616 #define smi_inc_stat(smi, stat) \
34617 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
34618 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
34619 #define smi_get_stat(smi, stat) \
34620 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
34621 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
34622
34623 #define SI_MAX_PARMS 4
34624
34625 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
34626 atomic_set(&new_smi->req_events, 0);
34627 new_smi->run_to_completion = 0;
34628 for (i = 0; i < SI_NUM_STATS; i++)
34629 - atomic_set(&new_smi->stats[i], 0);
34630 + atomic_set_unchecked(&new_smi->stats[i], 0);
34631
34632 new_smi->interrupt_disabled = 1;
34633 atomic_set(&new_smi->stop_operation, 0);
34634 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34635 index c6fa3bc..4ca3e42 100644
34636 --- a/drivers/char/mem.c
34637 +++ b/drivers/char/mem.c
34638 @@ -18,6 +18,7 @@
34639 #include <linux/raw.h>
34640 #include <linux/tty.h>
34641 #include <linux/capability.h>
34642 +#include <linux/security.h>
34643 #include <linux/ptrace.h>
34644 #include <linux/device.h>
34645 #include <linux/highmem.h>
34646 @@ -37,6 +38,10 @@
34647
34648 #define DEVPORT_MINOR 4
34649
34650 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34651 +extern const struct file_operations grsec_fops;
34652 +#endif
34653 +
34654 static inline unsigned long size_inside_page(unsigned long start,
34655 unsigned long size)
34656 {
34657 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34658
34659 while (cursor < to) {
34660 if (!devmem_is_allowed(pfn)) {
34661 +#ifdef CONFIG_GRKERNSEC_KMEM
34662 + gr_handle_mem_readwrite(from, to);
34663 +#else
34664 printk(KERN_INFO
34665 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34666 current->comm, from, to);
34667 +#endif
34668 return 0;
34669 }
34670 cursor += PAGE_SIZE;
34671 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34672 }
34673 return 1;
34674 }
34675 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34676 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34677 +{
34678 + return 0;
34679 +}
34680 #else
34681 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34682 {
34683 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34684
34685 while (count > 0) {
34686 unsigned long remaining;
34687 + char *temp;
34688
34689 sz = size_inside_page(p, count);
34690
34691 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34692 if (!ptr)
34693 return -EFAULT;
34694
34695 - remaining = copy_to_user(buf, ptr, sz);
34696 +#ifdef CONFIG_PAX_USERCOPY
34697 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34698 + if (!temp) {
34699 + unxlate_dev_mem_ptr(p, ptr);
34700 + return -ENOMEM;
34701 + }
34702 + memcpy(temp, ptr, sz);
34703 +#else
34704 + temp = ptr;
34705 +#endif
34706 +
34707 + remaining = copy_to_user(buf, temp, sz);
34708 +
34709 +#ifdef CONFIG_PAX_USERCOPY
34710 + kfree(temp);
34711 +#endif
34712 +
34713 unxlate_dev_mem_ptr(p, ptr);
34714 if (remaining)
34715 return -EFAULT;
34716 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34717 size_t count, loff_t *ppos)
34718 {
34719 unsigned long p = *ppos;
34720 - ssize_t low_count, read, sz;
34721 + ssize_t low_count, read, sz, err = 0;
34722 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34723 - int err = 0;
34724
34725 read = 0;
34726 if (p < (unsigned long) high_memory) {
34727 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34728 }
34729 #endif
34730 while (low_count > 0) {
34731 + char *temp;
34732 +
34733 sz = size_inside_page(p, low_count);
34734
34735 /*
34736 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34737 */
34738 kbuf = xlate_dev_kmem_ptr((char *)p);
34739
34740 - if (copy_to_user(buf, kbuf, sz))
34741 +#ifdef CONFIG_PAX_USERCOPY
34742 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34743 + if (!temp)
34744 + return -ENOMEM;
34745 + memcpy(temp, kbuf, sz);
34746 +#else
34747 + temp = kbuf;
34748 +#endif
34749 +
34750 + err = copy_to_user(buf, temp, sz);
34751 +
34752 +#ifdef CONFIG_PAX_USERCOPY
34753 + kfree(temp);
34754 +#endif
34755 +
34756 + if (err)
34757 return -EFAULT;
34758 buf += sz;
34759 p += sz;
34760 @@ -833,6 +880,9 @@ static const struct memdev {
34761 #ifdef CONFIG_CRASH_DUMP
34762 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34763 #endif
34764 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34765 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34766 +#endif
34767 };
34768
34769 static int memory_open(struct inode *inode, struct file *filp)
34770 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34771 index 9df78e2..01ba9ae 100644
34772 --- a/drivers/char/nvram.c
34773 +++ b/drivers/char/nvram.c
34774 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34775
34776 spin_unlock_irq(&rtc_lock);
34777
34778 - if (copy_to_user(buf, contents, tmp - contents))
34779 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34780 return -EFAULT;
34781
34782 *ppos = i;
34783 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34784 index b66eaa0..2619d1b 100644
34785 --- a/drivers/char/pcmcia/synclink_cs.c
34786 +++ b/drivers/char/pcmcia/synclink_cs.c
34787 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34788
34789 if (debug_level >= DEBUG_LEVEL_INFO)
34790 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34791 - __FILE__,__LINE__, info->device_name, port->count);
34792 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
34793
34794 - WARN_ON(!port->count);
34795 + WARN_ON(!atomic_read(&port->count));
34796
34797 if (tty_port_close_start(port, tty, filp) == 0)
34798 goto cleanup;
34799 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34800 cleanup:
34801 if (debug_level >= DEBUG_LEVEL_INFO)
34802 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
34803 - tty->driver->name, port->count);
34804 + tty->driver->name, atomic_read(&port->count));
34805 }
34806
34807 /* Wait until the transmitter is empty.
34808 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34809
34810 if (debug_level >= DEBUG_LEVEL_INFO)
34811 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34812 - __FILE__,__LINE__,tty->driver->name, port->count);
34813 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
34814
34815 /* If port is closing, signal caller to try again */
34816 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34817 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34818 goto cleanup;
34819 }
34820 spin_lock(&port->lock);
34821 - port->count++;
34822 + atomic_inc(&port->count);
34823 spin_unlock(&port->lock);
34824 spin_unlock_irqrestore(&info->netlock, flags);
34825
34826 - if (port->count == 1) {
34827 + if (atomic_read(&port->count) == 1) {
34828 /* 1st open on this device, init hardware */
34829 retval = startup(info, tty);
34830 if (retval < 0)
34831 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34832 unsigned short new_crctype;
34833
34834 /* return error if TTY interface open */
34835 - if (info->port.count)
34836 + if (atomic_read(&info->port.count))
34837 return -EBUSY;
34838
34839 switch (encoding)
34840 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
34841
34842 /* arbitrate between network and tty opens */
34843 spin_lock_irqsave(&info->netlock, flags);
34844 - if (info->port.count != 0 || info->netcount != 0) {
34845 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34846 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34847 spin_unlock_irqrestore(&info->netlock, flags);
34848 return -EBUSY;
34849 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34850 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
34851
34852 /* return error if TTY interface open */
34853 - if (info->port.count)
34854 + if (atomic_read(&info->port.count))
34855 return -EBUSY;
34856
34857 if (cmd != SIOCWANDEV)
34858 diff --git a/drivers/char/random.c b/drivers/char/random.c
34859 index 57d4b15..253207b 100644
34860 --- a/drivers/char/random.c
34861 +++ b/drivers/char/random.c
34862 @@ -272,8 +272,13 @@
34863 /*
34864 * Configuration information
34865 */
34866 +#ifdef CONFIG_GRKERNSEC_RANDNET
34867 +#define INPUT_POOL_WORDS 512
34868 +#define OUTPUT_POOL_WORDS 128
34869 +#else
34870 #define INPUT_POOL_WORDS 128
34871 #define OUTPUT_POOL_WORDS 32
34872 +#endif
34873 #define SEC_XFER_SIZE 512
34874 #define EXTRACT_SIZE 10
34875
34876 @@ -313,10 +318,17 @@ static struct poolinfo {
34877 int poolwords;
34878 int tap1, tap2, tap3, tap4, tap5;
34879 } poolinfo_table[] = {
34880 +#ifdef CONFIG_GRKERNSEC_RANDNET
34881 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34882 + { 512, 411, 308, 208, 104, 1 },
34883 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34884 + { 128, 103, 76, 51, 25, 1 },
34885 +#else
34886 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34887 { 128, 103, 76, 51, 25, 1 },
34888 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34889 { 32, 26, 20, 14, 7, 1 },
34890 +#endif
34891 #if 0
34892 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34893 { 2048, 1638, 1231, 819, 411, 1 },
34894 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34895 input_rotate += i ? 7 : 14;
34896 }
34897
34898 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34899 - ACCESS_ONCE(r->add_ptr) = i;
34900 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34901 + ACCESS_ONCE_RW(r->add_ptr) = i;
34902 smp_wmb();
34903
34904 if (out)
34905 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34906
34907 extract_buf(r, tmp);
34908 i = min_t(int, nbytes, EXTRACT_SIZE);
34909 - if (copy_to_user(buf, tmp, i)) {
34910 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34911 ret = -EFAULT;
34912 break;
34913 }
34914 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34915 #include <linux/sysctl.h>
34916
34917 static int min_read_thresh = 8, min_write_thresh;
34918 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34919 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34920 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34921 static char sysctl_bootid[16];
34922
34923 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
34924 static int proc_do_uuid(ctl_table *table, int write,
34925 void __user *buffer, size_t *lenp, loff_t *ppos)
34926 {
34927 - ctl_table fake_table;
34928 + ctl_table_no_const fake_table;
34929 unsigned char buf[64], tmp_uuid[16], *uuid;
34930
34931 uuid = table->data;
34932 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34933 index d780295..b29f3a8 100644
34934 --- a/drivers/char/sonypi.c
34935 +++ b/drivers/char/sonypi.c
34936 @@ -54,6 +54,7 @@
34937
34938 #include <asm/uaccess.h>
34939 #include <asm/io.h>
34940 +#include <asm/local.h>
34941
34942 #include <linux/sonypi.h>
34943
34944 @@ -490,7 +491,7 @@ static struct sonypi_device {
34945 spinlock_t fifo_lock;
34946 wait_queue_head_t fifo_proc_list;
34947 struct fasync_struct *fifo_async;
34948 - int open_count;
34949 + local_t open_count;
34950 int model;
34951 struct input_dev *input_jog_dev;
34952 struct input_dev *input_key_dev;
34953 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34954 static int sonypi_misc_release(struct inode *inode, struct file *file)
34955 {
34956 mutex_lock(&sonypi_device.lock);
34957 - sonypi_device.open_count--;
34958 + local_dec(&sonypi_device.open_count);
34959 mutex_unlock(&sonypi_device.lock);
34960 return 0;
34961 }
34962 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34963 {
34964 mutex_lock(&sonypi_device.lock);
34965 /* Flush input queue on first open */
34966 - if (!sonypi_device.open_count)
34967 + if (!local_read(&sonypi_device.open_count))
34968 kfifo_reset(&sonypi_device.fifo);
34969 - sonypi_device.open_count++;
34970 + local_inc(&sonypi_device.open_count);
34971 mutex_unlock(&sonypi_device.lock);
34972
34973 return 0;
34974 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
34975 index 93211df..c7805f7 100644
34976 --- a/drivers/char/tpm/tpm.c
34977 +++ b/drivers/char/tpm/tpm.c
34978 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
34979 chip->vendor.req_complete_val)
34980 goto out_recv;
34981
34982 - if ((status == chip->vendor.req_canceled)) {
34983 + if (status == chip->vendor.req_canceled) {
34984 dev_err(chip->dev, "Operation Canceled\n");
34985 rc = -ECANCELED;
34986 goto out;
34987 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34988 index 56051d0..11cf3b7 100644
34989 --- a/drivers/char/tpm/tpm_acpi.c
34990 +++ b/drivers/char/tpm/tpm_acpi.c
34991 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34992 virt = acpi_os_map_memory(start, len);
34993 if (!virt) {
34994 kfree(log->bios_event_log);
34995 + log->bios_event_log = NULL;
34996 printk("%s: ERROR - Unable to map memory\n", __func__);
34997 return -EIO;
34998 }
34999
35000 - memcpy_fromio(log->bios_event_log, virt, len);
35001 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
35002
35003 acpi_os_unmap_memory(virt, len);
35004 return 0;
35005 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
35006 index 84ddc55..1d32f1e 100644
35007 --- a/drivers/char/tpm/tpm_eventlog.c
35008 +++ b/drivers/char/tpm/tpm_eventlog.c
35009 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
35010 event = addr;
35011
35012 if ((event->event_type == 0 && event->event_size == 0) ||
35013 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
35014 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
35015 return NULL;
35016
35017 return addr;
35018 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
35019 return NULL;
35020
35021 if ((event->event_type == 0 && event->event_size == 0) ||
35022 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
35023 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
35024 return NULL;
35025
35026 (*pos)++;
35027 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
35028 int i;
35029
35030 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
35031 - seq_putc(m, data[i]);
35032 + if (!seq_putc(m, data[i]))
35033 + return -EFAULT;
35034
35035 return 0;
35036 }
35037 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
35038 index a4b7aa0..2faa0bc 100644
35039 --- a/drivers/char/virtio_console.c
35040 +++ b/drivers/char/virtio_console.c
35041 @@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
35042 if (to_user) {
35043 ssize_t ret;
35044
35045 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
35046 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
35047 if (ret)
35048 return -EFAULT;
35049 } else {
35050 @@ -784,7 +784,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
35051 if (!port_has_data(port) && !port->host_connected)
35052 return 0;
35053
35054 - return fill_readbuf(port, ubuf, count, true);
35055 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
35056 }
35057
35058 static int wait_port_writable(struct port *port, bool nonblock)
35059 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
35060 index 8ae1a61..9c00613 100644
35061 --- a/drivers/clocksource/arm_generic.c
35062 +++ b/drivers/clocksource/arm_generic.c
35063 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
35064 return NOTIFY_OK;
35065 }
35066
35067 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
35068 +static struct notifier_block arch_timer_cpu_nb = {
35069 .notifier_call = arch_timer_cpu_notify,
35070 };
35071
35072 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
35073 index 7b0d49d..134fac9 100644
35074 --- a/drivers/cpufreq/acpi-cpufreq.c
35075 +++ b/drivers/cpufreq/acpi-cpufreq.c
35076 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
35077 return sprintf(buf, "%u\n", boost_enabled);
35078 }
35079
35080 -static struct global_attr global_boost = __ATTR(boost, 0644,
35081 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
35082 show_global_boost,
35083 store_global_boost);
35084
35085 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
35086 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
35087 per_cpu(acfreq_data, cpu) = data;
35088
35089 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
35090 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
35091 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
35092 + pax_open_kernel();
35093 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
35094 + pax_close_kernel();
35095 + }
35096
35097 result = acpi_processor_register_performance(data->acpi_data, cpu);
35098 if (result)
35099 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
35100 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
35101 break;
35102 case ACPI_ADR_SPACE_FIXED_HARDWARE:
35103 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
35104 + pax_open_kernel();
35105 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
35106 + pax_close_kernel();
35107 policy->cur = get_cur_freq_on_cpu(cpu);
35108 break;
35109 default:
35110 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
35111 acpi_processor_notify_smm(THIS_MODULE);
35112
35113 /* Check for APERF/MPERF support in hardware */
35114 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
35115 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
35116 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
35117 + pax_open_kernel();
35118 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
35119 + pax_close_kernel();
35120 + }
35121
35122 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
35123 for (i = 0; i < perf->state_count; i++)
35124 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
35125 index 1f93dbd..305cef1 100644
35126 --- a/drivers/cpufreq/cpufreq.c
35127 +++ b/drivers/cpufreq/cpufreq.c
35128 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
35129 return NOTIFY_OK;
35130 }
35131
35132 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
35133 +static struct notifier_block cpufreq_cpu_notifier = {
35134 .notifier_call = cpufreq_cpu_callback,
35135 };
35136
35137 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
35138
35139 pr_debug("trying to register driver %s\n", driver_data->name);
35140
35141 - if (driver_data->setpolicy)
35142 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
35143 + if (driver_data->setpolicy) {
35144 + pax_open_kernel();
35145 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
35146 + pax_close_kernel();
35147 + }
35148
35149 spin_lock_irqsave(&cpufreq_driver_lock, flags);
35150 if (cpufreq_driver) {
35151 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
35152 index 6c5f1d3..c7e2f35e 100644
35153 --- a/drivers/cpufreq/cpufreq_governor.c
35154 +++ b/drivers/cpufreq/cpufreq_governor.c
35155 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
35156 * governor, thus we are bound to jiffes/HZ
35157 */
35158 if (dbs_data->governor == GOV_CONSERVATIVE) {
35159 - struct cs_ops *ops = dbs_data->gov_ops;
35160 + const struct cs_ops *ops = dbs_data->gov_ops;
35161
35162 cpufreq_register_notifier(ops->notifier_block,
35163 CPUFREQ_TRANSITION_NOTIFIER);
35164 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
35165 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
35166 jiffies_to_usecs(10);
35167 } else {
35168 - struct od_ops *ops = dbs_data->gov_ops;
35169 + const struct od_ops *ops = dbs_data->gov_ops;
35170
35171 od_tuners->io_is_busy = ops->io_busy();
35172 }
35173 @@ -268,7 +268,7 @@ second_time:
35174 cs_dbs_info->enable = 1;
35175 cs_dbs_info->requested_freq = policy->cur;
35176 } else {
35177 - struct od_ops *ops = dbs_data->gov_ops;
35178 + const struct od_ops *ops = dbs_data->gov_ops;
35179 od_dbs_info->rate_mult = 1;
35180 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
35181 ops->powersave_bias_init_cpu(cpu);
35182 @@ -289,7 +289,7 @@ second_time:
35183 mutex_destroy(&cpu_cdbs->timer_mutex);
35184 dbs_data->enable--;
35185 if (!dbs_data->enable) {
35186 - struct cs_ops *ops = dbs_data->gov_ops;
35187 + const struct cs_ops *ops = dbs_data->gov_ops;
35188
35189 sysfs_remove_group(cpufreq_global_kobject,
35190 dbs_data->attr_group);
35191 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
35192 index f661654..6c8e638 100644
35193 --- a/drivers/cpufreq/cpufreq_governor.h
35194 +++ b/drivers/cpufreq/cpufreq_governor.h
35195 @@ -142,7 +142,7 @@ struct dbs_data {
35196 void (*gov_check_cpu)(int cpu, unsigned int load);
35197
35198 /* Governor specific ops, see below */
35199 - void *gov_ops;
35200 + const void *gov_ops;
35201 };
35202
35203 /* Governor specific ops, will be passed to dbs_data->gov_ops */
35204 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
35205 index 9d7732b..0b1a793 100644
35206 --- a/drivers/cpufreq/cpufreq_stats.c
35207 +++ b/drivers/cpufreq/cpufreq_stats.c
35208 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
35209 }
35210
35211 /* priority=1 so this will get called before cpufreq_remove_dev */
35212 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
35213 +static struct notifier_block cpufreq_stat_cpu_notifier = {
35214 .notifier_call = cpufreq_stat_cpu_callback,
35215 .priority = 1,
35216 };
35217 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
35218 index 827629c9..0bc6a03 100644
35219 --- a/drivers/cpufreq/p4-clockmod.c
35220 +++ b/drivers/cpufreq/p4-clockmod.c
35221 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
35222 case 0x0F: /* Core Duo */
35223 case 0x16: /* Celeron Core */
35224 case 0x1C: /* Atom */
35225 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
35226 + pax_open_kernel();
35227 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
35228 + pax_close_kernel();
35229 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
35230 case 0x0D: /* Pentium M (Dothan) */
35231 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
35232 + pax_open_kernel();
35233 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
35234 + pax_close_kernel();
35235 /* fall through */
35236 case 0x09: /* Pentium M (Banias) */
35237 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
35238 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
35239
35240 /* on P-4s, the TSC runs with constant frequency independent whether
35241 * throttling is active or not. */
35242 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
35243 + pax_open_kernel();
35244 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
35245 + pax_close_kernel();
35246
35247 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
35248 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
35249 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
35250 index 3a953d5..f5993f6 100644
35251 --- a/drivers/cpufreq/speedstep-centrino.c
35252 +++ b/drivers/cpufreq/speedstep-centrino.c
35253 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
35254 !cpu_has(cpu, X86_FEATURE_EST))
35255 return -ENODEV;
35256
35257 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
35258 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
35259 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
35260 + pax_open_kernel();
35261 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
35262 + pax_close_kernel();
35263 + }
35264
35265 if (policy->cpu != 0)
35266 return -ENODEV;
35267 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
35268 index e1f6860..f8de20b 100644
35269 --- a/drivers/cpuidle/cpuidle.c
35270 +++ b/drivers/cpuidle/cpuidle.c
35271 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
35272
35273 static void poll_idle_init(struct cpuidle_driver *drv)
35274 {
35275 - struct cpuidle_state *state = &drv->states[0];
35276 + cpuidle_state_no_const *state = &drv->states[0];
35277
35278 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
35279 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
35280 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
35281 index ea2f8e7..70ac501 100644
35282 --- a/drivers/cpuidle/governor.c
35283 +++ b/drivers/cpuidle/governor.c
35284 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
35285 mutex_lock(&cpuidle_lock);
35286 if (__cpuidle_find_governor(gov->name) == NULL) {
35287 ret = 0;
35288 - list_add_tail(&gov->governor_list, &cpuidle_governors);
35289 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
35290 if (!cpuidle_curr_governor ||
35291 cpuidle_curr_governor->rating < gov->rating)
35292 cpuidle_switch_governor(gov);
35293 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
35294 new_gov = cpuidle_replace_governor(gov->rating);
35295 cpuidle_switch_governor(new_gov);
35296 }
35297 - list_del(&gov->governor_list);
35298 + pax_list_del((struct list_head *)&gov->governor_list);
35299 mutex_unlock(&cpuidle_lock);
35300 }
35301
35302 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
35303 index 428754a..8bdf9cc 100644
35304 --- a/drivers/cpuidle/sysfs.c
35305 +++ b/drivers/cpuidle/sysfs.c
35306 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
35307 NULL
35308 };
35309
35310 -static struct attribute_group cpuidle_attr_group = {
35311 +static attribute_group_no_const cpuidle_attr_group = {
35312 .attrs = cpuidle_default_attrs,
35313 .name = "cpuidle",
35314 };
35315 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
35316 index 3b36797..289c16a 100644
35317 --- a/drivers/devfreq/devfreq.c
35318 +++ b/drivers/devfreq/devfreq.c
35319 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
35320 goto err_out;
35321 }
35322
35323 - list_add(&governor->node, &devfreq_governor_list);
35324 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
35325
35326 list_for_each_entry(devfreq, &devfreq_list, node) {
35327 int ret = 0;
35328 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
35329 }
35330 }
35331
35332 - list_del(&governor->node);
35333 + pax_list_del((struct list_head *)&governor->node);
35334 err_out:
35335 mutex_unlock(&devfreq_list_lock);
35336
35337 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
35338 index b70709b..1d8d02a 100644
35339 --- a/drivers/dma/sh/shdma.c
35340 +++ b/drivers/dma/sh/shdma.c
35341 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
35342 return ret;
35343 }
35344
35345 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
35346 +static struct notifier_block sh_dmae_nmi_notifier = {
35347 .notifier_call = sh_dmae_nmi_handler,
35348
35349 /* Run before NMI debug handler and KGDB */
35350 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
35351 index 0ca1ca7..6e6f454 100644
35352 --- a/drivers/edac/edac_mc_sysfs.c
35353 +++ b/drivers/edac/edac_mc_sysfs.c
35354 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
35355 struct dev_ch_attribute {
35356 struct device_attribute attr;
35357 int channel;
35358 -};
35359 +} __do_const;
35360
35361 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
35362 struct dev_ch_attribute dev_attr_legacy_##_name = \
35363 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
35364 index 0056c4d..23b54d9 100644
35365 --- a/drivers/edac/edac_pci_sysfs.c
35366 +++ b/drivers/edac/edac_pci_sysfs.c
35367 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
35368 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
35369 static int edac_pci_poll_msec = 1000; /* one second workq period */
35370
35371 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
35372 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
35373 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
35374 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
35375
35376 static struct kobject *edac_pci_top_main_kobj;
35377 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
35378 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
35379 void *value;
35380 ssize_t(*show) (void *, char *);
35381 ssize_t(*store) (void *, const char *, size_t);
35382 -};
35383 +} __do_const;
35384
35385 /* Set of show/store abstract level functions for PCI Parity object */
35386 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
35387 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35388 edac_printk(KERN_CRIT, EDAC_PCI,
35389 "Signaled System Error on %s\n",
35390 pci_name(dev));
35391 - atomic_inc(&pci_nonparity_count);
35392 + atomic_inc_unchecked(&pci_nonparity_count);
35393 }
35394
35395 if (status & (PCI_STATUS_PARITY)) {
35396 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35397 "Master Data Parity Error on %s\n",
35398 pci_name(dev));
35399
35400 - atomic_inc(&pci_parity_count);
35401 + atomic_inc_unchecked(&pci_parity_count);
35402 }
35403
35404 if (status & (PCI_STATUS_DETECTED_PARITY)) {
35405 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35406 "Detected Parity Error on %s\n",
35407 pci_name(dev));
35408
35409 - atomic_inc(&pci_parity_count);
35410 + atomic_inc_unchecked(&pci_parity_count);
35411 }
35412 }
35413
35414 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35415 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
35416 "Signaled System Error on %s\n",
35417 pci_name(dev));
35418 - atomic_inc(&pci_nonparity_count);
35419 + atomic_inc_unchecked(&pci_nonparity_count);
35420 }
35421
35422 if (status & (PCI_STATUS_PARITY)) {
35423 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35424 "Master Data Parity Error on "
35425 "%s\n", pci_name(dev));
35426
35427 - atomic_inc(&pci_parity_count);
35428 + atomic_inc_unchecked(&pci_parity_count);
35429 }
35430
35431 if (status & (PCI_STATUS_DETECTED_PARITY)) {
35432 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
35433 "Detected Parity Error on %s\n",
35434 pci_name(dev));
35435
35436 - atomic_inc(&pci_parity_count);
35437 + atomic_inc_unchecked(&pci_parity_count);
35438 }
35439 }
35440 }
35441 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
35442 if (!check_pci_errors)
35443 return;
35444
35445 - before_count = atomic_read(&pci_parity_count);
35446 + before_count = atomic_read_unchecked(&pci_parity_count);
35447
35448 /* scan all PCI devices looking for a Parity Error on devices and
35449 * bridges.
35450 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
35451 /* Only if operator has selected panic on PCI Error */
35452 if (edac_pci_get_panic_on_pe()) {
35453 /* If the count is different 'after' from 'before' */
35454 - if (before_count != atomic_read(&pci_parity_count))
35455 + if (before_count != atomic_read_unchecked(&pci_parity_count))
35456 panic("EDAC: PCI Parity Error");
35457 }
35458 }
35459 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
35460 index 6796799..99e8377 100644
35461 --- a/drivers/edac/mce_amd.h
35462 +++ b/drivers/edac/mce_amd.h
35463 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
35464 struct amd_decoder_ops {
35465 bool (*mc0_mce)(u16, u8);
35466 bool (*mc1_mce)(u16, u8);
35467 -};
35468 +} __no_const;
35469
35470 void amd_report_gart_errors(bool);
35471 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
35472 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
35473 index 57ea7f4..789e3c3 100644
35474 --- a/drivers/firewire/core-card.c
35475 +++ b/drivers/firewire/core-card.c
35476 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
35477
35478 void fw_core_remove_card(struct fw_card *card)
35479 {
35480 - struct fw_card_driver dummy_driver = dummy_driver_template;
35481 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
35482
35483 card->driver->update_phy_reg(card, 4,
35484 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
35485 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
35486 index f8d2287..5aaf4db 100644
35487 --- a/drivers/firewire/core-cdev.c
35488 +++ b/drivers/firewire/core-cdev.c
35489 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
35490 int ret;
35491
35492 if ((request->channels == 0 && request->bandwidth == 0) ||
35493 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
35494 - request->bandwidth < 0)
35495 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
35496 return -EINVAL;
35497
35498 r = kmalloc(sizeof(*r), GFP_KERNEL);
35499 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
35500 index af3e8aa..eb2f227 100644
35501 --- a/drivers/firewire/core-device.c
35502 +++ b/drivers/firewire/core-device.c
35503 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
35504 struct config_rom_attribute {
35505 struct device_attribute attr;
35506 u32 key;
35507 -};
35508 +} __do_const;
35509
35510 static ssize_t show_immediate(struct device *dev,
35511 struct device_attribute *dattr, char *buf)
35512 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
35513 index 28a94c7..58da63a 100644
35514 --- a/drivers/firewire/core-transaction.c
35515 +++ b/drivers/firewire/core-transaction.c
35516 @@ -38,6 +38,7 @@
35517 #include <linux/timer.h>
35518 #include <linux/types.h>
35519 #include <linux/workqueue.h>
35520 +#include <linux/sched.h>
35521
35522 #include <asm/byteorder.h>
35523
35524 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
35525 index 515a42c..5ecf3ba 100644
35526 --- a/drivers/firewire/core.h
35527 +++ b/drivers/firewire/core.h
35528 @@ -111,6 +111,7 @@ struct fw_card_driver {
35529
35530 int (*stop_iso)(struct fw_iso_context *ctx);
35531 };
35532 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
35533
35534 void fw_card_initialize(struct fw_card *card,
35535 const struct fw_card_driver *driver, struct device *device);
35536 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
35537 index 94a58a0..f5eba42 100644
35538 --- a/drivers/firmware/dmi-id.c
35539 +++ b/drivers/firmware/dmi-id.c
35540 @@ -16,7 +16,7 @@
35541 struct dmi_device_attribute{
35542 struct device_attribute dev_attr;
35543 int field;
35544 -};
35545 +} __do_const;
35546 #define to_dmi_dev_attr(_dev_attr) \
35547 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35548
35549 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35550 index 4cd392d..4b629e1 100644
35551 --- a/drivers/firmware/dmi_scan.c
35552 +++ b/drivers/firmware/dmi_scan.c
35553 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
35554 }
35555 }
35556 else {
35557 - /*
35558 - * no iounmap() for that ioremap(); it would be a no-op, but
35559 - * it's so early in setup that sucker gets confused into doing
35560 - * what it shouldn't if we actually call it.
35561 - */
35562 p = dmi_ioremap(0xF0000, 0x10000);
35563 if (p == NULL)
35564 goto error;
35565 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35566 if (buf == NULL)
35567 return -1;
35568
35569 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35570 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35571
35572 iounmap(buf);
35573 return 0;
35574 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
35575 index b07cb37..2a51037 100644
35576 --- a/drivers/firmware/efivars.c
35577 +++ b/drivers/firmware/efivars.c
35578 @@ -138,7 +138,7 @@ struct efivar_attribute {
35579 };
35580
35581 static struct efivars __efivars;
35582 -static struct efivar_operations ops;
35583 +static efivar_operations_no_const ops __read_only;
35584
35585 #define PSTORE_EFI_ATTRIBUTES \
35586 (EFI_VARIABLE_NON_VOLATILE | \
35587 @@ -1834,7 +1834,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
35588 static int
35589 create_efivars_bin_attributes(struct efivars *efivars)
35590 {
35591 - struct bin_attribute *attr;
35592 + bin_attribute_no_const *attr;
35593 int error;
35594
35595 /* new_var */
35596 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35597 index 2a90ba6..07f3733 100644
35598 --- a/drivers/firmware/google/memconsole.c
35599 +++ b/drivers/firmware/google/memconsole.c
35600 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35601 if (!found_memconsole())
35602 return -ENODEV;
35603
35604 - memconsole_bin_attr.size = memconsole_length;
35605 + pax_open_kernel();
35606 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35607 + pax_close_kernel();
35608
35609 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35610
35611 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35612 index 6f2306d..af9476a 100644
35613 --- a/drivers/gpio/gpio-ich.c
35614 +++ b/drivers/gpio/gpio-ich.c
35615 @@ -69,7 +69,7 @@ struct ichx_desc {
35616 /* Some chipsets have quirks, let these use their own request/get */
35617 int (*request)(struct gpio_chip *chip, unsigned offset);
35618 int (*get)(struct gpio_chip *chip, unsigned offset);
35619 -};
35620 +} __do_const;
35621
35622 static struct {
35623 spinlock_t lock;
35624 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35625 index 9902732..64b62dd 100644
35626 --- a/drivers/gpio/gpio-vr41xx.c
35627 +++ b/drivers/gpio/gpio-vr41xx.c
35628 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35629 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35630 maskl, pendl, maskh, pendh);
35631
35632 - atomic_inc(&irq_err_count);
35633 + atomic_inc_unchecked(&irq_err_count);
35634
35635 return -EINVAL;
35636 }
35637 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35638 index 7b2d378..cc947ea 100644
35639 --- a/drivers/gpu/drm/drm_crtc_helper.c
35640 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35641 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35642 struct drm_crtc *tmp;
35643 int crtc_mask = 1;
35644
35645 - WARN(!crtc, "checking null crtc?\n");
35646 + BUG_ON(!crtc);
35647
35648 dev = crtc->dev;
35649
35650 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35651 index be174ca..7f38143 100644
35652 --- a/drivers/gpu/drm/drm_drv.c
35653 +++ b/drivers/gpu/drm/drm_drv.c
35654 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
35655 /**
35656 * Copy and IOCTL return string to user space
35657 */
35658 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35659 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35660 {
35661 int len;
35662
35663 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
35664 struct drm_file *file_priv = filp->private_data;
35665 struct drm_device *dev;
35666 struct drm_ioctl_desc *ioctl;
35667 - drm_ioctl_t *func;
35668 + drm_ioctl_no_const_t func;
35669 unsigned int nr = DRM_IOCTL_NR(cmd);
35670 int retcode = -EINVAL;
35671 char stack_kdata[128];
35672 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
35673 return -ENODEV;
35674
35675 atomic_inc(&dev->ioctl_count);
35676 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35677 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35678 ++file_priv->ioctl_count;
35679
35680 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
35681 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35682 index 32d7775..c8be5e1 100644
35683 --- a/drivers/gpu/drm/drm_fops.c
35684 +++ b/drivers/gpu/drm/drm_fops.c
35685 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35686 }
35687
35688 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35689 - atomic_set(&dev->counts[i], 0);
35690 + atomic_set_unchecked(&dev->counts[i], 0);
35691
35692 dev->sigdata.lock = NULL;
35693
35694 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35695 if (drm_device_is_unplugged(dev))
35696 return -ENODEV;
35697
35698 - if (!dev->open_count++)
35699 + if (local_inc_return(&dev->open_count) == 1)
35700 need_setup = 1;
35701 mutex_lock(&dev->struct_mutex);
35702 old_imapping = inode->i_mapping;
35703 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35704 retcode = drm_open_helper(inode, filp, dev);
35705 if (retcode)
35706 goto err_undo;
35707 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35708 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35709 if (need_setup) {
35710 retcode = drm_setup(dev);
35711 if (retcode)
35712 @@ -166,7 +166,7 @@ err_undo:
35713 iput(container_of(dev->dev_mapping, struct inode, i_data));
35714 dev->dev_mapping = old_mapping;
35715 mutex_unlock(&dev->struct_mutex);
35716 - dev->open_count--;
35717 + local_dec(&dev->open_count);
35718 return retcode;
35719 }
35720 EXPORT_SYMBOL(drm_open);
35721 @@ -440,7 +440,7 @@ int drm_release(struct inode *inode, struct file *filp)
35722
35723 mutex_lock(&drm_global_mutex);
35724
35725 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35726 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35727
35728 if (dev->driver->preclose)
35729 dev->driver->preclose(dev, file_priv);
35730 @@ -449,10 +449,10 @@ int drm_release(struct inode *inode, struct file *filp)
35731 * Begin inline drm_release
35732 */
35733
35734 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35735 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35736 task_pid_nr(current),
35737 (long)old_encode_dev(file_priv->minor->device),
35738 - dev->open_count);
35739 + local_read(&dev->open_count));
35740
35741 /* Release any auth tokens that might point to this file_priv,
35742 (do that under the drm_global_mutex) */
35743 @@ -549,8 +549,8 @@ int drm_release(struct inode *inode, struct file *filp)
35744 * End inline drm_release
35745 */
35746
35747 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35748 - if (!--dev->open_count) {
35749 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35750 + if (local_dec_and_test(&dev->open_count)) {
35751 if (atomic_read(&dev->ioctl_count)) {
35752 DRM_ERROR("Device busy: %d\n",
35753 atomic_read(&dev->ioctl_count));
35754 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35755 index f731116..629842c 100644
35756 --- a/drivers/gpu/drm/drm_global.c
35757 +++ b/drivers/gpu/drm/drm_global.c
35758 @@ -36,7 +36,7 @@
35759 struct drm_global_item {
35760 struct mutex mutex;
35761 void *object;
35762 - int refcount;
35763 + atomic_t refcount;
35764 };
35765
35766 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35767 @@ -49,7 +49,7 @@ void drm_global_init(void)
35768 struct drm_global_item *item = &glob[i];
35769 mutex_init(&item->mutex);
35770 item->object = NULL;
35771 - item->refcount = 0;
35772 + atomic_set(&item->refcount, 0);
35773 }
35774 }
35775
35776 @@ -59,7 +59,7 @@ void drm_global_release(void)
35777 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35778 struct drm_global_item *item = &glob[i];
35779 BUG_ON(item->object != NULL);
35780 - BUG_ON(item->refcount != 0);
35781 + BUG_ON(atomic_read(&item->refcount) != 0);
35782 }
35783 }
35784
35785 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35786 void *object;
35787
35788 mutex_lock(&item->mutex);
35789 - if (item->refcount == 0) {
35790 + if (atomic_read(&item->refcount) == 0) {
35791 item->object = kzalloc(ref->size, GFP_KERNEL);
35792 if (unlikely(item->object == NULL)) {
35793 ret = -ENOMEM;
35794 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35795 goto out_err;
35796
35797 }
35798 - ++item->refcount;
35799 + atomic_inc(&item->refcount);
35800 ref->object = item->object;
35801 object = item->object;
35802 mutex_unlock(&item->mutex);
35803 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35804 struct drm_global_item *item = &glob[ref->global_type];
35805
35806 mutex_lock(&item->mutex);
35807 - BUG_ON(item->refcount == 0);
35808 + BUG_ON(atomic_read(&item->refcount) == 0);
35809 BUG_ON(ref->object != item->object);
35810 - if (--item->refcount == 0) {
35811 + if (atomic_dec_and_test(&item->refcount)) {
35812 ref->release(ref);
35813 item->object = NULL;
35814 }
35815 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35816 index d4b20ce..77a8d41 100644
35817 --- a/drivers/gpu/drm/drm_info.c
35818 +++ b/drivers/gpu/drm/drm_info.c
35819 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35820 struct drm_local_map *map;
35821 struct drm_map_list *r_list;
35822
35823 - /* Hardcoded from _DRM_FRAME_BUFFER,
35824 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35825 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35826 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35827 + static const char * const types[] = {
35828 + [_DRM_FRAME_BUFFER] = "FB",
35829 + [_DRM_REGISTERS] = "REG",
35830 + [_DRM_SHM] = "SHM",
35831 + [_DRM_AGP] = "AGP",
35832 + [_DRM_SCATTER_GATHER] = "SG",
35833 + [_DRM_CONSISTENT] = "PCI",
35834 + [_DRM_GEM] = "GEM" };
35835 const char *type;
35836 int i;
35837
35838 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35839 map = r_list->map;
35840 if (!map)
35841 continue;
35842 - if (map->type < 0 || map->type > 5)
35843 + if (map->type >= ARRAY_SIZE(types))
35844 type = "??";
35845 else
35846 type = types[map->type];
35847 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35848 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35849 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35850 vma->vm_flags & VM_IO ? 'i' : '-',
35851 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35852 + 0);
35853 +#else
35854 vma->vm_pgoff);
35855 +#endif
35856
35857 #if defined(__i386__)
35858 pgprot = pgprot_val(vma->vm_page_prot);
35859 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35860 index 2f4c434..dd12cd2 100644
35861 --- a/drivers/gpu/drm/drm_ioc32.c
35862 +++ b/drivers/gpu/drm/drm_ioc32.c
35863 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35864 request = compat_alloc_user_space(nbytes);
35865 if (!access_ok(VERIFY_WRITE, request, nbytes))
35866 return -EFAULT;
35867 - list = (struct drm_buf_desc *) (request + 1);
35868 + list = (struct drm_buf_desc __user *) (request + 1);
35869
35870 if (__put_user(count, &request->count)
35871 || __put_user(list, &request->list))
35872 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35873 request = compat_alloc_user_space(nbytes);
35874 if (!access_ok(VERIFY_WRITE, request, nbytes))
35875 return -EFAULT;
35876 - list = (struct drm_buf_pub *) (request + 1);
35877 + list = (struct drm_buf_pub __user *) (request + 1);
35878
35879 if (__put_user(count, &request->count)
35880 || __put_user(list, &request->list))
35881 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35882 return 0;
35883 }
35884
35885 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35886 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35887 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35888 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35889 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35890 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35891 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35892 {
35893 unsigned int nr = DRM_IOCTL_NR(cmd);
35894 - drm_ioctl_compat_t *fn;
35895 int ret;
35896
35897 /* Assume that ioctls without an explicit compat routine will just
35898 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35899 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35900 return drm_ioctl(filp, cmd, arg);
35901
35902 - fn = drm_compat_ioctls[nr];
35903 -
35904 - if (fn != NULL)
35905 - ret = (*fn) (filp, cmd, arg);
35906 + if (drm_compat_ioctls[nr] != NULL)
35907 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35908 else
35909 ret = drm_ioctl(filp, cmd, arg);
35910
35911 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35912 index e77bd8b..1571b85 100644
35913 --- a/drivers/gpu/drm/drm_ioctl.c
35914 +++ b/drivers/gpu/drm/drm_ioctl.c
35915 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35916 stats->data[i].value =
35917 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35918 else
35919 - stats->data[i].value = atomic_read(&dev->counts[i]);
35920 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35921 stats->data[i].type = dev->types[i];
35922 }
35923
35924 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35925 index d752c96..fe08455 100644
35926 --- a/drivers/gpu/drm/drm_lock.c
35927 +++ b/drivers/gpu/drm/drm_lock.c
35928 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35929 if (drm_lock_take(&master->lock, lock->context)) {
35930 master->lock.file_priv = file_priv;
35931 master->lock.lock_time = jiffies;
35932 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35933 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35934 break; /* Got lock */
35935 }
35936
35937 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35938 return -EINVAL;
35939 }
35940
35941 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35942 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35943
35944 if (drm_lock_free(&master->lock, lock->context)) {
35945 /* FIXME: Should really bail out here. */
35946 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35947 index 200e104..59facda 100644
35948 --- a/drivers/gpu/drm/drm_stub.c
35949 +++ b/drivers/gpu/drm/drm_stub.c
35950 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
35951
35952 drm_device_set_unplugged(dev);
35953
35954 - if (dev->open_count == 0) {
35955 + if (local_read(&dev->open_count) == 0) {
35956 drm_put_dev(dev);
35957 }
35958 mutex_unlock(&drm_global_mutex);
35959 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35960 index 004ecdf..db1f6e0 100644
35961 --- a/drivers/gpu/drm/i810/i810_dma.c
35962 +++ b/drivers/gpu/drm/i810/i810_dma.c
35963 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35964 dma->buflist[vertex->idx],
35965 vertex->discard, vertex->used);
35966
35967 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35968 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35969 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35970 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35971 sarea_priv->last_enqueue = dev_priv->counter - 1;
35972 sarea_priv->last_dispatch = (int)hw_status[5];
35973
35974 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35975 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35976 mc->last_render);
35977
35978 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35979 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35980 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35981 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35982 sarea_priv->last_enqueue = dev_priv->counter - 1;
35983 sarea_priv->last_dispatch = (int)hw_status[5];
35984
35985 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35986 index 6e0acad..93c8289 100644
35987 --- a/drivers/gpu/drm/i810/i810_drv.h
35988 +++ b/drivers/gpu/drm/i810/i810_drv.h
35989 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35990 int page_flipping;
35991
35992 wait_queue_head_t irq_queue;
35993 - atomic_t irq_received;
35994 - atomic_t irq_emitted;
35995 + atomic_unchecked_t irq_received;
35996 + atomic_unchecked_t irq_emitted;
35997
35998 int front_offset;
35999 } drm_i810_private_t;
36000 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
36001 index 261efc8e..27af8a5 100644
36002 --- a/drivers/gpu/drm/i915/i915_debugfs.c
36003 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
36004 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
36005 I915_READ(GTIMR));
36006 }
36007 seq_printf(m, "Interrupts received: %d\n",
36008 - atomic_read(&dev_priv->irq_received));
36009 + atomic_read_unchecked(&dev_priv->irq_received));
36010 for_each_ring(ring, dev_priv, i) {
36011 if (IS_GEN6(dev) || IS_GEN7(dev)) {
36012 seq_printf(m,
36013 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
36014 index 99daa89..84ebd44 100644
36015 --- a/drivers/gpu/drm/i915/i915_dma.c
36016 +++ b/drivers/gpu/drm/i915/i915_dma.c
36017 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
36018 bool can_switch;
36019
36020 spin_lock(&dev->count_lock);
36021 - can_switch = (dev->open_count == 0);
36022 + can_switch = (local_read(&dev->open_count) == 0);
36023 spin_unlock(&dev->count_lock);
36024 return can_switch;
36025 }
36026 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
36027 index 7339a4b..445aaba 100644
36028 --- a/drivers/gpu/drm/i915/i915_drv.h
36029 +++ b/drivers/gpu/drm/i915/i915_drv.h
36030 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
36031 drm_dma_handle_t *status_page_dmah;
36032 struct resource mch_res;
36033
36034 - atomic_t irq_received;
36035 + atomic_unchecked_t irq_received;
36036
36037 /* protects the irq masks */
36038 spinlock_t irq_lock;
36039 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
36040 * will be page flipped away on the next vblank. When it
36041 * reaches 0, dev_priv->pending_flip_queue will be woken up.
36042 */
36043 - atomic_t pending_flip;
36044 + atomic_unchecked_t pending_flip;
36045 };
36046 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
36047
36048 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
36049 struct drm_i915_private *dev_priv, unsigned port);
36050 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
36051 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
36052 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
36053 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
36054 {
36055 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
36056 }
36057 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
36058 index ba8805a..39d5330 100644
36059 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
36060 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
36061 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
36062 i915_gem_clflush_object(obj);
36063
36064 if (obj->base.pending_write_domain)
36065 - flips |= atomic_read(&obj->pending_flip);
36066 + flips |= atomic_read_unchecked(&obj->pending_flip);
36067
36068 flush_domains |= obj->base.write_domain;
36069 }
36070 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
36071
36072 static int
36073 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
36074 - int count)
36075 + unsigned int count)
36076 {
36077 - int i;
36078 + unsigned int i;
36079 int relocs_total = 0;
36080 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
36081
36082 @@ -1202,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
36083 return -ENOMEM;
36084 }
36085 ret = copy_from_user(exec2_list,
36086 - (struct drm_i915_relocation_entry __user *)
36087 + (struct drm_i915_gem_exec_object2 __user *)
36088 (uintptr_t) args->buffers_ptr,
36089 sizeof(*exec2_list) * args->buffer_count);
36090 if (ret != 0) {
36091 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
36092 index 3c59584..500f2e9 100644
36093 --- a/drivers/gpu/drm/i915/i915_ioc32.c
36094 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
36095 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
36096 (unsigned long)request);
36097 }
36098
36099 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
36100 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
36101 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
36102 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
36103 [DRM_I915_GETPARAM] = compat_i915_getparam,
36104 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
36105 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36106 {
36107 unsigned int nr = DRM_IOCTL_NR(cmd);
36108 - drm_ioctl_compat_t *fn = NULL;
36109 int ret;
36110
36111 if (nr < DRM_COMMAND_BASE)
36112 return drm_compat_ioctl(filp, cmd, arg);
36113
36114 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
36115 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
36116 -
36117 - if (fn != NULL)
36118 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
36119 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
36120 ret = (*fn) (filp, cmd, arg);
36121 - else
36122 + } else
36123 ret = drm_ioctl(filp, cmd, arg);
36124
36125 return ret;
36126 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
36127 index fe84338..a863190 100644
36128 --- a/drivers/gpu/drm/i915/i915_irq.c
36129 +++ b/drivers/gpu/drm/i915/i915_irq.c
36130 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
36131 u32 pipe_stats[I915_MAX_PIPES];
36132 bool blc_event;
36133
36134 - atomic_inc(&dev_priv->irq_received);
36135 + atomic_inc_unchecked(&dev_priv->irq_received);
36136
36137 while (true) {
36138 iir = I915_READ(VLV_IIR);
36139 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
36140 irqreturn_t ret = IRQ_NONE;
36141 int i;
36142
36143 - atomic_inc(&dev_priv->irq_received);
36144 + atomic_inc_unchecked(&dev_priv->irq_received);
36145
36146 /* disable master interrupt before clearing iir */
36147 de_ier = I915_READ(DEIER);
36148 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
36149 int ret = IRQ_NONE;
36150 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
36151
36152 - atomic_inc(&dev_priv->irq_received);
36153 + atomic_inc_unchecked(&dev_priv->irq_received);
36154
36155 /* disable master interrupt before clearing iir */
36156 de_ier = I915_READ(DEIER);
36157 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
36158 {
36159 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
36160
36161 - atomic_set(&dev_priv->irq_received, 0);
36162 + atomic_set_unchecked(&dev_priv->irq_received, 0);
36163
36164 I915_WRITE(HWSTAM, 0xeffe);
36165
36166 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
36167 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
36168 int pipe;
36169
36170 - atomic_set(&dev_priv->irq_received, 0);
36171 + atomic_set_unchecked(&dev_priv->irq_received, 0);
36172
36173 /* VLV magic */
36174 I915_WRITE(VLV_IMR, 0);
36175 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
36176 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
36177 int pipe;
36178
36179 - atomic_set(&dev_priv->irq_received, 0);
36180 + atomic_set_unchecked(&dev_priv->irq_received, 0);
36181
36182 for_each_pipe(pipe)
36183 I915_WRITE(PIPESTAT(pipe), 0);
36184 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
36185 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
36186 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
36187
36188 - atomic_inc(&dev_priv->irq_received);
36189 + atomic_inc_unchecked(&dev_priv->irq_received);
36190
36191 iir = I915_READ16(IIR);
36192 if (iir == 0)
36193 @@ -2244,7 +2244,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
36194 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
36195 int pipe;
36196
36197 - atomic_set(&dev_priv->irq_received, 0);
36198 + atomic_set_unchecked(&dev_priv->irq_received, 0);
36199
36200 if (I915_HAS_HOTPLUG(dev)) {
36201 I915_WRITE(PORT_HOTPLUG_EN, 0);
36202 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
36203 };
36204 int pipe, ret = IRQ_NONE;
36205
36206 - atomic_inc(&dev_priv->irq_received);
36207 + atomic_inc_unchecked(&dev_priv->irq_received);
36208
36209 iir = I915_READ(IIR);
36210 do {
36211 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
36212 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
36213 int pipe;
36214
36215 - atomic_set(&dev_priv->irq_received, 0);
36216 + atomic_set_unchecked(&dev_priv->irq_received, 0);
36217
36218 I915_WRITE(PORT_HOTPLUG_EN, 0);
36219 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
36220 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
36221 int irq_received;
36222 int ret = IRQ_NONE, pipe;
36223
36224 - atomic_inc(&dev_priv->irq_received);
36225 + atomic_inc_unchecked(&dev_priv->irq_received);
36226
36227 iir = I915_READ(IIR);
36228
36229 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
36230 index d3f834a..0ad1b37 100644
36231 --- a/drivers/gpu/drm/i915/intel_display.c
36232 +++ b/drivers/gpu/drm/i915/intel_display.c
36233 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
36234
36235 wait_event(dev_priv->pending_flip_queue,
36236 atomic_read(&dev_priv->mm.wedged) ||
36237 - atomic_read(&obj->pending_flip) == 0);
36238 + atomic_read_unchecked(&obj->pending_flip) == 0);
36239
36240 /* Big Hammer, we also need to ensure that any pending
36241 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
36242 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
36243
36244 obj = work->old_fb_obj;
36245
36246 - atomic_clear_mask(1 << intel_crtc->plane,
36247 - &obj->pending_flip.counter);
36248 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
36249 wake_up(&dev_priv->pending_flip_queue);
36250
36251 queue_work(dev_priv->wq, &work->work);
36252 @@ -7486,7 +7485,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
36253 /* Block clients from rendering to the new back buffer until
36254 * the flip occurs and the object is no longer visible.
36255 */
36256 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
36257 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
36258 atomic_inc(&intel_crtc->unpin_work_count);
36259
36260 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
36261 @@ -7504,7 +7503,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
36262 cleanup_pending:
36263 atomic_dec(&intel_crtc->unpin_work_count);
36264 crtc->fb = old_fb;
36265 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
36266 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
36267 drm_gem_object_unreference(&work->old_fb_obj->base);
36268 drm_gem_object_unreference(&obj->base);
36269 mutex_unlock(&dev->struct_mutex);
36270 @@ -8846,13 +8845,13 @@ struct intel_quirk {
36271 int subsystem_vendor;
36272 int subsystem_device;
36273 void (*hook)(struct drm_device *dev);
36274 -};
36275 +} __do_const;
36276
36277 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
36278 struct intel_dmi_quirk {
36279 void (*hook)(struct drm_device *dev);
36280 const struct dmi_system_id (*dmi_id_list)[];
36281 -};
36282 +} __do_const;
36283
36284 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
36285 {
36286 @@ -8860,18 +8859,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
36287 return 1;
36288 }
36289
36290 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
36291 + {
36292 + .callback = intel_dmi_reverse_brightness,
36293 + .ident = "NCR Corporation",
36294 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
36295 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
36296 + },
36297 + },
36298 + { } /* terminating entry */
36299 +};
36300 +
36301 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
36302 {
36303 - .dmi_id_list = &(const struct dmi_system_id[]) {
36304 - {
36305 - .callback = intel_dmi_reverse_brightness,
36306 - .ident = "NCR Corporation",
36307 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
36308 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
36309 - },
36310 - },
36311 - { } /* terminating entry */
36312 - },
36313 + .dmi_id_list = &intel_dmi_quirks_table,
36314 .hook = quirk_invert_brightness,
36315 },
36316 };
36317 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
36318 index 54558a0..2d97005 100644
36319 --- a/drivers/gpu/drm/mga/mga_drv.h
36320 +++ b/drivers/gpu/drm/mga/mga_drv.h
36321 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
36322 u32 clear_cmd;
36323 u32 maccess;
36324
36325 - atomic_t vbl_received; /**< Number of vblanks received. */
36326 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
36327 wait_queue_head_t fence_queue;
36328 - atomic_t last_fence_retired;
36329 + atomic_unchecked_t last_fence_retired;
36330 u32 next_fence_to_post;
36331
36332 unsigned int fb_cpp;
36333 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
36334 index 709e90d..89a1c0d 100644
36335 --- a/drivers/gpu/drm/mga/mga_ioc32.c
36336 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
36337 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
36338 return 0;
36339 }
36340
36341 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
36342 +drm_ioctl_compat_t mga_compat_ioctls[] = {
36343 [DRM_MGA_INIT] = compat_mga_init,
36344 [DRM_MGA_GETPARAM] = compat_mga_getparam,
36345 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
36346 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
36347 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36348 {
36349 unsigned int nr = DRM_IOCTL_NR(cmd);
36350 - drm_ioctl_compat_t *fn = NULL;
36351 int ret;
36352
36353 if (nr < DRM_COMMAND_BASE)
36354 return drm_compat_ioctl(filp, cmd, arg);
36355
36356 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
36357 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
36358 -
36359 - if (fn != NULL)
36360 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
36361 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
36362 ret = (*fn) (filp, cmd, arg);
36363 - else
36364 + } else
36365 ret = drm_ioctl(filp, cmd, arg);
36366
36367 return ret;
36368 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
36369 index 598c281..60d590e 100644
36370 --- a/drivers/gpu/drm/mga/mga_irq.c
36371 +++ b/drivers/gpu/drm/mga/mga_irq.c
36372 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
36373 if (crtc != 0)
36374 return 0;
36375
36376 - return atomic_read(&dev_priv->vbl_received);
36377 + return atomic_read_unchecked(&dev_priv->vbl_received);
36378 }
36379
36380
36381 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
36382 /* VBLANK interrupt */
36383 if (status & MGA_VLINEPEN) {
36384 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
36385 - atomic_inc(&dev_priv->vbl_received);
36386 + atomic_inc_unchecked(&dev_priv->vbl_received);
36387 drm_handle_vblank(dev, 0);
36388 handled = 1;
36389 }
36390 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
36391 if ((prim_start & ~0x03) != (prim_end & ~0x03))
36392 MGA_WRITE(MGA_PRIMEND, prim_end);
36393
36394 - atomic_inc(&dev_priv->last_fence_retired);
36395 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
36396 DRM_WAKEUP(&dev_priv->fence_queue);
36397 handled = 1;
36398 }
36399 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
36400 * using fences.
36401 */
36402 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
36403 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
36404 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
36405 - *sequence) <= (1 << 23)));
36406
36407 *sequence = cur_fence;
36408 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
36409 index 865eddf..62c4cc3 100644
36410 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
36411 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
36412 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
36413 struct bit_table {
36414 const char id;
36415 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
36416 -};
36417 +} __no_const;
36418
36419 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
36420
36421 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
36422 index aa89eb9..d45d38b 100644
36423 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
36424 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
36425 @@ -80,7 +80,7 @@ struct nouveau_drm {
36426 struct drm_global_reference mem_global_ref;
36427 struct ttm_bo_global_ref bo_global_ref;
36428 struct ttm_bo_device bdev;
36429 - atomic_t validate_sequence;
36430 + atomic_unchecked_t validate_sequence;
36431 int (*move)(struct nouveau_channel *,
36432 struct ttm_buffer_object *,
36433 struct ttm_mem_reg *, struct ttm_mem_reg *);
36434 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
36435 index cdb83ac..27f0a16 100644
36436 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
36437 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
36438 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
36439 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
36440 struct nouveau_channel *);
36441 u32 (*read)(struct nouveau_channel *);
36442 -};
36443 +} __no_const;
36444
36445 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
36446
36447 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
36448 index 8bf695c..9fbc90a 100644
36449 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
36450 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
36451 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
36452 int trycnt = 0;
36453 int ret, i;
36454
36455 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
36456 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
36457 retry:
36458 if (++trycnt > 100000) {
36459 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
36460 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
36461 index 08214bc..9208577 100644
36462 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
36463 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
36464 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
36465 unsigned long arg)
36466 {
36467 unsigned int nr = DRM_IOCTL_NR(cmd);
36468 - drm_ioctl_compat_t *fn = NULL;
36469 + drm_ioctl_compat_t fn = NULL;
36470 int ret;
36471
36472 if (nr < DRM_COMMAND_BASE)
36473 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
36474 index 25d3495..d81aaf6 100644
36475 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
36476 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
36477 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
36478 bool can_switch;
36479
36480 spin_lock(&dev->count_lock);
36481 - can_switch = (dev->open_count == 0);
36482 + can_switch = (local_read(&dev->open_count) == 0);
36483 spin_unlock(&dev->count_lock);
36484 return can_switch;
36485 }
36486 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
36487 index d4660cf..70dbe65 100644
36488 --- a/drivers/gpu/drm/r128/r128_cce.c
36489 +++ b/drivers/gpu/drm/r128/r128_cce.c
36490 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
36491
36492 /* GH: Simple idle check.
36493 */
36494 - atomic_set(&dev_priv->idle_count, 0);
36495 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36496
36497 /* We don't support anything other than bus-mastering ring mode,
36498 * but the ring can be in either AGP or PCI space for the ring
36499 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
36500 index 930c71b..499aded 100644
36501 --- a/drivers/gpu/drm/r128/r128_drv.h
36502 +++ b/drivers/gpu/drm/r128/r128_drv.h
36503 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
36504 int is_pci;
36505 unsigned long cce_buffers_offset;
36506
36507 - atomic_t idle_count;
36508 + atomic_unchecked_t idle_count;
36509
36510 int page_flipping;
36511 int current_page;
36512 u32 crtc_offset;
36513 u32 crtc_offset_cntl;
36514
36515 - atomic_t vbl_received;
36516 + atomic_unchecked_t vbl_received;
36517
36518 u32 color_fmt;
36519 unsigned int front_offset;
36520 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
36521 index a954c54..9cc595c 100644
36522 --- a/drivers/gpu/drm/r128/r128_ioc32.c
36523 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
36524 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
36525 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
36526 }
36527
36528 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
36529 +drm_ioctl_compat_t r128_compat_ioctls[] = {
36530 [DRM_R128_INIT] = compat_r128_init,
36531 [DRM_R128_DEPTH] = compat_r128_depth,
36532 [DRM_R128_STIPPLE] = compat_r128_stipple,
36533 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
36534 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36535 {
36536 unsigned int nr = DRM_IOCTL_NR(cmd);
36537 - drm_ioctl_compat_t *fn = NULL;
36538 int ret;
36539
36540 if (nr < DRM_COMMAND_BASE)
36541 return drm_compat_ioctl(filp, cmd, arg);
36542
36543 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36544 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36545 -
36546 - if (fn != NULL)
36547 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36548 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36549 ret = (*fn) (filp, cmd, arg);
36550 - else
36551 + } else
36552 ret = drm_ioctl(filp, cmd, arg);
36553
36554 return ret;
36555 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36556 index 2ea4f09..d391371 100644
36557 --- a/drivers/gpu/drm/r128/r128_irq.c
36558 +++ b/drivers/gpu/drm/r128/r128_irq.c
36559 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36560 if (crtc != 0)
36561 return 0;
36562
36563 - return atomic_read(&dev_priv->vbl_received);
36564 + return atomic_read_unchecked(&dev_priv->vbl_received);
36565 }
36566
36567 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36568 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36569 /* VBLANK interrupt */
36570 if (status & R128_CRTC_VBLANK_INT) {
36571 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36572 - atomic_inc(&dev_priv->vbl_received);
36573 + atomic_inc_unchecked(&dev_priv->vbl_received);
36574 drm_handle_vblank(dev, 0);
36575 return IRQ_HANDLED;
36576 }
36577 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36578 index 19bb7e6..de7e2a2 100644
36579 --- a/drivers/gpu/drm/r128/r128_state.c
36580 +++ b/drivers/gpu/drm/r128/r128_state.c
36581 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36582
36583 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36584 {
36585 - if (atomic_read(&dev_priv->idle_count) == 0)
36586 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36587 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36588 else
36589 - atomic_set(&dev_priv->idle_count, 0);
36590 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36591 }
36592
36593 #endif
36594 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36595 index 5a82b6b..9e69c73 100644
36596 --- a/drivers/gpu/drm/radeon/mkregtable.c
36597 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36598 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36599 regex_t mask_rex;
36600 regmatch_t match[4];
36601 char buf[1024];
36602 - size_t end;
36603 + long end;
36604 int len;
36605 int done = 0;
36606 int r;
36607 unsigned o;
36608 struct offset *offset;
36609 char last_reg_s[10];
36610 - int last_reg;
36611 + unsigned long last_reg;
36612
36613 if (regcomp
36614 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36615 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36616 index 0d6562b..a154330 100644
36617 --- a/drivers/gpu/drm/radeon/radeon_device.c
36618 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36619 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36620 bool can_switch;
36621
36622 spin_lock(&dev->count_lock);
36623 - can_switch = (dev->open_count == 0);
36624 + can_switch = (local_read(&dev->open_count) == 0);
36625 spin_unlock(&dev->count_lock);
36626 return can_switch;
36627 }
36628 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36629 index e7fdf16..f4f6490 100644
36630 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36631 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36632 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
36633
36634 /* SW interrupt */
36635 wait_queue_head_t swi_queue;
36636 - atomic_t swi_emitted;
36637 + atomic_unchecked_t swi_emitted;
36638 int vblank_crtc;
36639 uint32_t irq_enable_reg;
36640 uint32_t r500_disp_irq_reg;
36641 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36642 index c180df8..5fd8186 100644
36643 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36644 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36645 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36646 request = compat_alloc_user_space(sizeof(*request));
36647 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36648 || __put_user(req32.param, &request->param)
36649 - || __put_user((void __user *)(unsigned long)req32.value,
36650 + || __put_user((unsigned long)req32.value,
36651 &request->value))
36652 return -EFAULT;
36653
36654 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36655 #define compat_radeon_cp_setparam NULL
36656 #endif /* X86_64 || IA64 */
36657
36658 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36659 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36660 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36661 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36662 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36663 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36664 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36665 {
36666 unsigned int nr = DRM_IOCTL_NR(cmd);
36667 - drm_ioctl_compat_t *fn = NULL;
36668 int ret;
36669
36670 if (nr < DRM_COMMAND_BASE)
36671 return drm_compat_ioctl(filp, cmd, arg);
36672
36673 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36674 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36675 -
36676 - if (fn != NULL)
36677 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36678 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36679 ret = (*fn) (filp, cmd, arg);
36680 - else
36681 + } else
36682 ret = drm_ioctl(filp, cmd, arg);
36683
36684 return ret;
36685 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36686 index e771033..a0bc6b3 100644
36687 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36688 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36689 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36690 unsigned int ret;
36691 RING_LOCALS;
36692
36693 - atomic_inc(&dev_priv->swi_emitted);
36694 - ret = atomic_read(&dev_priv->swi_emitted);
36695 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36696 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36697
36698 BEGIN_RING(4);
36699 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36700 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36701 drm_radeon_private_t *dev_priv =
36702 (drm_radeon_private_t *) dev->dev_private;
36703
36704 - atomic_set(&dev_priv->swi_emitted, 0);
36705 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36706 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36707
36708 dev->max_vblank_count = 0x001fffff;
36709 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36710 index 8e9057b..af6dacb 100644
36711 --- a/drivers/gpu/drm/radeon/radeon_state.c
36712 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36713 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36714 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36715 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36716
36717 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36718 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36719 sarea_priv->nbox * sizeof(depth_boxes[0])))
36720 return -EFAULT;
36721
36722 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36723 {
36724 drm_radeon_private_t *dev_priv = dev->dev_private;
36725 drm_radeon_getparam_t *param = data;
36726 - int value;
36727 + int value = 0;
36728
36729 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36730
36731 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36732 index 93f760e..8088227 100644
36733 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36734 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36735 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36736 man->size = size >> PAGE_SHIFT;
36737 }
36738
36739 -static struct vm_operations_struct radeon_ttm_vm_ops;
36740 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36741 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36742
36743 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36744 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36745 }
36746 if (unlikely(ttm_vm_ops == NULL)) {
36747 ttm_vm_ops = vma->vm_ops;
36748 + pax_open_kernel();
36749 radeon_ttm_vm_ops = *ttm_vm_ops;
36750 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36751 + pax_close_kernel();
36752 }
36753 vma->vm_ops = &radeon_ttm_vm_ops;
36754 return 0;
36755 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36756 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36757 else
36758 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36759 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36760 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36761 - radeon_mem_types_list[i].driver_features = 0;
36762 + pax_open_kernel();
36763 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36764 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36765 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36766 if (i == 0)
36767 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36768 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36769 else
36770 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36771 -
36772 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36773 + pax_close_kernel();
36774 }
36775 /* Add ttm page pool to debugfs */
36776 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36777 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36778 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36779 - radeon_mem_types_list[i].driver_features = 0;
36780 - radeon_mem_types_list[i++].data = NULL;
36781 + pax_open_kernel();
36782 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36783 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36784 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36785 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36786 + pax_close_kernel();
36787 #ifdef CONFIG_SWIOTLB
36788 if (swiotlb_nr_tbl()) {
36789 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36790 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36791 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36792 - radeon_mem_types_list[i].driver_features = 0;
36793 - radeon_mem_types_list[i++].data = NULL;
36794 + pax_open_kernel();
36795 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36796 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36797 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36798 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36799 + pax_close_kernel();
36800 }
36801 #endif
36802 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36803 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36804 index 5706d2a..17aedaa 100644
36805 --- a/drivers/gpu/drm/radeon/rs690.c
36806 +++ b/drivers/gpu/drm/radeon/rs690.c
36807 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36808 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36809 rdev->pm.sideport_bandwidth.full)
36810 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36811 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36812 + read_delay_latency.full = dfixed_const(800 * 1000);
36813 read_delay_latency.full = dfixed_div(read_delay_latency,
36814 rdev->pm.igp_sideport_mclk);
36815 + a.full = dfixed_const(370);
36816 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36817 } else {
36818 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36819 rdev->pm.k8_bandwidth.full)
36820 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36821 index bd2a3b4..122d9ad 100644
36822 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36823 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36824 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36825 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36826 struct shrink_control *sc)
36827 {
36828 - static atomic_t start_pool = ATOMIC_INIT(0);
36829 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36830 unsigned i;
36831 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36832 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36833 struct ttm_page_pool *pool;
36834 int shrink_pages = sc->nr_to_scan;
36835
36836 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36837 index 1eb060c..188b1fc 100644
36838 --- a/drivers/gpu/drm/udl/udl_fb.c
36839 +++ b/drivers/gpu/drm/udl/udl_fb.c
36840 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36841 fb_deferred_io_cleanup(info);
36842 kfree(info->fbdefio);
36843 info->fbdefio = NULL;
36844 - info->fbops->fb_mmap = udl_fb_mmap;
36845 }
36846
36847 pr_warn("released /dev/fb%d user=%d count=%d\n",
36848 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36849 index 893a650..6190d3b 100644
36850 --- a/drivers/gpu/drm/via/via_drv.h
36851 +++ b/drivers/gpu/drm/via/via_drv.h
36852 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36853 typedef uint32_t maskarray_t[5];
36854
36855 typedef struct drm_via_irq {
36856 - atomic_t irq_received;
36857 + atomic_unchecked_t irq_received;
36858 uint32_t pending_mask;
36859 uint32_t enable_mask;
36860 wait_queue_head_t irq_queue;
36861 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36862 struct timeval last_vblank;
36863 int last_vblank_valid;
36864 unsigned usec_per_vblank;
36865 - atomic_t vbl_received;
36866 + atomic_unchecked_t vbl_received;
36867 drm_via_state_t hc_state;
36868 char pci_buf[VIA_PCI_BUF_SIZE];
36869 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36870 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36871 index ac98964..5dbf512 100644
36872 --- a/drivers/gpu/drm/via/via_irq.c
36873 +++ b/drivers/gpu/drm/via/via_irq.c
36874 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36875 if (crtc != 0)
36876 return 0;
36877
36878 - return atomic_read(&dev_priv->vbl_received);
36879 + return atomic_read_unchecked(&dev_priv->vbl_received);
36880 }
36881
36882 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36883 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36884
36885 status = VIA_READ(VIA_REG_INTERRUPT);
36886 if (status & VIA_IRQ_VBLANK_PENDING) {
36887 - atomic_inc(&dev_priv->vbl_received);
36888 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36889 + atomic_inc_unchecked(&dev_priv->vbl_received);
36890 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36891 do_gettimeofday(&cur_vblank);
36892 if (dev_priv->last_vblank_valid) {
36893 dev_priv->usec_per_vblank =
36894 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36895 dev_priv->last_vblank = cur_vblank;
36896 dev_priv->last_vblank_valid = 1;
36897 }
36898 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36899 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36900 DRM_DEBUG("US per vblank is: %u\n",
36901 dev_priv->usec_per_vblank);
36902 }
36903 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36904
36905 for (i = 0; i < dev_priv->num_irqs; ++i) {
36906 if (status & cur_irq->pending_mask) {
36907 - atomic_inc(&cur_irq->irq_received);
36908 + atomic_inc_unchecked(&cur_irq->irq_received);
36909 DRM_WAKEUP(&cur_irq->irq_queue);
36910 handled = 1;
36911 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36912 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36913 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36914 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36915 masks[irq][4]));
36916 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36917 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36918 } else {
36919 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36920 (((cur_irq_sequence =
36921 - atomic_read(&cur_irq->irq_received)) -
36922 + atomic_read_unchecked(&cur_irq->irq_received)) -
36923 *sequence) <= (1 << 23)));
36924 }
36925 *sequence = cur_irq_sequence;
36926 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36927 }
36928
36929 for (i = 0; i < dev_priv->num_irqs; ++i) {
36930 - atomic_set(&cur_irq->irq_received, 0);
36931 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36932 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36933 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36934 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36935 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36936 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36937 case VIA_IRQ_RELATIVE:
36938 irqwait->request.sequence +=
36939 - atomic_read(&cur_irq->irq_received);
36940 + atomic_read_unchecked(&cur_irq->irq_received);
36941 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36942 case VIA_IRQ_ABSOLUTE:
36943 break;
36944 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36945 index 13aeda7..4a952d1 100644
36946 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36947 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36948 @@ -290,7 +290,7 @@ struct vmw_private {
36949 * Fencing and IRQs.
36950 */
36951
36952 - atomic_t marker_seq;
36953 + atomic_unchecked_t marker_seq;
36954 wait_queue_head_t fence_queue;
36955 wait_queue_head_t fifo_queue;
36956 int fence_queue_waiters; /* Protected by hw_mutex */
36957 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36958 index 3eb1486..0a47ee9 100644
36959 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36960 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36961 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36962 (unsigned int) min,
36963 (unsigned int) fifo->capabilities);
36964
36965 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36966 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36967 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36968 vmw_marker_queue_init(&fifo->marker_queue);
36969 return vmw_fifo_send_fence(dev_priv, &dummy);
36970 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36971 if (reserveable)
36972 iowrite32(bytes, fifo_mem +
36973 SVGA_FIFO_RESERVED);
36974 - return fifo_mem + (next_cmd >> 2);
36975 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36976 } else {
36977 need_bounce = true;
36978 }
36979 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36980
36981 fm = vmw_fifo_reserve(dev_priv, bytes);
36982 if (unlikely(fm == NULL)) {
36983 - *seqno = atomic_read(&dev_priv->marker_seq);
36984 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36985 ret = -ENOMEM;
36986 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36987 false, 3*HZ);
36988 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36989 }
36990
36991 do {
36992 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36993 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36994 } while (*seqno == 0);
36995
36996 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36997 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36998 index 4640adb..e1384ed 100644
36999 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
37000 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
37001 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
37002 * emitted. Then the fence is stale and signaled.
37003 */
37004
37005 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
37006 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
37007 > VMW_FENCE_WRAP);
37008
37009 return ret;
37010 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
37011
37012 if (fifo_idle)
37013 down_read(&fifo_state->rwsem);
37014 - signal_seq = atomic_read(&dev_priv->marker_seq);
37015 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
37016 ret = 0;
37017
37018 for (;;) {
37019 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
37020 index 8a8725c..afed796 100644
37021 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
37022 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
37023 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
37024 while (!vmw_lag_lt(queue, us)) {
37025 spin_lock(&queue->lock);
37026 if (list_empty(&queue->head))
37027 - seqno = atomic_read(&dev_priv->marker_seq);
37028 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
37029 else {
37030 marker = list_first_entry(&queue->head,
37031 struct vmw_marker, head);
37032 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
37033 index ceb3040..6160c5c 100644
37034 --- a/drivers/hid/hid-core.c
37035 +++ b/drivers/hid/hid-core.c
37036 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
37037
37038 int hid_add_device(struct hid_device *hdev)
37039 {
37040 - static atomic_t id = ATOMIC_INIT(0);
37041 + static atomic_unchecked_t id = ATOMIC_INIT(0);
37042 int ret;
37043
37044 if (WARN_ON(hdev->status & HID_STAT_ADDED))
37045 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
37046 /* XXX hack, any other cleaner solution after the driver core
37047 * is converted to allow more than 20 bytes as the device name? */
37048 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
37049 - hdev->vendor, hdev->product, atomic_inc_return(&id));
37050 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
37051
37052 hid_debug_register(hdev, dev_name(&hdev->dev));
37053 ret = device_add(&hdev->dev);
37054 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
37055 index eec3291..8ed706b 100644
37056 --- a/drivers/hid/hid-wiimote-debug.c
37057 +++ b/drivers/hid/hid-wiimote-debug.c
37058 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
37059 else if (size == 0)
37060 return -EIO;
37061
37062 - if (copy_to_user(u, buf, size))
37063 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
37064 return -EFAULT;
37065
37066 *off += size;
37067 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
37068 index 773a2f2..7ce08bc 100644
37069 --- a/drivers/hv/channel.c
37070 +++ b/drivers/hv/channel.c
37071 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
37072 int ret = 0;
37073 int t;
37074
37075 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
37076 - atomic_inc(&vmbus_connection.next_gpadl_handle);
37077 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
37078 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
37079
37080 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
37081 if (ret)
37082 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
37083 index 3648f8f..30ef30d 100644
37084 --- a/drivers/hv/hv.c
37085 +++ b/drivers/hv/hv.c
37086 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
37087 u64 output_address = (output) ? virt_to_phys(output) : 0;
37088 u32 output_address_hi = output_address >> 32;
37089 u32 output_address_lo = output_address & 0xFFFFFFFF;
37090 - void *hypercall_page = hv_context.hypercall_page;
37091 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
37092
37093 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
37094 "=a"(hv_status_lo) : "d" (control_hi),
37095 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
37096 index d8d1fad..b91caf7 100644
37097 --- a/drivers/hv/hyperv_vmbus.h
37098 +++ b/drivers/hv/hyperv_vmbus.h
37099 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
37100 struct vmbus_connection {
37101 enum vmbus_connect_state conn_state;
37102
37103 - atomic_t next_gpadl_handle;
37104 + atomic_unchecked_t next_gpadl_handle;
37105
37106 /*
37107 * Represents channel interrupts. Each bit position represents a
37108 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
37109 index 8e1a9ec..4687821 100644
37110 --- a/drivers/hv/vmbus_drv.c
37111 +++ b/drivers/hv/vmbus_drv.c
37112 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
37113 {
37114 int ret = 0;
37115
37116 - static atomic_t device_num = ATOMIC_INIT(0);
37117 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
37118
37119 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
37120 - atomic_inc_return(&device_num));
37121 + atomic_inc_return_unchecked(&device_num));
37122
37123 child_device_obj->device.bus = &hv_bus;
37124 child_device_obj->device.parent = &hv_acpi_dev->dev;
37125 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
37126 index 1672e2a..4a6297c 100644
37127 --- a/drivers/hwmon/acpi_power_meter.c
37128 +++ b/drivers/hwmon/acpi_power_meter.c
37129 @@ -117,7 +117,7 @@ struct sensor_template {
37130 struct device_attribute *devattr,
37131 const char *buf, size_t count);
37132 int index;
37133 -};
37134 +} __do_const;
37135
37136 /* Averaging interval */
37137 static int update_avg_interval(struct acpi_power_meter_resource *resource)
37138 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
37139 struct sensor_template *attrs)
37140 {
37141 struct device *dev = &resource->acpi_dev->dev;
37142 - struct sensor_device_attribute *sensors =
37143 + sensor_device_attribute_no_const *sensors =
37144 &resource->sensors[resource->num_sensors];
37145 int res = 0;
37146
37147 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
37148 index b41baff..4953e4d 100644
37149 --- a/drivers/hwmon/applesmc.c
37150 +++ b/drivers/hwmon/applesmc.c
37151 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
37152 {
37153 struct applesmc_node_group *grp;
37154 struct applesmc_dev_attr *node;
37155 - struct attribute *attr;
37156 + attribute_no_const *attr;
37157 int ret, i;
37158
37159 for (grp = groups; grp->format; grp++) {
37160 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
37161 index 56dbcfb..9874bf1 100644
37162 --- a/drivers/hwmon/asus_atk0110.c
37163 +++ b/drivers/hwmon/asus_atk0110.c
37164 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
37165 struct atk_sensor_data {
37166 struct list_head list;
37167 struct atk_data *data;
37168 - struct device_attribute label_attr;
37169 - struct device_attribute input_attr;
37170 - struct device_attribute limit1_attr;
37171 - struct device_attribute limit2_attr;
37172 + device_attribute_no_const label_attr;
37173 + device_attribute_no_const input_attr;
37174 + device_attribute_no_const limit1_attr;
37175 + device_attribute_no_const limit2_attr;
37176 char label_attr_name[ATTR_NAME_SIZE];
37177 char input_attr_name[ATTR_NAME_SIZE];
37178 char limit1_attr_name[ATTR_NAME_SIZE];
37179 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
37180 static struct device_attribute atk_name_attr =
37181 __ATTR(name, 0444, atk_name_show, NULL);
37182
37183 -static void atk_init_attribute(struct device_attribute *attr, char *name,
37184 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
37185 sysfs_show_func show)
37186 {
37187 sysfs_attr_init(&attr->attr);
37188 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
37189 index d64923d..72591e8 100644
37190 --- a/drivers/hwmon/coretemp.c
37191 +++ b/drivers/hwmon/coretemp.c
37192 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
37193 return NOTIFY_OK;
37194 }
37195
37196 -static struct notifier_block coretemp_cpu_notifier __refdata = {
37197 +static struct notifier_block coretemp_cpu_notifier = {
37198 .notifier_call = coretemp_cpu_callback,
37199 };
37200
37201 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
37202 index a14f634..2916ee2 100644
37203 --- a/drivers/hwmon/ibmaem.c
37204 +++ b/drivers/hwmon/ibmaem.c
37205 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
37206 struct aem_rw_sensor_template *rw)
37207 {
37208 struct device *dev = &data->pdev->dev;
37209 - struct sensor_device_attribute *sensors = data->sensors;
37210 + sensor_device_attribute_no_const *sensors = data->sensors;
37211 int err;
37212
37213 /* Set up read-only sensors */
37214 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
37215 index 7d19b1b..8fdaaac 100644
37216 --- a/drivers/hwmon/pmbus/pmbus_core.c
37217 +++ b/drivers/hwmon/pmbus/pmbus_core.c
37218 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
37219
37220 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
37221 do { \
37222 - struct sensor_device_attribute *a \
37223 + sensor_device_attribute_no_const *a \
37224 = &data->_type##s[data->num_##_type##s].attribute; \
37225 BUG_ON(data->num_attributes >= data->max_attributes); \
37226 sysfs_attr_init(&a->dev_attr.attr); \
37227 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
37228 index 8047fed..1e956f0 100644
37229 --- a/drivers/hwmon/sht15.c
37230 +++ b/drivers/hwmon/sht15.c
37231 @@ -169,7 +169,7 @@ struct sht15_data {
37232 int supply_uV;
37233 bool supply_uV_valid;
37234 struct work_struct update_supply_work;
37235 - atomic_t interrupt_handled;
37236 + atomic_unchecked_t interrupt_handled;
37237 };
37238
37239 /**
37240 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
37241 return ret;
37242
37243 gpio_direction_input(data->pdata->gpio_data);
37244 - atomic_set(&data->interrupt_handled, 0);
37245 + atomic_set_unchecked(&data->interrupt_handled, 0);
37246
37247 enable_irq(gpio_to_irq(data->pdata->gpio_data));
37248 if (gpio_get_value(data->pdata->gpio_data) == 0) {
37249 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
37250 /* Only relevant if the interrupt hasn't occurred. */
37251 - if (!atomic_read(&data->interrupt_handled))
37252 + if (!atomic_read_unchecked(&data->interrupt_handled))
37253 schedule_work(&data->read_work);
37254 }
37255 ret = wait_event_timeout(data->wait_queue,
37256 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
37257
37258 /* First disable the interrupt */
37259 disable_irq_nosync(irq);
37260 - atomic_inc(&data->interrupt_handled);
37261 + atomic_inc_unchecked(&data->interrupt_handled);
37262 /* Then schedule a reading work struct */
37263 if (data->state != SHT15_READING_NOTHING)
37264 schedule_work(&data->read_work);
37265 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
37266 * If not, then start the interrupt again - care here as could
37267 * have gone low in meantime so verify it hasn't!
37268 */
37269 - atomic_set(&data->interrupt_handled, 0);
37270 + atomic_set_unchecked(&data->interrupt_handled, 0);
37271 enable_irq(gpio_to_irq(data->pdata->gpio_data));
37272 /* If still not occurred or another handler was scheduled */
37273 if (gpio_get_value(data->pdata->gpio_data)
37274 - || atomic_read(&data->interrupt_handled))
37275 + || atomic_read_unchecked(&data->interrupt_handled))
37276 return;
37277 }
37278
37279 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
37280 index 76f157b..9c0db1b 100644
37281 --- a/drivers/hwmon/via-cputemp.c
37282 +++ b/drivers/hwmon/via-cputemp.c
37283 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
37284 return NOTIFY_OK;
37285 }
37286
37287 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
37288 +static struct notifier_block via_cputemp_cpu_notifier = {
37289 .notifier_call = via_cputemp_cpu_callback,
37290 };
37291
37292 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
37293 index 378fcb5..5e91fa8 100644
37294 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
37295 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
37296 @@ -43,7 +43,7 @@
37297 extern struct i2c_adapter amd756_smbus;
37298
37299 static struct i2c_adapter *s4882_adapter;
37300 -static struct i2c_algorithm *s4882_algo;
37301 +static i2c_algorithm_no_const *s4882_algo;
37302
37303 /* Wrapper access functions for multiplexed SMBus */
37304 static DEFINE_MUTEX(amd756_lock);
37305 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
37306 index 29015eb..af2d8e9 100644
37307 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
37308 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
37309 @@ -41,7 +41,7 @@
37310 extern struct i2c_adapter *nforce2_smbus;
37311
37312 static struct i2c_adapter *s4985_adapter;
37313 -static struct i2c_algorithm *s4985_algo;
37314 +static i2c_algorithm_no_const *s4985_algo;
37315
37316 /* Wrapper access functions for multiplexed SMBus */
37317 static DEFINE_MUTEX(nforce2_lock);
37318 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
37319 index 8126824..55a2798 100644
37320 --- a/drivers/ide/ide-cd.c
37321 +++ b/drivers/ide/ide-cd.c
37322 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
37323 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
37324 if ((unsigned long)buf & alignment
37325 || blk_rq_bytes(rq) & q->dma_pad_mask
37326 - || object_is_on_stack(buf))
37327 + || object_starts_on_stack(buf))
37328 drive->dma = 0;
37329 }
37330 }
37331 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
37332 index 8848f16..f8e6dd8 100644
37333 --- a/drivers/iio/industrialio-core.c
37334 +++ b/drivers/iio/industrialio-core.c
37335 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
37336 }
37337
37338 static
37339 -int __iio_device_attr_init(struct device_attribute *dev_attr,
37340 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
37341 const char *postfix,
37342 struct iio_chan_spec const *chan,
37343 ssize_t (*readfunc)(struct device *dev,
37344 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
37345 index 394fea2..c833880 100644
37346 --- a/drivers/infiniband/core/cm.c
37347 +++ b/drivers/infiniband/core/cm.c
37348 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
37349
37350 struct cm_counter_group {
37351 struct kobject obj;
37352 - atomic_long_t counter[CM_ATTR_COUNT];
37353 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
37354 };
37355
37356 struct cm_counter_attribute {
37357 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
37358 struct ib_mad_send_buf *msg = NULL;
37359 int ret;
37360
37361 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37362 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37363 counter[CM_REQ_COUNTER]);
37364
37365 /* Quick state check to discard duplicate REQs. */
37366 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
37367 if (!cm_id_priv)
37368 return;
37369
37370 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37371 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37372 counter[CM_REP_COUNTER]);
37373 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
37374 if (ret)
37375 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
37376 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
37377 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
37378 spin_unlock_irq(&cm_id_priv->lock);
37379 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37380 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37381 counter[CM_RTU_COUNTER]);
37382 goto out;
37383 }
37384 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
37385 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
37386 dreq_msg->local_comm_id);
37387 if (!cm_id_priv) {
37388 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37389 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37390 counter[CM_DREQ_COUNTER]);
37391 cm_issue_drep(work->port, work->mad_recv_wc);
37392 return -EINVAL;
37393 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
37394 case IB_CM_MRA_REP_RCVD:
37395 break;
37396 case IB_CM_TIMEWAIT:
37397 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37398 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37399 counter[CM_DREQ_COUNTER]);
37400 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37401 goto unlock;
37402 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
37403 cm_free_msg(msg);
37404 goto deref;
37405 case IB_CM_DREQ_RCVD:
37406 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37407 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37408 counter[CM_DREQ_COUNTER]);
37409 goto unlock;
37410 default:
37411 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
37412 ib_modify_mad(cm_id_priv->av.port->mad_agent,
37413 cm_id_priv->msg, timeout)) {
37414 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
37415 - atomic_long_inc(&work->port->
37416 + atomic_long_inc_unchecked(&work->port->
37417 counter_group[CM_RECV_DUPLICATES].
37418 counter[CM_MRA_COUNTER]);
37419 goto out;
37420 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
37421 break;
37422 case IB_CM_MRA_REQ_RCVD:
37423 case IB_CM_MRA_REP_RCVD:
37424 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37425 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37426 counter[CM_MRA_COUNTER]);
37427 /* fall through */
37428 default:
37429 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
37430 case IB_CM_LAP_IDLE:
37431 break;
37432 case IB_CM_MRA_LAP_SENT:
37433 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37434 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37435 counter[CM_LAP_COUNTER]);
37436 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37437 goto unlock;
37438 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
37439 cm_free_msg(msg);
37440 goto deref;
37441 case IB_CM_LAP_RCVD:
37442 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37443 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37444 counter[CM_LAP_COUNTER]);
37445 goto unlock;
37446 default:
37447 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
37448 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
37449 if (cur_cm_id_priv) {
37450 spin_unlock_irq(&cm.lock);
37451 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37452 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37453 counter[CM_SIDR_REQ_COUNTER]);
37454 goto out; /* Duplicate message. */
37455 }
37456 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
37457 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
37458 msg->retries = 1;
37459
37460 - atomic_long_add(1 + msg->retries,
37461 + atomic_long_add_unchecked(1 + msg->retries,
37462 &port->counter_group[CM_XMIT].counter[attr_index]);
37463 if (msg->retries)
37464 - atomic_long_add(msg->retries,
37465 + atomic_long_add_unchecked(msg->retries,
37466 &port->counter_group[CM_XMIT_RETRIES].
37467 counter[attr_index]);
37468
37469 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
37470 }
37471
37472 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
37473 - atomic_long_inc(&port->counter_group[CM_RECV].
37474 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
37475 counter[attr_id - CM_ATTR_ID_OFFSET]);
37476
37477 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
37478 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
37479 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
37480
37481 return sprintf(buf, "%ld\n",
37482 - atomic_long_read(&group->counter[cm_attr->index]));
37483 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
37484 }
37485
37486 static const struct sysfs_ops cm_counter_ops = {
37487 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
37488 index 176c8f9..2627b62 100644
37489 --- a/drivers/infiniband/core/fmr_pool.c
37490 +++ b/drivers/infiniband/core/fmr_pool.c
37491 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
37492
37493 struct task_struct *thread;
37494
37495 - atomic_t req_ser;
37496 - atomic_t flush_ser;
37497 + atomic_unchecked_t req_ser;
37498 + atomic_unchecked_t flush_ser;
37499
37500 wait_queue_head_t force_wait;
37501 };
37502 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37503 struct ib_fmr_pool *pool = pool_ptr;
37504
37505 do {
37506 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
37507 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
37508 ib_fmr_batch_release(pool);
37509
37510 - atomic_inc(&pool->flush_ser);
37511 + atomic_inc_unchecked(&pool->flush_ser);
37512 wake_up_interruptible(&pool->force_wait);
37513
37514 if (pool->flush_function)
37515 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37516 }
37517
37518 set_current_state(TASK_INTERRUPTIBLE);
37519 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
37520 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
37521 !kthread_should_stop())
37522 schedule();
37523 __set_current_state(TASK_RUNNING);
37524 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
37525 pool->dirty_watermark = params->dirty_watermark;
37526 pool->dirty_len = 0;
37527 spin_lock_init(&pool->pool_lock);
37528 - atomic_set(&pool->req_ser, 0);
37529 - atomic_set(&pool->flush_ser, 0);
37530 + atomic_set_unchecked(&pool->req_ser, 0);
37531 + atomic_set_unchecked(&pool->flush_ser, 0);
37532 init_waitqueue_head(&pool->force_wait);
37533
37534 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37535 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37536 }
37537 spin_unlock_irq(&pool->pool_lock);
37538
37539 - serial = atomic_inc_return(&pool->req_ser);
37540 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37541 wake_up_process(pool->thread);
37542
37543 if (wait_event_interruptible(pool->force_wait,
37544 - atomic_read(&pool->flush_ser) - serial >= 0))
37545 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37546 return -EINTR;
37547
37548 return 0;
37549 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37550 } else {
37551 list_add_tail(&fmr->list, &pool->dirty_list);
37552 if (++pool->dirty_len >= pool->dirty_watermark) {
37553 - atomic_inc(&pool->req_ser);
37554 + atomic_inc_unchecked(&pool->req_ser);
37555 wake_up_process(pool->thread);
37556 }
37557 }
37558 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37559 index afd8179..598063f 100644
37560 --- a/drivers/infiniband/hw/cxgb4/mem.c
37561 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37562 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37563 int err;
37564 struct fw_ri_tpte tpt;
37565 u32 stag_idx;
37566 - static atomic_t key;
37567 + static atomic_unchecked_t key;
37568
37569 if (c4iw_fatal_error(rdev))
37570 return -EIO;
37571 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37572 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37573 rdev->stats.stag.max = rdev->stats.stag.cur;
37574 mutex_unlock(&rdev->stats.lock);
37575 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37576 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37577 }
37578 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37579 __func__, stag_state, type, pdid, stag_idx);
37580 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37581 index 79b3dbc..96e5fcc 100644
37582 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37583 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37584 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37585 struct ib_atomic_eth *ateth;
37586 struct ipath_ack_entry *e;
37587 u64 vaddr;
37588 - atomic64_t *maddr;
37589 + atomic64_unchecked_t *maddr;
37590 u64 sdata;
37591 u32 rkey;
37592 u8 next;
37593 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37594 IB_ACCESS_REMOTE_ATOMIC)))
37595 goto nack_acc_unlck;
37596 /* Perform atomic OP and save result. */
37597 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37598 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37599 sdata = be64_to_cpu(ateth->swap_data);
37600 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37601 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37602 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37603 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37604 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37605 be64_to_cpu(ateth->compare_data),
37606 sdata);
37607 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37608 index 1f95bba..9530f87 100644
37609 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37610 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37611 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37612 unsigned long flags;
37613 struct ib_wc wc;
37614 u64 sdata;
37615 - atomic64_t *maddr;
37616 + atomic64_unchecked_t *maddr;
37617 enum ib_wc_status send_status;
37618
37619 /*
37620 @@ -382,11 +382,11 @@ again:
37621 IB_ACCESS_REMOTE_ATOMIC)))
37622 goto acc_err;
37623 /* Perform atomic OP and save result. */
37624 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37625 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37626 sdata = wqe->wr.wr.atomic.compare_add;
37627 *(u64 *) sqp->s_sge.sge.vaddr =
37628 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37629 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37630 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37631 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37632 sdata, wqe->wr.wr.atomic.swap);
37633 goto send_comp;
37634 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37635 index 9d3e5c1..d9afe4a 100644
37636 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37637 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37638 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37639 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37640 }
37641
37642 -int mthca_QUERY_FW(struct mthca_dev *dev)
37643 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37644 {
37645 struct mthca_mailbox *mailbox;
37646 u32 *outbox;
37647 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37648 index ed9a989..e0c5871 100644
37649 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37650 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37651 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37652 return key;
37653 }
37654
37655 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37656 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37657 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37658 {
37659 struct mthca_mailbox *mailbox;
37660 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37661 index 5b152a3..c1f3e83 100644
37662 --- a/drivers/infiniband/hw/nes/nes.c
37663 +++ b/drivers/infiniband/hw/nes/nes.c
37664 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37665 LIST_HEAD(nes_adapter_list);
37666 static LIST_HEAD(nes_dev_list);
37667
37668 -atomic_t qps_destroyed;
37669 +atomic_unchecked_t qps_destroyed;
37670
37671 static unsigned int ee_flsh_adapter;
37672 static unsigned int sysfs_nonidx_addr;
37673 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37674 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37675 struct nes_adapter *nesadapter = nesdev->nesadapter;
37676
37677 - atomic_inc(&qps_destroyed);
37678 + atomic_inc_unchecked(&qps_destroyed);
37679
37680 /* Free the control structures */
37681
37682 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37683 index 33cc589..3bd6538 100644
37684 --- a/drivers/infiniband/hw/nes/nes.h
37685 +++ b/drivers/infiniband/hw/nes/nes.h
37686 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37687 extern unsigned int wqm_quanta;
37688 extern struct list_head nes_adapter_list;
37689
37690 -extern atomic_t cm_connects;
37691 -extern atomic_t cm_accepts;
37692 -extern atomic_t cm_disconnects;
37693 -extern atomic_t cm_closes;
37694 -extern atomic_t cm_connecteds;
37695 -extern atomic_t cm_connect_reqs;
37696 -extern atomic_t cm_rejects;
37697 -extern atomic_t mod_qp_timouts;
37698 -extern atomic_t qps_created;
37699 -extern atomic_t qps_destroyed;
37700 -extern atomic_t sw_qps_destroyed;
37701 +extern atomic_unchecked_t cm_connects;
37702 +extern atomic_unchecked_t cm_accepts;
37703 +extern atomic_unchecked_t cm_disconnects;
37704 +extern atomic_unchecked_t cm_closes;
37705 +extern atomic_unchecked_t cm_connecteds;
37706 +extern atomic_unchecked_t cm_connect_reqs;
37707 +extern atomic_unchecked_t cm_rejects;
37708 +extern atomic_unchecked_t mod_qp_timouts;
37709 +extern atomic_unchecked_t qps_created;
37710 +extern atomic_unchecked_t qps_destroyed;
37711 +extern atomic_unchecked_t sw_qps_destroyed;
37712 extern u32 mh_detected;
37713 extern u32 mh_pauses_sent;
37714 extern u32 cm_packets_sent;
37715 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37716 extern u32 cm_packets_received;
37717 extern u32 cm_packets_dropped;
37718 extern u32 cm_packets_retrans;
37719 -extern atomic_t cm_listens_created;
37720 -extern atomic_t cm_listens_destroyed;
37721 +extern atomic_unchecked_t cm_listens_created;
37722 +extern atomic_unchecked_t cm_listens_destroyed;
37723 extern u32 cm_backlog_drops;
37724 -extern atomic_t cm_loopbacks;
37725 -extern atomic_t cm_nodes_created;
37726 -extern atomic_t cm_nodes_destroyed;
37727 -extern atomic_t cm_accel_dropped_pkts;
37728 -extern atomic_t cm_resets_recvd;
37729 -extern atomic_t pau_qps_created;
37730 -extern atomic_t pau_qps_destroyed;
37731 +extern atomic_unchecked_t cm_loopbacks;
37732 +extern atomic_unchecked_t cm_nodes_created;
37733 +extern atomic_unchecked_t cm_nodes_destroyed;
37734 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37735 +extern atomic_unchecked_t cm_resets_recvd;
37736 +extern atomic_unchecked_t pau_qps_created;
37737 +extern atomic_unchecked_t pau_qps_destroyed;
37738
37739 extern u32 int_mod_timer_init;
37740 extern u32 int_mod_cq_depth_256;
37741 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37742 index 22ea67e..dcbe3bc 100644
37743 --- a/drivers/infiniband/hw/nes/nes_cm.c
37744 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37745 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37746 u32 cm_packets_retrans;
37747 u32 cm_packets_created;
37748 u32 cm_packets_received;
37749 -atomic_t cm_listens_created;
37750 -atomic_t cm_listens_destroyed;
37751 +atomic_unchecked_t cm_listens_created;
37752 +atomic_unchecked_t cm_listens_destroyed;
37753 u32 cm_backlog_drops;
37754 -atomic_t cm_loopbacks;
37755 -atomic_t cm_nodes_created;
37756 -atomic_t cm_nodes_destroyed;
37757 -atomic_t cm_accel_dropped_pkts;
37758 -atomic_t cm_resets_recvd;
37759 +atomic_unchecked_t cm_loopbacks;
37760 +atomic_unchecked_t cm_nodes_created;
37761 +atomic_unchecked_t cm_nodes_destroyed;
37762 +atomic_unchecked_t cm_accel_dropped_pkts;
37763 +atomic_unchecked_t cm_resets_recvd;
37764
37765 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37766 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37767 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37768
37769 static struct nes_cm_core *g_cm_core;
37770
37771 -atomic_t cm_connects;
37772 -atomic_t cm_accepts;
37773 -atomic_t cm_disconnects;
37774 -atomic_t cm_closes;
37775 -atomic_t cm_connecteds;
37776 -atomic_t cm_connect_reqs;
37777 -atomic_t cm_rejects;
37778 +atomic_unchecked_t cm_connects;
37779 +atomic_unchecked_t cm_accepts;
37780 +atomic_unchecked_t cm_disconnects;
37781 +atomic_unchecked_t cm_closes;
37782 +atomic_unchecked_t cm_connecteds;
37783 +atomic_unchecked_t cm_connect_reqs;
37784 +atomic_unchecked_t cm_rejects;
37785
37786 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37787 {
37788 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37789 kfree(listener);
37790 listener = NULL;
37791 ret = 0;
37792 - atomic_inc(&cm_listens_destroyed);
37793 + atomic_inc_unchecked(&cm_listens_destroyed);
37794 } else {
37795 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37796 }
37797 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37798 cm_node->rem_mac);
37799
37800 add_hte_node(cm_core, cm_node);
37801 - atomic_inc(&cm_nodes_created);
37802 + atomic_inc_unchecked(&cm_nodes_created);
37803
37804 return cm_node;
37805 }
37806 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37807 }
37808
37809 atomic_dec(&cm_core->node_cnt);
37810 - atomic_inc(&cm_nodes_destroyed);
37811 + atomic_inc_unchecked(&cm_nodes_destroyed);
37812 nesqp = cm_node->nesqp;
37813 if (nesqp) {
37814 nesqp->cm_node = NULL;
37815 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37816
37817 static void drop_packet(struct sk_buff *skb)
37818 {
37819 - atomic_inc(&cm_accel_dropped_pkts);
37820 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37821 dev_kfree_skb_any(skb);
37822 }
37823
37824 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37825 {
37826
37827 int reset = 0; /* whether to send reset in case of err.. */
37828 - atomic_inc(&cm_resets_recvd);
37829 + atomic_inc_unchecked(&cm_resets_recvd);
37830 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37831 " refcnt=%d\n", cm_node, cm_node->state,
37832 atomic_read(&cm_node->ref_count));
37833 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37834 rem_ref_cm_node(cm_node->cm_core, cm_node);
37835 return NULL;
37836 }
37837 - atomic_inc(&cm_loopbacks);
37838 + atomic_inc_unchecked(&cm_loopbacks);
37839 loopbackremotenode->loopbackpartner = cm_node;
37840 loopbackremotenode->tcp_cntxt.rcv_wscale =
37841 NES_CM_DEFAULT_RCV_WND_SCALE;
37842 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37843 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37844 else {
37845 rem_ref_cm_node(cm_core, cm_node);
37846 - atomic_inc(&cm_accel_dropped_pkts);
37847 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37848 dev_kfree_skb_any(skb);
37849 }
37850 break;
37851 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37852
37853 if ((cm_id) && (cm_id->event_handler)) {
37854 if (issue_disconn) {
37855 - atomic_inc(&cm_disconnects);
37856 + atomic_inc_unchecked(&cm_disconnects);
37857 cm_event.event = IW_CM_EVENT_DISCONNECT;
37858 cm_event.status = disconn_status;
37859 cm_event.local_addr = cm_id->local_addr;
37860 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37861 }
37862
37863 if (issue_close) {
37864 - atomic_inc(&cm_closes);
37865 + atomic_inc_unchecked(&cm_closes);
37866 nes_disconnect(nesqp, 1);
37867
37868 cm_id->provider_data = nesqp;
37869 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37870
37871 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37872 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37873 - atomic_inc(&cm_accepts);
37874 + atomic_inc_unchecked(&cm_accepts);
37875
37876 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37877 netdev_refcnt_read(nesvnic->netdev));
37878 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37879 struct nes_cm_core *cm_core;
37880 u8 *start_buff;
37881
37882 - atomic_inc(&cm_rejects);
37883 + atomic_inc_unchecked(&cm_rejects);
37884 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37885 loopback = cm_node->loopbackpartner;
37886 cm_core = cm_node->cm_core;
37887 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37888 ntohl(cm_id->local_addr.sin_addr.s_addr),
37889 ntohs(cm_id->local_addr.sin_port));
37890
37891 - atomic_inc(&cm_connects);
37892 + atomic_inc_unchecked(&cm_connects);
37893 nesqp->active_conn = 1;
37894
37895 /* cache the cm_id in the qp */
37896 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37897 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37898 return err;
37899 }
37900 - atomic_inc(&cm_listens_created);
37901 + atomic_inc_unchecked(&cm_listens_created);
37902 }
37903
37904 cm_id->add_ref(cm_id);
37905 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37906
37907 if (nesqp->destroyed)
37908 return;
37909 - atomic_inc(&cm_connecteds);
37910 + atomic_inc_unchecked(&cm_connecteds);
37911 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37912 " local port 0x%04X. jiffies = %lu.\n",
37913 nesqp->hwqp.qp_id,
37914 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37915
37916 cm_id->add_ref(cm_id);
37917 ret = cm_id->event_handler(cm_id, &cm_event);
37918 - atomic_inc(&cm_closes);
37919 + atomic_inc_unchecked(&cm_closes);
37920 cm_event.event = IW_CM_EVENT_CLOSE;
37921 cm_event.status = 0;
37922 cm_event.provider_data = cm_id->provider_data;
37923 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37924 return;
37925 cm_id = cm_node->cm_id;
37926
37927 - atomic_inc(&cm_connect_reqs);
37928 + atomic_inc_unchecked(&cm_connect_reqs);
37929 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37930 cm_node, cm_id, jiffies);
37931
37932 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37933 return;
37934 cm_id = cm_node->cm_id;
37935
37936 - atomic_inc(&cm_connect_reqs);
37937 + atomic_inc_unchecked(&cm_connect_reqs);
37938 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37939 cm_node, cm_id, jiffies);
37940
37941 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37942 index 4166452..fc952c3 100644
37943 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37944 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37945 @@ -40,8 +40,8 @@
37946 #include "nes.h"
37947 #include "nes_mgt.h"
37948
37949 -atomic_t pau_qps_created;
37950 -atomic_t pau_qps_destroyed;
37951 +atomic_unchecked_t pau_qps_created;
37952 +atomic_unchecked_t pau_qps_destroyed;
37953
37954 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37955 {
37956 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37957 {
37958 struct sk_buff *skb;
37959 unsigned long flags;
37960 - atomic_inc(&pau_qps_destroyed);
37961 + atomic_inc_unchecked(&pau_qps_destroyed);
37962
37963 /* Free packets that have not yet been forwarded */
37964 /* Lock is acquired by skb_dequeue when removing the skb */
37965 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37966 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37967 skb_queue_head_init(&nesqp->pau_list);
37968 spin_lock_init(&nesqp->pau_lock);
37969 - atomic_inc(&pau_qps_created);
37970 + atomic_inc_unchecked(&pau_qps_created);
37971 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37972 }
37973
37974 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37975 index 9542e16..a008c40 100644
37976 --- a/drivers/infiniband/hw/nes/nes_nic.c
37977 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37978 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37979 target_stat_values[++index] = mh_detected;
37980 target_stat_values[++index] = mh_pauses_sent;
37981 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37982 - target_stat_values[++index] = atomic_read(&cm_connects);
37983 - target_stat_values[++index] = atomic_read(&cm_accepts);
37984 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37985 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37986 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37987 - target_stat_values[++index] = atomic_read(&cm_rejects);
37988 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37989 - target_stat_values[++index] = atomic_read(&qps_created);
37990 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37991 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37992 - target_stat_values[++index] = atomic_read(&cm_closes);
37993 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37994 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37995 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37996 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37997 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37998 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37999 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
38000 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
38001 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
38002 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
38003 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
38004 target_stat_values[++index] = cm_packets_sent;
38005 target_stat_values[++index] = cm_packets_bounced;
38006 target_stat_values[++index] = cm_packets_created;
38007 target_stat_values[++index] = cm_packets_received;
38008 target_stat_values[++index] = cm_packets_dropped;
38009 target_stat_values[++index] = cm_packets_retrans;
38010 - target_stat_values[++index] = atomic_read(&cm_listens_created);
38011 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
38012 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
38013 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
38014 target_stat_values[++index] = cm_backlog_drops;
38015 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
38016 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
38017 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
38018 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
38019 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
38020 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
38021 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
38022 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
38023 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
38024 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
38025 target_stat_values[++index] = nesadapter->free_4kpbl;
38026 target_stat_values[++index] = nesadapter->free_256pbl;
38027 target_stat_values[++index] = int_mod_timer_init;
38028 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
38029 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
38030 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
38031 - target_stat_values[++index] = atomic_read(&pau_qps_created);
38032 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
38033 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
38034 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
38035 }
38036
38037 /**
38038 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
38039 index 07e4fba..685f041 100644
38040 --- a/drivers/infiniband/hw/nes/nes_verbs.c
38041 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
38042 @@ -46,9 +46,9 @@
38043
38044 #include <rdma/ib_umem.h>
38045
38046 -atomic_t mod_qp_timouts;
38047 -atomic_t qps_created;
38048 -atomic_t sw_qps_destroyed;
38049 +atomic_unchecked_t mod_qp_timouts;
38050 +atomic_unchecked_t qps_created;
38051 +atomic_unchecked_t sw_qps_destroyed;
38052
38053 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
38054
38055 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
38056 if (init_attr->create_flags)
38057 return ERR_PTR(-EINVAL);
38058
38059 - atomic_inc(&qps_created);
38060 + atomic_inc_unchecked(&qps_created);
38061 switch (init_attr->qp_type) {
38062 case IB_QPT_RC:
38063 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
38064 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
38065 struct iw_cm_event cm_event;
38066 int ret = 0;
38067
38068 - atomic_inc(&sw_qps_destroyed);
38069 + atomic_inc_unchecked(&sw_qps_destroyed);
38070 nesqp->destroyed = 1;
38071
38072 /* Blow away the connection if it exists. */
38073 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
38074 index 4d11575..3e890e5 100644
38075 --- a/drivers/infiniband/hw/qib/qib.h
38076 +++ b/drivers/infiniband/hw/qib/qib.h
38077 @@ -51,6 +51,7 @@
38078 #include <linux/completion.h>
38079 #include <linux/kref.h>
38080 #include <linux/sched.h>
38081 +#include <linux/slab.h>
38082
38083 #include "qib_common.h"
38084 #include "qib_verbs.h"
38085 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
38086 index da739d9..da1c7f4 100644
38087 --- a/drivers/input/gameport/gameport.c
38088 +++ b/drivers/input/gameport/gameport.c
38089 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
38090 */
38091 static void gameport_init_port(struct gameport *gameport)
38092 {
38093 - static atomic_t gameport_no = ATOMIC_INIT(0);
38094 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
38095
38096 __module_get(THIS_MODULE);
38097
38098 mutex_init(&gameport->drv_mutex);
38099 device_initialize(&gameport->dev);
38100 dev_set_name(&gameport->dev, "gameport%lu",
38101 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
38102 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
38103 gameport->dev.bus = &gameport_bus;
38104 gameport->dev.release = gameport_release_port;
38105 if (gameport->parent)
38106 diff --git a/drivers/input/input.c b/drivers/input/input.c
38107 index c044699..174d71a 100644
38108 --- a/drivers/input/input.c
38109 +++ b/drivers/input/input.c
38110 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
38111 */
38112 int input_register_device(struct input_dev *dev)
38113 {
38114 - static atomic_t input_no = ATOMIC_INIT(0);
38115 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
38116 struct input_devres *devres = NULL;
38117 struct input_handler *handler;
38118 unsigned int packet_size;
38119 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
38120 dev->setkeycode = input_default_setkeycode;
38121
38122 dev_set_name(&dev->dev, "input%ld",
38123 - (unsigned long) atomic_inc_return(&input_no) - 1);
38124 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
38125
38126 error = device_add(&dev->dev);
38127 if (error)
38128 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
38129 index 04c69af..5f92d00 100644
38130 --- a/drivers/input/joystick/sidewinder.c
38131 +++ b/drivers/input/joystick/sidewinder.c
38132 @@ -30,6 +30,7 @@
38133 #include <linux/kernel.h>
38134 #include <linux/module.h>
38135 #include <linux/slab.h>
38136 +#include <linux/sched.h>
38137 #include <linux/init.h>
38138 #include <linux/input.h>
38139 #include <linux/gameport.h>
38140 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
38141 index d6cbfe9..6225402 100644
38142 --- a/drivers/input/joystick/xpad.c
38143 +++ b/drivers/input/joystick/xpad.c
38144 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
38145
38146 static int xpad_led_probe(struct usb_xpad *xpad)
38147 {
38148 - static atomic_t led_seq = ATOMIC_INIT(0);
38149 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
38150 long led_no;
38151 struct xpad_led *led;
38152 struct led_classdev *led_cdev;
38153 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
38154 if (!led)
38155 return -ENOMEM;
38156
38157 - led_no = (long)atomic_inc_return(&led_seq) - 1;
38158 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
38159
38160 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
38161 led->xpad = xpad;
38162 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
38163 index fe1df23..5b710f3 100644
38164 --- a/drivers/input/mouse/psmouse.h
38165 +++ b/drivers/input/mouse/psmouse.h
38166 @@ -115,7 +115,7 @@ struct psmouse_attribute {
38167 ssize_t (*set)(struct psmouse *psmouse, void *data,
38168 const char *buf, size_t count);
38169 bool protect;
38170 -};
38171 +} __do_const;
38172 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
38173
38174 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
38175 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
38176 index 4c842c3..590b0bf 100644
38177 --- a/drivers/input/mousedev.c
38178 +++ b/drivers/input/mousedev.c
38179 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
38180
38181 spin_unlock_irq(&client->packet_lock);
38182
38183 - if (copy_to_user(buffer, data, count))
38184 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
38185 return -EFAULT;
38186
38187 return count;
38188 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
38189 index 25fc597..558bf3b 100644
38190 --- a/drivers/input/serio/serio.c
38191 +++ b/drivers/input/serio/serio.c
38192 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
38193 */
38194 static void serio_init_port(struct serio *serio)
38195 {
38196 - static atomic_t serio_no = ATOMIC_INIT(0);
38197 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
38198
38199 __module_get(THIS_MODULE);
38200
38201 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
38202 mutex_init(&serio->drv_mutex);
38203 device_initialize(&serio->dev);
38204 dev_set_name(&serio->dev, "serio%ld",
38205 - (long)atomic_inc_return(&serio_no) - 1);
38206 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
38207 serio->dev.bus = &serio_bus;
38208 serio->dev.release = serio_release_port;
38209 serio->dev.groups = serio_device_attr_groups;
38210 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
38211 index ddbdaca..be18a78 100644
38212 --- a/drivers/iommu/iommu.c
38213 +++ b/drivers/iommu/iommu.c
38214 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
38215 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
38216 {
38217 bus_register_notifier(bus, &iommu_bus_nb);
38218 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
38219 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
38220 }
38221
38222 /**
38223 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
38224 index 89562a8..218999b 100644
38225 --- a/drivers/isdn/capi/capi.c
38226 +++ b/drivers/isdn/capi/capi.c
38227 @@ -81,8 +81,8 @@ struct capiminor {
38228
38229 struct capi20_appl *ap;
38230 u32 ncci;
38231 - atomic_t datahandle;
38232 - atomic_t msgid;
38233 + atomic_unchecked_t datahandle;
38234 + atomic_unchecked_t msgid;
38235
38236 struct tty_port port;
38237 int ttyinstop;
38238 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
38239 capimsg_setu16(s, 2, mp->ap->applid);
38240 capimsg_setu8 (s, 4, CAPI_DATA_B3);
38241 capimsg_setu8 (s, 5, CAPI_RESP);
38242 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
38243 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
38244 capimsg_setu32(s, 8, mp->ncci);
38245 capimsg_setu16(s, 12, datahandle);
38246 }
38247 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
38248 mp->outbytes -= len;
38249 spin_unlock_bh(&mp->outlock);
38250
38251 - datahandle = atomic_inc_return(&mp->datahandle);
38252 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
38253 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
38254 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
38255 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
38256 capimsg_setu16(skb->data, 2, mp->ap->applid);
38257 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
38258 capimsg_setu8 (skb->data, 5, CAPI_REQ);
38259 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
38260 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
38261 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
38262 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
38263 capimsg_setu16(skb->data, 16, len); /* Data length */
38264 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
38265 index 67abf3f..076b3a6 100644
38266 --- a/drivers/isdn/gigaset/interface.c
38267 +++ b/drivers/isdn/gigaset/interface.c
38268 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
38269 }
38270 tty->driver_data = cs;
38271
38272 - ++cs->port.count;
38273 + atomic_inc(&cs->port.count);
38274
38275 - if (cs->port.count == 1) {
38276 + if (atomic_read(&cs->port.count) == 1) {
38277 tty_port_tty_set(&cs->port, tty);
38278 tty->low_latency = 1;
38279 }
38280 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
38281
38282 if (!cs->connected)
38283 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
38284 - else if (!cs->port.count)
38285 + else if (!atomic_read(&cs->port.count))
38286 dev_warn(cs->dev, "%s: device not opened\n", __func__);
38287 - else if (!--cs->port.count)
38288 + else if (!atomic_dec_return(&cs->port.count))
38289 tty_port_tty_set(&cs->port, NULL);
38290
38291 mutex_unlock(&cs->mutex);
38292 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
38293 index 821f7ac..28d4030 100644
38294 --- a/drivers/isdn/hardware/avm/b1.c
38295 +++ b/drivers/isdn/hardware/avm/b1.c
38296 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
38297 }
38298 if (left) {
38299 if (t4file->user) {
38300 - if (copy_from_user(buf, dp, left))
38301 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38302 return -EFAULT;
38303 } else {
38304 memcpy(buf, dp, left);
38305 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
38306 }
38307 if (left) {
38308 if (config->user) {
38309 - if (copy_from_user(buf, dp, left))
38310 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38311 return -EFAULT;
38312 } else {
38313 memcpy(buf, dp, left);
38314 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
38315 index e09dc8a..15e2efb 100644
38316 --- a/drivers/isdn/i4l/isdn_tty.c
38317 +++ b/drivers/isdn/i4l/isdn_tty.c
38318 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
38319
38320 #ifdef ISDN_DEBUG_MODEM_OPEN
38321 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
38322 - port->count);
38323 + atomic_read(&port->count));
38324 #endif
38325 - port->count++;
38326 + atomic_inc(&port->count);
38327 port->tty = tty;
38328 /*
38329 * Start up serial port
38330 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38331 #endif
38332 return;
38333 }
38334 - if ((tty->count == 1) && (port->count != 1)) {
38335 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
38336 /*
38337 * Uh, oh. tty->count is 1, which means that the tty
38338 * structure will be freed. Info->count should always
38339 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38340 * serial port won't be shutdown.
38341 */
38342 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
38343 - "info->count is %d\n", port->count);
38344 - port->count = 1;
38345 + "info->count is %d\n", atomic_read(&port->count));
38346 + atomic_set(&port->count, 1);
38347 }
38348 - if (--port->count < 0) {
38349 + if (atomic_dec_return(&port->count) < 0) {
38350 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
38351 - info->line, port->count);
38352 - port->count = 0;
38353 + info->line, atomic_read(&port->count));
38354 + atomic_set(&port->count, 0);
38355 }
38356 - if (port->count) {
38357 + if (atomic_read(&port->count)) {
38358 #ifdef ISDN_DEBUG_MODEM_OPEN
38359 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
38360 #endif
38361 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
38362 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
38363 return;
38364 isdn_tty_shutdown(info);
38365 - port->count = 0;
38366 + atomic_set(&port->count, 0);
38367 port->flags &= ~ASYNC_NORMAL_ACTIVE;
38368 port->tty = NULL;
38369 wake_up_interruptible(&port->open_wait);
38370 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
38371 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
38372 modem_info *info = &dev->mdm.info[i];
38373
38374 - if (info->port.count == 0)
38375 + if (atomic_read(&info->port.count) == 0)
38376 continue;
38377 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
38378 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
38379 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
38380 index e74df7c..03a03ba 100644
38381 --- a/drivers/isdn/icn/icn.c
38382 +++ b/drivers/isdn/icn/icn.c
38383 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
38384 if (count > len)
38385 count = len;
38386 if (user) {
38387 - if (copy_from_user(msg, buf, count))
38388 + if (count > sizeof msg || copy_from_user(msg, buf, count))
38389 return -EFAULT;
38390 } else
38391 memcpy(msg, buf, count);
38392 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
38393 index 6a8405d..0bd1c7e 100644
38394 --- a/drivers/leds/leds-clevo-mail.c
38395 +++ b/drivers/leds/leds-clevo-mail.c
38396 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
38397 * detected as working, but in reality it is not) as low as
38398 * possible.
38399 */
38400 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
38401 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
38402 {
38403 .callback = clevo_mail_led_dmi_callback,
38404 .ident = "Clevo D410J",
38405 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
38406 index ec9b287..65c9bf4 100644
38407 --- a/drivers/leds/leds-ss4200.c
38408 +++ b/drivers/leds/leds-ss4200.c
38409 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
38410 * detected as working, but in reality it is not) as low as
38411 * possible.
38412 */
38413 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
38414 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
38415 {
38416 .callback = ss4200_led_dmi_callback,
38417 .ident = "Intel SS4200-E",
38418 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
38419 index a5ebc00..982886f 100644
38420 --- a/drivers/lguest/core.c
38421 +++ b/drivers/lguest/core.c
38422 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
38423 * it's worked so far. The end address needs +1 because __get_vm_area
38424 * allocates an extra guard page, so we need space for that.
38425 */
38426 +
38427 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
38428 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38429 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
38430 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38431 +#else
38432 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38433 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
38434 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38435 +#endif
38436 +
38437 if (!switcher_vma) {
38438 err = -ENOMEM;
38439 printk("lguest: could not map switcher pages high\n");
38440 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
38441 * Now the Switcher is mapped at the right address, we can't fail!
38442 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
38443 */
38444 - memcpy(switcher_vma->addr, start_switcher_text,
38445 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
38446 end_switcher_text - start_switcher_text);
38447
38448 printk(KERN_INFO "lguest: mapped switcher at %p\n",
38449 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
38450 index 3b62be16..e33134a 100644
38451 --- a/drivers/lguest/page_tables.c
38452 +++ b/drivers/lguest/page_tables.c
38453 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
38454 /*:*/
38455
38456 #ifdef CONFIG_X86_PAE
38457 -static void release_pmd(pmd_t *spmd)
38458 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
38459 {
38460 /* If the entry's not present, there's nothing to release. */
38461 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
38462 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
38463 index 4af12e1..0e89afe 100644
38464 --- a/drivers/lguest/x86/core.c
38465 +++ b/drivers/lguest/x86/core.c
38466 @@ -59,7 +59,7 @@ static struct {
38467 /* Offset from where switcher.S was compiled to where we've copied it */
38468 static unsigned long switcher_offset(void)
38469 {
38470 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
38471 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
38472 }
38473
38474 /* This cpu's struct lguest_pages. */
38475 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
38476 * These copies are pretty cheap, so we do them unconditionally: */
38477 /* Save the current Host top-level page directory.
38478 */
38479 +
38480 +#ifdef CONFIG_PAX_PER_CPU_PGD
38481 + pages->state.host_cr3 = read_cr3();
38482 +#else
38483 pages->state.host_cr3 = __pa(current->mm->pgd);
38484 +#endif
38485 +
38486 /*
38487 * Set up the Guest's page tables to see this CPU's pages (and no
38488 * other CPU's pages).
38489 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
38490 * compiled-in switcher code and the high-mapped copy we just made.
38491 */
38492 for (i = 0; i < IDT_ENTRIES; i++)
38493 - default_idt_entries[i] += switcher_offset();
38494 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
38495
38496 /*
38497 * Set up the Switcher's per-cpu areas.
38498 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
38499 * it will be undisturbed when we switch. To change %cs and jump we
38500 * need this structure to feed to Intel's "lcall" instruction.
38501 */
38502 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
38503 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
38504 lguest_entry.segment = LGUEST_CS;
38505
38506 /*
38507 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
38508 index 40634b0..4f5855e 100644
38509 --- a/drivers/lguest/x86/switcher_32.S
38510 +++ b/drivers/lguest/x86/switcher_32.S
38511 @@ -87,6 +87,7 @@
38512 #include <asm/page.h>
38513 #include <asm/segment.h>
38514 #include <asm/lguest.h>
38515 +#include <asm/processor-flags.h>
38516
38517 // We mark the start of the code to copy
38518 // It's placed in .text tho it's never run here
38519 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38520 // Changes type when we load it: damn Intel!
38521 // For after we switch over our page tables
38522 // That entry will be read-only: we'd crash.
38523 +
38524 +#ifdef CONFIG_PAX_KERNEXEC
38525 + mov %cr0, %edx
38526 + xor $X86_CR0_WP, %edx
38527 + mov %edx, %cr0
38528 +#endif
38529 +
38530 movl $(GDT_ENTRY_TSS*8), %edx
38531 ltr %dx
38532
38533 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38534 // Let's clear it again for our return.
38535 // The GDT descriptor of the Host
38536 // Points to the table after two "size" bytes
38537 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38538 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38539 // Clear "used" from type field (byte 5, bit 2)
38540 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38541 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38542 +
38543 +#ifdef CONFIG_PAX_KERNEXEC
38544 + mov %cr0, %eax
38545 + xor $X86_CR0_WP, %eax
38546 + mov %eax, %cr0
38547 +#endif
38548
38549 // Once our page table's switched, the Guest is live!
38550 // The Host fades as we run this final step.
38551 @@ -295,13 +309,12 @@ deliver_to_host:
38552 // I consulted gcc, and it gave
38553 // These instructions, which I gladly credit:
38554 leal (%edx,%ebx,8), %eax
38555 - movzwl (%eax),%edx
38556 - movl 4(%eax), %eax
38557 - xorw %ax, %ax
38558 - orl %eax, %edx
38559 + movl 4(%eax), %edx
38560 + movw (%eax), %dx
38561 // Now the address of the handler's in %edx
38562 // We call it now: its "iret" drops us home.
38563 - jmp *%edx
38564 + ljmp $__KERNEL_CS, $1f
38565 +1: jmp *%edx
38566
38567 // Every interrupt can come to us here
38568 // But we must truly tell each apart.
38569 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38570 index 7155945..4bcc562 100644
38571 --- a/drivers/md/bitmap.c
38572 +++ b/drivers/md/bitmap.c
38573 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38574 chunk_kb ? "KB" : "B");
38575 if (bitmap->storage.file) {
38576 seq_printf(seq, ", file: ");
38577 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38578 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38579 }
38580
38581 seq_printf(seq, "\n");
38582 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38583 index eee353d..74504c4 100644
38584 --- a/drivers/md/dm-ioctl.c
38585 +++ b/drivers/md/dm-ioctl.c
38586 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38587 cmd == DM_LIST_VERSIONS_CMD)
38588 return 0;
38589
38590 - if ((cmd == DM_DEV_CREATE_CMD)) {
38591 + if (cmd == DM_DEV_CREATE_CMD) {
38592 if (!*param->name) {
38593 DMWARN("name not supplied when creating device");
38594 return -EINVAL;
38595 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38596 index 7f24190..0e18099 100644
38597 --- a/drivers/md/dm-raid1.c
38598 +++ b/drivers/md/dm-raid1.c
38599 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38600
38601 struct mirror {
38602 struct mirror_set *ms;
38603 - atomic_t error_count;
38604 + atomic_unchecked_t error_count;
38605 unsigned long error_type;
38606 struct dm_dev *dev;
38607 sector_t offset;
38608 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38609 struct mirror *m;
38610
38611 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38612 - if (!atomic_read(&m->error_count))
38613 + if (!atomic_read_unchecked(&m->error_count))
38614 return m;
38615
38616 return NULL;
38617 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38618 * simple way to tell if a device has encountered
38619 * errors.
38620 */
38621 - atomic_inc(&m->error_count);
38622 + atomic_inc_unchecked(&m->error_count);
38623
38624 if (test_and_set_bit(error_type, &m->error_type))
38625 return;
38626 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38627 struct mirror *m = get_default_mirror(ms);
38628
38629 do {
38630 - if (likely(!atomic_read(&m->error_count)))
38631 + if (likely(!atomic_read_unchecked(&m->error_count)))
38632 return m;
38633
38634 if (m-- == ms->mirror)
38635 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
38636 {
38637 struct mirror *default_mirror = get_default_mirror(m->ms);
38638
38639 - return !atomic_read(&default_mirror->error_count);
38640 + return !atomic_read_unchecked(&default_mirror->error_count);
38641 }
38642
38643 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38644 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38645 */
38646 if (likely(region_in_sync(ms, region, 1)))
38647 m = choose_mirror(ms, bio->bi_sector);
38648 - else if (m && atomic_read(&m->error_count))
38649 + else if (m && atomic_read_unchecked(&m->error_count))
38650 m = NULL;
38651
38652 if (likely(m))
38653 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38654 }
38655
38656 ms->mirror[mirror].ms = ms;
38657 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38658 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38659 ms->mirror[mirror].error_type = 0;
38660 ms->mirror[mirror].offset = offset;
38661
38662 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
38663 */
38664 static char device_status_char(struct mirror *m)
38665 {
38666 - if (!atomic_read(&(m->error_count)))
38667 + if (!atomic_read_unchecked(&(m->error_count)))
38668 return 'A';
38669
38670 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38671 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38672 index aaecefa..23b3026 100644
38673 --- a/drivers/md/dm-stripe.c
38674 +++ b/drivers/md/dm-stripe.c
38675 @@ -20,7 +20,7 @@ struct stripe {
38676 struct dm_dev *dev;
38677 sector_t physical_start;
38678
38679 - atomic_t error_count;
38680 + atomic_unchecked_t error_count;
38681 };
38682
38683 struct stripe_c {
38684 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38685 kfree(sc);
38686 return r;
38687 }
38688 - atomic_set(&(sc->stripe[i].error_count), 0);
38689 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38690 }
38691
38692 ti->private = sc;
38693 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38694 DMEMIT("%d ", sc->stripes);
38695 for (i = 0; i < sc->stripes; i++) {
38696 DMEMIT("%s ", sc->stripe[i].dev->name);
38697 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38698 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38699 'D' : 'A';
38700 }
38701 buffer[i] = '\0';
38702 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38703 */
38704 for (i = 0; i < sc->stripes; i++)
38705 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38706 - atomic_inc(&(sc->stripe[i].error_count));
38707 - if (atomic_read(&(sc->stripe[i].error_count)) <
38708 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38709 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38710 DM_IO_ERROR_THRESHOLD)
38711 schedule_work(&sc->trigger_event);
38712 }
38713 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38714 index daf25d0..d74f49f 100644
38715 --- a/drivers/md/dm-table.c
38716 +++ b/drivers/md/dm-table.c
38717 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38718 if (!dev_size)
38719 return 0;
38720
38721 - if ((start >= dev_size) || (start + len > dev_size)) {
38722 + if ((start >= dev_size) || (len > dev_size - start)) {
38723 DMWARN("%s: %s too small for target: "
38724 "start=%llu, len=%llu, dev_size=%llu",
38725 dm_device_name(ti->table->md), bdevname(bdev, b),
38726 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38727 index 4d6e853..a234157 100644
38728 --- a/drivers/md/dm-thin-metadata.c
38729 +++ b/drivers/md/dm-thin-metadata.c
38730 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38731 {
38732 pmd->info.tm = pmd->tm;
38733 pmd->info.levels = 2;
38734 - pmd->info.value_type.context = pmd->data_sm;
38735 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38736 pmd->info.value_type.size = sizeof(__le64);
38737 pmd->info.value_type.inc = data_block_inc;
38738 pmd->info.value_type.dec = data_block_dec;
38739 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38740
38741 pmd->bl_info.tm = pmd->tm;
38742 pmd->bl_info.levels = 1;
38743 - pmd->bl_info.value_type.context = pmd->data_sm;
38744 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38745 pmd->bl_info.value_type.size = sizeof(__le64);
38746 pmd->bl_info.value_type.inc = data_block_inc;
38747 pmd->bl_info.value_type.dec = data_block_dec;
38748 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38749 index 0d8f086..f5a91d5 100644
38750 --- a/drivers/md/dm.c
38751 +++ b/drivers/md/dm.c
38752 @@ -170,9 +170,9 @@ struct mapped_device {
38753 /*
38754 * Event handling.
38755 */
38756 - atomic_t event_nr;
38757 + atomic_unchecked_t event_nr;
38758 wait_queue_head_t eventq;
38759 - atomic_t uevent_seq;
38760 + atomic_unchecked_t uevent_seq;
38761 struct list_head uevent_list;
38762 spinlock_t uevent_lock; /* Protect access to uevent_list */
38763
38764 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
38765 rwlock_init(&md->map_lock);
38766 atomic_set(&md->holders, 1);
38767 atomic_set(&md->open_count, 0);
38768 - atomic_set(&md->event_nr, 0);
38769 - atomic_set(&md->uevent_seq, 0);
38770 + atomic_set_unchecked(&md->event_nr, 0);
38771 + atomic_set_unchecked(&md->uevent_seq, 0);
38772 INIT_LIST_HEAD(&md->uevent_list);
38773 spin_lock_init(&md->uevent_lock);
38774
38775 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38776
38777 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38778
38779 - atomic_inc(&md->event_nr);
38780 + atomic_inc_unchecked(&md->event_nr);
38781 wake_up(&md->eventq);
38782 }
38783
38784 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38785
38786 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38787 {
38788 - return atomic_add_return(1, &md->uevent_seq);
38789 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38790 }
38791
38792 uint32_t dm_get_event_nr(struct mapped_device *md)
38793 {
38794 - return atomic_read(&md->event_nr);
38795 + return atomic_read_unchecked(&md->event_nr);
38796 }
38797
38798 int dm_wait_event(struct mapped_device *md, int event_nr)
38799 {
38800 return wait_event_interruptible(md->eventq,
38801 - (event_nr != atomic_read(&md->event_nr)));
38802 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38803 }
38804
38805 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38806 diff --git a/drivers/md/md.c b/drivers/md/md.c
38807 index f363135..9b38815 100644
38808 --- a/drivers/md/md.c
38809 +++ b/drivers/md/md.c
38810 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38811 * start build, activate spare
38812 */
38813 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38814 -static atomic_t md_event_count;
38815 +static atomic_unchecked_t md_event_count;
38816 void md_new_event(struct mddev *mddev)
38817 {
38818 - atomic_inc(&md_event_count);
38819 + atomic_inc_unchecked(&md_event_count);
38820 wake_up(&md_event_waiters);
38821 }
38822 EXPORT_SYMBOL_GPL(md_new_event);
38823 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38824 */
38825 static void md_new_event_inintr(struct mddev *mddev)
38826 {
38827 - atomic_inc(&md_event_count);
38828 + atomic_inc_unchecked(&md_event_count);
38829 wake_up(&md_event_waiters);
38830 }
38831
38832 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38833 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38834 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38835 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38836 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38837 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38838
38839 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38840 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38841 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38842 else
38843 sb->resync_offset = cpu_to_le64(0);
38844
38845 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38846 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38847
38848 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38849 sb->size = cpu_to_le64(mddev->dev_sectors);
38850 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38851 static ssize_t
38852 errors_show(struct md_rdev *rdev, char *page)
38853 {
38854 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38855 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38856 }
38857
38858 static ssize_t
38859 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38860 char *e;
38861 unsigned long n = simple_strtoul(buf, &e, 10);
38862 if (*buf && (*e == 0 || *e == '\n')) {
38863 - atomic_set(&rdev->corrected_errors, n);
38864 + atomic_set_unchecked(&rdev->corrected_errors, n);
38865 return len;
38866 }
38867 return -EINVAL;
38868 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38869 rdev->sb_loaded = 0;
38870 rdev->bb_page = NULL;
38871 atomic_set(&rdev->nr_pending, 0);
38872 - atomic_set(&rdev->read_errors, 0);
38873 - atomic_set(&rdev->corrected_errors, 0);
38874 + atomic_set_unchecked(&rdev->read_errors, 0);
38875 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38876
38877 INIT_LIST_HEAD(&rdev->same_set);
38878 init_waitqueue_head(&rdev->blocked_wait);
38879 @@ -6987,7 +6987,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38880
38881 spin_unlock(&pers_lock);
38882 seq_printf(seq, "\n");
38883 - seq->poll_event = atomic_read(&md_event_count);
38884 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38885 return 0;
38886 }
38887 if (v == (void*)2) {
38888 @@ -7090,7 +7090,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38889 return error;
38890
38891 seq = file->private_data;
38892 - seq->poll_event = atomic_read(&md_event_count);
38893 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38894 return error;
38895 }
38896
38897 @@ -7104,7 +7104,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38898 /* always allow read */
38899 mask = POLLIN | POLLRDNORM;
38900
38901 - if (seq->poll_event != atomic_read(&md_event_count))
38902 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38903 mask |= POLLERR | POLLPRI;
38904 return mask;
38905 }
38906 @@ -7148,7 +7148,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38907 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38908 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38909 (int)part_stat_read(&disk->part0, sectors[1]) -
38910 - atomic_read(&disk->sync_io);
38911 + atomic_read_unchecked(&disk->sync_io);
38912 /* sync IO will cause sync_io to increase before the disk_stats
38913 * as sync_io is counted when a request starts, and
38914 * disk_stats is counted when it completes.
38915 diff --git a/drivers/md/md.h b/drivers/md/md.h
38916 index eca59c3..7c42285 100644
38917 --- a/drivers/md/md.h
38918 +++ b/drivers/md/md.h
38919 @@ -94,13 +94,13 @@ struct md_rdev {
38920 * only maintained for arrays that
38921 * support hot removal
38922 */
38923 - atomic_t read_errors; /* number of consecutive read errors that
38924 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38925 * we have tried to ignore.
38926 */
38927 struct timespec last_read_error; /* monotonic time since our
38928 * last read error
38929 */
38930 - atomic_t corrected_errors; /* number of corrected read errors,
38931 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38932 * for reporting to userspace and storing
38933 * in superblock.
38934 */
38935 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38936
38937 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38938 {
38939 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38940 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38941 }
38942
38943 struct md_personality
38944 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38945 index 1cbfc6b..56e1dbb 100644
38946 --- a/drivers/md/persistent-data/dm-space-map.h
38947 +++ b/drivers/md/persistent-data/dm-space-map.h
38948 @@ -60,6 +60,7 @@ struct dm_space_map {
38949 int (*root_size)(struct dm_space_map *sm, size_t *result);
38950 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38951 };
38952 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38953
38954 /*----------------------------------------------------------------*/
38955
38956 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38957 index fd86b37..a5389ef 100644
38958 --- a/drivers/md/raid1.c
38959 +++ b/drivers/md/raid1.c
38960 @@ -1821,7 +1821,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38961 if (r1_sync_page_io(rdev, sect, s,
38962 bio->bi_io_vec[idx].bv_page,
38963 READ) != 0)
38964 - atomic_add(s, &rdev->corrected_errors);
38965 + atomic_add_unchecked(s, &rdev->corrected_errors);
38966 }
38967 sectors -= s;
38968 sect += s;
38969 @@ -2043,7 +2043,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38970 test_bit(In_sync, &rdev->flags)) {
38971 if (r1_sync_page_io(rdev, sect, s,
38972 conf->tmppage, READ)) {
38973 - atomic_add(s, &rdev->corrected_errors);
38974 + atomic_add_unchecked(s, &rdev->corrected_errors);
38975 printk(KERN_INFO
38976 "md/raid1:%s: read error corrected "
38977 "(%d sectors at %llu on %s)\n",
38978 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38979 index b3898d4..23a462b 100644
38980 --- a/drivers/md/raid10.c
38981 +++ b/drivers/md/raid10.c
38982 @@ -1881,7 +1881,7 @@ static void end_sync_read(struct bio *bio, int error)
38983 /* The write handler will notice the lack of
38984 * R10BIO_Uptodate and record any errors etc
38985 */
38986 - atomic_add(r10_bio->sectors,
38987 + atomic_add_unchecked(r10_bio->sectors,
38988 &conf->mirrors[d].rdev->corrected_errors);
38989
38990 /* for reconstruct, we always reschedule after a read.
38991 @@ -2230,7 +2230,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38992 {
38993 struct timespec cur_time_mon;
38994 unsigned long hours_since_last;
38995 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38996 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38997
38998 ktime_get_ts(&cur_time_mon);
38999
39000 @@ -2252,9 +2252,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
39001 * overflowing the shift of read_errors by hours_since_last.
39002 */
39003 if (hours_since_last >= 8 * sizeof(read_errors))
39004 - atomic_set(&rdev->read_errors, 0);
39005 + atomic_set_unchecked(&rdev->read_errors, 0);
39006 else
39007 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
39008 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
39009 }
39010
39011 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
39012 @@ -2308,8 +2308,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
39013 return;
39014
39015 check_decay_read_errors(mddev, rdev);
39016 - atomic_inc(&rdev->read_errors);
39017 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
39018 + atomic_inc_unchecked(&rdev->read_errors);
39019 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
39020 char b[BDEVNAME_SIZE];
39021 bdevname(rdev->bdev, b);
39022
39023 @@ -2317,7 +2317,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
39024 "md/raid10:%s: %s: Raid device exceeded "
39025 "read_error threshold [cur %d:max %d]\n",
39026 mdname(mddev), b,
39027 - atomic_read(&rdev->read_errors), max_read_errors);
39028 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
39029 printk(KERN_NOTICE
39030 "md/raid10:%s: %s: Failing raid device\n",
39031 mdname(mddev), b);
39032 @@ -2472,7 +2472,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
39033 sect +
39034 choose_data_offset(r10_bio, rdev)),
39035 bdevname(rdev->bdev, b));
39036 - atomic_add(s, &rdev->corrected_errors);
39037 + atomic_add_unchecked(s, &rdev->corrected_errors);
39038 }
39039
39040 rdev_dec_pending(rdev, mddev);
39041 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
39042 index 94ce78e..df99e24 100644
39043 --- a/drivers/md/raid5.c
39044 +++ b/drivers/md/raid5.c
39045 @@ -1800,21 +1800,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
39046 mdname(conf->mddev), STRIPE_SECTORS,
39047 (unsigned long long)s,
39048 bdevname(rdev->bdev, b));
39049 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
39050 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
39051 clear_bit(R5_ReadError, &sh->dev[i].flags);
39052 clear_bit(R5_ReWrite, &sh->dev[i].flags);
39053 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
39054 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
39055
39056 - if (atomic_read(&rdev->read_errors))
39057 - atomic_set(&rdev->read_errors, 0);
39058 + if (atomic_read_unchecked(&rdev->read_errors))
39059 + atomic_set_unchecked(&rdev->read_errors, 0);
39060 } else {
39061 const char *bdn = bdevname(rdev->bdev, b);
39062 int retry = 0;
39063 int set_bad = 0;
39064
39065 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
39066 - atomic_inc(&rdev->read_errors);
39067 + atomic_inc_unchecked(&rdev->read_errors);
39068 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
39069 printk_ratelimited(
39070 KERN_WARNING
39071 @@ -1842,7 +1842,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
39072 mdname(conf->mddev),
39073 (unsigned long long)s,
39074 bdn);
39075 - } else if (atomic_read(&rdev->read_errors)
39076 + } else if (atomic_read_unchecked(&rdev->read_errors)
39077 > conf->max_nr_stripes)
39078 printk(KERN_WARNING
39079 "md/raid:%s: Too many read errors, failing device %s.\n",
39080 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
39081 index d33101a..6b13069 100644
39082 --- a/drivers/media/dvb-core/dvbdev.c
39083 +++ b/drivers/media/dvb-core/dvbdev.c
39084 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
39085 const struct dvb_device *template, void *priv, int type)
39086 {
39087 struct dvb_device *dvbdev;
39088 - struct file_operations *dvbdevfops;
39089 + file_operations_no_const *dvbdevfops;
39090 struct device *clsdev;
39091 int minor;
39092 int id;
39093 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
39094 index 404f63a..4796533 100644
39095 --- a/drivers/media/dvb-frontends/dib3000.h
39096 +++ b/drivers/media/dvb-frontends/dib3000.h
39097 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
39098 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
39099 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
39100 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
39101 -};
39102 +} __no_const;
39103
39104 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
39105 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
39106 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
39107 index bc78354..42c9459 100644
39108 --- a/drivers/media/pci/cx88/cx88-video.c
39109 +++ b/drivers/media/pci/cx88/cx88-video.c
39110 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
39111
39112 /* ------------------------------------------------------------------ */
39113
39114 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
39115 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
39116 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
39117 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
39118 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
39119 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
39120
39121 module_param_array(video_nr, int, NULL, 0444);
39122 module_param_array(vbi_nr, int, NULL, 0444);
39123 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
39124 index 8e9a668..78d6310 100644
39125 --- a/drivers/media/platform/omap/omap_vout.c
39126 +++ b/drivers/media/platform/omap/omap_vout.c
39127 @@ -63,7 +63,6 @@ enum omap_vout_channels {
39128 OMAP_VIDEO2,
39129 };
39130
39131 -static struct videobuf_queue_ops video_vbq_ops;
39132 /* Variables configurable through module params*/
39133 static u32 video1_numbuffers = 3;
39134 static u32 video2_numbuffers = 3;
39135 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
39136 {
39137 struct videobuf_queue *q;
39138 struct omap_vout_device *vout = NULL;
39139 + static struct videobuf_queue_ops video_vbq_ops = {
39140 + .buf_setup = omap_vout_buffer_setup,
39141 + .buf_prepare = omap_vout_buffer_prepare,
39142 + .buf_release = omap_vout_buffer_release,
39143 + .buf_queue = omap_vout_buffer_queue,
39144 + };
39145
39146 vout = video_drvdata(file);
39147 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
39148 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
39149 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
39150
39151 q = &vout->vbq;
39152 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
39153 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
39154 - video_vbq_ops.buf_release = omap_vout_buffer_release;
39155 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
39156 spin_lock_init(&vout->vbq_lock);
39157
39158 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
39159 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
39160 index b671e20..34088b7 100644
39161 --- a/drivers/media/platform/s5p-tv/mixer.h
39162 +++ b/drivers/media/platform/s5p-tv/mixer.h
39163 @@ -155,7 +155,7 @@ struct mxr_layer {
39164 /** layer index (unique identifier) */
39165 int idx;
39166 /** callbacks for layer methods */
39167 - struct mxr_layer_ops ops;
39168 + struct mxr_layer_ops *ops;
39169 /** format array */
39170 const struct mxr_format **fmt_array;
39171 /** size of format array */
39172 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
39173 index b93a21f..2535195 100644
39174 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
39175 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
39176 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
39177 {
39178 struct mxr_layer *layer;
39179 int ret;
39180 - struct mxr_layer_ops ops = {
39181 + static struct mxr_layer_ops ops = {
39182 .release = mxr_graph_layer_release,
39183 .buffer_set = mxr_graph_buffer_set,
39184 .stream_set = mxr_graph_stream_set,
39185 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
39186 index 3b1670a..595c939 100644
39187 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
39188 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
39189 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
39190 layer->update_buf = next;
39191 }
39192
39193 - layer->ops.buffer_set(layer, layer->update_buf);
39194 + layer->ops->buffer_set(layer, layer->update_buf);
39195
39196 if (done && done != layer->shadow_buf)
39197 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
39198 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
39199 index 1f3b743..e839271 100644
39200 --- a/drivers/media/platform/s5p-tv/mixer_video.c
39201 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
39202 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
39203 layer->geo.src.height = layer->geo.src.full_height;
39204
39205 mxr_geometry_dump(mdev, &layer->geo);
39206 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39207 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39208 mxr_geometry_dump(mdev, &layer->geo);
39209 }
39210
39211 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
39212 layer->geo.dst.full_width = mbus_fmt.width;
39213 layer->geo.dst.full_height = mbus_fmt.height;
39214 layer->geo.dst.field = mbus_fmt.field;
39215 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39216 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
39217
39218 mxr_geometry_dump(mdev, &layer->geo);
39219 }
39220 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
39221 /* set source size to highest accepted value */
39222 geo->src.full_width = max(geo->dst.full_width, pix->width);
39223 geo->src.full_height = max(geo->dst.full_height, pix->height);
39224 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39225 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39226 mxr_geometry_dump(mdev, &layer->geo);
39227 /* set cropping to total visible screen */
39228 geo->src.width = pix->width;
39229 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
39230 geo->src.x_offset = 0;
39231 geo->src.y_offset = 0;
39232 /* assure consistency of geometry */
39233 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
39234 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
39235 mxr_geometry_dump(mdev, &layer->geo);
39236 /* set full size to lowest possible value */
39237 geo->src.full_width = 0;
39238 geo->src.full_height = 0;
39239 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39240 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
39241 mxr_geometry_dump(mdev, &layer->geo);
39242
39243 /* returning results */
39244 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
39245 target->width = s->r.width;
39246 target->height = s->r.height;
39247
39248 - layer->ops.fix_geometry(layer, stage, s->flags);
39249 + layer->ops->fix_geometry(layer, stage, s->flags);
39250
39251 /* retrieve update selection rectangle */
39252 res.left = target->x_offset;
39253 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
39254 mxr_output_get(mdev);
39255
39256 mxr_layer_update_output(layer);
39257 - layer->ops.format_set(layer);
39258 + layer->ops->format_set(layer);
39259 /* enabling layer in hardware */
39260 spin_lock_irqsave(&layer->enq_slock, flags);
39261 layer->state = MXR_LAYER_STREAMING;
39262 spin_unlock_irqrestore(&layer->enq_slock, flags);
39263
39264 - layer->ops.stream_set(layer, MXR_ENABLE);
39265 + layer->ops->stream_set(layer, MXR_ENABLE);
39266 mxr_streamer_get(mdev);
39267
39268 return 0;
39269 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
39270 spin_unlock_irqrestore(&layer->enq_slock, flags);
39271
39272 /* disabling layer in hardware */
39273 - layer->ops.stream_set(layer, MXR_DISABLE);
39274 + layer->ops->stream_set(layer, MXR_DISABLE);
39275 /* remove one streamer */
39276 mxr_streamer_put(mdev);
39277 /* allow changes in output configuration */
39278 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
39279
39280 void mxr_layer_release(struct mxr_layer *layer)
39281 {
39282 - if (layer->ops.release)
39283 - layer->ops.release(layer);
39284 + if (layer->ops->release)
39285 + layer->ops->release(layer);
39286 }
39287
39288 void mxr_base_layer_release(struct mxr_layer *layer)
39289 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
39290
39291 layer->mdev = mdev;
39292 layer->idx = idx;
39293 - layer->ops = *ops;
39294 + layer->ops = ops;
39295
39296 spin_lock_init(&layer->enq_slock);
39297 INIT_LIST_HEAD(&layer->enq_list);
39298 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39299 index 3d13a63..da31bf1 100644
39300 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39301 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39302 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
39303 {
39304 struct mxr_layer *layer;
39305 int ret;
39306 - struct mxr_layer_ops ops = {
39307 + static struct mxr_layer_ops ops = {
39308 .release = mxr_vp_layer_release,
39309 .buffer_set = mxr_vp_buffer_set,
39310 .stream_set = mxr_vp_stream_set,
39311 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
39312 index 643d80a..56bb96b 100644
39313 --- a/drivers/media/radio/radio-cadet.c
39314 +++ b/drivers/media/radio/radio-cadet.c
39315 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39316 unsigned char readbuf[RDS_BUFFER];
39317 int i = 0;
39318
39319 + if (count > RDS_BUFFER)
39320 + return -EFAULT;
39321 mutex_lock(&dev->lock);
39322 if (dev->rdsstat == 0)
39323 cadet_start_rds(dev);
39324 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39325 while (i < count && dev->rdsin != dev->rdsout)
39326 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
39327
39328 - if (i && copy_to_user(data, readbuf, i))
39329 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
39330 i = -EFAULT;
39331 unlock:
39332 mutex_unlock(&dev->lock);
39333 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
39334 index 3940bb0..fb3952a 100644
39335 --- a/drivers/media/usb/dvb-usb/cxusb.c
39336 +++ b/drivers/media/usb/dvb-usb/cxusb.c
39337 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
39338
39339 struct dib0700_adapter_state {
39340 int (*set_param_save) (struct dvb_frontend *);
39341 -};
39342 +} __no_const;
39343
39344 static int dib7070_set_param_override(struct dvb_frontend *fe)
39345 {
39346 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
39347 index 9382895..ac8093c 100644
39348 --- a/drivers/media/usb/dvb-usb/dw2102.c
39349 +++ b/drivers/media/usb/dvb-usb/dw2102.c
39350 @@ -95,7 +95,7 @@ struct su3000_state {
39351
39352 struct s6x0_state {
39353 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
39354 -};
39355 +} __no_const;
39356
39357 /* debug */
39358 static int dvb_usb_dw2102_debug;
39359 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
39360 index aa6e7c7..4cd8061 100644
39361 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
39362 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
39363 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
39364 struct file *file, void *fh, void *p);
39365 } u;
39366 void (*debug)(const void *arg, bool write_only);
39367 -};
39368 +} __do_const;
39369 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
39370
39371 /* This control needs a priority check */
39372 #define INFO_FL_PRIO (1 << 0)
39373 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
39374 struct video_device *vfd = video_devdata(file);
39375 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
39376 bool write_only = false;
39377 - struct v4l2_ioctl_info default_info;
39378 + v4l2_ioctl_info_no_const default_info;
39379 const struct v4l2_ioctl_info *info;
39380 void *fh = file->private_data;
39381 struct v4l2_fh *vfh = NULL;
39382 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
39383 index 29b2172..a7c5b31 100644
39384 --- a/drivers/memstick/host/r592.c
39385 +++ b/drivers/memstick/host/r592.c
39386 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
39387 /* Executes one TPC (data is read/written from small or large fifo) */
39388 static void r592_execute_tpc(struct r592_device *dev)
39389 {
39390 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
39391 + bool is_write;
39392 int len, error;
39393 u32 status, reg;
39394
39395 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
39396 return;
39397 }
39398
39399 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
39400 len = dev->req->long_data ?
39401 dev->req->sg.length : dev->req->data_len;
39402
39403 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
39404 index fb69baa..3aeea2e 100644
39405 --- a/drivers/message/fusion/mptbase.c
39406 +++ b/drivers/message/fusion/mptbase.c
39407 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39408 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
39409 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
39410
39411 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39412 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
39413 +#else
39414 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
39415 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
39416 +#endif
39417 +
39418 /*
39419 * Rounding UP to nearest 4-kB boundary here...
39420 */
39421 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39422 ioc->facts.GlobalCredits);
39423
39424 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
39425 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39426 + NULL, NULL);
39427 +#else
39428 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
39429 +#endif
39430 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
39431 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
39432 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
39433 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
39434 index fa43c39..daeb158 100644
39435 --- a/drivers/message/fusion/mptsas.c
39436 +++ b/drivers/message/fusion/mptsas.c
39437 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
39438 return 0;
39439 }
39440
39441 +static inline void
39442 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39443 +{
39444 + if (phy_info->port_details) {
39445 + phy_info->port_details->rphy = rphy;
39446 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39447 + ioc->name, rphy));
39448 + }
39449 +
39450 + if (rphy) {
39451 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39452 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39453 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39454 + ioc->name, rphy, rphy->dev.release));
39455 + }
39456 +}
39457 +
39458 /* no mutex */
39459 static void
39460 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
39461 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
39462 return NULL;
39463 }
39464
39465 -static inline void
39466 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39467 -{
39468 - if (phy_info->port_details) {
39469 - phy_info->port_details->rphy = rphy;
39470 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39471 - ioc->name, rphy));
39472 - }
39473 -
39474 - if (rphy) {
39475 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39476 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39477 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39478 - ioc->name, rphy, rphy->dev.release));
39479 - }
39480 -}
39481 -
39482 static inline struct sas_port *
39483 mptsas_get_port(struct mptsas_phyinfo *phy_info)
39484 {
39485 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
39486 index 164afa7..b6b2e74 100644
39487 --- a/drivers/message/fusion/mptscsih.c
39488 +++ b/drivers/message/fusion/mptscsih.c
39489 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
39490
39491 h = shost_priv(SChost);
39492
39493 - if (h) {
39494 - if (h->info_kbuf == NULL)
39495 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39496 - return h->info_kbuf;
39497 - h->info_kbuf[0] = '\0';
39498 + if (!h)
39499 + return NULL;
39500
39501 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39502 - h->info_kbuf[size-1] = '\0';
39503 - }
39504 + if (h->info_kbuf == NULL)
39505 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39506 + return h->info_kbuf;
39507 + h->info_kbuf[0] = '\0';
39508 +
39509 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39510 + h->info_kbuf[size-1] = '\0';
39511
39512 return h->info_kbuf;
39513 }
39514 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39515 index 8001aa6..b137580 100644
39516 --- a/drivers/message/i2o/i2o_proc.c
39517 +++ b/drivers/message/i2o/i2o_proc.c
39518 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39519 "Array Controller Device"
39520 };
39521
39522 -static char *chtostr(char *tmp, u8 *chars, int n)
39523 -{
39524 - tmp[0] = 0;
39525 - return strncat(tmp, (char *)chars, n);
39526 -}
39527 -
39528 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39529 char *group)
39530 {
39531 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39532 } *result;
39533
39534 i2o_exec_execute_ddm_table ddm_table;
39535 - char tmp[28 + 1];
39536
39537 result = kmalloc(sizeof(*result), GFP_KERNEL);
39538 if (!result)
39539 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39540
39541 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39542 seq_printf(seq, "%-#8x", ddm_table.module_id);
39543 - seq_printf(seq, "%-29s",
39544 - chtostr(tmp, ddm_table.module_name_version, 28));
39545 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39546 seq_printf(seq, "%9d ", ddm_table.data_size);
39547 seq_printf(seq, "%8d", ddm_table.code_size);
39548
39549 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39550
39551 i2o_driver_result_table *result;
39552 i2o_driver_store_table *dst;
39553 - char tmp[28 + 1];
39554
39555 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39556 if (result == NULL)
39557 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39558
39559 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39560 seq_printf(seq, "%-#8x", dst->module_id);
39561 - seq_printf(seq, "%-29s",
39562 - chtostr(tmp, dst->module_name_version, 28));
39563 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39564 + seq_printf(seq, "%-.28s", dst->module_name_version);
39565 + seq_printf(seq, "%-.8s", dst->date);
39566 seq_printf(seq, "%8d ", dst->module_size);
39567 seq_printf(seq, "%8d ", dst->mpb_size);
39568 seq_printf(seq, "0x%04x", dst->module_flags);
39569 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39570 // == (allow) 512d bytes (max)
39571 static u16 *work16 = (u16 *) work32;
39572 int token;
39573 - char tmp[16 + 1];
39574
39575 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39576
39577 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39578 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39579 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39580 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39581 - seq_printf(seq, "Vendor info : %s\n",
39582 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39583 - seq_printf(seq, "Product info : %s\n",
39584 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39585 - seq_printf(seq, "Description : %s\n",
39586 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39587 - seq_printf(seq, "Product rev. : %s\n",
39588 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39589 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39590 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39591 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39592 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39593
39594 seq_printf(seq, "Serial number : ");
39595 print_serial_number(seq, (u8 *) (work32 + 16),
39596 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39597 u8 pad[256]; // allow up to 256 byte (max) serial number
39598 } result;
39599
39600 - char tmp[24 + 1];
39601 -
39602 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39603
39604 if (token < 0) {
39605 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39606 }
39607
39608 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39609 - seq_printf(seq, "Module name : %s\n",
39610 - chtostr(tmp, result.module_name, 24));
39611 - seq_printf(seq, "Module revision : %s\n",
39612 - chtostr(tmp, result.module_rev, 8));
39613 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39614 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39615
39616 seq_printf(seq, "Serial number : ");
39617 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39618 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39619 u8 instance_number[4];
39620 } result;
39621
39622 - char tmp[64 + 1];
39623 -
39624 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39625
39626 if (token < 0) {
39627 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39628 return 0;
39629 }
39630
39631 - seq_printf(seq, "Device name : %s\n",
39632 - chtostr(tmp, result.device_name, 64));
39633 - seq_printf(seq, "Service name : %s\n",
39634 - chtostr(tmp, result.service_name, 64));
39635 - seq_printf(seq, "Physical name : %s\n",
39636 - chtostr(tmp, result.physical_location, 64));
39637 - seq_printf(seq, "Instance number : %s\n",
39638 - chtostr(tmp, result.instance_number, 4));
39639 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39640 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39641 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39642 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39643
39644 return 0;
39645 }
39646 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39647 index a8c08f3..155fe3d 100644
39648 --- a/drivers/message/i2o/iop.c
39649 +++ b/drivers/message/i2o/iop.c
39650 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39651
39652 spin_lock_irqsave(&c->context_list_lock, flags);
39653
39654 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39655 - atomic_inc(&c->context_list_counter);
39656 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39657 + atomic_inc_unchecked(&c->context_list_counter);
39658
39659 - entry->context = atomic_read(&c->context_list_counter);
39660 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39661
39662 list_add(&entry->list, &c->context_list);
39663
39664 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39665
39666 #if BITS_PER_LONG == 64
39667 spin_lock_init(&c->context_list_lock);
39668 - atomic_set(&c->context_list_counter, 0);
39669 + atomic_set_unchecked(&c->context_list_counter, 0);
39670 INIT_LIST_HEAD(&c->context_list);
39671 #endif
39672
39673 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39674 index 45ece11..8efa218 100644
39675 --- a/drivers/mfd/janz-cmodio.c
39676 +++ b/drivers/mfd/janz-cmodio.c
39677 @@ -13,6 +13,7 @@
39678
39679 #include <linux/kernel.h>
39680 #include <linux/module.h>
39681 +#include <linux/slab.h>
39682 #include <linux/init.h>
39683 #include <linux/pci.h>
39684 #include <linux/interrupt.h>
39685 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39686 index a5f9888..1c0ed56 100644
39687 --- a/drivers/mfd/twl4030-irq.c
39688 +++ b/drivers/mfd/twl4030-irq.c
39689 @@ -35,6 +35,7 @@
39690 #include <linux/of.h>
39691 #include <linux/irqdomain.h>
39692 #include <linux/i2c/twl.h>
39693 +#include <asm/pgtable.h>
39694
39695 #include "twl-core.h"
39696
39697 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39698 * Install an irq handler for each of the SIH modules;
39699 * clone dummy irq_chip since PIH can't *do* anything
39700 */
39701 - twl4030_irq_chip = dummy_irq_chip;
39702 - twl4030_irq_chip.name = "twl4030";
39703 + pax_open_kernel();
39704 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39705 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39706
39707 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39708 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39709 + pax_close_kernel();
39710
39711 for (i = irq_base; i < irq_end; i++) {
39712 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39713 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39714 index 277a8db..0e0b754 100644
39715 --- a/drivers/mfd/twl6030-irq.c
39716 +++ b/drivers/mfd/twl6030-irq.c
39717 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39718 * install an irq handler for each of the modules;
39719 * clone dummy irq_chip since PIH can't *do* anything
39720 */
39721 - twl6030_irq_chip = dummy_irq_chip;
39722 - twl6030_irq_chip.name = "twl6030";
39723 - twl6030_irq_chip.irq_set_type = NULL;
39724 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39725 + pax_open_kernel();
39726 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39727 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39728 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39729 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39730 + pax_close_kernel();
39731
39732 for (i = irq_base; i < irq_end; i++) {
39733 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39734 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39735 index f428d86..274c368 100644
39736 --- a/drivers/misc/c2port/core.c
39737 +++ b/drivers/misc/c2port/core.c
39738 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
39739 mutex_init(&c2dev->mutex);
39740
39741 /* Create binary file */
39742 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39743 + pax_open_kernel();
39744 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39745 + pax_close_kernel();
39746 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39747 if (unlikely(ret))
39748 goto error_device_create_bin_file;
39749 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39750 index 3aa9a96..59cf685 100644
39751 --- a/drivers/misc/kgdbts.c
39752 +++ b/drivers/misc/kgdbts.c
39753 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
39754 char before[BREAK_INSTR_SIZE];
39755 char after[BREAK_INSTR_SIZE];
39756
39757 - probe_kernel_read(before, (char *)kgdbts_break_test,
39758 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39759 BREAK_INSTR_SIZE);
39760 init_simple_test();
39761 ts.tst = plant_and_detach_test;
39762 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
39763 /* Activate test with initial breakpoint */
39764 if (!is_early)
39765 kgdb_breakpoint();
39766 - probe_kernel_read(after, (char *)kgdbts_break_test,
39767 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39768 BREAK_INSTR_SIZE);
39769 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39770 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39771 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39772 index 4a87e5c..76bdf5c 100644
39773 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39774 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39775 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39776 * the lid is closed. This leads to interrupts as soon as a little move
39777 * is done.
39778 */
39779 - atomic_inc(&lis3->count);
39780 + atomic_inc_unchecked(&lis3->count);
39781
39782 wake_up_interruptible(&lis3->misc_wait);
39783 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39784 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39785 if (lis3->pm_dev)
39786 pm_runtime_get_sync(lis3->pm_dev);
39787
39788 - atomic_set(&lis3->count, 0);
39789 + atomic_set_unchecked(&lis3->count, 0);
39790 return 0;
39791 }
39792
39793 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39794 add_wait_queue(&lis3->misc_wait, &wait);
39795 while (true) {
39796 set_current_state(TASK_INTERRUPTIBLE);
39797 - data = atomic_xchg(&lis3->count, 0);
39798 + data = atomic_xchg_unchecked(&lis3->count, 0);
39799 if (data)
39800 break;
39801
39802 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39803 struct lis3lv02d, miscdev);
39804
39805 poll_wait(file, &lis3->misc_wait, wait);
39806 - if (atomic_read(&lis3->count))
39807 + if (atomic_read_unchecked(&lis3->count))
39808 return POLLIN | POLLRDNORM;
39809 return 0;
39810 }
39811 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39812 index c439c82..1f20f57 100644
39813 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39814 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39815 @@ -297,7 +297,7 @@ struct lis3lv02d {
39816 struct input_polled_dev *idev; /* input device */
39817 struct platform_device *pdev; /* platform device */
39818 struct regulator_bulk_data regulators[2];
39819 - atomic_t count; /* interrupt count after last read */
39820 + atomic_unchecked_t count; /* interrupt count after last read */
39821 union axis_conversion ac; /* hw -> logical axis */
39822 int mapped_btns[3];
39823
39824 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39825 index 2f30bad..c4c13d0 100644
39826 --- a/drivers/misc/sgi-gru/gruhandles.c
39827 +++ b/drivers/misc/sgi-gru/gruhandles.c
39828 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39829 unsigned long nsec;
39830
39831 nsec = CLKS2NSEC(clks);
39832 - atomic_long_inc(&mcs_op_statistics[op].count);
39833 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39834 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39835 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39836 if (mcs_op_statistics[op].max < nsec)
39837 mcs_op_statistics[op].max = nsec;
39838 }
39839 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39840 index 950dbe9..eeef0f8 100644
39841 --- a/drivers/misc/sgi-gru/gruprocfs.c
39842 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39843 @@ -32,9 +32,9 @@
39844
39845 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39846
39847 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39848 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39849 {
39850 - unsigned long val = atomic_long_read(v);
39851 + unsigned long val = atomic_long_read_unchecked(v);
39852
39853 seq_printf(s, "%16lu %s\n", val, id);
39854 }
39855 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39856
39857 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39858 for (op = 0; op < mcsop_last; op++) {
39859 - count = atomic_long_read(&mcs_op_statistics[op].count);
39860 - total = atomic_long_read(&mcs_op_statistics[op].total);
39861 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39862 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39863 max = mcs_op_statistics[op].max;
39864 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39865 count ? total / count : 0, max);
39866 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39867 index 5c3ce24..4915ccb 100644
39868 --- a/drivers/misc/sgi-gru/grutables.h
39869 +++ b/drivers/misc/sgi-gru/grutables.h
39870 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39871 * GRU statistics.
39872 */
39873 struct gru_stats_s {
39874 - atomic_long_t vdata_alloc;
39875 - atomic_long_t vdata_free;
39876 - atomic_long_t gts_alloc;
39877 - atomic_long_t gts_free;
39878 - atomic_long_t gms_alloc;
39879 - atomic_long_t gms_free;
39880 - atomic_long_t gts_double_allocate;
39881 - atomic_long_t assign_context;
39882 - atomic_long_t assign_context_failed;
39883 - atomic_long_t free_context;
39884 - atomic_long_t load_user_context;
39885 - atomic_long_t load_kernel_context;
39886 - atomic_long_t lock_kernel_context;
39887 - atomic_long_t unlock_kernel_context;
39888 - atomic_long_t steal_user_context;
39889 - atomic_long_t steal_kernel_context;
39890 - atomic_long_t steal_context_failed;
39891 - atomic_long_t nopfn;
39892 - atomic_long_t asid_new;
39893 - atomic_long_t asid_next;
39894 - atomic_long_t asid_wrap;
39895 - atomic_long_t asid_reuse;
39896 - atomic_long_t intr;
39897 - atomic_long_t intr_cbr;
39898 - atomic_long_t intr_tfh;
39899 - atomic_long_t intr_spurious;
39900 - atomic_long_t intr_mm_lock_failed;
39901 - atomic_long_t call_os;
39902 - atomic_long_t call_os_wait_queue;
39903 - atomic_long_t user_flush_tlb;
39904 - atomic_long_t user_unload_context;
39905 - atomic_long_t user_exception;
39906 - atomic_long_t set_context_option;
39907 - atomic_long_t check_context_retarget_intr;
39908 - atomic_long_t check_context_unload;
39909 - atomic_long_t tlb_dropin;
39910 - atomic_long_t tlb_preload_page;
39911 - atomic_long_t tlb_dropin_fail_no_asid;
39912 - atomic_long_t tlb_dropin_fail_upm;
39913 - atomic_long_t tlb_dropin_fail_invalid;
39914 - atomic_long_t tlb_dropin_fail_range_active;
39915 - atomic_long_t tlb_dropin_fail_idle;
39916 - atomic_long_t tlb_dropin_fail_fmm;
39917 - atomic_long_t tlb_dropin_fail_no_exception;
39918 - atomic_long_t tfh_stale_on_fault;
39919 - atomic_long_t mmu_invalidate_range;
39920 - atomic_long_t mmu_invalidate_page;
39921 - atomic_long_t flush_tlb;
39922 - atomic_long_t flush_tlb_gru;
39923 - atomic_long_t flush_tlb_gru_tgh;
39924 - atomic_long_t flush_tlb_gru_zero_asid;
39925 + atomic_long_unchecked_t vdata_alloc;
39926 + atomic_long_unchecked_t vdata_free;
39927 + atomic_long_unchecked_t gts_alloc;
39928 + atomic_long_unchecked_t gts_free;
39929 + atomic_long_unchecked_t gms_alloc;
39930 + atomic_long_unchecked_t gms_free;
39931 + atomic_long_unchecked_t gts_double_allocate;
39932 + atomic_long_unchecked_t assign_context;
39933 + atomic_long_unchecked_t assign_context_failed;
39934 + atomic_long_unchecked_t free_context;
39935 + atomic_long_unchecked_t load_user_context;
39936 + atomic_long_unchecked_t load_kernel_context;
39937 + atomic_long_unchecked_t lock_kernel_context;
39938 + atomic_long_unchecked_t unlock_kernel_context;
39939 + atomic_long_unchecked_t steal_user_context;
39940 + atomic_long_unchecked_t steal_kernel_context;
39941 + atomic_long_unchecked_t steal_context_failed;
39942 + atomic_long_unchecked_t nopfn;
39943 + atomic_long_unchecked_t asid_new;
39944 + atomic_long_unchecked_t asid_next;
39945 + atomic_long_unchecked_t asid_wrap;
39946 + atomic_long_unchecked_t asid_reuse;
39947 + atomic_long_unchecked_t intr;
39948 + atomic_long_unchecked_t intr_cbr;
39949 + atomic_long_unchecked_t intr_tfh;
39950 + atomic_long_unchecked_t intr_spurious;
39951 + atomic_long_unchecked_t intr_mm_lock_failed;
39952 + atomic_long_unchecked_t call_os;
39953 + atomic_long_unchecked_t call_os_wait_queue;
39954 + atomic_long_unchecked_t user_flush_tlb;
39955 + atomic_long_unchecked_t user_unload_context;
39956 + atomic_long_unchecked_t user_exception;
39957 + atomic_long_unchecked_t set_context_option;
39958 + atomic_long_unchecked_t check_context_retarget_intr;
39959 + atomic_long_unchecked_t check_context_unload;
39960 + atomic_long_unchecked_t tlb_dropin;
39961 + atomic_long_unchecked_t tlb_preload_page;
39962 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39963 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39964 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39965 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39966 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39967 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39968 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39969 + atomic_long_unchecked_t tfh_stale_on_fault;
39970 + atomic_long_unchecked_t mmu_invalidate_range;
39971 + atomic_long_unchecked_t mmu_invalidate_page;
39972 + atomic_long_unchecked_t flush_tlb;
39973 + atomic_long_unchecked_t flush_tlb_gru;
39974 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39975 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39976
39977 - atomic_long_t copy_gpa;
39978 - atomic_long_t read_gpa;
39979 + atomic_long_unchecked_t copy_gpa;
39980 + atomic_long_unchecked_t read_gpa;
39981
39982 - atomic_long_t mesq_receive;
39983 - atomic_long_t mesq_receive_none;
39984 - atomic_long_t mesq_send;
39985 - atomic_long_t mesq_send_failed;
39986 - atomic_long_t mesq_noop;
39987 - atomic_long_t mesq_send_unexpected_error;
39988 - atomic_long_t mesq_send_lb_overflow;
39989 - atomic_long_t mesq_send_qlimit_reached;
39990 - atomic_long_t mesq_send_amo_nacked;
39991 - atomic_long_t mesq_send_put_nacked;
39992 - atomic_long_t mesq_page_overflow;
39993 - atomic_long_t mesq_qf_locked;
39994 - atomic_long_t mesq_qf_noop_not_full;
39995 - atomic_long_t mesq_qf_switch_head_failed;
39996 - atomic_long_t mesq_qf_unexpected_error;
39997 - atomic_long_t mesq_noop_unexpected_error;
39998 - atomic_long_t mesq_noop_lb_overflow;
39999 - atomic_long_t mesq_noop_qlimit_reached;
40000 - atomic_long_t mesq_noop_amo_nacked;
40001 - atomic_long_t mesq_noop_put_nacked;
40002 - atomic_long_t mesq_noop_page_overflow;
40003 + atomic_long_unchecked_t mesq_receive;
40004 + atomic_long_unchecked_t mesq_receive_none;
40005 + atomic_long_unchecked_t mesq_send;
40006 + atomic_long_unchecked_t mesq_send_failed;
40007 + atomic_long_unchecked_t mesq_noop;
40008 + atomic_long_unchecked_t mesq_send_unexpected_error;
40009 + atomic_long_unchecked_t mesq_send_lb_overflow;
40010 + atomic_long_unchecked_t mesq_send_qlimit_reached;
40011 + atomic_long_unchecked_t mesq_send_amo_nacked;
40012 + atomic_long_unchecked_t mesq_send_put_nacked;
40013 + atomic_long_unchecked_t mesq_page_overflow;
40014 + atomic_long_unchecked_t mesq_qf_locked;
40015 + atomic_long_unchecked_t mesq_qf_noop_not_full;
40016 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
40017 + atomic_long_unchecked_t mesq_qf_unexpected_error;
40018 + atomic_long_unchecked_t mesq_noop_unexpected_error;
40019 + atomic_long_unchecked_t mesq_noop_lb_overflow;
40020 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
40021 + atomic_long_unchecked_t mesq_noop_amo_nacked;
40022 + atomic_long_unchecked_t mesq_noop_put_nacked;
40023 + atomic_long_unchecked_t mesq_noop_page_overflow;
40024
40025 };
40026
40027 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
40028 tghop_invalidate, mcsop_last};
40029
40030 struct mcs_op_statistic {
40031 - atomic_long_t count;
40032 - atomic_long_t total;
40033 + atomic_long_unchecked_t count;
40034 + atomic_long_unchecked_t total;
40035 unsigned long max;
40036 };
40037
40038 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
40039
40040 #define STAT(id) do { \
40041 if (gru_options & OPT_STATS) \
40042 - atomic_long_inc(&gru_stats.id); \
40043 + atomic_long_inc_unchecked(&gru_stats.id); \
40044 } while (0)
40045
40046 #ifdef CONFIG_SGI_GRU_DEBUG
40047 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
40048 index c862cd4..0d176fe 100644
40049 --- a/drivers/misc/sgi-xp/xp.h
40050 +++ b/drivers/misc/sgi-xp/xp.h
40051 @@ -288,7 +288,7 @@ struct xpc_interface {
40052 xpc_notify_func, void *);
40053 void (*received) (short, int, void *);
40054 enum xp_retval (*partid_to_nasids) (short, void *);
40055 -};
40056 +} __no_const;
40057
40058 extern struct xpc_interface xpc_interface;
40059
40060 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
40061 index b94d5f7..7f494c5 100644
40062 --- a/drivers/misc/sgi-xp/xpc.h
40063 +++ b/drivers/misc/sgi-xp/xpc.h
40064 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
40065 void (*received_payload) (struct xpc_channel *, void *);
40066 void (*notify_senders_of_disconnect) (struct xpc_channel *);
40067 };
40068 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
40069
40070 /* struct xpc_partition act_state values (for XPC HB) */
40071
40072 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
40073 /* found in xpc_main.c */
40074 extern struct device *xpc_part;
40075 extern struct device *xpc_chan;
40076 -extern struct xpc_arch_operations xpc_arch_ops;
40077 +extern xpc_arch_operations_no_const xpc_arch_ops;
40078 extern int xpc_disengage_timelimit;
40079 extern int xpc_disengage_timedout;
40080 extern int xpc_activate_IRQ_rcvd;
40081 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
40082 index d971817..33bdca5 100644
40083 --- a/drivers/misc/sgi-xp/xpc_main.c
40084 +++ b/drivers/misc/sgi-xp/xpc_main.c
40085 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
40086 .notifier_call = xpc_system_die,
40087 };
40088
40089 -struct xpc_arch_operations xpc_arch_ops;
40090 +xpc_arch_operations_no_const xpc_arch_ops;
40091
40092 /*
40093 * Timer function to enforce the timelimit on the partition disengage.
40094 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
40095
40096 if (((die_args->trapnr == X86_TRAP_MF) ||
40097 (die_args->trapnr == X86_TRAP_XF)) &&
40098 - !user_mode_vm(die_args->regs))
40099 + !user_mode(die_args->regs))
40100 xpc_die_deactivate();
40101
40102 break;
40103 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
40104 index 6d8f701..35b6369 100644
40105 --- a/drivers/mmc/core/mmc_ops.c
40106 +++ b/drivers/mmc/core/mmc_ops.c
40107 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
40108 void *data_buf;
40109 int is_on_stack;
40110
40111 - is_on_stack = object_is_on_stack(buf);
40112 + is_on_stack = object_starts_on_stack(buf);
40113 if (is_on_stack) {
40114 /*
40115 * dma onto stack is unsafe/nonportable, but callers to this
40116 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
40117 index 53b8fd9..615b462 100644
40118 --- a/drivers/mmc/host/dw_mmc.h
40119 +++ b/drivers/mmc/host/dw_mmc.h
40120 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
40121 int (*parse_dt)(struct dw_mci *host);
40122 int (*setup_bus)(struct dw_mci *host,
40123 struct device_node *slot_np, u8 bus_width);
40124 -};
40125 +} __do_const;
40126 #endif /* _DW_MMC_H_ */
40127 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
40128 index 82a8de1..3c56ccb 100644
40129 --- a/drivers/mmc/host/sdhci-s3c.c
40130 +++ b/drivers/mmc/host/sdhci-s3c.c
40131 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
40132 * we can use overriding functions instead of default.
40133 */
40134 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
40135 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
40136 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
40137 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
40138 + pax_open_kernel();
40139 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
40140 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
40141 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
40142 + pax_close_kernel();
40143 }
40144
40145 /* It supports additional host capabilities if needed */
40146 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
40147 index a4eb8b5..8c0628f 100644
40148 --- a/drivers/mtd/devices/doc2000.c
40149 +++ b/drivers/mtd/devices/doc2000.c
40150 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
40151
40152 /* The ECC will not be calculated correctly if less than 512 is written */
40153 /* DBB-
40154 - if (len != 0x200 && eccbuf)
40155 + if (len != 0x200)
40156 printk(KERN_WARNING
40157 "ECC needs a full sector write (adr: %lx size %lx)\n",
40158 (long) to, (long) len);
40159 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
40160 index 0c8bb6b..6f35deb 100644
40161 --- a/drivers/mtd/nand/denali.c
40162 +++ b/drivers/mtd/nand/denali.c
40163 @@ -24,6 +24,7 @@
40164 #include <linux/slab.h>
40165 #include <linux/mtd/mtd.h>
40166 #include <linux/module.h>
40167 +#include <linux/slab.h>
40168
40169 #include "denali.h"
40170
40171 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
40172 index 51b9d6a..52af9a7 100644
40173 --- a/drivers/mtd/nftlmount.c
40174 +++ b/drivers/mtd/nftlmount.c
40175 @@ -24,6 +24,7 @@
40176 #include <asm/errno.h>
40177 #include <linux/delay.h>
40178 #include <linux/slab.h>
40179 +#include <linux/sched.h>
40180 #include <linux/mtd/mtd.h>
40181 #include <linux/mtd/nand.h>
40182 #include <linux/mtd/nftl.h>
40183 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
40184 index 8dd6ba5..419cc1d 100644
40185 --- a/drivers/mtd/sm_ftl.c
40186 +++ b/drivers/mtd/sm_ftl.c
40187 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
40188 #define SM_CIS_VENDOR_OFFSET 0x59
40189 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
40190 {
40191 - struct attribute_group *attr_group;
40192 + attribute_group_no_const *attr_group;
40193 struct attribute **attributes;
40194 struct sm_sysfs_attribute *vendor_attribute;
40195
40196 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
40197 index 27cdf1f..8c37357 100644
40198 --- a/drivers/net/bonding/bond_main.c
40199 +++ b/drivers/net/bonding/bond_main.c
40200 @@ -4859,7 +4859,7 @@ static unsigned int bond_get_num_tx_queues(void)
40201 return tx_queues;
40202 }
40203
40204 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
40205 +static struct rtnl_link_ops bond_link_ops = {
40206 .kind = "bond",
40207 .priv_size = sizeof(struct bonding),
40208 .setup = bond_setup,
40209 @@ -4975,8 +4975,8 @@ static void __exit bonding_exit(void)
40210
40211 bond_destroy_debugfs();
40212
40213 - rtnl_link_unregister(&bond_link_ops);
40214 unregister_pernet_subsys(&bond_net_ops);
40215 + rtnl_link_unregister(&bond_link_ops);
40216
40217 #ifdef CONFIG_NET_POLL_CONTROLLER
40218 /*
40219 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
40220 index 70dba5d..11a0919 100644
40221 --- a/drivers/net/ethernet/8390/ax88796.c
40222 +++ b/drivers/net/ethernet/8390/ax88796.c
40223 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
40224 if (ax->plat->reg_offsets)
40225 ei_local->reg_offset = ax->plat->reg_offsets;
40226 else {
40227 + resource_size_t _mem_size = mem_size;
40228 + do_div(_mem_size, 0x18);
40229 ei_local->reg_offset = ax->reg_offsets;
40230 for (ret = 0; ret < 0x18; ret++)
40231 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
40232 + ax->reg_offsets[ret] = _mem_size * ret;
40233 }
40234
40235 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
40236 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40237 index 0991534..8098e92 100644
40238 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40239 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40240 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
40241 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
40242 {
40243 /* RX_MODE controlling object */
40244 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
40245 + bnx2x_init_rx_mode_obj(bp);
40246
40247 /* multicast configuration controlling object */
40248 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
40249 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
40250 index 10bc093..a2fb42a 100644
40251 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
40252 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
40253 @@ -2136,12 +2136,12 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
40254 break;
40255 default:
40256 BNX2X_ERR("Non valid capability ID\n");
40257 - rval = -EINVAL;
40258 + rval = 1;
40259 break;
40260 }
40261 } else {
40262 DP(BNX2X_MSG_DCB, "DCB disabled\n");
40263 - rval = -EINVAL;
40264 + rval = 1;
40265 }
40266
40267 DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
40268 @@ -2167,12 +2167,12 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num)
40269 break;
40270 default:
40271 BNX2X_ERR("Non valid TC-ID\n");
40272 - rval = -EINVAL;
40273 + rval = 1;
40274 break;
40275 }
40276 } else {
40277 DP(BNX2X_MSG_DCB, "DCB disabled\n");
40278 - rval = -EINVAL;
40279 + rval = 1;
40280 }
40281
40282 return rval;
40283 @@ -2185,7 +2185,7 @@ static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num)
40284 return -EINVAL;
40285 }
40286
40287 -static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
40288 +static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
40289 {
40290 struct bnx2x *bp = netdev_priv(netdev);
40291 DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
40292 @@ -2387,12 +2387,12 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
40293 break;
40294 default:
40295 BNX2X_ERR("Non valid featrue-ID\n");
40296 - rval = -EINVAL;
40297 + rval = 1;
40298 break;
40299 }
40300 } else {
40301 DP(BNX2X_MSG_DCB, "DCB disabled\n");
40302 - rval = -EINVAL;
40303 + rval = 1;
40304 }
40305
40306 return rval;
40307 @@ -2428,12 +2428,12 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid,
40308 break;
40309 default:
40310 BNX2X_ERR("Non valid featrue-ID\n");
40311 - rval = -EINVAL;
40312 + rval = 1;
40313 break;
40314 }
40315 } else {
40316 DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
40317 - rval = -EINVAL;
40318 + rval = 1;
40319 }
40320
40321 return rval;
40322 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40323 index 5523da3..4fcf274 100644
40324 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40325 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
40326 @@ -4767,7 +4767,7 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
40327 q);
40328 }
40329
40330 - if (!NO_FCOE(bp)) {
40331 + if (!NO_FCOE(bp) && CNIC_ENABLED(bp)) {
40332 fp = &bp->fp[FCOE_IDX(bp)];
40333 queue_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
40334
40335 @@ -13047,6 +13047,7 @@ static int bnx2x_unregister_cnic(struct net_device *dev)
40336 RCU_INIT_POINTER(bp->cnic_ops, NULL);
40337 mutex_unlock(&bp->cnic_mutex);
40338 synchronize_rcu();
40339 + bp->cnic_enabled = false;
40340 kfree(bp->cnic_kwq);
40341 bp->cnic_kwq = NULL;
40342
40343 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40344 index 09b625e..15b16fe 100644
40345 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40346 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40347 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
40348 return rc;
40349 }
40350
40351 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40352 - struct bnx2x_rx_mode_obj *o)
40353 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
40354 {
40355 if (CHIP_IS_E1x(bp)) {
40356 - o->wait_comp = bnx2x_empty_rx_mode_wait;
40357 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
40358 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
40359 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
40360 } else {
40361 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
40362 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
40363 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
40364 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
40365 }
40366 }
40367
40368 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40369 index adbd91b..58ec94a 100644
40370 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40371 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40372 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
40373
40374 /********************* RX MODE ****************/
40375
40376 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40377 - struct bnx2x_rx_mode_obj *o);
40378 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
40379
40380 /**
40381 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
40382 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
40383 index 6f9b74c..7f219b8 100644
40384 --- a/drivers/net/ethernet/broadcom/tg3.h
40385 +++ b/drivers/net/ethernet/broadcom/tg3.h
40386 @@ -146,6 +146,7 @@
40387 #define CHIPREV_ID_5750_A0 0x4000
40388 #define CHIPREV_ID_5750_A1 0x4001
40389 #define CHIPREV_ID_5750_A3 0x4003
40390 +#define CHIPREV_ID_5750_C1 0x4201
40391 #define CHIPREV_ID_5750_C2 0x4202
40392 #define CHIPREV_ID_5752_A0_HW 0x5000
40393 #define CHIPREV_ID_5752_A0 0x6000
40394 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40395 index 8cffcdf..aadf043 100644
40396 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40397 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40398 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
40399 */
40400 struct l2t_skb_cb {
40401 arp_failure_handler_func arp_failure_handler;
40402 -};
40403 +} __no_const;
40404
40405 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
40406
40407 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
40408 index 4c83003..2a2a5b9 100644
40409 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
40410 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
40411 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40412 for (i=0; i<ETH_ALEN; i++) {
40413 tmp.addr[i] = dev->dev_addr[i];
40414 }
40415 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40416 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40417 break;
40418
40419 case DE4X5_SET_HWADDR: /* Set the hardware address */
40420 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40421 spin_lock_irqsave(&lp->lock, flags);
40422 memcpy(&statbuf, &lp->pktStats, ioc->len);
40423 spin_unlock_irqrestore(&lp->lock, flags);
40424 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
40425 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
40426 return -EFAULT;
40427 break;
40428 }
40429 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
40430 index 4d6f3c5..449bc5c 100644
40431 --- a/drivers/net/ethernet/emulex/benet/be_main.c
40432 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
40433 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
40434
40435 if (wrapped)
40436 newacc += 65536;
40437 - ACCESS_ONCE(*acc) = newacc;
40438 + ACCESS_ONCE_RW(*acc) = newacc;
40439 }
40440
40441 void be_parse_stats(struct be_adapter *adapter)
40442 @@ -759,8 +759,9 @@ static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter,
40443
40444 if (vlan_tx_tag_present(skb)) {
40445 vlan_tag = be_get_tx_vlan_tag(adapter, skb);
40446 - __vlan_put_tag(skb, vlan_tag);
40447 - skb->vlan_tci = 0;
40448 + skb = __vlan_put_tag(skb, vlan_tag);
40449 + if (skb)
40450 + skb->vlan_tci = 0;
40451 }
40452
40453 return skb;
40454 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
40455 index 74d749e..eefb1bd 100644
40456 --- a/drivers/net/ethernet/faraday/ftgmac100.c
40457 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
40458 @@ -31,6 +31,8 @@
40459 #include <linux/netdevice.h>
40460 #include <linux/phy.h>
40461 #include <linux/platform_device.h>
40462 +#include <linux/interrupt.h>
40463 +#include <linux/irqreturn.h>
40464 #include <net/ip.h>
40465
40466 #include "ftgmac100.h"
40467 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
40468 index b901a01..1ff32ee 100644
40469 --- a/drivers/net/ethernet/faraday/ftmac100.c
40470 +++ b/drivers/net/ethernet/faraday/ftmac100.c
40471 @@ -31,6 +31,8 @@
40472 #include <linux/module.h>
40473 #include <linux/netdevice.h>
40474 #include <linux/platform_device.h>
40475 +#include <linux/interrupt.h>
40476 +#include <linux/irqreturn.h>
40477
40478 #include "ftmac100.h"
40479
40480 diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
40481 index a59f077..7925d77 100644
40482 --- a/drivers/net/ethernet/intel/e100.c
40483 +++ b/drivers/net/ethernet/intel/e100.c
40484 @@ -870,7 +870,7 @@ err_unlock:
40485 }
40486
40487 static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
40488 - void (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
40489 + int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
40490 {
40491 struct cb *cb;
40492 unsigned long flags;
40493 @@ -888,10 +888,13 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
40494 nic->cbs_avail--;
40495 cb->skb = skb;
40496
40497 + err = cb_prepare(nic, cb, skb);
40498 + if (err)
40499 + goto err_unlock;
40500 +
40501 if (unlikely(!nic->cbs_avail))
40502 err = -ENOSPC;
40503
40504 - cb_prepare(nic, cb, skb);
40505
40506 /* Order is important otherwise we'll be in a race with h/w:
40507 * set S-bit in current first, then clear S-bit in previous. */
40508 @@ -1091,7 +1094,7 @@ static void e100_get_defaults(struct nic *nic)
40509 nic->mii.mdio_write = mdio_write;
40510 }
40511
40512 -static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40513 +static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40514 {
40515 struct config *config = &cb->u.config;
40516 u8 *c = (u8 *)config;
40517 @@ -1181,6 +1184,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40518 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
40519 "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
40520 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
40521 + return 0;
40522 }
40523
40524 /*************************************************************************
40525 @@ -1331,7 +1335,7 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
40526 return fw;
40527 }
40528
40529 -static void e100_setup_ucode(struct nic *nic, struct cb *cb,
40530 +static int e100_setup_ucode(struct nic *nic, struct cb *cb,
40531 struct sk_buff *skb)
40532 {
40533 const struct firmware *fw = (void *)skb;
40534 @@ -1358,6 +1362,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb,
40535 cb->u.ucode[min_size] |= cpu_to_le32((BUNDLESMALL) ? 0xFFFF : 0xFF80);
40536
40537 cb->command = cpu_to_le16(cb_ucode | cb_el);
40538 + return 0;
40539 }
40540
40541 static inline int e100_load_ucode_wait(struct nic *nic)
40542 @@ -1400,18 +1405,20 @@ static inline int e100_load_ucode_wait(struct nic *nic)
40543 return err;
40544 }
40545
40546 -static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40547 +static int e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40548 struct sk_buff *skb)
40549 {
40550 cb->command = cpu_to_le16(cb_iaaddr);
40551 memcpy(cb->u.iaaddr, nic->netdev->dev_addr, ETH_ALEN);
40552 + return 0;
40553 }
40554
40555 -static void e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40556 +static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40557 {
40558 cb->command = cpu_to_le16(cb_dump);
40559 cb->u.dump_buffer_addr = cpu_to_le32(nic->dma_addr +
40560 offsetof(struct mem, dump_buf));
40561 + return 0;
40562 }
40563
40564 static int e100_phy_check_without_mii(struct nic *nic)
40565 @@ -1581,7 +1588,7 @@ static int e100_hw_init(struct nic *nic)
40566 return 0;
40567 }
40568
40569 -static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40570 +static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40571 {
40572 struct net_device *netdev = nic->netdev;
40573 struct netdev_hw_addr *ha;
40574 @@ -1596,6 +1603,7 @@ static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40575 memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &ha->addr,
40576 ETH_ALEN);
40577 }
40578 + return 0;
40579 }
40580
40581 static void e100_set_multicast_list(struct net_device *netdev)
40582 @@ -1756,11 +1764,18 @@ static void e100_watchdog(unsigned long data)
40583 round_jiffies(jiffies + E100_WATCHDOG_PERIOD));
40584 }
40585
40586 -static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40587 +static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
40588 struct sk_buff *skb)
40589 {
40590 + dma_addr_t dma_addr;
40591 cb->command = nic->tx_command;
40592
40593 + dma_addr = pci_map_single(nic->pdev,
40594 + skb->data, skb->len, PCI_DMA_TODEVICE);
40595 + /* If we can't map the skb, have the upper layer try later */
40596 + if (pci_dma_mapping_error(nic->pdev, dma_addr))
40597 + return -ENOMEM;
40598 +
40599 /*
40600 * Use the last 4 bytes of the SKB payload packet as the CRC, used for
40601 * testing, ie sending frames with bad CRC.
40602 @@ -1777,11 +1792,10 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40603 cb->u.tcb.tcb_byte_count = 0;
40604 cb->u.tcb.threshold = nic->tx_threshold;
40605 cb->u.tcb.tbd_count = 1;
40606 - cb->u.tcb.tbd.buf_addr = cpu_to_le32(pci_map_single(nic->pdev,
40607 - skb->data, skb->len, PCI_DMA_TODEVICE));
40608 - /* check for mapping failure? */
40609 + cb->u.tcb.tbd.buf_addr = cpu_to_le32(dma_addr);
40610 cb->u.tcb.tbd.size = cpu_to_le16(skb->len);
40611 skb_tx_timestamp(skb);
40612 + return 0;
40613 }
40614
40615 static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
40616 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40617 index bb9256a..56d8752 100644
40618 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40619 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40620 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40621 }
40622
40623 /* update the base incval used to calculate frequency adjustment */
40624 - ACCESS_ONCE(adapter->base_incval) = incval;
40625 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40626 smp_mb();
40627
40628 /* need lock to prevent incorrect read while modifying cyclecounter */
40629 diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
40630 index c124e67..db9b897 100644
40631 --- a/drivers/net/ethernet/lantiq_etop.c
40632 +++ b/drivers/net/ethernet/lantiq_etop.c
40633 @@ -769,7 +769,7 @@ ltq_etop_probe(struct platform_device *pdev)
40634 return 0;
40635
40636 err_free:
40637 - kfree(dev);
40638 + free_netdev(dev);
40639 err_out:
40640 return err;
40641 }
40642 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40643 index fbe5363..266b4e3 100644
40644 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40645 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40646 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40647 struct __vxge_hw_fifo *fifo;
40648 struct vxge_hw_fifo_config *config;
40649 u32 txdl_size, txdl_per_memblock;
40650 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40651 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40652 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40653 + };
40654 +
40655 struct __vxge_hw_virtualpath *vpath;
40656
40657 if ((vp == NULL) || (attr == NULL)) {
40658 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40659 goto exit;
40660 }
40661
40662 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40663 -
40664 fifo->mempool =
40665 __vxge_hw_mempool_create(vpath->hldev,
40666 fifo->config->memblock_size,
40667 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40668 index 2d849da..23bba3b 100644
40669 --- a/drivers/net/ethernet/realtek/r8169.c
40670 +++ b/drivers/net/ethernet/realtek/r8169.c
40671 @@ -741,22 +741,22 @@ struct rtl8169_private {
40672 struct mdio_ops {
40673 void (*write)(struct rtl8169_private *, int, int);
40674 int (*read)(struct rtl8169_private *, int);
40675 - } mdio_ops;
40676 + } __no_const mdio_ops;
40677
40678 struct pll_power_ops {
40679 void (*down)(struct rtl8169_private *);
40680 void (*up)(struct rtl8169_private *);
40681 - } pll_power_ops;
40682 + } __no_const pll_power_ops;
40683
40684 struct jumbo_ops {
40685 void (*enable)(struct rtl8169_private *);
40686 void (*disable)(struct rtl8169_private *);
40687 - } jumbo_ops;
40688 + } __no_const jumbo_ops;
40689
40690 struct csi_ops {
40691 void (*write)(struct rtl8169_private *, int, int);
40692 u32 (*read)(struct rtl8169_private *, int);
40693 - } csi_ops;
40694 + } __no_const csi_ops;
40695
40696 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40697 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40698 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40699 index 3f93624..cf01144 100644
40700 --- a/drivers/net/ethernet/sfc/ptp.c
40701 +++ b/drivers/net/ethernet/sfc/ptp.c
40702 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40703 (u32)((u64)ptp->start.dma_addr >> 32));
40704
40705 /* Clear flag that signals MC ready */
40706 - ACCESS_ONCE(*start) = 0;
40707 + ACCESS_ONCE_RW(*start) = 0;
40708 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40709 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40710
40711 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40712 index 0c74a70..3bc6f68 100644
40713 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40714 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40715 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40716
40717 writel(value, ioaddr + MMC_CNTRL);
40718
40719 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40720 - MMC_CNTRL, value);
40721 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40722 +// MMC_CNTRL, value);
40723 }
40724
40725 /* To mask all all interrupts.*/
40726 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40727 index e6fe0d8..2b7d752 100644
40728 --- a/drivers/net/hyperv/hyperv_net.h
40729 +++ b/drivers/net/hyperv/hyperv_net.h
40730 @@ -101,7 +101,7 @@ struct rndis_device {
40731
40732 enum rndis_device_state state;
40733 bool link_state;
40734 - atomic_t new_req_id;
40735 + atomic_unchecked_t new_req_id;
40736
40737 spinlock_t request_lock;
40738 struct list_head req_list;
40739 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40740 index 2b657d4..9903bc0 100644
40741 --- a/drivers/net/hyperv/rndis_filter.c
40742 +++ b/drivers/net/hyperv/rndis_filter.c
40743 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40744 * template
40745 */
40746 set = &rndis_msg->msg.set_req;
40747 - set->req_id = atomic_inc_return(&dev->new_req_id);
40748 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40749
40750 /* Add to the request list */
40751 spin_lock_irqsave(&dev->request_lock, flags);
40752 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40753
40754 /* Setup the rndis set */
40755 halt = &request->request_msg.msg.halt_req;
40756 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40757 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40758
40759 /* Ignore return since this msg is optional. */
40760 rndis_filter_send_request(dev, request);
40761 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40762 index 1e9cb0b..7839125 100644
40763 --- a/drivers/net/ieee802154/fakehard.c
40764 +++ b/drivers/net/ieee802154/fakehard.c
40765 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40766 phy->transmit_power = 0xbf;
40767
40768 dev->netdev_ops = &fake_ops;
40769 - dev->ml_priv = &fake_mlme;
40770 + dev->ml_priv = (void *)&fake_mlme;
40771
40772 priv = netdev_priv(dev);
40773 priv->phy = phy;
40774 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40775 index e5cb723..1fc0461 100644
40776 --- a/drivers/net/macvlan.c
40777 +++ b/drivers/net/macvlan.c
40778 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40779 int macvlan_link_register(struct rtnl_link_ops *ops)
40780 {
40781 /* common fields */
40782 - ops->priv_size = sizeof(struct macvlan_dev);
40783 - ops->validate = macvlan_validate;
40784 - ops->maxtype = IFLA_MACVLAN_MAX;
40785 - ops->policy = macvlan_policy;
40786 - ops->changelink = macvlan_changelink;
40787 - ops->get_size = macvlan_get_size;
40788 - ops->fill_info = macvlan_fill_info;
40789 + pax_open_kernel();
40790 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40791 + *(void **)&ops->validate = macvlan_validate;
40792 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40793 + *(const void **)&ops->policy = macvlan_policy;
40794 + *(void **)&ops->changelink = macvlan_changelink;
40795 + *(void **)&ops->get_size = macvlan_get_size;
40796 + *(void **)&ops->fill_info = macvlan_fill_info;
40797 + pax_close_kernel();
40798
40799 return rtnl_link_register(ops);
40800 };
40801 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40802 return NOTIFY_DONE;
40803 }
40804
40805 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40806 +static struct notifier_block macvlan_notifier_block = {
40807 .notifier_call = macvlan_device_event,
40808 };
40809
40810 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40811 index 0f0f9ce..0ca5819 100644
40812 --- a/drivers/net/macvtap.c
40813 +++ b/drivers/net/macvtap.c
40814 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40815 return NOTIFY_DONE;
40816 }
40817
40818 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40819 +static struct notifier_block macvtap_notifier_block = {
40820 .notifier_call = macvtap_device_event,
40821 };
40822
40823 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40824 index daec9b0..6428fcb 100644
40825 --- a/drivers/net/phy/mdio-bitbang.c
40826 +++ b/drivers/net/phy/mdio-bitbang.c
40827 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40828 struct mdiobb_ctrl *ctrl = bus->priv;
40829
40830 module_put(ctrl->ops->owner);
40831 + mdiobus_unregister(bus);
40832 mdiobus_free(bus);
40833 }
40834 EXPORT_SYMBOL(free_mdio_bitbang);
40835 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40836 index 508570e..f706dc7 100644
40837 --- a/drivers/net/ppp/ppp_generic.c
40838 +++ b/drivers/net/ppp/ppp_generic.c
40839 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40840 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40841 struct ppp_stats stats;
40842 struct ppp_comp_stats cstats;
40843 - char *vers;
40844
40845 switch (cmd) {
40846 case SIOCGPPPSTATS:
40847 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40848 break;
40849
40850 case SIOCGPPPVER:
40851 - vers = PPP_VERSION;
40852 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40853 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40854 break;
40855 err = 0;
40856 break;
40857 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40858 index 8efe47a..a8075c5 100644
40859 --- a/drivers/net/team/team.c
40860 +++ b/drivers/net/team/team.c
40861 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
40862 return NOTIFY_DONE;
40863 }
40864
40865 -static struct notifier_block team_notifier_block __read_mostly = {
40866 +static struct notifier_block team_notifier_block = {
40867 .notifier_call = team_device_event,
40868 };
40869
40870 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40871 index cb95fe5..16909e2 100644
40872 --- a/drivers/net/tun.c
40873 +++ b/drivers/net/tun.c
40874 @@ -1594,7 +1594,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
40875
40876 if (tun->flags & TUN_TAP_MQ &&
40877 (tun->numqueues + tun->numdisabled > 1))
40878 - return err;
40879 + return -EBUSY;
40880 }
40881 else {
40882 char *name;
40883 @@ -1838,7 +1838,7 @@ unlock:
40884 }
40885
40886 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40887 - unsigned long arg, int ifreq_len)
40888 + unsigned long arg, size_t ifreq_len)
40889 {
40890 struct tun_file *tfile = file->private_data;
40891 struct tun_struct *tun;
40892 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40893 int vnet_hdr_sz;
40894 int ret;
40895
40896 + if (ifreq_len > sizeof ifr)
40897 + return -EFAULT;
40898 +
40899 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40900 if (copy_from_user(&ifr, argp, ifreq_len))
40901 return -EFAULT;
40902 diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
40903 index 16c8429..6bd9167 100644
40904 --- a/drivers/net/usb/cdc_mbim.c
40905 +++ b/drivers/net/usb/cdc_mbim.c
40906 @@ -134,7 +134,7 @@ static struct sk_buff *cdc_mbim_tx_fixup(struct usbnet *dev, struct sk_buff *skb
40907 goto error;
40908
40909 if (skb) {
40910 - if (skb->len <= sizeof(ETH_HLEN))
40911 + if (skb->len <= ETH_HLEN)
40912 goto error;
40913
40914 /* mapping VLANs to MBIM sessions:
40915 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40916 index cd8ccb2..cff5144 100644
40917 --- a/drivers/net/usb/hso.c
40918 +++ b/drivers/net/usb/hso.c
40919 @@ -71,7 +71,7 @@
40920 #include <asm/byteorder.h>
40921 #include <linux/serial_core.h>
40922 #include <linux/serial.h>
40923 -
40924 +#include <asm/local.h>
40925
40926 #define MOD_AUTHOR "Option Wireless"
40927 #define MOD_DESCRIPTION "USB High Speed Option driver"
40928 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40929 struct urb *urb;
40930
40931 urb = serial->rx_urb[0];
40932 - if (serial->port.count > 0) {
40933 + if (atomic_read(&serial->port.count) > 0) {
40934 count = put_rxbuf_data(urb, serial);
40935 if (count == -1)
40936 return;
40937 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40938 DUMP1(urb->transfer_buffer, urb->actual_length);
40939
40940 /* Anyone listening? */
40941 - if (serial->port.count == 0)
40942 + if (atomic_read(&serial->port.count) == 0)
40943 return;
40944
40945 if (status == 0) {
40946 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40947 tty_port_tty_set(&serial->port, tty);
40948
40949 /* check for port already opened, if not set the termios */
40950 - serial->port.count++;
40951 - if (serial->port.count == 1) {
40952 + if (atomic_inc_return(&serial->port.count) == 1) {
40953 serial->rx_state = RX_IDLE;
40954 /* Force default termio settings */
40955 _hso_serial_set_termios(tty, NULL);
40956 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40957 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40958 if (result) {
40959 hso_stop_serial_device(serial->parent);
40960 - serial->port.count--;
40961 + atomic_dec(&serial->port.count);
40962 kref_put(&serial->parent->ref, hso_serial_ref_free);
40963 }
40964 } else {
40965 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40966
40967 /* reset the rts and dtr */
40968 /* do the actual close */
40969 - serial->port.count--;
40970 + atomic_dec(&serial->port.count);
40971
40972 - if (serial->port.count <= 0) {
40973 - serial->port.count = 0;
40974 + if (atomic_read(&serial->port.count) <= 0) {
40975 + atomic_set(&serial->port.count, 0);
40976 tty_port_tty_set(&serial->port, NULL);
40977 if (!usb_gone)
40978 hso_stop_serial_device(serial->parent);
40979 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40980
40981 /* the actual setup */
40982 spin_lock_irqsave(&serial->serial_lock, flags);
40983 - if (serial->port.count)
40984 + if (atomic_read(&serial->port.count))
40985 _hso_serial_set_termios(tty, old);
40986 else
40987 tty->termios = *old;
40988 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40989 D1("Pending read interrupt on port %d\n", i);
40990 spin_lock(&serial->serial_lock);
40991 if (serial->rx_state == RX_IDLE &&
40992 - serial->port.count > 0) {
40993 + atomic_read(&serial->port.count) > 0) {
40994 /* Setup and send a ctrl req read on
40995 * port i */
40996 if (!serial->rx_urb_filled[0]) {
40997 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
40998 /* Start all serial ports */
40999 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
41000 if (serial_table[i] && (serial_table[i]->interface == iface)) {
41001 - if (dev2ser(serial_table[i])->port.count) {
41002 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
41003 result =
41004 hso_start_serial_device(serial_table[i], GFP_NOIO);
41005 hso_kick_transmit(dev2ser(serial_table[i]));
41006 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
41007 index 6993bfa..9053a34 100644
41008 --- a/drivers/net/vxlan.c
41009 +++ b/drivers/net/vxlan.c
41010 @@ -1428,7 +1428,7 @@ nla_put_failure:
41011 return -EMSGSIZE;
41012 }
41013
41014 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
41015 +static struct rtnl_link_ops vxlan_link_ops = {
41016 .kind = "vxlan",
41017 .maxtype = IFLA_VXLAN_MAX,
41018 .policy = vxlan_policy,
41019 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
41020 index 77fa428..996b355 100644
41021 --- a/drivers/net/wireless/at76c50x-usb.c
41022 +++ b/drivers/net/wireless/at76c50x-usb.c
41023 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
41024 }
41025
41026 /* Convert timeout from the DFU status to jiffies */
41027 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
41028 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
41029 {
41030 return msecs_to_jiffies((s->poll_timeout[2] << 16)
41031 | (s->poll_timeout[1] << 8)
41032 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
41033 index 8d78253..bebbb68 100644
41034 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
41035 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
41036 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
41037 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
41038 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
41039
41040 - ACCESS_ONCE(ads->ds_link) = i->link;
41041 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
41042 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
41043 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
41044
41045 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
41046 ctl6 = SM(i->keytype, AR_EncrType);
41047 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
41048
41049 if ((i->is_first || i->is_last) &&
41050 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
41051 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
41052 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
41053 | set11nTries(i->rates, 1)
41054 | set11nTries(i->rates, 2)
41055 | set11nTries(i->rates, 3)
41056 | (i->dur_update ? AR_DurUpdateEna : 0)
41057 | SM(0, AR_BurstDur);
41058
41059 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
41060 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
41061 | set11nRate(i->rates, 1)
41062 | set11nRate(i->rates, 2)
41063 | set11nRate(i->rates, 3);
41064 } else {
41065 - ACCESS_ONCE(ads->ds_ctl2) = 0;
41066 - ACCESS_ONCE(ads->ds_ctl3) = 0;
41067 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
41068 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
41069 }
41070
41071 if (!i->is_first) {
41072 - ACCESS_ONCE(ads->ds_ctl0) = 0;
41073 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
41074 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
41075 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
41076 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
41077 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
41078 return;
41079 }
41080
41081 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
41082 break;
41083 }
41084
41085 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
41086 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
41087 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
41088 | SM(i->txpower, AR_XmitPower)
41089 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
41090 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
41091 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
41092 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
41093
41094 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
41095 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
41096 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
41097 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
41098
41099 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
41100 return;
41101
41102 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
41103 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
41104 | set11nPktDurRTSCTS(i->rates, 1);
41105
41106 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
41107 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
41108 | set11nPktDurRTSCTS(i->rates, 3);
41109
41110 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
41111 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
41112 | set11nRateFlags(i->rates, 1)
41113 | set11nRateFlags(i->rates, 2)
41114 | set11nRateFlags(i->rates, 3)
41115 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
41116 index 301bf72..3f5654f 100644
41117 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
41118 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
41119 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
41120 (i->qcu << AR_TxQcuNum_S) | desc_len;
41121
41122 checksum += val;
41123 - ACCESS_ONCE(ads->info) = val;
41124 + ACCESS_ONCE_RW(ads->info) = val;
41125
41126 checksum += i->link;
41127 - ACCESS_ONCE(ads->link) = i->link;
41128 + ACCESS_ONCE_RW(ads->link) = i->link;
41129
41130 checksum += i->buf_addr[0];
41131 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
41132 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
41133 checksum += i->buf_addr[1];
41134 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
41135 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
41136 checksum += i->buf_addr[2];
41137 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
41138 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
41139 checksum += i->buf_addr[3];
41140 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
41141 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
41142
41143 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
41144 - ACCESS_ONCE(ads->ctl3) = val;
41145 + ACCESS_ONCE_RW(ads->ctl3) = val;
41146 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
41147 - ACCESS_ONCE(ads->ctl5) = val;
41148 + ACCESS_ONCE_RW(ads->ctl5) = val;
41149 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
41150 - ACCESS_ONCE(ads->ctl7) = val;
41151 + ACCESS_ONCE_RW(ads->ctl7) = val;
41152 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
41153 - ACCESS_ONCE(ads->ctl9) = val;
41154 + ACCESS_ONCE_RW(ads->ctl9) = val;
41155
41156 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
41157 - ACCESS_ONCE(ads->ctl10) = checksum;
41158 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
41159
41160 if (i->is_first || i->is_last) {
41161 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
41162 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
41163 | set11nTries(i->rates, 1)
41164 | set11nTries(i->rates, 2)
41165 | set11nTries(i->rates, 3)
41166 | (i->dur_update ? AR_DurUpdateEna : 0)
41167 | SM(0, AR_BurstDur);
41168
41169 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
41170 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
41171 | set11nRate(i->rates, 1)
41172 | set11nRate(i->rates, 2)
41173 | set11nRate(i->rates, 3);
41174 } else {
41175 - ACCESS_ONCE(ads->ctl13) = 0;
41176 - ACCESS_ONCE(ads->ctl14) = 0;
41177 + ACCESS_ONCE_RW(ads->ctl13) = 0;
41178 + ACCESS_ONCE_RW(ads->ctl14) = 0;
41179 }
41180
41181 ads->ctl20 = 0;
41182 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
41183
41184 ctl17 = SM(i->keytype, AR_EncrType);
41185 if (!i->is_first) {
41186 - ACCESS_ONCE(ads->ctl11) = 0;
41187 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
41188 - ACCESS_ONCE(ads->ctl15) = 0;
41189 - ACCESS_ONCE(ads->ctl16) = 0;
41190 - ACCESS_ONCE(ads->ctl17) = ctl17;
41191 - ACCESS_ONCE(ads->ctl18) = 0;
41192 - ACCESS_ONCE(ads->ctl19) = 0;
41193 + ACCESS_ONCE_RW(ads->ctl11) = 0;
41194 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
41195 + ACCESS_ONCE_RW(ads->ctl15) = 0;
41196 + ACCESS_ONCE_RW(ads->ctl16) = 0;
41197 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
41198 + ACCESS_ONCE_RW(ads->ctl18) = 0;
41199 + ACCESS_ONCE_RW(ads->ctl19) = 0;
41200 return;
41201 }
41202
41203 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
41204 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
41205 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
41206 | SM(i->txpower, AR_XmitPower)
41207 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
41208 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
41209 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
41210 ctl12 |= SM(val, AR_PAPRDChainMask);
41211
41212 - ACCESS_ONCE(ads->ctl12) = ctl12;
41213 - ACCESS_ONCE(ads->ctl17) = ctl17;
41214 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
41215 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
41216
41217 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
41218 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
41219 | set11nPktDurRTSCTS(i->rates, 1);
41220
41221 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
41222 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
41223 | set11nPktDurRTSCTS(i->rates, 3);
41224
41225 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
41226 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
41227 | set11nRateFlags(i->rates, 1)
41228 | set11nRateFlags(i->rates, 2)
41229 | set11nRateFlags(i->rates, 3)
41230 | SM(i->rtscts_rate, AR_RTSCTSRate);
41231
41232 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
41233 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
41234 }
41235
41236 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
41237 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
41238 index 9d26fc5..60d9f14 100644
41239 --- a/drivers/net/wireless/ath/ath9k/hw.h
41240 +++ b/drivers/net/wireless/ath/ath9k/hw.h
41241 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
41242
41243 /* ANI */
41244 void (*ani_cache_ini_regs)(struct ath_hw *ah);
41245 -};
41246 +} __no_const;
41247
41248 /**
41249 * struct ath_hw_ops - callbacks used by hardware code and driver code
41250 @@ -688,7 +688,7 @@ struct ath_hw_ops {
41251 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
41252 struct ath_hw_antcomb_conf *antconf);
41253 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
41254 -};
41255 +} __no_const;
41256
41257 struct ath_nf_limits {
41258 s16 max;
41259 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
41260 index 3726cd6..b655808 100644
41261 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
41262 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
41263 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
41264 */
41265 if (il3945_mod_params.disable_hw_scan) {
41266 D_INFO("Disabling hw_scan\n");
41267 - il3945_mac_ops.hw_scan = NULL;
41268 + pax_open_kernel();
41269 + *(void **)&il3945_mac_ops.hw_scan = NULL;
41270 + pax_close_kernel();
41271 }
41272
41273 D_INFO("*** LOAD DRIVER ***\n");
41274 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
41275 index 5b9533e..7733880 100644
41276 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
41277 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
41278 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
41279 {
41280 struct iwl_priv *priv = file->private_data;
41281 char buf[64];
41282 - int buf_size;
41283 + size_t buf_size;
41284 u32 offset, len;
41285
41286 memset(buf, 0, sizeof(buf));
41287 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
41288 struct iwl_priv *priv = file->private_data;
41289
41290 char buf[8];
41291 - int buf_size;
41292 + size_t buf_size;
41293 u32 reset_flag;
41294
41295 memset(buf, 0, sizeof(buf));
41296 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
41297 {
41298 struct iwl_priv *priv = file->private_data;
41299 char buf[8];
41300 - int buf_size;
41301 + size_t buf_size;
41302 int ht40;
41303
41304 memset(buf, 0, sizeof(buf));
41305 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
41306 {
41307 struct iwl_priv *priv = file->private_data;
41308 char buf[8];
41309 - int buf_size;
41310 + size_t buf_size;
41311 int value;
41312
41313 memset(buf, 0, sizeof(buf));
41314 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
41315 {
41316 struct iwl_priv *priv = file->private_data;
41317 char buf[8];
41318 - int buf_size;
41319 + size_t buf_size;
41320 int clear;
41321
41322 memset(buf, 0, sizeof(buf));
41323 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
41324 {
41325 struct iwl_priv *priv = file->private_data;
41326 char buf[8];
41327 - int buf_size;
41328 + size_t buf_size;
41329 int trace;
41330
41331 memset(buf, 0, sizeof(buf));
41332 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
41333 {
41334 struct iwl_priv *priv = file->private_data;
41335 char buf[8];
41336 - int buf_size;
41337 + size_t buf_size;
41338 int missed;
41339
41340 memset(buf, 0, sizeof(buf));
41341 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
41342
41343 struct iwl_priv *priv = file->private_data;
41344 char buf[8];
41345 - int buf_size;
41346 + size_t buf_size;
41347 int plcp;
41348
41349 memset(buf, 0, sizeof(buf));
41350 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
41351
41352 struct iwl_priv *priv = file->private_data;
41353 char buf[8];
41354 - int buf_size;
41355 + size_t buf_size;
41356 int flush;
41357
41358 memset(buf, 0, sizeof(buf));
41359 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
41360
41361 struct iwl_priv *priv = file->private_data;
41362 char buf[8];
41363 - int buf_size;
41364 + size_t buf_size;
41365 int rts;
41366
41367 if (!priv->cfg->ht_params)
41368 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
41369 {
41370 struct iwl_priv *priv = file->private_data;
41371 char buf[8];
41372 - int buf_size;
41373 + size_t buf_size;
41374
41375 memset(buf, 0, sizeof(buf));
41376 buf_size = min(count, sizeof(buf) - 1);
41377 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
41378 struct iwl_priv *priv = file->private_data;
41379 u32 event_log_flag;
41380 char buf[8];
41381 - int buf_size;
41382 + size_t buf_size;
41383
41384 /* check that the interface is up */
41385 if (!iwl_is_ready(priv))
41386 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
41387 struct iwl_priv *priv = file->private_data;
41388 char buf[8];
41389 u32 calib_disabled;
41390 - int buf_size;
41391 + size_t buf_size;
41392
41393 memset(buf, 0, sizeof(buf));
41394 buf_size = min(count, sizeof(buf) - 1);
41395 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
41396 index 35708b9..31f7754 100644
41397 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
41398 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
41399 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
41400 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
41401
41402 char buf[8];
41403 - int buf_size;
41404 + size_t buf_size;
41405 u32 reset_flag;
41406
41407 memset(buf, 0, sizeof(buf));
41408 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
41409 {
41410 struct iwl_trans *trans = file->private_data;
41411 char buf[8];
41412 - int buf_size;
41413 + size_t buf_size;
41414 int csr;
41415
41416 memset(buf, 0, sizeof(buf));
41417 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
41418 index ff90855..e46d223 100644
41419 --- a/drivers/net/wireless/mac80211_hwsim.c
41420 +++ b/drivers/net/wireless/mac80211_hwsim.c
41421 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
41422
41423 if (channels > 1) {
41424 hwsim_if_comb.num_different_channels = channels;
41425 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
41426 - mac80211_hwsim_ops.cancel_hw_scan =
41427 - mac80211_hwsim_cancel_hw_scan;
41428 - mac80211_hwsim_ops.sw_scan_start = NULL;
41429 - mac80211_hwsim_ops.sw_scan_complete = NULL;
41430 - mac80211_hwsim_ops.remain_on_channel =
41431 - mac80211_hwsim_roc;
41432 - mac80211_hwsim_ops.cancel_remain_on_channel =
41433 - mac80211_hwsim_croc;
41434 - mac80211_hwsim_ops.add_chanctx =
41435 - mac80211_hwsim_add_chanctx;
41436 - mac80211_hwsim_ops.remove_chanctx =
41437 - mac80211_hwsim_remove_chanctx;
41438 - mac80211_hwsim_ops.change_chanctx =
41439 - mac80211_hwsim_change_chanctx;
41440 - mac80211_hwsim_ops.assign_vif_chanctx =
41441 - mac80211_hwsim_assign_vif_chanctx;
41442 - mac80211_hwsim_ops.unassign_vif_chanctx =
41443 - mac80211_hwsim_unassign_vif_chanctx;
41444 + pax_open_kernel();
41445 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
41446 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
41447 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
41448 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
41449 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
41450 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
41451 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
41452 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
41453 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
41454 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
41455 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
41456 + pax_close_kernel();
41457 }
41458
41459 spin_lock_init(&hwsim_radio_lock);
41460 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
41461 index abe1d03..fb02c22 100644
41462 --- a/drivers/net/wireless/rndis_wlan.c
41463 +++ b/drivers/net/wireless/rndis_wlan.c
41464 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
41465
41466 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
41467
41468 - if (rts_threshold < 0 || rts_threshold > 2347)
41469 + if (rts_threshold > 2347)
41470 rts_threshold = 2347;
41471
41472 tmp = cpu_to_le32(rts_threshold);
41473 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
41474 index 0751b35..246ba3e 100644
41475 --- a/drivers/net/wireless/rt2x00/rt2x00.h
41476 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
41477 @@ -398,7 +398,7 @@ struct rt2x00_intf {
41478 * for hardware which doesn't support hardware
41479 * sequence counting.
41480 */
41481 - atomic_t seqno;
41482 + atomic_unchecked_t seqno;
41483 };
41484
41485 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
41486 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
41487 index e488b94..14b6a0c 100644
41488 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
41489 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
41490 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
41491 * sequence counter given by mac80211.
41492 */
41493 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
41494 - seqno = atomic_add_return(0x10, &intf->seqno);
41495 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
41496 else
41497 - seqno = atomic_read(&intf->seqno);
41498 + seqno = atomic_read_unchecked(&intf->seqno);
41499
41500 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
41501 hdr->seq_ctrl |= cpu_to_le16(seqno);
41502 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
41503 index e57ee48..541cf6c 100644
41504 --- a/drivers/net/wireless/ti/wl1251/sdio.c
41505 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
41506 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
41507
41508 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
41509
41510 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41511 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41512 + pax_open_kernel();
41513 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41514 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41515 + pax_close_kernel();
41516
41517 wl1251_info("using dedicated interrupt line");
41518 } else {
41519 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41520 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41521 + pax_open_kernel();
41522 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41523 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41524 + pax_close_kernel();
41525
41526 wl1251_info("using SDIO interrupt");
41527 }
41528 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
41529 index e5f5f8f..fdf15b7 100644
41530 --- a/drivers/net/wireless/ti/wl12xx/main.c
41531 +++ b/drivers/net/wireless/ti/wl12xx/main.c
41532 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41533 sizeof(wl->conf.mem));
41534
41535 /* read data preparation is only needed by wl127x */
41536 - wl->ops->prepare_read = wl127x_prepare_read;
41537 + pax_open_kernel();
41538 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41539 + pax_close_kernel();
41540
41541 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
41542 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
41543 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41544 sizeof(wl->conf.mem));
41545
41546 /* read data preparation is only needed by wl127x */
41547 - wl->ops->prepare_read = wl127x_prepare_read;
41548 + pax_open_kernel();
41549 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41550 + pax_close_kernel();
41551
41552 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
41553 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
41554 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41555 index 8d8c1f8..e754844 100644
41556 --- a/drivers/net/wireless/ti/wl18xx/main.c
41557 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41558 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41559 }
41560
41561 if (!checksum_param) {
41562 - wl18xx_ops.set_rx_csum = NULL;
41563 - wl18xx_ops.init_vif = NULL;
41564 + pax_open_kernel();
41565 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41566 + *(void **)&wl18xx_ops.init_vif = NULL;
41567 + pax_close_kernel();
41568 }
41569
41570 /* Enable 11a Band only if we have 5G antennas */
41571 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41572 index ef2b171..bb513a6 100644
41573 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41574 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41575 @@ -387,7 +387,7 @@ static inline void handle_regs_int(struct urb *urb)
41576 {
41577 struct zd_usb *usb = urb->context;
41578 struct zd_usb_interrupt *intr = &usb->intr;
41579 - int len;
41580 + unsigned int len;
41581 u16 int_num;
41582
41583 ZD_ASSERT(in_interrupt());
41584 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41585 index d93b2b6..ae50401 100644
41586 --- a/drivers/oprofile/buffer_sync.c
41587 +++ b/drivers/oprofile/buffer_sync.c
41588 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41589 if (cookie == NO_COOKIE)
41590 offset = pc;
41591 if (cookie == INVALID_COOKIE) {
41592 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41593 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41594 offset = pc;
41595 }
41596 if (cookie != last_cookie) {
41597 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41598 /* add userspace sample */
41599
41600 if (!mm) {
41601 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41602 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41603 return 0;
41604 }
41605
41606 cookie = lookup_dcookie(mm, s->eip, &offset);
41607
41608 if (cookie == INVALID_COOKIE) {
41609 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41610 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41611 return 0;
41612 }
41613
41614 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41615 /* ignore backtraces if failed to add a sample */
41616 if (state == sb_bt_start) {
41617 state = sb_bt_ignore;
41618 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41619 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41620 }
41621 }
41622 release_mm(mm);
41623 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41624 index c0cc4e7..44d4e54 100644
41625 --- a/drivers/oprofile/event_buffer.c
41626 +++ b/drivers/oprofile/event_buffer.c
41627 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41628 }
41629
41630 if (buffer_pos == buffer_size) {
41631 - atomic_inc(&oprofile_stats.event_lost_overflow);
41632 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41633 return;
41634 }
41635
41636 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41637 index ed2c3ec..deda85a 100644
41638 --- a/drivers/oprofile/oprof.c
41639 +++ b/drivers/oprofile/oprof.c
41640 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41641 if (oprofile_ops.switch_events())
41642 return;
41643
41644 - atomic_inc(&oprofile_stats.multiplex_counter);
41645 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41646 start_switch_worker();
41647 }
41648
41649 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41650 index 84a208d..d61b0a1 100644
41651 --- a/drivers/oprofile/oprofile_files.c
41652 +++ b/drivers/oprofile/oprofile_files.c
41653 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41654
41655 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41656
41657 -static ssize_t timeout_read(struct file *file, char __user *buf,
41658 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41659 size_t count, loff_t *offset)
41660 {
41661 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41662 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41663 index 917d28e..d62d981 100644
41664 --- a/drivers/oprofile/oprofile_stats.c
41665 +++ b/drivers/oprofile/oprofile_stats.c
41666 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41667 cpu_buf->sample_invalid_eip = 0;
41668 }
41669
41670 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41671 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41672 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41673 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41674 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41675 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41676 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41677 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41678 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41679 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41680 }
41681
41682
41683 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41684 index 38b6fc0..b5cbfce 100644
41685 --- a/drivers/oprofile/oprofile_stats.h
41686 +++ b/drivers/oprofile/oprofile_stats.h
41687 @@ -13,11 +13,11 @@
41688 #include <linux/atomic.h>
41689
41690 struct oprofile_stat_struct {
41691 - atomic_t sample_lost_no_mm;
41692 - atomic_t sample_lost_no_mapping;
41693 - atomic_t bt_lost_no_mapping;
41694 - atomic_t event_lost_overflow;
41695 - atomic_t multiplex_counter;
41696 + atomic_unchecked_t sample_lost_no_mm;
41697 + atomic_unchecked_t sample_lost_no_mapping;
41698 + atomic_unchecked_t bt_lost_no_mapping;
41699 + atomic_unchecked_t event_lost_overflow;
41700 + atomic_unchecked_t multiplex_counter;
41701 };
41702
41703 extern struct oprofile_stat_struct oprofile_stats;
41704 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41705 index 849357c..b83c1e0 100644
41706 --- a/drivers/oprofile/oprofilefs.c
41707 +++ b/drivers/oprofile/oprofilefs.c
41708 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
41709
41710
41711 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41712 - char const *name, atomic_t *val)
41713 + char const *name, atomic_unchecked_t *val)
41714 {
41715 return __oprofilefs_create_file(sb, root, name,
41716 &atomic_ro_fops, 0444, val);
41717 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41718 index 93404f7..4a313d8 100644
41719 --- a/drivers/oprofile/timer_int.c
41720 +++ b/drivers/oprofile/timer_int.c
41721 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41722 return NOTIFY_OK;
41723 }
41724
41725 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41726 +static struct notifier_block oprofile_cpu_notifier = {
41727 .notifier_call = oprofile_cpu_notify,
41728 };
41729
41730 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41731 index 3f56bc0..707d642 100644
41732 --- a/drivers/parport/procfs.c
41733 +++ b/drivers/parport/procfs.c
41734 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41735
41736 *ppos += len;
41737
41738 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41739 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41740 }
41741
41742 #ifdef CONFIG_PARPORT_1284
41743 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41744
41745 *ppos += len;
41746
41747 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41748 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41749 }
41750 #endif /* IEEE1284.3 support. */
41751
41752 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41753 index c35e8ad..fc33beb 100644
41754 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41755 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41756 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41757 goto init_cleanup;
41758 }
41759
41760 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41761 + pax_open_kernel();
41762 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41763 + pax_close_kernel();
41764 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41765
41766 return retval;
41767 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41768 index a6a71c4..c91097b 100644
41769 --- a/drivers/pci/hotplug/cpcihp_generic.c
41770 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41771 @@ -73,7 +73,6 @@ static u16 port;
41772 static unsigned int enum_bit;
41773 static u8 enum_mask;
41774
41775 -static struct cpci_hp_controller_ops generic_hpc_ops;
41776 static struct cpci_hp_controller generic_hpc;
41777
41778 static int __init validate_parameters(void)
41779 @@ -139,6 +138,10 @@ static int query_enum(void)
41780 return ((value & enum_mask) == enum_mask);
41781 }
41782
41783 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41784 + .query_enum = query_enum,
41785 +};
41786 +
41787 static int __init cpcihp_generic_init(void)
41788 {
41789 int status;
41790 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41791 pci_dev_put(dev);
41792
41793 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41794 - generic_hpc_ops.query_enum = query_enum;
41795 generic_hpc.ops = &generic_hpc_ops;
41796
41797 status = cpci_hp_register_controller(&generic_hpc);
41798 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41799 index 449b4bb..257e2e8 100644
41800 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41801 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41802 @@ -59,7 +59,6 @@
41803 /* local variables */
41804 static bool debug;
41805 static bool poll;
41806 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41807 static struct cpci_hp_controller zt5550_hpc;
41808
41809 /* Primary cPCI bus bridge device */
41810 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41811 return 0;
41812 }
41813
41814 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41815 + .query_enum = zt5550_hc_query_enum,
41816 +};
41817 +
41818 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41819 {
41820 int status;
41821 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41822 dbg("returned from zt5550_hc_config");
41823
41824 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41825 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41826 zt5550_hpc.ops = &zt5550_hpc_ops;
41827 if(!poll) {
41828 zt5550_hpc.irq = hc_dev->irq;
41829 zt5550_hpc.irq_flags = IRQF_SHARED;
41830 zt5550_hpc.dev_id = hc_dev;
41831
41832 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41833 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41834 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41835 + pax_open_kernel();
41836 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41837 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41838 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41839 + pax_open_kernel();
41840 } else {
41841 info("using ENUM# polling mode");
41842 }
41843 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41844 index 76ba8a1..20ca857 100644
41845 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41846 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41847 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41848
41849 void compaq_nvram_init (void __iomem *rom_start)
41850 {
41851 +
41852 +#ifndef CONFIG_PAX_KERNEXEC
41853 if (rom_start) {
41854 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41855 }
41856 +#endif
41857 +
41858 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41859
41860 /* initialize our int15 lock */
41861 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41862 index 202f4a9..8ee47d0 100644
41863 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41864 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41865 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41866 return -EINVAL;
41867 }
41868
41869 - slot->ops->owner = owner;
41870 - slot->ops->mod_name = mod_name;
41871 + pax_open_kernel();
41872 + *(struct module **)&slot->ops->owner = owner;
41873 + *(const char **)&slot->ops->mod_name = mod_name;
41874 + pax_close_kernel();
41875
41876 mutex_lock(&pci_hp_mutex);
41877 /*
41878 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41879 index 939bd1d..a1459c9 100644
41880 --- a/drivers/pci/hotplug/pciehp_core.c
41881 +++ b/drivers/pci/hotplug/pciehp_core.c
41882 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41883 struct slot *slot = ctrl->slot;
41884 struct hotplug_slot *hotplug = NULL;
41885 struct hotplug_slot_info *info = NULL;
41886 - struct hotplug_slot_ops *ops = NULL;
41887 + hotplug_slot_ops_no_const *ops = NULL;
41888 char name[SLOT_NAME_SIZE];
41889 int retval = -ENOMEM;
41890
41891 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41892 index 9c6e9bb..2916736 100644
41893 --- a/drivers/pci/pci-sysfs.c
41894 +++ b/drivers/pci/pci-sysfs.c
41895 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41896 {
41897 /* allocate attribute structure, piggyback attribute name */
41898 int name_len = write_combine ? 13 : 10;
41899 - struct bin_attribute *res_attr;
41900 + bin_attribute_no_const *res_attr;
41901 int retval;
41902
41903 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41904 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41905 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41906 {
41907 int retval;
41908 - struct bin_attribute *attr;
41909 + bin_attribute_no_const *attr;
41910
41911 /* If the device has VPD, try to expose it in sysfs. */
41912 if (dev->vpd) {
41913 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41914 {
41915 int retval;
41916 int rom_size = 0;
41917 - struct bin_attribute *attr;
41918 + bin_attribute_no_const *attr;
41919
41920 if (!sysfs_initialized)
41921 return -EACCES;
41922 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41923 index e851829..a1a7196 100644
41924 --- a/drivers/pci/pci.h
41925 +++ b/drivers/pci/pci.h
41926 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
41927 struct pci_vpd {
41928 unsigned int len;
41929 const struct pci_vpd_ops *ops;
41930 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41931 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41932 };
41933
41934 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41935 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41936 index 8474b6a..ee81993 100644
41937 --- a/drivers/pci/pcie/aspm.c
41938 +++ b/drivers/pci/pcie/aspm.c
41939 @@ -27,9 +27,9 @@
41940 #define MODULE_PARAM_PREFIX "pcie_aspm."
41941
41942 /* Note: those are not register definitions */
41943 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41944 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41945 -#define ASPM_STATE_L1 (4) /* L1 state */
41946 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41947 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41948 +#define ASPM_STATE_L1 (4U) /* L1 state */
41949 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41950 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41951
41952 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41953 index 6186f03..1a78714 100644
41954 --- a/drivers/pci/probe.c
41955 +++ b/drivers/pci/probe.c
41956 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41957 struct pci_bus_region region;
41958 bool bar_too_big = false, bar_disabled = false;
41959
41960 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41961 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41962
41963 /* No printks while decoding is disabled! */
41964 if (!dev->mmio_always_on) {
41965 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41966 index 9b8505c..f00870a 100644
41967 --- a/drivers/pci/proc.c
41968 +++ b/drivers/pci/proc.c
41969 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41970 static int __init pci_proc_init(void)
41971 {
41972 struct pci_dev *dev = NULL;
41973 +
41974 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41975 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41976 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41977 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41978 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41979 +#endif
41980 +#else
41981 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41982 +#endif
41983 proc_create("devices", 0, proc_bus_pci_dir,
41984 &proc_bus_pci_dev_operations);
41985 proc_initialized = 1;
41986 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41987 index 2111dbb..79e434b 100644
41988 --- a/drivers/platform/x86/msi-laptop.c
41989 +++ b/drivers/platform/x86/msi-laptop.c
41990 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41991 int result;
41992
41993 /* allow userland write sysfs file */
41994 - dev_attr_bluetooth.store = store_bluetooth;
41995 - dev_attr_wlan.store = store_wlan;
41996 - dev_attr_threeg.store = store_threeg;
41997 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41998 - dev_attr_wlan.attr.mode |= S_IWUSR;
41999 - dev_attr_threeg.attr.mode |= S_IWUSR;
42000 + pax_open_kernel();
42001 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
42002 + *(void **)&dev_attr_wlan.store = store_wlan;
42003 + *(void **)&dev_attr_threeg.store = store_threeg;
42004 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
42005 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
42006 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
42007 + pax_close_kernel();
42008
42009 /* disable hardware control by fn key */
42010 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
42011 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
42012 index 0fe987f..6f3d5c3 100644
42013 --- a/drivers/platform/x86/sony-laptop.c
42014 +++ b/drivers/platform/x86/sony-laptop.c
42015 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
42016 }
42017
42018 /* High speed charging function */
42019 -static struct device_attribute *hsc_handle;
42020 +static device_attribute_no_const *hsc_handle;
42021
42022 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
42023 struct device_attribute *attr,
42024 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
42025 index f946ca7..f25c833 100644
42026 --- a/drivers/platform/x86/thinkpad_acpi.c
42027 +++ b/drivers/platform/x86/thinkpad_acpi.c
42028 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
42029 return 0;
42030 }
42031
42032 -void static hotkey_mask_warn_incomplete_mask(void)
42033 +static void hotkey_mask_warn_incomplete_mask(void)
42034 {
42035 /* log only what the user can fix... */
42036 const u32 wantedmask = hotkey_driver_mask &
42037 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
42038 }
42039 }
42040
42041 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
42042 - struct tp_nvram_state *newn,
42043 - const u32 event_mask)
42044 -{
42045 -
42046 #define TPACPI_COMPARE_KEY(__scancode, __member) \
42047 do { \
42048 if ((event_mask & (1 << __scancode)) && \
42049 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
42050 tpacpi_hotkey_send_key(__scancode); \
42051 } while (0)
42052
42053 - void issue_volchange(const unsigned int oldvol,
42054 - const unsigned int newvol)
42055 - {
42056 - unsigned int i = oldvol;
42057 +static void issue_volchange(const unsigned int oldvol,
42058 + const unsigned int newvol,
42059 + const u32 event_mask)
42060 +{
42061 + unsigned int i = oldvol;
42062
42063 - while (i > newvol) {
42064 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
42065 - i--;
42066 - }
42067 - while (i < newvol) {
42068 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
42069 - i++;
42070 - }
42071 + while (i > newvol) {
42072 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
42073 + i--;
42074 }
42075 + while (i < newvol) {
42076 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
42077 + i++;
42078 + }
42079 +}
42080
42081 - void issue_brightnesschange(const unsigned int oldbrt,
42082 - const unsigned int newbrt)
42083 - {
42084 - unsigned int i = oldbrt;
42085 +static void issue_brightnesschange(const unsigned int oldbrt,
42086 + const unsigned int newbrt,
42087 + const u32 event_mask)
42088 +{
42089 + unsigned int i = oldbrt;
42090
42091 - while (i > newbrt) {
42092 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
42093 - i--;
42094 - }
42095 - while (i < newbrt) {
42096 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
42097 - i++;
42098 - }
42099 + while (i > newbrt) {
42100 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
42101 + i--;
42102 + }
42103 + while (i < newbrt) {
42104 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
42105 + i++;
42106 }
42107 +}
42108
42109 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
42110 + struct tp_nvram_state *newn,
42111 + const u32 event_mask)
42112 +{
42113 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
42114 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
42115 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
42116 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
42117 oldn->volume_level != newn->volume_level) {
42118 /* recently muted, or repeated mute keypress, or
42119 * multiple presses ending in mute */
42120 - issue_volchange(oldn->volume_level, newn->volume_level);
42121 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
42122 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
42123 }
42124 } else {
42125 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
42126 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
42127 }
42128 if (oldn->volume_level != newn->volume_level) {
42129 - issue_volchange(oldn->volume_level, newn->volume_level);
42130 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
42131 } else if (oldn->volume_toggle != newn->volume_toggle) {
42132 /* repeated vol up/down keypress at end of scale ? */
42133 if (newn->volume_level == 0)
42134 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
42135 /* handle brightness */
42136 if (oldn->brightness_level != newn->brightness_level) {
42137 issue_brightnesschange(oldn->brightness_level,
42138 - newn->brightness_level);
42139 + newn->brightness_level,
42140 + event_mask);
42141 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
42142 /* repeated key presses that didn't change state */
42143 if (newn->brightness_level == 0)
42144 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
42145 && !tp_features.bright_unkfw)
42146 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
42147 }
42148 +}
42149
42150 #undef TPACPI_COMPARE_KEY
42151 #undef TPACPI_MAY_SEND_KEY
42152 -}
42153
42154 /*
42155 * Polling driver
42156 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
42157 index 769d265..a3a05ca 100644
42158 --- a/drivers/pnp/pnpbios/bioscalls.c
42159 +++ b/drivers/pnp/pnpbios/bioscalls.c
42160 @@ -58,7 +58,7 @@ do { \
42161 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
42162 } while(0)
42163
42164 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
42165 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
42166 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
42167
42168 /*
42169 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
42170
42171 cpu = get_cpu();
42172 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
42173 +
42174 + pax_open_kernel();
42175 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
42176 + pax_close_kernel();
42177
42178 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
42179 spin_lock_irqsave(&pnp_bios_lock, flags);
42180 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
42181 :"memory");
42182 spin_unlock_irqrestore(&pnp_bios_lock, flags);
42183
42184 + pax_open_kernel();
42185 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
42186 + pax_close_kernel();
42187 +
42188 put_cpu();
42189
42190 /* If we get here and this is set then the PnP BIOS faulted on us. */
42191 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
42192 return status;
42193 }
42194
42195 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
42196 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
42197 {
42198 int i;
42199
42200 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
42201 pnp_bios_callpoint.offset = header->fields.pm16offset;
42202 pnp_bios_callpoint.segment = PNP_CS16;
42203
42204 + pax_open_kernel();
42205 +
42206 for_each_possible_cpu(i) {
42207 struct desc_struct *gdt = get_cpu_gdt_table(i);
42208 if (!gdt)
42209 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
42210 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
42211 (unsigned long)__va(header->fields.pm16dseg));
42212 }
42213 +
42214 + pax_close_kernel();
42215 }
42216 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
42217 index 3e6db1c..1fbbdae 100644
42218 --- a/drivers/pnp/resource.c
42219 +++ b/drivers/pnp/resource.c
42220 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
42221 return 1;
42222
42223 /* check if the resource is valid */
42224 - if (*irq < 0 || *irq > 15)
42225 + if (*irq > 15)
42226 return 0;
42227
42228 /* check if the resource is reserved */
42229 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
42230 return 1;
42231
42232 /* check if the resource is valid */
42233 - if (*dma < 0 || *dma == 4 || *dma > 7)
42234 + if (*dma == 4 || *dma > 7)
42235 return 0;
42236
42237 /* check if the resource is reserved */
42238 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
42239 index 7df7c5f..bd48c47 100644
42240 --- a/drivers/power/pda_power.c
42241 +++ b/drivers/power/pda_power.c
42242 @@ -37,7 +37,11 @@ static int polling;
42243
42244 #ifdef CONFIG_USB_OTG_UTILS
42245 static struct usb_phy *transceiver;
42246 -static struct notifier_block otg_nb;
42247 +static int otg_handle_notification(struct notifier_block *nb,
42248 + unsigned long event, void *unused);
42249 +static struct notifier_block otg_nb = {
42250 + .notifier_call = otg_handle_notification
42251 +};
42252 #endif
42253
42254 static struct regulator *ac_draw;
42255 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
42256
42257 #ifdef CONFIG_USB_OTG_UTILS
42258 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
42259 - otg_nb.notifier_call = otg_handle_notification;
42260 ret = usb_register_notifier(transceiver, &otg_nb);
42261 if (ret) {
42262 dev_err(dev, "failure to register otg notifier\n");
42263 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
42264 index cc439fd..8fa30df 100644
42265 --- a/drivers/power/power_supply.h
42266 +++ b/drivers/power/power_supply.h
42267 @@ -16,12 +16,12 @@ struct power_supply;
42268
42269 #ifdef CONFIG_SYSFS
42270
42271 -extern void power_supply_init_attrs(struct device_type *dev_type);
42272 +extern void power_supply_init_attrs(void);
42273 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
42274
42275 #else
42276
42277 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
42278 +static inline void power_supply_init_attrs(void) {}
42279 #define power_supply_uevent NULL
42280
42281 #endif /* CONFIG_SYSFS */
42282 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
42283 index 8a7cfb3..72e6e9b 100644
42284 --- a/drivers/power/power_supply_core.c
42285 +++ b/drivers/power/power_supply_core.c
42286 @@ -24,7 +24,10 @@
42287 struct class *power_supply_class;
42288 EXPORT_SYMBOL_GPL(power_supply_class);
42289
42290 -static struct device_type power_supply_dev_type;
42291 +extern const struct attribute_group *power_supply_attr_groups[];
42292 +static struct device_type power_supply_dev_type = {
42293 + .groups = power_supply_attr_groups,
42294 +};
42295
42296 static int __power_supply_changed_work(struct device *dev, void *data)
42297 {
42298 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
42299 return PTR_ERR(power_supply_class);
42300
42301 power_supply_class->dev_uevent = power_supply_uevent;
42302 - power_supply_init_attrs(&power_supply_dev_type);
42303 + power_supply_init_attrs();
42304
42305 return 0;
42306 }
42307 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
42308 index 40fa3b7..d9c2e0e 100644
42309 --- a/drivers/power/power_supply_sysfs.c
42310 +++ b/drivers/power/power_supply_sysfs.c
42311 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
42312 .is_visible = power_supply_attr_is_visible,
42313 };
42314
42315 -static const struct attribute_group *power_supply_attr_groups[] = {
42316 +const struct attribute_group *power_supply_attr_groups[] = {
42317 &power_supply_attr_group,
42318 NULL,
42319 };
42320
42321 -void power_supply_init_attrs(struct device_type *dev_type)
42322 +void power_supply_init_attrs(void)
42323 {
42324 int i;
42325
42326 - dev_type->groups = power_supply_attr_groups;
42327 -
42328 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
42329 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
42330 }
42331 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
42332 index 4d7c635..9860196 100644
42333 --- a/drivers/regulator/max8660.c
42334 +++ b/drivers/regulator/max8660.c
42335 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
42336 max8660->shadow_regs[MAX8660_OVER1] = 5;
42337 } else {
42338 /* Otherwise devices can be toggled via software */
42339 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
42340 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
42341 + pax_open_kernel();
42342 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
42343 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
42344 + pax_close_kernel();
42345 }
42346
42347 /*
42348 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
42349 index 9a8ea91..c483dd9 100644
42350 --- a/drivers/regulator/max8973-regulator.c
42351 +++ b/drivers/regulator/max8973-regulator.c
42352 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
42353 if (!pdata->enable_ext_control) {
42354 max->desc.enable_reg = MAX8973_VOUT;
42355 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
42356 - max8973_dcdc_ops.enable = regulator_enable_regmap;
42357 - max8973_dcdc_ops.disable = regulator_disable_regmap;
42358 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
42359 + pax_open_kernel();
42360 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
42361 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
42362 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
42363 + pax_close_kernel();
42364 }
42365
42366 max->enable_external_control = pdata->enable_ext_control;
42367 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
42368 index 0d84b1f..c2da6ac 100644
42369 --- a/drivers/regulator/mc13892-regulator.c
42370 +++ b/drivers/regulator/mc13892-regulator.c
42371 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
42372 }
42373 mc13xxx_unlock(mc13892);
42374
42375 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
42376 + pax_open_kernel();
42377 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
42378 = mc13892_vcam_set_mode;
42379 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
42380 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
42381 = mc13892_vcam_get_mode;
42382 + pax_close_kernel();
42383
42384 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
42385 ARRAY_SIZE(mc13892_regulators));
42386 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
42387 index 16630aa..6afc992 100644
42388 --- a/drivers/rtc/rtc-cmos.c
42389 +++ b/drivers/rtc/rtc-cmos.c
42390 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
42391 hpet_rtc_timer_init();
42392
42393 /* export at least the first block of NVRAM */
42394 - nvram.size = address_space - NVRAM_OFFSET;
42395 + pax_open_kernel();
42396 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
42397 + pax_close_kernel();
42398 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
42399 if (retval < 0) {
42400 dev_dbg(dev, "can't create nvram file? %d\n", retval);
42401 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
42402 index 9a86b4b..3a383dc 100644
42403 --- a/drivers/rtc/rtc-dev.c
42404 +++ b/drivers/rtc/rtc-dev.c
42405 @@ -14,6 +14,7 @@
42406 #include <linux/module.h>
42407 #include <linux/rtc.h>
42408 #include <linux/sched.h>
42409 +#include <linux/grsecurity.h>
42410 #include "rtc-core.h"
42411
42412 static dev_t rtc_devt;
42413 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
42414 if (copy_from_user(&tm, uarg, sizeof(tm)))
42415 return -EFAULT;
42416
42417 + gr_log_timechange();
42418 +
42419 return rtc_set_time(rtc, &tm);
42420
42421 case RTC_PIE_ON:
42422 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
42423 index e0d0ba4..3c65868 100644
42424 --- a/drivers/rtc/rtc-ds1307.c
42425 +++ b/drivers/rtc/rtc-ds1307.c
42426 @@ -106,7 +106,7 @@ struct ds1307 {
42427 u8 offset; /* register's offset */
42428 u8 regs[11];
42429 u16 nvram_offset;
42430 - struct bin_attribute *nvram;
42431 + bin_attribute_no_const *nvram;
42432 enum ds_type type;
42433 unsigned long flags;
42434 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
42435 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
42436 index 130f29a..6179d03 100644
42437 --- a/drivers/rtc/rtc-m48t59.c
42438 +++ b/drivers/rtc/rtc-m48t59.c
42439 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
42440 goto out;
42441 }
42442
42443 - m48t59_nvram_attr.size = pdata->offset;
42444 + pax_open_kernel();
42445 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
42446 + pax_close_kernel();
42447
42448 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
42449 if (ret) {
42450 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
42451 index e693af6..2e525b6 100644
42452 --- a/drivers/scsi/bfa/bfa_fcpim.h
42453 +++ b/drivers/scsi/bfa/bfa_fcpim.h
42454 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
42455
42456 struct bfa_itn_s {
42457 bfa_isr_func_t isr;
42458 -};
42459 +} __no_const;
42460
42461 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
42462 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
42463 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
42464 index 23a90e7..9cf04ee 100644
42465 --- a/drivers/scsi/bfa/bfa_ioc.h
42466 +++ b/drivers/scsi/bfa/bfa_ioc.h
42467 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
42468 bfa_ioc_disable_cbfn_t disable_cbfn;
42469 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
42470 bfa_ioc_reset_cbfn_t reset_cbfn;
42471 -};
42472 +} __no_const;
42473
42474 /*
42475 * IOC event notification mechanism.
42476 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
42477 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
42478 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
42479 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
42480 -};
42481 +} __no_const;
42482
42483 /*
42484 * Queue element to wait for room in request queue. FIFO order is
42485 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
42486 index 593085a..47aa999 100644
42487 --- a/drivers/scsi/hosts.c
42488 +++ b/drivers/scsi/hosts.c
42489 @@ -42,7 +42,7 @@
42490 #include "scsi_logging.h"
42491
42492
42493 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42494 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42495
42496
42497 static void scsi_host_cls_release(struct device *dev)
42498 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
42499 * subtract one because we increment first then return, but we need to
42500 * know what the next host number was before increment
42501 */
42502 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
42503 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
42504 shost->dma_channel = 0xff;
42505
42506 /* These three are default values which can be overridden */
42507 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
42508 index 4f33806..afd6f60 100644
42509 --- a/drivers/scsi/hpsa.c
42510 +++ b/drivers/scsi/hpsa.c
42511 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
42512 unsigned long flags;
42513
42514 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
42515 - return h->access.command_completed(h, q);
42516 + return h->access->command_completed(h, q);
42517
42518 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
42519 a = rq->head[rq->current_entry];
42520 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
42521 while (!list_empty(&h->reqQ)) {
42522 c = list_entry(h->reqQ.next, struct CommandList, list);
42523 /* can't do anything if fifo is full */
42524 - if ((h->access.fifo_full(h))) {
42525 + if ((h->access->fifo_full(h))) {
42526 dev_warn(&h->pdev->dev, "fifo full\n");
42527 break;
42528 }
42529 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
42530
42531 /* Tell the controller execute command */
42532 spin_unlock_irqrestore(&h->lock, flags);
42533 - h->access.submit_command(h, c);
42534 + h->access->submit_command(h, c);
42535 spin_lock_irqsave(&h->lock, flags);
42536 }
42537 spin_unlock_irqrestore(&h->lock, flags);
42538 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
42539
42540 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42541 {
42542 - return h->access.command_completed(h, q);
42543 + return h->access->command_completed(h, q);
42544 }
42545
42546 static inline bool interrupt_pending(struct ctlr_info *h)
42547 {
42548 - return h->access.intr_pending(h);
42549 + return h->access->intr_pending(h);
42550 }
42551
42552 static inline long interrupt_not_for_us(struct ctlr_info *h)
42553 {
42554 - return (h->access.intr_pending(h) == 0) ||
42555 + return (h->access->intr_pending(h) == 0) ||
42556 (h->interrupts_enabled == 0);
42557 }
42558
42559 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42560 if (prod_index < 0)
42561 return -ENODEV;
42562 h->product_name = products[prod_index].product_name;
42563 - h->access = *(products[prod_index].access);
42564 + h->access = products[prod_index].access;
42565
42566 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42567 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42568 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42569
42570 assert_spin_locked(&lockup_detector_lock);
42571 remove_ctlr_from_lockup_detector_list(h);
42572 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42573 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42574 spin_lock_irqsave(&h->lock, flags);
42575 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42576 spin_unlock_irqrestore(&h->lock, flags);
42577 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
42578 }
42579
42580 /* make sure the board interrupts are off */
42581 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42582 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42583
42584 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42585 goto clean2;
42586 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
42587 * fake ones to scoop up any residual completions.
42588 */
42589 spin_lock_irqsave(&h->lock, flags);
42590 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42591 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42592 spin_unlock_irqrestore(&h->lock, flags);
42593 free_irqs(h);
42594 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42595 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
42596 dev_info(&h->pdev->dev, "Board READY.\n");
42597 dev_info(&h->pdev->dev,
42598 "Waiting for stale completions to drain.\n");
42599 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42600 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42601 msleep(10000);
42602 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42603 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42604
42605 rc = controller_reset_failed(h->cfgtable);
42606 if (rc)
42607 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
42608 }
42609
42610 /* Turn the interrupts on so we can service requests */
42611 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42612 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42613
42614 hpsa_hba_inquiry(h);
42615 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42616 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42617 * To write all data in the battery backed cache to disks
42618 */
42619 hpsa_flush_cache(h);
42620 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42621 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42622 hpsa_free_irqs_and_disable_msix(h);
42623 }
42624
42625 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42626 return;
42627 }
42628 /* Change the access methods to the performant access methods */
42629 - h->access = SA5_performant_access;
42630 + h->access = &SA5_performant_access;
42631 h->transMethod = CFGTBL_Trans_Performant;
42632 }
42633
42634 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42635 index 9816479..c5d4e97 100644
42636 --- a/drivers/scsi/hpsa.h
42637 +++ b/drivers/scsi/hpsa.h
42638 @@ -79,7 +79,7 @@ struct ctlr_info {
42639 unsigned int msix_vector;
42640 unsigned int msi_vector;
42641 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42642 - struct access_method access;
42643 + struct access_method *access;
42644
42645 /* queue and queue Info */
42646 struct list_head reqQ;
42647 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42648 index c772d8d..35c362c 100644
42649 --- a/drivers/scsi/libfc/fc_exch.c
42650 +++ b/drivers/scsi/libfc/fc_exch.c
42651 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42652 u16 pool_max_index;
42653
42654 struct {
42655 - atomic_t no_free_exch;
42656 - atomic_t no_free_exch_xid;
42657 - atomic_t xid_not_found;
42658 - atomic_t xid_busy;
42659 - atomic_t seq_not_found;
42660 - atomic_t non_bls_resp;
42661 + atomic_unchecked_t no_free_exch;
42662 + atomic_unchecked_t no_free_exch_xid;
42663 + atomic_unchecked_t xid_not_found;
42664 + atomic_unchecked_t xid_busy;
42665 + atomic_unchecked_t seq_not_found;
42666 + atomic_unchecked_t non_bls_resp;
42667 } stats;
42668 };
42669
42670 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42671 /* allocate memory for exchange */
42672 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42673 if (!ep) {
42674 - atomic_inc(&mp->stats.no_free_exch);
42675 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42676 goto out;
42677 }
42678 memset(ep, 0, sizeof(*ep));
42679 @@ -786,7 +786,7 @@ out:
42680 return ep;
42681 err:
42682 spin_unlock_bh(&pool->lock);
42683 - atomic_inc(&mp->stats.no_free_exch_xid);
42684 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42685 mempool_free(ep, mp->ep_pool);
42686 return NULL;
42687 }
42688 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42689 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42690 ep = fc_exch_find(mp, xid);
42691 if (!ep) {
42692 - atomic_inc(&mp->stats.xid_not_found);
42693 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42694 reject = FC_RJT_OX_ID;
42695 goto out;
42696 }
42697 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42698 ep = fc_exch_find(mp, xid);
42699 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42700 if (ep) {
42701 - atomic_inc(&mp->stats.xid_busy);
42702 + atomic_inc_unchecked(&mp->stats.xid_busy);
42703 reject = FC_RJT_RX_ID;
42704 goto rel;
42705 }
42706 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42707 }
42708 xid = ep->xid; /* get our XID */
42709 } else if (!ep) {
42710 - atomic_inc(&mp->stats.xid_not_found);
42711 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42712 reject = FC_RJT_RX_ID; /* XID not found */
42713 goto out;
42714 }
42715 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42716 } else {
42717 sp = &ep->seq;
42718 if (sp->id != fh->fh_seq_id) {
42719 - atomic_inc(&mp->stats.seq_not_found);
42720 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42721 if (f_ctl & FC_FC_END_SEQ) {
42722 /*
42723 * Update sequence_id based on incoming last
42724 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42725
42726 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42727 if (!ep) {
42728 - atomic_inc(&mp->stats.xid_not_found);
42729 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42730 goto out;
42731 }
42732 if (ep->esb_stat & ESB_ST_COMPLETE) {
42733 - atomic_inc(&mp->stats.xid_not_found);
42734 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42735 goto rel;
42736 }
42737 if (ep->rxid == FC_XID_UNKNOWN)
42738 ep->rxid = ntohs(fh->fh_rx_id);
42739 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42740 - atomic_inc(&mp->stats.xid_not_found);
42741 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42742 goto rel;
42743 }
42744 if (ep->did != ntoh24(fh->fh_s_id) &&
42745 ep->did != FC_FID_FLOGI) {
42746 - atomic_inc(&mp->stats.xid_not_found);
42747 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42748 goto rel;
42749 }
42750 sof = fr_sof(fp);
42751 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42752 sp->ssb_stat |= SSB_ST_RESP;
42753 sp->id = fh->fh_seq_id;
42754 } else if (sp->id != fh->fh_seq_id) {
42755 - atomic_inc(&mp->stats.seq_not_found);
42756 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42757 goto rel;
42758 }
42759
42760 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42761 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42762
42763 if (!sp)
42764 - atomic_inc(&mp->stats.xid_not_found);
42765 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42766 else
42767 - atomic_inc(&mp->stats.non_bls_resp);
42768 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42769
42770 fc_frame_free(fp);
42771 }
42772 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42773
42774 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42775 mp = ema->mp;
42776 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42777 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42778 st->fc_no_free_exch_xid +=
42779 - atomic_read(&mp->stats.no_free_exch_xid);
42780 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42781 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42782 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42783 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42784 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42785 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42786 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42787 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42788 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42789 }
42790 }
42791 EXPORT_SYMBOL(fc_exch_update_stats);
42792 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42793 index bdb81cd..d3c7c2c 100644
42794 --- a/drivers/scsi/libsas/sas_ata.c
42795 +++ b/drivers/scsi/libsas/sas_ata.c
42796 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42797 .postreset = ata_std_postreset,
42798 .error_handler = ata_std_error_handler,
42799 .post_internal_cmd = sas_ata_post_internal,
42800 - .qc_defer = ata_std_qc_defer,
42801 + .qc_defer = ata_std_qc_defer,
42802 .qc_prep = ata_noop_qc_prep,
42803 .qc_issue = sas_ata_qc_issue,
42804 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42805 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42806 index df4c13a..a51e90c 100644
42807 --- a/drivers/scsi/lpfc/lpfc.h
42808 +++ b/drivers/scsi/lpfc/lpfc.h
42809 @@ -424,7 +424,7 @@ struct lpfc_vport {
42810 struct dentry *debug_nodelist;
42811 struct dentry *vport_debugfs_root;
42812 struct lpfc_debugfs_trc *disc_trc;
42813 - atomic_t disc_trc_cnt;
42814 + atomic_unchecked_t disc_trc_cnt;
42815 #endif
42816 uint8_t stat_data_enabled;
42817 uint8_t stat_data_blocked;
42818 @@ -842,8 +842,8 @@ struct lpfc_hba {
42819 struct timer_list fabric_block_timer;
42820 unsigned long bit_flags;
42821 #define FABRIC_COMANDS_BLOCKED 0
42822 - atomic_t num_rsrc_err;
42823 - atomic_t num_cmd_success;
42824 + atomic_unchecked_t num_rsrc_err;
42825 + atomic_unchecked_t num_cmd_success;
42826 unsigned long last_rsrc_error_time;
42827 unsigned long last_ramp_down_time;
42828 unsigned long last_ramp_up_time;
42829 @@ -879,7 +879,7 @@ struct lpfc_hba {
42830
42831 struct dentry *debug_slow_ring_trc;
42832 struct lpfc_debugfs_trc *slow_ring_trc;
42833 - atomic_t slow_ring_trc_cnt;
42834 + atomic_unchecked_t slow_ring_trc_cnt;
42835 /* iDiag debugfs sub-directory */
42836 struct dentry *idiag_root;
42837 struct dentry *idiag_pci_cfg;
42838 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42839 index f63f5ff..de29189 100644
42840 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42841 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42842 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42843
42844 #include <linux/debugfs.h>
42845
42846 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42847 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42848 static unsigned long lpfc_debugfs_start_time = 0L;
42849
42850 /* iDiag */
42851 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42852 lpfc_debugfs_enable = 0;
42853
42854 len = 0;
42855 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42856 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42857 (lpfc_debugfs_max_disc_trc - 1);
42858 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42859 dtp = vport->disc_trc + i;
42860 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42861 lpfc_debugfs_enable = 0;
42862
42863 len = 0;
42864 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42865 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42866 (lpfc_debugfs_max_slow_ring_trc - 1);
42867 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42868 dtp = phba->slow_ring_trc + i;
42869 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42870 !vport || !vport->disc_trc)
42871 return;
42872
42873 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42874 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42875 (lpfc_debugfs_max_disc_trc - 1);
42876 dtp = vport->disc_trc + index;
42877 dtp->fmt = fmt;
42878 dtp->data1 = data1;
42879 dtp->data2 = data2;
42880 dtp->data3 = data3;
42881 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42882 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42883 dtp->jif = jiffies;
42884 #endif
42885 return;
42886 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42887 !phba || !phba->slow_ring_trc)
42888 return;
42889
42890 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42891 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42892 (lpfc_debugfs_max_slow_ring_trc - 1);
42893 dtp = phba->slow_ring_trc + index;
42894 dtp->fmt = fmt;
42895 dtp->data1 = data1;
42896 dtp->data2 = data2;
42897 dtp->data3 = data3;
42898 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42899 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42900 dtp->jif = jiffies;
42901 #endif
42902 return;
42903 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42904 "slow_ring buffer\n");
42905 goto debug_failed;
42906 }
42907 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42908 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42909 memset(phba->slow_ring_trc, 0,
42910 (sizeof(struct lpfc_debugfs_trc) *
42911 lpfc_debugfs_max_slow_ring_trc));
42912 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42913 "buffer\n");
42914 goto debug_failed;
42915 }
42916 - atomic_set(&vport->disc_trc_cnt, 0);
42917 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42918
42919 snprintf(name, sizeof(name), "discovery_trace");
42920 vport->debug_disc_trc =
42921 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42922 index 89ad558..76956c4 100644
42923 --- a/drivers/scsi/lpfc/lpfc_init.c
42924 +++ b/drivers/scsi/lpfc/lpfc_init.c
42925 @@ -10618,8 +10618,10 @@ lpfc_init(void)
42926 "misc_register returned with status %d", error);
42927
42928 if (lpfc_enable_npiv) {
42929 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42930 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42931 + pax_open_kernel();
42932 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42933 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42934 + pax_close_kernel();
42935 }
42936 lpfc_transport_template =
42937 fc_attach_transport(&lpfc_transport_functions);
42938 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42939 index 60e5a17..ff7a793 100644
42940 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42941 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42942 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42943 uint32_t evt_posted;
42944
42945 spin_lock_irqsave(&phba->hbalock, flags);
42946 - atomic_inc(&phba->num_rsrc_err);
42947 + atomic_inc_unchecked(&phba->num_rsrc_err);
42948 phba->last_rsrc_error_time = jiffies;
42949
42950 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42951 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42952 unsigned long flags;
42953 struct lpfc_hba *phba = vport->phba;
42954 uint32_t evt_posted;
42955 - atomic_inc(&phba->num_cmd_success);
42956 + atomic_inc_unchecked(&phba->num_cmd_success);
42957
42958 if (vport->cfg_lun_queue_depth <= queue_depth)
42959 return;
42960 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42961 unsigned long num_rsrc_err, num_cmd_success;
42962 int i;
42963
42964 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42965 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42966 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42967 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42968
42969 /*
42970 * The error and success command counters are global per
42971 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42972 }
42973 }
42974 lpfc_destroy_vport_work_array(phba, vports);
42975 - atomic_set(&phba->num_rsrc_err, 0);
42976 - atomic_set(&phba->num_cmd_success, 0);
42977 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42978 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42979 }
42980
42981 /**
42982 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42983 }
42984 }
42985 lpfc_destroy_vport_work_array(phba, vports);
42986 - atomic_set(&phba->num_rsrc_err, 0);
42987 - atomic_set(&phba->num_cmd_success, 0);
42988 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42989 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42990 }
42991
42992 /**
42993 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42994 index b46f5e9..c4c4ccb 100644
42995 --- a/drivers/scsi/pmcraid.c
42996 +++ b/drivers/scsi/pmcraid.c
42997 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42998 res->scsi_dev = scsi_dev;
42999 scsi_dev->hostdata = res;
43000 res->change_detected = 0;
43001 - atomic_set(&res->read_failures, 0);
43002 - atomic_set(&res->write_failures, 0);
43003 + atomic_set_unchecked(&res->read_failures, 0);
43004 + atomic_set_unchecked(&res->write_failures, 0);
43005 rc = 0;
43006 }
43007 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
43008 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
43009
43010 /* If this was a SCSI read/write command keep count of errors */
43011 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
43012 - atomic_inc(&res->read_failures);
43013 + atomic_inc_unchecked(&res->read_failures);
43014 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
43015 - atomic_inc(&res->write_failures);
43016 + atomic_inc_unchecked(&res->write_failures);
43017
43018 if (!RES_IS_GSCSI(res->cfg_entry) &&
43019 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
43020 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
43021 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
43022 * hrrq_id assigned here in queuecommand
43023 */
43024 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
43025 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
43026 pinstance->num_hrrq;
43027 cmd->cmd_done = pmcraid_io_done;
43028
43029 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
43030 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
43031 * hrrq_id assigned here in queuecommand
43032 */
43033 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
43034 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
43035 pinstance->num_hrrq;
43036
43037 if (request_size) {
43038 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
43039
43040 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
43041 /* add resources only after host is added into system */
43042 - if (!atomic_read(&pinstance->expose_resources))
43043 + if (!atomic_read_unchecked(&pinstance->expose_resources))
43044 return;
43045
43046 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
43047 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
43048 init_waitqueue_head(&pinstance->reset_wait_q);
43049
43050 atomic_set(&pinstance->outstanding_cmds, 0);
43051 - atomic_set(&pinstance->last_message_id, 0);
43052 - atomic_set(&pinstance->expose_resources, 0);
43053 + atomic_set_unchecked(&pinstance->last_message_id, 0);
43054 + atomic_set_unchecked(&pinstance->expose_resources, 0);
43055
43056 INIT_LIST_HEAD(&pinstance->free_res_q);
43057 INIT_LIST_HEAD(&pinstance->used_res_q);
43058 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
43059 /* Schedule worker thread to handle CCN and take care of adding and
43060 * removing devices to OS
43061 */
43062 - atomic_set(&pinstance->expose_resources, 1);
43063 + atomic_set_unchecked(&pinstance->expose_resources, 1);
43064 schedule_work(&pinstance->worker_q);
43065 return rc;
43066
43067 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
43068 index e1d150f..6c6df44 100644
43069 --- a/drivers/scsi/pmcraid.h
43070 +++ b/drivers/scsi/pmcraid.h
43071 @@ -748,7 +748,7 @@ struct pmcraid_instance {
43072 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
43073
43074 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
43075 - atomic_t last_message_id;
43076 + atomic_unchecked_t last_message_id;
43077
43078 /* configuration table */
43079 struct pmcraid_config_table *cfg_table;
43080 @@ -777,7 +777,7 @@ struct pmcraid_instance {
43081 atomic_t outstanding_cmds;
43082
43083 /* should add/delete resources to mid-layer now ?*/
43084 - atomic_t expose_resources;
43085 + atomic_unchecked_t expose_resources;
43086
43087
43088
43089 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
43090 struct pmcraid_config_table_entry_ext cfg_entry_ext;
43091 };
43092 struct scsi_device *scsi_dev; /* Link scsi_device structure */
43093 - atomic_t read_failures; /* count of failed READ commands */
43094 - atomic_t write_failures; /* count of failed WRITE commands */
43095 + atomic_unchecked_t read_failures; /* count of failed READ commands */
43096 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
43097
43098 /* To indicate add/delete/modify during CCN */
43099 u8 change_detected;
43100 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
43101 index 83d7984..a27d947 100644
43102 --- a/drivers/scsi/qla2xxx/qla_attr.c
43103 +++ b/drivers/scsi/qla2xxx/qla_attr.c
43104 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
43105 return 0;
43106 }
43107
43108 -struct fc_function_template qla2xxx_transport_functions = {
43109 +fc_function_template_no_const qla2xxx_transport_functions = {
43110
43111 .show_host_node_name = 1,
43112 .show_host_port_name = 1,
43113 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
43114 .bsg_timeout = qla24xx_bsg_timeout,
43115 };
43116
43117 -struct fc_function_template qla2xxx_transport_vport_functions = {
43118 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
43119
43120 .show_host_node_name = 1,
43121 .show_host_port_name = 1,
43122 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
43123 index 2411d1a..4673766 100644
43124 --- a/drivers/scsi/qla2xxx/qla_gbl.h
43125 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
43126 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
43127 struct device_attribute;
43128 extern struct device_attribute *qla2x00_host_attrs[];
43129 struct fc_function_template;
43130 -extern struct fc_function_template qla2xxx_transport_functions;
43131 -extern struct fc_function_template qla2xxx_transport_vport_functions;
43132 +extern fc_function_template_no_const qla2xxx_transport_functions;
43133 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
43134 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
43135 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
43136 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
43137 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
43138 index 10d23f8..a7d5d4c 100644
43139 --- a/drivers/scsi/qla2xxx/qla_os.c
43140 +++ b/drivers/scsi/qla2xxx/qla_os.c
43141 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
43142 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
43143 /* Ok, a 64bit DMA mask is applicable. */
43144 ha->flags.enable_64bit_addressing = 1;
43145 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
43146 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
43147 + pax_open_kernel();
43148 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
43149 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
43150 + pax_close_kernel();
43151 return;
43152 }
43153 }
43154 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
43155 index 329d553..f20d31d 100644
43156 --- a/drivers/scsi/qla4xxx/ql4_def.h
43157 +++ b/drivers/scsi/qla4xxx/ql4_def.h
43158 @@ -273,7 +273,7 @@ struct ddb_entry {
43159 * (4000 only) */
43160 atomic_t relogin_timer; /* Max Time to wait for
43161 * relogin to complete */
43162 - atomic_t relogin_retry_count; /* Num of times relogin has been
43163 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
43164 * retried */
43165 uint32_t default_time2wait; /* Default Min time between
43166 * relogins (+aens) */
43167 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
43168 index 4cec123..7c1329f 100644
43169 --- a/drivers/scsi/qla4xxx/ql4_os.c
43170 +++ b/drivers/scsi/qla4xxx/ql4_os.c
43171 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
43172 */
43173 if (!iscsi_is_session_online(cls_sess)) {
43174 /* Reset retry relogin timer */
43175 - atomic_inc(&ddb_entry->relogin_retry_count);
43176 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
43177 DEBUG2(ql4_printk(KERN_INFO, ha,
43178 "%s: index[%d] relogin timed out-retrying"
43179 " relogin (%d), retry (%d)\n", __func__,
43180 ddb_entry->fw_ddb_index,
43181 - atomic_read(&ddb_entry->relogin_retry_count),
43182 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
43183 ddb_entry->default_time2wait + 4));
43184 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
43185 atomic_set(&ddb_entry->retry_relogin_timer,
43186 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
43187
43188 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
43189 atomic_set(&ddb_entry->relogin_timer, 0);
43190 - atomic_set(&ddb_entry->relogin_retry_count, 0);
43191 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
43192 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
43193 ddb_entry->default_relogin_timeout =
43194 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
43195 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
43196 index 2c0d0ec..4e8681a 100644
43197 --- a/drivers/scsi/scsi.c
43198 +++ b/drivers/scsi/scsi.c
43199 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
43200 unsigned long timeout;
43201 int rtn = 0;
43202
43203 - atomic_inc(&cmd->device->iorequest_cnt);
43204 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
43205
43206 /* check if the device is still usable */
43207 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
43208 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
43209 index f1bf5af..f67e943 100644
43210 --- a/drivers/scsi/scsi_lib.c
43211 +++ b/drivers/scsi/scsi_lib.c
43212 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
43213 shost = sdev->host;
43214 scsi_init_cmd_errh(cmd);
43215 cmd->result = DID_NO_CONNECT << 16;
43216 - atomic_inc(&cmd->device->iorequest_cnt);
43217 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
43218
43219 /*
43220 * SCSI request completion path will do scsi_device_unbusy(),
43221 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
43222
43223 INIT_LIST_HEAD(&cmd->eh_entry);
43224
43225 - atomic_inc(&cmd->device->iodone_cnt);
43226 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
43227 if (cmd->result)
43228 - atomic_inc(&cmd->device->ioerr_cnt);
43229 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
43230
43231 disposition = scsi_decide_disposition(cmd);
43232 if (disposition != SUCCESS &&
43233 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
43234 index 931a7d9..0c2a754 100644
43235 --- a/drivers/scsi/scsi_sysfs.c
43236 +++ b/drivers/scsi/scsi_sysfs.c
43237 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
43238 char *buf) \
43239 { \
43240 struct scsi_device *sdev = to_scsi_device(dev); \
43241 - unsigned long long count = atomic_read(&sdev->field); \
43242 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
43243 return snprintf(buf, 20, "0x%llx\n", count); \
43244 } \
43245 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
43246 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
43247 index 84a1fdf..693b0d6 100644
43248 --- a/drivers/scsi/scsi_tgt_lib.c
43249 +++ b/drivers/scsi/scsi_tgt_lib.c
43250 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
43251 int err;
43252
43253 dprintk("%lx %u\n", uaddr, len);
43254 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
43255 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
43256 if (err) {
43257 /*
43258 * TODO: need to fixup sg_tablesize, max_segment_size,
43259 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
43260 index e894ca7..de9d7660 100644
43261 --- a/drivers/scsi/scsi_transport_fc.c
43262 +++ b/drivers/scsi/scsi_transport_fc.c
43263 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
43264 * Netlink Infrastructure
43265 */
43266
43267 -static atomic_t fc_event_seq;
43268 +static atomic_unchecked_t fc_event_seq;
43269
43270 /**
43271 * fc_get_event_number - Obtain the next sequential FC event number
43272 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
43273 u32
43274 fc_get_event_number(void)
43275 {
43276 - return atomic_add_return(1, &fc_event_seq);
43277 + return atomic_add_return_unchecked(1, &fc_event_seq);
43278 }
43279 EXPORT_SYMBOL(fc_get_event_number);
43280
43281 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
43282 {
43283 int error;
43284
43285 - atomic_set(&fc_event_seq, 0);
43286 + atomic_set_unchecked(&fc_event_seq, 0);
43287
43288 error = transport_class_register(&fc_host_class);
43289 if (error)
43290 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
43291 char *cp;
43292
43293 *val = simple_strtoul(buf, &cp, 0);
43294 - if ((*cp && (*cp != '\n')) || (*val < 0))
43295 + if (*cp && (*cp != '\n'))
43296 return -EINVAL;
43297 /*
43298 * Check for overflow; dev_loss_tmo is u32
43299 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
43300 index 31969f2..2b348f0 100644
43301 --- a/drivers/scsi/scsi_transport_iscsi.c
43302 +++ b/drivers/scsi/scsi_transport_iscsi.c
43303 @@ -79,7 +79,7 @@ struct iscsi_internal {
43304 struct transport_container session_cont;
43305 };
43306
43307 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
43308 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
43309 static struct workqueue_struct *iscsi_eh_timer_workq;
43310
43311 static DEFINE_IDA(iscsi_sess_ida);
43312 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
43313 int err;
43314
43315 ihost = shost->shost_data;
43316 - session->sid = atomic_add_return(1, &iscsi_session_nr);
43317 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
43318
43319 if (target_id == ISCSI_MAX_TARGET) {
43320 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
43321 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
43322 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
43323 ISCSI_TRANSPORT_VERSION);
43324
43325 - atomic_set(&iscsi_session_nr, 0);
43326 + atomic_set_unchecked(&iscsi_session_nr, 0);
43327
43328 err = class_register(&iscsi_transport_class);
43329 if (err)
43330 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
43331 index f379c7f..e8fc69c 100644
43332 --- a/drivers/scsi/scsi_transport_srp.c
43333 +++ b/drivers/scsi/scsi_transport_srp.c
43334 @@ -33,7 +33,7 @@
43335 #include "scsi_transport_srp_internal.h"
43336
43337 struct srp_host_attrs {
43338 - atomic_t next_port_id;
43339 + atomic_unchecked_t next_port_id;
43340 };
43341 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
43342
43343 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
43344 struct Scsi_Host *shost = dev_to_shost(dev);
43345 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
43346
43347 - atomic_set(&srp_host->next_port_id, 0);
43348 + atomic_set_unchecked(&srp_host->next_port_id, 0);
43349 return 0;
43350 }
43351
43352 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
43353 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
43354 rport->roles = ids->roles;
43355
43356 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
43357 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
43358 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
43359
43360 transport_setup_device(&rport->dev);
43361 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
43362 index 7992635..609faf8 100644
43363 --- a/drivers/scsi/sd.c
43364 +++ b/drivers/scsi/sd.c
43365 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
43366 sdkp->disk = gd;
43367 sdkp->index = index;
43368 atomic_set(&sdkp->openers, 0);
43369 - atomic_set(&sdkp->device->ioerr_cnt, 0);
43370 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
43371
43372 if (!sdp->request_queue->rq_timeout) {
43373 if (sdp->type != TYPE_MOD)
43374 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
43375 index be2c9a6..275525c 100644
43376 --- a/drivers/scsi/sg.c
43377 +++ b/drivers/scsi/sg.c
43378 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
43379 sdp->disk->disk_name,
43380 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
43381 NULL,
43382 - (char *)arg);
43383 + (char __user *)arg);
43384 case BLKTRACESTART:
43385 return blk_trace_startstop(sdp->device->request_queue, 1);
43386 case BLKTRACESTOP:
43387 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
43388 index 19ee901..6e8c2ef 100644
43389 --- a/drivers/spi/spi.c
43390 +++ b/drivers/spi/spi.c
43391 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
43392 EXPORT_SYMBOL_GPL(spi_bus_unlock);
43393
43394 /* portable code must never pass more than 32 bytes */
43395 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
43396 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
43397
43398 static u8 *buf;
43399
43400 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
43401 index c7a5f97..71ecd35 100644
43402 --- a/drivers/staging/iio/iio_hwmon.c
43403 +++ b/drivers/staging/iio/iio_hwmon.c
43404 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
43405 static int iio_hwmon_probe(struct platform_device *pdev)
43406 {
43407 struct iio_hwmon_state *st;
43408 - struct sensor_device_attribute *a;
43409 + sensor_device_attribute_no_const *a;
43410 int ret, i;
43411 int in_i = 1, temp_i = 1, curr_i = 1;
43412 enum iio_chan_type type;
43413 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
43414 index 34afc16..ffe44dd 100644
43415 --- a/drivers/staging/octeon/ethernet-rx.c
43416 +++ b/drivers/staging/octeon/ethernet-rx.c
43417 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
43418 /* Increment RX stats for virtual ports */
43419 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
43420 #ifdef CONFIG_64BIT
43421 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
43422 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
43423 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
43424 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
43425 #else
43426 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
43427 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
43428 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
43429 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
43430 #endif
43431 }
43432 netif_receive_skb(skb);
43433 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
43434 dev->name);
43435 */
43436 #ifdef CONFIG_64BIT
43437 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
43438 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43439 #else
43440 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
43441 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
43442 #endif
43443 dev_kfree_skb_irq(skb);
43444 }
43445 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
43446 index ef32dc1..a159d68 100644
43447 --- a/drivers/staging/octeon/ethernet.c
43448 +++ b/drivers/staging/octeon/ethernet.c
43449 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
43450 * since the RX tasklet also increments it.
43451 */
43452 #ifdef CONFIG_64BIT
43453 - atomic64_add(rx_status.dropped_packets,
43454 - (atomic64_t *)&priv->stats.rx_dropped);
43455 + atomic64_add_unchecked(rx_status.dropped_packets,
43456 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43457 #else
43458 - atomic_add(rx_status.dropped_packets,
43459 - (atomic_t *)&priv->stats.rx_dropped);
43460 + atomic_add_unchecked(rx_status.dropped_packets,
43461 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
43462 #endif
43463 }
43464
43465 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
43466 index a2b7e03..aaf3630 100644
43467 --- a/drivers/staging/ramster/tmem.c
43468 +++ b/drivers/staging/ramster/tmem.c
43469 @@ -50,25 +50,25 @@
43470 * A tmem host implementation must use this function to register callbacks
43471 * for memory allocation.
43472 */
43473 -static struct tmem_hostops tmem_hostops;
43474 +static struct tmem_hostops *tmem_hostops;
43475
43476 static void tmem_objnode_tree_init(void);
43477
43478 void tmem_register_hostops(struct tmem_hostops *m)
43479 {
43480 tmem_objnode_tree_init();
43481 - tmem_hostops = *m;
43482 + tmem_hostops = m;
43483 }
43484
43485 /*
43486 * A tmem host implementation must use this function to register
43487 * callbacks for a page-accessible memory (PAM) implementation.
43488 */
43489 -static struct tmem_pamops tmem_pamops;
43490 +static struct tmem_pamops *tmem_pamops;
43491
43492 void tmem_register_pamops(struct tmem_pamops *m)
43493 {
43494 - tmem_pamops = *m;
43495 + tmem_pamops = m;
43496 }
43497
43498 /*
43499 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
43500 obj->pampd_count = 0;
43501 #ifdef CONFIG_RAMSTER
43502 if (tmem_pamops.new_obj != NULL)
43503 - (*tmem_pamops.new_obj)(obj);
43504 + (tmem_pamops->new_obj)(obj);
43505 #endif
43506 SET_SENTINEL(obj, OBJ);
43507
43508 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
43509 rbnode = rb_next(rbnode);
43510 tmem_pampd_destroy_all_in_obj(obj, true);
43511 tmem_obj_free(obj, hb);
43512 - (*tmem_hostops.obj_free)(obj, pool);
43513 + (tmem_hostops->obj_free)(obj, pool);
43514 }
43515 spin_unlock(&hb->lock);
43516 }
43517 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
43518 ASSERT_SENTINEL(obj, OBJ);
43519 BUG_ON(obj->pool == NULL);
43520 ASSERT_SENTINEL(obj->pool, POOL);
43521 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
43522 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
43523 if (unlikely(objnode == NULL))
43524 goto out;
43525 objnode->obj = obj;
43526 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
43527 ASSERT_SENTINEL(pool, POOL);
43528 objnode->obj->objnode_count--;
43529 objnode->obj = NULL;
43530 - (*tmem_hostops.objnode_free)(objnode, pool);
43531 + (tmem_hostops->objnode_free)(objnode, pool);
43532 }
43533
43534 /*
43535 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
43536 void *old_pampd = *(void **)slot;
43537 *(void **)slot = new_pampd;
43538 if (!no_free)
43539 - (*tmem_pamops.free)(old_pampd, obj->pool,
43540 + (tmem_pamops->free)(old_pampd, obj->pool,
43541 NULL, 0, false);
43542 ret = new_pampd;
43543 }
43544 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
43545 if (objnode->slots[i]) {
43546 if (ht == 1) {
43547 obj->pampd_count--;
43548 - (*tmem_pamops.free)(objnode->slots[i],
43549 + (tmem_pamops->free)(objnode->slots[i],
43550 obj->pool, NULL, 0, true);
43551 objnode->slots[i] = NULL;
43552 continue;
43553 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43554 return;
43555 if (obj->objnode_tree_height == 0) {
43556 obj->pampd_count--;
43557 - (*tmem_pamops.free)(obj->objnode_tree_root,
43558 + (tmem_pamops->free)(obj->objnode_tree_root,
43559 obj->pool, NULL, 0, true);
43560 } else {
43561 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
43562 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43563 obj->objnode_tree_root = NULL;
43564 #ifdef CONFIG_RAMSTER
43565 if (tmem_pamops.free_obj != NULL)
43566 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
43567 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
43568 #endif
43569 }
43570
43571 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43572 /* if found, is a dup put, flush the old one */
43573 pampd_del = tmem_pampd_delete_from_obj(obj, index);
43574 BUG_ON(pampd_del != pampd);
43575 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43576 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43577 if (obj->pampd_count == 0) {
43578 objnew = obj;
43579 objfound = NULL;
43580 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43581 pampd = NULL;
43582 }
43583 } else {
43584 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
43585 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
43586 if (unlikely(obj == NULL)) {
43587 ret = -ENOMEM;
43588 goto out;
43589 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43590 if (unlikely(ret == -ENOMEM))
43591 /* may have partially built objnode tree ("stump") */
43592 goto delete_and_free;
43593 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
43594 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
43595 goto out;
43596
43597 delete_and_free:
43598 (void)tmem_pampd_delete_from_obj(obj, index);
43599 if (pampd)
43600 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
43601 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
43602 if (objnew) {
43603 tmem_obj_free(objnew, hb);
43604 - (*tmem_hostops.obj_free)(objnew, pool);
43605 + (tmem_hostops->obj_free)(objnew, pool);
43606 }
43607 out:
43608 spin_unlock(&hb->lock);
43609 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
43610 if (pampd != NULL) {
43611 BUG_ON(obj == NULL);
43612 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
43613 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
43614 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
43615 } else if (delete) {
43616 BUG_ON(obj == NULL);
43617 (void)tmem_pampd_delete_from_obj(obj, index);
43618 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43619 int ret = 0;
43620
43621 if (!is_ephemeral(pool))
43622 - new_pampd = (*tmem_pamops.repatriate_preload)(
43623 + new_pampd = (tmem_pamops->repatriate_preload)(
43624 old_pampd, pool, oidp, index, &intransit);
43625 if (intransit)
43626 ret = -EAGAIN;
43627 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43628 /* must release the hb->lock else repatriate can't sleep */
43629 spin_unlock(&hb->lock);
43630 if (!intransit)
43631 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
43632 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
43633 oidp, index, free, data);
43634 if (ret == -EAGAIN) {
43635 /* rare I think, but should cond_resched()??? */
43636 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
43637 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
43638 /* if we bug here, pamops wasn't properly set up for ramster */
43639 BUG_ON(tmem_pamops.replace_in_obj == NULL);
43640 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
43641 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
43642 out:
43643 spin_unlock(&hb->lock);
43644 return ret;
43645 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43646 if (free) {
43647 if (obj->pampd_count == 0) {
43648 tmem_obj_free(obj, hb);
43649 - (*tmem_hostops.obj_free)(obj, pool);
43650 + (tmem_hostops->obj_free)(obj, pool);
43651 obj = NULL;
43652 }
43653 }
43654 if (free)
43655 - ret = (*tmem_pamops.get_data_and_free)(
43656 + ret = (tmem_pamops->get_data_and_free)(
43657 data, sizep, raw, pampd, pool, oidp, index);
43658 else
43659 - ret = (*tmem_pamops.get_data)(
43660 + ret = (tmem_pamops->get_data)(
43661 data, sizep, raw, pampd, pool, oidp, index);
43662 if (ret < 0)
43663 goto out;
43664 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
43665 pampd = tmem_pampd_delete_from_obj(obj, index);
43666 if (pampd == NULL)
43667 goto out;
43668 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43669 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43670 if (obj->pampd_count == 0) {
43671 tmem_obj_free(obj, hb);
43672 - (*tmem_hostops.obj_free)(obj, pool);
43673 + (tmem_hostops->obj_free)(obj, pool);
43674 }
43675 ret = 0;
43676
43677 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
43678 goto out;
43679 tmem_pampd_destroy_all_in_obj(obj, false);
43680 tmem_obj_free(obj, hb);
43681 - (*tmem_hostops.obj_free)(obj, pool);
43682 + (tmem_hostops->obj_free)(obj, pool);
43683 ret = 0;
43684
43685 out:
43686 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43687 index dc23395..cf7e9b1 100644
43688 --- a/drivers/staging/rtl8712/rtl871x_io.h
43689 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43690 @@ -108,7 +108,7 @@ struct _io_ops {
43691 u8 *pmem);
43692 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43693 u8 *pmem);
43694 -};
43695 +} __no_const;
43696
43697 struct io_req {
43698 struct list_head list;
43699 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43700 index 1f5088b..0e59820 100644
43701 --- a/drivers/staging/sbe-2t3e3/netdev.c
43702 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43703 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43704 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43705
43706 if (rlen)
43707 - if (copy_to_user(data, &resp, rlen))
43708 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43709 return -EFAULT;
43710
43711 return 0;
43712 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43713 index 5dddc4d..34fcb2f 100644
43714 --- a/drivers/staging/usbip/vhci.h
43715 +++ b/drivers/staging/usbip/vhci.h
43716 @@ -83,7 +83,7 @@ struct vhci_hcd {
43717 unsigned resuming:1;
43718 unsigned long re_timeout;
43719
43720 - atomic_t seqnum;
43721 + atomic_unchecked_t seqnum;
43722
43723 /*
43724 * NOTE:
43725 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43726 index c3aa219..bf8b3de 100644
43727 --- a/drivers/staging/usbip/vhci_hcd.c
43728 +++ b/drivers/staging/usbip/vhci_hcd.c
43729 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
43730 return;
43731 }
43732
43733 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43734 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43735 if (priv->seqnum == 0xffff)
43736 dev_info(&urb->dev->dev, "seqnum max\n");
43737
43738 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43739 return -ENOMEM;
43740 }
43741
43742 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43743 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43744 if (unlink->seqnum == 0xffff)
43745 pr_info("seqnum max\n");
43746
43747 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
43748 vdev->rhport = rhport;
43749 }
43750
43751 - atomic_set(&vhci->seqnum, 0);
43752 + atomic_set_unchecked(&vhci->seqnum, 0);
43753 spin_lock_init(&vhci->lock);
43754
43755 hcd->power_budget = 0; /* no limit */
43756 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43757 index ba5f1c0..11d8122 100644
43758 --- a/drivers/staging/usbip/vhci_rx.c
43759 +++ b/drivers/staging/usbip/vhci_rx.c
43760 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43761 if (!urb) {
43762 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43763 pr_info("max seqnum %d\n",
43764 - atomic_read(&the_controller->seqnum));
43765 + atomic_read_unchecked(&the_controller->seqnum));
43766 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43767 return;
43768 }
43769 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43770 index 5f13890..36a044b 100644
43771 --- a/drivers/staging/vt6655/hostap.c
43772 +++ b/drivers/staging/vt6655/hostap.c
43773 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
43774 *
43775 */
43776
43777 +static net_device_ops_no_const apdev_netdev_ops;
43778 +
43779 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43780 {
43781 PSDevice apdev_priv;
43782 struct net_device *dev = pDevice->dev;
43783 int ret;
43784 - const struct net_device_ops apdev_netdev_ops = {
43785 - .ndo_start_xmit = pDevice->tx_80211,
43786 - };
43787
43788 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43789
43790 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43791 *apdev_priv = *pDevice;
43792 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43793
43794 + /* only half broken now */
43795 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43796 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43797
43798 pDevice->apdev->type = ARPHRD_IEEE80211;
43799 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43800 index 26a7d0e..897b083 100644
43801 --- a/drivers/staging/vt6656/hostap.c
43802 +++ b/drivers/staging/vt6656/hostap.c
43803 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43804 *
43805 */
43806
43807 +static net_device_ops_no_const apdev_netdev_ops;
43808 +
43809 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43810 {
43811 PSDevice apdev_priv;
43812 struct net_device *dev = pDevice->dev;
43813 int ret;
43814 - const struct net_device_ops apdev_netdev_ops = {
43815 - .ndo_start_xmit = pDevice->tx_80211,
43816 - };
43817
43818 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43819
43820 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43821 *apdev_priv = *pDevice;
43822 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43823
43824 + /* only half broken now */
43825 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43826 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43827
43828 pDevice->apdev->type = ARPHRD_IEEE80211;
43829 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43830 index 56c8e60..1920c63 100644
43831 --- a/drivers/staging/zcache/tmem.c
43832 +++ b/drivers/staging/zcache/tmem.c
43833 @@ -39,7 +39,7 @@
43834 * A tmem host implementation must use this function to register callbacks
43835 * for memory allocation.
43836 */
43837 -static struct tmem_hostops tmem_hostops;
43838 +static tmem_hostops_no_const tmem_hostops;
43839
43840 static void tmem_objnode_tree_init(void);
43841
43842 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43843 * A tmem host implementation must use this function to register
43844 * callbacks for a page-accessible memory (PAM) implementation
43845 */
43846 -static struct tmem_pamops tmem_pamops;
43847 +static tmem_pamops_no_const tmem_pamops;
43848
43849 void tmem_register_pamops(struct tmem_pamops *m)
43850 {
43851 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43852 index 0d4aa82..f7832d4 100644
43853 --- a/drivers/staging/zcache/tmem.h
43854 +++ b/drivers/staging/zcache/tmem.h
43855 @@ -180,6 +180,7 @@ struct tmem_pamops {
43856 void (*new_obj)(struct tmem_obj *);
43857 int (*replace_in_obj)(void *, struct tmem_obj *);
43858 };
43859 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43860 extern void tmem_register_pamops(struct tmem_pamops *m);
43861
43862 /* memory allocation methods provided by the host implementation */
43863 @@ -189,6 +190,7 @@ struct tmem_hostops {
43864 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43865 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43866 };
43867 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43868 extern void tmem_register_hostops(struct tmem_hostops *m);
43869
43870 /* core tmem accessor functions */
43871 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43872 index 96f4981..4daaa7e 100644
43873 --- a/drivers/target/target_core_device.c
43874 +++ b/drivers/target/target_core_device.c
43875 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43876 spin_lock_init(&dev->se_port_lock);
43877 spin_lock_init(&dev->se_tmr_lock);
43878 spin_lock_init(&dev->qf_cmd_lock);
43879 - atomic_set(&dev->dev_ordered_id, 0);
43880 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43881 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43882 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43883 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43884 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43885 index fcf880f..a4d1e8f 100644
43886 --- a/drivers/target/target_core_transport.c
43887 +++ b/drivers/target/target_core_transport.c
43888 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43889 * Used to determine when ORDERED commands should go from
43890 * Dormant to Active status.
43891 */
43892 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43893 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43894 smp_mb__after_atomic_inc();
43895 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43896 cmd->se_ordered_id, cmd->sam_task_attr,
43897 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43898 index b09c8d1f..c4225c0 100644
43899 --- a/drivers/tty/cyclades.c
43900 +++ b/drivers/tty/cyclades.c
43901 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43902 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43903 info->port.count);
43904 #endif
43905 - info->port.count++;
43906 + atomic_inc(&info->port.count);
43907 #ifdef CY_DEBUG_COUNT
43908 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43909 - current->pid, info->port.count);
43910 + current->pid, atomic_read(&info->port.count));
43911 #endif
43912
43913 /*
43914 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43915 for (j = 0; j < cy_card[i].nports; j++) {
43916 info = &cy_card[i].ports[j];
43917
43918 - if (info->port.count) {
43919 + if (atomic_read(&info->port.count)) {
43920 /* XXX is the ldisc num worth this? */
43921 struct tty_struct *tty;
43922 struct tty_ldisc *ld;
43923 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43924 index 13ee53b..418d164 100644
43925 --- a/drivers/tty/hvc/hvc_console.c
43926 +++ b/drivers/tty/hvc/hvc_console.c
43927 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43928
43929 spin_lock_irqsave(&hp->port.lock, flags);
43930 /* Check and then increment for fast path open. */
43931 - if (hp->port.count++ > 0) {
43932 + if (atomic_inc_return(&hp->port.count) > 1) {
43933 spin_unlock_irqrestore(&hp->port.lock, flags);
43934 hvc_kick();
43935 return 0;
43936 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43937
43938 spin_lock_irqsave(&hp->port.lock, flags);
43939
43940 - if (--hp->port.count == 0) {
43941 + if (atomic_dec_return(&hp->port.count) == 0) {
43942 spin_unlock_irqrestore(&hp->port.lock, flags);
43943 /* We are done with the tty pointer now. */
43944 tty_port_tty_set(&hp->port, NULL);
43945 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43946 */
43947 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43948 } else {
43949 - if (hp->port.count < 0)
43950 + if (atomic_read(&hp->port.count) < 0)
43951 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43952 - hp->vtermno, hp->port.count);
43953 + hp->vtermno, atomic_read(&hp->port.count));
43954 spin_unlock_irqrestore(&hp->port.lock, flags);
43955 }
43956 }
43957 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43958 * open->hangup case this can be called after the final close so prevent
43959 * that from happening for now.
43960 */
43961 - if (hp->port.count <= 0) {
43962 + if (atomic_read(&hp->port.count) <= 0) {
43963 spin_unlock_irqrestore(&hp->port.lock, flags);
43964 return;
43965 }
43966
43967 - hp->port.count = 0;
43968 + atomic_set(&hp->port.count, 0);
43969 spin_unlock_irqrestore(&hp->port.lock, flags);
43970 tty_port_tty_set(&hp->port, NULL);
43971
43972 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43973 return -EPIPE;
43974
43975 /* FIXME what's this (unprotected) check for? */
43976 - if (hp->port.count <= 0)
43977 + if (atomic_read(&hp->port.count) <= 0)
43978 return -EIO;
43979
43980 spin_lock_irqsave(&hp->lock, flags);
43981 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43982 index 8776357..b2d4afd 100644
43983 --- a/drivers/tty/hvc/hvcs.c
43984 +++ b/drivers/tty/hvc/hvcs.c
43985 @@ -83,6 +83,7 @@
43986 #include <asm/hvcserver.h>
43987 #include <asm/uaccess.h>
43988 #include <asm/vio.h>
43989 +#include <asm/local.h>
43990
43991 /*
43992 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43993 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43994
43995 spin_lock_irqsave(&hvcsd->lock, flags);
43996
43997 - if (hvcsd->port.count > 0) {
43998 + if (atomic_read(&hvcsd->port.count) > 0) {
43999 spin_unlock_irqrestore(&hvcsd->lock, flags);
44000 printk(KERN_INFO "HVCS: vterm state unchanged. "
44001 "The hvcs device node is still in use.\n");
44002 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
44003 }
44004 }
44005
44006 - hvcsd->port.count = 0;
44007 + atomic_set(&hvcsd->port.count, 0);
44008 hvcsd->port.tty = tty;
44009 tty->driver_data = hvcsd;
44010
44011 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
44012 unsigned long flags;
44013
44014 spin_lock_irqsave(&hvcsd->lock, flags);
44015 - hvcsd->port.count++;
44016 + atomic_inc(&hvcsd->port.count);
44017 hvcsd->todo_mask |= HVCS_SCHED_READ;
44018 spin_unlock_irqrestore(&hvcsd->lock, flags);
44019
44020 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
44021 hvcsd = tty->driver_data;
44022
44023 spin_lock_irqsave(&hvcsd->lock, flags);
44024 - if (--hvcsd->port.count == 0) {
44025 + if (atomic_dec_and_test(&hvcsd->port.count)) {
44026
44027 vio_disable_interrupts(hvcsd->vdev);
44028
44029 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
44030
44031 free_irq(irq, hvcsd);
44032 return;
44033 - } else if (hvcsd->port.count < 0) {
44034 + } else if (atomic_read(&hvcsd->port.count) < 0) {
44035 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
44036 " is missmanaged.\n",
44037 - hvcsd->vdev->unit_address, hvcsd->port.count);
44038 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
44039 }
44040
44041 spin_unlock_irqrestore(&hvcsd->lock, flags);
44042 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
44043
44044 spin_lock_irqsave(&hvcsd->lock, flags);
44045 /* Preserve this so that we know how many kref refs to put */
44046 - temp_open_count = hvcsd->port.count;
44047 + temp_open_count = atomic_read(&hvcsd->port.count);
44048
44049 /*
44050 * Don't kref put inside the spinlock because the destruction
44051 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
44052 tty->driver_data = NULL;
44053 hvcsd->port.tty = NULL;
44054
44055 - hvcsd->port.count = 0;
44056 + atomic_set(&hvcsd->port.count, 0);
44057
44058 /* This will drop any buffered data on the floor which is OK in a hangup
44059 * scenario. */
44060 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
44061 * the middle of a write operation? This is a crummy place to do this
44062 * but we want to keep it all in the spinlock.
44063 */
44064 - if (hvcsd->port.count <= 0) {
44065 + if (atomic_read(&hvcsd->port.count) <= 0) {
44066 spin_unlock_irqrestore(&hvcsd->lock, flags);
44067 return -ENODEV;
44068 }
44069 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
44070 {
44071 struct hvcs_struct *hvcsd = tty->driver_data;
44072
44073 - if (!hvcsd || hvcsd->port.count <= 0)
44074 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
44075 return 0;
44076
44077 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
44078 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
44079 index 2cde13d..645d78f 100644
44080 --- a/drivers/tty/ipwireless/tty.c
44081 +++ b/drivers/tty/ipwireless/tty.c
44082 @@ -29,6 +29,7 @@
44083 #include <linux/tty_driver.h>
44084 #include <linux/tty_flip.h>
44085 #include <linux/uaccess.h>
44086 +#include <asm/local.h>
44087
44088 #include "tty.h"
44089 #include "network.h"
44090 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
44091 mutex_unlock(&tty->ipw_tty_mutex);
44092 return -ENODEV;
44093 }
44094 - if (tty->port.count == 0)
44095 + if (atomic_read(&tty->port.count) == 0)
44096 tty->tx_bytes_queued = 0;
44097
44098 - tty->port.count++;
44099 + atomic_inc(&tty->port.count);
44100
44101 tty->port.tty = linux_tty;
44102 linux_tty->driver_data = tty;
44103 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
44104
44105 static void do_ipw_close(struct ipw_tty *tty)
44106 {
44107 - tty->port.count--;
44108 -
44109 - if (tty->port.count == 0) {
44110 + if (atomic_dec_return(&tty->port.count) == 0) {
44111 struct tty_struct *linux_tty = tty->port.tty;
44112
44113 if (linux_tty != NULL) {
44114 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
44115 return;
44116
44117 mutex_lock(&tty->ipw_tty_mutex);
44118 - if (tty->port.count == 0) {
44119 + if (atomic_read(&tty->port.count) == 0) {
44120 mutex_unlock(&tty->ipw_tty_mutex);
44121 return;
44122 }
44123 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
44124 return;
44125 }
44126
44127 - if (!tty->port.count) {
44128 + if (!atomic_read(&tty->port.count)) {
44129 mutex_unlock(&tty->ipw_tty_mutex);
44130 return;
44131 }
44132 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
44133 return -ENODEV;
44134
44135 mutex_lock(&tty->ipw_tty_mutex);
44136 - if (!tty->port.count) {
44137 + if (!atomic_read(&tty->port.count)) {
44138 mutex_unlock(&tty->ipw_tty_mutex);
44139 return -EINVAL;
44140 }
44141 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
44142 if (!tty)
44143 return -ENODEV;
44144
44145 - if (!tty->port.count)
44146 + if (!atomic_read(&tty->port.count))
44147 return -EINVAL;
44148
44149 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
44150 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
44151 if (!tty)
44152 return 0;
44153
44154 - if (!tty->port.count)
44155 + if (!atomic_read(&tty->port.count))
44156 return 0;
44157
44158 return tty->tx_bytes_queued;
44159 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
44160 if (!tty)
44161 return -ENODEV;
44162
44163 - if (!tty->port.count)
44164 + if (!atomic_read(&tty->port.count))
44165 return -EINVAL;
44166
44167 return get_control_lines(tty);
44168 @@ -391,7 +390,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
44169 if (!tty)
44170 return -ENODEV;
44171
44172 - if (!tty->port.count)
44173 + if (!atomic_read(&tty->port.count))
44174 return -EINVAL;
44175
44176 return set_control_lines(tty, set, clear);
44177 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
44178 if (!tty)
44179 return -ENODEV;
44180
44181 - if (!tty->port.count)
44182 + if (!atomic_read(&tty->port.count))
44183 return -EINVAL;
44184
44185 /* FIXME: Exactly how is the tty object locked here .. */
44186 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
44187 * are gone */
44188 mutex_lock(&ttyj->ipw_tty_mutex);
44189 }
44190 - while (ttyj->port.count)
44191 + while (atomic_read(&ttyj->port.count))
44192 do_ipw_close(ttyj);
44193 ipwireless_disassociate_network_ttys(network,
44194 ttyj->channel_idx);
44195 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
44196 index f9d2850..b006f04 100644
44197 --- a/drivers/tty/moxa.c
44198 +++ b/drivers/tty/moxa.c
44199 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
44200 }
44201
44202 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
44203 - ch->port.count++;
44204 + atomic_inc(&ch->port.count);
44205 tty->driver_data = ch;
44206 tty_port_tty_set(&ch->port, tty);
44207 mutex_lock(&ch->port.mutex);
44208 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
44209 index bfd6771..e0d93c4 100644
44210 --- a/drivers/tty/n_gsm.c
44211 +++ b/drivers/tty/n_gsm.c
44212 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
44213 spin_lock_init(&dlci->lock);
44214 mutex_init(&dlci->mutex);
44215 dlci->fifo = &dlci->_fifo;
44216 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
44217 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
44218 kfree(dlci);
44219 return NULL;
44220 }
44221 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
44222 struct gsm_dlci *dlci = tty->driver_data;
44223 struct tty_port *port = &dlci->port;
44224
44225 - port->count++;
44226 + atomic_inc(&port->count);
44227 dlci_get(dlci);
44228 dlci_get(dlci->gsm->dlci[0]);
44229 mux_get(dlci->gsm);
44230 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
44231 index 19083ef..6e34e97 100644
44232 --- a/drivers/tty/n_tty.c
44233 +++ b/drivers/tty/n_tty.c
44234 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
44235 {
44236 *ops = tty_ldisc_N_TTY;
44237 ops->owner = NULL;
44238 - ops->refcount = ops->flags = 0;
44239 + atomic_set(&ops->refcount, 0);
44240 + ops->flags = 0;
44241 }
44242 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
44243 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
44244 index ac35c90..c47deac 100644
44245 --- a/drivers/tty/pty.c
44246 +++ b/drivers/tty/pty.c
44247 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
44248 panic("Couldn't register Unix98 pts driver");
44249
44250 /* Now create the /dev/ptmx special device */
44251 + pax_open_kernel();
44252 tty_default_fops(&ptmx_fops);
44253 - ptmx_fops.open = ptmx_open;
44254 + *(void **)&ptmx_fops.open = ptmx_open;
44255 + pax_close_kernel();
44256
44257 cdev_init(&ptmx_cdev, &ptmx_fops);
44258 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
44259 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
44260 index e42009a..566a036 100644
44261 --- a/drivers/tty/rocket.c
44262 +++ b/drivers/tty/rocket.c
44263 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
44264 tty->driver_data = info;
44265 tty_port_tty_set(port, tty);
44266
44267 - if (port->count++ == 0) {
44268 + if (atomic_inc_return(&port->count) == 1) {
44269 atomic_inc(&rp_num_ports_open);
44270
44271 #ifdef ROCKET_DEBUG_OPEN
44272 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
44273 #endif
44274 }
44275 #ifdef ROCKET_DEBUG_OPEN
44276 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
44277 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
44278 #endif
44279
44280 /*
44281 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
44282 spin_unlock_irqrestore(&info->port.lock, flags);
44283 return;
44284 }
44285 - if (info->port.count)
44286 + if (atomic_read(&info->port.count))
44287 atomic_dec(&rp_num_ports_open);
44288 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
44289 spin_unlock_irqrestore(&info->port.lock, flags);
44290 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
44291 index 1002054..dd644a8 100644
44292 --- a/drivers/tty/serial/kgdboc.c
44293 +++ b/drivers/tty/serial/kgdboc.c
44294 @@ -24,8 +24,9 @@
44295 #define MAX_CONFIG_LEN 40
44296
44297 static struct kgdb_io kgdboc_io_ops;
44298 +static struct kgdb_io kgdboc_io_ops_console;
44299
44300 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
44301 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
44302 static int configured = -1;
44303
44304 static char config[MAX_CONFIG_LEN];
44305 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
44306 kgdboc_unregister_kbd();
44307 if (configured == 1)
44308 kgdb_unregister_io_module(&kgdboc_io_ops);
44309 + else if (configured == 2)
44310 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
44311 }
44312
44313 static int configure_kgdboc(void)
44314 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
44315 int err;
44316 char *cptr = config;
44317 struct console *cons;
44318 + int is_console = 0;
44319
44320 err = kgdboc_option_setup(config);
44321 if (err || !strlen(config) || isspace(config[0]))
44322 goto noconfig;
44323
44324 err = -ENODEV;
44325 - kgdboc_io_ops.is_console = 0;
44326 kgdb_tty_driver = NULL;
44327
44328 kgdboc_use_kms = 0;
44329 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
44330 int idx;
44331 if (cons->device && cons->device(cons, &idx) == p &&
44332 idx == tty_line) {
44333 - kgdboc_io_ops.is_console = 1;
44334 + is_console = 1;
44335 break;
44336 }
44337 cons = cons->next;
44338 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
44339 kgdb_tty_line = tty_line;
44340
44341 do_register:
44342 - err = kgdb_register_io_module(&kgdboc_io_ops);
44343 + if (is_console) {
44344 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
44345 + configured = 2;
44346 + } else {
44347 + err = kgdb_register_io_module(&kgdboc_io_ops);
44348 + configured = 1;
44349 + }
44350 if (err)
44351 goto noconfig;
44352
44353 @@ -205,8 +214,6 @@ do_register:
44354 if (err)
44355 goto nmi_con_failed;
44356
44357 - configured = 1;
44358 -
44359 return 0;
44360
44361 nmi_con_failed:
44362 @@ -223,7 +230,7 @@ noconfig:
44363 static int __init init_kgdboc(void)
44364 {
44365 /* Already configured? */
44366 - if (configured == 1)
44367 + if (configured >= 1)
44368 return 0;
44369
44370 return configure_kgdboc();
44371 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
44372 if (config[len - 1] == '\n')
44373 config[len - 1] = '\0';
44374
44375 - if (configured == 1)
44376 + if (configured >= 1)
44377 cleanup_kgdboc();
44378
44379 /* Go and configure with the new params. */
44380 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
44381 .post_exception = kgdboc_post_exp_handler,
44382 };
44383
44384 +static struct kgdb_io kgdboc_io_ops_console = {
44385 + .name = "kgdboc",
44386 + .read_char = kgdboc_get_char,
44387 + .write_char = kgdboc_put_char,
44388 + .pre_exception = kgdboc_pre_exp_handler,
44389 + .post_exception = kgdboc_post_exp_handler,
44390 + .is_console = 1
44391 +};
44392 +
44393 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
44394 /* This is only available if kgdboc is a built in for early debugging */
44395 static int __init kgdboc_early_init(char *opt)
44396 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
44397 index e514b3a..c73d614 100644
44398 --- a/drivers/tty/serial/samsung.c
44399 +++ b/drivers/tty/serial/samsung.c
44400 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
44401 }
44402 }
44403
44404 +static int s3c64xx_serial_startup(struct uart_port *port);
44405 static int s3c24xx_serial_startup(struct uart_port *port)
44406 {
44407 struct s3c24xx_uart_port *ourport = to_ourport(port);
44408 int ret;
44409
44410 + /* Startup sequence is different for s3c64xx and higher SoC's */
44411 + if (s3c24xx_serial_has_interrupt_mask(port))
44412 + return s3c64xx_serial_startup(port);
44413 +
44414 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
44415 port->mapbase, port->membase);
44416
44417 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
44418 /* setup info for port */
44419 port->dev = &platdev->dev;
44420
44421 - /* Startup sequence is different for s3c64xx and higher SoC's */
44422 - if (s3c24xx_serial_has_interrupt_mask(port))
44423 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
44424 -
44425 port->uartclk = 1;
44426
44427 if (cfg->uart_flags & UPF_CONS_FLOW) {
44428 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
44429 index 2c7230a..2104f16 100644
44430 --- a/drivers/tty/serial/serial_core.c
44431 +++ b/drivers/tty/serial/serial_core.c
44432 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
44433 uart_flush_buffer(tty);
44434 uart_shutdown(tty, state);
44435 spin_lock_irqsave(&port->lock, flags);
44436 - port->count = 0;
44437 + atomic_set(&port->count, 0);
44438 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
44439 spin_unlock_irqrestore(&port->lock, flags);
44440 tty_port_tty_set(port, NULL);
44441 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
44442 goto end;
44443 }
44444
44445 - port->count++;
44446 + atomic_inc(&port->count);
44447 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
44448 retval = -ENXIO;
44449 goto err_dec_count;
44450 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
44451 /*
44452 * Make sure the device is in D0 state.
44453 */
44454 - if (port->count == 1)
44455 + if (atomic_read(&port->count) == 1)
44456 uart_change_pm(state, 0);
44457
44458 /*
44459 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
44460 end:
44461 return retval;
44462 err_dec_count:
44463 - port->count--;
44464 + atomic_inc(&port->count);
44465 mutex_unlock(&port->mutex);
44466 goto end;
44467 }
44468 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
44469 index 9e071f6..f30ae69 100644
44470 --- a/drivers/tty/synclink.c
44471 +++ b/drivers/tty/synclink.c
44472 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
44473
44474 if (debug_level >= DEBUG_LEVEL_INFO)
44475 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
44476 - __FILE__,__LINE__, info->device_name, info->port.count);
44477 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44478
44479 if (tty_port_close_start(&info->port, tty, filp) == 0)
44480 goto cleanup;
44481 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
44482 cleanup:
44483 if (debug_level >= DEBUG_LEVEL_INFO)
44484 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
44485 - tty->driver->name, info->port.count);
44486 + tty->driver->name, atomic_read(&info->port.count));
44487
44488 } /* end of mgsl_close() */
44489
44490 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
44491
44492 mgsl_flush_buffer(tty);
44493 shutdown(info);
44494 -
44495 - info->port.count = 0;
44496 +
44497 + atomic_set(&info->port.count, 0);
44498 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44499 info->port.tty = NULL;
44500
44501 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44502
44503 if (debug_level >= DEBUG_LEVEL_INFO)
44504 printk("%s(%d):block_til_ready before block on %s count=%d\n",
44505 - __FILE__,__LINE__, tty->driver->name, port->count );
44506 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44507
44508 spin_lock_irqsave(&info->irq_spinlock, flags);
44509 if (!tty_hung_up_p(filp)) {
44510 extra_count = true;
44511 - port->count--;
44512 + atomic_dec(&port->count);
44513 }
44514 spin_unlock_irqrestore(&info->irq_spinlock, flags);
44515 port->blocked_open++;
44516 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44517
44518 if (debug_level >= DEBUG_LEVEL_INFO)
44519 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
44520 - __FILE__,__LINE__, tty->driver->name, port->count );
44521 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44522
44523 tty_unlock(tty);
44524 schedule();
44525 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44526
44527 /* FIXME: Racy on hangup during close wait */
44528 if (extra_count)
44529 - port->count++;
44530 + atomic_inc(&port->count);
44531 port->blocked_open--;
44532
44533 if (debug_level >= DEBUG_LEVEL_INFO)
44534 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
44535 - __FILE__,__LINE__, tty->driver->name, port->count );
44536 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44537
44538 if (!retval)
44539 port->flags |= ASYNC_NORMAL_ACTIVE;
44540 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44541
44542 if (debug_level >= DEBUG_LEVEL_INFO)
44543 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
44544 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44545 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44546
44547 /* If port is closing, signal caller to try again */
44548 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44549 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44550 spin_unlock_irqrestore(&info->netlock, flags);
44551 goto cleanup;
44552 }
44553 - info->port.count++;
44554 + atomic_inc(&info->port.count);
44555 spin_unlock_irqrestore(&info->netlock, flags);
44556
44557 - if (info->port.count == 1) {
44558 + if (atomic_read(&info->port.count) == 1) {
44559 /* 1st open on this device, init hardware */
44560 retval = startup(info);
44561 if (retval < 0)
44562 @@ -3451,8 +3451,8 @@ cleanup:
44563 if (retval) {
44564 if (tty->count == 1)
44565 info->port.tty = NULL; /* tty layer will release tty struct */
44566 - if(info->port.count)
44567 - info->port.count--;
44568 + if (atomic_read(&info->port.count))
44569 + atomic_dec(&info->port.count);
44570 }
44571
44572 return retval;
44573 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44574 unsigned short new_crctype;
44575
44576 /* return error if TTY interface open */
44577 - if (info->port.count)
44578 + if (atomic_read(&info->port.count))
44579 return -EBUSY;
44580
44581 switch (encoding)
44582 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
44583
44584 /* arbitrate between network and tty opens */
44585 spin_lock_irqsave(&info->netlock, flags);
44586 - if (info->port.count != 0 || info->netcount != 0) {
44587 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44588 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44589 spin_unlock_irqrestore(&info->netlock, flags);
44590 return -EBUSY;
44591 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44592 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44593
44594 /* return error if TTY interface open */
44595 - if (info->port.count)
44596 + if (atomic_read(&info->port.count))
44597 return -EBUSY;
44598
44599 if (cmd != SIOCWANDEV)
44600 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44601 index aba1e59..877ac33 100644
44602 --- a/drivers/tty/synclink_gt.c
44603 +++ b/drivers/tty/synclink_gt.c
44604 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44605 tty->driver_data = info;
44606 info->port.tty = tty;
44607
44608 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44609 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44610
44611 /* If port is closing, signal caller to try again */
44612 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44613 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44614 mutex_unlock(&info->port.mutex);
44615 goto cleanup;
44616 }
44617 - info->port.count++;
44618 + atomic_inc(&info->port.count);
44619 spin_unlock_irqrestore(&info->netlock, flags);
44620
44621 - if (info->port.count == 1) {
44622 + if (atomic_read(&info->port.count) == 1) {
44623 /* 1st open on this device, init hardware */
44624 retval = startup(info);
44625 if (retval < 0) {
44626 @@ -716,8 +716,8 @@ cleanup:
44627 if (retval) {
44628 if (tty->count == 1)
44629 info->port.tty = NULL; /* tty layer will release tty struct */
44630 - if(info->port.count)
44631 - info->port.count--;
44632 + if(atomic_read(&info->port.count))
44633 + atomic_dec(&info->port.count);
44634 }
44635
44636 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44637 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44638
44639 if (sanity_check(info, tty->name, "close"))
44640 return;
44641 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44642 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44643
44644 if (tty_port_close_start(&info->port, tty, filp) == 0)
44645 goto cleanup;
44646 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44647 tty_port_close_end(&info->port, tty);
44648 info->port.tty = NULL;
44649 cleanup:
44650 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44651 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44652 }
44653
44654 static void hangup(struct tty_struct *tty)
44655 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
44656 shutdown(info);
44657
44658 spin_lock_irqsave(&info->port.lock, flags);
44659 - info->port.count = 0;
44660 + atomic_set(&info->port.count, 0);
44661 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44662 info->port.tty = NULL;
44663 spin_unlock_irqrestore(&info->port.lock, flags);
44664 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44665 unsigned short new_crctype;
44666
44667 /* return error if TTY interface open */
44668 - if (info->port.count)
44669 + if (atomic_read(&info->port.count))
44670 return -EBUSY;
44671
44672 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44673 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
44674
44675 /* arbitrate between network and tty opens */
44676 spin_lock_irqsave(&info->netlock, flags);
44677 - if (info->port.count != 0 || info->netcount != 0) {
44678 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44679 DBGINFO(("%s hdlc_open busy\n", dev->name));
44680 spin_unlock_irqrestore(&info->netlock, flags);
44681 return -EBUSY;
44682 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44683 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44684
44685 /* return error if TTY interface open */
44686 - if (info->port.count)
44687 + if (atomic_read(&info->port.count))
44688 return -EBUSY;
44689
44690 if (cmd != SIOCWANDEV)
44691 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44692 if (port == NULL)
44693 continue;
44694 spin_lock(&port->lock);
44695 - if ((port->port.count || port->netcount) &&
44696 + if ((atomic_read(&port->port.count) || port->netcount) &&
44697 port->pending_bh && !port->bh_running &&
44698 !port->bh_requested) {
44699 DBGISR(("%s bh queued\n", port->device_name));
44700 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44701 spin_lock_irqsave(&info->lock, flags);
44702 if (!tty_hung_up_p(filp)) {
44703 extra_count = true;
44704 - port->count--;
44705 + atomic_dec(&port->count);
44706 }
44707 spin_unlock_irqrestore(&info->lock, flags);
44708 port->blocked_open++;
44709 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44710 remove_wait_queue(&port->open_wait, &wait);
44711
44712 if (extra_count)
44713 - port->count++;
44714 + atomic_inc(&port->count);
44715 port->blocked_open--;
44716
44717 if (!retval)
44718 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44719 index fd43fb6..34704ad 100644
44720 --- a/drivers/tty/synclinkmp.c
44721 +++ b/drivers/tty/synclinkmp.c
44722 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44723
44724 if (debug_level >= DEBUG_LEVEL_INFO)
44725 printk("%s(%d):%s open(), old ref count = %d\n",
44726 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44727 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44728
44729 /* If port is closing, signal caller to try again */
44730 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44731 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44732 spin_unlock_irqrestore(&info->netlock, flags);
44733 goto cleanup;
44734 }
44735 - info->port.count++;
44736 + atomic_inc(&info->port.count);
44737 spin_unlock_irqrestore(&info->netlock, flags);
44738
44739 - if (info->port.count == 1) {
44740 + if (atomic_read(&info->port.count) == 1) {
44741 /* 1st open on this device, init hardware */
44742 retval = startup(info);
44743 if (retval < 0)
44744 @@ -797,8 +797,8 @@ cleanup:
44745 if (retval) {
44746 if (tty->count == 1)
44747 info->port.tty = NULL; /* tty layer will release tty struct */
44748 - if(info->port.count)
44749 - info->port.count--;
44750 + if(atomic_read(&info->port.count))
44751 + atomic_dec(&info->port.count);
44752 }
44753
44754 return retval;
44755 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44756
44757 if (debug_level >= DEBUG_LEVEL_INFO)
44758 printk("%s(%d):%s close() entry, count=%d\n",
44759 - __FILE__,__LINE__, info->device_name, info->port.count);
44760 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44761
44762 if (tty_port_close_start(&info->port, tty, filp) == 0)
44763 goto cleanup;
44764 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44765 cleanup:
44766 if (debug_level >= DEBUG_LEVEL_INFO)
44767 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44768 - tty->driver->name, info->port.count);
44769 + tty->driver->name, atomic_read(&info->port.count));
44770 }
44771
44772 /* Called by tty_hangup() when a hangup is signaled.
44773 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
44774 shutdown(info);
44775
44776 spin_lock_irqsave(&info->port.lock, flags);
44777 - info->port.count = 0;
44778 + atomic_set(&info->port.count, 0);
44779 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44780 info->port.tty = NULL;
44781 spin_unlock_irqrestore(&info->port.lock, flags);
44782 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44783 unsigned short new_crctype;
44784
44785 /* return error if TTY interface open */
44786 - if (info->port.count)
44787 + if (atomic_read(&info->port.count))
44788 return -EBUSY;
44789
44790 switch (encoding)
44791 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
44792
44793 /* arbitrate between network and tty opens */
44794 spin_lock_irqsave(&info->netlock, flags);
44795 - if (info->port.count != 0 || info->netcount != 0) {
44796 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44797 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44798 spin_unlock_irqrestore(&info->netlock, flags);
44799 return -EBUSY;
44800 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44801 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44802
44803 /* return error if TTY interface open */
44804 - if (info->port.count)
44805 + if (atomic_read(&info->port.count))
44806 return -EBUSY;
44807
44808 if (cmd != SIOCWANDEV)
44809 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44810 * do not request bottom half processing if the
44811 * device is not open in a normal mode.
44812 */
44813 - if ( port && (port->port.count || port->netcount) &&
44814 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44815 port->pending_bh && !port->bh_running &&
44816 !port->bh_requested ) {
44817 if ( debug_level >= DEBUG_LEVEL_ISR )
44818 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44819
44820 if (debug_level >= DEBUG_LEVEL_INFO)
44821 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44822 - __FILE__,__LINE__, tty->driver->name, port->count );
44823 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44824
44825 spin_lock_irqsave(&info->lock, flags);
44826 if (!tty_hung_up_p(filp)) {
44827 extra_count = true;
44828 - port->count--;
44829 + atomic_dec(&port->count);
44830 }
44831 spin_unlock_irqrestore(&info->lock, flags);
44832 port->blocked_open++;
44833 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44834
44835 if (debug_level >= DEBUG_LEVEL_INFO)
44836 printk("%s(%d):%s block_til_ready() count=%d\n",
44837 - __FILE__,__LINE__, tty->driver->name, port->count );
44838 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44839
44840 tty_unlock(tty);
44841 schedule();
44842 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44843 remove_wait_queue(&port->open_wait, &wait);
44844
44845 if (extra_count)
44846 - port->count++;
44847 + atomic_inc(&port->count);
44848 port->blocked_open--;
44849
44850 if (debug_level >= DEBUG_LEVEL_INFO)
44851 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44852 - __FILE__,__LINE__, tty->driver->name, port->count );
44853 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44854
44855 if (!retval)
44856 port->flags |= ASYNC_NORMAL_ACTIVE;
44857 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44858 index b3c4a25..723916f 100644
44859 --- a/drivers/tty/sysrq.c
44860 +++ b/drivers/tty/sysrq.c
44861 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44862 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44863 size_t count, loff_t *ppos)
44864 {
44865 - if (count) {
44866 + if (count && capable(CAP_SYS_ADMIN)) {
44867 char c;
44868
44869 if (get_user(c, buf))
44870 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44871 index da9fde8..621d6dc 100644
44872 --- a/drivers/tty/tty_io.c
44873 +++ b/drivers/tty/tty_io.c
44874 @@ -941,6 +941,14 @@ void start_tty(struct tty_struct *tty)
44875
44876 EXPORT_SYMBOL(start_tty);
44877
44878 +static void tty_update_time(struct timespec *time)
44879 +{
44880 + unsigned long sec = get_seconds();
44881 + sec -= sec % 60;
44882 + if ((long)(sec - time->tv_sec) > 0)
44883 + time->tv_sec = sec;
44884 +}
44885 +
44886 /**
44887 * tty_read - read method for tty device files
44888 * @file: pointer to tty file
44889 @@ -977,8 +985,10 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
44890 else
44891 i = -EIO;
44892 tty_ldisc_deref(ld);
44893 +
44894 if (i > 0)
44895 - inode->i_atime = current_fs_time(inode->i_sb);
44896 + tty_update_time(&inode->i_atime);
44897 +
44898 return i;
44899 }
44900
44901 @@ -1080,8 +1090,7 @@ static inline ssize_t do_tty_write(
44902 cond_resched();
44903 }
44904 if (written) {
44905 - struct inode *inode = file->f_path.dentry->d_inode;
44906 - inode->i_mtime = current_fs_time(inode->i_sb);
44907 + tty_update_time(&file->f_path.dentry->d_inode->i_mtime);
44908 ret = written;
44909 }
44910 out:
44911 @@ -3391,7 +3400,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44912
44913 void tty_default_fops(struct file_operations *fops)
44914 {
44915 - *fops = tty_fops;
44916 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44917 }
44918
44919 /*
44920 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44921 index 78f1be2..3e98910 100644
44922 --- a/drivers/tty/tty_ldisc.c
44923 +++ b/drivers/tty/tty_ldisc.c
44924 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
44925 if (atomic_dec_and_test(&ld->users)) {
44926 struct tty_ldisc_ops *ldo = ld->ops;
44927
44928 - ldo->refcount--;
44929 + atomic_dec(&ldo->refcount);
44930 module_put(ldo->owner);
44931 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44932
44933 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44934 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44935 tty_ldiscs[disc] = new_ldisc;
44936 new_ldisc->num = disc;
44937 - new_ldisc->refcount = 0;
44938 + atomic_set(&new_ldisc->refcount, 0);
44939 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44940
44941 return ret;
44942 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
44943 return -EINVAL;
44944
44945 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44946 - if (tty_ldiscs[disc]->refcount)
44947 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44948 ret = -EBUSY;
44949 else
44950 tty_ldiscs[disc] = NULL;
44951 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44952 if (ldops) {
44953 ret = ERR_PTR(-EAGAIN);
44954 if (try_module_get(ldops->owner)) {
44955 - ldops->refcount++;
44956 + atomic_inc(&ldops->refcount);
44957 ret = ldops;
44958 }
44959 }
44960 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44961 unsigned long flags;
44962
44963 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44964 - ldops->refcount--;
44965 + atomic_dec(&ldops->refcount);
44966 module_put(ldops->owner);
44967 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44968 }
44969 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44970 index b7ff59d..7c6105e 100644
44971 --- a/drivers/tty/tty_port.c
44972 +++ b/drivers/tty/tty_port.c
44973 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44974 unsigned long flags;
44975
44976 spin_lock_irqsave(&port->lock, flags);
44977 - port->count = 0;
44978 + atomic_set(&port->count, 0);
44979 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44980 if (port->tty) {
44981 set_bit(TTY_IO_ERROR, &port->tty->flags);
44982 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44983 /* The port lock protects the port counts */
44984 spin_lock_irqsave(&port->lock, flags);
44985 if (!tty_hung_up_p(filp))
44986 - port->count--;
44987 + atomic_dec(&port->count);
44988 port->blocked_open++;
44989 spin_unlock_irqrestore(&port->lock, flags);
44990
44991 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44992 we must not mess that up further */
44993 spin_lock_irqsave(&port->lock, flags);
44994 if (!tty_hung_up_p(filp))
44995 - port->count++;
44996 + atomic_inc(&port->count);
44997 port->blocked_open--;
44998 if (retval == 0)
44999 port->flags |= ASYNC_NORMAL_ACTIVE;
45000 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
45001 return 0;
45002 }
45003
45004 - if (tty->count == 1 && port->count != 1) {
45005 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
45006 printk(KERN_WARNING
45007 "tty_port_close_start: tty->count = 1 port count = %d.\n",
45008 - port->count);
45009 - port->count = 1;
45010 + atomic_read(&port->count));
45011 + atomic_set(&port->count, 1);
45012 }
45013 - if (--port->count < 0) {
45014 + if (atomic_dec_return(&port->count) < 0) {
45015 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
45016 - port->count);
45017 - port->count = 0;
45018 + atomic_read(&port->count));
45019 + atomic_set(&port->count, 0);
45020 }
45021
45022 - if (port->count) {
45023 + if (atomic_read(&port->count)) {
45024 spin_unlock_irqrestore(&port->lock, flags);
45025 if (port->ops->drop)
45026 port->ops->drop(port);
45027 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
45028 {
45029 spin_lock_irq(&port->lock);
45030 if (!tty_hung_up_p(filp))
45031 - ++port->count;
45032 + atomic_inc(&port->count);
45033 spin_unlock_irq(&port->lock);
45034 tty_port_tty_set(port, tty);
45035
45036 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
45037 index 681765b..d3ccdf2 100644
45038 --- a/drivers/tty/vt/keyboard.c
45039 +++ b/drivers/tty/vt/keyboard.c
45040 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
45041 kbd->kbdmode == VC_OFF) &&
45042 value != KVAL(K_SAK))
45043 return; /* SAK is allowed even in raw mode */
45044 +
45045 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
45046 + {
45047 + void *func = fn_handler[value];
45048 + if (func == fn_show_state || func == fn_show_ptregs ||
45049 + func == fn_show_mem)
45050 + return;
45051 + }
45052 +#endif
45053 +
45054 fn_handler[value](vc);
45055 }
45056
45057 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
45058 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
45059 return -EFAULT;
45060
45061 - if (!capable(CAP_SYS_TTY_CONFIG))
45062 - perm = 0;
45063 -
45064 switch (cmd) {
45065 case KDGKBENT:
45066 /* Ensure another thread doesn't free it under us */
45067 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
45068 spin_unlock_irqrestore(&kbd_event_lock, flags);
45069 return put_user(val, &user_kbe->kb_value);
45070 case KDSKBENT:
45071 + if (!capable(CAP_SYS_TTY_CONFIG))
45072 + perm = 0;
45073 +
45074 if (!perm)
45075 return -EPERM;
45076 if (!i && v == K_NOSUCHMAP) {
45077 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
45078 int i, j, k;
45079 int ret;
45080
45081 - if (!capable(CAP_SYS_TTY_CONFIG))
45082 - perm = 0;
45083 -
45084 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
45085 if (!kbs) {
45086 ret = -ENOMEM;
45087 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
45088 kfree(kbs);
45089 return ((p && *p) ? -EOVERFLOW : 0);
45090 case KDSKBSENT:
45091 + if (!capable(CAP_SYS_TTY_CONFIG))
45092 + perm = 0;
45093 +
45094 if (!perm) {
45095 ret = -EPERM;
45096 goto reterr;
45097 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
45098 index 5110f36..8dc0a74 100644
45099 --- a/drivers/uio/uio.c
45100 +++ b/drivers/uio/uio.c
45101 @@ -25,6 +25,7 @@
45102 #include <linux/kobject.h>
45103 #include <linux/cdev.h>
45104 #include <linux/uio_driver.h>
45105 +#include <asm/local.h>
45106
45107 #define UIO_MAX_DEVICES (1U << MINORBITS)
45108
45109 @@ -32,10 +33,10 @@ struct uio_device {
45110 struct module *owner;
45111 struct device *dev;
45112 int minor;
45113 - atomic_t event;
45114 + atomic_unchecked_t event;
45115 struct fasync_struct *async_queue;
45116 wait_queue_head_t wait;
45117 - int vma_count;
45118 + local_t vma_count;
45119 struct uio_info *info;
45120 struct kobject *map_dir;
45121 struct kobject *portio_dir;
45122 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
45123 struct device_attribute *attr, char *buf)
45124 {
45125 struct uio_device *idev = dev_get_drvdata(dev);
45126 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
45127 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
45128 }
45129
45130 static struct device_attribute uio_class_attributes[] = {
45131 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
45132 {
45133 struct uio_device *idev = info->uio_dev;
45134
45135 - atomic_inc(&idev->event);
45136 + atomic_inc_unchecked(&idev->event);
45137 wake_up_interruptible(&idev->wait);
45138 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
45139 }
45140 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
45141 }
45142
45143 listener->dev = idev;
45144 - listener->event_count = atomic_read(&idev->event);
45145 + listener->event_count = atomic_read_unchecked(&idev->event);
45146 filep->private_data = listener;
45147
45148 if (idev->info->open) {
45149 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
45150 return -EIO;
45151
45152 poll_wait(filep, &idev->wait, wait);
45153 - if (listener->event_count != atomic_read(&idev->event))
45154 + if (listener->event_count != atomic_read_unchecked(&idev->event))
45155 return POLLIN | POLLRDNORM;
45156 return 0;
45157 }
45158 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
45159 do {
45160 set_current_state(TASK_INTERRUPTIBLE);
45161
45162 - event_count = atomic_read(&idev->event);
45163 + event_count = atomic_read_unchecked(&idev->event);
45164 if (event_count != listener->event_count) {
45165 if (copy_to_user(buf, &event_count, count))
45166 retval = -EFAULT;
45167 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
45168 static void uio_vma_open(struct vm_area_struct *vma)
45169 {
45170 struct uio_device *idev = vma->vm_private_data;
45171 - idev->vma_count++;
45172 + local_inc(&idev->vma_count);
45173 }
45174
45175 static void uio_vma_close(struct vm_area_struct *vma)
45176 {
45177 struct uio_device *idev = vma->vm_private_data;
45178 - idev->vma_count--;
45179 + local_dec(&idev->vma_count);
45180 }
45181
45182 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
45183 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
45184 idev->owner = owner;
45185 idev->info = info;
45186 init_waitqueue_head(&idev->wait);
45187 - atomic_set(&idev->event, 0);
45188 + atomic_set_unchecked(&idev->event, 0);
45189
45190 ret = uio_get_minor(idev);
45191 if (ret)
45192 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
45193 index b7eb86a..36d28af 100644
45194 --- a/drivers/usb/atm/cxacru.c
45195 +++ b/drivers/usb/atm/cxacru.c
45196 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
45197 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
45198 if (ret < 2)
45199 return -EINVAL;
45200 - if (index < 0 || index > 0x7f)
45201 + if (index > 0x7f)
45202 return -EINVAL;
45203 pos += tmp;
45204
45205 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
45206 index 35f10bf..6a38a0b 100644
45207 --- a/drivers/usb/atm/usbatm.c
45208 +++ b/drivers/usb/atm/usbatm.c
45209 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
45210 if (printk_ratelimit())
45211 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
45212 __func__, vpi, vci);
45213 - atomic_inc(&vcc->stats->rx_err);
45214 + atomic_inc_unchecked(&vcc->stats->rx_err);
45215 return;
45216 }
45217
45218 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
45219 if (length > ATM_MAX_AAL5_PDU) {
45220 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
45221 __func__, length, vcc);
45222 - atomic_inc(&vcc->stats->rx_err);
45223 + atomic_inc_unchecked(&vcc->stats->rx_err);
45224 goto out;
45225 }
45226
45227 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
45228 if (sarb->len < pdu_length) {
45229 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
45230 __func__, pdu_length, sarb->len, vcc);
45231 - atomic_inc(&vcc->stats->rx_err);
45232 + atomic_inc_unchecked(&vcc->stats->rx_err);
45233 goto out;
45234 }
45235
45236 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
45237 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
45238 __func__, vcc);
45239 - atomic_inc(&vcc->stats->rx_err);
45240 + atomic_inc_unchecked(&vcc->stats->rx_err);
45241 goto out;
45242 }
45243
45244 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
45245 if (printk_ratelimit())
45246 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
45247 __func__, length);
45248 - atomic_inc(&vcc->stats->rx_drop);
45249 + atomic_inc_unchecked(&vcc->stats->rx_drop);
45250 goto out;
45251 }
45252
45253 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
45254
45255 vcc->push(vcc, skb);
45256
45257 - atomic_inc(&vcc->stats->rx);
45258 + atomic_inc_unchecked(&vcc->stats->rx);
45259 out:
45260 skb_trim(sarb, 0);
45261 }
45262 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
45263 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
45264
45265 usbatm_pop(vcc, skb);
45266 - atomic_inc(&vcc->stats->tx);
45267 + atomic_inc_unchecked(&vcc->stats->tx);
45268
45269 skb = skb_dequeue(&instance->sndqueue);
45270 }
45271 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
45272 if (!left--)
45273 return sprintf(page,
45274 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
45275 - atomic_read(&atm_dev->stats.aal5.tx),
45276 - atomic_read(&atm_dev->stats.aal5.tx_err),
45277 - atomic_read(&atm_dev->stats.aal5.rx),
45278 - atomic_read(&atm_dev->stats.aal5.rx_err),
45279 - atomic_read(&atm_dev->stats.aal5.rx_drop));
45280 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
45281 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
45282 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
45283 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
45284 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
45285
45286 if (!left--) {
45287 if (instance->disconnected)
45288 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
45289 index cbacea9..246cccd 100644
45290 --- a/drivers/usb/core/devices.c
45291 +++ b/drivers/usb/core/devices.c
45292 @@ -126,7 +126,7 @@ static const char format_endpt[] =
45293 * time it gets called.
45294 */
45295 static struct device_connect_event {
45296 - atomic_t count;
45297 + atomic_unchecked_t count;
45298 wait_queue_head_t wait;
45299 } device_event = {
45300 .count = ATOMIC_INIT(1),
45301 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
45302
45303 void usbfs_conn_disc_event(void)
45304 {
45305 - atomic_add(2, &device_event.count);
45306 + atomic_add_unchecked(2, &device_event.count);
45307 wake_up(&device_event.wait);
45308 }
45309
45310 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
45311
45312 poll_wait(file, &device_event.wait, wait);
45313
45314 - event_count = atomic_read(&device_event.count);
45315 + event_count = atomic_read_unchecked(&device_event.count);
45316 if (file->f_version != event_count) {
45317 file->f_version = event_count;
45318 return POLLIN | POLLRDNORM;
45319 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
45320 index 8e64adf..9a33a3c 100644
45321 --- a/drivers/usb/core/hcd.c
45322 +++ b/drivers/usb/core/hcd.c
45323 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
45324 */
45325 usb_get_urb(urb);
45326 atomic_inc(&urb->use_count);
45327 - atomic_inc(&urb->dev->urbnum);
45328 + atomic_inc_unchecked(&urb->dev->urbnum);
45329 usbmon_urb_submit(&hcd->self, urb);
45330
45331 /* NOTE requirements on root-hub callers (usbfs and the hub
45332 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
45333 urb->hcpriv = NULL;
45334 INIT_LIST_HEAD(&urb->urb_list);
45335 atomic_dec(&urb->use_count);
45336 - atomic_dec(&urb->dev->urbnum);
45337 + atomic_dec_unchecked(&urb->dev->urbnum);
45338 if (atomic_read(&urb->reject))
45339 wake_up(&usb_kill_urb_queue);
45340 usb_put_urb(urb);
45341 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
45342 index 131f736..99004c3 100644
45343 --- a/drivers/usb/core/message.c
45344 +++ b/drivers/usb/core/message.c
45345 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
45346 * method can wait for it to complete. Since you don't have a handle on the
45347 * URB used, you can't cancel the request.
45348 */
45349 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
45350 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
45351 __u8 requesttype, __u16 value, __u16 index, void *data,
45352 __u16 size, int timeout)
45353 {
45354 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
45355 index 818e4a0..0fc9589 100644
45356 --- a/drivers/usb/core/sysfs.c
45357 +++ b/drivers/usb/core/sysfs.c
45358 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
45359 struct usb_device *udev;
45360
45361 udev = to_usb_device(dev);
45362 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
45363 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
45364 }
45365 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
45366
45367 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
45368 index f81b925..78d22ec 100644
45369 --- a/drivers/usb/core/usb.c
45370 +++ b/drivers/usb/core/usb.c
45371 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
45372 set_dev_node(&dev->dev, dev_to_node(bus->controller));
45373 dev->state = USB_STATE_ATTACHED;
45374 dev->lpm_disable_count = 1;
45375 - atomic_set(&dev->urbnum, 0);
45376 + atomic_set_unchecked(&dev->urbnum, 0);
45377
45378 INIT_LIST_HEAD(&dev->ep0.urb_list);
45379 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
45380 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
45381 index 5e29dde..eca992f 100644
45382 --- a/drivers/usb/early/ehci-dbgp.c
45383 +++ b/drivers/usb/early/ehci-dbgp.c
45384 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
45385
45386 #ifdef CONFIG_KGDB
45387 static struct kgdb_io kgdbdbgp_io_ops;
45388 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
45389 +static struct kgdb_io kgdbdbgp_io_ops_console;
45390 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
45391 #else
45392 #define dbgp_kgdb_mode (0)
45393 #endif
45394 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
45395 .write_char = kgdbdbgp_write_char,
45396 };
45397
45398 +static struct kgdb_io kgdbdbgp_io_ops_console = {
45399 + .name = "kgdbdbgp",
45400 + .read_char = kgdbdbgp_read_char,
45401 + .write_char = kgdbdbgp_write_char,
45402 + .is_console = 1
45403 +};
45404 +
45405 static int kgdbdbgp_wait_time;
45406
45407 static int __init kgdbdbgp_parse_config(char *str)
45408 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
45409 ptr++;
45410 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
45411 }
45412 - kgdb_register_io_module(&kgdbdbgp_io_ops);
45413 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
45414 + if (early_dbgp_console.index != -1)
45415 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
45416 + else
45417 + kgdb_register_io_module(&kgdbdbgp_io_ops);
45418
45419 return 0;
45420 }
45421 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
45422 index 598dcc1..032dd4f 100644
45423 --- a/drivers/usb/gadget/u_serial.c
45424 +++ b/drivers/usb/gadget/u_serial.c
45425 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
45426 spin_lock_irq(&port->port_lock);
45427
45428 /* already open? Great. */
45429 - if (port->port.count) {
45430 + if (atomic_read(&port->port.count)) {
45431 status = 0;
45432 - port->port.count++;
45433 + atomic_inc(&port->port.count);
45434
45435 /* currently opening/closing? wait ... */
45436 } else if (port->openclose) {
45437 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
45438 tty->driver_data = port;
45439 port->port.tty = tty;
45440
45441 - port->port.count = 1;
45442 + atomic_set(&port->port.count, 1);
45443 port->openclose = false;
45444
45445 /* if connected, start the I/O stream */
45446 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
45447
45448 spin_lock_irq(&port->port_lock);
45449
45450 - if (port->port.count != 1) {
45451 - if (port->port.count == 0)
45452 + if (atomic_read(&port->port.count) != 1) {
45453 + if (atomic_read(&port->port.count) == 0)
45454 WARN_ON(1);
45455 else
45456 - --port->port.count;
45457 + atomic_dec(&port->port.count);
45458 goto exit;
45459 }
45460
45461 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
45462 * and sleep if necessary
45463 */
45464 port->openclose = true;
45465 - port->port.count = 0;
45466 + atomic_set(&port->port.count, 0);
45467
45468 gser = port->port_usb;
45469 if (gser && gser->disconnect)
45470 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
45471 int cond;
45472
45473 spin_lock_irq(&port->port_lock);
45474 - cond = (port->port.count == 0) && !port->openclose;
45475 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
45476 spin_unlock_irq(&port->port_lock);
45477 return cond;
45478 }
45479 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
45480 /* if it's already open, start I/O ... and notify the serial
45481 * protocol about open/close status (connect/disconnect).
45482 */
45483 - if (port->port.count) {
45484 + if (atomic_read(&port->port.count)) {
45485 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
45486 gs_start_io(port);
45487 if (gser->connect)
45488 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
45489
45490 port->port_usb = NULL;
45491 gser->ioport = NULL;
45492 - if (port->port.count > 0 || port->openclose) {
45493 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
45494 wake_up_interruptible(&port->drain_wait);
45495 if (port->port.tty)
45496 tty_hangup(port->port.tty);
45497 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
45498
45499 /* finally, free any unused/unusable I/O buffers */
45500 spin_lock_irqsave(&port->port_lock, flags);
45501 - if (port->port.count == 0 && !port->openclose)
45502 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
45503 gs_buf_free(&port->port_write_buf);
45504 gs_free_requests(gser->out, &port->read_pool, NULL);
45505 gs_free_requests(gser->out, &port->read_queue, NULL);
45506 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
45507 index 5f3bcd3..bfca43f 100644
45508 --- a/drivers/usb/serial/console.c
45509 +++ b/drivers/usb/serial/console.c
45510 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
45511
45512 info->port = port;
45513
45514 - ++port->port.count;
45515 + atomic_inc(&port->port.count);
45516 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
45517 if (serial->type->set_termios) {
45518 /*
45519 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
45520 }
45521 /* Now that any required fake tty operations are completed restore
45522 * the tty port count */
45523 - --port->port.count;
45524 + atomic_dec(&port->port.count);
45525 /* The console is special in terms of closing the device so
45526 * indicate this port is now acting as a system console. */
45527 port->port.console = 1;
45528 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
45529 free_tty:
45530 kfree(tty);
45531 reset_open_count:
45532 - port->port.count = 0;
45533 + atomic_set(&port->port.count, 0);
45534 usb_autopm_put_interface(serial->interface);
45535 error_get_interface:
45536 usb_serial_put(serial);
45537 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
45538 index 6c3586a..a94e621 100644
45539 --- a/drivers/usb/storage/realtek_cr.c
45540 +++ b/drivers/usb/storage/realtek_cr.c
45541 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
45542
45543 buf = kmalloc(len, GFP_NOIO);
45544 if (buf == NULL)
45545 - return USB_STOR_TRANSPORT_ERROR;
45546 + return -ENOMEM;
45547
45548 US_DEBUGP("%s, lun = %d\n", __func__, lun);
45549
45550 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
45551 index 75f70f0..d467e1a 100644
45552 --- a/drivers/usb/storage/usb.h
45553 +++ b/drivers/usb/storage/usb.h
45554 @@ -63,7 +63,7 @@ struct us_unusual_dev {
45555 __u8 useProtocol;
45556 __u8 useTransport;
45557 int (*initFunction)(struct us_data *);
45558 -};
45559 +} __do_const;
45560
45561
45562 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
45563 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
45564 index d6bea3e..60b250e 100644
45565 --- a/drivers/usb/wusbcore/wa-hc.h
45566 +++ b/drivers/usb/wusbcore/wa-hc.h
45567 @@ -192,7 +192,7 @@ struct wahc {
45568 struct list_head xfer_delayed_list;
45569 spinlock_t xfer_list_lock;
45570 struct work_struct xfer_work;
45571 - atomic_t xfer_id_count;
45572 + atomic_unchecked_t xfer_id_count;
45573 };
45574
45575
45576 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
45577 INIT_LIST_HEAD(&wa->xfer_delayed_list);
45578 spin_lock_init(&wa->xfer_list_lock);
45579 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
45580 - atomic_set(&wa->xfer_id_count, 1);
45581 + atomic_set_unchecked(&wa->xfer_id_count, 1);
45582 }
45583
45584 /**
45585 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
45586 index 57c01ab..8a05959 100644
45587 --- a/drivers/usb/wusbcore/wa-xfer.c
45588 +++ b/drivers/usb/wusbcore/wa-xfer.c
45589 @@ -296,7 +296,7 @@ out:
45590 */
45591 static void wa_xfer_id_init(struct wa_xfer *xfer)
45592 {
45593 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
45594 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
45595 }
45596
45597 /*
45598 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
45599 index 8c55011..eed4ae1a 100644
45600 --- a/drivers/video/aty/aty128fb.c
45601 +++ b/drivers/video/aty/aty128fb.c
45602 @@ -149,7 +149,7 @@ enum {
45603 };
45604
45605 /* Must match above enum */
45606 -static char * const r128_family[] = {
45607 +static const char * const r128_family[] = {
45608 "AGP",
45609 "PCI",
45610 "PRO AGP",
45611 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45612 index 4f27fdc..d3537e6 100644
45613 --- a/drivers/video/aty/atyfb_base.c
45614 +++ b/drivers/video/aty/atyfb_base.c
45615 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45616 par->accel_flags = var->accel_flags; /* hack */
45617
45618 if (var->accel_flags) {
45619 - info->fbops->fb_sync = atyfb_sync;
45620 + pax_open_kernel();
45621 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45622 + pax_close_kernel();
45623 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45624 } else {
45625 - info->fbops->fb_sync = NULL;
45626 + pax_open_kernel();
45627 + *(void **)&info->fbops->fb_sync = NULL;
45628 + pax_close_kernel();
45629 info->flags |= FBINFO_HWACCEL_DISABLED;
45630 }
45631
45632 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45633 index 95ec042..e6affdd 100644
45634 --- a/drivers/video/aty/mach64_cursor.c
45635 +++ b/drivers/video/aty/mach64_cursor.c
45636 @@ -7,6 +7,7 @@
45637 #include <linux/string.h>
45638
45639 #include <asm/io.h>
45640 +#include <asm/pgtable.h>
45641
45642 #ifdef __sparc__
45643 #include <asm/fbio.h>
45644 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45645 info->sprite.buf_align = 16; /* and 64 lines tall. */
45646 info->sprite.flags = FB_PIXMAP_IO;
45647
45648 - info->fbops->fb_cursor = atyfb_cursor;
45649 + pax_open_kernel();
45650 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45651 + pax_close_kernel();
45652
45653 return 0;
45654 }
45655 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45656 index 6c5ed6b..b727c88 100644
45657 --- a/drivers/video/backlight/kb3886_bl.c
45658 +++ b/drivers/video/backlight/kb3886_bl.c
45659 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45660 static unsigned long kb3886bl_flags;
45661 #define KB3886BL_SUSPENDED 0x01
45662
45663 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45664 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45665 {
45666 .ident = "Sahara Touch-iT",
45667 .matches = {
45668 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45669 index 88cad6b..dd746c7 100644
45670 --- a/drivers/video/fb_defio.c
45671 +++ b/drivers/video/fb_defio.c
45672 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45673
45674 BUG_ON(!fbdefio);
45675 mutex_init(&fbdefio->lock);
45676 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45677 + pax_open_kernel();
45678 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45679 + pax_close_kernel();
45680 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45681 INIT_LIST_HEAD(&fbdefio->pagelist);
45682 if (fbdefio->delay == 0) /* set a default of 1 s */
45683 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45684 page->mapping = NULL;
45685 }
45686
45687 - info->fbops->fb_mmap = NULL;
45688 + *(void **)&info->fbops->fb_mmap = NULL;
45689 mutex_destroy(&fbdefio->lock);
45690 }
45691 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45692 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45693 index 5c3960d..15cf8fc 100644
45694 --- a/drivers/video/fbcmap.c
45695 +++ b/drivers/video/fbcmap.c
45696 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45697 rc = -ENODEV;
45698 goto out;
45699 }
45700 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45701 - !info->fbops->fb_setcmap)) {
45702 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45703 rc = -EINVAL;
45704 goto out1;
45705 }
45706 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45707 index 0a49456..fd5be1b 100644
45708 --- a/drivers/video/fbmem.c
45709 +++ b/drivers/video/fbmem.c
45710 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45711 image->dx += image->width + 8;
45712 }
45713 } else if (rotate == FB_ROTATE_UD) {
45714 - for (x = 0; x < num && image->dx >= 0; x++) {
45715 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45716 info->fbops->fb_imageblit(info, image);
45717 image->dx -= image->width + 8;
45718 }
45719 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45720 image->dy += image->height + 8;
45721 }
45722 } else if (rotate == FB_ROTATE_CCW) {
45723 - for (x = 0; x < num && image->dy >= 0; x++) {
45724 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45725 info->fbops->fb_imageblit(info, image);
45726 image->dy -= image->height + 8;
45727 }
45728 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45729 return -EFAULT;
45730 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45731 return -EINVAL;
45732 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45733 + if (con2fb.framebuffer >= FB_MAX)
45734 return -EINVAL;
45735 if (!registered_fb[con2fb.framebuffer])
45736 request_module("fb%d", con2fb.framebuffer);
45737 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45738 index 7672d2e..b56437f 100644
45739 --- a/drivers/video/i810/i810_accel.c
45740 +++ b/drivers/video/i810/i810_accel.c
45741 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45742 }
45743 }
45744 printk("ringbuffer lockup!!!\n");
45745 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45746 i810_report_error(mmio);
45747 par->dev_flags |= LOCKUP;
45748 info->pixmap.scan_align = 1;
45749 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45750 index 3c14e43..eafa544 100644
45751 --- a/drivers/video/logo/logo_linux_clut224.ppm
45752 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45753 @@ -1,1604 +1,1123 @@
45754 P3
45755 -# Standard 224-color Linux logo
45756 80 80
45757 255
45758 - 0 0 0 0 0 0 0 0 0 0 0 0
45759 - 0 0 0 0 0 0 0 0 0 0 0 0
45760 - 0 0 0 0 0 0 0 0 0 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 - 6 6 6 6 6 6 10 10 10 10 10 10
45768 - 10 10 10 6 6 6 6 6 6 6 6 6
45769 - 0 0 0 0 0 0 0 0 0 0 0 0
45770 - 0 0 0 0 0 0 0 0 0 0 0 0
45771 - 0 0 0 0 0 0 0 0 0 0 0 0
45772 - 0 0 0 0 0 0 0 0 0 0 0 0
45773 - 0 0 0 0 0 0 0 0 0 0 0 0
45774 - 0 0 0 0 0 0 0 0 0 0 0 0
45775 - 0 0 0 0 0 0 0 0 0 0 0 0
45776 - 0 0 0 0 0 0 0 0 0 0 0 0
45777 - 0 0 0 0 0 0 0 0 0 0 0 0
45778 - 0 0 0 0 0 0 0 0 0 0 0 0
45779 - 0 0 0 0 0 0 0 0 0 0 0 0
45780 - 0 0 0 0 0 0 0 0 0 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 6 6 6 10 10 10 14 14 14
45787 - 22 22 22 26 26 26 30 30 30 34 34 34
45788 - 30 30 30 30 30 30 26 26 26 18 18 18
45789 - 14 14 14 10 10 10 6 6 6 0 0 0
45790 - 0 0 0 0 0 0 0 0 0 0 0 0
45791 - 0 0 0 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 0 0 0
45793 - 0 0 0 0 0 0 0 0 0 0 0 0
45794 - 0 0 0 0 0 0 0 0 0 0 0 0
45795 - 0 0 0 0 0 0 0 0 0 0 0 0
45796 - 0 0 0 0 0 0 0 0 0 0 0 0
45797 - 0 0 0 0 0 0 0 0 0 0 0 0
45798 - 0 0 0 0 0 0 0 0 0 0 0 0
45799 - 0 0 0 0 0 1 0 0 1 0 0 0
45800 - 0 0 0 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 - 6 6 6 14 14 14 26 26 26 42 42 42
45807 - 54 54 54 66 66 66 78 78 78 78 78 78
45808 - 78 78 78 74 74 74 66 66 66 54 54 54
45809 - 42 42 42 26 26 26 18 18 18 10 10 10
45810 - 6 6 6 0 0 0 0 0 0 0 0 0
45811 - 0 0 0 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 0 0 0
45813 - 0 0 0 0 0 0 0 0 0 0 0 0
45814 - 0 0 0 0 0 0 0 0 0 0 0 0
45815 - 0 0 0 0 0 0 0 0 0 0 0 0
45816 - 0 0 0 0 0 0 0 0 0 0 0 0
45817 - 0 0 0 0 0 0 0 0 0 0 0 0
45818 - 0 0 0 0 0 0 0 0 0 0 0 0
45819 - 0 0 1 0 0 0 0 0 0 0 0 0
45820 - 0 0 0 0 0 0 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 10 10 10
45826 - 22 22 22 42 42 42 66 66 66 86 86 86
45827 - 66 66 66 38 38 38 38 38 38 22 22 22
45828 - 26 26 26 34 34 34 54 54 54 66 66 66
45829 - 86 86 86 70 70 70 46 46 46 26 26 26
45830 - 14 14 14 6 6 6 0 0 0 0 0 0
45831 - 0 0 0 0 0 0 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 0 0 0
45833 - 0 0 0 0 0 0 0 0 0 0 0 0
45834 - 0 0 0 0 0 0 0 0 0 0 0 0
45835 - 0 0 0 0 0 0 0 0 0 0 0 0
45836 - 0 0 0 0 0 0 0 0 0 0 0 0
45837 - 0 0 0 0 0 0 0 0 0 0 0 0
45838 - 0 0 0 0 0 0 0 0 0 0 0 0
45839 - 0 0 1 0 0 1 0 0 1 0 0 0
45840 - 0 0 0 0 0 0 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 10 10 10 26 26 26
45846 - 50 50 50 82 82 82 58 58 58 6 6 6
45847 - 2 2 6 2 2 6 2 2 6 2 2 6
45848 - 2 2 6 2 2 6 2 2 6 2 2 6
45849 - 6 6 6 54 54 54 86 86 86 66 66 66
45850 - 38 38 38 18 18 18 6 6 6 0 0 0
45851 - 0 0 0 0 0 0 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 0 0 0 0 0 0
45853 - 0 0 0 0 0 0 0 0 0 0 0 0
45854 - 0 0 0 0 0 0 0 0 0 0 0 0
45855 - 0 0 0 0 0 0 0 0 0 0 0 0
45856 - 0 0 0 0 0 0 0 0 0 0 0 0
45857 - 0 0 0 0 0 0 0 0 0 0 0 0
45858 - 0 0 0 0 0 0 0 0 0 0 0 0
45859 - 0 0 0 0 0 0 0 0 0 0 0 0
45860 - 0 0 0 0 0 0 0 0 0 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 6 6 6 22 22 22 50 50 50
45866 - 78 78 78 34 34 34 2 2 6 2 2 6
45867 - 2 2 6 2 2 6 2 2 6 2 2 6
45868 - 2 2 6 2 2 6 2 2 6 2 2 6
45869 - 2 2 6 2 2 6 6 6 6 70 70 70
45870 - 78 78 78 46 46 46 22 22 22 6 6 6
45871 - 0 0 0 0 0 0 0 0 0 0 0 0
45872 - 0 0 0 0 0 0 0 0 0 0 0 0
45873 - 0 0 0 0 0 0 0 0 0 0 0 0
45874 - 0 0 0 0 0 0 0 0 0 0 0 0
45875 - 0 0 0 0 0 0 0 0 0 0 0 0
45876 - 0 0 0 0 0 0 0 0 0 0 0 0
45877 - 0 0 0 0 0 0 0 0 0 0 0 0
45878 - 0 0 0 0 0 0 0 0 0 0 0 0
45879 - 0 0 1 0 0 1 0 0 1 0 0 0
45880 - 0 0 0 0 0 0 0 0 0 0 0 0
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 - 6 6 6 18 18 18 42 42 42 82 82 82
45886 - 26 26 26 2 2 6 2 2 6 2 2 6
45887 - 2 2 6 2 2 6 2 2 6 2 2 6
45888 - 2 2 6 2 2 6 2 2 6 14 14 14
45889 - 46 46 46 34 34 34 6 6 6 2 2 6
45890 - 42 42 42 78 78 78 42 42 42 18 18 18
45891 - 6 6 6 0 0 0 0 0 0 0 0 0
45892 - 0 0 0 0 0 0 0 0 0 0 0 0
45893 - 0 0 0 0 0 0 0 0 0 0 0 0
45894 - 0 0 0 0 0 0 0 0 0 0 0 0
45895 - 0 0 0 0 0 0 0 0 0 0 0 0
45896 - 0 0 0 0 0 0 0 0 0 0 0 0
45897 - 0 0 0 0 0 0 0 0 0 0 0 0
45898 - 0 0 0 0 0 0 0 0 0 0 0 0
45899 - 0 0 1 0 0 0 0 0 1 0 0 0
45900 - 0 0 0 0 0 0 0 0 0 0 0 0
45901 - 0 0 0 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 - 10 10 10 30 30 30 66 66 66 58 58 58
45906 - 2 2 6 2 2 6 2 2 6 2 2 6
45907 - 2 2 6 2 2 6 2 2 6 2 2 6
45908 - 2 2 6 2 2 6 2 2 6 26 26 26
45909 - 86 86 86 101 101 101 46 46 46 10 10 10
45910 - 2 2 6 58 58 58 70 70 70 34 34 34
45911 - 10 10 10 0 0 0 0 0 0 0 0 0
45912 - 0 0 0 0 0 0 0 0 0 0 0 0
45913 - 0 0 0 0 0 0 0 0 0 0 0 0
45914 - 0 0 0 0 0 0 0 0 0 0 0 0
45915 - 0 0 0 0 0 0 0 0 0 0 0 0
45916 - 0 0 0 0 0 0 0 0 0 0 0 0
45917 - 0 0 0 0 0 0 0 0 0 0 0 0
45918 - 0 0 0 0 0 0 0 0 0 0 0 0
45919 - 0 0 1 0 0 1 0 0 1 0 0 0
45920 - 0 0 0 0 0 0 0 0 0 0 0 0
45921 - 0 0 0 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 - 14 14 14 42 42 42 86 86 86 10 10 10
45926 - 2 2 6 2 2 6 2 2 6 2 2 6
45927 - 2 2 6 2 2 6 2 2 6 2 2 6
45928 - 2 2 6 2 2 6 2 2 6 30 30 30
45929 - 94 94 94 94 94 94 58 58 58 26 26 26
45930 - 2 2 6 6 6 6 78 78 78 54 54 54
45931 - 22 22 22 6 6 6 0 0 0 0 0 0
45932 - 0 0 0 0 0 0 0 0 0 0 0 0
45933 - 0 0 0 0 0 0 0 0 0 0 0 0
45934 - 0 0 0 0 0 0 0 0 0 0 0 0
45935 - 0 0 0 0 0 0 0 0 0 0 0 0
45936 - 0 0 0 0 0 0 0 0 0 0 0 0
45937 - 0 0 0 0 0 0 0 0 0 0 0 0
45938 - 0 0 0 0 0 0 0 0 0 0 0 0
45939 - 0 0 0 0 0 0 0 0 0 0 0 0
45940 - 0 0 0 0 0 0 0 0 0 0 0 0
45941 - 0 0 0 0 0 0 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 6 6 6
45945 - 22 22 22 62 62 62 62 62 62 2 2 6
45946 - 2 2 6 2 2 6 2 2 6 2 2 6
45947 - 2 2 6 2 2 6 2 2 6 2 2 6
45948 - 2 2 6 2 2 6 2 2 6 26 26 26
45949 - 54 54 54 38 38 38 18 18 18 10 10 10
45950 - 2 2 6 2 2 6 34 34 34 82 82 82
45951 - 38 38 38 14 14 14 0 0 0 0 0 0
45952 - 0 0 0 0 0 0 0 0 0 0 0 0
45953 - 0 0 0 0 0 0 0 0 0 0 0 0
45954 - 0 0 0 0 0 0 0 0 0 0 0 0
45955 - 0 0 0 0 0 0 0 0 0 0 0 0
45956 - 0 0 0 0 0 0 0 0 0 0 0 0
45957 - 0 0 0 0 0 0 0 0 0 0 0 0
45958 - 0 0 0 0 0 0 0 0 0 0 0 0
45959 - 0 0 0 0 0 1 0 0 1 0 0 0
45960 - 0 0 0 0 0 0 0 0 0 0 0 0
45961 - 0 0 0 0 0 0 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 6 6 6
45965 - 30 30 30 78 78 78 30 30 30 2 2 6
45966 - 2 2 6 2 2 6 2 2 6 2 2 6
45967 - 2 2 6 2 2 6 2 2 6 2 2 6
45968 - 2 2 6 2 2 6 2 2 6 10 10 10
45969 - 10 10 10 2 2 6 2 2 6 2 2 6
45970 - 2 2 6 2 2 6 2 2 6 78 78 78
45971 - 50 50 50 18 18 18 6 6 6 0 0 0
45972 - 0 0 0 0 0 0 0 0 0 0 0 0
45973 - 0 0 0 0 0 0 0 0 0 0 0 0
45974 - 0 0 0 0 0 0 0 0 0 0 0 0
45975 - 0 0 0 0 0 0 0 0 0 0 0 0
45976 - 0 0 0 0 0 0 0 0 0 0 0 0
45977 - 0 0 0 0 0 0 0 0 0 0 0 0
45978 - 0 0 0 0 0 0 0 0 0 0 0 0
45979 - 0 0 1 0 0 0 0 0 0 0 0 0
45980 - 0 0 0 0 0 0 0 0 0 0 0 0
45981 - 0 0 0 0 0 0 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 10 10 10
45985 - 38 38 38 86 86 86 14 14 14 2 2 6
45986 - 2 2 6 2 2 6 2 2 6 2 2 6
45987 - 2 2 6 2 2 6 2 2 6 2 2 6
45988 - 2 2 6 2 2 6 2 2 6 2 2 6
45989 - 2 2 6 2 2 6 2 2 6 2 2 6
45990 - 2 2 6 2 2 6 2 2 6 54 54 54
45991 - 66 66 66 26 26 26 6 6 6 0 0 0
45992 - 0 0 0 0 0 0 0 0 0 0 0 0
45993 - 0 0 0 0 0 0 0 0 0 0 0 0
45994 - 0 0 0 0 0 0 0 0 0 0 0 0
45995 - 0 0 0 0 0 0 0 0 0 0 0 0
45996 - 0 0 0 0 0 0 0 0 0 0 0 0
45997 - 0 0 0 0 0 0 0 0 0 0 0 0
45998 - 0 0 0 0 0 0 0 0 0 0 0 0
45999 - 0 0 0 0 0 1 0 0 1 0 0 0
46000 - 0 0 0 0 0 0 0 0 0 0 0 0
46001 - 0 0 0 0 0 0 0 0 0 0 0 0
46002 - 0 0 0 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 14 14 14
46005 - 42 42 42 82 82 82 2 2 6 2 2 6
46006 - 2 2 6 6 6 6 10 10 10 2 2 6
46007 - 2 2 6 2 2 6 2 2 6 2 2 6
46008 - 2 2 6 2 2 6 2 2 6 6 6 6
46009 - 14 14 14 10 10 10 2 2 6 2 2 6
46010 - 2 2 6 2 2 6 2 2 6 18 18 18
46011 - 82 82 82 34 34 34 10 10 10 0 0 0
46012 - 0 0 0 0 0 0 0 0 0 0 0 0
46013 - 0 0 0 0 0 0 0 0 0 0 0 0
46014 - 0 0 0 0 0 0 0 0 0 0 0 0
46015 - 0 0 0 0 0 0 0 0 0 0 0 0
46016 - 0 0 0 0 0 0 0 0 0 0 0 0
46017 - 0 0 0 0 0 0 0 0 0 0 0 0
46018 - 0 0 0 0 0 0 0 0 0 0 0 0
46019 - 0 0 1 0 0 0 0 0 0 0 0 0
46020 - 0 0 0 0 0 0 0 0 0 0 0 0
46021 - 0 0 0 0 0 0 0 0 0 0 0 0
46022 - 0 0 0 0 0 0 0 0 0 0 0 0
46023 - 0 0 0 0 0 0 0 0 0 0 0 0
46024 - 0 0 0 0 0 0 0 0 0 14 14 14
46025 - 46 46 46 86 86 86 2 2 6 2 2 6
46026 - 6 6 6 6 6 6 22 22 22 34 34 34
46027 - 6 6 6 2 2 6 2 2 6 2 2 6
46028 - 2 2 6 2 2 6 18 18 18 34 34 34
46029 - 10 10 10 50 50 50 22 22 22 2 2 6
46030 - 2 2 6 2 2 6 2 2 6 10 10 10
46031 - 86 86 86 42 42 42 14 14 14 0 0 0
46032 - 0 0 0 0 0 0 0 0 0 0 0 0
46033 - 0 0 0 0 0 0 0 0 0 0 0 0
46034 - 0 0 0 0 0 0 0 0 0 0 0 0
46035 - 0 0 0 0 0 0 0 0 0 0 0 0
46036 - 0 0 0 0 0 0 0 0 0 0 0 0
46037 - 0 0 0 0 0 0 0 0 0 0 0 0
46038 - 0 0 0 0 0 0 0 0 0 0 0 0
46039 - 0 0 1 0 0 1 0 0 1 0 0 0
46040 - 0 0 0 0 0 0 0 0 0 0 0 0
46041 - 0 0 0 0 0 0 0 0 0 0 0 0
46042 - 0 0 0 0 0 0 0 0 0 0 0 0
46043 - 0 0 0 0 0 0 0 0 0 0 0 0
46044 - 0 0 0 0 0 0 0 0 0 14 14 14
46045 - 46 46 46 86 86 86 2 2 6 2 2 6
46046 - 38 38 38 116 116 116 94 94 94 22 22 22
46047 - 22 22 22 2 2 6 2 2 6 2 2 6
46048 - 14 14 14 86 86 86 138 138 138 162 162 162
46049 -154 154 154 38 38 38 26 26 26 6 6 6
46050 - 2 2 6 2 2 6 2 2 6 2 2 6
46051 - 86 86 86 46 46 46 14 14 14 0 0 0
46052 - 0 0 0 0 0 0 0 0 0 0 0 0
46053 - 0 0 0 0 0 0 0 0 0 0 0 0
46054 - 0 0 0 0 0 0 0 0 0 0 0 0
46055 - 0 0 0 0 0 0 0 0 0 0 0 0
46056 - 0 0 0 0 0 0 0 0 0 0 0 0
46057 - 0 0 0 0 0 0 0 0 0 0 0 0
46058 - 0 0 0 0 0 0 0 0 0 0 0 0
46059 - 0 0 0 0 0 0 0 0 0 0 0 0
46060 - 0 0 0 0 0 0 0 0 0 0 0 0
46061 - 0 0 0 0 0 0 0 0 0 0 0 0
46062 - 0 0 0 0 0 0 0 0 0 0 0 0
46063 - 0 0 0 0 0 0 0 0 0 0 0 0
46064 - 0 0 0 0 0 0 0 0 0 14 14 14
46065 - 46 46 46 86 86 86 2 2 6 14 14 14
46066 -134 134 134 198 198 198 195 195 195 116 116 116
46067 - 10 10 10 2 2 6 2 2 6 6 6 6
46068 -101 98 89 187 187 187 210 210 210 218 218 218
46069 -214 214 214 134 134 134 14 14 14 6 6 6
46070 - 2 2 6 2 2 6 2 2 6 2 2 6
46071 - 86 86 86 50 50 50 18 18 18 6 6 6
46072 - 0 0 0 0 0 0 0 0 0 0 0 0
46073 - 0 0 0 0 0 0 0 0 0 0 0 0
46074 - 0 0 0 0 0 0 0 0 0 0 0 0
46075 - 0 0 0 0 0 0 0 0 0 0 0 0
46076 - 0 0 0 0 0 0 0 0 0 0 0 0
46077 - 0 0 0 0 0 0 0 0 0 0 0 0
46078 - 0 0 0 0 0 0 0 0 1 0 0 0
46079 - 0 0 1 0 0 1 0 0 1 0 0 0
46080 - 0 0 0 0 0 0 0 0 0 0 0 0
46081 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
46085 - 46 46 46 86 86 86 2 2 6 54 54 54
46086 -218 218 218 195 195 195 226 226 226 246 246 246
46087 - 58 58 58 2 2 6 2 2 6 30 30 30
46088 -210 210 210 253 253 253 174 174 174 123 123 123
46089 -221 221 221 234 234 234 74 74 74 2 2 6
46090 - 2 2 6 2 2 6 2 2 6 2 2 6
46091 - 70 70 70 58 58 58 22 22 22 6 6 6
46092 - 0 0 0 0 0 0 0 0 0 0 0 0
46093 - 0 0 0 0 0 0 0 0 0 0 0 0
46094 - 0 0 0 0 0 0 0 0 0 0 0 0
46095 - 0 0 0 0 0 0 0 0 0 0 0 0
46096 - 0 0 0 0 0 0 0 0 0 0 0 0
46097 - 0 0 0 0 0 0 0 0 0 0 0 0
46098 - 0 0 0 0 0 0 0 0 0 0 0 0
46099 - 0 0 0 0 0 0 0 0 0 0 0 0
46100 - 0 0 0 0 0 0 0 0 0 0 0 0
46101 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
46105 - 46 46 46 82 82 82 2 2 6 106 106 106
46106 -170 170 170 26 26 26 86 86 86 226 226 226
46107 -123 123 123 10 10 10 14 14 14 46 46 46
46108 -231 231 231 190 190 190 6 6 6 70 70 70
46109 - 90 90 90 238 238 238 158 158 158 2 2 6
46110 - 2 2 6 2 2 6 2 2 6 2 2 6
46111 - 70 70 70 58 58 58 22 22 22 6 6 6
46112 - 0 0 0 0 0 0 0 0 0 0 0 0
46113 - 0 0 0 0 0 0 0 0 0 0 0 0
46114 - 0 0 0 0 0 0 0 0 0 0 0 0
46115 - 0 0 0 0 0 0 0 0 0 0 0 0
46116 - 0 0 0 0 0 0 0 0 0 0 0 0
46117 - 0 0 0 0 0 0 0 0 0 0 0 0
46118 - 0 0 0 0 0 0 0 0 1 0 0 0
46119 - 0 0 1 0 0 1 0 0 1 0 0 0
46120 - 0 0 0 0 0 0 0 0 0 0 0 0
46121 - 0 0 0 0 0 0 0 0 0 0 0 0
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 14 14 14
46125 - 42 42 42 86 86 86 6 6 6 116 116 116
46126 -106 106 106 6 6 6 70 70 70 149 149 149
46127 -128 128 128 18 18 18 38 38 38 54 54 54
46128 -221 221 221 106 106 106 2 2 6 14 14 14
46129 - 46 46 46 190 190 190 198 198 198 2 2 6
46130 - 2 2 6 2 2 6 2 2 6 2 2 6
46131 - 74 74 74 62 62 62 22 22 22 6 6 6
46132 - 0 0 0 0 0 0 0 0 0 0 0 0
46133 - 0 0 0 0 0 0 0 0 0 0 0 0
46134 - 0 0 0 0 0 0 0 0 0 0 0 0
46135 - 0 0 0 0 0 0 0 0 0 0 0 0
46136 - 0 0 0 0 0 0 0 0 0 0 0 0
46137 - 0 0 0 0 0 0 0 0 0 0 0 0
46138 - 0 0 0 0 0 0 0 0 1 0 0 0
46139 - 0 0 1 0 0 0 0 0 1 0 0 0
46140 - 0 0 0 0 0 0 0 0 0 0 0 0
46141 - 0 0 0 0 0 0 0 0 0 0 0 0
46142 - 0 0 0 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 14 14 14
46145 - 42 42 42 94 94 94 14 14 14 101 101 101
46146 -128 128 128 2 2 6 18 18 18 116 116 116
46147 -118 98 46 121 92 8 121 92 8 98 78 10
46148 -162 162 162 106 106 106 2 2 6 2 2 6
46149 - 2 2 6 195 195 195 195 195 195 6 6 6
46150 - 2 2 6 2 2 6 2 2 6 2 2 6
46151 - 74 74 74 62 62 62 22 22 22 6 6 6
46152 - 0 0 0 0 0 0 0 0 0 0 0 0
46153 - 0 0 0 0 0 0 0 0 0 0 0 0
46154 - 0 0 0 0 0 0 0 0 0 0 0 0
46155 - 0 0 0 0 0 0 0 0 0 0 0 0
46156 - 0 0 0 0 0 0 0 0 0 0 0 0
46157 - 0 0 0 0 0 0 0 0 0 0 0 0
46158 - 0 0 0 0 0 0 0 0 1 0 0 1
46159 - 0 0 1 0 0 0 0 0 1 0 0 0
46160 - 0 0 0 0 0 0 0 0 0 0 0 0
46161 - 0 0 0 0 0 0 0 0 0 0 0 0
46162 - 0 0 0 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 10 10 10
46165 - 38 38 38 90 90 90 14 14 14 58 58 58
46166 -210 210 210 26 26 26 54 38 6 154 114 10
46167 -226 170 11 236 186 11 225 175 15 184 144 12
46168 -215 174 15 175 146 61 37 26 9 2 2 6
46169 - 70 70 70 246 246 246 138 138 138 2 2 6
46170 - 2 2 6 2 2 6 2 2 6 2 2 6
46171 - 70 70 70 66 66 66 26 26 26 6 6 6
46172 - 0 0 0 0 0 0 0 0 0 0 0 0
46173 - 0 0 0 0 0 0 0 0 0 0 0 0
46174 - 0 0 0 0 0 0 0 0 0 0 0 0
46175 - 0 0 0 0 0 0 0 0 0 0 0 0
46176 - 0 0 0 0 0 0 0 0 0 0 0 0
46177 - 0 0 0 0 0 0 0 0 0 0 0 0
46178 - 0 0 0 0 0 0 0 0 0 0 0 0
46179 - 0 0 0 0 0 0 0 0 0 0 0 0
46180 - 0 0 0 0 0 0 0 0 0 0 0 0
46181 - 0 0 0 0 0 0 0 0 0 0 0 0
46182 - 0 0 0 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 10 10 10
46185 - 38 38 38 86 86 86 14 14 14 10 10 10
46186 -195 195 195 188 164 115 192 133 9 225 175 15
46187 -239 182 13 234 190 10 232 195 16 232 200 30
46188 -245 207 45 241 208 19 232 195 16 184 144 12
46189 -218 194 134 211 206 186 42 42 42 2 2 6
46190 - 2 2 6 2 2 6 2 2 6 2 2 6
46191 - 50 50 50 74 74 74 30 30 30 6 6 6
46192 - 0 0 0 0 0 0 0 0 0 0 0 0
46193 - 0 0 0 0 0 0 0 0 0 0 0 0
46194 - 0 0 0 0 0 0 0 0 0 0 0 0
46195 - 0 0 0 0 0 0 0 0 0 0 0 0
46196 - 0 0 0 0 0 0 0 0 0 0 0 0
46197 - 0 0 0 0 0 0 0 0 0 0 0 0
46198 - 0 0 0 0 0 0 0 0 0 0 0 0
46199 - 0 0 0 0 0 0 0 0 0 0 0 0
46200 - 0 0 0 0 0 0 0 0 0 0 0 0
46201 - 0 0 0 0 0 0 0 0 0 0 0 0
46202 - 0 0 0 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 10 10 10
46205 - 34 34 34 86 86 86 14 14 14 2 2 6
46206 -121 87 25 192 133 9 219 162 10 239 182 13
46207 -236 186 11 232 195 16 241 208 19 244 214 54
46208 -246 218 60 246 218 38 246 215 20 241 208 19
46209 -241 208 19 226 184 13 121 87 25 2 2 6
46210 - 2 2 6 2 2 6 2 2 6 2 2 6
46211 - 50 50 50 82 82 82 34 34 34 10 10 10
46212 - 0 0 0 0 0 0 0 0 0 0 0 0
46213 - 0 0 0 0 0 0 0 0 0 0 0 0
46214 - 0 0 0 0 0 0 0 0 0 0 0 0
46215 - 0 0 0 0 0 0 0 0 0 0 0 0
46216 - 0 0 0 0 0 0 0 0 0 0 0 0
46217 - 0 0 0 0 0 0 0 0 0 0 0 0
46218 - 0 0 0 0 0 0 0 0 0 0 0 0
46219 - 0 0 0 0 0 0 0 0 0 0 0 0
46220 - 0 0 0 0 0 0 0 0 0 0 0 0
46221 - 0 0 0 0 0 0 0 0 0 0 0 0
46222 - 0 0 0 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 10 10 10
46225 - 34 34 34 82 82 82 30 30 30 61 42 6
46226 -180 123 7 206 145 10 230 174 11 239 182 13
46227 -234 190 10 238 202 15 241 208 19 246 218 74
46228 -246 218 38 246 215 20 246 215 20 246 215 20
46229 -226 184 13 215 174 15 184 144 12 6 6 6
46230 - 2 2 6 2 2 6 2 2 6 2 2 6
46231 - 26 26 26 94 94 94 42 42 42 14 14 14
46232 - 0 0 0 0 0 0 0 0 0 0 0 0
46233 - 0 0 0 0 0 0 0 0 0 0 0 0
46234 - 0 0 0 0 0 0 0 0 0 0 0 0
46235 - 0 0 0 0 0 0 0 0 0 0 0 0
46236 - 0 0 0 0 0 0 0 0 0 0 0 0
46237 - 0 0 0 0 0 0 0 0 0 0 0 0
46238 - 0 0 0 0 0 0 0 0 0 0 0 0
46239 - 0 0 0 0 0 0 0 0 0 0 0 0
46240 - 0 0 0 0 0 0 0 0 0 0 0 0
46241 - 0 0 0 0 0 0 0 0 0 0 0 0
46242 - 0 0 0 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 10 10 10
46245 - 30 30 30 78 78 78 50 50 50 104 69 6
46246 -192 133 9 216 158 10 236 178 12 236 186 11
46247 -232 195 16 241 208 19 244 214 54 245 215 43
46248 -246 215 20 246 215 20 241 208 19 198 155 10
46249 -200 144 11 216 158 10 156 118 10 2 2 6
46250 - 2 2 6 2 2 6 2 2 6 2 2 6
46251 - 6 6 6 90 90 90 54 54 54 18 18 18
46252 - 6 6 6 0 0 0 0 0 0 0 0 0
46253 - 0 0 0 0 0 0 0 0 0 0 0 0
46254 - 0 0 0 0 0 0 0 0 0 0 0 0
46255 - 0 0 0 0 0 0 0 0 0 0 0 0
46256 - 0 0 0 0 0 0 0 0 0 0 0 0
46257 - 0 0 0 0 0 0 0 0 0 0 0 0
46258 - 0 0 0 0 0 0 0 0 0 0 0 0
46259 - 0 0 0 0 0 0 0 0 0 0 0 0
46260 - 0 0 0 0 0 0 0 0 0 0 0 0
46261 - 0 0 0 0 0 0 0 0 0 0 0 0
46262 - 0 0 0 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 10 10 10
46265 - 30 30 30 78 78 78 46 46 46 22 22 22
46266 -137 92 6 210 162 10 239 182 13 238 190 10
46267 -238 202 15 241 208 19 246 215 20 246 215 20
46268 -241 208 19 203 166 17 185 133 11 210 150 10
46269 -216 158 10 210 150 10 102 78 10 2 2 6
46270 - 6 6 6 54 54 54 14 14 14 2 2 6
46271 - 2 2 6 62 62 62 74 74 74 30 30 30
46272 - 10 10 10 0 0 0 0 0 0 0 0 0
46273 - 0 0 0 0 0 0 0 0 0 0 0 0
46274 - 0 0 0 0 0 0 0 0 0 0 0 0
46275 - 0 0 0 0 0 0 0 0 0 0 0 0
46276 - 0 0 0 0 0 0 0 0 0 0 0 0
46277 - 0 0 0 0 0 0 0 0 0 0 0 0
46278 - 0 0 0 0 0 0 0 0 0 0 0 0
46279 - 0 0 0 0 0 0 0 0 0 0 0 0
46280 - 0 0 0 0 0 0 0 0 0 0 0 0
46281 - 0 0 0 0 0 0 0 0 0 0 0 0
46282 - 0 0 0 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 10 10 10
46285 - 34 34 34 78 78 78 50 50 50 6 6 6
46286 - 94 70 30 139 102 15 190 146 13 226 184 13
46287 -232 200 30 232 195 16 215 174 15 190 146 13
46288 -168 122 10 192 133 9 210 150 10 213 154 11
46289 -202 150 34 182 157 106 101 98 89 2 2 6
46290 - 2 2 6 78 78 78 116 116 116 58 58 58
46291 - 2 2 6 22 22 22 90 90 90 46 46 46
46292 - 18 18 18 6 6 6 0 0 0 0 0 0
46293 - 0 0 0 0 0 0 0 0 0 0 0 0
46294 - 0 0 0 0 0 0 0 0 0 0 0 0
46295 - 0 0 0 0 0 0 0 0 0 0 0 0
46296 - 0 0 0 0 0 0 0 0 0 0 0 0
46297 - 0 0 0 0 0 0 0 0 0 0 0 0
46298 - 0 0 0 0 0 0 0 0 0 0 0 0
46299 - 0 0 0 0 0 0 0 0 0 0 0 0
46300 - 0 0 0 0 0 0 0 0 0 0 0 0
46301 - 0 0 0 0 0 0 0 0 0 0 0 0
46302 - 0 0 0 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 10 10 10
46305 - 38 38 38 86 86 86 50 50 50 6 6 6
46306 -128 128 128 174 154 114 156 107 11 168 122 10
46307 -198 155 10 184 144 12 197 138 11 200 144 11
46308 -206 145 10 206 145 10 197 138 11 188 164 115
46309 -195 195 195 198 198 198 174 174 174 14 14 14
46310 - 2 2 6 22 22 22 116 116 116 116 116 116
46311 - 22 22 22 2 2 6 74 74 74 70 70 70
46312 - 30 30 30 10 10 10 0 0 0 0 0 0
46313 - 0 0 0 0 0 0 0 0 0 0 0 0
46314 - 0 0 0 0 0 0 0 0 0 0 0 0
46315 - 0 0 0 0 0 0 0 0 0 0 0 0
46316 - 0 0 0 0 0 0 0 0 0 0 0 0
46317 - 0 0 0 0 0 0 0 0 0 0 0 0
46318 - 0 0 0 0 0 0 0 0 0 0 0 0
46319 - 0 0 0 0 0 0 0 0 0 0 0 0
46320 - 0 0 0 0 0 0 0 0 0 0 0 0
46321 - 0 0 0 0 0 0 0 0 0 0 0 0
46322 - 0 0 0 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 6 6 6 18 18 18
46325 - 50 50 50 101 101 101 26 26 26 10 10 10
46326 -138 138 138 190 190 190 174 154 114 156 107 11
46327 -197 138 11 200 144 11 197 138 11 192 133 9
46328 -180 123 7 190 142 34 190 178 144 187 187 187
46329 -202 202 202 221 221 221 214 214 214 66 66 66
46330 - 2 2 6 2 2 6 50 50 50 62 62 62
46331 - 6 6 6 2 2 6 10 10 10 90 90 90
46332 - 50 50 50 18 18 18 6 6 6 0 0 0
46333 - 0 0 0 0 0 0 0 0 0 0 0 0
46334 - 0 0 0 0 0 0 0 0 0 0 0 0
46335 - 0 0 0 0 0 0 0 0 0 0 0 0
46336 - 0 0 0 0 0 0 0 0 0 0 0 0
46337 - 0 0 0 0 0 0 0 0 0 0 0 0
46338 - 0 0 0 0 0 0 0 0 0 0 0 0
46339 - 0 0 0 0 0 0 0 0 0 0 0 0
46340 - 0 0 0 0 0 0 0 0 0 0 0 0
46341 - 0 0 0 0 0 0 0 0 0 0 0 0
46342 - 0 0 0 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 10 10 10 34 34 34
46345 - 74 74 74 74 74 74 2 2 6 6 6 6
46346 -144 144 144 198 198 198 190 190 190 178 166 146
46347 -154 121 60 156 107 11 156 107 11 168 124 44
46348 -174 154 114 187 187 187 190 190 190 210 210 210
46349 -246 246 246 253 253 253 253 253 253 182 182 182
46350 - 6 6 6 2 2 6 2 2 6 2 2 6
46351 - 2 2 6 2 2 6 2 2 6 62 62 62
46352 - 74 74 74 34 34 34 14 14 14 0 0 0
46353 - 0 0 0 0 0 0 0 0 0 0 0 0
46354 - 0 0 0 0 0 0 0 0 0 0 0 0
46355 - 0 0 0 0 0 0 0 0 0 0 0 0
46356 - 0 0 0 0 0 0 0 0 0 0 0 0
46357 - 0 0 0 0 0 0 0 0 0 0 0 0
46358 - 0 0 0 0 0 0 0 0 0 0 0 0
46359 - 0 0 0 0 0 0 0 0 0 0 0 0
46360 - 0 0 0 0 0 0 0 0 0 0 0 0
46361 - 0 0 0 0 0 0 0 0 0 0 0 0
46362 - 0 0 0 0 0 0 0 0 0 0 0 0
46363 - 0 0 0 0 0 0 0 0 0 0 0 0
46364 - 0 0 0 10 10 10 22 22 22 54 54 54
46365 - 94 94 94 18 18 18 2 2 6 46 46 46
46366 -234 234 234 221 221 221 190 190 190 190 190 190
46367 -190 190 190 187 187 187 187 187 187 190 190 190
46368 -190 190 190 195 195 195 214 214 214 242 242 242
46369 -253 253 253 253 253 253 253 253 253 253 253 253
46370 - 82 82 82 2 2 6 2 2 6 2 2 6
46371 - 2 2 6 2 2 6 2 2 6 14 14 14
46372 - 86 86 86 54 54 54 22 22 22 6 6 6
46373 - 0 0 0 0 0 0 0 0 0 0 0 0
46374 - 0 0 0 0 0 0 0 0 0 0 0 0
46375 - 0 0 0 0 0 0 0 0 0 0 0 0
46376 - 0 0 0 0 0 0 0 0 0 0 0 0
46377 - 0 0 0 0 0 0 0 0 0 0 0 0
46378 - 0 0 0 0 0 0 0 0 0 0 0 0
46379 - 0 0 0 0 0 0 0 0 0 0 0 0
46380 - 0 0 0 0 0 0 0 0 0 0 0 0
46381 - 0 0 0 0 0 0 0 0 0 0 0 0
46382 - 0 0 0 0 0 0 0 0 0 0 0 0
46383 - 0 0 0 0 0 0 0 0 0 0 0 0
46384 - 6 6 6 18 18 18 46 46 46 90 90 90
46385 - 46 46 46 18 18 18 6 6 6 182 182 182
46386 -253 253 253 246 246 246 206 206 206 190 190 190
46387 -190 190 190 190 190 190 190 190 190 190 190 190
46388 -206 206 206 231 231 231 250 250 250 253 253 253
46389 -253 253 253 253 253 253 253 253 253 253 253 253
46390 -202 202 202 14 14 14 2 2 6 2 2 6
46391 - 2 2 6 2 2 6 2 2 6 2 2 6
46392 - 42 42 42 86 86 86 42 42 42 18 18 18
46393 - 6 6 6 0 0 0 0 0 0 0 0 0
46394 - 0 0 0 0 0 0 0 0 0 0 0 0
46395 - 0 0 0 0 0 0 0 0 0 0 0 0
46396 - 0 0 0 0 0 0 0 0 0 0 0 0
46397 - 0 0 0 0 0 0 0 0 0 0 0 0
46398 - 0 0 0 0 0 0 0 0 0 0 0 0
46399 - 0 0 0 0 0 0 0 0 0 0 0 0
46400 - 0 0 0 0 0 0 0 0 0 0 0 0
46401 - 0 0 0 0 0 0 0 0 0 0 0 0
46402 - 0 0 0 0 0 0 0 0 0 0 0 0
46403 - 0 0 0 0 0 0 0 0 0 6 6 6
46404 - 14 14 14 38 38 38 74 74 74 66 66 66
46405 - 2 2 6 6 6 6 90 90 90 250 250 250
46406 -253 253 253 253 253 253 238 238 238 198 198 198
46407 -190 190 190 190 190 190 195 195 195 221 221 221
46408 -246 246 246 253 253 253 253 253 253 253 253 253
46409 -253 253 253 253 253 253 253 253 253 253 253 253
46410 -253 253 253 82 82 82 2 2 6 2 2 6
46411 - 2 2 6 2 2 6 2 2 6 2 2 6
46412 - 2 2 6 78 78 78 70 70 70 34 34 34
46413 - 14 14 14 6 6 6 0 0 0 0 0 0
46414 - 0 0 0 0 0 0 0 0 0 0 0 0
46415 - 0 0 0 0 0 0 0 0 0 0 0 0
46416 - 0 0 0 0 0 0 0 0 0 0 0 0
46417 - 0 0 0 0 0 0 0 0 0 0 0 0
46418 - 0 0 0 0 0 0 0 0 0 0 0 0
46419 - 0 0 0 0 0 0 0 0 0 0 0 0
46420 - 0 0 0 0 0 0 0 0 0 0 0 0
46421 - 0 0 0 0 0 0 0 0 0 0 0 0
46422 - 0 0 0 0 0 0 0 0 0 0 0 0
46423 - 0 0 0 0 0 0 0 0 0 14 14 14
46424 - 34 34 34 66 66 66 78 78 78 6 6 6
46425 - 2 2 6 18 18 18 218 218 218 253 253 253
46426 -253 253 253 253 253 253 253 253 253 246 246 246
46427 -226 226 226 231 231 231 246 246 246 253 253 253
46428 -253 253 253 253 253 253 253 253 253 253 253 253
46429 -253 253 253 253 253 253 253 253 253 253 253 253
46430 -253 253 253 178 178 178 2 2 6 2 2 6
46431 - 2 2 6 2 2 6 2 2 6 2 2 6
46432 - 2 2 6 18 18 18 90 90 90 62 62 62
46433 - 30 30 30 10 10 10 0 0 0 0 0 0
46434 - 0 0 0 0 0 0 0 0 0 0 0 0
46435 - 0 0 0 0 0 0 0 0 0 0 0 0
46436 - 0 0 0 0 0 0 0 0 0 0 0 0
46437 - 0 0 0 0 0 0 0 0 0 0 0 0
46438 - 0 0 0 0 0 0 0 0 0 0 0 0
46439 - 0 0 0 0 0 0 0 0 0 0 0 0
46440 - 0 0 0 0 0 0 0 0 0 0 0 0
46441 - 0 0 0 0 0 0 0 0 0 0 0 0
46442 - 0 0 0 0 0 0 0 0 0 0 0 0
46443 - 0 0 0 0 0 0 10 10 10 26 26 26
46444 - 58 58 58 90 90 90 18 18 18 2 2 6
46445 - 2 2 6 110 110 110 253 253 253 253 253 253
46446 -253 253 253 253 253 253 253 253 253 253 253 253
46447 -250 250 250 253 253 253 253 253 253 253 253 253
46448 -253 253 253 253 253 253 253 253 253 253 253 253
46449 -253 253 253 253 253 253 253 253 253 253 253 253
46450 -253 253 253 231 231 231 18 18 18 2 2 6
46451 - 2 2 6 2 2 6 2 2 6 2 2 6
46452 - 2 2 6 2 2 6 18 18 18 94 94 94
46453 - 54 54 54 26 26 26 10 10 10 0 0 0
46454 - 0 0 0 0 0 0 0 0 0 0 0 0
46455 - 0 0 0 0 0 0 0 0 0 0 0 0
46456 - 0 0 0 0 0 0 0 0 0 0 0 0
46457 - 0 0 0 0 0 0 0 0 0 0 0 0
46458 - 0 0 0 0 0 0 0 0 0 0 0 0
46459 - 0 0 0 0 0 0 0 0 0 0 0 0
46460 - 0 0 0 0 0 0 0 0 0 0 0 0
46461 - 0 0 0 0 0 0 0 0 0 0 0 0
46462 - 0 0 0 0 0 0 0 0 0 0 0 0
46463 - 0 0 0 6 6 6 22 22 22 50 50 50
46464 - 90 90 90 26 26 26 2 2 6 2 2 6
46465 - 14 14 14 195 195 195 250 250 250 253 253 253
46466 -253 253 253 253 253 253 253 253 253 253 253 253
46467 -253 253 253 253 253 253 253 253 253 253 253 253
46468 -253 253 253 253 253 253 253 253 253 253 253 253
46469 -253 253 253 253 253 253 253 253 253 253 253 253
46470 -250 250 250 242 242 242 54 54 54 2 2 6
46471 - 2 2 6 2 2 6 2 2 6 2 2 6
46472 - 2 2 6 2 2 6 2 2 6 38 38 38
46473 - 86 86 86 50 50 50 22 22 22 6 6 6
46474 - 0 0 0 0 0 0 0 0 0 0 0 0
46475 - 0 0 0 0 0 0 0 0 0 0 0 0
46476 - 0 0 0 0 0 0 0 0 0 0 0 0
46477 - 0 0 0 0 0 0 0 0 0 0 0 0
46478 - 0 0 0 0 0 0 0 0 0 0 0 0
46479 - 0 0 0 0 0 0 0 0 0 0 0 0
46480 - 0 0 0 0 0 0 0 0 0 0 0 0
46481 - 0 0 0 0 0 0 0 0 0 0 0 0
46482 - 0 0 0 0 0 0 0 0 0 0 0 0
46483 - 6 6 6 14 14 14 38 38 38 82 82 82
46484 - 34 34 34 2 2 6 2 2 6 2 2 6
46485 - 42 42 42 195 195 195 246 246 246 253 253 253
46486 -253 253 253 253 253 253 253 253 253 250 250 250
46487 -242 242 242 242 242 242 250 250 250 253 253 253
46488 -253 253 253 253 253 253 253 253 253 253 253 253
46489 -253 253 253 250 250 250 246 246 246 238 238 238
46490 -226 226 226 231 231 231 101 101 101 6 6 6
46491 - 2 2 6 2 2 6 2 2 6 2 2 6
46492 - 2 2 6 2 2 6 2 2 6 2 2 6
46493 - 38 38 38 82 82 82 42 42 42 14 14 14
46494 - 6 6 6 0 0 0 0 0 0 0 0 0
46495 - 0 0 0 0 0 0 0 0 0 0 0 0
46496 - 0 0 0 0 0 0 0 0 0 0 0 0
46497 - 0 0 0 0 0 0 0 0 0 0 0 0
46498 - 0 0 0 0 0 0 0 0 0 0 0 0
46499 - 0 0 0 0 0 0 0 0 0 0 0 0
46500 - 0 0 0 0 0 0 0 0 0 0 0 0
46501 - 0 0 0 0 0 0 0 0 0 0 0 0
46502 - 0 0 0 0 0 0 0 0 0 0 0 0
46503 - 10 10 10 26 26 26 62 62 62 66 66 66
46504 - 2 2 6 2 2 6 2 2 6 6 6 6
46505 - 70 70 70 170 170 170 206 206 206 234 234 234
46506 -246 246 246 250 250 250 250 250 250 238 238 238
46507 -226 226 226 231 231 231 238 238 238 250 250 250
46508 -250 250 250 250 250 250 246 246 246 231 231 231
46509 -214 214 214 206 206 206 202 202 202 202 202 202
46510 -198 198 198 202 202 202 182 182 182 18 18 18
46511 - 2 2 6 2 2 6 2 2 6 2 2 6
46512 - 2 2 6 2 2 6 2 2 6 2 2 6
46513 - 2 2 6 62 62 62 66 66 66 30 30 30
46514 - 10 10 10 0 0 0 0 0 0 0 0 0
46515 - 0 0 0 0 0 0 0 0 0 0 0 0
46516 - 0 0 0 0 0 0 0 0 0 0 0 0
46517 - 0 0 0 0 0 0 0 0 0 0 0 0
46518 - 0 0 0 0 0 0 0 0 0 0 0 0
46519 - 0 0 0 0 0 0 0 0 0 0 0 0
46520 - 0 0 0 0 0 0 0 0 0 0 0 0
46521 - 0 0 0 0 0 0 0 0 0 0 0 0
46522 - 0 0 0 0 0 0 0 0 0 0 0 0
46523 - 14 14 14 42 42 42 82 82 82 18 18 18
46524 - 2 2 6 2 2 6 2 2 6 10 10 10
46525 - 94 94 94 182 182 182 218 218 218 242 242 242
46526 -250 250 250 253 253 253 253 253 253 250 250 250
46527 -234 234 234 253 253 253 253 253 253 253 253 253
46528 -253 253 253 253 253 253 253 253 253 246 246 246
46529 -238 238 238 226 226 226 210 210 210 202 202 202
46530 -195 195 195 195 195 195 210 210 210 158 158 158
46531 - 6 6 6 14 14 14 50 50 50 14 14 14
46532 - 2 2 6 2 2 6 2 2 6 2 2 6
46533 - 2 2 6 6 6 6 86 86 86 46 46 46
46534 - 18 18 18 6 6 6 0 0 0 0 0 0
46535 - 0 0 0 0 0 0 0 0 0 0 0 0
46536 - 0 0 0 0 0 0 0 0 0 0 0 0
46537 - 0 0 0 0 0 0 0 0 0 0 0 0
46538 - 0 0 0 0 0 0 0 0 0 0 0 0
46539 - 0 0 0 0 0 0 0 0 0 0 0 0
46540 - 0 0 0 0 0 0 0 0 0 0 0 0
46541 - 0 0 0 0 0 0 0 0 0 0 0 0
46542 - 0 0 0 0 0 0 0 0 0 6 6 6
46543 - 22 22 22 54 54 54 70 70 70 2 2 6
46544 - 2 2 6 10 10 10 2 2 6 22 22 22
46545 -166 166 166 231 231 231 250 250 250 253 253 253
46546 -253 253 253 253 253 253 253 253 253 250 250 250
46547 -242 242 242 253 253 253 253 253 253 253 253 253
46548 -253 253 253 253 253 253 253 253 253 253 253 253
46549 -253 253 253 253 253 253 253 253 253 246 246 246
46550 -231 231 231 206 206 206 198 198 198 226 226 226
46551 - 94 94 94 2 2 6 6 6 6 38 38 38
46552 - 30 30 30 2 2 6 2 2 6 2 2 6
46553 - 2 2 6 2 2 6 62 62 62 66 66 66
46554 - 26 26 26 10 10 10 0 0 0 0 0 0
46555 - 0 0 0 0 0 0 0 0 0 0 0 0
46556 - 0 0 0 0 0 0 0 0 0 0 0 0
46557 - 0 0 0 0 0 0 0 0 0 0 0 0
46558 - 0 0 0 0 0 0 0 0 0 0 0 0
46559 - 0 0 0 0 0 0 0 0 0 0 0 0
46560 - 0 0 0 0 0 0 0 0 0 0 0 0
46561 - 0 0 0 0 0 0 0 0 0 0 0 0
46562 - 0 0 0 0 0 0 0 0 0 10 10 10
46563 - 30 30 30 74 74 74 50 50 50 2 2 6
46564 - 26 26 26 26 26 26 2 2 6 106 106 106
46565 -238 238 238 253 253 253 253 253 253 253 253 253
46566 -253 253 253 253 253 253 253 253 253 253 253 253
46567 -253 253 253 253 253 253 253 253 253 253 253 253
46568 -253 253 253 253 253 253 253 253 253 253 253 253
46569 -253 253 253 253 253 253 253 253 253 253 253 253
46570 -253 253 253 246 246 246 218 218 218 202 202 202
46571 -210 210 210 14 14 14 2 2 6 2 2 6
46572 - 30 30 30 22 22 22 2 2 6 2 2 6
46573 - 2 2 6 2 2 6 18 18 18 86 86 86
46574 - 42 42 42 14 14 14 0 0 0 0 0 0
46575 - 0 0 0 0 0 0 0 0 0 0 0 0
46576 - 0 0 0 0 0 0 0 0 0 0 0 0
46577 - 0 0 0 0 0 0 0 0 0 0 0 0
46578 - 0 0 0 0 0 0 0 0 0 0 0 0
46579 - 0 0 0 0 0 0 0 0 0 0 0 0
46580 - 0 0 0 0 0 0 0 0 0 0 0 0
46581 - 0 0 0 0 0 0 0 0 0 0 0 0
46582 - 0 0 0 0 0 0 0 0 0 14 14 14
46583 - 42 42 42 90 90 90 22 22 22 2 2 6
46584 - 42 42 42 2 2 6 18 18 18 218 218 218
46585 -253 253 253 253 253 253 253 253 253 253 253 253
46586 -253 253 253 253 253 253 253 253 253 253 253 253
46587 -253 253 253 253 253 253 253 253 253 253 253 253
46588 -253 253 253 253 253 253 253 253 253 253 253 253
46589 -253 253 253 253 253 253 253 253 253 253 253 253
46590 -253 253 253 253 253 253 250 250 250 221 221 221
46591 -218 218 218 101 101 101 2 2 6 14 14 14
46592 - 18 18 18 38 38 38 10 10 10 2 2 6
46593 - 2 2 6 2 2 6 2 2 6 78 78 78
46594 - 58 58 58 22 22 22 6 6 6 0 0 0
46595 - 0 0 0 0 0 0 0 0 0 0 0 0
46596 - 0 0 0 0 0 0 0 0 0 0 0 0
46597 - 0 0 0 0 0 0 0 0 0 0 0 0
46598 - 0 0 0 0 0 0 0 0 0 0 0 0
46599 - 0 0 0 0 0 0 0 0 0 0 0 0
46600 - 0 0 0 0 0 0 0 0 0 0 0 0
46601 - 0 0 0 0 0 0 0 0 0 0 0 0
46602 - 0 0 0 0 0 0 6 6 6 18 18 18
46603 - 54 54 54 82 82 82 2 2 6 26 26 26
46604 - 22 22 22 2 2 6 123 123 123 253 253 253
46605 -253 253 253 253 253 253 253 253 253 253 253 253
46606 -253 253 253 253 253 253 253 253 253 253 253 253
46607 -253 253 253 253 253 253 253 253 253 253 253 253
46608 -253 253 253 253 253 253 253 253 253 253 253 253
46609 -253 253 253 253 253 253 253 253 253 253 253 253
46610 -253 253 253 253 253 253 253 253 253 250 250 250
46611 -238 238 238 198 198 198 6 6 6 38 38 38
46612 - 58 58 58 26 26 26 38 38 38 2 2 6
46613 - 2 2 6 2 2 6 2 2 6 46 46 46
46614 - 78 78 78 30 30 30 10 10 10 0 0 0
46615 - 0 0 0 0 0 0 0 0 0 0 0 0
46616 - 0 0 0 0 0 0 0 0 0 0 0 0
46617 - 0 0 0 0 0 0 0 0 0 0 0 0
46618 - 0 0 0 0 0 0 0 0 0 0 0 0
46619 - 0 0 0 0 0 0 0 0 0 0 0 0
46620 - 0 0 0 0 0 0 0 0 0 0 0 0
46621 - 0 0 0 0 0 0 0 0 0 0 0 0
46622 - 0 0 0 0 0 0 10 10 10 30 30 30
46623 - 74 74 74 58 58 58 2 2 6 42 42 42
46624 - 2 2 6 22 22 22 231 231 231 253 253 253
46625 -253 253 253 253 253 253 253 253 253 253 253 253
46626 -253 253 253 253 253 253 253 253 253 250 250 250
46627 -253 253 253 253 253 253 253 253 253 253 253 253
46628 -253 253 253 253 253 253 253 253 253 253 253 253
46629 -253 253 253 253 253 253 253 253 253 253 253 253
46630 -253 253 253 253 253 253 253 253 253 253 253 253
46631 -253 253 253 246 246 246 46 46 46 38 38 38
46632 - 42 42 42 14 14 14 38 38 38 14 14 14
46633 - 2 2 6 2 2 6 2 2 6 6 6 6
46634 - 86 86 86 46 46 46 14 14 14 0 0 0
46635 - 0 0 0 0 0 0 0 0 0 0 0 0
46636 - 0 0 0 0 0 0 0 0 0 0 0 0
46637 - 0 0 0 0 0 0 0 0 0 0 0 0
46638 - 0 0 0 0 0 0 0 0 0 0 0 0
46639 - 0 0 0 0 0 0 0 0 0 0 0 0
46640 - 0 0 0 0 0 0 0 0 0 0 0 0
46641 - 0 0 0 0 0 0 0 0 0 0 0 0
46642 - 0 0 0 6 6 6 14 14 14 42 42 42
46643 - 90 90 90 18 18 18 18 18 18 26 26 26
46644 - 2 2 6 116 116 116 253 253 253 253 253 253
46645 -253 253 253 253 253 253 253 253 253 253 253 253
46646 -253 253 253 253 253 253 250 250 250 238 238 238
46647 -253 253 253 253 253 253 253 253 253 253 253 253
46648 -253 253 253 253 253 253 253 253 253 253 253 253
46649 -253 253 253 253 253 253 253 253 253 253 253 253
46650 -253 253 253 253 253 253 253 253 253 253 253 253
46651 -253 253 253 253 253 253 94 94 94 6 6 6
46652 - 2 2 6 2 2 6 10 10 10 34 34 34
46653 - 2 2 6 2 2 6 2 2 6 2 2 6
46654 - 74 74 74 58 58 58 22 22 22 6 6 6
46655 - 0 0 0 0 0 0 0 0 0 0 0 0
46656 - 0 0 0 0 0 0 0 0 0 0 0 0
46657 - 0 0 0 0 0 0 0 0 0 0 0 0
46658 - 0 0 0 0 0 0 0 0 0 0 0 0
46659 - 0 0 0 0 0 0 0 0 0 0 0 0
46660 - 0 0 0 0 0 0 0 0 0 0 0 0
46661 - 0 0 0 0 0 0 0 0 0 0 0 0
46662 - 0 0 0 10 10 10 26 26 26 66 66 66
46663 - 82 82 82 2 2 6 38 38 38 6 6 6
46664 - 14 14 14 210 210 210 253 253 253 253 253 253
46665 -253 253 253 253 253 253 253 253 253 253 253 253
46666 -253 253 253 253 253 253 246 246 246 242 242 242
46667 -253 253 253 253 253 253 253 253 253 253 253 253
46668 -253 253 253 253 253 253 253 253 253 253 253 253
46669 -253 253 253 253 253 253 253 253 253 253 253 253
46670 -253 253 253 253 253 253 253 253 253 253 253 253
46671 -253 253 253 253 253 253 144 144 144 2 2 6
46672 - 2 2 6 2 2 6 2 2 6 46 46 46
46673 - 2 2 6 2 2 6 2 2 6 2 2 6
46674 - 42 42 42 74 74 74 30 30 30 10 10 10
46675 - 0 0 0 0 0 0 0 0 0 0 0 0
46676 - 0 0 0 0 0 0 0 0 0 0 0 0
46677 - 0 0 0 0 0 0 0 0 0 0 0 0
46678 - 0 0 0 0 0 0 0 0 0 0 0 0
46679 - 0 0 0 0 0 0 0 0 0 0 0 0
46680 - 0 0 0 0 0 0 0 0 0 0 0 0
46681 - 0 0 0 0 0 0 0 0 0 0 0 0
46682 - 6 6 6 14 14 14 42 42 42 90 90 90
46683 - 26 26 26 6 6 6 42 42 42 2 2 6
46684 - 74 74 74 250 250 250 253 253 253 253 253 253
46685 -253 253 253 253 253 253 253 253 253 253 253 253
46686 -253 253 253 253 253 253 242 242 242 242 242 242
46687 -253 253 253 253 253 253 253 253 253 253 253 253
46688 -253 253 253 253 253 253 253 253 253 253 253 253
46689 -253 253 253 253 253 253 253 253 253 253 253 253
46690 -253 253 253 253 253 253 253 253 253 253 253 253
46691 -253 253 253 253 253 253 182 182 182 2 2 6
46692 - 2 2 6 2 2 6 2 2 6 46 46 46
46693 - 2 2 6 2 2 6 2 2 6 2 2 6
46694 - 10 10 10 86 86 86 38 38 38 10 10 10
46695 - 0 0 0 0 0 0 0 0 0 0 0 0
46696 - 0 0 0 0 0 0 0 0 0 0 0 0
46697 - 0 0 0 0 0 0 0 0 0 0 0 0
46698 - 0 0 0 0 0 0 0 0 0 0 0 0
46699 - 0 0 0 0 0 0 0 0 0 0 0 0
46700 - 0 0 0 0 0 0 0 0 0 0 0 0
46701 - 0 0 0 0 0 0 0 0 0 0 0 0
46702 - 10 10 10 26 26 26 66 66 66 82 82 82
46703 - 2 2 6 22 22 22 18 18 18 2 2 6
46704 -149 149 149 253 253 253 253 253 253 253 253 253
46705 -253 253 253 253 253 253 253 253 253 253 253 253
46706 -253 253 253 253 253 253 234 234 234 242 242 242
46707 -253 253 253 253 253 253 253 253 253 253 253 253
46708 -253 253 253 253 253 253 253 253 253 253 253 253
46709 -253 253 253 253 253 253 253 253 253 253 253 253
46710 -253 253 253 253 253 253 253 253 253 253 253 253
46711 -253 253 253 253 253 253 206 206 206 2 2 6
46712 - 2 2 6 2 2 6 2 2 6 38 38 38
46713 - 2 2 6 2 2 6 2 2 6 2 2 6
46714 - 6 6 6 86 86 86 46 46 46 14 14 14
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 - 0 0 0 0 0 0 0 0 0 0 0 0
46718 - 0 0 0 0 0 0 0 0 0 0 0 0
46719 - 0 0 0 0 0 0 0 0 0 0 0 0
46720 - 0 0 0 0 0 0 0 0 0 0 0 0
46721 - 0 0 0 0 0 0 0 0 0 6 6 6
46722 - 18 18 18 46 46 46 86 86 86 18 18 18
46723 - 2 2 6 34 34 34 10 10 10 6 6 6
46724 -210 210 210 253 253 253 253 253 253 253 253 253
46725 -253 253 253 253 253 253 253 253 253 253 253 253
46726 -253 253 253 253 253 253 234 234 234 242 242 242
46727 -253 253 253 253 253 253 253 253 253 253 253 253
46728 -253 253 253 253 253 253 253 253 253 253 253 253
46729 -253 253 253 253 253 253 253 253 253 253 253 253
46730 -253 253 253 253 253 253 253 253 253 253 253 253
46731 -253 253 253 253 253 253 221 221 221 6 6 6
46732 - 2 2 6 2 2 6 6 6 6 30 30 30
46733 - 2 2 6 2 2 6 2 2 6 2 2 6
46734 - 2 2 6 82 82 82 54 54 54 18 18 18
46735 - 6 6 6 0 0 0 0 0 0 0 0 0
46736 - 0 0 0 0 0 0 0 0 0 0 0 0
46737 - 0 0 0 0 0 0 0 0 0 0 0 0
46738 - 0 0 0 0 0 0 0 0 0 0 0 0
46739 - 0 0 0 0 0 0 0 0 0 0 0 0
46740 - 0 0 0 0 0 0 0 0 0 0 0 0
46741 - 0 0 0 0 0 0 0 0 0 10 10 10
46742 - 26 26 26 66 66 66 62 62 62 2 2 6
46743 - 2 2 6 38 38 38 10 10 10 26 26 26
46744 -238 238 238 253 253 253 253 253 253 253 253 253
46745 -253 253 253 253 253 253 253 253 253 253 253 253
46746 -253 253 253 253 253 253 231 231 231 238 238 238
46747 -253 253 253 253 253 253 253 253 253 253 253 253
46748 -253 253 253 253 253 253 253 253 253 253 253 253
46749 -253 253 253 253 253 253 253 253 253 253 253 253
46750 -253 253 253 253 253 253 253 253 253 253 253 253
46751 -253 253 253 253 253 253 231 231 231 6 6 6
46752 - 2 2 6 2 2 6 10 10 10 30 30 30
46753 - 2 2 6 2 2 6 2 2 6 2 2 6
46754 - 2 2 6 66 66 66 58 58 58 22 22 22
46755 - 6 6 6 0 0 0 0 0 0 0 0 0
46756 - 0 0 0 0 0 0 0 0 0 0 0 0
46757 - 0 0 0 0 0 0 0 0 0 0 0 0
46758 - 0 0 0 0 0 0 0 0 0 0 0 0
46759 - 0 0 0 0 0 0 0 0 0 0 0 0
46760 - 0 0 0 0 0 0 0 0 0 0 0 0
46761 - 0 0 0 0 0 0 0 0 0 10 10 10
46762 - 38 38 38 78 78 78 6 6 6 2 2 6
46763 - 2 2 6 46 46 46 14 14 14 42 42 42
46764 -246 246 246 253 253 253 253 253 253 253 253 253
46765 -253 253 253 253 253 253 253 253 253 253 253 253
46766 -253 253 253 253 253 253 231 231 231 242 242 242
46767 -253 253 253 253 253 253 253 253 253 253 253 253
46768 -253 253 253 253 253 253 253 253 253 253 253 253
46769 -253 253 253 253 253 253 253 253 253 253 253 253
46770 -253 253 253 253 253 253 253 253 253 253 253 253
46771 -253 253 253 253 253 253 234 234 234 10 10 10
46772 - 2 2 6 2 2 6 22 22 22 14 14 14
46773 - 2 2 6 2 2 6 2 2 6 2 2 6
46774 - 2 2 6 66 66 66 62 62 62 22 22 22
46775 - 6 6 6 0 0 0 0 0 0 0 0 0
46776 - 0 0 0 0 0 0 0 0 0 0 0 0
46777 - 0 0 0 0 0 0 0 0 0 0 0 0
46778 - 0 0 0 0 0 0 0 0 0 0 0 0
46779 - 0 0 0 0 0 0 0 0 0 0 0 0
46780 - 0 0 0 0 0 0 0 0 0 0 0 0
46781 - 0 0 0 0 0 0 6 6 6 18 18 18
46782 - 50 50 50 74 74 74 2 2 6 2 2 6
46783 - 14 14 14 70 70 70 34 34 34 62 62 62
46784 -250 250 250 253 253 253 253 253 253 253 253 253
46785 -253 253 253 253 253 253 253 253 253 253 253 253
46786 -253 253 253 253 253 253 231 231 231 246 246 246
46787 -253 253 253 253 253 253 253 253 253 253 253 253
46788 -253 253 253 253 253 253 253 253 253 253 253 253
46789 -253 253 253 253 253 253 253 253 253 253 253 253
46790 -253 253 253 253 253 253 253 253 253 253 253 253
46791 -253 253 253 253 253 253 234 234 234 14 14 14
46792 - 2 2 6 2 2 6 30 30 30 2 2 6
46793 - 2 2 6 2 2 6 2 2 6 2 2 6
46794 - 2 2 6 66 66 66 62 62 62 22 22 22
46795 - 6 6 6 0 0 0 0 0 0 0 0 0
46796 - 0 0 0 0 0 0 0 0 0 0 0 0
46797 - 0 0 0 0 0 0 0 0 0 0 0 0
46798 - 0 0 0 0 0 0 0 0 0 0 0 0
46799 - 0 0 0 0 0 0 0 0 0 0 0 0
46800 - 0 0 0 0 0 0 0 0 0 0 0 0
46801 - 0 0 0 0 0 0 6 6 6 18 18 18
46802 - 54 54 54 62 62 62 2 2 6 2 2 6
46803 - 2 2 6 30 30 30 46 46 46 70 70 70
46804 -250 250 250 253 253 253 253 253 253 253 253 253
46805 -253 253 253 253 253 253 253 253 253 253 253 253
46806 -253 253 253 253 253 253 231 231 231 246 246 246
46807 -253 253 253 253 253 253 253 253 253 253 253 253
46808 -253 253 253 253 253 253 253 253 253 253 253 253
46809 -253 253 253 253 253 253 253 253 253 253 253 253
46810 -253 253 253 253 253 253 253 253 253 253 253 253
46811 -253 253 253 253 253 253 226 226 226 10 10 10
46812 - 2 2 6 6 6 6 30 30 30 2 2 6
46813 - 2 2 6 2 2 6 2 2 6 2 2 6
46814 - 2 2 6 66 66 66 58 58 58 22 22 22
46815 - 6 6 6 0 0 0 0 0 0 0 0 0
46816 - 0 0 0 0 0 0 0 0 0 0 0 0
46817 - 0 0 0 0 0 0 0 0 0 0 0 0
46818 - 0 0 0 0 0 0 0 0 0 0 0 0
46819 - 0 0 0 0 0 0 0 0 0 0 0 0
46820 - 0 0 0 0 0 0 0 0 0 0 0 0
46821 - 0 0 0 0 0 0 6 6 6 22 22 22
46822 - 58 58 58 62 62 62 2 2 6 2 2 6
46823 - 2 2 6 2 2 6 30 30 30 78 78 78
46824 -250 250 250 253 253 253 253 253 253 253 253 253
46825 -253 253 253 253 253 253 253 253 253 253 253 253
46826 -253 253 253 253 253 253 231 231 231 246 246 246
46827 -253 253 253 253 253 253 253 253 253 253 253 253
46828 -253 253 253 253 253 253 253 253 253 253 253 253
46829 -253 253 253 253 253 253 253 253 253 253 253 253
46830 -253 253 253 253 253 253 253 253 253 253 253 253
46831 -253 253 253 253 253 253 206 206 206 2 2 6
46832 - 22 22 22 34 34 34 18 14 6 22 22 22
46833 - 26 26 26 18 18 18 6 6 6 2 2 6
46834 - 2 2 6 82 82 82 54 54 54 18 18 18
46835 - 6 6 6 0 0 0 0 0 0 0 0 0
46836 - 0 0 0 0 0 0 0 0 0 0 0 0
46837 - 0 0 0 0 0 0 0 0 0 0 0 0
46838 - 0 0 0 0 0 0 0 0 0 0 0 0
46839 - 0 0 0 0 0 0 0 0 0 0 0 0
46840 - 0 0 0 0 0 0 0 0 0 0 0 0
46841 - 0 0 0 0 0 0 6 6 6 26 26 26
46842 - 62 62 62 106 106 106 74 54 14 185 133 11
46843 -210 162 10 121 92 8 6 6 6 62 62 62
46844 -238 238 238 253 253 253 253 253 253 253 253 253
46845 -253 253 253 253 253 253 253 253 253 253 253 253
46846 -253 253 253 253 253 253 231 231 231 246 246 246
46847 -253 253 253 253 253 253 253 253 253 253 253 253
46848 -253 253 253 253 253 253 253 253 253 253 253 253
46849 -253 253 253 253 253 253 253 253 253 253 253 253
46850 -253 253 253 253 253 253 253 253 253 253 253 253
46851 -253 253 253 253 253 253 158 158 158 18 18 18
46852 - 14 14 14 2 2 6 2 2 6 2 2 6
46853 - 6 6 6 18 18 18 66 66 66 38 38 38
46854 - 6 6 6 94 94 94 50 50 50 18 18 18
46855 - 6 6 6 0 0 0 0 0 0 0 0 0
46856 - 0 0 0 0 0 0 0 0 0 0 0 0
46857 - 0 0 0 0 0 0 0 0 0 0 0 0
46858 - 0 0 0 0 0 0 0 0 0 0 0 0
46859 - 0 0 0 0 0 0 0 0 0 0 0 0
46860 - 0 0 0 0 0 0 0 0 0 6 6 6
46861 - 10 10 10 10 10 10 18 18 18 38 38 38
46862 - 78 78 78 142 134 106 216 158 10 242 186 14
46863 -246 190 14 246 190 14 156 118 10 10 10 10
46864 - 90 90 90 238 238 238 253 253 253 253 253 253
46865 -253 253 253 253 253 253 253 253 253 253 253 253
46866 -253 253 253 253 253 253 231 231 231 250 250 250
46867 -253 253 253 253 253 253 253 253 253 253 253 253
46868 -253 253 253 253 253 253 253 253 253 253 253 253
46869 -253 253 253 253 253 253 253 253 253 253 253 253
46870 -253 253 253 253 253 253 253 253 253 246 230 190
46871 -238 204 91 238 204 91 181 142 44 37 26 9
46872 - 2 2 6 2 2 6 2 2 6 2 2 6
46873 - 2 2 6 2 2 6 38 38 38 46 46 46
46874 - 26 26 26 106 106 106 54 54 54 18 18 18
46875 - 6 6 6 0 0 0 0 0 0 0 0 0
46876 - 0 0 0 0 0 0 0 0 0 0 0 0
46877 - 0 0 0 0 0 0 0 0 0 0 0 0
46878 - 0 0 0 0 0 0 0 0 0 0 0 0
46879 - 0 0 0 0 0 0 0 0 0 0 0 0
46880 - 0 0 0 6 6 6 14 14 14 22 22 22
46881 - 30 30 30 38 38 38 50 50 50 70 70 70
46882 -106 106 106 190 142 34 226 170 11 242 186 14
46883 -246 190 14 246 190 14 246 190 14 154 114 10
46884 - 6 6 6 74 74 74 226 226 226 253 253 253
46885 -253 253 253 253 253 253 253 253 253 253 253 253
46886 -253 253 253 253 253 253 231 231 231 250 250 250
46887 -253 253 253 253 253 253 253 253 253 253 253 253
46888 -253 253 253 253 253 253 253 253 253 253 253 253
46889 -253 253 253 253 253 253 253 253 253 253 253 253
46890 -253 253 253 253 253 253 253 253 253 228 184 62
46891 -241 196 14 241 208 19 232 195 16 38 30 10
46892 - 2 2 6 2 2 6 2 2 6 2 2 6
46893 - 2 2 6 6 6 6 30 30 30 26 26 26
46894 -203 166 17 154 142 90 66 66 66 26 26 26
46895 - 6 6 6 0 0 0 0 0 0 0 0 0
46896 - 0 0 0 0 0 0 0 0 0 0 0 0
46897 - 0 0 0 0 0 0 0 0 0 0 0 0
46898 - 0 0 0 0 0 0 0 0 0 0 0 0
46899 - 0 0 0 0 0 0 0 0 0 0 0 0
46900 - 6 6 6 18 18 18 38 38 38 58 58 58
46901 - 78 78 78 86 86 86 101 101 101 123 123 123
46902 -175 146 61 210 150 10 234 174 13 246 186 14
46903 -246 190 14 246 190 14 246 190 14 238 190 10
46904 -102 78 10 2 2 6 46 46 46 198 198 198
46905 -253 253 253 253 253 253 253 253 253 253 253 253
46906 -253 253 253 253 253 253 234 234 234 242 242 242
46907 -253 253 253 253 253 253 253 253 253 253 253 253
46908 -253 253 253 253 253 253 253 253 253 253 253 253
46909 -253 253 253 253 253 253 253 253 253 253 253 253
46910 -253 253 253 253 253 253 253 253 253 224 178 62
46911 -242 186 14 241 196 14 210 166 10 22 18 6
46912 - 2 2 6 2 2 6 2 2 6 2 2 6
46913 - 2 2 6 2 2 6 6 6 6 121 92 8
46914 -238 202 15 232 195 16 82 82 82 34 34 34
46915 - 10 10 10 0 0 0 0 0 0 0 0 0
46916 - 0 0 0 0 0 0 0 0 0 0 0 0
46917 - 0 0 0 0 0 0 0 0 0 0 0 0
46918 - 0 0 0 0 0 0 0 0 0 0 0 0
46919 - 0 0 0 0 0 0 0 0 0 0 0 0
46920 - 14 14 14 38 38 38 70 70 70 154 122 46
46921 -190 142 34 200 144 11 197 138 11 197 138 11
46922 -213 154 11 226 170 11 242 186 14 246 190 14
46923 -246 190 14 246 190 14 246 190 14 246 190 14
46924 -225 175 15 46 32 6 2 2 6 22 22 22
46925 -158 158 158 250 250 250 253 253 253 253 253 253
46926 -253 253 253 253 253 253 253 253 253 253 253 253
46927 -253 253 253 253 253 253 253 253 253 253 253 253
46928 -253 253 253 253 253 253 253 253 253 253 253 253
46929 -253 253 253 253 253 253 253 253 253 253 253 253
46930 -253 253 253 250 250 250 242 242 242 224 178 62
46931 -239 182 13 236 186 11 213 154 11 46 32 6
46932 - 2 2 6 2 2 6 2 2 6 2 2 6
46933 - 2 2 6 2 2 6 61 42 6 225 175 15
46934 -238 190 10 236 186 11 112 100 78 42 42 42
46935 - 14 14 14 0 0 0 0 0 0 0 0 0
46936 - 0 0 0 0 0 0 0 0 0 0 0 0
46937 - 0 0 0 0 0 0 0 0 0 0 0 0
46938 - 0 0 0 0 0 0 0 0 0 0 0 0
46939 - 0 0 0 0 0 0 0 0 0 6 6 6
46940 - 22 22 22 54 54 54 154 122 46 213 154 11
46941 -226 170 11 230 174 11 226 170 11 226 170 11
46942 -236 178 12 242 186 14 246 190 14 246 190 14
46943 -246 190 14 246 190 14 246 190 14 246 190 14
46944 -241 196 14 184 144 12 10 10 10 2 2 6
46945 - 6 6 6 116 116 116 242 242 242 253 253 253
46946 -253 253 253 253 253 253 253 253 253 253 253 253
46947 -253 253 253 253 253 253 253 253 253 253 253 253
46948 -253 253 253 253 253 253 253 253 253 253 253 253
46949 -253 253 253 253 253 253 253 253 253 253 253 253
46950 -253 253 253 231 231 231 198 198 198 214 170 54
46951 -236 178 12 236 178 12 210 150 10 137 92 6
46952 - 18 14 6 2 2 6 2 2 6 2 2 6
46953 - 6 6 6 70 47 6 200 144 11 236 178 12
46954 -239 182 13 239 182 13 124 112 88 58 58 58
46955 - 22 22 22 6 6 6 0 0 0 0 0 0
46956 - 0 0 0 0 0 0 0 0 0 0 0 0
46957 - 0 0 0 0 0 0 0 0 0 0 0 0
46958 - 0 0 0 0 0 0 0 0 0 0 0 0
46959 - 0 0 0 0 0 0 0 0 0 10 10 10
46960 - 30 30 30 70 70 70 180 133 36 226 170 11
46961 -239 182 13 242 186 14 242 186 14 246 186 14
46962 -246 190 14 246 190 14 246 190 14 246 190 14
46963 -246 190 14 246 190 14 246 190 14 246 190 14
46964 -246 190 14 232 195 16 98 70 6 2 2 6
46965 - 2 2 6 2 2 6 66 66 66 221 221 221
46966 -253 253 253 253 253 253 253 253 253 253 253 253
46967 -253 253 253 253 253 253 253 253 253 253 253 253
46968 -253 253 253 253 253 253 253 253 253 253 253 253
46969 -253 253 253 253 253 253 253 253 253 253 253 253
46970 -253 253 253 206 206 206 198 198 198 214 166 58
46971 -230 174 11 230 174 11 216 158 10 192 133 9
46972 -163 110 8 116 81 8 102 78 10 116 81 8
46973 -167 114 7 197 138 11 226 170 11 239 182 13
46974 -242 186 14 242 186 14 162 146 94 78 78 78
46975 - 34 34 34 14 14 14 6 6 6 0 0 0
46976 - 0 0 0 0 0 0 0 0 0 0 0 0
46977 - 0 0 0 0 0 0 0 0 0 0 0 0
46978 - 0 0 0 0 0 0 0 0 0 0 0 0
46979 - 0 0 0 0 0 0 0 0 0 6 6 6
46980 - 30 30 30 78 78 78 190 142 34 226 170 11
46981 -239 182 13 246 190 14 246 190 14 246 190 14
46982 -246 190 14 246 190 14 246 190 14 246 190 14
46983 -246 190 14 246 190 14 246 190 14 246 190 14
46984 -246 190 14 241 196 14 203 166 17 22 18 6
46985 - 2 2 6 2 2 6 2 2 6 38 38 38
46986 -218 218 218 253 253 253 253 253 253 253 253 253
46987 -253 253 253 253 253 253 253 253 253 253 253 253
46988 -253 253 253 253 253 253 253 253 253 253 253 253
46989 -253 253 253 253 253 253 253 253 253 253 253 253
46990 -250 250 250 206 206 206 198 198 198 202 162 69
46991 -226 170 11 236 178 12 224 166 10 210 150 10
46992 -200 144 11 197 138 11 192 133 9 197 138 11
46993 -210 150 10 226 170 11 242 186 14 246 190 14
46994 -246 190 14 246 186 14 225 175 15 124 112 88
46995 - 62 62 62 30 30 30 14 14 14 6 6 6
46996 - 0 0 0 0 0 0 0 0 0 0 0 0
46997 - 0 0 0 0 0 0 0 0 0 0 0 0
46998 - 0 0 0 0 0 0 0 0 0 0 0 0
46999 - 0 0 0 0 0 0 0 0 0 10 10 10
47000 - 30 30 30 78 78 78 174 135 50 224 166 10
47001 -239 182 13 246 190 14 246 190 14 246 190 14
47002 -246 190 14 246 190 14 246 190 14 246 190 14
47003 -246 190 14 246 190 14 246 190 14 246 190 14
47004 -246 190 14 246 190 14 241 196 14 139 102 15
47005 - 2 2 6 2 2 6 2 2 6 2 2 6
47006 - 78 78 78 250 250 250 253 253 253 253 253 253
47007 -253 253 253 253 253 253 253 253 253 253 253 253
47008 -253 253 253 253 253 253 253 253 253 253 253 253
47009 -253 253 253 253 253 253 253 253 253 253 253 253
47010 -250 250 250 214 214 214 198 198 198 190 150 46
47011 -219 162 10 236 178 12 234 174 13 224 166 10
47012 -216 158 10 213 154 11 213 154 11 216 158 10
47013 -226 170 11 239 182 13 246 190 14 246 190 14
47014 -246 190 14 246 190 14 242 186 14 206 162 42
47015 -101 101 101 58 58 58 30 30 30 14 14 14
47016 - 6 6 6 0 0 0 0 0 0 0 0 0
47017 - 0 0 0 0 0 0 0 0 0 0 0 0
47018 - 0 0 0 0 0 0 0 0 0 0 0 0
47019 - 0 0 0 0 0 0 0 0 0 10 10 10
47020 - 30 30 30 74 74 74 174 135 50 216 158 10
47021 -236 178 12 246 190 14 246 190 14 246 190 14
47022 -246 190 14 246 190 14 246 190 14 246 190 14
47023 -246 190 14 246 190 14 246 190 14 246 190 14
47024 -246 190 14 246 190 14 241 196 14 226 184 13
47025 - 61 42 6 2 2 6 2 2 6 2 2 6
47026 - 22 22 22 238 238 238 253 253 253 253 253 253
47027 -253 253 253 253 253 253 253 253 253 253 253 253
47028 -253 253 253 253 253 253 253 253 253 253 253 253
47029 -253 253 253 253 253 253 253 253 253 253 253 253
47030 -253 253 253 226 226 226 187 187 187 180 133 36
47031 -216 158 10 236 178 12 239 182 13 236 178 12
47032 -230 174 11 226 170 11 226 170 11 230 174 11
47033 -236 178 12 242 186 14 246 190 14 246 190 14
47034 -246 190 14 246 190 14 246 186 14 239 182 13
47035 -206 162 42 106 106 106 66 66 66 34 34 34
47036 - 14 14 14 6 6 6 0 0 0 0 0 0
47037 - 0 0 0 0 0 0 0 0 0 0 0 0
47038 - 0 0 0 0 0 0 0 0 0 0 0 0
47039 - 0 0 0 0 0 0 0 0 0 6 6 6
47040 - 26 26 26 70 70 70 163 133 67 213 154 11
47041 -236 178 12 246 190 14 246 190 14 246 190 14
47042 -246 190 14 246 190 14 246 190 14 246 190 14
47043 -246 190 14 246 190 14 246 190 14 246 190 14
47044 -246 190 14 246 190 14 246 190 14 241 196 14
47045 -190 146 13 18 14 6 2 2 6 2 2 6
47046 - 46 46 46 246 246 246 253 253 253 253 253 253
47047 -253 253 253 253 253 253 253 253 253 253 253 253
47048 -253 253 253 253 253 253 253 253 253 253 253 253
47049 -253 253 253 253 253 253 253 253 253 253 253 253
47050 -253 253 253 221 221 221 86 86 86 156 107 11
47051 -216 158 10 236 178 12 242 186 14 246 186 14
47052 -242 186 14 239 182 13 239 182 13 242 186 14
47053 -242 186 14 246 186 14 246 190 14 246 190 14
47054 -246 190 14 246 190 14 246 190 14 246 190 14
47055 -242 186 14 225 175 15 142 122 72 66 66 66
47056 - 30 30 30 10 10 10 0 0 0 0 0 0
47057 - 0 0 0 0 0 0 0 0 0 0 0 0
47058 - 0 0 0 0 0 0 0 0 0 0 0 0
47059 - 0 0 0 0 0 0 0 0 0 6 6 6
47060 - 26 26 26 70 70 70 163 133 67 210 150 10
47061 -236 178 12 246 190 14 246 190 14 246 190 14
47062 -246 190 14 246 190 14 246 190 14 246 190 14
47063 -246 190 14 246 190 14 246 190 14 246 190 14
47064 -246 190 14 246 190 14 246 190 14 246 190 14
47065 -232 195 16 121 92 8 34 34 34 106 106 106
47066 -221 221 221 253 253 253 253 253 253 253 253 253
47067 -253 253 253 253 253 253 253 253 253 253 253 253
47068 -253 253 253 253 253 253 253 253 253 253 253 253
47069 -253 253 253 253 253 253 253 253 253 253 253 253
47070 -242 242 242 82 82 82 18 14 6 163 110 8
47071 -216 158 10 236 178 12 242 186 14 246 190 14
47072 -246 190 14 246 190 14 246 190 14 246 190 14
47073 -246 190 14 246 190 14 246 190 14 246 190 14
47074 -246 190 14 246 190 14 246 190 14 246 190 14
47075 -246 190 14 246 190 14 242 186 14 163 133 67
47076 - 46 46 46 18 18 18 6 6 6 0 0 0
47077 - 0 0 0 0 0 0 0 0 0 0 0 0
47078 - 0 0 0 0 0 0 0 0 0 0 0 0
47079 - 0 0 0 0 0 0 0 0 0 10 10 10
47080 - 30 30 30 78 78 78 163 133 67 210 150 10
47081 -236 178 12 246 186 14 246 190 14 246 190 14
47082 -246 190 14 246 190 14 246 190 14 246 190 14
47083 -246 190 14 246 190 14 246 190 14 246 190 14
47084 -246 190 14 246 190 14 246 190 14 246 190 14
47085 -241 196 14 215 174 15 190 178 144 253 253 253
47086 -253 253 253 253 253 253 253 253 253 253 253 253
47087 -253 253 253 253 253 253 253 253 253 253 253 253
47088 -253 253 253 253 253 253 253 253 253 253 253 253
47089 -253 253 253 253 253 253 253 253 253 218 218 218
47090 - 58 58 58 2 2 6 22 18 6 167 114 7
47091 -216 158 10 236 178 12 246 186 14 246 190 14
47092 -246 190 14 246 190 14 246 190 14 246 190 14
47093 -246 190 14 246 190 14 246 190 14 246 190 14
47094 -246 190 14 246 190 14 246 190 14 246 190 14
47095 -246 190 14 246 186 14 242 186 14 190 150 46
47096 - 54 54 54 22 22 22 6 6 6 0 0 0
47097 - 0 0 0 0 0 0 0 0 0 0 0 0
47098 - 0 0 0 0 0 0 0 0 0 0 0 0
47099 - 0 0 0 0 0 0 0 0 0 14 14 14
47100 - 38 38 38 86 86 86 180 133 36 213 154 11
47101 -236 178 12 246 186 14 246 190 14 246 190 14
47102 -246 190 14 246 190 14 246 190 14 246 190 14
47103 -246 190 14 246 190 14 246 190 14 246 190 14
47104 -246 190 14 246 190 14 246 190 14 246 190 14
47105 -246 190 14 232 195 16 190 146 13 214 214 214
47106 -253 253 253 253 253 253 253 253 253 253 253 253
47107 -253 253 253 253 253 253 253 253 253 253 253 253
47108 -253 253 253 253 253 253 253 253 253 253 253 253
47109 -253 253 253 250 250 250 170 170 170 26 26 26
47110 - 2 2 6 2 2 6 37 26 9 163 110 8
47111 -219 162 10 239 182 13 246 186 14 246 190 14
47112 -246 190 14 246 190 14 246 190 14 246 190 14
47113 -246 190 14 246 190 14 246 190 14 246 190 14
47114 -246 190 14 246 190 14 246 190 14 246 190 14
47115 -246 186 14 236 178 12 224 166 10 142 122 72
47116 - 46 46 46 18 18 18 6 6 6 0 0 0
47117 - 0 0 0 0 0 0 0 0 0 0 0 0
47118 - 0 0 0 0 0 0 0 0 0 0 0 0
47119 - 0 0 0 0 0 0 6 6 6 18 18 18
47120 - 50 50 50 109 106 95 192 133 9 224 166 10
47121 -242 186 14 246 190 14 246 190 14 246 190 14
47122 -246 190 14 246 190 14 246 190 14 246 190 14
47123 -246 190 14 246 190 14 246 190 14 246 190 14
47124 -246 190 14 246 190 14 246 190 14 246 190 14
47125 -242 186 14 226 184 13 210 162 10 142 110 46
47126 -226 226 226 253 253 253 253 253 253 253 253 253
47127 -253 253 253 253 253 253 253 253 253 253 253 253
47128 -253 253 253 253 253 253 253 253 253 253 253 253
47129 -198 198 198 66 66 66 2 2 6 2 2 6
47130 - 2 2 6 2 2 6 50 34 6 156 107 11
47131 -219 162 10 239 182 13 246 186 14 246 190 14
47132 -246 190 14 246 190 14 246 190 14 246 190 14
47133 -246 190 14 246 190 14 246 190 14 246 190 14
47134 -246 190 14 246 190 14 246 190 14 242 186 14
47135 -234 174 13 213 154 11 154 122 46 66 66 66
47136 - 30 30 30 10 10 10 0 0 0 0 0 0
47137 - 0 0 0 0 0 0 0 0 0 0 0 0
47138 - 0 0 0 0 0 0 0 0 0 0 0 0
47139 - 0 0 0 0 0 0 6 6 6 22 22 22
47140 - 58 58 58 154 121 60 206 145 10 234 174 13
47141 -242 186 14 246 186 14 246 190 14 246 190 14
47142 -246 190 14 246 190 14 246 190 14 246 190 14
47143 -246 190 14 246 190 14 246 190 14 246 190 14
47144 -246 190 14 246 190 14 246 190 14 246 190 14
47145 -246 186 14 236 178 12 210 162 10 163 110 8
47146 - 61 42 6 138 138 138 218 218 218 250 250 250
47147 -253 253 253 253 253 253 253 253 253 250 250 250
47148 -242 242 242 210 210 210 144 144 144 66 66 66
47149 - 6 6 6 2 2 6 2 2 6 2 2 6
47150 - 2 2 6 2 2 6 61 42 6 163 110 8
47151 -216 158 10 236 178 12 246 190 14 246 190 14
47152 -246 190 14 246 190 14 246 190 14 246 190 14
47153 -246 190 14 246 190 14 246 190 14 246 190 14
47154 -246 190 14 239 182 13 230 174 11 216 158 10
47155 -190 142 34 124 112 88 70 70 70 38 38 38
47156 - 18 18 18 6 6 6 0 0 0 0 0 0
47157 - 0 0 0 0 0 0 0 0 0 0 0 0
47158 - 0 0 0 0 0 0 0 0 0 0 0 0
47159 - 0 0 0 0 0 0 6 6 6 22 22 22
47160 - 62 62 62 168 124 44 206 145 10 224 166 10
47161 -236 178 12 239 182 13 242 186 14 242 186 14
47162 -246 186 14 246 190 14 246 190 14 246 190 14
47163 -246 190 14 246 190 14 246 190 14 246 190 14
47164 -246 190 14 246 190 14 246 190 14 246 190 14
47165 -246 190 14 236 178 12 216 158 10 175 118 6
47166 - 80 54 7 2 2 6 6 6 6 30 30 30
47167 - 54 54 54 62 62 62 50 50 50 38 38 38
47168 - 14 14 14 2 2 6 2 2 6 2 2 6
47169 - 2 2 6 2 2 6 2 2 6 2 2 6
47170 - 2 2 6 6 6 6 80 54 7 167 114 7
47171 -213 154 11 236 178 12 246 190 14 246 190 14
47172 -246 190 14 246 190 14 246 190 14 246 190 14
47173 -246 190 14 242 186 14 239 182 13 239 182 13
47174 -230 174 11 210 150 10 174 135 50 124 112 88
47175 - 82 82 82 54 54 54 34 34 34 18 18 18
47176 - 6 6 6 0 0 0 0 0 0 0 0 0
47177 - 0 0 0 0 0 0 0 0 0 0 0 0
47178 - 0 0 0 0 0 0 0 0 0 0 0 0
47179 - 0 0 0 0 0 0 6 6 6 18 18 18
47180 - 50 50 50 158 118 36 192 133 9 200 144 11
47181 -216 158 10 219 162 10 224 166 10 226 170 11
47182 -230 174 11 236 178 12 239 182 13 239 182 13
47183 -242 186 14 246 186 14 246 190 14 246 190 14
47184 -246 190 14 246 190 14 246 190 14 246 190 14
47185 -246 186 14 230 174 11 210 150 10 163 110 8
47186 -104 69 6 10 10 10 2 2 6 2 2 6
47187 - 2 2 6 2 2 6 2 2 6 2 2 6
47188 - 2 2 6 2 2 6 2 2 6 2 2 6
47189 - 2 2 6 2 2 6 2 2 6 2 2 6
47190 - 2 2 6 6 6 6 91 60 6 167 114 7
47191 -206 145 10 230 174 11 242 186 14 246 190 14
47192 -246 190 14 246 190 14 246 186 14 242 186 14
47193 -239 182 13 230 174 11 224 166 10 213 154 11
47194 -180 133 36 124 112 88 86 86 86 58 58 58
47195 - 38 38 38 22 22 22 10 10 10 6 6 6
47196 - 0 0 0 0 0 0 0 0 0 0 0 0
47197 - 0 0 0 0 0 0 0 0 0 0 0 0
47198 - 0 0 0 0 0 0 0 0 0 0 0 0
47199 - 0 0 0 0 0 0 0 0 0 14 14 14
47200 - 34 34 34 70 70 70 138 110 50 158 118 36
47201 -167 114 7 180 123 7 192 133 9 197 138 11
47202 -200 144 11 206 145 10 213 154 11 219 162 10
47203 -224 166 10 230 174 11 239 182 13 242 186 14
47204 -246 186 14 246 186 14 246 186 14 246 186 14
47205 -239 182 13 216 158 10 185 133 11 152 99 6
47206 -104 69 6 18 14 6 2 2 6 2 2 6
47207 - 2 2 6 2 2 6 2 2 6 2 2 6
47208 - 2 2 6 2 2 6 2 2 6 2 2 6
47209 - 2 2 6 2 2 6 2 2 6 2 2 6
47210 - 2 2 6 6 6 6 80 54 7 152 99 6
47211 -192 133 9 219 162 10 236 178 12 239 182 13
47212 -246 186 14 242 186 14 239 182 13 236 178 12
47213 -224 166 10 206 145 10 192 133 9 154 121 60
47214 - 94 94 94 62 62 62 42 42 42 22 22 22
47215 - 14 14 14 6 6 6 0 0 0 0 0 0
47216 - 0 0 0 0 0 0 0 0 0 0 0 0
47217 - 0 0 0 0 0 0 0 0 0 0 0 0
47218 - 0 0 0 0 0 0 0 0 0 0 0 0
47219 - 0 0 0 0 0 0 0 0 0 6 6 6
47220 - 18 18 18 34 34 34 58 58 58 78 78 78
47221 -101 98 89 124 112 88 142 110 46 156 107 11
47222 -163 110 8 167 114 7 175 118 6 180 123 7
47223 -185 133 11 197 138 11 210 150 10 219 162 10
47224 -226 170 11 236 178 12 236 178 12 234 174 13
47225 -219 162 10 197 138 11 163 110 8 130 83 6
47226 - 91 60 6 10 10 10 2 2 6 2 2 6
47227 - 18 18 18 38 38 38 38 38 38 38 38 38
47228 - 38 38 38 38 38 38 38 38 38 38 38 38
47229 - 38 38 38 38 38 38 26 26 26 2 2 6
47230 - 2 2 6 6 6 6 70 47 6 137 92 6
47231 -175 118 6 200 144 11 219 162 10 230 174 11
47232 -234 174 13 230 174 11 219 162 10 210 150 10
47233 -192 133 9 163 110 8 124 112 88 82 82 82
47234 - 50 50 50 30 30 30 14 14 14 6 6 6
47235 - 0 0 0 0 0 0 0 0 0 0 0 0
47236 - 0 0 0 0 0 0 0 0 0 0 0 0
47237 - 0 0 0 0 0 0 0 0 0 0 0 0
47238 - 0 0 0 0 0 0 0 0 0 0 0 0
47239 - 0 0 0 0 0 0 0 0 0 0 0 0
47240 - 6 6 6 14 14 14 22 22 22 34 34 34
47241 - 42 42 42 58 58 58 74 74 74 86 86 86
47242 -101 98 89 122 102 70 130 98 46 121 87 25
47243 -137 92 6 152 99 6 163 110 8 180 123 7
47244 -185 133 11 197 138 11 206 145 10 200 144 11
47245 -180 123 7 156 107 11 130 83 6 104 69 6
47246 - 50 34 6 54 54 54 110 110 110 101 98 89
47247 - 86 86 86 82 82 82 78 78 78 78 78 78
47248 - 78 78 78 78 78 78 78 78 78 78 78 78
47249 - 78 78 78 82 82 82 86 86 86 94 94 94
47250 -106 106 106 101 101 101 86 66 34 124 80 6
47251 -156 107 11 180 123 7 192 133 9 200 144 11
47252 -206 145 10 200 144 11 192 133 9 175 118 6
47253 -139 102 15 109 106 95 70 70 70 42 42 42
47254 - 22 22 22 10 10 10 0 0 0 0 0 0
47255 - 0 0 0 0 0 0 0 0 0 0 0 0
47256 - 0 0 0 0 0 0 0 0 0 0 0 0
47257 - 0 0 0 0 0 0 0 0 0 0 0 0
47258 - 0 0 0 0 0 0 0 0 0 0 0 0
47259 - 0 0 0 0 0 0 0 0 0 0 0 0
47260 - 0 0 0 0 0 0 6 6 6 10 10 10
47261 - 14 14 14 22 22 22 30 30 30 38 38 38
47262 - 50 50 50 62 62 62 74 74 74 90 90 90
47263 -101 98 89 112 100 78 121 87 25 124 80 6
47264 -137 92 6 152 99 6 152 99 6 152 99 6
47265 -138 86 6 124 80 6 98 70 6 86 66 30
47266 -101 98 89 82 82 82 58 58 58 46 46 46
47267 - 38 38 38 34 34 34 34 34 34 34 34 34
47268 - 34 34 34 34 34 34 34 34 34 34 34 34
47269 - 34 34 34 34 34 34 38 38 38 42 42 42
47270 - 54 54 54 82 82 82 94 86 76 91 60 6
47271 -134 86 6 156 107 11 167 114 7 175 118 6
47272 -175 118 6 167 114 7 152 99 6 121 87 25
47273 -101 98 89 62 62 62 34 34 34 18 18 18
47274 - 6 6 6 0 0 0 0 0 0 0 0 0
47275 - 0 0 0 0 0 0 0 0 0 0 0 0
47276 - 0 0 0 0 0 0 0 0 0 0 0 0
47277 - 0 0 0 0 0 0 0 0 0 0 0 0
47278 - 0 0 0 0 0 0 0 0 0 0 0 0
47279 - 0 0 0 0 0 0 0 0 0 0 0 0
47280 - 0 0 0 0 0 0 0 0 0 0 0 0
47281 - 0 0 0 6 6 6 6 6 6 10 10 10
47282 - 18 18 18 22 22 22 30 30 30 42 42 42
47283 - 50 50 50 66 66 66 86 86 86 101 98 89
47284 -106 86 58 98 70 6 104 69 6 104 69 6
47285 -104 69 6 91 60 6 82 62 34 90 90 90
47286 - 62 62 62 38 38 38 22 22 22 14 14 14
47287 - 10 10 10 10 10 10 10 10 10 10 10 10
47288 - 10 10 10 10 10 10 6 6 6 10 10 10
47289 - 10 10 10 10 10 10 10 10 10 14 14 14
47290 - 22 22 22 42 42 42 70 70 70 89 81 66
47291 - 80 54 7 104 69 6 124 80 6 137 92 6
47292 -134 86 6 116 81 8 100 82 52 86 86 86
47293 - 58 58 58 30 30 30 14 14 14 6 6 6
47294 - 0 0 0 0 0 0 0 0 0 0 0 0
47295 - 0 0 0 0 0 0 0 0 0 0 0 0
47296 - 0 0 0 0 0 0 0 0 0 0 0 0
47297 - 0 0 0 0 0 0 0 0 0 0 0 0
47298 - 0 0 0 0 0 0 0 0 0 0 0 0
47299 - 0 0 0 0 0 0 0 0 0 0 0 0
47300 - 0 0 0 0 0 0 0 0 0 0 0 0
47301 - 0 0 0 0 0 0 0 0 0 0 0 0
47302 - 0 0 0 6 6 6 10 10 10 14 14 14
47303 - 18 18 18 26 26 26 38 38 38 54 54 54
47304 - 70 70 70 86 86 86 94 86 76 89 81 66
47305 - 89 81 66 86 86 86 74 74 74 50 50 50
47306 - 30 30 30 14 14 14 6 6 6 0 0 0
47307 - 0 0 0 0 0 0 0 0 0 0 0 0
47308 - 0 0 0 0 0 0 0 0 0 0 0 0
47309 - 0 0 0 0 0 0 0 0 0 0 0 0
47310 - 6 6 6 18 18 18 34 34 34 58 58 58
47311 - 82 82 82 89 81 66 89 81 66 89 81 66
47312 - 94 86 66 94 86 76 74 74 74 50 50 50
47313 - 26 26 26 14 14 14 6 6 6 0 0 0
47314 - 0 0 0 0 0 0 0 0 0 0 0 0
47315 - 0 0 0 0 0 0 0 0 0 0 0 0
47316 - 0 0 0 0 0 0 0 0 0 0 0 0
47317 - 0 0 0 0 0 0 0 0 0 0 0 0
47318 - 0 0 0 0 0 0 0 0 0 0 0 0
47319 - 0 0 0 0 0 0 0 0 0 0 0 0
47320 - 0 0 0 0 0 0 0 0 0 0 0 0
47321 - 0 0 0 0 0 0 0 0 0 0 0 0
47322 - 0 0 0 0 0 0 0 0 0 0 0 0
47323 - 6 6 6 6 6 6 14 14 14 18 18 18
47324 - 30 30 30 38 38 38 46 46 46 54 54 54
47325 - 50 50 50 42 42 42 30 30 30 18 18 18
47326 - 10 10 10 0 0 0 0 0 0 0 0 0
47327 - 0 0 0 0 0 0 0 0 0 0 0 0
47328 - 0 0 0 0 0 0 0 0 0 0 0 0
47329 - 0 0 0 0 0 0 0 0 0 0 0 0
47330 - 0 0 0 6 6 6 14 14 14 26 26 26
47331 - 38 38 38 50 50 50 58 58 58 58 58 58
47332 - 54 54 54 42 42 42 30 30 30 18 18 18
47333 - 10 10 10 0 0 0 0 0 0 0 0 0
47334 - 0 0 0 0 0 0 0 0 0 0 0 0
47335 - 0 0 0 0 0 0 0 0 0 0 0 0
47336 - 0 0 0 0 0 0 0 0 0 0 0 0
47337 - 0 0 0 0 0 0 0 0 0 0 0 0
47338 - 0 0 0 0 0 0 0 0 0 0 0 0
47339 - 0 0 0 0 0 0 0 0 0 0 0 0
47340 - 0 0 0 0 0 0 0 0 0 0 0 0
47341 - 0 0 0 0 0 0 0 0 0 0 0 0
47342 - 0 0 0 0 0 0 0 0 0 0 0 0
47343 - 0 0 0 0 0 0 0 0 0 6 6 6
47344 - 6 6 6 10 10 10 14 14 14 18 18 18
47345 - 18 18 18 14 14 14 10 10 10 6 6 6
47346 - 0 0 0 0 0 0 0 0 0 0 0 0
47347 - 0 0 0 0 0 0 0 0 0 0 0 0
47348 - 0 0 0 0 0 0 0 0 0 0 0 0
47349 - 0 0 0 0 0 0 0 0 0 0 0 0
47350 - 0 0 0 0 0 0 0 0 0 6 6 6
47351 - 14 14 14 18 18 18 22 22 22 22 22 22
47352 - 18 18 18 14 14 14 10 10 10 6 6 6
47353 - 0 0 0 0 0 0 0 0 0 0 0 0
47354 - 0 0 0 0 0 0 0 0 0 0 0 0
47355 - 0 0 0 0 0 0 0 0 0 0 0 0
47356 - 0 0 0 0 0 0 0 0 0 0 0 0
47357 - 0 0 0 0 0 0 0 0 0 0 0 0
47358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47363 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
47367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47369 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47370 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47371 +4 4 4 4 4 4
47372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47377 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
47381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47383 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47385 +4 4 4 4 4 4
47386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47391 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
47395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47397 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47399 +4 4 4 4 4 4
47400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47405 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
47409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47411 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47413 +4 4 4 4 4 4
47414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47419 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
47423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47425 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47427 +4 4 4 4 4 4
47428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47433 +4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
47437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47441 +4 4 4 4 4 4
47442 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47446 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
47447 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4
47451 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
47452 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
47453 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
47454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47455 +4 4 4 4 4 4
47456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47460 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
47461 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
47462 +5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4
47465 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
47466 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
47467 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
47468 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47469 +4 4 4 4 4 4
47470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47474 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
47475 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
47476 +0 0 0 3 3 3 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 4 4 4 4 4 4 4 4 4 4 4 4
47479 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
47480 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
47481 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
47482 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
47483 +4 4 4 4 4 4
47484 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47485 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47486 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47487 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
47488 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
47489 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
47490 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
47491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47492 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47493 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
47494 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
47495 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
47496 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
47497 +4 4 4 4 4 4
47498 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47499 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47501 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
47502 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
47503 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
47504 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
47505 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47506 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
47507 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
47508 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
47509 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
47510 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
47511 +4 4 4 4 4 4
47512 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47513 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47515 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
47516 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
47517 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
47518 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
47519 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47520 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
47521 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
47522 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
47523 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
47524 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
47525 +4 4 4 4 4 4
47526 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47527 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47528 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
47529 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
47530 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
47531 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
47532 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
47533 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
47534 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
47535 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
47536 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
47537 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
47538 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
47539 +4 4 4 4 4 4
47540 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47541 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47542 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
47543 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
47544 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
47545 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
47546 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
47547 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
47548 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
47549 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
47550 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
47551 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
47552 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
47553 +4 4 4 4 4 4
47554 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47555 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47556 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
47557 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
47558 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
47559 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
47560 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
47561 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
47562 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
47563 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
47564 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
47565 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
47566 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
47567 +4 4 4 4 4 4
47568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47570 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
47571 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
47572 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
47573 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
47574 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
47575 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
47576 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
47577 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
47578 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
47579 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
47580 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
47581 +4 4 4 4 4 4
47582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47583 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
47584 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
47585 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
47586 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
47587 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
47588 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
47589 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
47590 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
47591 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
47592 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
47593 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
47594 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
47595 +4 4 4 4 4 4
47596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47597 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
47598 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
47599 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
47600 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47601 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
47602 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
47603 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
47604 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
47605 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47606 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47607 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47608 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47609 +0 0 0 4 4 4
47610 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47611 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47612 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47613 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47614 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47615 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47616 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47617 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47618 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47619 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47620 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47621 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47622 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47623 +2 0 0 0 0 0
47624 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47625 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47626 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47627 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47628 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47629 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47630 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47631 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47632 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47633 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47634 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47635 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47636 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47637 +37 38 37 0 0 0
47638 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47639 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47640 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47641 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47642 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47643 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47644 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47645 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47646 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47647 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47648 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47649 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47650 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47651 +85 115 134 4 0 0
47652 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47653 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47654 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47655 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47656 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47657 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47658 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47659 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47660 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47661 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47662 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47663 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47664 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47665 +60 73 81 4 0 0
47666 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47667 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47668 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47669 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47670 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47671 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47672 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47673 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47674 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47675 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47676 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47677 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47678 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47679 +16 19 21 4 0 0
47680 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47681 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47682 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47683 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47684 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47685 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47686 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47687 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47688 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47689 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47690 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47691 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47692 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47693 +4 0 0 4 3 3
47694 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47695 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47696 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47698 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47699 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47700 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47701 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47702 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47703 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47704 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47705 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47706 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47707 +3 2 2 4 4 4
47708 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47709 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47710 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47711 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47712 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47713 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47714 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47715 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47716 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47717 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47718 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47719 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47720 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47721 +4 4 4 4 4 4
47722 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47723 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47724 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47725 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47726 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47727 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47728 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47729 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47730 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47731 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47732 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47733 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47734 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47735 +4 4 4 4 4 4
47736 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47737 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47738 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47739 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47740 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47741 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47742 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47743 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47744 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47745 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47746 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47747 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47748 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47749 +5 5 5 5 5 5
47750 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47751 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47752 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47753 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47754 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47755 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47756 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47757 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47758 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47759 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47760 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47761 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47762 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47763 +5 5 5 4 4 4
47764 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47765 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47766 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47767 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47768 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47769 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47770 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47771 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47772 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47773 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47774 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47775 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47777 +4 4 4 4 4 4
47778 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47779 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47780 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47781 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47782 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47783 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47784 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47785 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47786 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47787 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47788 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47789 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47791 +4 4 4 4 4 4
47792 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47793 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47794 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47795 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47796 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47797 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47798 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47799 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47800 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47801 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47802 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47805 +4 4 4 4 4 4
47806 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47807 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47808 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47809 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47810 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47811 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47812 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47813 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47814 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47815 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47816 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47819 +4 4 4 4 4 4
47820 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47821 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47822 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47823 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47824 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47825 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47826 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47827 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47828 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47829 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47830 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47833 +4 4 4 4 4 4
47834 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47835 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47836 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47837 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47838 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47839 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47840 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47841 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47842 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47843 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47844 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47847 +4 4 4 4 4 4
47848 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47849 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47850 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47851 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47852 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47853 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47854 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47855 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47856 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47857 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47858 +4 0 0 3 2 2 5 5 5 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
47862 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47863 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47864 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47865 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47866 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47867 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47868 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47869 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47870 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47871 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47872 +4 0 0 4 3 3 5 5 5 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
47876 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47877 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47878 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47879 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47880 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47881 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47882 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47883 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47884 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47885 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47886 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47889 +4 4 4 4 4 4
47890 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47891 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47892 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47893 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47894 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47895 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47896 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47897 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47898 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47899 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47900 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47903 +4 4 4 4 4 4
47904 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47905 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47906 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47907 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47908 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47909 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47910 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47911 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47912 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47913 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47914 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47917 +4 4 4 4 4 4
47918 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47919 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47920 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47921 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47922 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47923 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47924 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47925 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47926 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47927 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47928 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47929 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47930 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47931 +4 4 4 4 4 4
47932 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47933 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47934 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47935 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47936 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47937 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47938 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47939 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47940 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47941 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47942 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47943 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47944 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47945 +4 4 4 4 4 4
47946 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47947 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47948 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47949 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47950 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47951 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47952 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47953 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47954 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47955 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47956 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47957 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47958 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47959 +4 4 4 4 4 4
47960 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47961 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47962 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47963 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47964 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47965 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47966 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47967 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47968 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47969 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47970 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47971 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47972 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47973 +4 4 4 4 4 4
47974 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47975 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47976 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47977 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47978 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47979 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47980 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47981 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47982 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47983 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47984 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47985 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47986 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47987 +4 4 4 4 4 4
47988 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47989 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47990 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47991 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47992 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47993 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47994 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47995 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47996 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47997 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47998 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47999 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48000 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48001 +4 4 4 4 4 4
48002 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
48003 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
48004 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
48005 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
48006 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
48007 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
48008 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
48009 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
48010 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
48011 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
48012 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
48013 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48014 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48015 +4 4 4 4 4 4
48016 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
48017 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
48018 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
48019 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
48020 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
48021 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
48022 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
48023 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
48024 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
48025 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
48026 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
48027 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48028 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48029 +4 4 4 4 4 4
48030 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
48031 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
48032 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
48033 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
48034 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
48035 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
48036 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
48037 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
48038 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
48039 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
48040 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
48041 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48042 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48043 +4 4 4 4 4 4
48044 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
48045 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
48046 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
48047 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
48048 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
48049 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
48050 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
48051 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
48052 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
48053 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
48054 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
48055 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48056 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48057 +4 4 4 4 4 4
48058 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
48059 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
48060 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
48061 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
48062 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
48063 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
48064 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
48065 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
48066 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
48067 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
48068 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
48069 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48070 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48071 +4 4 4 4 4 4
48072 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
48073 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
48074 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
48075 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
48076 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
48077 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
48078 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
48079 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
48080 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
48081 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
48082 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
48083 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48084 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48085 +4 4 4 4 4 4
48086 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
48087 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
48088 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
48089 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
48090 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
48091 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
48092 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
48093 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
48094 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
48095 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
48096 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
48097 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48098 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48099 +4 4 4 4 4 4
48100 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
48101 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
48102 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
48103 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
48104 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
48105 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
48106 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
48107 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
48108 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
48109 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
48110 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
48111 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48112 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48113 +4 4 4 4 4 4
48114 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
48115 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
48116 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
48117 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
48118 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
48119 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
48120 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
48121 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
48122 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
48123 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
48124 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
48125 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48126 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48127 +4 4 4 4 4 4
48128 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
48129 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
48130 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
48131 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
48132 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
48133 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
48134 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
48135 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
48136 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
48137 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
48138 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48139 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48140 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48141 +4 4 4 4 4 4
48142 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
48143 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
48144 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
48145 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
48146 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
48147 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
48148 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48149 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
48150 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
48151 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
48152 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
48153 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48154 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48155 +4 4 4 4 4 4
48156 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
48157 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
48158 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
48159 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
48160 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
48161 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
48162 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
48163 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
48164 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
48165 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
48166 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48167 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48168 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48169 +4 4 4 4 4 4
48170 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
48171 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
48172 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
48173 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
48174 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
48175 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
48176 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
48177 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
48178 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
48179 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
48180 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48181 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48182 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48183 +4 4 4 4 4 4
48184 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
48185 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
48186 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
48187 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
48188 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
48189 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
48190 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
48191 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
48192 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
48193 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
48194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48195 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48196 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48197 +4 4 4 4 4 4
48198 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
48199 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
48200 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
48201 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
48202 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
48203 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
48204 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
48205 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
48206 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
48207 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
48208 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48209 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48210 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48211 +4 4 4 4 4 4
48212 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
48213 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
48214 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
48215 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
48216 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
48217 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
48218 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
48219 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
48220 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
48221 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
48222 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48223 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48224 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48225 +4 4 4 4 4 4
48226 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
48227 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
48228 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
48229 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
48230 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
48231 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
48232 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
48233 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
48234 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
48235 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48236 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48237 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48238 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48239 +4 4 4 4 4 4
48240 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
48241 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
48242 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
48243 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
48244 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
48245 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
48246 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
48247 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
48248 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
48249 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48250 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48251 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48253 +4 4 4 4 4 4
48254 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
48255 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
48256 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
48257 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
48258 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
48259 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
48260 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
48261 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
48262 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48263 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48264 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48265 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48267 +4 4 4 4 4 4
48268 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
48269 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
48270 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
48271 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
48272 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
48273 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
48274 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
48275 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
48276 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48277 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48278 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48279 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48281 +4 4 4 4 4 4
48282 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
48283 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
48284 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
48285 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
48286 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
48287 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
48288 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
48289 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
48290 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48291 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48292 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48293 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48295 +4 4 4 4 4 4
48296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
48297 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
48298 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
48299 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
48300 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
48301 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
48302 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
48303 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
48304 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48305 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48306 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48307 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48309 +4 4 4 4 4 4
48310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48311 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
48312 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
48313 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
48314 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
48315 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
48316 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
48317 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
48318 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48319 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48321 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48323 +4 4 4 4 4 4
48324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48325 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
48326 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
48327 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
48328 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
48329 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
48330 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
48331 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
48332 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48333 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48335 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48337 +4 4 4 4 4 4
48338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48340 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
48341 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
48342 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
48343 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
48344 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
48345 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
48346 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48347 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48349 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48351 +4 4 4 4 4 4
48352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48353 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48354 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
48355 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
48356 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
48357 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
48358 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
48359 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48360 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48361 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48363 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48365 +4 4 4 4 4 4
48366 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48368 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48369 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
48370 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
48371 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
48372 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
48373 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48374 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48375 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48377 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48379 +4 4 4 4 4 4
48380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48382 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48383 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
48384 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
48385 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
48386 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
48387 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48388 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48389 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48391 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48393 +4 4 4 4 4 4
48394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48396 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48397 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
48398 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
48399 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
48400 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
48401 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48402 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48403 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48405 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48407 +4 4 4 4 4 4
48408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48410 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48411 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
48412 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
48413 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
48414 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
48415 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48416 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48417 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48419 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48421 +4 4 4 4 4 4
48422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48424 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48425 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48426 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
48427 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
48428 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
48429 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48430 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48431 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48435 +4 4 4 4 4 4
48436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48438 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48439 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48440 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
48441 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
48442 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48443 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48444 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48445 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48449 +4 4 4 4 4 4
48450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48452 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48453 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48454 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
48455 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
48456 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48457 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48458 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48459 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48463 +4 4 4 4 4 4
48464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48466 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48467 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48468 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
48469 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
48470 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48471 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48472 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48473 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48477 +4 4 4 4 4 4
48478 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
48479 index fe92eed..106e085 100644
48480 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
48481 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
48482 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
48483 struct mb862xxfb_par *par = info->par;
48484
48485 if (info->var.bits_per_pixel == 32) {
48486 - info->fbops->fb_fillrect = cfb_fillrect;
48487 - info->fbops->fb_copyarea = cfb_copyarea;
48488 - info->fbops->fb_imageblit = cfb_imageblit;
48489 + pax_open_kernel();
48490 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
48491 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
48492 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
48493 + pax_close_kernel();
48494 } else {
48495 outreg(disp, GC_L0EM, 3);
48496 - info->fbops->fb_fillrect = mb86290fb_fillrect;
48497 - info->fbops->fb_copyarea = mb86290fb_copyarea;
48498 - info->fbops->fb_imageblit = mb86290fb_imageblit;
48499 + pax_open_kernel();
48500 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
48501 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
48502 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
48503 + pax_close_kernel();
48504 }
48505 outreg(draw, GDC_REG_DRAW_BASE, 0);
48506 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
48507 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
48508 index ff22871..b129bed 100644
48509 --- a/drivers/video/nvidia/nvidia.c
48510 +++ b/drivers/video/nvidia/nvidia.c
48511 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
48512 info->fix.line_length = (info->var.xres_virtual *
48513 info->var.bits_per_pixel) >> 3;
48514 if (info->var.accel_flags) {
48515 - info->fbops->fb_imageblit = nvidiafb_imageblit;
48516 - info->fbops->fb_fillrect = nvidiafb_fillrect;
48517 - info->fbops->fb_copyarea = nvidiafb_copyarea;
48518 - info->fbops->fb_sync = nvidiafb_sync;
48519 + pax_open_kernel();
48520 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
48521 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
48522 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
48523 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
48524 + pax_close_kernel();
48525 info->pixmap.scan_align = 4;
48526 info->flags &= ~FBINFO_HWACCEL_DISABLED;
48527 info->flags |= FBINFO_READS_FAST;
48528 NVResetGraphics(info);
48529 } else {
48530 - info->fbops->fb_imageblit = cfb_imageblit;
48531 - info->fbops->fb_fillrect = cfb_fillrect;
48532 - info->fbops->fb_copyarea = cfb_copyarea;
48533 - info->fbops->fb_sync = NULL;
48534 + pax_open_kernel();
48535 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
48536 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
48537 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
48538 + *(void **)&info->fbops->fb_sync = NULL;
48539 + pax_close_kernel();
48540 info->pixmap.scan_align = 1;
48541 info->flags |= FBINFO_HWACCEL_DISABLED;
48542 info->flags &= ~FBINFO_READS_FAST;
48543 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
48544 info->pixmap.size = 8 * 1024;
48545 info->pixmap.flags = FB_PIXMAP_SYSTEM;
48546
48547 - if (!hwcur)
48548 - info->fbops->fb_cursor = NULL;
48549 + if (!hwcur) {
48550 + pax_open_kernel();
48551 + *(void **)&info->fbops->fb_cursor = NULL;
48552 + pax_close_kernel();
48553 + }
48554
48555 info->var.accel_flags = (!noaccel);
48556
48557 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
48558 index 76d9053..dec2bfd 100644
48559 --- a/drivers/video/s1d13xxxfb.c
48560 +++ b/drivers/video/s1d13xxxfb.c
48561 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
48562
48563 switch(prod_id) {
48564 case S1D13506_PROD_ID: /* activate acceleration */
48565 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48566 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48567 + pax_open_kernel();
48568 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48569 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48570 + pax_close_kernel();
48571 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
48572 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
48573 break;
48574 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
48575 index 97bd662..39fab85 100644
48576 --- a/drivers/video/smscufx.c
48577 +++ b/drivers/video/smscufx.c
48578 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
48579 fb_deferred_io_cleanup(info);
48580 kfree(info->fbdefio);
48581 info->fbdefio = NULL;
48582 - info->fbops->fb_mmap = ufx_ops_mmap;
48583 + pax_open_kernel();
48584 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
48585 + pax_close_kernel();
48586 }
48587
48588 pr_debug("released /dev/fb%d user=%d count=%d",
48589 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
48590 index 86d449e..8e04dc5 100644
48591 --- a/drivers/video/udlfb.c
48592 +++ b/drivers/video/udlfb.c
48593 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
48594 dlfb_urb_completion(urb);
48595
48596 error:
48597 - atomic_add(bytes_sent, &dev->bytes_sent);
48598 - atomic_add(bytes_identical, &dev->bytes_identical);
48599 - atomic_add(width*height*2, &dev->bytes_rendered);
48600 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48601 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48602 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
48603 end_cycles = get_cycles();
48604 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48605 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48606 >> 10)), /* Kcycles */
48607 &dev->cpu_kcycles_used);
48608
48609 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48610 dlfb_urb_completion(urb);
48611
48612 error:
48613 - atomic_add(bytes_sent, &dev->bytes_sent);
48614 - atomic_add(bytes_identical, &dev->bytes_identical);
48615 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48616 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48617 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48618 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48619 end_cycles = get_cycles();
48620 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48621 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48622 >> 10)), /* Kcycles */
48623 &dev->cpu_kcycles_used);
48624 }
48625 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48626 fb_deferred_io_cleanup(info);
48627 kfree(info->fbdefio);
48628 info->fbdefio = NULL;
48629 - info->fbops->fb_mmap = dlfb_ops_mmap;
48630 + pax_open_kernel();
48631 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48632 + pax_close_kernel();
48633 }
48634
48635 pr_warn("released /dev/fb%d user=%d count=%d\n",
48636 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48637 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48638 struct dlfb_data *dev = fb_info->par;
48639 return snprintf(buf, PAGE_SIZE, "%u\n",
48640 - atomic_read(&dev->bytes_rendered));
48641 + atomic_read_unchecked(&dev->bytes_rendered));
48642 }
48643
48644 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48645 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48646 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48647 struct dlfb_data *dev = fb_info->par;
48648 return snprintf(buf, PAGE_SIZE, "%u\n",
48649 - atomic_read(&dev->bytes_identical));
48650 + atomic_read_unchecked(&dev->bytes_identical));
48651 }
48652
48653 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48654 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48655 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48656 struct dlfb_data *dev = fb_info->par;
48657 return snprintf(buf, PAGE_SIZE, "%u\n",
48658 - atomic_read(&dev->bytes_sent));
48659 + atomic_read_unchecked(&dev->bytes_sent));
48660 }
48661
48662 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48663 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48664 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48665 struct dlfb_data *dev = fb_info->par;
48666 return snprintf(buf, PAGE_SIZE, "%u\n",
48667 - atomic_read(&dev->cpu_kcycles_used));
48668 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48669 }
48670
48671 static ssize_t edid_show(
48672 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48673 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48674 struct dlfb_data *dev = fb_info->par;
48675
48676 - atomic_set(&dev->bytes_rendered, 0);
48677 - atomic_set(&dev->bytes_identical, 0);
48678 - atomic_set(&dev->bytes_sent, 0);
48679 - atomic_set(&dev->cpu_kcycles_used, 0);
48680 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48681 + atomic_set_unchecked(&dev->bytes_identical, 0);
48682 + atomic_set_unchecked(&dev->bytes_sent, 0);
48683 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48684
48685 return count;
48686 }
48687 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48688 index b75db01..ad2f34a 100644
48689 --- a/drivers/video/uvesafb.c
48690 +++ b/drivers/video/uvesafb.c
48691 @@ -19,6 +19,7 @@
48692 #include <linux/io.h>
48693 #include <linux/mutex.h>
48694 #include <linux/slab.h>
48695 +#include <linux/moduleloader.h>
48696 #include <video/edid.h>
48697 #include <video/uvesafb.h>
48698 #ifdef CONFIG_X86
48699 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48700 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48701 par->pmi_setpal = par->ypan = 0;
48702 } else {
48703 +
48704 +#ifdef CONFIG_PAX_KERNEXEC
48705 +#ifdef CONFIG_MODULES
48706 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48707 +#endif
48708 + if (!par->pmi_code) {
48709 + par->pmi_setpal = par->ypan = 0;
48710 + return 0;
48711 + }
48712 +#endif
48713 +
48714 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48715 + task->t.regs.edi);
48716 +
48717 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48718 + pax_open_kernel();
48719 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48720 + pax_close_kernel();
48721 +
48722 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48723 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48724 +#else
48725 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48726 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48727 +#endif
48728 +
48729 printk(KERN_INFO "uvesafb: protected mode interface info at "
48730 "%04x:%04x\n",
48731 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48732 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48733 par->ypan = ypan;
48734
48735 if (par->pmi_setpal || par->ypan) {
48736 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48737 if (__supported_pte_mask & _PAGE_NX) {
48738 par->pmi_setpal = par->ypan = 0;
48739 printk(KERN_WARNING "uvesafb: NX protection is actively."
48740 "We have better not to use the PMI.\n");
48741 - } else {
48742 + } else
48743 +#endif
48744 uvesafb_vbe_getpmi(task, par);
48745 - }
48746 }
48747 #else
48748 /* The protected mode interface is not available on non-x86. */
48749 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48750 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48751
48752 /* Disable blanking if the user requested so. */
48753 - if (!blank)
48754 - info->fbops->fb_blank = NULL;
48755 + if (!blank) {
48756 + pax_open_kernel();
48757 + *(void **)&info->fbops->fb_blank = NULL;
48758 + pax_close_kernel();
48759 + }
48760
48761 /*
48762 * Find out how much IO memory is required for the mode with
48763 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48764 info->flags = FBINFO_FLAG_DEFAULT |
48765 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48766
48767 - if (!par->ypan)
48768 - info->fbops->fb_pan_display = NULL;
48769 + if (!par->ypan) {
48770 + pax_open_kernel();
48771 + *(void **)&info->fbops->fb_pan_display = NULL;
48772 + pax_close_kernel();
48773 + }
48774 }
48775
48776 static void uvesafb_init_mtrr(struct fb_info *info)
48777 @@ -1836,6 +1866,11 @@ out:
48778 if (par->vbe_modes)
48779 kfree(par->vbe_modes);
48780
48781 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48782 + if (par->pmi_code)
48783 + module_free_exec(NULL, par->pmi_code);
48784 +#endif
48785 +
48786 framebuffer_release(info);
48787 return err;
48788 }
48789 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48790 kfree(par->vbe_state_orig);
48791 if (par->vbe_state_saved)
48792 kfree(par->vbe_state_saved);
48793 +
48794 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48795 + if (par->pmi_code)
48796 + module_free_exec(NULL, par->pmi_code);
48797 +#endif
48798 +
48799 }
48800
48801 framebuffer_release(info);
48802 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48803 index 501b340..d80aa17 100644
48804 --- a/drivers/video/vesafb.c
48805 +++ b/drivers/video/vesafb.c
48806 @@ -9,6 +9,7 @@
48807 */
48808
48809 #include <linux/module.h>
48810 +#include <linux/moduleloader.h>
48811 #include <linux/kernel.h>
48812 #include <linux/errno.h>
48813 #include <linux/string.h>
48814 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48815 static int vram_total __initdata; /* Set total amount of memory */
48816 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48817 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48818 -static void (*pmi_start)(void) __read_mostly;
48819 -static void (*pmi_pal) (void) __read_mostly;
48820 +static void (*pmi_start)(void) __read_only;
48821 +static void (*pmi_pal) (void) __read_only;
48822 static int depth __read_mostly;
48823 static int vga_compat __read_mostly;
48824 /* --------------------------------------------------------------------- */
48825 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48826 unsigned int size_vmode;
48827 unsigned int size_remap;
48828 unsigned int size_total;
48829 + void *pmi_code = NULL;
48830
48831 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48832 return -ENODEV;
48833 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48834 size_remap = size_total;
48835 vesafb_fix.smem_len = size_remap;
48836
48837 -#ifndef __i386__
48838 - screen_info.vesapm_seg = 0;
48839 -#endif
48840 -
48841 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48842 printk(KERN_WARNING
48843 "vesafb: cannot reserve video memory at 0x%lx\n",
48844 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48845 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48846 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48847
48848 +#ifdef __i386__
48849 +
48850 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48851 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48852 + if (!pmi_code)
48853 +#elif !defined(CONFIG_PAX_KERNEXEC)
48854 + if (0)
48855 +#endif
48856 +
48857 +#endif
48858 + screen_info.vesapm_seg = 0;
48859 +
48860 if (screen_info.vesapm_seg) {
48861 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48862 - screen_info.vesapm_seg,screen_info.vesapm_off);
48863 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48864 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48865 }
48866
48867 if (screen_info.vesapm_seg < 0xc000)
48868 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48869
48870 if (ypan || pmi_setpal) {
48871 unsigned short *pmi_base;
48872 +
48873 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48874 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48875 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48876 +
48877 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48878 + pax_open_kernel();
48879 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48880 +#else
48881 + pmi_code = pmi_base;
48882 +#endif
48883 +
48884 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48885 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48886 +
48887 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48888 + pmi_start = ktva_ktla(pmi_start);
48889 + pmi_pal = ktva_ktla(pmi_pal);
48890 + pax_close_kernel();
48891 +#endif
48892 +
48893 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48894 if (pmi_base[3]) {
48895 printk(KERN_INFO "vesafb: pmi: ports = ");
48896 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48897 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48898 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48899
48900 - if (!ypan)
48901 - info->fbops->fb_pan_display = NULL;
48902 + if (!ypan) {
48903 + pax_open_kernel();
48904 + *(void **)&info->fbops->fb_pan_display = NULL;
48905 + pax_close_kernel();
48906 + }
48907
48908 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48909 err = -ENOMEM;
48910 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48911 info->node, info->fix.id);
48912 return 0;
48913 err:
48914 +
48915 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48916 + module_free_exec(NULL, pmi_code);
48917 +#endif
48918 +
48919 if (info->screen_base)
48920 iounmap(info->screen_base);
48921 framebuffer_release(info);
48922 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48923 index 88714ae..16c2e11 100644
48924 --- a/drivers/video/via/via_clock.h
48925 +++ b/drivers/video/via/via_clock.h
48926 @@ -56,7 +56,7 @@ struct via_clock {
48927
48928 void (*set_engine_pll_state)(u8 state);
48929 void (*set_engine_pll)(struct via_pll_config config);
48930 -};
48931 +} __no_const;
48932
48933
48934 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48935 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48936 index fef20db..d28b1ab 100644
48937 --- a/drivers/xen/xenfs/xenstored.c
48938 +++ b/drivers/xen/xenfs/xenstored.c
48939 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48940 static int xsd_kva_open(struct inode *inode, struct file *file)
48941 {
48942 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48943 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48944 + NULL);
48945 +#else
48946 xen_store_interface);
48947 +#endif
48948 +
48949 if (!file->private_data)
48950 return -ENOMEM;
48951 return 0;
48952 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48953 index 890bed5..17ae73e 100644
48954 --- a/fs/9p/vfs_inode.c
48955 +++ b/fs/9p/vfs_inode.c
48956 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48957 void
48958 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48959 {
48960 - char *s = nd_get_link(nd);
48961 + const char *s = nd_get_link(nd);
48962
48963 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48964 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48965 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48966 index 0efd152..b5802ad 100644
48967 --- a/fs/Kconfig.binfmt
48968 +++ b/fs/Kconfig.binfmt
48969 @@ -89,7 +89,7 @@ config HAVE_AOUT
48970
48971 config BINFMT_AOUT
48972 tristate "Kernel support for a.out and ECOFF binaries"
48973 - depends on HAVE_AOUT
48974 + depends on HAVE_AOUT && BROKEN
48975 ---help---
48976 A.out (Assembler.OUTput) is a set of formats for libraries and
48977 executables used in the earliest versions of UNIX. Linux used
48978 diff --git a/fs/aio.c b/fs/aio.c
48979 index 71f613c..ee07789 100644
48980 --- a/fs/aio.c
48981 +++ b/fs/aio.c
48982 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48983 size += sizeof(struct io_event) * nr_events;
48984 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48985
48986 - if (nr_pages < 0)
48987 + if (nr_pages <= 0)
48988 return -EINVAL;
48989
48990 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48991 @@ -1027,9 +1027,9 @@ static int aio_read_evt(struct kioctx *ioctx, struct io_event *ent)
48992 spin_unlock(&info->ring_lock);
48993
48994 out:
48995 - kunmap_atomic(ring);
48996 dprintk("leaving aio_read_evt: %d h%lu t%lu\n", ret,
48997 (unsigned long)ring->head, (unsigned long)ring->tail);
48998 + kunmap_atomic(ring);
48999 return ret;
49000 }
49001
49002 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
49003 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
49004 {
49005 ssize_t ret;
49006 + struct iovec iovstack;
49007
49008 #ifdef CONFIG_COMPAT
49009 if (compat)
49010 ret = compat_rw_copy_check_uvector(type,
49011 (struct compat_iovec __user *)kiocb->ki_buf,
49012 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
49013 + kiocb->ki_nbytes, 1, &iovstack,
49014 &kiocb->ki_iovec);
49015 else
49016 #endif
49017 ret = rw_copy_check_uvector(type,
49018 (struct iovec __user *)kiocb->ki_buf,
49019 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
49020 + kiocb->ki_nbytes, 1, &iovstack,
49021 &kiocb->ki_iovec);
49022 if (ret < 0)
49023 goto out;
49024 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
49025 if (ret < 0)
49026 goto out;
49027
49028 + if (kiocb->ki_iovec == &iovstack) {
49029 + kiocb->ki_inline_vec = iovstack;
49030 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
49031 + }
49032 kiocb->ki_nr_segs = kiocb->ki_nbytes;
49033 kiocb->ki_cur_seg = 0;
49034 /* ki_nbytes/left now reflect bytes instead of segs */
49035 diff --git a/fs/attr.c b/fs/attr.c
49036 index 1449adb..a2038c2 100644
49037 --- a/fs/attr.c
49038 +++ b/fs/attr.c
49039 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
49040 unsigned long limit;
49041
49042 limit = rlimit(RLIMIT_FSIZE);
49043 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
49044 if (limit != RLIM_INFINITY && offset > limit)
49045 goto out_sig;
49046 if (offset > inode->i_sb->s_maxbytes)
49047 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
49048 index 03bc1d3..6205356 100644
49049 --- a/fs/autofs4/waitq.c
49050 +++ b/fs/autofs4/waitq.c
49051 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
49052 {
49053 unsigned long sigpipe, flags;
49054 mm_segment_t fs;
49055 - const char *data = (const char *)addr;
49056 + const char __user *data = (const char __force_user *)addr;
49057 ssize_t wr = 0;
49058
49059 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
49060 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
49061 return 1;
49062 }
49063
49064 +#ifdef CONFIG_GRKERNSEC_HIDESYM
49065 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
49066 +#endif
49067 +
49068 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
49069 enum autofs_notify notify)
49070 {
49071 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
49072
49073 /* If this is a direct mount request create a dummy name */
49074 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
49075 +#ifdef CONFIG_GRKERNSEC_HIDESYM
49076 + /* this name does get written to userland via autofs4_write() */
49077 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
49078 +#else
49079 qstr.len = sprintf(name, "%p", dentry);
49080 +#endif
49081 else {
49082 qstr.len = autofs4_getpath(sbi, dentry, &name);
49083 if (!qstr.len) {
49084 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
49085 index 2722387..c8dd2a7 100644
49086 --- a/fs/befs/endian.h
49087 +++ b/fs/befs/endian.h
49088 @@ -11,7 +11,7 @@
49089
49090 #include <asm/byteorder.h>
49091
49092 -static inline u64
49093 +static inline u64 __intentional_overflow(-1)
49094 fs64_to_cpu(const struct super_block *sb, fs64 n)
49095 {
49096 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
49097 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
49098 return (__force fs64)cpu_to_be64(n);
49099 }
49100
49101 -static inline u32
49102 +static inline u32 __intentional_overflow(-1)
49103 fs32_to_cpu(const struct super_block *sb, fs32 n)
49104 {
49105 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
49106 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
49107 index 2b3bda8..6a2d4be 100644
49108 --- a/fs/befs/linuxvfs.c
49109 +++ b/fs/befs/linuxvfs.c
49110 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
49111 {
49112 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
49113 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
49114 - char *link = nd_get_link(nd);
49115 + const char *link = nd_get_link(nd);
49116 if (!IS_ERR(link))
49117 kfree(link);
49118 }
49119 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
49120 index 6043567..16a9239 100644
49121 --- a/fs/binfmt_aout.c
49122 +++ b/fs/binfmt_aout.c
49123 @@ -16,6 +16,7 @@
49124 #include <linux/string.h>
49125 #include <linux/fs.h>
49126 #include <linux/file.h>
49127 +#include <linux/security.h>
49128 #include <linux/stat.h>
49129 #include <linux/fcntl.h>
49130 #include <linux/ptrace.h>
49131 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
49132 #endif
49133 # define START_STACK(u) ((void __user *)u.start_stack)
49134
49135 + memset(&dump, 0, sizeof(dump));
49136 +
49137 fs = get_fs();
49138 set_fs(KERNEL_DS);
49139 has_dumped = 1;
49140 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
49141
49142 /* If the size of the dump file exceeds the rlimit, then see what would happen
49143 if we wrote the stack, but not the data area. */
49144 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
49145 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
49146 dump.u_dsize = 0;
49147
49148 /* Make sure we have enough room to write the stack and data areas. */
49149 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
49150 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
49151 dump.u_ssize = 0;
49152
49153 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
49154 rlim = rlimit(RLIMIT_DATA);
49155 if (rlim >= RLIM_INFINITY)
49156 rlim = ~0;
49157 +
49158 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
49159 if (ex.a_data + ex.a_bss > rlim)
49160 return -ENOMEM;
49161
49162 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
49163
49164 install_exec_creds(bprm);
49165
49166 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49167 + current->mm->pax_flags = 0UL;
49168 +#endif
49169 +
49170 +#ifdef CONFIG_PAX_PAGEEXEC
49171 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
49172 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
49173 +
49174 +#ifdef CONFIG_PAX_EMUTRAMP
49175 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
49176 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
49177 +#endif
49178 +
49179 +#ifdef CONFIG_PAX_MPROTECT
49180 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
49181 + current->mm->pax_flags |= MF_PAX_MPROTECT;
49182 +#endif
49183 +
49184 + }
49185 +#endif
49186 +
49187 if (N_MAGIC(ex) == OMAGIC) {
49188 unsigned long text_addr, map_size;
49189 loff_t pos;
49190 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
49191 }
49192
49193 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
49194 - PROT_READ | PROT_WRITE | PROT_EXEC,
49195 + PROT_READ | PROT_WRITE,
49196 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
49197 fd_offset + ex.a_text);
49198 if (error != N_DATADDR(ex)) {
49199 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
49200 index 5843a47..160fbe2 100644
49201 --- a/fs/binfmt_elf.c
49202 +++ b/fs/binfmt_elf.c
49203 @@ -33,6 +33,7 @@
49204 #include <linux/elf.h>
49205 #include <linux/utsname.h>
49206 #include <linux/coredump.h>
49207 +#include <linux/xattr.h>
49208 #include <asm/uaccess.h>
49209 #include <asm/param.h>
49210 #include <asm/page.h>
49211 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
49212 #define elf_core_dump NULL
49213 #endif
49214
49215 +#ifdef CONFIG_PAX_MPROTECT
49216 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
49217 +#endif
49218 +
49219 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
49220 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
49221 #else
49222 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
49223 .load_binary = load_elf_binary,
49224 .load_shlib = load_elf_library,
49225 .core_dump = elf_core_dump,
49226 +
49227 +#ifdef CONFIG_PAX_MPROTECT
49228 + .handle_mprotect= elf_handle_mprotect,
49229 +#endif
49230 +
49231 .min_coredump = ELF_EXEC_PAGESIZE,
49232 };
49233
49234 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
49235
49236 static int set_brk(unsigned long start, unsigned long end)
49237 {
49238 + unsigned long e = end;
49239 +
49240 start = ELF_PAGEALIGN(start);
49241 end = ELF_PAGEALIGN(end);
49242 if (end > start) {
49243 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
49244 if (BAD_ADDR(addr))
49245 return addr;
49246 }
49247 - current->mm->start_brk = current->mm->brk = end;
49248 + current->mm->start_brk = current->mm->brk = e;
49249 return 0;
49250 }
49251
49252 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
49253 elf_addr_t __user *u_rand_bytes;
49254 const char *k_platform = ELF_PLATFORM;
49255 const char *k_base_platform = ELF_BASE_PLATFORM;
49256 - unsigned char k_rand_bytes[16];
49257 + u32 k_rand_bytes[4];
49258 int items;
49259 elf_addr_t *elf_info;
49260 int ei_index = 0;
49261 const struct cred *cred = current_cred();
49262 struct vm_area_struct *vma;
49263 + unsigned long saved_auxv[AT_VECTOR_SIZE];
49264
49265 /*
49266 * In some cases (e.g. Hyper-Threading), we want to avoid L1
49267 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
49268 * Generate 16 random bytes for userspace PRNG seeding.
49269 */
49270 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
49271 - u_rand_bytes = (elf_addr_t __user *)
49272 - STACK_ALLOC(p, sizeof(k_rand_bytes));
49273 + srandom32(k_rand_bytes[0] ^ random32());
49274 + srandom32(k_rand_bytes[1] ^ random32());
49275 + srandom32(k_rand_bytes[2] ^ random32());
49276 + srandom32(k_rand_bytes[3] ^ random32());
49277 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
49278 + u_rand_bytes = (elf_addr_t __user *) p;
49279 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
49280 return -EFAULT;
49281
49282 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
49283 return -EFAULT;
49284 current->mm->env_end = p;
49285
49286 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
49287 +
49288 /* Put the elf_info on the stack in the right place. */
49289 sp = (elf_addr_t __user *)envp + 1;
49290 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
49291 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
49292 return -EFAULT;
49293 return 0;
49294 }
49295 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
49296 an ELF header */
49297
49298 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
49299 - struct file *interpreter, unsigned long *interp_map_addr,
49300 - unsigned long no_base)
49301 + struct file *interpreter, unsigned long no_base)
49302 {
49303 struct elf_phdr *elf_phdata;
49304 struct elf_phdr *eppnt;
49305 - unsigned long load_addr = 0;
49306 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
49307 int load_addr_set = 0;
49308 unsigned long last_bss = 0, elf_bss = 0;
49309 - unsigned long error = ~0UL;
49310 + unsigned long error = -EINVAL;
49311 unsigned long total_size;
49312 int retval, i, size;
49313
49314 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
49315 goto out_close;
49316 }
49317
49318 +#ifdef CONFIG_PAX_SEGMEXEC
49319 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
49320 + pax_task_size = SEGMEXEC_TASK_SIZE;
49321 +#endif
49322 +
49323 eppnt = elf_phdata;
49324 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
49325 if (eppnt->p_type == PT_LOAD) {
49326 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
49327 map_addr = elf_map(interpreter, load_addr + vaddr,
49328 eppnt, elf_prot, elf_type, total_size);
49329 total_size = 0;
49330 - if (!*interp_map_addr)
49331 - *interp_map_addr = map_addr;
49332 error = map_addr;
49333 if (BAD_ADDR(map_addr))
49334 goto out_close;
49335 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
49336 k = load_addr + eppnt->p_vaddr;
49337 if (BAD_ADDR(k) ||
49338 eppnt->p_filesz > eppnt->p_memsz ||
49339 - eppnt->p_memsz > TASK_SIZE ||
49340 - TASK_SIZE - eppnt->p_memsz < k) {
49341 + eppnt->p_memsz > pax_task_size ||
49342 + pax_task_size - eppnt->p_memsz < k) {
49343 error = -ENOMEM;
49344 goto out_close;
49345 }
49346 @@ -530,6 +551,315 @@ out:
49347 return error;
49348 }
49349
49350 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
49351 +#ifdef CONFIG_PAX_SOFTMODE
49352 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
49353 +{
49354 + unsigned long pax_flags = 0UL;
49355 +
49356 +#ifdef CONFIG_PAX_PAGEEXEC
49357 + if (elf_phdata->p_flags & PF_PAGEEXEC)
49358 + pax_flags |= MF_PAX_PAGEEXEC;
49359 +#endif
49360 +
49361 +#ifdef CONFIG_PAX_SEGMEXEC
49362 + if (elf_phdata->p_flags & PF_SEGMEXEC)
49363 + pax_flags |= MF_PAX_SEGMEXEC;
49364 +#endif
49365 +
49366 +#ifdef CONFIG_PAX_EMUTRAMP
49367 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
49368 + pax_flags |= MF_PAX_EMUTRAMP;
49369 +#endif
49370 +
49371 +#ifdef CONFIG_PAX_MPROTECT
49372 + if (elf_phdata->p_flags & PF_MPROTECT)
49373 + pax_flags |= MF_PAX_MPROTECT;
49374 +#endif
49375 +
49376 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
49377 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
49378 + pax_flags |= MF_PAX_RANDMMAP;
49379 +#endif
49380 +
49381 + return pax_flags;
49382 +}
49383 +#endif
49384 +
49385 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
49386 +{
49387 + unsigned long pax_flags = 0UL;
49388 +
49389 +#ifdef CONFIG_PAX_PAGEEXEC
49390 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
49391 + pax_flags |= MF_PAX_PAGEEXEC;
49392 +#endif
49393 +
49394 +#ifdef CONFIG_PAX_SEGMEXEC
49395 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
49396 + pax_flags |= MF_PAX_SEGMEXEC;
49397 +#endif
49398 +
49399 +#ifdef CONFIG_PAX_EMUTRAMP
49400 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
49401 + pax_flags |= MF_PAX_EMUTRAMP;
49402 +#endif
49403 +
49404 +#ifdef CONFIG_PAX_MPROTECT
49405 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
49406 + pax_flags |= MF_PAX_MPROTECT;
49407 +#endif
49408 +
49409 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
49410 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
49411 + pax_flags |= MF_PAX_RANDMMAP;
49412 +#endif
49413 +
49414 + return pax_flags;
49415 +}
49416 +#endif
49417 +
49418 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
49419 +#ifdef CONFIG_PAX_SOFTMODE
49420 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
49421 +{
49422 + unsigned long pax_flags = 0UL;
49423 +
49424 +#ifdef CONFIG_PAX_PAGEEXEC
49425 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
49426 + pax_flags |= MF_PAX_PAGEEXEC;
49427 +#endif
49428 +
49429 +#ifdef CONFIG_PAX_SEGMEXEC
49430 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
49431 + pax_flags |= MF_PAX_SEGMEXEC;
49432 +#endif
49433 +
49434 +#ifdef CONFIG_PAX_EMUTRAMP
49435 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
49436 + pax_flags |= MF_PAX_EMUTRAMP;
49437 +#endif
49438 +
49439 +#ifdef CONFIG_PAX_MPROTECT
49440 + if (pax_flags_softmode & MF_PAX_MPROTECT)
49441 + pax_flags |= MF_PAX_MPROTECT;
49442 +#endif
49443 +
49444 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
49445 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
49446 + pax_flags |= MF_PAX_RANDMMAP;
49447 +#endif
49448 +
49449 + return pax_flags;
49450 +}
49451 +#endif
49452 +
49453 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
49454 +{
49455 + unsigned long pax_flags = 0UL;
49456 +
49457 +#ifdef CONFIG_PAX_PAGEEXEC
49458 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
49459 + pax_flags |= MF_PAX_PAGEEXEC;
49460 +#endif
49461 +
49462 +#ifdef CONFIG_PAX_SEGMEXEC
49463 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
49464 + pax_flags |= MF_PAX_SEGMEXEC;
49465 +#endif
49466 +
49467 +#ifdef CONFIG_PAX_EMUTRAMP
49468 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
49469 + pax_flags |= MF_PAX_EMUTRAMP;
49470 +#endif
49471 +
49472 +#ifdef CONFIG_PAX_MPROTECT
49473 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
49474 + pax_flags |= MF_PAX_MPROTECT;
49475 +#endif
49476 +
49477 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
49478 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
49479 + pax_flags |= MF_PAX_RANDMMAP;
49480 +#endif
49481 +
49482 + return pax_flags;
49483 +}
49484 +#endif
49485 +
49486 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49487 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
49488 +{
49489 + unsigned long pax_flags = 0UL;
49490 +
49491 +#ifdef CONFIG_PAX_EI_PAX
49492 +
49493 +#ifdef CONFIG_PAX_PAGEEXEC
49494 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
49495 + pax_flags |= MF_PAX_PAGEEXEC;
49496 +#endif
49497 +
49498 +#ifdef CONFIG_PAX_SEGMEXEC
49499 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
49500 + pax_flags |= MF_PAX_SEGMEXEC;
49501 +#endif
49502 +
49503 +#ifdef CONFIG_PAX_EMUTRAMP
49504 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
49505 + pax_flags |= MF_PAX_EMUTRAMP;
49506 +#endif
49507 +
49508 +#ifdef CONFIG_PAX_MPROTECT
49509 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
49510 + pax_flags |= MF_PAX_MPROTECT;
49511 +#endif
49512 +
49513 +#ifdef CONFIG_PAX_ASLR
49514 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
49515 + pax_flags |= MF_PAX_RANDMMAP;
49516 +#endif
49517 +
49518 +#else
49519 +
49520 +#ifdef CONFIG_PAX_PAGEEXEC
49521 + pax_flags |= MF_PAX_PAGEEXEC;
49522 +#endif
49523 +
49524 +#ifdef CONFIG_PAX_SEGMEXEC
49525 + pax_flags |= MF_PAX_SEGMEXEC;
49526 +#endif
49527 +
49528 +#ifdef CONFIG_PAX_MPROTECT
49529 + pax_flags |= MF_PAX_MPROTECT;
49530 +#endif
49531 +
49532 +#ifdef CONFIG_PAX_RANDMMAP
49533 + if (randomize_va_space)
49534 + pax_flags |= MF_PAX_RANDMMAP;
49535 +#endif
49536 +
49537 +#endif
49538 +
49539 + return pax_flags;
49540 +}
49541 +
49542 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
49543 +{
49544 +
49545 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
49546 + unsigned long i;
49547 +
49548 + for (i = 0UL; i < elf_ex->e_phnum; i++)
49549 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
49550 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
49551 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
49552 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
49553 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
49554 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
49555 + return ~0UL;
49556 +
49557 +#ifdef CONFIG_PAX_SOFTMODE
49558 + if (pax_softmode)
49559 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
49560 + else
49561 +#endif
49562 +
49563 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
49564 + break;
49565 + }
49566 +#endif
49567 +
49568 + return ~0UL;
49569 +}
49570 +
49571 +static unsigned long pax_parse_xattr_pax(struct file * const file)
49572 +{
49573 +
49574 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
49575 + ssize_t xattr_size, i;
49576 + unsigned char xattr_value[5];
49577 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
49578 +
49579 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
49580 + if (xattr_size <= 0 || xattr_size > 5)
49581 + return ~0UL;
49582 +
49583 + for (i = 0; i < xattr_size; i++)
49584 + switch (xattr_value[i]) {
49585 + default:
49586 + return ~0UL;
49587 +
49588 +#define parse_flag(option1, option2, flag) \
49589 + case option1: \
49590 + if (pax_flags_hardmode & MF_PAX_##flag) \
49591 + return ~0UL; \
49592 + pax_flags_hardmode |= MF_PAX_##flag; \
49593 + break; \
49594 + case option2: \
49595 + if (pax_flags_softmode & MF_PAX_##flag) \
49596 + return ~0UL; \
49597 + pax_flags_softmode |= MF_PAX_##flag; \
49598 + break;
49599 +
49600 + parse_flag('p', 'P', PAGEEXEC);
49601 + parse_flag('e', 'E', EMUTRAMP);
49602 + parse_flag('m', 'M', MPROTECT);
49603 + parse_flag('r', 'R', RANDMMAP);
49604 + parse_flag('s', 'S', SEGMEXEC);
49605 +
49606 +#undef parse_flag
49607 + }
49608 +
49609 + if (pax_flags_hardmode & pax_flags_softmode)
49610 + return ~0UL;
49611 +
49612 +#ifdef CONFIG_PAX_SOFTMODE
49613 + if (pax_softmode)
49614 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
49615 + else
49616 +#endif
49617 +
49618 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49619 +#else
49620 + return ~0UL;
49621 +#endif
49622 +
49623 +}
49624 +
49625 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49626 +{
49627 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49628 +
49629 + pax_flags = pax_parse_ei_pax(elf_ex);
49630 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49631 + xattr_pax_flags = pax_parse_xattr_pax(file);
49632 +
49633 + if (pt_pax_flags == ~0UL)
49634 + pt_pax_flags = xattr_pax_flags;
49635 + else if (xattr_pax_flags == ~0UL)
49636 + xattr_pax_flags = pt_pax_flags;
49637 + if (pt_pax_flags != xattr_pax_flags)
49638 + return -EINVAL;
49639 + if (pt_pax_flags != ~0UL)
49640 + pax_flags = pt_pax_flags;
49641 +
49642 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49643 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49644 + if ((__supported_pte_mask & _PAGE_NX))
49645 + pax_flags &= ~MF_PAX_SEGMEXEC;
49646 + else
49647 + pax_flags &= ~MF_PAX_PAGEEXEC;
49648 + }
49649 +#endif
49650 +
49651 + if (0 > pax_check_flags(&pax_flags))
49652 + return -EINVAL;
49653 +
49654 + current->mm->pax_flags = pax_flags;
49655 + return 0;
49656 +}
49657 +#endif
49658 +
49659 /*
49660 * These are the functions used to load ELF style executables and shared
49661 * libraries. There is no binary dependent code anywhere else.
49662 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49663 {
49664 unsigned int random_variable = 0;
49665
49666 +#ifdef CONFIG_PAX_RANDUSTACK
49667 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49668 + return stack_top - current->mm->delta_stack;
49669 +#endif
49670 +
49671 if ((current->flags & PF_RANDOMIZE) &&
49672 !(current->personality & ADDR_NO_RANDOMIZE)) {
49673 random_variable = get_random_int() & STACK_RND_MASK;
49674 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49675 unsigned long load_addr = 0, load_bias = 0;
49676 int load_addr_set = 0;
49677 char * elf_interpreter = NULL;
49678 - unsigned long error;
49679 + unsigned long error = 0;
49680 struct elf_phdr *elf_ppnt, *elf_phdata;
49681 unsigned long elf_bss, elf_brk;
49682 int retval, i;
49683 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49684 unsigned long start_code, end_code, start_data, end_data;
49685 unsigned long reloc_func_desc __maybe_unused = 0;
49686 int executable_stack = EXSTACK_DEFAULT;
49687 - unsigned long def_flags = 0;
49688 struct pt_regs *regs = current_pt_regs();
49689 struct {
49690 struct elfhdr elf_ex;
49691 struct elfhdr interp_elf_ex;
49692 } *loc;
49693 + unsigned long pax_task_size = TASK_SIZE;
49694
49695 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49696 if (!loc) {
49697 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49698 goto out_free_dentry;
49699
49700 /* OK, This is the point of no return */
49701 - current->mm->def_flags = def_flags;
49702 +
49703 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49704 + current->mm->pax_flags = 0UL;
49705 +#endif
49706 +
49707 +#ifdef CONFIG_PAX_DLRESOLVE
49708 + current->mm->call_dl_resolve = 0UL;
49709 +#endif
49710 +
49711 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49712 + current->mm->call_syscall = 0UL;
49713 +#endif
49714 +
49715 +#ifdef CONFIG_PAX_ASLR
49716 + current->mm->delta_mmap = 0UL;
49717 + current->mm->delta_stack = 0UL;
49718 +#endif
49719 +
49720 + current->mm->def_flags = 0;
49721 +
49722 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49723 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49724 + send_sig(SIGKILL, current, 0);
49725 + goto out_free_dentry;
49726 + }
49727 +#endif
49728 +
49729 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49730 + pax_set_initial_flags(bprm);
49731 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49732 + if (pax_set_initial_flags_func)
49733 + (pax_set_initial_flags_func)(bprm);
49734 +#endif
49735 +
49736 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49737 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49738 + current->mm->context.user_cs_limit = PAGE_SIZE;
49739 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49740 + }
49741 +#endif
49742 +
49743 +#ifdef CONFIG_PAX_SEGMEXEC
49744 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49745 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49746 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49747 + pax_task_size = SEGMEXEC_TASK_SIZE;
49748 + current->mm->def_flags |= VM_NOHUGEPAGE;
49749 + }
49750 +#endif
49751 +
49752 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49753 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49754 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49755 + put_cpu();
49756 + }
49757 +#endif
49758
49759 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49760 may depend on the personality. */
49761 SET_PERSONALITY(loc->elf_ex);
49762 +
49763 +#ifdef CONFIG_PAX_ASLR
49764 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49765 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49766 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49767 + }
49768 +#endif
49769 +
49770 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49771 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49772 + executable_stack = EXSTACK_DISABLE_X;
49773 + current->personality &= ~READ_IMPLIES_EXEC;
49774 + } else
49775 +#endif
49776 +
49777 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49778 current->personality |= READ_IMPLIES_EXEC;
49779
49780 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49781 #else
49782 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49783 #endif
49784 +
49785 +#ifdef CONFIG_PAX_RANDMMAP
49786 + /* PaX: randomize base address at the default exe base if requested */
49787 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49788 +#ifdef CONFIG_SPARC64
49789 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49790 +#else
49791 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49792 +#endif
49793 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49794 + elf_flags |= MAP_FIXED;
49795 + }
49796 +#endif
49797 +
49798 }
49799
49800 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49801 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49802 * allowed task size. Note that p_filesz must always be
49803 * <= p_memsz so it is only necessary to check p_memsz.
49804 */
49805 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49806 - elf_ppnt->p_memsz > TASK_SIZE ||
49807 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49808 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49809 + elf_ppnt->p_memsz > pax_task_size ||
49810 + pax_task_size - elf_ppnt->p_memsz < k) {
49811 /* set_brk can never work. Avoid overflows. */
49812 send_sig(SIGKILL, current, 0);
49813 retval = -EINVAL;
49814 @@ -883,17 +1302,44 @@ static int load_elf_binary(struct linux_binprm *bprm)
49815 goto out_free_dentry;
49816 }
49817 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49818 - send_sig(SIGSEGV, current, 0);
49819 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49820 - goto out_free_dentry;
49821 + /*
49822 + * This bss-zeroing can fail if the ELF
49823 + * file specifies odd protections. So
49824 + * we don't check the return value
49825 + */
49826 }
49827
49828 +#ifdef CONFIG_PAX_RANDMMAP
49829 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49830 + unsigned long start, size, flags, vm_flags;
49831 +
49832 + start = ELF_PAGEALIGN(elf_brk);
49833 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49834 + flags = MAP_FIXED | MAP_PRIVATE;
49835 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49836 +
49837 + down_write(&current->mm->mmap_sem);
49838 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49839 + retval = -ENOMEM;
49840 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49841 +// if (current->personality & ADDR_NO_RANDOMIZE)
49842 +// vm_flags |= VM_READ | VM_MAYREAD;
49843 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
49844 + retval = IS_ERR_VALUE(start) ? start : 0;
49845 + }
49846 + up_write(&current->mm->mmap_sem);
49847 + if (retval == 0)
49848 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49849 + if (retval < 0) {
49850 + send_sig(SIGKILL, current, 0);
49851 + goto out_free_dentry;
49852 + }
49853 + }
49854 +#endif
49855 +
49856 if (elf_interpreter) {
49857 - unsigned long interp_map_addr = 0;
49858 -
49859 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49860 interpreter,
49861 - &interp_map_addr,
49862 load_bias);
49863 if (!IS_ERR((void *)elf_entry)) {
49864 /*
49865 @@ -1115,7 +1561,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49866 * Decide what to dump of a segment, part, all or none.
49867 */
49868 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49869 - unsigned long mm_flags)
49870 + unsigned long mm_flags, long signr)
49871 {
49872 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49873
49874 @@ -1153,7 +1599,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49875 if (vma->vm_file == NULL)
49876 return 0;
49877
49878 - if (FILTER(MAPPED_PRIVATE))
49879 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49880 goto whole;
49881
49882 /*
49883 @@ -1375,9 +1821,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49884 {
49885 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49886 int i = 0;
49887 - do
49888 + do {
49889 i += 2;
49890 - while (auxv[i - 2] != AT_NULL);
49891 + } while (auxv[i - 2] != AT_NULL);
49892 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49893 }
49894
49895 @@ -2007,14 +2453,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49896 }
49897
49898 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49899 - unsigned long mm_flags)
49900 + struct coredump_params *cprm)
49901 {
49902 struct vm_area_struct *vma;
49903 size_t size = 0;
49904
49905 for (vma = first_vma(current, gate_vma); vma != NULL;
49906 vma = next_vma(vma, gate_vma))
49907 - size += vma_dump_size(vma, mm_flags);
49908 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49909 return size;
49910 }
49911
49912 @@ -2108,7 +2554,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49913
49914 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49915
49916 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49917 + offset += elf_core_vma_data_size(gate_vma, cprm);
49918 offset += elf_core_extra_data_size();
49919 e_shoff = offset;
49920
49921 @@ -2122,10 +2568,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49922 offset = dataoff;
49923
49924 size += sizeof(*elf);
49925 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49926 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49927 goto end_coredump;
49928
49929 size += sizeof(*phdr4note);
49930 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49931 if (size > cprm->limit
49932 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49933 goto end_coredump;
49934 @@ -2139,7 +2587,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49935 phdr.p_offset = offset;
49936 phdr.p_vaddr = vma->vm_start;
49937 phdr.p_paddr = 0;
49938 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49939 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49940 phdr.p_memsz = vma->vm_end - vma->vm_start;
49941 offset += phdr.p_filesz;
49942 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49943 @@ -2150,6 +2598,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49944 phdr.p_align = ELF_EXEC_PAGESIZE;
49945
49946 size += sizeof(phdr);
49947 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49948 if (size > cprm->limit
49949 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49950 goto end_coredump;
49951 @@ -2174,7 +2623,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49952 unsigned long addr;
49953 unsigned long end;
49954
49955 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49956 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49957
49958 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49959 struct page *page;
49960 @@ -2183,6 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49961 page = get_dump_page(addr);
49962 if (page) {
49963 void *kaddr = kmap(page);
49964 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49965 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49966 !dump_write(cprm->file, kaddr,
49967 PAGE_SIZE);
49968 @@ -2200,6 +2650,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49969
49970 if (e_phnum == PN_XNUM) {
49971 size += sizeof(*shdr4extnum);
49972 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49973 if (size > cprm->limit
49974 || !dump_write(cprm->file, shdr4extnum,
49975 sizeof(*shdr4extnum)))
49976 @@ -2220,6 +2671,97 @@ out:
49977
49978 #endif /* CONFIG_ELF_CORE */
49979
49980 +#ifdef CONFIG_PAX_MPROTECT
49981 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49982 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49983 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49984 + *
49985 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49986 + * basis because we want to allow the common case and not the special ones.
49987 + */
49988 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49989 +{
49990 + struct elfhdr elf_h;
49991 + struct elf_phdr elf_p;
49992 + unsigned long i;
49993 + unsigned long oldflags;
49994 + bool is_textrel_rw, is_textrel_rx, is_relro;
49995 +
49996 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49997 + return;
49998 +
49999 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
50000 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
50001 +
50002 +#ifdef CONFIG_PAX_ELFRELOCS
50003 + /* possible TEXTREL */
50004 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
50005 + 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);
50006 +#else
50007 + is_textrel_rw = false;
50008 + is_textrel_rx = false;
50009 +#endif
50010 +
50011 + /* possible RELRO */
50012 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
50013 +
50014 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
50015 + return;
50016 +
50017 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
50018 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
50019 +
50020 +#ifdef CONFIG_PAX_ETEXECRELOCS
50021 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
50022 +#else
50023 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
50024 +#endif
50025 +
50026 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
50027 + !elf_check_arch(&elf_h) ||
50028 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
50029 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
50030 + return;
50031 +
50032 + for (i = 0UL; i < elf_h.e_phnum; i++) {
50033 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
50034 + return;
50035 + switch (elf_p.p_type) {
50036 + case PT_DYNAMIC:
50037 + if (!is_textrel_rw && !is_textrel_rx)
50038 + continue;
50039 + i = 0UL;
50040 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
50041 + elf_dyn dyn;
50042 +
50043 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
50044 + return;
50045 + if (dyn.d_tag == DT_NULL)
50046 + return;
50047 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
50048 + gr_log_textrel(vma);
50049 + if (is_textrel_rw)
50050 + vma->vm_flags |= VM_MAYWRITE;
50051 + else
50052 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
50053 + vma->vm_flags &= ~VM_MAYWRITE;
50054 + return;
50055 + }
50056 + i++;
50057 + }
50058 + return;
50059 +
50060 + case PT_GNU_RELRO:
50061 + if (!is_relro)
50062 + continue;
50063 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
50064 + vma->vm_flags &= ~VM_MAYWRITE;
50065 + return;
50066 + }
50067 + }
50068 +}
50069 +#endif
50070 +
50071 static int __init init_elf_binfmt(void)
50072 {
50073 register_binfmt(&elf_format);
50074 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
50075 index b563719..3868998 100644
50076 --- a/fs/binfmt_flat.c
50077 +++ b/fs/binfmt_flat.c
50078 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
50079 realdatastart = (unsigned long) -ENOMEM;
50080 printk("Unable to allocate RAM for process data, errno %d\n",
50081 (int)-realdatastart);
50082 + down_write(&current->mm->mmap_sem);
50083 vm_munmap(textpos, text_len);
50084 + up_write(&current->mm->mmap_sem);
50085 ret = realdatastart;
50086 goto err;
50087 }
50088 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
50089 }
50090 if (IS_ERR_VALUE(result)) {
50091 printk("Unable to read data+bss, errno %d\n", (int)-result);
50092 + down_write(&current->mm->mmap_sem);
50093 vm_munmap(textpos, text_len);
50094 vm_munmap(realdatastart, len);
50095 + up_write(&current->mm->mmap_sem);
50096 ret = result;
50097 goto err;
50098 }
50099 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
50100 }
50101 if (IS_ERR_VALUE(result)) {
50102 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
50103 + down_write(&current->mm->mmap_sem);
50104 vm_munmap(textpos, text_len + data_len + extra +
50105 MAX_SHARED_LIBS * sizeof(unsigned long));
50106 + up_write(&current->mm->mmap_sem);
50107 ret = result;
50108 goto err;
50109 }
50110 diff --git a/fs/bio.c b/fs/bio.c
50111 index b96fc6c..431d628 100644
50112 --- a/fs/bio.c
50113 +++ b/fs/bio.c
50114 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
50115 /*
50116 * Overflow, abort
50117 */
50118 - if (end < start)
50119 + if (end < start || end - start > INT_MAX - nr_pages)
50120 return ERR_PTR(-EINVAL);
50121
50122 nr_pages += end - start;
50123 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
50124 /*
50125 * Overflow, abort
50126 */
50127 - if (end < start)
50128 + if (end < start || end - start > INT_MAX - nr_pages)
50129 return ERR_PTR(-EINVAL);
50130
50131 nr_pages += end - start;
50132 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
50133 const int read = bio_data_dir(bio) == READ;
50134 struct bio_map_data *bmd = bio->bi_private;
50135 int i;
50136 - char *p = bmd->sgvecs[0].iov_base;
50137 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
50138
50139 __bio_for_each_segment(bvec, bio, i, 0) {
50140 char *addr = page_address(bvec->bv_page);
50141 diff --git a/fs/block_dev.c b/fs/block_dev.c
50142 index 883dc49..f27794a 100644
50143 --- a/fs/block_dev.c
50144 +++ b/fs/block_dev.c
50145 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
50146 else if (bdev->bd_contains == bdev)
50147 return true; /* is a whole device which isn't held */
50148
50149 - else if (whole->bd_holder == bd_may_claim)
50150 + else if (whole->bd_holder == (void *)bd_may_claim)
50151 return true; /* is a partition of a device that is being partitioned */
50152 else if (whole->bd_holder != NULL)
50153 return false; /* is a partition of a held device */
50154 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
50155 index ce1c169..1ef484f 100644
50156 --- a/fs/btrfs/ctree.c
50157 +++ b/fs/btrfs/ctree.c
50158 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
50159 free_extent_buffer(buf);
50160 add_root_to_dirty_list(root);
50161 } else {
50162 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
50163 - parent_start = parent->start;
50164 - else
50165 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
50166 + if (parent)
50167 + parent_start = parent->start;
50168 + else
50169 + parent_start = 0;
50170 + } else
50171 parent_start = 0;
50172
50173 WARN_ON(trans->transid != btrfs_header_generation(parent));
50174 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
50175 index 7c4e6cc..27bd5c2 100644
50176 --- a/fs/btrfs/inode.c
50177 +++ b/fs/btrfs/inode.c
50178 @@ -7314,7 +7314,7 @@ fail:
50179 return -ENOMEM;
50180 }
50181
50182 -static int btrfs_getattr(struct vfsmount *mnt,
50183 +int btrfs_getattr(struct vfsmount *mnt,
50184 struct dentry *dentry, struct kstat *stat)
50185 {
50186 struct inode *inode = dentry->d_inode;
50187 @@ -7328,6 +7328,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
50188 return 0;
50189 }
50190
50191 +EXPORT_SYMBOL(btrfs_getattr);
50192 +
50193 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
50194 +{
50195 + return BTRFS_I(inode)->root->anon_dev;
50196 +}
50197 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
50198 +
50199 /*
50200 * If a file is moved, it will inherit the cow and compression flags of the new
50201 * directory.
50202 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
50203 index 338f259..b657640 100644
50204 --- a/fs/btrfs/ioctl.c
50205 +++ b/fs/btrfs/ioctl.c
50206 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
50207 for (i = 0; i < num_types; i++) {
50208 struct btrfs_space_info *tmp;
50209
50210 + /* Don't copy in more than we allocated */
50211 if (!slot_count)
50212 break;
50213
50214 + slot_count--;
50215 +
50216 info = NULL;
50217 rcu_read_lock();
50218 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
50219 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
50220 memcpy(dest, &space, sizeof(space));
50221 dest++;
50222 space_args.total_spaces++;
50223 - slot_count--;
50224 }
50225 - if (!slot_count)
50226 - break;
50227 }
50228 up_read(&info->groups_sem);
50229 }
50230 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
50231 index 300e09a..9fe4539 100644
50232 --- a/fs/btrfs/relocation.c
50233 +++ b/fs/btrfs/relocation.c
50234 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
50235 }
50236 spin_unlock(&rc->reloc_root_tree.lock);
50237
50238 - BUG_ON((struct btrfs_root *)node->data != root);
50239 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
50240
50241 if (!del) {
50242 spin_lock(&rc->reloc_root_tree.lock);
50243 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
50244 index d8982e9..29a85fa 100644
50245 --- a/fs/btrfs/super.c
50246 +++ b/fs/btrfs/super.c
50247 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
50248 function, line, errstr);
50249 return;
50250 }
50251 - ACCESS_ONCE(trans->transaction->aborted) = errno;
50252 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
50253 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
50254 }
50255 /*
50256 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
50257 index 622f469..e8d2d55 100644
50258 --- a/fs/cachefiles/bind.c
50259 +++ b/fs/cachefiles/bind.c
50260 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
50261 args);
50262
50263 /* start by checking things over */
50264 - ASSERT(cache->fstop_percent >= 0 &&
50265 - cache->fstop_percent < cache->fcull_percent &&
50266 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
50267 cache->fcull_percent < cache->frun_percent &&
50268 cache->frun_percent < 100);
50269
50270 - ASSERT(cache->bstop_percent >= 0 &&
50271 - cache->bstop_percent < cache->bcull_percent &&
50272 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
50273 cache->bcull_percent < cache->brun_percent &&
50274 cache->brun_percent < 100);
50275
50276 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
50277 index 0a1467b..6a53245 100644
50278 --- a/fs/cachefiles/daemon.c
50279 +++ b/fs/cachefiles/daemon.c
50280 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
50281 if (n > buflen)
50282 return -EMSGSIZE;
50283
50284 - if (copy_to_user(_buffer, buffer, n) != 0)
50285 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
50286 return -EFAULT;
50287
50288 return n;
50289 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
50290 if (test_bit(CACHEFILES_DEAD, &cache->flags))
50291 return -EIO;
50292
50293 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
50294 + if (datalen > PAGE_SIZE - 1)
50295 return -EOPNOTSUPP;
50296
50297 /* drag the command string into the kernel so we can parse it */
50298 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
50299 if (args[0] != '%' || args[1] != '\0')
50300 return -EINVAL;
50301
50302 - if (fstop < 0 || fstop >= cache->fcull_percent)
50303 + if (fstop >= cache->fcull_percent)
50304 return cachefiles_daemon_range_error(cache, args);
50305
50306 cache->fstop_percent = fstop;
50307 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
50308 if (args[0] != '%' || args[1] != '\0')
50309 return -EINVAL;
50310
50311 - if (bstop < 0 || bstop >= cache->bcull_percent)
50312 + if (bstop >= cache->bcull_percent)
50313 return cachefiles_daemon_range_error(cache, args);
50314
50315 cache->bstop_percent = bstop;
50316 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
50317 index 4938251..7e01445 100644
50318 --- a/fs/cachefiles/internal.h
50319 +++ b/fs/cachefiles/internal.h
50320 @@ -59,7 +59,7 @@ struct cachefiles_cache {
50321 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
50322 struct rb_root active_nodes; /* active nodes (can't be culled) */
50323 rwlock_t active_lock; /* lock for active_nodes */
50324 - atomic_t gravecounter; /* graveyard uniquifier */
50325 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
50326 unsigned frun_percent; /* when to stop culling (% files) */
50327 unsigned fcull_percent; /* when to start culling (% files) */
50328 unsigned fstop_percent; /* when to stop allocating (% files) */
50329 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
50330 * proc.c
50331 */
50332 #ifdef CONFIG_CACHEFILES_HISTOGRAM
50333 -extern atomic_t cachefiles_lookup_histogram[HZ];
50334 -extern atomic_t cachefiles_mkdir_histogram[HZ];
50335 -extern atomic_t cachefiles_create_histogram[HZ];
50336 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
50337 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
50338 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
50339
50340 extern int __init cachefiles_proc_init(void);
50341 extern void cachefiles_proc_cleanup(void);
50342 static inline
50343 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
50344 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
50345 {
50346 unsigned long jif = jiffies - start_jif;
50347 if (jif >= HZ)
50348 jif = HZ - 1;
50349 - atomic_inc(&histogram[jif]);
50350 + atomic_inc_unchecked(&histogram[jif]);
50351 }
50352
50353 #else
50354 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
50355 index 8c01c5fc..15f982e 100644
50356 --- a/fs/cachefiles/namei.c
50357 +++ b/fs/cachefiles/namei.c
50358 @@ -317,7 +317,7 @@ try_again:
50359 /* first step is to make up a grave dentry in the graveyard */
50360 sprintf(nbuffer, "%08x%08x",
50361 (uint32_t) get_seconds(),
50362 - (uint32_t) atomic_inc_return(&cache->gravecounter));
50363 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
50364
50365 /* do the multiway lock magic */
50366 trap = lock_rename(cache->graveyard, dir);
50367 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
50368 index eccd339..4c1d995 100644
50369 --- a/fs/cachefiles/proc.c
50370 +++ b/fs/cachefiles/proc.c
50371 @@ -14,9 +14,9 @@
50372 #include <linux/seq_file.h>
50373 #include "internal.h"
50374
50375 -atomic_t cachefiles_lookup_histogram[HZ];
50376 -atomic_t cachefiles_mkdir_histogram[HZ];
50377 -atomic_t cachefiles_create_histogram[HZ];
50378 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
50379 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
50380 +atomic_unchecked_t cachefiles_create_histogram[HZ];
50381
50382 /*
50383 * display the latency histogram
50384 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
50385 return 0;
50386 default:
50387 index = (unsigned long) v - 3;
50388 - x = atomic_read(&cachefiles_lookup_histogram[index]);
50389 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
50390 - z = atomic_read(&cachefiles_create_histogram[index]);
50391 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
50392 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
50393 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
50394 if (x == 0 && y == 0 && z == 0)
50395 return 0;
50396
50397 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
50398 index 4809922..aab2c39 100644
50399 --- a/fs/cachefiles/rdwr.c
50400 +++ b/fs/cachefiles/rdwr.c
50401 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
50402 old_fs = get_fs();
50403 set_fs(KERNEL_DS);
50404 ret = file->f_op->write(
50405 - file, (const void __user *) data, len, &pos);
50406 + file, (const void __force_user *) data, len, &pos);
50407 set_fs(old_fs);
50408 kunmap(page);
50409 if (ret != len)
50410 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
50411 index 8c1aabe..bbf856a 100644
50412 --- a/fs/ceph/dir.c
50413 +++ b/fs/ceph/dir.c
50414 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
50415 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
50416 struct ceph_mds_client *mdsc = fsc->mdsc;
50417 unsigned frag = fpos_frag(filp->f_pos);
50418 - int off = fpos_off(filp->f_pos);
50419 + unsigned int off = fpos_off(filp->f_pos);
50420 int err;
50421 u32 ftype;
50422 struct ceph_mds_reply_info_parsed *rinfo;
50423 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
50424 index d9ea6ed..1e6c8ac 100644
50425 --- a/fs/cifs/cifs_debug.c
50426 +++ b/fs/cifs/cifs_debug.c
50427 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
50428
50429 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
50430 #ifdef CONFIG_CIFS_STATS2
50431 - atomic_set(&totBufAllocCount, 0);
50432 - atomic_set(&totSmBufAllocCount, 0);
50433 + atomic_set_unchecked(&totBufAllocCount, 0);
50434 + atomic_set_unchecked(&totSmBufAllocCount, 0);
50435 #endif /* CONFIG_CIFS_STATS2 */
50436 spin_lock(&cifs_tcp_ses_lock);
50437 list_for_each(tmp1, &cifs_tcp_ses_list) {
50438 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
50439 tcon = list_entry(tmp3,
50440 struct cifs_tcon,
50441 tcon_list);
50442 - atomic_set(&tcon->num_smbs_sent, 0);
50443 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
50444 if (server->ops->clear_stats)
50445 server->ops->clear_stats(tcon);
50446 }
50447 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
50448 smBufAllocCount.counter, cifs_min_small);
50449 #ifdef CONFIG_CIFS_STATS2
50450 seq_printf(m, "Total Large %d Small %d Allocations\n",
50451 - atomic_read(&totBufAllocCount),
50452 - atomic_read(&totSmBufAllocCount));
50453 + atomic_read_unchecked(&totBufAllocCount),
50454 + atomic_read_unchecked(&totSmBufAllocCount));
50455 #endif /* CONFIG_CIFS_STATS2 */
50456
50457 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
50458 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
50459 if (tcon->need_reconnect)
50460 seq_puts(m, "\tDISCONNECTED ");
50461 seq_printf(m, "\nSMBs: %d",
50462 - atomic_read(&tcon->num_smbs_sent));
50463 + atomic_read_unchecked(&tcon->num_smbs_sent));
50464 if (server->ops->print_stats)
50465 server->ops->print_stats(m, tcon);
50466 }
50467 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
50468 index b9db388..9a73d6d 100644
50469 --- a/fs/cifs/cifsfs.c
50470 +++ b/fs/cifs/cifsfs.c
50471 @@ -1026,7 +1026,7 @@ cifs_init_request_bufs(void)
50472 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
50473 cifs_req_cachep = kmem_cache_create("cifs_request",
50474 CIFSMaxBufSize + max_hdr_size, 0,
50475 - SLAB_HWCACHE_ALIGN, NULL);
50476 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
50477 if (cifs_req_cachep == NULL)
50478 return -ENOMEM;
50479
50480 @@ -1053,7 +1053,7 @@ cifs_init_request_bufs(void)
50481 efficient to alloc 1 per page off the slab compared to 17K (5page)
50482 alloc of large cifs buffers even when page debugging is on */
50483 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
50484 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
50485 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
50486 NULL);
50487 if (cifs_sm_req_cachep == NULL) {
50488 mempool_destroy(cifs_req_poolp);
50489 @@ -1138,8 +1138,8 @@ init_cifs(void)
50490 atomic_set(&bufAllocCount, 0);
50491 atomic_set(&smBufAllocCount, 0);
50492 #ifdef CONFIG_CIFS_STATS2
50493 - atomic_set(&totBufAllocCount, 0);
50494 - atomic_set(&totSmBufAllocCount, 0);
50495 + atomic_set_unchecked(&totBufAllocCount, 0);
50496 + atomic_set_unchecked(&totSmBufAllocCount, 0);
50497 #endif /* CONFIG_CIFS_STATS2 */
50498
50499 atomic_set(&midCount, 0);
50500 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
50501 index e6899ce..d6b2920 100644
50502 --- a/fs/cifs/cifsglob.h
50503 +++ b/fs/cifs/cifsglob.h
50504 @@ -751,35 +751,35 @@ struct cifs_tcon {
50505 __u16 Flags; /* optional support bits */
50506 enum statusEnum tidStatus;
50507 #ifdef CONFIG_CIFS_STATS
50508 - atomic_t num_smbs_sent;
50509 + atomic_unchecked_t num_smbs_sent;
50510 union {
50511 struct {
50512 - atomic_t num_writes;
50513 - atomic_t num_reads;
50514 - atomic_t num_flushes;
50515 - atomic_t num_oplock_brks;
50516 - atomic_t num_opens;
50517 - atomic_t num_closes;
50518 - atomic_t num_deletes;
50519 - atomic_t num_mkdirs;
50520 - atomic_t num_posixopens;
50521 - atomic_t num_posixmkdirs;
50522 - atomic_t num_rmdirs;
50523 - atomic_t num_renames;
50524 - atomic_t num_t2renames;
50525 - atomic_t num_ffirst;
50526 - atomic_t num_fnext;
50527 - atomic_t num_fclose;
50528 - atomic_t num_hardlinks;
50529 - atomic_t num_symlinks;
50530 - atomic_t num_locks;
50531 - atomic_t num_acl_get;
50532 - atomic_t num_acl_set;
50533 + atomic_unchecked_t num_writes;
50534 + atomic_unchecked_t num_reads;
50535 + atomic_unchecked_t num_flushes;
50536 + atomic_unchecked_t num_oplock_brks;
50537 + atomic_unchecked_t num_opens;
50538 + atomic_unchecked_t num_closes;
50539 + atomic_unchecked_t num_deletes;
50540 + atomic_unchecked_t num_mkdirs;
50541 + atomic_unchecked_t num_posixopens;
50542 + atomic_unchecked_t num_posixmkdirs;
50543 + atomic_unchecked_t num_rmdirs;
50544 + atomic_unchecked_t num_renames;
50545 + atomic_unchecked_t num_t2renames;
50546 + atomic_unchecked_t num_ffirst;
50547 + atomic_unchecked_t num_fnext;
50548 + atomic_unchecked_t num_fclose;
50549 + atomic_unchecked_t num_hardlinks;
50550 + atomic_unchecked_t num_symlinks;
50551 + atomic_unchecked_t num_locks;
50552 + atomic_unchecked_t num_acl_get;
50553 + atomic_unchecked_t num_acl_set;
50554 } cifs_stats;
50555 #ifdef CONFIG_CIFS_SMB2
50556 struct {
50557 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
50558 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
50559 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
50560 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
50561 } smb2_stats;
50562 #endif /* CONFIG_CIFS_SMB2 */
50563 } stats;
50564 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
50565 }
50566
50567 #ifdef CONFIG_CIFS_STATS
50568 -#define cifs_stats_inc atomic_inc
50569 +#define cifs_stats_inc atomic_inc_unchecked
50570
50571 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
50572 unsigned int bytes)
50573 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
50574 /* Various Debug counters */
50575 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
50576 #ifdef CONFIG_CIFS_STATS2
50577 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
50578 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
50579 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
50580 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
50581 #endif
50582 GLOBAL_EXTERN atomic_t smBufAllocCount;
50583 GLOBAL_EXTERN atomic_t midCount;
50584 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
50585 index 51dc2fb..1e12a33 100644
50586 --- a/fs/cifs/link.c
50587 +++ b/fs/cifs/link.c
50588 @@ -616,7 +616,7 @@ symlink_exit:
50589
50590 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
50591 {
50592 - char *p = nd_get_link(nd);
50593 + const char *p = nd_get_link(nd);
50594 if (!IS_ERR(p))
50595 kfree(p);
50596 }
50597 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
50598 index 3a00c0d..42d901c 100644
50599 --- a/fs/cifs/misc.c
50600 +++ b/fs/cifs/misc.c
50601 @@ -169,7 +169,7 @@ cifs_buf_get(void)
50602 memset(ret_buf, 0, buf_size + 3);
50603 atomic_inc(&bufAllocCount);
50604 #ifdef CONFIG_CIFS_STATS2
50605 - atomic_inc(&totBufAllocCount);
50606 + atomic_inc_unchecked(&totBufAllocCount);
50607 #endif /* CONFIG_CIFS_STATS2 */
50608 }
50609
50610 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
50611 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
50612 atomic_inc(&smBufAllocCount);
50613 #ifdef CONFIG_CIFS_STATS2
50614 - atomic_inc(&totSmBufAllocCount);
50615 + atomic_inc_unchecked(&totSmBufAllocCount);
50616 #endif /* CONFIG_CIFS_STATS2 */
50617
50618 }
50619 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50620 index 47bc5a8..10decbe 100644
50621 --- a/fs/cifs/smb1ops.c
50622 +++ b/fs/cifs/smb1ops.c
50623 @@ -586,27 +586,27 @@ static void
50624 cifs_clear_stats(struct cifs_tcon *tcon)
50625 {
50626 #ifdef CONFIG_CIFS_STATS
50627 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50628 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50629 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50630 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50631 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50632 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50633 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50634 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50635 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50636 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50637 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50638 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50639 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50640 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50641 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50642 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50643 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50644 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50645 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50646 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50647 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50648 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50649 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50650 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50651 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50652 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50653 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50654 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50655 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50656 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50657 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50658 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50659 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50660 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50661 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50662 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50663 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50664 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50665 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50666 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50667 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50668 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50669 #endif
50670 }
50671
50672 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50673 {
50674 #ifdef CONFIG_CIFS_STATS
50675 seq_printf(m, " Oplocks breaks: %d",
50676 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50677 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50678 seq_printf(m, "\nReads: %d Bytes: %llu",
50679 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50680 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50681 (long long)(tcon->bytes_read));
50682 seq_printf(m, "\nWrites: %d Bytes: %llu",
50683 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50684 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50685 (long long)(tcon->bytes_written));
50686 seq_printf(m, "\nFlushes: %d",
50687 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50688 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50689 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50690 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50691 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50692 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50693 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50694 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50695 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50696 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50697 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50698 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50699 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50700 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50701 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50702 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50703 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50704 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50705 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50706 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50707 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50708 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50709 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50710 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50711 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50712 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50713 seq_printf(m, "\nRenames: %d T2 Renames %d",
50714 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50715 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50716 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50717 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50718 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50719 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50720 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50721 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50722 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50723 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50724 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50725 #endif
50726 }
50727
50728 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50729 index bceffe7..cd1ae59 100644
50730 --- a/fs/cifs/smb2ops.c
50731 +++ b/fs/cifs/smb2ops.c
50732 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50733 #ifdef CONFIG_CIFS_STATS
50734 int i;
50735 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50736 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50737 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50738 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50739 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50740 }
50741 #endif
50742 }
50743 @@ -284,66 +284,66 @@ static void
50744 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50745 {
50746 #ifdef CONFIG_CIFS_STATS
50747 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50748 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50749 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50750 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50751 seq_printf(m, "\nNegotiates: %d sent %d failed",
50752 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50753 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50754 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50755 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50756 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50757 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50758 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50759 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50760 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50761 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50762 seq_printf(m, "\nLogoffs: %d sent %d failed",
50763 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50764 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50765 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50766 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50767 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50768 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50769 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50770 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50771 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50772 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50773 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50774 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50775 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50776 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50777 seq_printf(m, "\nCreates: %d sent %d failed",
50778 - atomic_read(&sent[SMB2_CREATE_HE]),
50779 - atomic_read(&failed[SMB2_CREATE_HE]));
50780 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50781 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50782 seq_printf(m, "\nCloses: %d sent %d failed",
50783 - atomic_read(&sent[SMB2_CLOSE_HE]),
50784 - atomic_read(&failed[SMB2_CLOSE_HE]));
50785 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50786 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50787 seq_printf(m, "\nFlushes: %d sent %d failed",
50788 - atomic_read(&sent[SMB2_FLUSH_HE]),
50789 - atomic_read(&failed[SMB2_FLUSH_HE]));
50790 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50791 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50792 seq_printf(m, "\nReads: %d sent %d failed",
50793 - atomic_read(&sent[SMB2_READ_HE]),
50794 - atomic_read(&failed[SMB2_READ_HE]));
50795 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50796 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50797 seq_printf(m, "\nWrites: %d sent %d failed",
50798 - atomic_read(&sent[SMB2_WRITE_HE]),
50799 - atomic_read(&failed[SMB2_WRITE_HE]));
50800 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50801 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50802 seq_printf(m, "\nLocks: %d sent %d failed",
50803 - atomic_read(&sent[SMB2_LOCK_HE]),
50804 - atomic_read(&failed[SMB2_LOCK_HE]));
50805 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50806 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50807 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50808 - atomic_read(&sent[SMB2_IOCTL_HE]),
50809 - atomic_read(&failed[SMB2_IOCTL_HE]));
50810 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50811 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50812 seq_printf(m, "\nCancels: %d sent %d failed",
50813 - atomic_read(&sent[SMB2_CANCEL_HE]),
50814 - atomic_read(&failed[SMB2_CANCEL_HE]));
50815 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50816 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50817 seq_printf(m, "\nEchos: %d sent %d failed",
50818 - atomic_read(&sent[SMB2_ECHO_HE]),
50819 - atomic_read(&failed[SMB2_ECHO_HE]));
50820 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50821 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50822 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50823 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50824 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50825 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50826 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50827 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50828 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50829 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50830 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50831 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50832 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50833 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50834 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50835 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50836 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50837 seq_printf(m, "\nSetInfos: %d sent %d failed",
50838 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50839 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50840 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50841 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50842 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50843 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50844 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50845 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50846 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50847 #endif
50848 }
50849
50850 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50851 index 41d9d07..dbb4772 100644
50852 --- a/fs/cifs/smb2pdu.c
50853 +++ b/fs/cifs/smb2pdu.c
50854 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50855 default:
50856 cERROR(1, "info level %u isn't supported",
50857 srch_inf->info_level);
50858 - rc = -EINVAL;
50859 - goto qdir_exit;
50860 + return -EINVAL;
50861 }
50862
50863 req->FileIndex = cpu_to_le32(index);
50864 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50865 index 958ae0e..505c9d0 100644
50866 --- a/fs/coda/cache.c
50867 +++ b/fs/coda/cache.c
50868 @@ -24,7 +24,7 @@
50869 #include "coda_linux.h"
50870 #include "coda_cache.h"
50871
50872 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50873 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50874
50875 /* replace or extend an acl cache hit */
50876 void coda_cache_enter(struct inode *inode, int mask)
50877 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50878 struct coda_inode_info *cii = ITOC(inode);
50879
50880 spin_lock(&cii->c_lock);
50881 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50882 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50883 if (cii->c_uid != current_fsuid()) {
50884 cii->c_uid = current_fsuid();
50885 cii->c_cached_perm = mask;
50886 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50887 {
50888 struct coda_inode_info *cii = ITOC(inode);
50889 spin_lock(&cii->c_lock);
50890 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50891 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50892 spin_unlock(&cii->c_lock);
50893 }
50894
50895 /* remove all acl caches */
50896 void coda_cache_clear_all(struct super_block *sb)
50897 {
50898 - atomic_inc(&permission_epoch);
50899 + atomic_inc_unchecked(&permission_epoch);
50900 }
50901
50902
50903 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50904 spin_lock(&cii->c_lock);
50905 hit = (mask & cii->c_cached_perm) == mask &&
50906 cii->c_uid == current_fsuid() &&
50907 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50908 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50909 spin_unlock(&cii->c_lock);
50910
50911 return hit;
50912 diff --git a/fs/compat.c b/fs/compat.c
50913 index a06dcbc..dacb6d3 100644
50914 --- a/fs/compat.c
50915 +++ b/fs/compat.c
50916 @@ -54,7 +54,7 @@
50917 #include <asm/ioctls.h>
50918 #include "internal.h"
50919
50920 -int compat_log = 1;
50921 +int compat_log = 0;
50922
50923 int compat_printk(const char *fmt, ...)
50924 {
50925 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50926
50927 set_fs(KERNEL_DS);
50928 /* The __user pointer cast is valid because of the set_fs() */
50929 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50930 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50931 set_fs(oldfs);
50932 /* truncating is ok because it's a user address */
50933 if (!ret)
50934 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50935 goto out;
50936
50937 ret = -EINVAL;
50938 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50939 + if (nr_segs > UIO_MAXIOV)
50940 goto out;
50941 if (nr_segs > fast_segs) {
50942 ret = -ENOMEM;
50943 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50944
50945 struct compat_readdir_callback {
50946 struct compat_old_linux_dirent __user *dirent;
50947 + struct file * file;
50948 int result;
50949 };
50950
50951 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50952 buf->result = -EOVERFLOW;
50953 return -EOVERFLOW;
50954 }
50955 +
50956 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50957 + return 0;
50958 +
50959 buf->result++;
50960 dirent = buf->dirent;
50961 if (!access_ok(VERIFY_WRITE, dirent,
50962 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50963
50964 buf.result = 0;
50965 buf.dirent = dirent;
50966 + buf.file = f.file;
50967
50968 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50969 if (buf.result)
50970 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50971 struct compat_getdents_callback {
50972 struct compat_linux_dirent __user *current_dir;
50973 struct compat_linux_dirent __user *previous;
50974 + struct file * file;
50975 int count;
50976 int error;
50977 };
50978 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50979 buf->error = -EOVERFLOW;
50980 return -EOVERFLOW;
50981 }
50982 +
50983 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50984 + return 0;
50985 +
50986 dirent = buf->previous;
50987 if (dirent) {
50988 if (__put_user(offset, &dirent->d_off))
50989 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50990 buf.previous = NULL;
50991 buf.count = count;
50992 buf.error = 0;
50993 + buf.file = f.file;
50994
50995 error = vfs_readdir(f.file, compat_filldir, &buf);
50996 if (error >= 0)
50997 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50998 struct compat_getdents_callback64 {
50999 struct linux_dirent64 __user *current_dir;
51000 struct linux_dirent64 __user *previous;
51001 + struct file * file;
51002 int count;
51003 int error;
51004 };
51005 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
51006 buf->error = -EINVAL; /* only used if we fail.. */
51007 if (reclen > buf->count)
51008 return -EINVAL;
51009 +
51010 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
51011 + return 0;
51012 +
51013 dirent = buf->previous;
51014
51015 if (dirent) {
51016 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
51017 buf.previous = NULL;
51018 buf.count = count;
51019 buf.error = 0;
51020 + buf.file = f.file;
51021
51022 error = vfs_readdir(f.file, compat_filldir64, &buf);
51023 if (error >= 0)
51024 error = buf.error;
51025 lastdirent = buf.previous;
51026 if (lastdirent) {
51027 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
51028 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
51029 if (__put_user_unaligned(d_off, &lastdirent->d_off))
51030 error = -EFAULT;
51031 else
51032 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
51033 index a81147e..20bf2b5 100644
51034 --- a/fs/compat_binfmt_elf.c
51035 +++ b/fs/compat_binfmt_elf.c
51036 @@ -30,11 +30,13 @@
51037 #undef elf_phdr
51038 #undef elf_shdr
51039 #undef elf_note
51040 +#undef elf_dyn
51041 #undef elf_addr_t
51042 #define elfhdr elf32_hdr
51043 #define elf_phdr elf32_phdr
51044 #define elf_shdr elf32_shdr
51045 #define elf_note elf32_note
51046 +#define elf_dyn Elf32_Dyn
51047 #define elf_addr_t Elf32_Addr
51048
51049 /*
51050 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
51051 index e2f57a0..3c78771 100644
51052 --- a/fs/compat_ioctl.c
51053 +++ b/fs/compat_ioctl.c
51054 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
51055 return -EFAULT;
51056 if (__get_user(udata, &ss32->iomem_base))
51057 return -EFAULT;
51058 - ss.iomem_base = compat_ptr(udata);
51059 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
51060 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
51061 __get_user(ss.port_high, &ss32->port_high))
51062 return -EFAULT;
51063 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
51064 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
51065 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
51066 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
51067 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
51068 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
51069 return -EFAULT;
51070
51071 return ioctl_preallocate(file, p);
51072 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
51073 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
51074 {
51075 unsigned int a, b;
51076 - a = *(unsigned int *)p;
51077 - b = *(unsigned int *)q;
51078 + a = *(const unsigned int *)p;
51079 + b = *(const unsigned int *)q;
51080 if (a > b)
51081 return 1;
51082 if (a < b)
51083 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
51084 index 712b10f..c33c4ca 100644
51085 --- a/fs/configfs/dir.c
51086 +++ b/fs/configfs/dir.c
51087 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
51088 static int configfs_depend_prep(struct dentry *origin,
51089 struct config_item *target)
51090 {
51091 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
51092 + struct configfs_dirent *child_sd, *sd;
51093 int ret = 0;
51094
51095 - BUG_ON(!origin || !sd);
51096 + BUG_ON(!origin || !origin->d_fsdata);
51097 + sd = origin->d_fsdata;
51098
51099 if (sd->s_element == target) /* Boo-yah */
51100 goto out;
51101 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
51102 }
51103 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
51104 struct configfs_dirent *next;
51105 - const char * name;
51106 + const unsigned char * name;
51107 + char d_name[sizeof(next->s_dentry->d_iname)];
51108 int len;
51109 struct inode *inode = NULL;
51110
51111 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
51112 continue;
51113
51114 name = configfs_get_name(next);
51115 - len = strlen(name);
51116 + if (next->s_dentry && name == next->s_dentry->d_iname) {
51117 + len = next->s_dentry->d_name.len;
51118 + memcpy(d_name, name, len);
51119 + name = d_name;
51120 + } else
51121 + len = strlen(name);
51122
51123 /*
51124 * We'll have a dentry and an inode for
51125 diff --git a/fs/coredump.c b/fs/coredump.c
51126 index 1774932..5812106 100644
51127 --- a/fs/coredump.c
51128 +++ b/fs/coredump.c
51129 @@ -52,7 +52,7 @@ struct core_name {
51130 char *corename;
51131 int used, size;
51132 };
51133 -static atomic_t call_count = ATOMIC_INIT(1);
51134 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
51135
51136 /* The maximal length of core_pattern is also specified in sysctl.c */
51137
51138 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
51139 {
51140 char *old_corename = cn->corename;
51141
51142 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
51143 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
51144 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
51145
51146 if (!cn->corename) {
51147 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
51148 int pid_in_pattern = 0;
51149 int err = 0;
51150
51151 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
51152 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
51153 cn->corename = kmalloc(cn->size, GFP_KERNEL);
51154 cn->used = 0;
51155
51156 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
51157 pipe = file->f_path.dentry->d_inode->i_pipe;
51158
51159 pipe_lock(pipe);
51160 - pipe->readers++;
51161 - pipe->writers--;
51162 + atomic_inc(&pipe->readers);
51163 + atomic_dec(&pipe->writers);
51164
51165 - while ((pipe->readers > 1) && (!signal_pending(current))) {
51166 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
51167 wake_up_interruptible_sync(&pipe->wait);
51168 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
51169 pipe_wait(pipe);
51170 }
51171
51172 - pipe->readers--;
51173 - pipe->writers++;
51174 + atomic_dec(&pipe->readers);
51175 + atomic_inc(&pipe->writers);
51176 pipe_unlock(pipe);
51177
51178 }
51179 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
51180 int ispipe;
51181 struct files_struct *displaced;
51182 bool need_nonrelative = false;
51183 - static atomic_t core_dump_count = ATOMIC_INIT(0);
51184 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
51185 + long signr = siginfo->si_signo;
51186 struct coredump_params cprm = {
51187 .siginfo = siginfo,
51188 .regs = signal_pt_regs(),
51189 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
51190 .mm_flags = mm->flags,
51191 };
51192
51193 - audit_core_dumps(siginfo->si_signo);
51194 + audit_core_dumps(signr);
51195 +
51196 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
51197 + gr_handle_brute_attach(cprm.mm_flags);
51198
51199 binfmt = mm->binfmt;
51200 if (!binfmt || !binfmt->core_dump)
51201 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
51202 need_nonrelative = true;
51203 }
51204
51205 - retval = coredump_wait(siginfo->si_signo, &core_state);
51206 + retval = coredump_wait(signr, &core_state);
51207 if (retval < 0)
51208 goto fail_creds;
51209
51210 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
51211 }
51212 cprm.limit = RLIM_INFINITY;
51213
51214 - dump_count = atomic_inc_return(&core_dump_count);
51215 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
51216 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
51217 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
51218 task_tgid_vnr(current), current->comm);
51219 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
51220 } else {
51221 struct inode *inode;
51222
51223 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
51224 +
51225 if (cprm.limit < binfmt->min_coredump)
51226 goto fail_unlock;
51227
51228 @@ -640,7 +646,7 @@ close_fail:
51229 filp_close(cprm.file, NULL);
51230 fail_dropcount:
51231 if (ispipe)
51232 - atomic_dec(&core_dump_count);
51233 + atomic_dec_unchecked(&core_dump_count);
51234 fail_unlock:
51235 kfree(cn.corename);
51236 fail_corename:
51237 @@ -659,7 +665,7 @@ fail:
51238 */
51239 int dump_write(struct file *file, const void *addr, int nr)
51240 {
51241 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
51242 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
51243 }
51244 EXPORT_SYMBOL(dump_write);
51245
51246 diff --git a/fs/dcache.c b/fs/dcache.c
51247 index c3bbf85..5b71101 100644
51248 --- a/fs/dcache.c
51249 +++ b/fs/dcache.c
51250 @@ -3139,7 +3139,7 @@ void __init vfs_caches_init(unsigned long mempages)
51251 mempages -= reserve;
51252
51253 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
51254 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
51255 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
51256
51257 dcache_init();
51258 inode_init();
51259 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
51260 index a5f12b7..4ee8a6f 100644
51261 --- a/fs/debugfs/inode.c
51262 +++ b/fs/debugfs/inode.c
51263 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
51264 */
51265 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
51266 {
51267 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
51268 + return __create_file(name, S_IFDIR | S_IRWXU,
51269 +#else
51270 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
51271 +#endif
51272 parent, NULL, NULL);
51273 }
51274 EXPORT_SYMBOL_GPL(debugfs_create_dir);
51275 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
51276 index cc7709e..7e7211f 100644
51277 --- a/fs/ecryptfs/inode.c
51278 +++ b/fs/ecryptfs/inode.c
51279 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
51280 old_fs = get_fs();
51281 set_fs(get_ds());
51282 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
51283 - (char __user *)lower_buf,
51284 + (char __force_user *)lower_buf,
51285 PATH_MAX);
51286 set_fs(old_fs);
51287 if (rc < 0)
51288 @@ -706,7 +706,7 @@ out:
51289 static void
51290 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
51291 {
51292 - char *buf = nd_get_link(nd);
51293 + const char *buf = nd_get_link(nd);
51294 if (!IS_ERR(buf)) {
51295 /* Free the char* */
51296 kfree(buf);
51297 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
51298 index 412e6ed..d8263e8 100644
51299 --- a/fs/ecryptfs/miscdev.c
51300 +++ b/fs/ecryptfs/miscdev.c
51301 @@ -80,13 +80,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
51302 int rc;
51303
51304 mutex_lock(&ecryptfs_daemon_hash_mux);
51305 - rc = try_module_get(THIS_MODULE);
51306 - if (rc == 0) {
51307 - rc = -EIO;
51308 - printk(KERN_ERR "%s: Error attempting to increment module use "
51309 - "count; rc = [%d]\n", __func__, rc);
51310 - goto out_unlock_daemon_list;
51311 - }
51312 rc = ecryptfs_find_daemon_by_euid(&daemon);
51313 if (!rc) {
51314 rc = -EINVAL;
51315 @@ -96,7 +89,7 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
51316 if (rc) {
51317 printk(KERN_ERR "%s: Error attempting to spawn daemon; "
51318 "rc = [%d]\n", __func__, rc);
51319 - goto out_module_put_unlock_daemon_list;
51320 + goto out_unlock_daemon_list;
51321 }
51322 mutex_lock(&daemon->mux);
51323 if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) {
51324 @@ -108,9 +101,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
51325 atomic_inc(&ecryptfs_num_miscdev_opens);
51326 out_unlock_daemon:
51327 mutex_unlock(&daemon->mux);
51328 -out_module_put_unlock_daemon_list:
51329 - if (rc)
51330 - module_put(THIS_MODULE);
51331 out_unlock_daemon_list:
51332 mutex_unlock(&ecryptfs_daemon_hash_mux);
51333 return rc;
51334 @@ -147,7 +137,6 @@ ecryptfs_miscdev_release(struct inode *inode, struct file *file)
51335 "bug.\n", __func__, rc);
51336 BUG();
51337 }
51338 - module_put(THIS_MODULE);
51339 return rc;
51340 }
51341
51342 @@ -315,7 +304,7 @@ check_list:
51343 goto out_unlock_msg_ctx;
51344 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
51345 if (msg_ctx->msg) {
51346 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
51347 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
51348 goto out_unlock_msg_ctx;
51349 i += packet_length_size;
51350 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
51351 @@ -471,6 +460,7 @@ out_free:
51352
51353
51354 static const struct file_operations ecryptfs_miscdev_fops = {
51355 + .owner = THIS_MODULE,
51356 .open = ecryptfs_miscdev_open,
51357 .poll = ecryptfs_miscdev_poll,
51358 .read = ecryptfs_miscdev_read,
51359 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
51360 index b2a34a1..162fa69 100644
51361 --- a/fs/ecryptfs/read_write.c
51362 +++ b/fs/ecryptfs/read_write.c
51363 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
51364 return -EIO;
51365 fs_save = get_fs();
51366 set_fs(get_ds());
51367 - rc = vfs_write(lower_file, data, size, &offset);
51368 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
51369 set_fs(fs_save);
51370 mark_inode_dirty_sync(ecryptfs_inode);
51371 return rc;
51372 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
51373 return -EIO;
51374 fs_save = get_fs();
51375 set_fs(get_ds());
51376 - rc = vfs_read(lower_file, data, size, &offset);
51377 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
51378 set_fs(fs_save);
51379 return rc;
51380 }
51381 diff --git a/fs/exec.c b/fs/exec.c
51382 index 20df02c..9a87617 100644
51383 --- a/fs/exec.c
51384 +++ b/fs/exec.c
51385 @@ -55,8 +55,20 @@
51386 #include <linux/pipe_fs_i.h>
51387 #include <linux/oom.h>
51388 #include <linux/compat.h>
51389 +#include <linux/random.h>
51390 +#include <linux/seq_file.h>
51391 +#include <linux/coredump.h>
51392 +#include <linux/mman.h>
51393 +
51394 +#ifdef CONFIG_PAX_REFCOUNT
51395 +#include <linux/kallsyms.h>
51396 +#include <linux/kdebug.h>
51397 +#endif
51398 +
51399 +#include <trace/events/fs.h>
51400
51401 #include <asm/uaccess.h>
51402 +#include <asm/sections.h>
51403 #include <asm/mmu_context.h>
51404 #include <asm/tlb.h>
51405
51406 @@ -66,6 +78,18 @@
51407
51408 #include <trace/events/sched.h>
51409
51410 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
51411 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
51412 +{
51413 + 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");
51414 +}
51415 +#endif
51416 +
51417 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
51418 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
51419 +EXPORT_SYMBOL(pax_set_initial_flags_func);
51420 +#endif
51421 +
51422 int suid_dumpable = 0;
51423
51424 static LIST_HEAD(formats);
51425 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
51426 {
51427 BUG_ON(!fmt);
51428 write_lock(&binfmt_lock);
51429 - insert ? list_add(&fmt->lh, &formats) :
51430 - list_add_tail(&fmt->lh, &formats);
51431 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
51432 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
51433 write_unlock(&binfmt_lock);
51434 }
51435
51436 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
51437 void unregister_binfmt(struct linux_binfmt * fmt)
51438 {
51439 write_lock(&binfmt_lock);
51440 - list_del(&fmt->lh);
51441 + pax_list_del((struct list_head *)&fmt->lh);
51442 write_unlock(&binfmt_lock);
51443 }
51444
51445 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
51446 int write)
51447 {
51448 struct page *page;
51449 - int ret;
51450
51451 -#ifdef CONFIG_STACK_GROWSUP
51452 - if (write) {
51453 - ret = expand_downwards(bprm->vma, pos);
51454 - if (ret < 0)
51455 - return NULL;
51456 - }
51457 -#endif
51458 - ret = get_user_pages(current, bprm->mm, pos,
51459 - 1, write, 1, &page, NULL);
51460 - if (ret <= 0)
51461 + if (0 > expand_downwards(bprm->vma, pos))
51462 + return NULL;
51463 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
51464 return NULL;
51465
51466 if (write) {
51467 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
51468 if (size <= ARG_MAX)
51469 return page;
51470
51471 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51472 + // only allow 512KB for argv+env on suid/sgid binaries
51473 + // to prevent easy ASLR exhaustion
51474 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
51475 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
51476 + (size > (512 * 1024))) {
51477 + put_page(page);
51478 + return NULL;
51479 + }
51480 +#endif
51481 +
51482 /*
51483 * Limit to 1/4-th the stack size for the argv+env strings.
51484 * This ensures that:
51485 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
51486 vma->vm_end = STACK_TOP_MAX;
51487 vma->vm_start = vma->vm_end - PAGE_SIZE;
51488 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
51489 +
51490 +#ifdef CONFIG_PAX_SEGMEXEC
51491 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
51492 +#endif
51493 +
51494 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
51495 INIT_LIST_HEAD(&vma->anon_vma_chain);
51496
51497 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
51498 mm->stack_vm = mm->total_vm = 1;
51499 up_write(&mm->mmap_sem);
51500 bprm->p = vma->vm_end - sizeof(void *);
51501 +
51502 +#ifdef CONFIG_PAX_RANDUSTACK
51503 + if (randomize_va_space)
51504 + bprm->p ^= random32() & ~PAGE_MASK;
51505 +#endif
51506 +
51507 return 0;
51508 err:
51509 up_write(&mm->mmap_sem);
51510 @@ -396,7 +434,7 @@ struct user_arg_ptr {
51511 } ptr;
51512 };
51513
51514 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
51515 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
51516 {
51517 const char __user *native;
51518
51519 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
51520 compat_uptr_t compat;
51521
51522 if (get_user(compat, argv.ptr.compat + nr))
51523 - return ERR_PTR(-EFAULT);
51524 + return (const char __force_user *)ERR_PTR(-EFAULT);
51525
51526 return compat_ptr(compat);
51527 }
51528 #endif
51529
51530 if (get_user(native, argv.ptr.native + nr))
51531 - return ERR_PTR(-EFAULT);
51532 + return (const char __force_user *)ERR_PTR(-EFAULT);
51533
51534 return native;
51535 }
51536 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
51537 if (!p)
51538 break;
51539
51540 - if (IS_ERR(p))
51541 + if (IS_ERR((const char __force_kernel *)p))
51542 return -EFAULT;
51543
51544 if (i >= max)
51545 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
51546
51547 ret = -EFAULT;
51548 str = get_user_arg_ptr(argv, argc);
51549 - if (IS_ERR(str))
51550 + if (IS_ERR((const char __force_kernel *)str))
51551 goto out;
51552
51553 len = strnlen_user(str, MAX_ARG_STRLEN);
51554 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
51555 int r;
51556 mm_segment_t oldfs = get_fs();
51557 struct user_arg_ptr argv = {
51558 - .ptr.native = (const char __user *const __user *)__argv,
51559 + .ptr.native = (const char __force_user *const __force_user *)__argv,
51560 };
51561
51562 set_fs(KERNEL_DS);
51563 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51564 unsigned long new_end = old_end - shift;
51565 struct mmu_gather tlb;
51566
51567 - BUG_ON(new_start > new_end);
51568 + if (new_start >= new_end || new_start < mmap_min_addr)
51569 + return -ENOMEM;
51570
51571 /*
51572 * ensure there are no vmas between where we want to go
51573 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51574 if (vma != find_vma(mm, new_start))
51575 return -EFAULT;
51576
51577 +#ifdef CONFIG_PAX_SEGMEXEC
51578 + BUG_ON(pax_find_mirror_vma(vma));
51579 +#endif
51580 +
51581 /*
51582 * cover the whole range: [new_start, old_end)
51583 */
51584 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51585 stack_top = arch_align_stack(stack_top);
51586 stack_top = PAGE_ALIGN(stack_top);
51587
51588 - if (unlikely(stack_top < mmap_min_addr) ||
51589 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
51590 - return -ENOMEM;
51591 -
51592 stack_shift = vma->vm_end - stack_top;
51593
51594 bprm->p -= stack_shift;
51595 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
51596 bprm->exec -= stack_shift;
51597
51598 down_write(&mm->mmap_sem);
51599 +
51600 + /* Move stack pages down in memory. */
51601 + if (stack_shift) {
51602 + ret = shift_arg_pages(vma, stack_shift);
51603 + if (ret)
51604 + goto out_unlock;
51605 + }
51606 +
51607 vm_flags = VM_STACK_FLAGS;
51608
51609 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51610 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51611 + vm_flags &= ~VM_EXEC;
51612 +
51613 +#ifdef CONFIG_PAX_MPROTECT
51614 + if (mm->pax_flags & MF_PAX_MPROTECT)
51615 + vm_flags &= ~VM_MAYEXEC;
51616 +#endif
51617 +
51618 + }
51619 +#endif
51620 +
51621 /*
51622 * Adjust stack execute permissions; explicitly enable for
51623 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
51624 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51625 goto out_unlock;
51626 BUG_ON(prev != vma);
51627
51628 - /* Move stack pages down in memory. */
51629 - if (stack_shift) {
51630 - ret = shift_arg_pages(vma, stack_shift);
51631 - if (ret)
51632 - goto out_unlock;
51633 - }
51634 -
51635 /* mprotect_fixup is overkill to remove the temporary stack flags */
51636 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
51637
51638 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
51639 #endif
51640 current->mm->start_stack = bprm->p;
51641 ret = expand_stack(vma, stack_base);
51642 +
51643 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
51644 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
51645 + unsigned long size, flags, vm_flags;
51646 +
51647 + size = STACK_TOP - vma->vm_end;
51648 + flags = MAP_FIXED | MAP_PRIVATE;
51649 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
51650 +
51651 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
51652 +
51653 +#ifdef CONFIG_X86
51654 + if (!ret) {
51655 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
51656 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
51657 + }
51658 +#endif
51659 +
51660 + }
51661 +#endif
51662 +
51663 if (ret)
51664 ret = -EFAULT;
51665
51666 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
51667
51668 fsnotify_open(file);
51669
51670 + trace_open_exec(name);
51671 +
51672 err = deny_write_access(file);
51673 if (err)
51674 goto exit;
51675 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
51676 old_fs = get_fs();
51677 set_fs(get_ds());
51678 /* The cast to a user pointer is valid due to the set_fs() */
51679 - result = vfs_read(file, (void __user *)addr, count, &pos);
51680 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51681 set_fs(old_fs);
51682 return result;
51683 }
51684 @@ -1247,7 +1322,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51685 }
51686 rcu_read_unlock();
51687
51688 - if (p->fs->users > n_fs) {
51689 + if (atomic_read(&p->fs->users) > n_fs) {
51690 bprm->unsafe |= LSM_UNSAFE_SHARE;
51691 } else {
51692 res = -EAGAIN;
51693 @@ -1447,6 +1522,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51694
51695 EXPORT_SYMBOL(search_binary_handler);
51696
51697 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51698 +static DEFINE_PER_CPU(u64, exec_counter);
51699 +static int __init init_exec_counters(void)
51700 +{
51701 + unsigned int cpu;
51702 +
51703 + for_each_possible_cpu(cpu) {
51704 + per_cpu(exec_counter, cpu) = (u64)cpu;
51705 + }
51706 +
51707 + return 0;
51708 +}
51709 +early_initcall(init_exec_counters);
51710 +static inline void increment_exec_counter(void)
51711 +{
51712 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51713 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51714 +}
51715 +#else
51716 +static inline void increment_exec_counter(void) {}
51717 +#endif
51718 +
51719 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51720 + struct user_arg_ptr argv);
51721 +
51722 /*
51723 * sys_execve() executes a new program.
51724 */
51725 @@ -1454,6 +1554,11 @@ static int do_execve_common(const char *filename,
51726 struct user_arg_ptr argv,
51727 struct user_arg_ptr envp)
51728 {
51729 +#ifdef CONFIG_GRKERNSEC
51730 + struct file *old_exec_file;
51731 + struct acl_subject_label *old_acl;
51732 + struct rlimit old_rlim[RLIM_NLIMITS];
51733 +#endif
51734 struct linux_binprm *bprm;
51735 struct file *file;
51736 struct files_struct *displaced;
51737 @@ -1461,6 +1566,8 @@ static int do_execve_common(const char *filename,
51738 int retval;
51739 const struct cred *cred = current_cred();
51740
51741 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
51742 +
51743 /*
51744 * We move the actual failure in case of RLIMIT_NPROC excess from
51745 * set*uid() to execve() because too many poorly written programs
51746 @@ -1501,12 +1608,27 @@ static int do_execve_common(const char *filename,
51747 if (IS_ERR(file))
51748 goto out_unmark;
51749
51750 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51751 + retval = -EPERM;
51752 + goto out_file;
51753 + }
51754 +
51755 sched_exec();
51756
51757 bprm->file = file;
51758 bprm->filename = filename;
51759 bprm->interp = filename;
51760
51761 + if (gr_process_user_ban()) {
51762 + retval = -EPERM;
51763 + goto out_file;
51764 + }
51765 +
51766 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
51767 + retval = -EACCES;
51768 + goto out_file;
51769 + }
51770 +
51771 retval = bprm_mm_init(bprm);
51772 if (retval)
51773 goto out_file;
51774 @@ -1523,24 +1645,65 @@ static int do_execve_common(const char *filename,
51775 if (retval < 0)
51776 goto out;
51777
51778 +#ifdef CONFIG_GRKERNSEC
51779 + old_acl = current->acl;
51780 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51781 + old_exec_file = current->exec_file;
51782 + get_file(file);
51783 + current->exec_file = file;
51784 +#endif
51785 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51786 + /* limit suid stack to 8MB
51787 + * we saved the old limits above and will restore them if this exec fails
51788 + */
51789 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51790 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51791 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51792 +#endif
51793 +
51794 + if (!gr_tpe_allow(file)) {
51795 + retval = -EACCES;
51796 + goto out_fail;
51797 + }
51798 +
51799 + if (gr_check_crash_exec(file)) {
51800 + retval = -EACCES;
51801 + goto out_fail;
51802 + }
51803 +
51804 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
51805 + bprm->unsafe);
51806 + if (retval < 0)
51807 + goto out_fail;
51808 +
51809 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51810 if (retval < 0)
51811 - goto out;
51812 + goto out_fail;
51813
51814 bprm->exec = bprm->p;
51815 retval = copy_strings(bprm->envc, envp, bprm);
51816 if (retval < 0)
51817 - goto out;
51818 + goto out_fail;
51819
51820 retval = copy_strings(bprm->argc, argv, bprm);
51821 if (retval < 0)
51822 - goto out;
51823 + goto out_fail;
51824 +
51825 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
51826 +
51827 + gr_handle_exec_args(bprm, argv);
51828
51829 retval = search_binary_handler(bprm);
51830 if (retval < 0)
51831 - goto out;
51832 + goto out_fail;
51833 +#ifdef CONFIG_GRKERNSEC
51834 + if (old_exec_file)
51835 + fput(old_exec_file);
51836 +#endif
51837
51838 /* execve succeeded */
51839 +
51840 + increment_exec_counter();
51841 current->fs->in_exec = 0;
51842 current->in_execve = 0;
51843 acct_update_integrals(current);
51844 @@ -1549,6 +1712,14 @@ static int do_execve_common(const char *filename,
51845 put_files_struct(displaced);
51846 return retval;
51847
51848 +out_fail:
51849 +#ifdef CONFIG_GRKERNSEC
51850 + current->acl = old_acl;
51851 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51852 + fput(current->exec_file);
51853 + current->exec_file = old_exec_file;
51854 +#endif
51855 +
51856 out:
51857 if (bprm->mm) {
51858 acct_arg_size(bprm, 0);
51859 @@ -1697,3 +1868,278 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51860 return error;
51861 }
51862 #endif
51863 +
51864 +int pax_check_flags(unsigned long *flags)
51865 +{
51866 + int retval = 0;
51867 +
51868 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51869 + if (*flags & MF_PAX_SEGMEXEC)
51870 + {
51871 + *flags &= ~MF_PAX_SEGMEXEC;
51872 + retval = -EINVAL;
51873 + }
51874 +#endif
51875 +
51876 + if ((*flags & MF_PAX_PAGEEXEC)
51877 +
51878 +#ifdef CONFIG_PAX_PAGEEXEC
51879 + && (*flags & MF_PAX_SEGMEXEC)
51880 +#endif
51881 +
51882 + )
51883 + {
51884 + *flags &= ~MF_PAX_PAGEEXEC;
51885 + retval = -EINVAL;
51886 + }
51887 +
51888 + if ((*flags & MF_PAX_MPROTECT)
51889 +
51890 +#ifdef CONFIG_PAX_MPROTECT
51891 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51892 +#endif
51893 +
51894 + )
51895 + {
51896 + *flags &= ~MF_PAX_MPROTECT;
51897 + retval = -EINVAL;
51898 + }
51899 +
51900 + if ((*flags & MF_PAX_EMUTRAMP)
51901 +
51902 +#ifdef CONFIG_PAX_EMUTRAMP
51903 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51904 +#endif
51905 +
51906 + )
51907 + {
51908 + *flags &= ~MF_PAX_EMUTRAMP;
51909 + retval = -EINVAL;
51910 + }
51911 +
51912 + return retval;
51913 +}
51914 +
51915 +EXPORT_SYMBOL(pax_check_flags);
51916 +
51917 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51918 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51919 +{
51920 + struct task_struct *tsk = current;
51921 + struct mm_struct *mm = current->mm;
51922 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51923 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51924 + char *path_exec = NULL;
51925 + char *path_fault = NULL;
51926 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51927 + siginfo_t info = { };
51928 +
51929 + if (buffer_exec && buffer_fault) {
51930 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51931 +
51932 + down_read(&mm->mmap_sem);
51933 + vma = mm->mmap;
51934 + while (vma && (!vma_exec || !vma_fault)) {
51935 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51936 + vma_exec = vma;
51937 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51938 + vma_fault = vma;
51939 + vma = vma->vm_next;
51940 + }
51941 + if (vma_exec) {
51942 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51943 + if (IS_ERR(path_exec))
51944 + path_exec = "<path too long>";
51945 + else {
51946 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51947 + if (path_exec) {
51948 + *path_exec = 0;
51949 + path_exec = buffer_exec;
51950 + } else
51951 + path_exec = "<path too long>";
51952 + }
51953 + }
51954 + if (vma_fault) {
51955 + start = vma_fault->vm_start;
51956 + end = vma_fault->vm_end;
51957 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51958 + if (vma_fault->vm_file) {
51959 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51960 + if (IS_ERR(path_fault))
51961 + path_fault = "<path too long>";
51962 + else {
51963 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51964 + if (path_fault) {
51965 + *path_fault = 0;
51966 + path_fault = buffer_fault;
51967 + } else
51968 + path_fault = "<path too long>";
51969 + }
51970 + } else
51971 + path_fault = "<anonymous mapping>";
51972 + }
51973 + up_read(&mm->mmap_sem);
51974 + }
51975 + if (tsk->signal->curr_ip)
51976 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51977 + else
51978 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51979 + 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),
51980 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51981 + free_page((unsigned long)buffer_exec);
51982 + free_page((unsigned long)buffer_fault);
51983 + pax_report_insns(regs, pc, sp);
51984 + info.si_signo = SIGKILL;
51985 + info.si_errno = 0;
51986 + info.si_code = SI_KERNEL;
51987 + info.si_pid = 0;
51988 + info.si_uid = 0;
51989 + do_coredump(&info);
51990 +}
51991 +#endif
51992 +
51993 +#ifdef CONFIG_PAX_REFCOUNT
51994 +void pax_report_refcount_overflow(struct pt_regs *regs)
51995 +{
51996 + if (current->signal->curr_ip)
51997 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51998 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51999 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
52000 + else
52001 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
52002 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
52003 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
52004 + show_regs(regs);
52005 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
52006 +}
52007 +#endif
52008 +
52009 +#ifdef CONFIG_PAX_USERCOPY
52010 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
52011 +static noinline int check_stack_object(const void *obj, unsigned long len)
52012 +{
52013 + const void * const stack = task_stack_page(current);
52014 + const void * const stackend = stack + THREAD_SIZE;
52015 +
52016 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
52017 + const void *frame = NULL;
52018 + const void *oldframe;
52019 +#endif
52020 +
52021 + if (obj + len < obj)
52022 + return -1;
52023 +
52024 + if (obj + len <= stack || stackend <= obj)
52025 + return 0;
52026 +
52027 + if (obj < stack || stackend < obj + len)
52028 + return -1;
52029 +
52030 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
52031 + oldframe = __builtin_frame_address(1);
52032 + if (oldframe)
52033 + frame = __builtin_frame_address(2);
52034 + /*
52035 + low ----------------------------------------------> high
52036 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
52037 + ^----------------^
52038 + allow copies only within here
52039 + */
52040 + while (stack <= frame && frame < stackend) {
52041 + /* if obj + len extends past the last frame, this
52042 + check won't pass and the next frame will be 0,
52043 + causing us to bail out and correctly report
52044 + the copy as invalid
52045 + */
52046 + if (obj + len <= frame)
52047 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
52048 + oldframe = frame;
52049 + frame = *(const void * const *)frame;
52050 + }
52051 + return -1;
52052 +#else
52053 + return 1;
52054 +#endif
52055 +}
52056 +
52057 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
52058 +{
52059 + if (current->signal->curr_ip)
52060 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
52061 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
52062 + else
52063 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
52064 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
52065 + dump_stack();
52066 + gr_handle_kernel_exploit();
52067 + do_group_exit(SIGKILL);
52068 +}
52069 +#endif
52070 +
52071 +#ifdef CONFIG_PAX_USERCOPY
52072 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
52073 +{
52074 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
52075 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
52076 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
52077 +#else
52078 + unsigned long textlow = _stext;
52079 + unsigned long texthigh = _etext;
52080 +#endif
52081 +
52082 + if (high < textlow || low > texthigh)
52083 + return false;
52084 + else
52085 + return true;
52086 +}
52087 +#endif
52088 +
52089 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
52090 +{
52091 +
52092 +#ifdef CONFIG_PAX_USERCOPY
52093 + const char *type;
52094 +
52095 + if (!n)
52096 + return;
52097 +
52098 + type = check_heap_object(ptr, n);
52099 + if (!type) {
52100 + int ret = check_stack_object(ptr, n);
52101 + if (ret == 1 || ret == 2)
52102 + return;
52103 + if (ret == 0) {
52104 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
52105 + type = "<kernel text>";
52106 + else
52107 + return;
52108 + } else
52109 + type = "<process stack>";
52110 + }
52111 +
52112 + pax_report_usercopy(ptr, n, to_user, type);
52113 +#endif
52114 +
52115 +}
52116 +EXPORT_SYMBOL(__check_object_size);
52117 +
52118 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
52119 +void pax_track_stack(void)
52120 +{
52121 + unsigned long sp = (unsigned long)&sp;
52122 + if (sp < current_thread_info()->lowest_stack &&
52123 + sp > (unsigned long)task_stack_page(current))
52124 + current_thread_info()->lowest_stack = sp;
52125 +}
52126 +EXPORT_SYMBOL(pax_track_stack);
52127 +#endif
52128 +
52129 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
52130 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
52131 +{
52132 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
52133 + dump_stack();
52134 + do_group_exit(SIGKILL);
52135 +}
52136 +EXPORT_SYMBOL(report_size_overflow);
52137 +#endif
52138 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
52139 index 2616d0e..2ffdec9 100644
52140 --- a/fs/ext2/balloc.c
52141 +++ b/fs/ext2/balloc.c
52142 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
52143
52144 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
52145 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
52146 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
52147 + if (free_blocks < root_blocks + 1 &&
52148 !uid_eq(sbi->s_resuid, current_fsuid()) &&
52149 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
52150 - !in_group_p (sbi->s_resgid))) {
52151 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
52152 return 0;
52153 }
52154 return 1;
52155 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
52156 index 22548f5..41521d8 100644
52157 --- a/fs/ext3/balloc.c
52158 +++ b/fs/ext3/balloc.c
52159 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
52160
52161 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
52162 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
52163 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
52164 + if (free_blocks < root_blocks + 1 &&
52165 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
52166 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
52167 - !in_group_p (sbi->s_resgid))) {
52168 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
52169 return 0;
52170 }
52171 return 1;
52172 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
52173 index 92e68b3..115d987 100644
52174 --- a/fs/ext4/balloc.c
52175 +++ b/fs/ext4/balloc.c
52176 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
52177 /* Hm, nope. Are (enough) root reserved clusters available? */
52178 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
52179 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
52180 - capable(CAP_SYS_RESOURCE) ||
52181 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
52182 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
52183 + capable_nolog(CAP_SYS_RESOURCE)) {
52184
52185 if (free_clusters >= (nclusters + dirty_clusters))
52186 return 1;
52187 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
52188 index bbcd6a0..2824592 100644
52189 --- a/fs/ext4/ext4.h
52190 +++ b/fs/ext4/ext4.h
52191 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
52192 unsigned long s_mb_last_start;
52193
52194 /* stats for buddy allocator */
52195 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
52196 - atomic_t s_bal_success; /* we found long enough chunks */
52197 - atomic_t s_bal_allocated; /* in blocks */
52198 - atomic_t s_bal_ex_scanned; /* total extents scanned */
52199 - atomic_t s_bal_goals; /* goal hits */
52200 - atomic_t s_bal_breaks; /* too long searches */
52201 - atomic_t s_bal_2orders; /* 2^order hits */
52202 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
52203 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
52204 + atomic_unchecked_t s_bal_allocated; /* in blocks */
52205 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
52206 + atomic_unchecked_t s_bal_goals; /* goal hits */
52207 + atomic_unchecked_t s_bal_breaks; /* too long searches */
52208 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
52209 spinlock_t s_bal_lock;
52210 unsigned long s_mb_buddies_generated;
52211 unsigned long long s_mb_generation_time;
52212 - atomic_t s_mb_lost_chunks;
52213 - atomic_t s_mb_preallocated;
52214 - atomic_t s_mb_discarded;
52215 + atomic_unchecked_t s_mb_lost_chunks;
52216 + atomic_unchecked_t s_mb_preallocated;
52217 + atomic_unchecked_t s_mb_discarded;
52218 atomic_t s_lock_busy;
52219
52220 /* locality groups */
52221 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
52222 index 82f8c2d..ce7c889 100644
52223 --- a/fs/ext4/mballoc.c
52224 +++ b/fs/ext4/mballoc.c
52225 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
52226 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
52227
52228 if (EXT4_SB(sb)->s_mb_stats)
52229 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
52230 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
52231
52232 break;
52233 }
52234 @@ -2044,7 +2044,7 @@ repeat:
52235 ac->ac_status = AC_STATUS_CONTINUE;
52236 ac->ac_flags |= EXT4_MB_HINT_FIRST;
52237 cr = 3;
52238 - atomic_inc(&sbi->s_mb_lost_chunks);
52239 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
52240 goto repeat;
52241 }
52242 }
52243 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
52244 if (sbi->s_mb_stats) {
52245 ext4_msg(sb, KERN_INFO,
52246 "mballoc: %u blocks %u reqs (%u success)",
52247 - atomic_read(&sbi->s_bal_allocated),
52248 - atomic_read(&sbi->s_bal_reqs),
52249 - atomic_read(&sbi->s_bal_success));
52250 + atomic_read_unchecked(&sbi->s_bal_allocated),
52251 + atomic_read_unchecked(&sbi->s_bal_reqs),
52252 + atomic_read_unchecked(&sbi->s_bal_success));
52253 ext4_msg(sb, KERN_INFO,
52254 "mballoc: %u extents scanned, %u goal hits, "
52255 "%u 2^N hits, %u breaks, %u lost",
52256 - atomic_read(&sbi->s_bal_ex_scanned),
52257 - atomic_read(&sbi->s_bal_goals),
52258 - atomic_read(&sbi->s_bal_2orders),
52259 - atomic_read(&sbi->s_bal_breaks),
52260 - atomic_read(&sbi->s_mb_lost_chunks));
52261 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
52262 + atomic_read_unchecked(&sbi->s_bal_goals),
52263 + atomic_read_unchecked(&sbi->s_bal_2orders),
52264 + atomic_read_unchecked(&sbi->s_bal_breaks),
52265 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
52266 ext4_msg(sb, KERN_INFO,
52267 "mballoc: %lu generated and it took %Lu",
52268 sbi->s_mb_buddies_generated,
52269 sbi->s_mb_generation_time);
52270 ext4_msg(sb, KERN_INFO,
52271 "mballoc: %u preallocated, %u discarded",
52272 - atomic_read(&sbi->s_mb_preallocated),
52273 - atomic_read(&sbi->s_mb_discarded));
52274 + atomic_read_unchecked(&sbi->s_mb_preallocated),
52275 + atomic_read_unchecked(&sbi->s_mb_discarded));
52276 }
52277
52278 free_percpu(sbi->s_locality_groups);
52279 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
52280 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
52281
52282 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
52283 - atomic_inc(&sbi->s_bal_reqs);
52284 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
52285 + atomic_inc_unchecked(&sbi->s_bal_reqs);
52286 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
52287 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
52288 - atomic_inc(&sbi->s_bal_success);
52289 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
52290 + atomic_inc_unchecked(&sbi->s_bal_success);
52291 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
52292 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
52293 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
52294 - atomic_inc(&sbi->s_bal_goals);
52295 + atomic_inc_unchecked(&sbi->s_bal_goals);
52296 if (ac->ac_found > sbi->s_mb_max_to_scan)
52297 - atomic_inc(&sbi->s_bal_breaks);
52298 + atomic_inc_unchecked(&sbi->s_bal_breaks);
52299 }
52300
52301 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
52302 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
52303 trace_ext4_mb_new_inode_pa(ac, pa);
52304
52305 ext4_mb_use_inode_pa(ac, pa);
52306 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
52307 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
52308
52309 ei = EXT4_I(ac->ac_inode);
52310 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
52311 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
52312 trace_ext4_mb_new_group_pa(ac, pa);
52313
52314 ext4_mb_use_group_pa(ac, pa);
52315 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
52316 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
52317
52318 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
52319 lg = ac->ac_lg;
52320 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
52321 * from the bitmap and continue.
52322 */
52323 }
52324 - atomic_add(free, &sbi->s_mb_discarded);
52325 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
52326
52327 return err;
52328 }
52329 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
52330 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
52331 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
52332 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
52333 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
52334 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
52335 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
52336
52337 return 0;
52338 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
52339 index 24c767d..893aa55 100644
52340 --- a/fs/ext4/super.c
52341 +++ b/fs/ext4/super.c
52342 @@ -2429,7 +2429,7 @@ struct ext4_attr {
52343 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
52344 const char *, size_t);
52345 int offset;
52346 -};
52347 +} __do_const;
52348
52349 static int parse_strtoul(const char *buf,
52350 unsigned long max, unsigned long *value)
52351 diff --git a/fs/fcntl.c b/fs/fcntl.c
52352 index 71a600a..20d87b1 100644
52353 --- a/fs/fcntl.c
52354 +++ b/fs/fcntl.c
52355 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
52356 if (err)
52357 return err;
52358
52359 + if (gr_handle_chroot_fowner(pid, type))
52360 + return -ENOENT;
52361 + if (gr_check_protected_task_fowner(pid, type))
52362 + return -EACCES;
52363 +
52364 f_modown(filp, pid, type, force);
52365 return 0;
52366 }
52367 diff --git a/fs/fhandle.c b/fs/fhandle.c
52368 index 999ff5c..41f4109 100644
52369 --- a/fs/fhandle.c
52370 +++ b/fs/fhandle.c
52371 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
52372 } else
52373 retval = 0;
52374 /* copy the mount id */
52375 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
52376 - sizeof(*mnt_id)) ||
52377 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
52378 copy_to_user(ufh, handle,
52379 sizeof(struct file_handle) + handle_bytes))
52380 retval = -EFAULT;
52381 diff --git a/fs/fifo.c b/fs/fifo.c
52382 index cf6f434..3d7942c 100644
52383 --- a/fs/fifo.c
52384 +++ b/fs/fifo.c
52385 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
52386 */
52387 filp->f_op = &read_pipefifo_fops;
52388 pipe->r_counter++;
52389 - if (pipe->readers++ == 0)
52390 + if (atomic_inc_return(&pipe->readers) == 1)
52391 wake_up_partner(inode);
52392
52393 - if (!pipe->writers) {
52394 + if (!atomic_read(&pipe->writers)) {
52395 if ((filp->f_flags & O_NONBLOCK)) {
52396 /* suppress POLLHUP until we have
52397 * seen a writer */
52398 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
52399 * errno=ENXIO when there is no process reading the FIFO.
52400 */
52401 ret = -ENXIO;
52402 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
52403 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
52404 goto err;
52405
52406 filp->f_op = &write_pipefifo_fops;
52407 pipe->w_counter++;
52408 - if (!pipe->writers++)
52409 + if (atomic_inc_return(&pipe->writers) == 1)
52410 wake_up_partner(inode);
52411
52412 - if (!pipe->readers) {
52413 + if (!atomic_read(&pipe->readers)) {
52414 if (wait_for_partner(inode, &pipe->r_counter))
52415 goto err_wr;
52416 }
52417 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
52418 */
52419 filp->f_op = &rdwr_pipefifo_fops;
52420
52421 - pipe->readers++;
52422 - pipe->writers++;
52423 + atomic_inc(&pipe->readers);
52424 + atomic_inc(&pipe->writers);
52425 pipe->r_counter++;
52426 pipe->w_counter++;
52427 - if (pipe->readers == 1 || pipe->writers == 1)
52428 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
52429 wake_up_partner(inode);
52430 break;
52431
52432 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
52433 return 0;
52434
52435 err_rd:
52436 - if (!--pipe->readers)
52437 + if (atomic_dec_and_test(&pipe->readers))
52438 wake_up_interruptible(&pipe->wait);
52439 ret = -ERESTARTSYS;
52440 goto err;
52441
52442 err_wr:
52443 - if (!--pipe->writers)
52444 + if (atomic_dec_and_test(&pipe->writers))
52445 wake_up_interruptible(&pipe->wait);
52446 ret = -ERESTARTSYS;
52447 goto err;
52448
52449 err:
52450 - if (!pipe->readers && !pipe->writers)
52451 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
52452 free_pipe_info(inode);
52453
52454 err_nocleanup:
52455 diff --git a/fs/file.c b/fs/file.c
52456 index 2b3570b..c57924b 100644
52457 --- a/fs/file.c
52458 +++ b/fs/file.c
52459 @@ -16,6 +16,7 @@
52460 #include <linux/slab.h>
52461 #include <linux/vmalloc.h>
52462 #include <linux/file.h>
52463 +#include <linux/security.h>
52464 #include <linux/fdtable.h>
52465 #include <linux/bitops.h>
52466 #include <linux/interrupt.h>
52467 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
52468 if (!file)
52469 return __close_fd(files, fd);
52470
52471 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
52472 if (fd >= rlimit(RLIMIT_NOFILE))
52473 return -EBADF;
52474
52475 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
52476 if (unlikely(oldfd == newfd))
52477 return -EINVAL;
52478
52479 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
52480 if (newfd >= rlimit(RLIMIT_NOFILE))
52481 return -EBADF;
52482
52483 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
52484 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
52485 {
52486 int err;
52487 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
52488 if (from >= rlimit(RLIMIT_NOFILE))
52489 return -EINVAL;
52490 err = alloc_fd(from, flags);
52491 diff --git a/fs/filesystems.c b/fs/filesystems.c
52492 index da165f6..3671bdb 100644
52493 --- a/fs/filesystems.c
52494 +++ b/fs/filesystems.c
52495 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
52496 int len = dot ? dot - name : strlen(name);
52497
52498 fs = __get_fs_type(name, len);
52499 +
52500 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
52501 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
52502 +#else
52503 if (!fs && (request_module("%.*s", len, name) == 0))
52504 +#endif
52505 fs = __get_fs_type(name, len);
52506
52507 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
52508 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
52509 index fe6ca58..65318cf 100644
52510 --- a/fs/fs_struct.c
52511 +++ b/fs/fs_struct.c
52512 @@ -4,6 +4,7 @@
52513 #include <linux/path.h>
52514 #include <linux/slab.h>
52515 #include <linux/fs_struct.h>
52516 +#include <linux/grsecurity.h>
52517 #include "internal.h"
52518
52519 /*
52520 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
52521 write_seqcount_begin(&fs->seq);
52522 old_root = fs->root;
52523 fs->root = *path;
52524 + gr_set_chroot_entries(current, path);
52525 write_seqcount_end(&fs->seq);
52526 spin_unlock(&fs->lock);
52527 if (old_root.dentry)
52528 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
52529 return 1;
52530 }
52531
52532 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
52533 +{
52534 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
52535 + return 0;
52536 + *p = *new;
52537 +
52538 + /* This function is only called from pivot_root(). Leave our
52539 + gr_chroot_dentry and is_chrooted flags as-is, so that a
52540 + pivoted root isn't treated as a chroot
52541 + */
52542 + //gr_set_chroot_entries(task, new);
52543 +
52544 + return 1;
52545 +}
52546 +
52547 void chroot_fs_refs(struct path *old_root, struct path *new_root)
52548 {
52549 struct task_struct *g, *p;
52550 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
52551 int hits = 0;
52552 spin_lock(&fs->lock);
52553 write_seqcount_begin(&fs->seq);
52554 - hits += replace_path(&fs->root, old_root, new_root);
52555 + hits += replace_root_path(p, &fs->root, old_root, new_root);
52556 hits += replace_path(&fs->pwd, old_root, new_root);
52557 write_seqcount_end(&fs->seq);
52558 while (hits--) {
52559 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
52560 task_lock(tsk);
52561 spin_lock(&fs->lock);
52562 tsk->fs = NULL;
52563 - kill = !--fs->users;
52564 + gr_clear_chroot_entries(tsk);
52565 + kill = !atomic_dec_return(&fs->users);
52566 spin_unlock(&fs->lock);
52567 task_unlock(tsk);
52568 if (kill)
52569 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
52570 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
52571 /* We don't need to lock fs - think why ;-) */
52572 if (fs) {
52573 - fs->users = 1;
52574 + atomic_set(&fs->users, 1);
52575 fs->in_exec = 0;
52576 spin_lock_init(&fs->lock);
52577 seqcount_init(&fs->seq);
52578 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
52579 spin_lock(&old->lock);
52580 fs->root = old->root;
52581 path_get(&fs->root);
52582 + /* instead of calling gr_set_chroot_entries here,
52583 + we call it from every caller of this function
52584 + */
52585 fs->pwd = old->pwd;
52586 path_get(&fs->pwd);
52587 spin_unlock(&old->lock);
52588 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
52589
52590 task_lock(current);
52591 spin_lock(&fs->lock);
52592 - kill = !--fs->users;
52593 + kill = !atomic_dec_return(&fs->users);
52594 current->fs = new_fs;
52595 + gr_set_chroot_entries(current, &new_fs->root);
52596 spin_unlock(&fs->lock);
52597 task_unlock(current);
52598
52599 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
52600
52601 int current_umask(void)
52602 {
52603 - return current->fs->umask;
52604 + return current->fs->umask | gr_acl_umask();
52605 }
52606 EXPORT_SYMBOL(current_umask);
52607
52608 /* to be mentioned only in INIT_TASK */
52609 struct fs_struct init_fs = {
52610 - .users = 1,
52611 + .users = ATOMIC_INIT(1),
52612 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
52613 .seq = SEQCNT_ZERO,
52614 .umask = 0022,
52615 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
52616 index 8dcb114..b1072e2 100644
52617 --- a/fs/fscache/cookie.c
52618 +++ b/fs/fscache/cookie.c
52619 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
52620 parent ? (char *) parent->def->name : "<no-parent>",
52621 def->name, netfs_data);
52622
52623 - fscache_stat(&fscache_n_acquires);
52624 + fscache_stat_unchecked(&fscache_n_acquires);
52625
52626 /* if there's no parent cookie, then we don't create one here either */
52627 if (!parent) {
52628 - fscache_stat(&fscache_n_acquires_null);
52629 + fscache_stat_unchecked(&fscache_n_acquires_null);
52630 _leave(" [no parent]");
52631 return NULL;
52632 }
52633 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
52634 /* allocate and initialise a cookie */
52635 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
52636 if (!cookie) {
52637 - fscache_stat(&fscache_n_acquires_oom);
52638 + fscache_stat_unchecked(&fscache_n_acquires_oom);
52639 _leave(" [ENOMEM]");
52640 return NULL;
52641 }
52642 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52643
52644 switch (cookie->def->type) {
52645 case FSCACHE_COOKIE_TYPE_INDEX:
52646 - fscache_stat(&fscache_n_cookie_index);
52647 + fscache_stat_unchecked(&fscache_n_cookie_index);
52648 break;
52649 case FSCACHE_COOKIE_TYPE_DATAFILE:
52650 - fscache_stat(&fscache_n_cookie_data);
52651 + fscache_stat_unchecked(&fscache_n_cookie_data);
52652 break;
52653 default:
52654 - fscache_stat(&fscache_n_cookie_special);
52655 + fscache_stat_unchecked(&fscache_n_cookie_special);
52656 break;
52657 }
52658
52659 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52660 if (fscache_acquire_non_index_cookie(cookie) < 0) {
52661 atomic_dec(&parent->n_children);
52662 __fscache_cookie_put(cookie);
52663 - fscache_stat(&fscache_n_acquires_nobufs);
52664 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
52665 _leave(" = NULL");
52666 return NULL;
52667 }
52668 }
52669
52670 - fscache_stat(&fscache_n_acquires_ok);
52671 + fscache_stat_unchecked(&fscache_n_acquires_ok);
52672 _leave(" = %p", cookie);
52673 return cookie;
52674 }
52675 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
52676 cache = fscache_select_cache_for_object(cookie->parent);
52677 if (!cache) {
52678 up_read(&fscache_addremove_sem);
52679 - fscache_stat(&fscache_n_acquires_no_cache);
52680 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
52681 _leave(" = -ENOMEDIUM [no cache]");
52682 return -ENOMEDIUM;
52683 }
52684 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
52685 object = cache->ops->alloc_object(cache, cookie);
52686 fscache_stat_d(&fscache_n_cop_alloc_object);
52687 if (IS_ERR(object)) {
52688 - fscache_stat(&fscache_n_object_no_alloc);
52689 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
52690 ret = PTR_ERR(object);
52691 goto error;
52692 }
52693
52694 - fscache_stat(&fscache_n_object_alloc);
52695 + fscache_stat_unchecked(&fscache_n_object_alloc);
52696
52697 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
52698
52699 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52700
52701 _enter("{%s}", cookie->def->name);
52702
52703 - fscache_stat(&fscache_n_invalidates);
52704 + fscache_stat_unchecked(&fscache_n_invalidates);
52705
52706 /* Only permit invalidation of data files. Invalidating an index will
52707 * require the caller to release all its attachments to the tree rooted
52708 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52709 struct fscache_object *object;
52710 struct hlist_node *_p;
52711
52712 - fscache_stat(&fscache_n_updates);
52713 + fscache_stat_unchecked(&fscache_n_updates);
52714
52715 if (!cookie) {
52716 - fscache_stat(&fscache_n_updates_null);
52717 + fscache_stat_unchecked(&fscache_n_updates_null);
52718 _leave(" [no cookie]");
52719 return;
52720 }
52721 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52722 struct fscache_object *object;
52723 unsigned long event;
52724
52725 - fscache_stat(&fscache_n_relinquishes);
52726 + fscache_stat_unchecked(&fscache_n_relinquishes);
52727 if (retire)
52728 - fscache_stat(&fscache_n_relinquishes_retire);
52729 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52730
52731 if (!cookie) {
52732 - fscache_stat(&fscache_n_relinquishes_null);
52733 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52734 _leave(" [no cookie]");
52735 return;
52736 }
52737 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52738
52739 /* wait for the cookie to finish being instantiated (or to fail) */
52740 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52741 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52742 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52743 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52744 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52745 }
52746 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52747 index ee38fef..0a326d4 100644
52748 --- a/fs/fscache/internal.h
52749 +++ b/fs/fscache/internal.h
52750 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52751 * stats.c
52752 */
52753 #ifdef CONFIG_FSCACHE_STATS
52754 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52755 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52756 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52757 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52758
52759 -extern atomic_t fscache_n_op_pend;
52760 -extern atomic_t fscache_n_op_run;
52761 -extern atomic_t fscache_n_op_enqueue;
52762 -extern atomic_t fscache_n_op_deferred_release;
52763 -extern atomic_t fscache_n_op_release;
52764 -extern atomic_t fscache_n_op_gc;
52765 -extern atomic_t fscache_n_op_cancelled;
52766 -extern atomic_t fscache_n_op_rejected;
52767 +extern atomic_unchecked_t fscache_n_op_pend;
52768 +extern atomic_unchecked_t fscache_n_op_run;
52769 +extern atomic_unchecked_t fscache_n_op_enqueue;
52770 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52771 +extern atomic_unchecked_t fscache_n_op_release;
52772 +extern atomic_unchecked_t fscache_n_op_gc;
52773 +extern atomic_unchecked_t fscache_n_op_cancelled;
52774 +extern atomic_unchecked_t fscache_n_op_rejected;
52775
52776 -extern atomic_t fscache_n_attr_changed;
52777 -extern atomic_t fscache_n_attr_changed_ok;
52778 -extern atomic_t fscache_n_attr_changed_nobufs;
52779 -extern atomic_t fscache_n_attr_changed_nomem;
52780 -extern atomic_t fscache_n_attr_changed_calls;
52781 +extern atomic_unchecked_t fscache_n_attr_changed;
52782 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52783 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52784 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52785 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52786
52787 -extern atomic_t fscache_n_allocs;
52788 -extern atomic_t fscache_n_allocs_ok;
52789 -extern atomic_t fscache_n_allocs_wait;
52790 -extern atomic_t fscache_n_allocs_nobufs;
52791 -extern atomic_t fscache_n_allocs_intr;
52792 -extern atomic_t fscache_n_allocs_object_dead;
52793 -extern atomic_t fscache_n_alloc_ops;
52794 -extern atomic_t fscache_n_alloc_op_waits;
52795 +extern atomic_unchecked_t fscache_n_allocs;
52796 +extern atomic_unchecked_t fscache_n_allocs_ok;
52797 +extern atomic_unchecked_t fscache_n_allocs_wait;
52798 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52799 +extern atomic_unchecked_t fscache_n_allocs_intr;
52800 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52801 +extern atomic_unchecked_t fscache_n_alloc_ops;
52802 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52803
52804 -extern atomic_t fscache_n_retrievals;
52805 -extern atomic_t fscache_n_retrievals_ok;
52806 -extern atomic_t fscache_n_retrievals_wait;
52807 -extern atomic_t fscache_n_retrievals_nodata;
52808 -extern atomic_t fscache_n_retrievals_nobufs;
52809 -extern atomic_t fscache_n_retrievals_intr;
52810 -extern atomic_t fscache_n_retrievals_nomem;
52811 -extern atomic_t fscache_n_retrievals_object_dead;
52812 -extern atomic_t fscache_n_retrieval_ops;
52813 -extern atomic_t fscache_n_retrieval_op_waits;
52814 +extern atomic_unchecked_t fscache_n_retrievals;
52815 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52816 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52817 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52818 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52819 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52820 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52821 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52822 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52823 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52824
52825 -extern atomic_t fscache_n_stores;
52826 -extern atomic_t fscache_n_stores_ok;
52827 -extern atomic_t fscache_n_stores_again;
52828 -extern atomic_t fscache_n_stores_nobufs;
52829 -extern atomic_t fscache_n_stores_oom;
52830 -extern atomic_t fscache_n_store_ops;
52831 -extern atomic_t fscache_n_store_calls;
52832 -extern atomic_t fscache_n_store_pages;
52833 -extern atomic_t fscache_n_store_radix_deletes;
52834 -extern atomic_t fscache_n_store_pages_over_limit;
52835 +extern atomic_unchecked_t fscache_n_stores;
52836 +extern atomic_unchecked_t fscache_n_stores_ok;
52837 +extern atomic_unchecked_t fscache_n_stores_again;
52838 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52839 +extern atomic_unchecked_t fscache_n_stores_oom;
52840 +extern atomic_unchecked_t fscache_n_store_ops;
52841 +extern atomic_unchecked_t fscache_n_store_calls;
52842 +extern atomic_unchecked_t fscache_n_store_pages;
52843 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52844 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52845
52846 -extern atomic_t fscache_n_store_vmscan_not_storing;
52847 -extern atomic_t fscache_n_store_vmscan_gone;
52848 -extern atomic_t fscache_n_store_vmscan_busy;
52849 -extern atomic_t fscache_n_store_vmscan_cancelled;
52850 -extern atomic_t fscache_n_store_vmscan_wait;
52851 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52852 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52853 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52854 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52855 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52856
52857 -extern atomic_t fscache_n_marks;
52858 -extern atomic_t fscache_n_uncaches;
52859 +extern atomic_unchecked_t fscache_n_marks;
52860 +extern atomic_unchecked_t fscache_n_uncaches;
52861
52862 -extern atomic_t fscache_n_acquires;
52863 -extern atomic_t fscache_n_acquires_null;
52864 -extern atomic_t fscache_n_acquires_no_cache;
52865 -extern atomic_t fscache_n_acquires_ok;
52866 -extern atomic_t fscache_n_acquires_nobufs;
52867 -extern atomic_t fscache_n_acquires_oom;
52868 +extern atomic_unchecked_t fscache_n_acquires;
52869 +extern atomic_unchecked_t fscache_n_acquires_null;
52870 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52871 +extern atomic_unchecked_t fscache_n_acquires_ok;
52872 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52873 +extern atomic_unchecked_t fscache_n_acquires_oom;
52874
52875 -extern atomic_t fscache_n_invalidates;
52876 -extern atomic_t fscache_n_invalidates_run;
52877 +extern atomic_unchecked_t fscache_n_invalidates;
52878 +extern atomic_unchecked_t fscache_n_invalidates_run;
52879
52880 -extern atomic_t fscache_n_updates;
52881 -extern atomic_t fscache_n_updates_null;
52882 -extern atomic_t fscache_n_updates_run;
52883 +extern atomic_unchecked_t fscache_n_updates;
52884 +extern atomic_unchecked_t fscache_n_updates_null;
52885 +extern atomic_unchecked_t fscache_n_updates_run;
52886
52887 -extern atomic_t fscache_n_relinquishes;
52888 -extern atomic_t fscache_n_relinquishes_null;
52889 -extern atomic_t fscache_n_relinquishes_waitcrt;
52890 -extern atomic_t fscache_n_relinquishes_retire;
52891 +extern atomic_unchecked_t fscache_n_relinquishes;
52892 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52893 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52894 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52895
52896 -extern atomic_t fscache_n_cookie_index;
52897 -extern atomic_t fscache_n_cookie_data;
52898 -extern atomic_t fscache_n_cookie_special;
52899 +extern atomic_unchecked_t fscache_n_cookie_index;
52900 +extern atomic_unchecked_t fscache_n_cookie_data;
52901 +extern atomic_unchecked_t fscache_n_cookie_special;
52902
52903 -extern atomic_t fscache_n_object_alloc;
52904 -extern atomic_t fscache_n_object_no_alloc;
52905 -extern atomic_t fscache_n_object_lookups;
52906 -extern atomic_t fscache_n_object_lookups_negative;
52907 -extern atomic_t fscache_n_object_lookups_positive;
52908 -extern atomic_t fscache_n_object_lookups_timed_out;
52909 -extern atomic_t fscache_n_object_created;
52910 -extern atomic_t fscache_n_object_avail;
52911 -extern atomic_t fscache_n_object_dead;
52912 +extern atomic_unchecked_t fscache_n_object_alloc;
52913 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52914 +extern atomic_unchecked_t fscache_n_object_lookups;
52915 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52916 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52917 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52918 +extern atomic_unchecked_t fscache_n_object_created;
52919 +extern atomic_unchecked_t fscache_n_object_avail;
52920 +extern atomic_unchecked_t fscache_n_object_dead;
52921
52922 -extern atomic_t fscache_n_checkaux_none;
52923 -extern atomic_t fscache_n_checkaux_okay;
52924 -extern atomic_t fscache_n_checkaux_update;
52925 -extern atomic_t fscache_n_checkaux_obsolete;
52926 +extern atomic_unchecked_t fscache_n_checkaux_none;
52927 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52928 +extern atomic_unchecked_t fscache_n_checkaux_update;
52929 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52930
52931 extern atomic_t fscache_n_cop_alloc_object;
52932 extern atomic_t fscache_n_cop_lookup_object;
52933 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52934 atomic_inc(stat);
52935 }
52936
52937 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52938 +{
52939 + atomic_inc_unchecked(stat);
52940 +}
52941 +
52942 static inline void fscache_stat_d(atomic_t *stat)
52943 {
52944 atomic_dec(stat);
52945 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52946
52947 #define __fscache_stat(stat) (NULL)
52948 #define fscache_stat(stat) do {} while (0)
52949 +#define fscache_stat_unchecked(stat) do {} while (0)
52950 #define fscache_stat_d(stat) do {} while (0)
52951 #endif
52952
52953 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52954 index 50d41c1..10ee117 100644
52955 --- a/fs/fscache/object.c
52956 +++ b/fs/fscache/object.c
52957 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52958 /* Invalidate an object on disk */
52959 case FSCACHE_OBJECT_INVALIDATING:
52960 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52961 - fscache_stat(&fscache_n_invalidates_run);
52962 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52963 fscache_stat(&fscache_n_cop_invalidate_object);
52964 fscache_invalidate_object(object);
52965 fscache_stat_d(&fscache_n_cop_invalidate_object);
52966 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52967 /* update the object metadata on disk */
52968 case FSCACHE_OBJECT_UPDATING:
52969 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52970 - fscache_stat(&fscache_n_updates_run);
52971 + fscache_stat_unchecked(&fscache_n_updates_run);
52972 fscache_stat(&fscache_n_cop_update_object);
52973 object->cache->ops->update_object(object);
52974 fscache_stat_d(&fscache_n_cop_update_object);
52975 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52976 spin_lock(&object->lock);
52977 object->state = FSCACHE_OBJECT_DEAD;
52978 spin_unlock(&object->lock);
52979 - fscache_stat(&fscache_n_object_dead);
52980 + fscache_stat_unchecked(&fscache_n_object_dead);
52981 goto terminal_transit;
52982
52983 /* handle the parent cache of this object being withdrawn from
52984 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52985 spin_lock(&object->lock);
52986 object->state = FSCACHE_OBJECT_DEAD;
52987 spin_unlock(&object->lock);
52988 - fscache_stat(&fscache_n_object_dead);
52989 + fscache_stat_unchecked(&fscache_n_object_dead);
52990 goto terminal_transit;
52991
52992 /* complain about the object being woken up once it is
52993 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52994 parent->cookie->def->name, cookie->def->name,
52995 object->cache->tag->name);
52996
52997 - fscache_stat(&fscache_n_object_lookups);
52998 + fscache_stat_unchecked(&fscache_n_object_lookups);
52999 fscache_stat(&fscache_n_cop_lookup_object);
53000 ret = object->cache->ops->lookup_object(object);
53001 fscache_stat_d(&fscache_n_cop_lookup_object);
53002 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
53003 if (ret == -ETIMEDOUT) {
53004 /* probably stuck behind another object, so move this one to
53005 * the back of the queue */
53006 - fscache_stat(&fscache_n_object_lookups_timed_out);
53007 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
53008 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
53009 }
53010
53011 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
53012
53013 spin_lock(&object->lock);
53014 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
53015 - fscache_stat(&fscache_n_object_lookups_negative);
53016 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
53017
53018 /* transit here to allow write requests to begin stacking up
53019 * and read requests to begin returning ENODATA */
53020 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
53021 * result, in which case there may be data available */
53022 spin_lock(&object->lock);
53023 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
53024 - fscache_stat(&fscache_n_object_lookups_positive);
53025 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
53026
53027 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
53028
53029 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
53030 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
53031 } else {
53032 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
53033 - fscache_stat(&fscache_n_object_created);
53034 + fscache_stat_unchecked(&fscache_n_object_created);
53035
53036 object->state = FSCACHE_OBJECT_AVAILABLE;
53037 spin_unlock(&object->lock);
53038 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
53039 fscache_enqueue_dependents(object);
53040
53041 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
53042 - fscache_stat(&fscache_n_object_avail);
53043 + fscache_stat_unchecked(&fscache_n_object_avail);
53044
53045 _leave("");
53046 }
53047 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
53048 enum fscache_checkaux result;
53049
53050 if (!object->cookie->def->check_aux) {
53051 - fscache_stat(&fscache_n_checkaux_none);
53052 + fscache_stat_unchecked(&fscache_n_checkaux_none);
53053 return FSCACHE_CHECKAUX_OKAY;
53054 }
53055
53056 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
53057 switch (result) {
53058 /* entry okay as is */
53059 case FSCACHE_CHECKAUX_OKAY:
53060 - fscache_stat(&fscache_n_checkaux_okay);
53061 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
53062 break;
53063
53064 /* entry requires update */
53065 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
53066 - fscache_stat(&fscache_n_checkaux_update);
53067 + fscache_stat_unchecked(&fscache_n_checkaux_update);
53068 break;
53069
53070 /* entry requires deletion */
53071 case FSCACHE_CHECKAUX_OBSOLETE:
53072 - fscache_stat(&fscache_n_checkaux_obsolete);
53073 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
53074 break;
53075
53076 default:
53077 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
53078 index 762a9ec..2023284 100644
53079 --- a/fs/fscache/operation.c
53080 +++ b/fs/fscache/operation.c
53081 @@ -17,7 +17,7 @@
53082 #include <linux/slab.h>
53083 #include "internal.h"
53084
53085 -atomic_t fscache_op_debug_id;
53086 +atomic_unchecked_t fscache_op_debug_id;
53087 EXPORT_SYMBOL(fscache_op_debug_id);
53088
53089 /**
53090 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
53091 ASSERTCMP(atomic_read(&op->usage), >, 0);
53092 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
53093
53094 - fscache_stat(&fscache_n_op_enqueue);
53095 + fscache_stat_unchecked(&fscache_n_op_enqueue);
53096 switch (op->flags & FSCACHE_OP_TYPE) {
53097 case FSCACHE_OP_ASYNC:
53098 _debug("queue async");
53099 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
53100 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
53101 if (op->processor)
53102 fscache_enqueue_operation(op);
53103 - fscache_stat(&fscache_n_op_run);
53104 + fscache_stat_unchecked(&fscache_n_op_run);
53105 }
53106
53107 /*
53108 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
53109 if (object->n_in_progress > 0) {
53110 atomic_inc(&op->usage);
53111 list_add_tail(&op->pend_link, &object->pending_ops);
53112 - fscache_stat(&fscache_n_op_pend);
53113 + fscache_stat_unchecked(&fscache_n_op_pend);
53114 } else if (!list_empty(&object->pending_ops)) {
53115 atomic_inc(&op->usage);
53116 list_add_tail(&op->pend_link, &object->pending_ops);
53117 - fscache_stat(&fscache_n_op_pend);
53118 + fscache_stat_unchecked(&fscache_n_op_pend);
53119 fscache_start_operations(object);
53120 } else {
53121 ASSERTCMP(object->n_in_progress, ==, 0);
53122 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
53123 object->n_exclusive++; /* reads and writes must wait */
53124 atomic_inc(&op->usage);
53125 list_add_tail(&op->pend_link, &object->pending_ops);
53126 - fscache_stat(&fscache_n_op_pend);
53127 + fscache_stat_unchecked(&fscache_n_op_pend);
53128 ret = 0;
53129 } else {
53130 /* If we're in any other state, there must have been an I/O
53131 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
53132 if (object->n_exclusive > 0) {
53133 atomic_inc(&op->usage);
53134 list_add_tail(&op->pend_link, &object->pending_ops);
53135 - fscache_stat(&fscache_n_op_pend);
53136 + fscache_stat_unchecked(&fscache_n_op_pend);
53137 } else if (!list_empty(&object->pending_ops)) {
53138 atomic_inc(&op->usage);
53139 list_add_tail(&op->pend_link, &object->pending_ops);
53140 - fscache_stat(&fscache_n_op_pend);
53141 + fscache_stat_unchecked(&fscache_n_op_pend);
53142 fscache_start_operations(object);
53143 } else {
53144 ASSERTCMP(object->n_exclusive, ==, 0);
53145 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
53146 object->n_ops++;
53147 atomic_inc(&op->usage);
53148 list_add_tail(&op->pend_link, &object->pending_ops);
53149 - fscache_stat(&fscache_n_op_pend);
53150 + fscache_stat_unchecked(&fscache_n_op_pend);
53151 ret = 0;
53152 } else if (object->state == FSCACHE_OBJECT_DYING ||
53153 object->state == FSCACHE_OBJECT_LC_DYING ||
53154 object->state == FSCACHE_OBJECT_WITHDRAWING) {
53155 - fscache_stat(&fscache_n_op_rejected);
53156 + fscache_stat_unchecked(&fscache_n_op_rejected);
53157 op->state = FSCACHE_OP_ST_CANCELLED;
53158 ret = -ENOBUFS;
53159 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
53160 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
53161 ret = -EBUSY;
53162 if (op->state == FSCACHE_OP_ST_PENDING) {
53163 ASSERT(!list_empty(&op->pend_link));
53164 - fscache_stat(&fscache_n_op_cancelled);
53165 + fscache_stat_unchecked(&fscache_n_op_cancelled);
53166 list_del_init(&op->pend_link);
53167 if (do_cancel)
53168 do_cancel(op);
53169 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
53170 while (!list_empty(&object->pending_ops)) {
53171 op = list_entry(object->pending_ops.next,
53172 struct fscache_operation, pend_link);
53173 - fscache_stat(&fscache_n_op_cancelled);
53174 + fscache_stat_unchecked(&fscache_n_op_cancelled);
53175 list_del_init(&op->pend_link);
53176
53177 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
53178 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
53179 op->state, ==, FSCACHE_OP_ST_CANCELLED);
53180 op->state = FSCACHE_OP_ST_DEAD;
53181
53182 - fscache_stat(&fscache_n_op_release);
53183 + fscache_stat_unchecked(&fscache_n_op_release);
53184
53185 if (op->release) {
53186 op->release(op);
53187 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
53188 * lock, and defer it otherwise */
53189 if (!spin_trylock(&object->lock)) {
53190 _debug("defer put");
53191 - fscache_stat(&fscache_n_op_deferred_release);
53192 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
53193
53194 cache = object->cache;
53195 spin_lock(&cache->op_gc_list_lock);
53196 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
53197
53198 _debug("GC DEFERRED REL OBJ%x OP%x",
53199 object->debug_id, op->debug_id);
53200 - fscache_stat(&fscache_n_op_gc);
53201 + fscache_stat_unchecked(&fscache_n_op_gc);
53202
53203 ASSERTCMP(atomic_read(&op->usage), ==, 0);
53204 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
53205 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
53206 index ff000e5..c44ec6d 100644
53207 --- a/fs/fscache/page.c
53208 +++ b/fs/fscache/page.c
53209 @@ -61,7 +61,7 @@ try_again:
53210 val = radix_tree_lookup(&cookie->stores, page->index);
53211 if (!val) {
53212 rcu_read_unlock();
53213 - fscache_stat(&fscache_n_store_vmscan_not_storing);
53214 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
53215 __fscache_uncache_page(cookie, page);
53216 return true;
53217 }
53218 @@ -91,11 +91,11 @@ try_again:
53219 spin_unlock(&cookie->stores_lock);
53220
53221 if (xpage) {
53222 - fscache_stat(&fscache_n_store_vmscan_cancelled);
53223 - fscache_stat(&fscache_n_store_radix_deletes);
53224 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
53225 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
53226 ASSERTCMP(xpage, ==, page);
53227 } else {
53228 - fscache_stat(&fscache_n_store_vmscan_gone);
53229 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
53230 }
53231
53232 wake_up_bit(&cookie->flags, 0);
53233 @@ -110,11 +110,11 @@ page_busy:
53234 * sleeping on memory allocation, so we may need to impose a timeout
53235 * too. */
53236 if (!(gfp & __GFP_WAIT)) {
53237 - fscache_stat(&fscache_n_store_vmscan_busy);
53238 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
53239 return false;
53240 }
53241
53242 - fscache_stat(&fscache_n_store_vmscan_wait);
53243 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
53244 __fscache_wait_on_page_write(cookie, page);
53245 gfp &= ~__GFP_WAIT;
53246 goto try_again;
53247 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
53248 FSCACHE_COOKIE_STORING_TAG);
53249 if (!radix_tree_tag_get(&cookie->stores, page->index,
53250 FSCACHE_COOKIE_PENDING_TAG)) {
53251 - fscache_stat(&fscache_n_store_radix_deletes);
53252 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
53253 xpage = radix_tree_delete(&cookie->stores, page->index);
53254 }
53255 spin_unlock(&cookie->stores_lock);
53256 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
53257
53258 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
53259
53260 - fscache_stat(&fscache_n_attr_changed_calls);
53261 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
53262
53263 if (fscache_object_is_active(object)) {
53264 fscache_stat(&fscache_n_cop_attr_changed);
53265 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
53266
53267 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
53268
53269 - fscache_stat(&fscache_n_attr_changed);
53270 + fscache_stat_unchecked(&fscache_n_attr_changed);
53271
53272 op = kzalloc(sizeof(*op), GFP_KERNEL);
53273 if (!op) {
53274 - fscache_stat(&fscache_n_attr_changed_nomem);
53275 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
53276 _leave(" = -ENOMEM");
53277 return -ENOMEM;
53278 }
53279 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
53280 if (fscache_submit_exclusive_op(object, op) < 0)
53281 goto nobufs;
53282 spin_unlock(&cookie->lock);
53283 - fscache_stat(&fscache_n_attr_changed_ok);
53284 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
53285 fscache_put_operation(op);
53286 _leave(" = 0");
53287 return 0;
53288 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
53289 nobufs:
53290 spin_unlock(&cookie->lock);
53291 kfree(op);
53292 - fscache_stat(&fscache_n_attr_changed_nobufs);
53293 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
53294 _leave(" = %d", -ENOBUFS);
53295 return -ENOBUFS;
53296 }
53297 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
53298 /* allocate a retrieval operation and attempt to submit it */
53299 op = kzalloc(sizeof(*op), GFP_NOIO);
53300 if (!op) {
53301 - fscache_stat(&fscache_n_retrievals_nomem);
53302 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
53303 return NULL;
53304 }
53305
53306 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
53307 return 0;
53308 }
53309
53310 - fscache_stat(&fscache_n_retrievals_wait);
53311 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
53312
53313 jif = jiffies;
53314 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
53315 fscache_wait_bit_interruptible,
53316 TASK_INTERRUPTIBLE) != 0) {
53317 - fscache_stat(&fscache_n_retrievals_intr);
53318 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
53319 _leave(" = -ERESTARTSYS");
53320 return -ERESTARTSYS;
53321 }
53322 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
53323 */
53324 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
53325 struct fscache_retrieval *op,
53326 - atomic_t *stat_op_waits,
53327 - atomic_t *stat_object_dead)
53328 + atomic_unchecked_t *stat_op_waits,
53329 + atomic_unchecked_t *stat_object_dead)
53330 {
53331 int ret;
53332
53333 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
53334 goto check_if_dead;
53335
53336 _debug(">>> WT");
53337 - fscache_stat(stat_op_waits);
53338 + fscache_stat_unchecked(stat_op_waits);
53339 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
53340 fscache_wait_bit_interruptible,
53341 TASK_INTERRUPTIBLE) != 0) {
53342 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
53343
53344 check_if_dead:
53345 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
53346 - fscache_stat(stat_object_dead);
53347 + fscache_stat_unchecked(stat_object_dead);
53348 _leave(" = -ENOBUFS [cancelled]");
53349 return -ENOBUFS;
53350 }
53351 if (unlikely(fscache_object_is_dead(object))) {
53352 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
53353 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
53354 - fscache_stat(stat_object_dead);
53355 + fscache_stat_unchecked(stat_object_dead);
53356 return -ENOBUFS;
53357 }
53358 return 0;
53359 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
53360
53361 _enter("%p,%p,,,", cookie, page);
53362
53363 - fscache_stat(&fscache_n_retrievals);
53364 + fscache_stat_unchecked(&fscache_n_retrievals);
53365
53366 if (hlist_empty(&cookie->backing_objects))
53367 goto nobufs;
53368 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
53369 goto nobufs_unlock_dec;
53370 spin_unlock(&cookie->lock);
53371
53372 - fscache_stat(&fscache_n_retrieval_ops);
53373 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
53374
53375 /* pin the netfs read context in case we need to do the actual netfs
53376 * read because we've encountered a cache read failure */
53377 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
53378
53379 error:
53380 if (ret == -ENOMEM)
53381 - fscache_stat(&fscache_n_retrievals_nomem);
53382 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
53383 else if (ret == -ERESTARTSYS)
53384 - fscache_stat(&fscache_n_retrievals_intr);
53385 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
53386 else if (ret == -ENODATA)
53387 - fscache_stat(&fscache_n_retrievals_nodata);
53388 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
53389 else if (ret < 0)
53390 - fscache_stat(&fscache_n_retrievals_nobufs);
53391 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
53392 else
53393 - fscache_stat(&fscache_n_retrievals_ok);
53394 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
53395
53396 fscache_put_retrieval(op);
53397 _leave(" = %d", ret);
53398 @@ -467,7 +467,7 @@ nobufs_unlock:
53399 spin_unlock(&cookie->lock);
53400 kfree(op);
53401 nobufs:
53402 - fscache_stat(&fscache_n_retrievals_nobufs);
53403 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
53404 _leave(" = -ENOBUFS");
53405 return -ENOBUFS;
53406 }
53407 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
53408
53409 _enter("%p,,%d,,,", cookie, *nr_pages);
53410
53411 - fscache_stat(&fscache_n_retrievals);
53412 + fscache_stat_unchecked(&fscache_n_retrievals);
53413
53414 if (hlist_empty(&cookie->backing_objects))
53415 goto nobufs;
53416 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
53417 goto nobufs_unlock_dec;
53418 spin_unlock(&cookie->lock);
53419
53420 - fscache_stat(&fscache_n_retrieval_ops);
53421 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
53422
53423 /* pin the netfs read context in case we need to do the actual netfs
53424 * read because we've encountered a cache read failure */
53425 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
53426
53427 error:
53428 if (ret == -ENOMEM)
53429 - fscache_stat(&fscache_n_retrievals_nomem);
53430 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
53431 else if (ret == -ERESTARTSYS)
53432 - fscache_stat(&fscache_n_retrievals_intr);
53433 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
53434 else if (ret == -ENODATA)
53435 - fscache_stat(&fscache_n_retrievals_nodata);
53436 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
53437 else if (ret < 0)
53438 - fscache_stat(&fscache_n_retrievals_nobufs);
53439 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
53440 else
53441 - fscache_stat(&fscache_n_retrievals_ok);
53442 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
53443
53444 fscache_put_retrieval(op);
53445 _leave(" = %d", ret);
53446 @@ -591,7 +591,7 @@ nobufs_unlock:
53447 spin_unlock(&cookie->lock);
53448 kfree(op);
53449 nobufs:
53450 - fscache_stat(&fscache_n_retrievals_nobufs);
53451 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
53452 _leave(" = -ENOBUFS");
53453 return -ENOBUFS;
53454 }
53455 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
53456
53457 _enter("%p,%p,,,", cookie, page);
53458
53459 - fscache_stat(&fscache_n_allocs);
53460 + fscache_stat_unchecked(&fscache_n_allocs);
53461
53462 if (hlist_empty(&cookie->backing_objects))
53463 goto nobufs;
53464 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
53465 goto nobufs_unlock;
53466 spin_unlock(&cookie->lock);
53467
53468 - fscache_stat(&fscache_n_alloc_ops);
53469 + fscache_stat_unchecked(&fscache_n_alloc_ops);
53470
53471 ret = fscache_wait_for_retrieval_activation(
53472 object, op,
53473 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
53474
53475 error:
53476 if (ret == -ERESTARTSYS)
53477 - fscache_stat(&fscache_n_allocs_intr);
53478 + fscache_stat_unchecked(&fscache_n_allocs_intr);
53479 else if (ret < 0)
53480 - fscache_stat(&fscache_n_allocs_nobufs);
53481 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
53482 else
53483 - fscache_stat(&fscache_n_allocs_ok);
53484 + fscache_stat_unchecked(&fscache_n_allocs_ok);
53485
53486 fscache_put_retrieval(op);
53487 _leave(" = %d", ret);
53488 @@ -677,7 +677,7 @@ nobufs_unlock:
53489 spin_unlock(&cookie->lock);
53490 kfree(op);
53491 nobufs:
53492 - fscache_stat(&fscache_n_allocs_nobufs);
53493 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
53494 _leave(" = -ENOBUFS");
53495 return -ENOBUFS;
53496 }
53497 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
53498
53499 spin_lock(&cookie->stores_lock);
53500
53501 - fscache_stat(&fscache_n_store_calls);
53502 + fscache_stat_unchecked(&fscache_n_store_calls);
53503
53504 /* find a page to store */
53505 page = NULL;
53506 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
53507 page = results[0];
53508 _debug("gang %d [%lx]", n, page->index);
53509 if (page->index > op->store_limit) {
53510 - fscache_stat(&fscache_n_store_pages_over_limit);
53511 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
53512 goto superseded;
53513 }
53514
53515 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
53516 spin_unlock(&cookie->stores_lock);
53517 spin_unlock(&object->lock);
53518
53519 - fscache_stat(&fscache_n_store_pages);
53520 + fscache_stat_unchecked(&fscache_n_store_pages);
53521 fscache_stat(&fscache_n_cop_write_page);
53522 ret = object->cache->ops->write_page(op, page);
53523 fscache_stat_d(&fscache_n_cop_write_page);
53524 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53525 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
53526 ASSERT(PageFsCache(page));
53527
53528 - fscache_stat(&fscache_n_stores);
53529 + fscache_stat_unchecked(&fscache_n_stores);
53530
53531 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
53532 _leave(" = -ENOBUFS [invalidating]");
53533 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53534 spin_unlock(&cookie->stores_lock);
53535 spin_unlock(&object->lock);
53536
53537 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
53538 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
53539 op->store_limit = object->store_limit;
53540
53541 if (fscache_submit_op(object, &op->op) < 0)
53542 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53543
53544 spin_unlock(&cookie->lock);
53545 radix_tree_preload_end();
53546 - fscache_stat(&fscache_n_store_ops);
53547 - fscache_stat(&fscache_n_stores_ok);
53548 + fscache_stat_unchecked(&fscache_n_store_ops);
53549 + fscache_stat_unchecked(&fscache_n_stores_ok);
53550
53551 /* the work queue now carries its own ref on the object */
53552 fscache_put_operation(&op->op);
53553 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53554 return 0;
53555
53556 already_queued:
53557 - fscache_stat(&fscache_n_stores_again);
53558 + fscache_stat_unchecked(&fscache_n_stores_again);
53559 already_pending:
53560 spin_unlock(&cookie->stores_lock);
53561 spin_unlock(&object->lock);
53562 spin_unlock(&cookie->lock);
53563 radix_tree_preload_end();
53564 kfree(op);
53565 - fscache_stat(&fscache_n_stores_ok);
53566 + fscache_stat_unchecked(&fscache_n_stores_ok);
53567 _leave(" = 0");
53568 return 0;
53569
53570 @@ -959,14 +959,14 @@ nobufs:
53571 spin_unlock(&cookie->lock);
53572 radix_tree_preload_end();
53573 kfree(op);
53574 - fscache_stat(&fscache_n_stores_nobufs);
53575 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
53576 _leave(" = -ENOBUFS");
53577 return -ENOBUFS;
53578
53579 nomem_free:
53580 kfree(op);
53581 nomem:
53582 - fscache_stat(&fscache_n_stores_oom);
53583 + fscache_stat_unchecked(&fscache_n_stores_oom);
53584 _leave(" = -ENOMEM");
53585 return -ENOMEM;
53586 }
53587 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
53588 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
53589 ASSERTCMP(page, !=, NULL);
53590
53591 - fscache_stat(&fscache_n_uncaches);
53592 + fscache_stat_unchecked(&fscache_n_uncaches);
53593
53594 /* cache withdrawal may beat us to it */
53595 if (!PageFsCache(page))
53596 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
53597 struct fscache_cookie *cookie = op->op.object->cookie;
53598
53599 #ifdef CONFIG_FSCACHE_STATS
53600 - atomic_inc(&fscache_n_marks);
53601 + atomic_inc_unchecked(&fscache_n_marks);
53602 #endif
53603
53604 _debug("- mark %p{%lx}", page, page->index);
53605 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
53606 index 8179e8b..5072cc7 100644
53607 --- a/fs/fscache/stats.c
53608 +++ b/fs/fscache/stats.c
53609 @@ -18,99 +18,99 @@
53610 /*
53611 * operation counters
53612 */
53613 -atomic_t fscache_n_op_pend;
53614 -atomic_t fscache_n_op_run;
53615 -atomic_t fscache_n_op_enqueue;
53616 -atomic_t fscache_n_op_requeue;
53617 -atomic_t fscache_n_op_deferred_release;
53618 -atomic_t fscache_n_op_release;
53619 -atomic_t fscache_n_op_gc;
53620 -atomic_t fscache_n_op_cancelled;
53621 -atomic_t fscache_n_op_rejected;
53622 +atomic_unchecked_t fscache_n_op_pend;
53623 +atomic_unchecked_t fscache_n_op_run;
53624 +atomic_unchecked_t fscache_n_op_enqueue;
53625 +atomic_unchecked_t fscache_n_op_requeue;
53626 +atomic_unchecked_t fscache_n_op_deferred_release;
53627 +atomic_unchecked_t fscache_n_op_release;
53628 +atomic_unchecked_t fscache_n_op_gc;
53629 +atomic_unchecked_t fscache_n_op_cancelled;
53630 +atomic_unchecked_t fscache_n_op_rejected;
53631
53632 -atomic_t fscache_n_attr_changed;
53633 -atomic_t fscache_n_attr_changed_ok;
53634 -atomic_t fscache_n_attr_changed_nobufs;
53635 -atomic_t fscache_n_attr_changed_nomem;
53636 -atomic_t fscache_n_attr_changed_calls;
53637 +atomic_unchecked_t fscache_n_attr_changed;
53638 +atomic_unchecked_t fscache_n_attr_changed_ok;
53639 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
53640 +atomic_unchecked_t fscache_n_attr_changed_nomem;
53641 +atomic_unchecked_t fscache_n_attr_changed_calls;
53642
53643 -atomic_t fscache_n_allocs;
53644 -atomic_t fscache_n_allocs_ok;
53645 -atomic_t fscache_n_allocs_wait;
53646 -atomic_t fscache_n_allocs_nobufs;
53647 -atomic_t fscache_n_allocs_intr;
53648 -atomic_t fscache_n_allocs_object_dead;
53649 -atomic_t fscache_n_alloc_ops;
53650 -atomic_t fscache_n_alloc_op_waits;
53651 +atomic_unchecked_t fscache_n_allocs;
53652 +atomic_unchecked_t fscache_n_allocs_ok;
53653 +atomic_unchecked_t fscache_n_allocs_wait;
53654 +atomic_unchecked_t fscache_n_allocs_nobufs;
53655 +atomic_unchecked_t fscache_n_allocs_intr;
53656 +atomic_unchecked_t fscache_n_allocs_object_dead;
53657 +atomic_unchecked_t fscache_n_alloc_ops;
53658 +atomic_unchecked_t fscache_n_alloc_op_waits;
53659
53660 -atomic_t fscache_n_retrievals;
53661 -atomic_t fscache_n_retrievals_ok;
53662 -atomic_t fscache_n_retrievals_wait;
53663 -atomic_t fscache_n_retrievals_nodata;
53664 -atomic_t fscache_n_retrievals_nobufs;
53665 -atomic_t fscache_n_retrievals_intr;
53666 -atomic_t fscache_n_retrievals_nomem;
53667 -atomic_t fscache_n_retrievals_object_dead;
53668 -atomic_t fscache_n_retrieval_ops;
53669 -atomic_t fscache_n_retrieval_op_waits;
53670 +atomic_unchecked_t fscache_n_retrievals;
53671 +atomic_unchecked_t fscache_n_retrievals_ok;
53672 +atomic_unchecked_t fscache_n_retrievals_wait;
53673 +atomic_unchecked_t fscache_n_retrievals_nodata;
53674 +atomic_unchecked_t fscache_n_retrievals_nobufs;
53675 +atomic_unchecked_t fscache_n_retrievals_intr;
53676 +atomic_unchecked_t fscache_n_retrievals_nomem;
53677 +atomic_unchecked_t fscache_n_retrievals_object_dead;
53678 +atomic_unchecked_t fscache_n_retrieval_ops;
53679 +atomic_unchecked_t fscache_n_retrieval_op_waits;
53680
53681 -atomic_t fscache_n_stores;
53682 -atomic_t fscache_n_stores_ok;
53683 -atomic_t fscache_n_stores_again;
53684 -atomic_t fscache_n_stores_nobufs;
53685 -atomic_t fscache_n_stores_oom;
53686 -atomic_t fscache_n_store_ops;
53687 -atomic_t fscache_n_store_calls;
53688 -atomic_t fscache_n_store_pages;
53689 -atomic_t fscache_n_store_radix_deletes;
53690 -atomic_t fscache_n_store_pages_over_limit;
53691 +atomic_unchecked_t fscache_n_stores;
53692 +atomic_unchecked_t fscache_n_stores_ok;
53693 +atomic_unchecked_t fscache_n_stores_again;
53694 +atomic_unchecked_t fscache_n_stores_nobufs;
53695 +atomic_unchecked_t fscache_n_stores_oom;
53696 +atomic_unchecked_t fscache_n_store_ops;
53697 +atomic_unchecked_t fscache_n_store_calls;
53698 +atomic_unchecked_t fscache_n_store_pages;
53699 +atomic_unchecked_t fscache_n_store_radix_deletes;
53700 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53701
53702 -atomic_t fscache_n_store_vmscan_not_storing;
53703 -atomic_t fscache_n_store_vmscan_gone;
53704 -atomic_t fscache_n_store_vmscan_busy;
53705 -atomic_t fscache_n_store_vmscan_cancelled;
53706 -atomic_t fscache_n_store_vmscan_wait;
53707 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53708 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53709 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53710 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53711 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53712
53713 -atomic_t fscache_n_marks;
53714 -atomic_t fscache_n_uncaches;
53715 +atomic_unchecked_t fscache_n_marks;
53716 +atomic_unchecked_t fscache_n_uncaches;
53717
53718 -atomic_t fscache_n_acquires;
53719 -atomic_t fscache_n_acquires_null;
53720 -atomic_t fscache_n_acquires_no_cache;
53721 -atomic_t fscache_n_acquires_ok;
53722 -atomic_t fscache_n_acquires_nobufs;
53723 -atomic_t fscache_n_acquires_oom;
53724 +atomic_unchecked_t fscache_n_acquires;
53725 +atomic_unchecked_t fscache_n_acquires_null;
53726 +atomic_unchecked_t fscache_n_acquires_no_cache;
53727 +atomic_unchecked_t fscache_n_acquires_ok;
53728 +atomic_unchecked_t fscache_n_acquires_nobufs;
53729 +atomic_unchecked_t fscache_n_acquires_oom;
53730
53731 -atomic_t fscache_n_invalidates;
53732 -atomic_t fscache_n_invalidates_run;
53733 +atomic_unchecked_t fscache_n_invalidates;
53734 +atomic_unchecked_t fscache_n_invalidates_run;
53735
53736 -atomic_t fscache_n_updates;
53737 -atomic_t fscache_n_updates_null;
53738 -atomic_t fscache_n_updates_run;
53739 +atomic_unchecked_t fscache_n_updates;
53740 +atomic_unchecked_t fscache_n_updates_null;
53741 +atomic_unchecked_t fscache_n_updates_run;
53742
53743 -atomic_t fscache_n_relinquishes;
53744 -atomic_t fscache_n_relinquishes_null;
53745 -atomic_t fscache_n_relinquishes_waitcrt;
53746 -atomic_t fscache_n_relinquishes_retire;
53747 +atomic_unchecked_t fscache_n_relinquishes;
53748 +atomic_unchecked_t fscache_n_relinquishes_null;
53749 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53750 +atomic_unchecked_t fscache_n_relinquishes_retire;
53751
53752 -atomic_t fscache_n_cookie_index;
53753 -atomic_t fscache_n_cookie_data;
53754 -atomic_t fscache_n_cookie_special;
53755 +atomic_unchecked_t fscache_n_cookie_index;
53756 +atomic_unchecked_t fscache_n_cookie_data;
53757 +atomic_unchecked_t fscache_n_cookie_special;
53758
53759 -atomic_t fscache_n_object_alloc;
53760 -atomic_t fscache_n_object_no_alloc;
53761 -atomic_t fscache_n_object_lookups;
53762 -atomic_t fscache_n_object_lookups_negative;
53763 -atomic_t fscache_n_object_lookups_positive;
53764 -atomic_t fscache_n_object_lookups_timed_out;
53765 -atomic_t fscache_n_object_created;
53766 -atomic_t fscache_n_object_avail;
53767 -atomic_t fscache_n_object_dead;
53768 +atomic_unchecked_t fscache_n_object_alloc;
53769 +atomic_unchecked_t fscache_n_object_no_alloc;
53770 +atomic_unchecked_t fscache_n_object_lookups;
53771 +atomic_unchecked_t fscache_n_object_lookups_negative;
53772 +atomic_unchecked_t fscache_n_object_lookups_positive;
53773 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53774 +atomic_unchecked_t fscache_n_object_created;
53775 +atomic_unchecked_t fscache_n_object_avail;
53776 +atomic_unchecked_t fscache_n_object_dead;
53777
53778 -atomic_t fscache_n_checkaux_none;
53779 -atomic_t fscache_n_checkaux_okay;
53780 -atomic_t fscache_n_checkaux_update;
53781 -atomic_t fscache_n_checkaux_obsolete;
53782 +atomic_unchecked_t fscache_n_checkaux_none;
53783 +atomic_unchecked_t fscache_n_checkaux_okay;
53784 +atomic_unchecked_t fscache_n_checkaux_update;
53785 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53786
53787 atomic_t fscache_n_cop_alloc_object;
53788 atomic_t fscache_n_cop_lookup_object;
53789 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53790 seq_puts(m, "FS-Cache statistics\n");
53791
53792 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53793 - atomic_read(&fscache_n_cookie_index),
53794 - atomic_read(&fscache_n_cookie_data),
53795 - atomic_read(&fscache_n_cookie_special));
53796 + atomic_read_unchecked(&fscache_n_cookie_index),
53797 + atomic_read_unchecked(&fscache_n_cookie_data),
53798 + atomic_read_unchecked(&fscache_n_cookie_special));
53799
53800 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53801 - atomic_read(&fscache_n_object_alloc),
53802 - atomic_read(&fscache_n_object_no_alloc),
53803 - atomic_read(&fscache_n_object_avail),
53804 - atomic_read(&fscache_n_object_dead));
53805 + atomic_read_unchecked(&fscache_n_object_alloc),
53806 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53807 + atomic_read_unchecked(&fscache_n_object_avail),
53808 + atomic_read_unchecked(&fscache_n_object_dead));
53809 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53810 - atomic_read(&fscache_n_checkaux_none),
53811 - atomic_read(&fscache_n_checkaux_okay),
53812 - atomic_read(&fscache_n_checkaux_update),
53813 - atomic_read(&fscache_n_checkaux_obsolete));
53814 + atomic_read_unchecked(&fscache_n_checkaux_none),
53815 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53816 + atomic_read_unchecked(&fscache_n_checkaux_update),
53817 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53818
53819 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53820 - atomic_read(&fscache_n_marks),
53821 - atomic_read(&fscache_n_uncaches));
53822 + atomic_read_unchecked(&fscache_n_marks),
53823 + atomic_read_unchecked(&fscache_n_uncaches));
53824
53825 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53826 " oom=%u\n",
53827 - atomic_read(&fscache_n_acquires),
53828 - atomic_read(&fscache_n_acquires_null),
53829 - atomic_read(&fscache_n_acquires_no_cache),
53830 - atomic_read(&fscache_n_acquires_ok),
53831 - atomic_read(&fscache_n_acquires_nobufs),
53832 - atomic_read(&fscache_n_acquires_oom));
53833 + atomic_read_unchecked(&fscache_n_acquires),
53834 + atomic_read_unchecked(&fscache_n_acquires_null),
53835 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53836 + atomic_read_unchecked(&fscache_n_acquires_ok),
53837 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53838 + atomic_read_unchecked(&fscache_n_acquires_oom));
53839
53840 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53841 - atomic_read(&fscache_n_object_lookups),
53842 - atomic_read(&fscache_n_object_lookups_negative),
53843 - atomic_read(&fscache_n_object_lookups_positive),
53844 - atomic_read(&fscache_n_object_created),
53845 - atomic_read(&fscache_n_object_lookups_timed_out));
53846 + atomic_read_unchecked(&fscache_n_object_lookups),
53847 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53848 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53849 + atomic_read_unchecked(&fscache_n_object_created),
53850 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53851
53852 seq_printf(m, "Invals : n=%u run=%u\n",
53853 - atomic_read(&fscache_n_invalidates),
53854 - atomic_read(&fscache_n_invalidates_run));
53855 + atomic_read_unchecked(&fscache_n_invalidates),
53856 + atomic_read_unchecked(&fscache_n_invalidates_run));
53857
53858 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53859 - atomic_read(&fscache_n_updates),
53860 - atomic_read(&fscache_n_updates_null),
53861 - atomic_read(&fscache_n_updates_run));
53862 + atomic_read_unchecked(&fscache_n_updates),
53863 + atomic_read_unchecked(&fscache_n_updates_null),
53864 + atomic_read_unchecked(&fscache_n_updates_run));
53865
53866 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53867 - atomic_read(&fscache_n_relinquishes),
53868 - atomic_read(&fscache_n_relinquishes_null),
53869 - atomic_read(&fscache_n_relinquishes_waitcrt),
53870 - atomic_read(&fscache_n_relinquishes_retire));
53871 + atomic_read_unchecked(&fscache_n_relinquishes),
53872 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53873 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53874 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53875
53876 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53877 - atomic_read(&fscache_n_attr_changed),
53878 - atomic_read(&fscache_n_attr_changed_ok),
53879 - atomic_read(&fscache_n_attr_changed_nobufs),
53880 - atomic_read(&fscache_n_attr_changed_nomem),
53881 - atomic_read(&fscache_n_attr_changed_calls));
53882 + atomic_read_unchecked(&fscache_n_attr_changed),
53883 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53884 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53885 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53886 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53887
53888 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53889 - atomic_read(&fscache_n_allocs),
53890 - atomic_read(&fscache_n_allocs_ok),
53891 - atomic_read(&fscache_n_allocs_wait),
53892 - atomic_read(&fscache_n_allocs_nobufs),
53893 - atomic_read(&fscache_n_allocs_intr));
53894 + atomic_read_unchecked(&fscache_n_allocs),
53895 + atomic_read_unchecked(&fscache_n_allocs_ok),
53896 + atomic_read_unchecked(&fscache_n_allocs_wait),
53897 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53898 + atomic_read_unchecked(&fscache_n_allocs_intr));
53899 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53900 - atomic_read(&fscache_n_alloc_ops),
53901 - atomic_read(&fscache_n_alloc_op_waits),
53902 - atomic_read(&fscache_n_allocs_object_dead));
53903 + atomic_read_unchecked(&fscache_n_alloc_ops),
53904 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53905 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53906
53907 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53908 " int=%u oom=%u\n",
53909 - atomic_read(&fscache_n_retrievals),
53910 - atomic_read(&fscache_n_retrievals_ok),
53911 - atomic_read(&fscache_n_retrievals_wait),
53912 - atomic_read(&fscache_n_retrievals_nodata),
53913 - atomic_read(&fscache_n_retrievals_nobufs),
53914 - atomic_read(&fscache_n_retrievals_intr),
53915 - atomic_read(&fscache_n_retrievals_nomem));
53916 + atomic_read_unchecked(&fscache_n_retrievals),
53917 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53918 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53919 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53920 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53921 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53922 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53923 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53924 - atomic_read(&fscache_n_retrieval_ops),
53925 - atomic_read(&fscache_n_retrieval_op_waits),
53926 - atomic_read(&fscache_n_retrievals_object_dead));
53927 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53928 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53929 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53930
53931 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53932 - atomic_read(&fscache_n_stores),
53933 - atomic_read(&fscache_n_stores_ok),
53934 - atomic_read(&fscache_n_stores_again),
53935 - atomic_read(&fscache_n_stores_nobufs),
53936 - atomic_read(&fscache_n_stores_oom));
53937 + atomic_read_unchecked(&fscache_n_stores),
53938 + atomic_read_unchecked(&fscache_n_stores_ok),
53939 + atomic_read_unchecked(&fscache_n_stores_again),
53940 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53941 + atomic_read_unchecked(&fscache_n_stores_oom));
53942 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53943 - atomic_read(&fscache_n_store_ops),
53944 - atomic_read(&fscache_n_store_calls),
53945 - atomic_read(&fscache_n_store_pages),
53946 - atomic_read(&fscache_n_store_radix_deletes),
53947 - atomic_read(&fscache_n_store_pages_over_limit));
53948 + atomic_read_unchecked(&fscache_n_store_ops),
53949 + atomic_read_unchecked(&fscache_n_store_calls),
53950 + atomic_read_unchecked(&fscache_n_store_pages),
53951 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53952 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53953
53954 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53955 - atomic_read(&fscache_n_store_vmscan_not_storing),
53956 - atomic_read(&fscache_n_store_vmscan_gone),
53957 - atomic_read(&fscache_n_store_vmscan_busy),
53958 - atomic_read(&fscache_n_store_vmscan_cancelled),
53959 - atomic_read(&fscache_n_store_vmscan_wait));
53960 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53961 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53962 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53963 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53964 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53965
53966 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53967 - atomic_read(&fscache_n_op_pend),
53968 - atomic_read(&fscache_n_op_run),
53969 - atomic_read(&fscache_n_op_enqueue),
53970 - atomic_read(&fscache_n_op_cancelled),
53971 - atomic_read(&fscache_n_op_rejected));
53972 + atomic_read_unchecked(&fscache_n_op_pend),
53973 + atomic_read_unchecked(&fscache_n_op_run),
53974 + atomic_read_unchecked(&fscache_n_op_enqueue),
53975 + atomic_read_unchecked(&fscache_n_op_cancelled),
53976 + atomic_read_unchecked(&fscache_n_op_rejected));
53977 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53978 - atomic_read(&fscache_n_op_deferred_release),
53979 - atomic_read(&fscache_n_op_release),
53980 - atomic_read(&fscache_n_op_gc));
53981 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53982 + atomic_read_unchecked(&fscache_n_op_release),
53983 + atomic_read_unchecked(&fscache_n_op_gc));
53984
53985 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53986 atomic_read(&fscache_n_cop_alloc_object),
53987 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53988 index e397b67..b0d8709 100644
53989 --- a/fs/fuse/cuse.c
53990 +++ b/fs/fuse/cuse.c
53991 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
53992 INIT_LIST_HEAD(&cuse_conntbl[i]);
53993
53994 /* inherit and extend fuse_dev_operations */
53995 - cuse_channel_fops = fuse_dev_operations;
53996 - cuse_channel_fops.owner = THIS_MODULE;
53997 - cuse_channel_fops.open = cuse_channel_open;
53998 - cuse_channel_fops.release = cuse_channel_release;
53999 + pax_open_kernel();
54000 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
54001 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
54002 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
54003 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
54004 + pax_close_kernel();
54005
54006 cuse_class = class_create(THIS_MODULE, "cuse");
54007 if (IS_ERR(cuse_class))
54008 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
54009 index e83351a..41e3c9c 100644
54010 --- a/fs/fuse/dev.c
54011 +++ b/fs/fuse/dev.c
54012 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
54013 ret = 0;
54014 pipe_lock(pipe);
54015
54016 - if (!pipe->readers) {
54017 + if (!atomic_read(&pipe->readers)) {
54018 send_sig(SIGPIPE, current, 0);
54019 if (!ret)
54020 ret = -EPIPE;
54021 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
54022 index 315e1f8..91f890c 100644
54023 --- a/fs/fuse/dir.c
54024 +++ b/fs/fuse/dir.c
54025 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
54026 return link;
54027 }
54028
54029 -static void free_link(char *link)
54030 +static void free_link(const char *link)
54031 {
54032 if (!IS_ERR(link))
54033 free_page((unsigned long) link);
54034 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
54035 index 2b6f569..fcb4d1f 100644
54036 --- a/fs/gfs2/inode.c
54037 +++ b/fs/gfs2/inode.c
54038 @@ -1499,7 +1499,7 @@ out:
54039
54040 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
54041 {
54042 - char *s = nd_get_link(nd);
54043 + const char *s = nd_get_link(nd);
54044 if (!IS_ERR(s))
54045 kfree(s);
54046 }
54047 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
54048 index ccee8cc..144b5d7 100644
54049 --- a/fs/hugetlbfs/inode.c
54050 +++ b/fs/hugetlbfs/inode.c
54051 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
54052 struct mm_struct *mm = current->mm;
54053 struct vm_area_struct *vma;
54054 struct hstate *h = hstate_file(file);
54055 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
54056 struct vm_unmapped_area_info info;
54057
54058 if (len & ~huge_page_mask(h))
54059 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
54060 return addr;
54061 }
54062
54063 +#ifdef CONFIG_PAX_RANDMMAP
54064 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
54065 +#endif
54066 +
54067 if (addr) {
54068 addr = ALIGN(addr, huge_page_size(h));
54069 vma = find_vma(mm, addr);
54070 - if (TASK_SIZE - len >= addr &&
54071 - (!vma || addr + len <= vma->vm_start))
54072 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
54073 return addr;
54074 }
54075
54076 info.flags = 0;
54077 info.length = len;
54078 info.low_limit = TASK_UNMAPPED_BASE;
54079 +
54080 +#ifdef CONFIG_PAX_RANDMMAP
54081 + if (mm->pax_flags & MF_PAX_RANDMMAP)
54082 + info.low_limit += mm->delta_mmap;
54083 +#endif
54084 +
54085 info.high_limit = TASK_SIZE;
54086 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
54087 info.align_offset = 0;
54088 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
54089 .kill_sb = kill_litter_super,
54090 };
54091
54092 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
54093 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
54094
54095 static int can_do_hugetlb_shm(void)
54096 {
54097 diff --git a/fs/inode.c b/fs/inode.c
54098 index b98540e..6a439ea 100644
54099 --- a/fs/inode.c
54100 +++ b/fs/inode.c
54101 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
54102
54103 #ifdef CONFIG_SMP
54104 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
54105 - static atomic_t shared_last_ino;
54106 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
54107 + static atomic_unchecked_t shared_last_ino;
54108 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
54109
54110 res = next - LAST_INO_BATCH;
54111 }
54112 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
54113 index 4a6cf28..d3a29d3 100644
54114 --- a/fs/jffs2/erase.c
54115 +++ b/fs/jffs2/erase.c
54116 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
54117 struct jffs2_unknown_node marker = {
54118 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
54119 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
54120 - .totlen = cpu_to_je32(c->cleanmarker_size)
54121 + .totlen = cpu_to_je32(c->cleanmarker_size),
54122 + .hdr_crc = cpu_to_je32(0)
54123 };
54124
54125 jffs2_prealloc_raw_node_refs(c, jeb, 1);
54126 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
54127 index a6597d6..41b30ec 100644
54128 --- a/fs/jffs2/wbuf.c
54129 +++ b/fs/jffs2/wbuf.c
54130 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
54131 {
54132 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
54133 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
54134 - .totlen = constant_cpu_to_je32(8)
54135 + .totlen = constant_cpu_to_je32(8),
54136 + .hdr_crc = constant_cpu_to_je32(0)
54137 };
54138
54139 /*
54140 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
54141 index 1a543be..a4e1363 100644
54142 --- a/fs/jfs/super.c
54143 +++ b/fs/jfs/super.c
54144 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
54145 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
54146 int *flag)
54147 {
54148 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
54149 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
54150 char *p;
54151 struct jfs_sb_info *sbi = JFS_SBI(sb);
54152
54153 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
54154 /* Don't do anything ;-) */
54155 break;
54156 case Opt_iocharset:
54157 - if (nls_map && nls_map != (void *) -1)
54158 + if (nls_map && nls_map != (const void *) -1)
54159 unload_nls(nls_map);
54160 if (!strcmp(args[0].from, "none"))
54161 nls_map = NULL;
54162 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
54163
54164 jfs_inode_cachep =
54165 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
54166 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
54167 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
54168 init_once);
54169 if (jfs_inode_cachep == NULL)
54170 return -ENOMEM;
54171 diff --git a/fs/libfs.c b/fs/libfs.c
54172 index 916da8c..1588998 100644
54173 --- a/fs/libfs.c
54174 +++ b/fs/libfs.c
54175 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
54176
54177 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
54178 struct dentry *next;
54179 + char d_name[sizeof(next->d_iname)];
54180 + const unsigned char *name;
54181 +
54182 next = list_entry(p, struct dentry, d_u.d_child);
54183 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
54184 if (!simple_positive(next)) {
54185 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
54186
54187 spin_unlock(&next->d_lock);
54188 spin_unlock(&dentry->d_lock);
54189 - if (filldir(dirent, next->d_name.name,
54190 + name = next->d_name.name;
54191 + if (name == next->d_iname) {
54192 + memcpy(d_name, name, next->d_name.len);
54193 + name = d_name;
54194 + }
54195 + if (filldir(dirent, name,
54196 next->d_name.len, filp->f_pos,
54197 next->d_inode->i_ino,
54198 dt_type(next->d_inode)) < 0)
54199 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
54200 index 52e5120..808936e 100644
54201 --- a/fs/lockd/clntproc.c
54202 +++ b/fs/lockd/clntproc.c
54203 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
54204 /*
54205 * Cookie counter for NLM requests
54206 */
54207 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
54208 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
54209
54210 void nlmclnt_next_cookie(struct nlm_cookie *c)
54211 {
54212 - u32 cookie = atomic_inc_return(&nlm_cookie);
54213 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
54214
54215 memcpy(c->data, &cookie, 4);
54216 c->len=4;
54217 diff --git a/fs/locks.c b/fs/locks.c
54218 index a94e331..060bce3 100644
54219 --- a/fs/locks.c
54220 +++ b/fs/locks.c
54221 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
54222 return;
54223
54224 if (filp->f_op && filp->f_op->flock) {
54225 - struct file_lock fl = {
54226 + struct file_lock flock = {
54227 .fl_pid = current->tgid,
54228 .fl_file = filp,
54229 .fl_flags = FL_FLOCK,
54230 .fl_type = F_UNLCK,
54231 .fl_end = OFFSET_MAX,
54232 };
54233 - filp->f_op->flock(filp, F_SETLKW, &fl);
54234 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
54235 - fl.fl_ops->fl_release_private(&fl);
54236 + filp->f_op->flock(filp, F_SETLKW, &flock);
54237 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
54238 + flock.fl_ops->fl_release_private(&flock);
54239 }
54240
54241 lock_flocks();
54242 diff --git a/fs/namei.c b/fs/namei.c
54243 index ec97aef..e67718d 100644
54244 --- a/fs/namei.c
54245 +++ b/fs/namei.c
54246 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
54247 if (ret != -EACCES)
54248 return ret;
54249
54250 +#ifdef CONFIG_GRKERNSEC
54251 + /* we'll block if we have to log due to a denied capability use */
54252 + if (mask & MAY_NOT_BLOCK)
54253 + return -ECHILD;
54254 +#endif
54255 +
54256 if (S_ISDIR(inode->i_mode)) {
54257 /* DACs are overridable for directories */
54258 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
54259 - return 0;
54260 if (!(mask & MAY_WRITE))
54261 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
54262 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
54263 + inode_capable(inode, CAP_DAC_READ_SEARCH))
54264 return 0;
54265 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
54266 + return 0;
54267 return -EACCES;
54268 }
54269 /*
54270 + * Searching includes executable on directories, else just read.
54271 + */
54272 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
54273 + if (mask == MAY_READ)
54274 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
54275 + inode_capable(inode, CAP_DAC_READ_SEARCH))
54276 + return 0;
54277 +
54278 + /*
54279 * Read/write DACs are always overridable.
54280 * Executable DACs are overridable when there is
54281 * at least one exec bit set.
54282 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
54283 if (inode_capable(inode, CAP_DAC_OVERRIDE))
54284 return 0;
54285
54286 - /*
54287 - * Searching includes executable on directories, else just read.
54288 - */
54289 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
54290 - if (mask == MAY_READ)
54291 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
54292 - return 0;
54293 -
54294 return -EACCES;
54295 }
54296
54297 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
54298 {
54299 struct dentry *dentry = link->dentry;
54300 int error;
54301 - char *s;
54302 + const char *s;
54303
54304 BUG_ON(nd->flags & LOOKUP_RCU);
54305
54306 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
54307 if (error)
54308 goto out_put_nd_path;
54309
54310 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
54311 + dentry->d_inode, dentry, nd->path.mnt)) {
54312 + error = -EACCES;
54313 + goto out_put_nd_path;
54314 + }
54315 +
54316 nd->last_type = LAST_BIND;
54317 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
54318 error = PTR_ERR(*p);
54319 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
54320 break;
54321 res = walk_component(nd, path, &nd->last,
54322 nd->last_type, LOOKUP_FOLLOW);
54323 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
54324 + res = -EACCES;
54325 put_link(nd, &link, cookie);
54326 } while (res > 0);
54327
54328 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
54329 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
54330 {
54331 unsigned long a, b, adata, bdata, mask, hash, len;
54332 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
54333 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
54334
54335 hash = a = 0;
54336 len = -sizeof(unsigned long);
54337 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
54338 if (err)
54339 break;
54340 err = lookup_last(nd, &path);
54341 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
54342 + err = -EACCES;
54343 put_link(nd, &link, cookie);
54344 }
54345 }
54346 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
54347 if (!err)
54348 err = complete_walk(nd);
54349
54350 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
54351 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
54352 + path_put(&nd->path);
54353 + err = -ENOENT;
54354 + }
54355 + }
54356 +
54357 if (!err && nd->flags & LOOKUP_DIRECTORY) {
54358 if (!nd->inode->i_op->lookup) {
54359 path_put(&nd->path);
54360 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
54361 retval = path_lookupat(dfd, name->name,
54362 flags | LOOKUP_REVAL, nd);
54363
54364 - if (likely(!retval))
54365 + if (likely(!retval)) {
54366 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
54367 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
54368 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
54369 + path_put(&nd->path);
54370 + return -ENOENT;
54371 + }
54372 + }
54373 + }
54374 return retval;
54375 }
54376
54377 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
54378 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
54379 return -EPERM;
54380
54381 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
54382 + return -EPERM;
54383 + if (gr_handle_rawio(inode))
54384 + return -EPERM;
54385 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
54386 + return -EACCES;
54387 +
54388 return 0;
54389 }
54390
54391 @@ -2611,7 +2650,7 @@ looked_up:
54392 * cleared otherwise prior to returning.
54393 */
54394 static int lookup_open(struct nameidata *nd, struct path *path,
54395 - struct file *file,
54396 + struct path *link, struct file *file,
54397 const struct open_flags *op,
54398 bool got_write, int *opened)
54399 {
54400 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
54401 /* Negative dentry, just create the file */
54402 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
54403 umode_t mode = op->mode;
54404 +
54405 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
54406 + error = -EACCES;
54407 + goto out_dput;
54408 + }
54409 +
54410 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
54411 + error = -EACCES;
54412 + goto out_dput;
54413 + }
54414 +
54415 if (!IS_POSIXACL(dir->d_inode))
54416 mode &= ~current_umask();
54417 /*
54418 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
54419 nd->flags & LOOKUP_EXCL);
54420 if (error)
54421 goto out_dput;
54422 + else
54423 + gr_handle_create(dentry, nd->path.mnt);
54424 }
54425 out_no_open:
54426 path->dentry = dentry;
54427 @@ -2681,7 +2733,7 @@ out_dput:
54428 /*
54429 * Handle the last step of open()
54430 */
54431 -static int do_last(struct nameidata *nd, struct path *path,
54432 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
54433 struct file *file, const struct open_flags *op,
54434 int *opened, struct filename *name)
54435 {
54436 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
54437 error = complete_walk(nd);
54438 if (error)
54439 return error;
54440 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
54441 + error = -ENOENT;
54442 + goto out;
54443 + }
54444 audit_inode(name, nd->path.dentry, 0);
54445 if (open_flag & O_CREAT) {
54446 error = -EISDIR;
54447 goto out;
54448 }
54449 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
54450 + error = -EACCES;
54451 + goto out;
54452 + }
54453 goto finish_open;
54454 case LAST_BIND:
54455 error = complete_walk(nd);
54456 if (error)
54457 return error;
54458 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
54459 + error = -ENOENT;
54460 + goto out;
54461 + }
54462 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
54463 + error = -EACCES;
54464 + goto out;
54465 + }
54466 audit_inode(name, dir, 0);
54467 goto finish_open;
54468 }
54469 @@ -2768,7 +2836,7 @@ retry_lookup:
54470 */
54471 }
54472 mutex_lock(&dir->d_inode->i_mutex);
54473 - error = lookup_open(nd, path, file, op, got_write, opened);
54474 + error = lookup_open(nd, path, link, file, op, got_write, opened);
54475 mutex_unlock(&dir->d_inode->i_mutex);
54476
54477 if (error <= 0) {
54478 @@ -2792,11 +2860,28 @@ retry_lookup:
54479 goto finish_open_created;
54480 }
54481
54482 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
54483 + error = -ENOENT;
54484 + goto exit_dput;
54485 + }
54486 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
54487 + error = -EACCES;
54488 + goto exit_dput;
54489 + }
54490 +
54491 /*
54492 * create/update audit record if it already exists.
54493 */
54494 - if (path->dentry->d_inode)
54495 + if (path->dentry->d_inode) {
54496 + /* only check if O_CREAT is specified, all other checks need to go
54497 + into may_open */
54498 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
54499 + error = -EACCES;
54500 + goto exit_dput;
54501 + }
54502 +
54503 audit_inode(name, path->dentry, 0);
54504 + }
54505
54506 /*
54507 * If atomic_open() acquired write access it is dropped now due to
54508 @@ -2837,6 +2922,11 @@ finish_lookup:
54509 }
54510 }
54511 BUG_ON(inode != path->dentry->d_inode);
54512 + /* if we're resolving a symlink to another symlink */
54513 + if (link && gr_handle_symlink_owner(link, inode)) {
54514 + error = -EACCES;
54515 + goto out;
54516 + }
54517 return 1;
54518 }
54519
54520 @@ -2846,7 +2936,6 @@ finish_lookup:
54521 save_parent.dentry = nd->path.dentry;
54522 save_parent.mnt = mntget(path->mnt);
54523 nd->path.dentry = path->dentry;
54524 -
54525 }
54526 nd->inode = inode;
54527 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
54528 @@ -2855,6 +2944,16 @@ finish_lookup:
54529 path_put(&save_parent);
54530 return error;
54531 }
54532 +
54533 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
54534 + error = -ENOENT;
54535 + goto out;
54536 + }
54537 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
54538 + error = -EACCES;
54539 + goto out;
54540 + }
54541 +
54542 error = -EISDIR;
54543 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
54544 goto out;
54545 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
54546 if (unlikely(error))
54547 goto out;
54548
54549 - error = do_last(nd, &path, file, op, &opened, pathname);
54550 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
54551 while (unlikely(error > 0)) { /* trailing symlink */
54552 struct path link = path;
54553 void *cookie;
54554 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
54555 error = follow_link(&link, nd, &cookie);
54556 if (unlikely(error))
54557 break;
54558 - error = do_last(nd, &path, file, op, &opened, pathname);
54559 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
54560 put_link(nd, &link, cookie);
54561 }
54562 out:
54563 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
54564 goto unlock;
54565
54566 error = -EEXIST;
54567 - if (dentry->d_inode)
54568 + if (dentry->d_inode) {
54569 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
54570 + error = -ENOENT;
54571 + }
54572 goto fail;
54573 + }
54574 /*
54575 * Special case - lookup gave negative, but... we had foo/bar/
54576 * From the vfs_mknod() POV we just have a negative dentry -
54577 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
54578 }
54579 EXPORT_SYMBOL(user_path_create);
54580
54581 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
54582 +{
54583 + struct filename *tmp = getname(pathname);
54584 + struct dentry *res;
54585 + if (IS_ERR(tmp))
54586 + return ERR_CAST(tmp);
54587 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
54588 + if (IS_ERR(res))
54589 + putname(tmp);
54590 + else
54591 + *to = tmp;
54592 + return res;
54593 +}
54594 +
54595 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
54596 {
54597 int error = may_create(dir, dentry);
54598 @@ -3186,6 +3303,17 @@ retry:
54599
54600 if (!IS_POSIXACL(path.dentry->d_inode))
54601 mode &= ~current_umask();
54602 +
54603 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
54604 + error = -EPERM;
54605 + goto out;
54606 + }
54607 +
54608 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
54609 + error = -EACCES;
54610 + goto out;
54611 + }
54612 +
54613 error = security_path_mknod(&path, dentry, mode, dev);
54614 if (error)
54615 goto out;
54616 @@ -3202,6 +3330,8 @@ retry:
54617 break;
54618 }
54619 out:
54620 + if (!error)
54621 + gr_handle_create(dentry, path.mnt);
54622 done_path_create(&path, dentry);
54623 if (retry_estale(error, lookup_flags)) {
54624 lookup_flags |= LOOKUP_REVAL;
54625 @@ -3254,9 +3384,16 @@ retry:
54626
54627 if (!IS_POSIXACL(path.dentry->d_inode))
54628 mode &= ~current_umask();
54629 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
54630 + error = -EACCES;
54631 + goto out;
54632 + }
54633 error = security_path_mkdir(&path, dentry, mode);
54634 if (!error)
54635 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
54636 + if (!error)
54637 + gr_handle_create(dentry, path.mnt);
54638 +out:
54639 done_path_create(&path, dentry);
54640 if (retry_estale(error, lookup_flags)) {
54641 lookup_flags |= LOOKUP_REVAL;
54642 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
54643 struct filename *name;
54644 struct dentry *dentry;
54645 struct nameidata nd;
54646 + ino_t saved_ino = 0;
54647 + dev_t saved_dev = 0;
54648 unsigned int lookup_flags = 0;
54649 retry:
54650 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54651 @@ -3369,10 +3508,21 @@ retry:
54652 error = -ENOENT;
54653 goto exit3;
54654 }
54655 +
54656 + saved_ino = dentry->d_inode->i_ino;
54657 + saved_dev = gr_get_dev_from_dentry(dentry);
54658 +
54659 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
54660 + error = -EACCES;
54661 + goto exit3;
54662 + }
54663 +
54664 error = security_path_rmdir(&nd.path, dentry);
54665 if (error)
54666 goto exit3;
54667 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
54668 + if (!error && (saved_dev || saved_ino))
54669 + gr_handle_delete(saved_ino, saved_dev);
54670 exit3:
54671 dput(dentry);
54672 exit2:
54673 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
54674 struct dentry *dentry;
54675 struct nameidata nd;
54676 struct inode *inode = NULL;
54677 + ino_t saved_ino = 0;
54678 + dev_t saved_dev = 0;
54679 unsigned int lookup_flags = 0;
54680 retry:
54681 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54682 @@ -3464,10 +3616,22 @@ retry:
54683 if (!inode)
54684 goto slashes;
54685 ihold(inode);
54686 +
54687 + if (inode->i_nlink <= 1) {
54688 + saved_ino = inode->i_ino;
54689 + saved_dev = gr_get_dev_from_dentry(dentry);
54690 + }
54691 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
54692 + error = -EACCES;
54693 + goto exit2;
54694 + }
54695 +
54696 error = security_path_unlink(&nd.path, dentry);
54697 if (error)
54698 goto exit2;
54699 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54700 + if (!error && (saved_ino || saved_dev))
54701 + gr_handle_delete(saved_ino, saved_dev);
54702 exit2:
54703 dput(dentry);
54704 }
54705 @@ -3545,9 +3709,17 @@ retry:
54706 if (IS_ERR(dentry))
54707 goto out_putname;
54708
54709 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54710 + error = -EACCES;
54711 + goto out;
54712 + }
54713 +
54714 error = security_path_symlink(&path, dentry, from->name);
54715 if (!error)
54716 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54717 + if (!error)
54718 + gr_handle_create(dentry, path.mnt);
54719 +out:
54720 done_path_create(&path, dentry);
54721 if (retry_estale(error, lookup_flags)) {
54722 lookup_flags |= LOOKUP_REVAL;
54723 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54724 {
54725 struct dentry *new_dentry;
54726 struct path old_path, new_path;
54727 + struct filename *to = NULL;
54728 int how = 0;
54729 int error;
54730
54731 @@ -3644,7 +3817,7 @@ retry:
54732 if (error)
54733 return error;
54734
54735 - new_dentry = user_path_create(newdfd, newname, &new_path,
54736 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54737 (how & LOOKUP_REVAL));
54738 error = PTR_ERR(new_dentry);
54739 if (IS_ERR(new_dentry))
54740 @@ -3656,11 +3829,28 @@ retry:
54741 error = may_linkat(&old_path);
54742 if (unlikely(error))
54743 goto out_dput;
54744 +
54745 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54746 + old_path.dentry->d_inode,
54747 + old_path.dentry->d_inode->i_mode, to)) {
54748 + error = -EACCES;
54749 + goto out_dput;
54750 + }
54751 +
54752 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54753 + old_path.dentry, old_path.mnt, to)) {
54754 + error = -EACCES;
54755 + goto out_dput;
54756 + }
54757 +
54758 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54759 if (error)
54760 goto out_dput;
54761 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54762 + if (!error)
54763 + gr_handle_create(new_dentry, new_path.mnt);
54764 out_dput:
54765 + putname(to);
54766 done_path_create(&new_path, new_dentry);
54767 if (retry_estale(error, how)) {
54768 how |= LOOKUP_REVAL;
54769 @@ -3906,12 +4096,21 @@ retry:
54770 if (new_dentry == trap)
54771 goto exit5;
54772
54773 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54774 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54775 + to);
54776 + if (error)
54777 + goto exit5;
54778 +
54779 error = security_path_rename(&oldnd.path, old_dentry,
54780 &newnd.path, new_dentry);
54781 if (error)
54782 goto exit5;
54783 error = vfs_rename(old_dir->d_inode, old_dentry,
54784 new_dir->d_inode, new_dentry);
54785 + if (!error)
54786 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54787 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54788 exit5:
54789 dput(new_dentry);
54790 exit4:
54791 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54792
54793 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54794 {
54795 + char tmpbuf[64];
54796 + const char *newlink;
54797 int len;
54798
54799 len = PTR_ERR(link);
54800 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54801 len = strlen(link);
54802 if (len > (unsigned) buflen)
54803 len = buflen;
54804 - if (copy_to_user(buffer, link, len))
54805 +
54806 + if (len < sizeof(tmpbuf)) {
54807 + memcpy(tmpbuf, link, len);
54808 + newlink = tmpbuf;
54809 + } else
54810 + newlink = link;
54811 +
54812 + if (copy_to_user(buffer, newlink, len))
54813 len = -EFAULT;
54814 out:
54815 return len;
54816 diff --git a/fs/namespace.c b/fs/namespace.c
54817 index 5dd7709..6f64e9c 100644
54818 --- a/fs/namespace.c
54819 +++ b/fs/namespace.c
54820 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
54821 if (!(sb->s_flags & MS_RDONLY))
54822 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54823 up_write(&sb->s_umount);
54824 +
54825 + gr_log_remount(mnt->mnt_devname, retval);
54826 +
54827 return retval;
54828 }
54829
54830 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
54831 br_write_unlock(&vfsmount_lock);
54832 up_write(&namespace_sem);
54833 release_mounts(&umount_list);
54834 +
54835 + gr_log_unmount(mnt->mnt_devname, retval);
54836 +
54837 return retval;
54838 }
54839
54840 @@ -1713,7 +1719,7 @@ static int do_loopback(struct path *path, const char *old_name,
54841
54842 if (IS_ERR(mnt)) {
54843 err = PTR_ERR(mnt);
54844 - goto out;
54845 + goto out2;
54846 }
54847
54848 err = graft_tree(mnt, path);
54849 @@ -2294,6 +2300,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54850 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54851 MS_STRICTATIME);
54852
54853 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54854 + retval = -EPERM;
54855 + goto dput_out;
54856 + }
54857 +
54858 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54859 + retval = -EPERM;
54860 + goto dput_out;
54861 + }
54862 +
54863 if (flags & MS_REMOUNT)
54864 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54865 data_page);
54866 @@ -2308,6 +2324,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54867 dev_name, data_page);
54868 dput_out:
54869 path_put(&path);
54870 +
54871 + gr_log_mount(dev_name, dir_name, retval);
54872 +
54873 return retval;
54874 }
54875
54876 @@ -2594,6 +2613,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54877 if (error)
54878 goto out2;
54879
54880 + if (gr_handle_chroot_pivot()) {
54881 + error = -EPERM;
54882 + goto out2;
54883 + }
54884 +
54885 get_fs_root(current->fs, &root);
54886 error = lock_mount(&old);
54887 if (error)
54888 @@ -2842,7 +2866,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54889 !nsown_capable(CAP_SYS_ADMIN))
54890 return -EPERM;
54891
54892 - if (fs->users != 1)
54893 + if (atomic_read(&fs->users) != 1)
54894 return -EINVAL;
54895
54896 get_mnt_ns(mnt_ns);
54897 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54898 index 59461c9..b17c57e 100644
54899 --- a/fs/nfs/callback_xdr.c
54900 +++ b/fs/nfs/callback_xdr.c
54901 @@ -51,7 +51,7 @@ struct callback_op {
54902 callback_decode_arg_t decode_args;
54903 callback_encode_res_t encode_res;
54904 long res_maxsize;
54905 -};
54906 +} __do_const;
54907
54908 static struct callback_op callback_ops[];
54909
54910 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54911 index ebeb94c..ff35337 100644
54912 --- a/fs/nfs/inode.c
54913 +++ b/fs/nfs/inode.c
54914 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54915 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54916 }
54917
54918 -static atomic_long_t nfs_attr_generation_counter;
54919 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54920
54921 static unsigned long nfs_read_attr_generation_counter(void)
54922 {
54923 - return atomic_long_read(&nfs_attr_generation_counter);
54924 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54925 }
54926
54927 unsigned long nfs_inc_attr_generation_counter(void)
54928 {
54929 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54930 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54931 }
54932
54933 void nfs_fattr_init(struct nfs_fattr *fattr)
54934 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54935 index 9d1c5db..1e13db8 100644
54936 --- a/fs/nfsd/nfs4proc.c
54937 +++ b/fs/nfsd/nfs4proc.c
54938 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
54939 nfsd4op_rsize op_rsize_bop;
54940 stateid_getter op_get_currentstateid;
54941 stateid_setter op_set_currentstateid;
54942 -};
54943 +} __do_const;
54944
54945 static struct nfsd4_operation nfsd4_ops[];
54946
54947 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54948 index d1dd710..32ac0e8 100644
54949 --- a/fs/nfsd/nfs4xdr.c
54950 +++ b/fs/nfsd/nfs4xdr.c
54951 @@ -1456,7 +1456,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54952
54953 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54954
54955 -static nfsd4_dec nfsd4_dec_ops[] = {
54956 +static const nfsd4_dec nfsd4_dec_ops[] = {
54957 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54958 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54959 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54960 @@ -1496,7 +1496,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54961 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54962 };
54963
54964 -static nfsd4_dec nfsd41_dec_ops[] = {
54965 +static const nfsd4_dec nfsd41_dec_ops[] = {
54966 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54967 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54968 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54969 @@ -1558,7 +1558,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54970 };
54971
54972 struct nfsd4_minorversion_ops {
54973 - nfsd4_dec *decoders;
54974 + const nfsd4_dec *decoders;
54975 int nops;
54976 };
54977
54978 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54979 index 69c6413..c0408d2 100644
54980 --- a/fs/nfsd/vfs.c
54981 +++ b/fs/nfsd/vfs.c
54982 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54983 } else {
54984 oldfs = get_fs();
54985 set_fs(KERNEL_DS);
54986 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54987 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54988 set_fs(oldfs);
54989 }
54990
54991 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54992
54993 /* Write the data. */
54994 oldfs = get_fs(); set_fs(KERNEL_DS);
54995 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54996 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54997 set_fs(oldfs);
54998 if (host_err < 0)
54999 goto out_nfserr;
55000 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
55001 */
55002
55003 oldfs = get_fs(); set_fs(KERNEL_DS);
55004 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
55005 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
55006 set_fs(oldfs);
55007
55008 if (host_err < 0)
55009 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
55010 index fea6bd5..8ee9d81 100644
55011 --- a/fs/nls/nls_base.c
55012 +++ b/fs/nls/nls_base.c
55013 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
55014
55015 int register_nls(struct nls_table * nls)
55016 {
55017 - struct nls_table ** tmp = &tables;
55018 + struct nls_table *tmp = tables;
55019
55020 if (nls->next)
55021 return -EBUSY;
55022
55023 spin_lock(&nls_lock);
55024 - while (*tmp) {
55025 - if (nls == *tmp) {
55026 + while (tmp) {
55027 + if (nls == tmp) {
55028 spin_unlock(&nls_lock);
55029 return -EBUSY;
55030 }
55031 - tmp = &(*tmp)->next;
55032 + tmp = tmp->next;
55033 }
55034 - nls->next = tables;
55035 + pax_open_kernel();
55036 + *(struct nls_table **)&nls->next = tables;
55037 + pax_close_kernel();
55038 tables = nls;
55039 spin_unlock(&nls_lock);
55040 return 0;
55041 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
55042
55043 int unregister_nls(struct nls_table * nls)
55044 {
55045 - struct nls_table ** tmp = &tables;
55046 + struct nls_table * const * tmp = &tables;
55047
55048 spin_lock(&nls_lock);
55049 while (*tmp) {
55050 if (nls == *tmp) {
55051 - *tmp = nls->next;
55052 + pax_open_kernel();
55053 + *(struct nls_table **)tmp = nls->next;
55054 + pax_close_kernel();
55055 spin_unlock(&nls_lock);
55056 return 0;
55057 }
55058 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
55059 index 7424929..35f6be5 100644
55060 --- a/fs/nls/nls_euc-jp.c
55061 +++ b/fs/nls/nls_euc-jp.c
55062 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
55063 p_nls = load_nls("cp932");
55064
55065 if (p_nls) {
55066 - table.charset2upper = p_nls->charset2upper;
55067 - table.charset2lower = p_nls->charset2lower;
55068 + pax_open_kernel();
55069 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
55070 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
55071 + pax_close_kernel();
55072 return register_nls(&table);
55073 }
55074
55075 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
55076 index e7bc1d7..06bd4bb 100644
55077 --- a/fs/nls/nls_koi8-ru.c
55078 +++ b/fs/nls/nls_koi8-ru.c
55079 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
55080 p_nls = load_nls("koi8-u");
55081
55082 if (p_nls) {
55083 - table.charset2upper = p_nls->charset2upper;
55084 - table.charset2lower = p_nls->charset2lower;
55085 + pax_open_kernel();
55086 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
55087 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
55088 + pax_close_kernel();
55089 return register_nls(&table);
55090 }
55091
55092 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
55093 index 9ff4a5e..deb1f0f 100644
55094 --- a/fs/notify/fanotify/fanotify_user.c
55095 +++ b/fs/notify/fanotify/fanotify_user.c
55096 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
55097
55098 fd = fanotify_event_metadata.fd;
55099 ret = -EFAULT;
55100 - if (copy_to_user(buf, &fanotify_event_metadata,
55101 - fanotify_event_metadata.event_len))
55102 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
55103 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
55104 goto out_close_fd;
55105
55106 ret = prepare_for_access_response(group, event, fd);
55107 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
55108 index 7b51b05..5ea5ef6 100644
55109 --- a/fs/notify/notification.c
55110 +++ b/fs/notify/notification.c
55111 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
55112 * get set to 0 so it will never get 'freed'
55113 */
55114 static struct fsnotify_event *q_overflow_event;
55115 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
55116 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
55117
55118 /**
55119 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
55120 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
55121 */
55122 u32 fsnotify_get_cookie(void)
55123 {
55124 - return atomic_inc_return(&fsnotify_sync_cookie);
55125 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
55126 }
55127 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
55128
55129 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
55130 index 99e3610..02c1068 100644
55131 --- a/fs/ntfs/dir.c
55132 +++ b/fs/ntfs/dir.c
55133 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
55134 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
55135 ~(s64)(ndir->itype.index.block_size - 1)));
55136 /* Bounds checks. */
55137 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
55138 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
55139 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
55140 "inode 0x%lx or driver bug.", vdir->i_ino);
55141 goto err_out;
55142 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
55143 index 5b2d4f0..c6de396 100644
55144 --- a/fs/ntfs/file.c
55145 +++ b/fs/ntfs/file.c
55146 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
55147 #endif /* NTFS_RW */
55148 };
55149
55150 -const struct file_operations ntfs_empty_file_ops = {};
55151 +const struct file_operations ntfs_empty_file_ops __read_only;
55152
55153 -const struct inode_operations ntfs_empty_inode_ops = {};
55154 +const struct inode_operations ntfs_empty_inode_ops __read_only;
55155 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
55156 index a9f78c7..ed8a381 100644
55157 --- a/fs/ocfs2/localalloc.c
55158 +++ b/fs/ocfs2/localalloc.c
55159 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
55160 goto bail;
55161 }
55162
55163 - atomic_inc(&osb->alloc_stats.moves);
55164 + atomic_inc_unchecked(&osb->alloc_stats.moves);
55165
55166 bail:
55167 if (handle)
55168 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
55169 index d355e6e..578d905 100644
55170 --- a/fs/ocfs2/ocfs2.h
55171 +++ b/fs/ocfs2/ocfs2.h
55172 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
55173
55174 struct ocfs2_alloc_stats
55175 {
55176 - atomic_t moves;
55177 - atomic_t local_data;
55178 - atomic_t bitmap_data;
55179 - atomic_t bg_allocs;
55180 - atomic_t bg_extends;
55181 + atomic_unchecked_t moves;
55182 + atomic_unchecked_t local_data;
55183 + atomic_unchecked_t bitmap_data;
55184 + atomic_unchecked_t bg_allocs;
55185 + atomic_unchecked_t bg_extends;
55186 };
55187
55188 enum ocfs2_local_alloc_state
55189 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
55190 index b7e74b5..19c6536 100644
55191 --- a/fs/ocfs2/suballoc.c
55192 +++ b/fs/ocfs2/suballoc.c
55193 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
55194 mlog_errno(status);
55195 goto bail;
55196 }
55197 - atomic_inc(&osb->alloc_stats.bg_extends);
55198 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
55199
55200 /* You should never ask for this much metadata */
55201 BUG_ON(bits_wanted >
55202 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
55203 mlog_errno(status);
55204 goto bail;
55205 }
55206 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
55207 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
55208
55209 *suballoc_loc = res.sr_bg_blkno;
55210 *suballoc_bit_start = res.sr_bit_offset;
55211 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
55212 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
55213 res->sr_bits);
55214
55215 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
55216 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
55217
55218 BUG_ON(res->sr_bits != 1);
55219
55220 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
55221 mlog_errno(status);
55222 goto bail;
55223 }
55224 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
55225 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
55226
55227 BUG_ON(res.sr_bits != 1);
55228
55229 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
55230 cluster_start,
55231 num_clusters);
55232 if (!status)
55233 - atomic_inc(&osb->alloc_stats.local_data);
55234 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
55235 } else {
55236 if (min_clusters > (osb->bitmap_cpg - 1)) {
55237 /* The only paths asking for contiguousness
55238 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
55239 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
55240 res.sr_bg_blkno,
55241 res.sr_bit_offset);
55242 - atomic_inc(&osb->alloc_stats.bitmap_data);
55243 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
55244 *num_clusters = res.sr_bits;
55245 }
55246 }
55247 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
55248 index 0e91ec2..f4b3fc6 100644
55249 --- a/fs/ocfs2/super.c
55250 +++ b/fs/ocfs2/super.c
55251 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
55252 "%10s => GlobalAllocs: %d LocalAllocs: %d "
55253 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
55254 "Stats",
55255 - atomic_read(&osb->alloc_stats.bitmap_data),
55256 - atomic_read(&osb->alloc_stats.local_data),
55257 - atomic_read(&osb->alloc_stats.bg_allocs),
55258 - atomic_read(&osb->alloc_stats.moves),
55259 - atomic_read(&osb->alloc_stats.bg_extends));
55260 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
55261 + atomic_read_unchecked(&osb->alloc_stats.local_data),
55262 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
55263 + atomic_read_unchecked(&osb->alloc_stats.moves),
55264 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
55265
55266 out += snprintf(buf + out, len - out,
55267 "%10s => State: %u Descriptor: %llu Size: %u bits "
55268 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
55269 spin_lock_init(&osb->osb_xattr_lock);
55270 ocfs2_init_steal_slots(osb);
55271
55272 - atomic_set(&osb->alloc_stats.moves, 0);
55273 - atomic_set(&osb->alloc_stats.local_data, 0);
55274 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
55275 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
55276 - atomic_set(&osb->alloc_stats.bg_extends, 0);
55277 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
55278 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
55279 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
55280 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
55281 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
55282
55283 /* Copy the blockcheck stats from the superblock probe */
55284 osb->osb_ecc_stats = *stats;
55285 diff --git a/fs/open.c b/fs/open.c
55286 index 9b33c0c..2ffcca2 100644
55287 --- a/fs/open.c
55288 +++ b/fs/open.c
55289 @@ -31,6 +31,8 @@
55290 #include <linux/ima.h>
55291 #include <linux/dnotify.h>
55292
55293 +#define CREATE_TRACE_POINTS
55294 +#include <trace/events/fs.h>
55295 #include "internal.h"
55296
55297 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
55298 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
55299 error = locks_verify_truncate(inode, NULL, length);
55300 if (!error)
55301 error = security_path_truncate(path);
55302 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
55303 + error = -EACCES;
55304 if (!error)
55305 error = do_truncate(path->dentry, length, 0, NULL);
55306
55307 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
55308 error = locks_verify_truncate(inode, f.file, length);
55309 if (!error)
55310 error = security_path_truncate(&f.file->f_path);
55311 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
55312 + error = -EACCES;
55313 if (!error)
55314 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
55315 sb_end_write(inode->i_sb);
55316 @@ -373,6 +379,9 @@ retry:
55317 if (__mnt_is_readonly(path.mnt))
55318 res = -EROFS;
55319
55320 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
55321 + res = -EACCES;
55322 +
55323 out_path_release:
55324 path_put(&path);
55325 if (retry_estale(res, lookup_flags)) {
55326 @@ -404,6 +413,8 @@ retry:
55327 if (error)
55328 goto dput_and_out;
55329
55330 + gr_log_chdir(path.dentry, path.mnt);
55331 +
55332 set_fs_pwd(current->fs, &path);
55333
55334 dput_and_out:
55335 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
55336 goto out_putf;
55337
55338 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
55339 +
55340 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
55341 + error = -EPERM;
55342 +
55343 + if (!error)
55344 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
55345 +
55346 if (!error)
55347 set_fs_pwd(current->fs, &f.file->f_path);
55348 out_putf:
55349 @@ -462,7 +480,13 @@ retry:
55350 if (error)
55351 goto dput_and_out;
55352
55353 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
55354 + goto dput_and_out;
55355 +
55356 set_fs_root(current->fs, &path);
55357 +
55358 + gr_handle_chroot_chdir(&path);
55359 +
55360 error = 0;
55361 dput_and_out:
55362 path_put(&path);
55363 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
55364 if (error)
55365 return error;
55366 mutex_lock(&inode->i_mutex);
55367 +
55368 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
55369 + error = -EACCES;
55370 + goto out_unlock;
55371 + }
55372 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
55373 + error = -EACCES;
55374 + goto out_unlock;
55375 + }
55376 +
55377 error = security_path_chmod(path, mode);
55378 if (error)
55379 goto out_unlock;
55380 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
55381 uid = make_kuid(current_user_ns(), user);
55382 gid = make_kgid(current_user_ns(), group);
55383
55384 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
55385 + return -EACCES;
55386 +
55387 newattrs.ia_valid = ATTR_CTIME;
55388 if (user != (uid_t) -1) {
55389 if (!uid_valid(uid))
55390 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
55391 } else {
55392 fsnotify_open(f);
55393 fd_install(fd, f);
55394 + trace_do_sys_open(tmp->name, flags, mode);
55395 }
55396 }
55397 putname(tmp);
55398 diff --git a/fs/pipe.c b/fs/pipe.c
55399 index 8e2e73f..1ef1048 100644
55400 --- a/fs/pipe.c
55401 +++ b/fs/pipe.c
55402 @@ -438,9 +438,9 @@ redo:
55403 }
55404 if (bufs) /* More to do? */
55405 continue;
55406 - if (!pipe->writers)
55407 + if (!atomic_read(&pipe->writers))
55408 break;
55409 - if (!pipe->waiting_writers) {
55410 + if (!atomic_read(&pipe->waiting_writers)) {
55411 /* syscall merging: Usually we must not sleep
55412 * if O_NONBLOCK is set, or if we got some data.
55413 * But if a writer sleeps in kernel space, then
55414 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
55415 mutex_lock(&inode->i_mutex);
55416 pipe = inode->i_pipe;
55417
55418 - if (!pipe->readers) {
55419 + if (!atomic_read(&pipe->readers)) {
55420 send_sig(SIGPIPE, current, 0);
55421 ret = -EPIPE;
55422 goto out;
55423 @@ -553,7 +553,7 @@ redo1:
55424 for (;;) {
55425 int bufs;
55426
55427 - if (!pipe->readers) {
55428 + if (!atomic_read(&pipe->readers)) {
55429 send_sig(SIGPIPE, current, 0);
55430 if (!ret)
55431 ret = -EPIPE;
55432 @@ -644,9 +644,9 @@ redo2:
55433 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55434 do_wakeup = 0;
55435 }
55436 - pipe->waiting_writers++;
55437 + atomic_inc(&pipe->waiting_writers);
55438 pipe_wait(pipe);
55439 - pipe->waiting_writers--;
55440 + atomic_dec(&pipe->waiting_writers);
55441 }
55442 out:
55443 mutex_unlock(&inode->i_mutex);
55444 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
55445 mask = 0;
55446 if (filp->f_mode & FMODE_READ) {
55447 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
55448 - if (!pipe->writers && filp->f_version != pipe->w_counter)
55449 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
55450 mask |= POLLHUP;
55451 }
55452
55453 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
55454 * Most Unices do not set POLLERR for FIFOs but on Linux they
55455 * behave exactly like pipes for poll().
55456 */
55457 - if (!pipe->readers)
55458 + if (!atomic_read(&pipe->readers))
55459 mask |= POLLERR;
55460 }
55461
55462 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
55463
55464 mutex_lock(&inode->i_mutex);
55465 pipe = inode->i_pipe;
55466 - pipe->readers -= decr;
55467 - pipe->writers -= decw;
55468 + atomic_sub(decr, &pipe->readers);
55469 + atomic_sub(decw, &pipe->writers);
55470
55471 - if (!pipe->readers && !pipe->writers) {
55472 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
55473 free_pipe_info(inode);
55474 } else {
55475 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
55476 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
55477
55478 if (inode->i_pipe) {
55479 ret = 0;
55480 - inode->i_pipe->readers++;
55481 + atomic_inc(&inode->i_pipe->readers);
55482 }
55483
55484 mutex_unlock(&inode->i_mutex);
55485 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
55486
55487 if (inode->i_pipe) {
55488 ret = 0;
55489 - inode->i_pipe->writers++;
55490 + atomic_inc(&inode->i_pipe->writers);
55491 }
55492
55493 mutex_unlock(&inode->i_mutex);
55494 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
55495 if (inode->i_pipe) {
55496 ret = 0;
55497 if (filp->f_mode & FMODE_READ)
55498 - inode->i_pipe->readers++;
55499 + atomic_inc(&inode->i_pipe->readers);
55500 if (filp->f_mode & FMODE_WRITE)
55501 - inode->i_pipe->writers++;
55502 + atomic_inc(&inode->i_pipe->writers);
55503 }
55504
55505 mutex_unlock(&inode->i_mutex);
55506 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
55507 inode->i_pipe = NULL;
55508 }
55509
55510 -static struct vfsmount *pipe_mnt __read_mostly;
55511 +struct vfsmount *pipe_mnt __read_mostly;
55512
55513 /*
55514 * pipefs_dname() is called from d_path().
55515 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
55516 goto fail_iput;
55517 inode->i_pipe = pipe;
55518
55519 - pipe->readers = pipe->writers = 1;
55520 + atomic_set(&pipe->readers, 1);
55521 + atomic_set(&pipe->writers, 1);
55522 inode->i_fop = &rdwr_pipefifo_fops;
55523
55524 /*
55525 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
55526 index 15af622..0e9f4467 100644
55527 --- a/fs/proc/Kconfig
55528 +++ b/fs/proc/Kconfig
55529 @@ -30,12 +30,12 @@ config PROC_FS
55530
55531 config PROC_KCORE
55532 bool "/proc/kcore support" if !ARM
55533 - depends on PROC_FS && MMU
55534 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
55535
55536 config PROC_VMCORE
55537 bool "/proc/vmcore support"
55538 - depends on PROC_FS && CRASH_DUMP
55539 - default y
55540 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
55541 + default n
55542 help
55543 Exports the dump image of crashed kernel in ELF format.
55544
55545 @@ -59,8 +59,8 @@ config PROC_SYSCTL
55546 limited in memory.
55547
55548 config PROC_PAGE_MONITOR
55549 - default y
55550 - depends on PROC_FS && MMU
55551 + default n
55552 + depends on PROC_FS && MMU && !GRKERNSEC
55553 bool "Enable /proc page monitoring" if EXPERT
55554 help
55555 Various /proc files exist to monitor process memory utilization:
55556 diff --git a/fs/proc/array.c b/fs/proc/array.c
55557 index be3c22f..0df1564 100644
55558 --- a/fs/proc/array.c
55559 +++ b/fs/proc/array.c
55560 @@ -60,6 +60,7 @@
55561 #include <linux/tty.h>
55562 #include <linux/string.h>
55563 #include <linux/mman.h>
55564 +#include <linux/grsecurity.h>
55565 #include <linux/proc_fs.h>
55566 #include <linux/ioport.h>
55567 #include <linux/uaccess.h>
55568 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
55569 seq_putc(m, '\n');
55570 }
55571
55572 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55573 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
55574 +{
55575 + if (p->mm)
55576 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
55577 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
55578 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
55579 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
55580 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
55581 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
55582 + else
55583 + seq_printf(m, "PaX:\t-----\n");
55584 +}
55585 +#endif
55586 +
55587 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55588 struct pid *pid, struct task_struct *task)
55589 {
55590 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55591 task_cpus_allowed(m, task);
55592 cpuset_task_status_allowed(m, task);
55593 task_context_switch_counts(m, task);
55594 +
55595 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55596 + task_pax(m, task);
55597 +#endif
55598 +
55599 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
55600 + task_grsec_rbac(m, task);
55601 +#endif
55602 +
55603 return 0;
55604 }
55605
55606 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55607 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55608 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55609 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55610 +#endif
55611 +
55612 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55613 struct pid *pid, struct task_struct *task, int whole)
55614 {
55615 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55616 char tcomm[sizeof(task->comm)];
55617 unsigned long flags;
55618
55619 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55620 + if (current->exec_id != m->exec_id) {
55621 + gr_log_badprocpid("stat");
55622 + return 0;
55623 + }
55624 +#endif
55625 +
55626 state = *get_task_state(task);
55627 vsize = eip = esp = 0;
55628 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55629 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55630 gtime = task->gtime;
55631 }
55632
55633 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55634 + if (PAX_RAND_FLAGS(mm)) {
55635 + eip = 0;
55636 + esp = 0;
55637 + wchan = 0;
55638 + }
55639 +#endif
55640 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55641 + wchan = 0;
55642 + eip =0;
55643 + esp =0;
55644 +#endif
55645 +
55646 /* scale priority and nice values from timeslices to -20..20 */
55647 /* to make it look like a "normal" Unix priority/nice value */
55648 priority = task_prio(task);
55649 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55650 seq_put_decimal_ull(m, ' ', vsize);
55651 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55652 seq_put_decimal_ull(m, ' ', rsslim);
55653 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55654 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55655 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55656 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55657 +#else
55658 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55659 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55660 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55661 +#endif
55662 seq_put_decimal_ull(m, ' ', esp);
55663 seq_put_decimal_ull(m, ' ', eip);
55664 /* The signal information here is obsolete.
55665 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55666 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55667 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55668
55669 - if (mm && permitted) {
55670 + if (mm && permitted
55671 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55672 + && !PAX_RAND_FLAGS(mm)
55673 +#endif
55674 + ) {
55675 seq_put_decimal_ull(m, ' ', mm->start_data);
55676 seq_put_decimal_ull(m, ' ', mm->end_data);
55677 seq_put_decimal_ull(m, ' ', mm->start_brk);
55678 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55679 struct pid *pid, struct task_struct *task)
55680 {
55681 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55682 - struct mm_struct *mm = get_task_mm(task);
55683 + struct mm_struct *mm;
55684
55685 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55686 + if (current->exec_id != m->exec_id) {
55687 + gr_log_badprocpid("statm");
55688 + return 0;
55689 + }
55690 +#endif
55691 + mm = get_task_mm(task);
55692 if (mm) {
55693 size = task_statm(mm, &shared, &text, &data, &resident);
55694 mmput(mm);
55695 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55696 return 0;
55697 }
55698
55699 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55700 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55701 +{
55702 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55703 +}
55704 +#endif
55705 +
55706 #ifdef CONFIG_CHECKPOINT_RESTORE
55707 static struct pid *
55708 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55709 diff --git a/fs/proc/base.c b/fs/proc/base.c
55710 index 9b43ff77..0fa9564 100644
55711 --- a/fs/proc/base.c
55712 +++ b/fs/proc/base.c
55713 @@ -111,6 +111,14 @@ struct pid_entry {
55714 union proc_op op;
55715 };
55716
55717 +struct getdents_callback {
55718 + struct linux_dirent __user * current_dir;
55719 + struct linux_dirent __user * previous;
55720 + struct file * file;
55721 + int count;
55722 + int error;
55723 +};
55724 +
55725 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55726 .name = (NAME), \
55727 .len = sizeof(NAME) - 1, \
55728 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55729 if (!mm->arg_end)
55730 goto out_mm; /* Shh! No looking before we're done */
55731
55732 + if (gr_acl_handle_procpidmem(task))
55733 + goto out_mm;
55734 +
55735 len = mm->arg_end - mm->arg_start;
55736
55737 if (len > PAGE_SIZE)
55738 @@ -235,12 +246,28 @@ out:
55739 return res;
55740 }
55741
55742 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55743 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55744 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55745 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55746 +#endif
55747 +
55748 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55749 {
55750 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55751 int res = PTR_ERR(mm);
55752 if (mm && !IS_ERR(mm)) {
55753 unsigned int nwords = 0;
55754 +
55755 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55756 + /* allow if we're currently ptracing this task */
55757 + if (PAX_RAND_FLAGS(mm) &&
55758 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55759 + mmput(mm);
55760 + return 0;
55761 + }
55762 +#endif
55763 +
55764 do {
55765 nwords += 2;
55766 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55767 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55768 }
55769
55770
55771 -#ifdef CONFIG_KALLSYMS
55772 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55773 /*
55774 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55775 * Returns the resolved symbol. If that fails, simply return the address.
55776 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
55777 mutex_unlock(&task->signal->cred_guard_mutex);
55778 }
55779
55780 -#ifdef CONFIG_STACKTRACE
55781 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55782
55783 #define MAX_STACK_TRACE_DEPTH 64
55784
55785 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55786 return count;
55787 }
55788
55789 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55790 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55791 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55792 {
55793 long nr;
55794 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55795 /************************************************************************/
55796
55797 /* permission checks */
55798 -static int proc_fd_access_allowed(struct inode *inode)
55799 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55800 {
55801 struct task_struct *task;
55802 int allowed = 0;
55803 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55804 */
55805 task = get_proc_task(inode);
55806 if (task) {
55807 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55808 + if (log)
55809 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55810 + else
55811 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55812 put_task_struct(task);
55813 }
55814 return allowed;
55815 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55816 struct task_struct *task,
55817 int hide_pid_min)
55818 {
55819 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55820 + return false;
55821 +
55822 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55823 + rcu_read_lock();
55824 + {
55825 + const struct cred *tmpcred = current_cred();
55826 + const struct cred *cred = __task_cred(task);
55827 +
55828 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55829 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55830 + || in_group_p(grsec_proc_gid)
55831 +#endif
55832 + ) {
55833 + rcu_read_unlock();
55834 + return true;
55835 + }
55836 + }
55837 + rcu_read_unlock();
55838 +
55839 + if (!pid->hide_pid)
55840 + return false;
55841 +#endif
55842 +
55843 if (pid->hide_pid < hide_pid_min)
55844 return true;
55845 if (in_group_p(pid->pid_gid))
55846 return true;
55847 +
55848 return ptrace_may_access(task, PTRACE_MODE_READ);
55849 }
55850
55851 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55852 put_task_struct(task);
55853
55854 if (!has_perms) {
55855 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55856 + {
55857 +#else
55858 if (pid->hide_pid == 2) {
55859 +#endif
55860 /*
55861 * Let's make getdents(), stat(), and open()
55862 * consistent with each other. If a process
55863 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55864 if (!task)
55865 return -ESRCH;
55866
55867 + if (gr_acl_handle_procpidmem(task)) {
55868 + put_task_struct(task);
55869 + return -EPERM;
55870 + }
55871 +
55872 mm = mm_access(task, mode);
55873 put_task_struct(task);
55874
55875 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55876
55877 file->private_data = mm;
55878
55879 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55880 + file->f_version = current->exec_id;
55881 +#endif
55882 +
55883 return 0;
55884 }
55885
55886 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55887 ssize_t copied;
55888 char *page;
55889
55890 +#ifdef CONFIG_GRKERNSEC
55891 + if (write)
55892 + return -EPERM;
55893 +#endif
55894 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55895 + if (file->f_version != current->exec_id) {
55896 + gr_log_badprocpid("mem");
55897 + return 0;
55898 + }
55899 +#endif
55900 +
55901 if (!mm)
55902 return 0;
55903
55904 @@ -722,7 +801,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55905 goto free;
55906
55907 while (count > 0) {
55908 - int this_len = min_t(int, count, PAGE_SIZE);
55909 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55910
55911 if (write && copy_from_user(page, buf, this_len)) {
55912 copied = -EFAULT;
55913 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55914 if (!mm)
55915 return 0;
55916
55917 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55918 + if (file->f_version != current->exec_id) {
55919 + gr_log_badprocpid("environ");
55920 + return 0;
55921 + }
55922 +#endif
55923 +
55924 page = (char *)__get_free_page(GFP_TEMPORARY);
55925 if (!page)
55926 return -ENOMEM;
55927 @@ -823,7 +909,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55928 goto free;
55929 while (count > 0) {
55930 size_t this_len, max_len;
55931 - int retval;
55932 + ssize_t retval;
55933
55934 if (src >= (mm->env_end - mm->env_start))
55935 break;
55936 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55937 int error = -EACCES;
55938
55939 /* Are we allowed to snoop on the tasks file descriptors? */
55940 - if (!proc_fd_access_allowed(inode))
55941 + if (!proc_fd_access_allowed(inode, 0))
55942 goto out;
55943
55944 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55945 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55946 struct path path;
55947
55948 /* Are we allowed to snoop on the tasks file descriptors? */
55949 - if (!proc_fd_access_allowed(inode))
55950 - goto out;
55951 + /* logging this is needed for learning on chromium to work properly,
55952 + but we don't want to flood the logs from 'ps' which does a readlink
55953 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55954 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55955 + */
55956 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55957 + if (!proc_fd_access_allowed(inode,0))
55958 + goto out;
55959 + } else {
55960 + if (!proc_fd_access_allowed(inode,1))
55961 + goto out;
55962 + }
55963
55964 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55965 if (error)
55966 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55967 rcu_read_lock();
55968 cred = __task_cred(task);
55969 inode->i_uid = cred->euid;
55970 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55971 + inode->i_gid = grsec_proc_gid;
55972 +#else
55973 inode->i_gid = cred->egid;
55974 +#endif
55975 rcu_read_unlock();
55976 }
55977 security_task_to_inode(task, inode);
55978 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55979 return -ENOENT;
55980 }
55981 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55982 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55983 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55984 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55985 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55986 +#endif
55987 task_dumpable(task)) {
55988 cred = __task_cred(task);
55989 stat->uid = cred->euid;
55990 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55991 + stat->gid = grsec_proc_gid;
55992 +#else
55993 stat->gid = cred->egid;
55994 +#endif
55995 }
55996 }
55997 rcu_read_unlock();
55998 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55999
56000 if (task) {
56001 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
56002 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56003 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
56004 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56005 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
56006 +#endif
56007 task_dumpable(task)) {
56008 rcu_read_lock();
56009 cred = __task_cred(task);
56010 inode->i_uid = cred->euid;
56011 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
56012 + inode->i_gid = grsec_proc_gid;
56013 +#else
56014 inode->i_gid = cred->egid;
56015 +#endif
56016 rcu_read_unlock();
56017 } else {
56018 inode->i_uid = GLOBAL_ROOT_UID;
56019 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
56020 if (!task)
56021 goto out_no_task;
56022
56023 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
56024 + goto out;
56025 +
56026 /*
56027 * Yes, it does not scale. And it should not. Don't add
56028 * new entries into /proc/<tgid>/ without very good reasons.
56029 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
56030 if (!task)
56031 goto out_no_task;
56032
56033 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
56034 + goto out;
56035 +
56036 ret = 0;
56037 i = filp->f_pos;
56038 switch (i) {
56039 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
56040 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
56041 #endif
56042 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
56043 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
56044 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
56045 INF("syscall", S_IRUGO, proc_pid_syscall),
56046 #endif
56047 INF("cmdline", S_IRUGO, proc_pid_cmdline),
56048 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
56049 #ifdef CONFIG_SECURITY
56050 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
56051 #endif
56052 -#ifdef CONFIG_KALLSYMS
56053 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
56054 INF("wchan", S_IRUGO, proc_pid_wchan),
56055 #endif
56056 -#ifdef CONFIG_STACKTRACE
56057 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
56058 ONE("stack", S_IRUGO, proc_pid_stack),
56059 #endif
56060 #ifdef CONFIG_SCHEDSTATS
56061 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
56062 #ifdef CONFIG_HARDWALL
56063 INF("hardwall", S_IRUGO, proc_pid_hardwall),
56064 #endif
56065 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
56066 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
56067 +#endif
56068 #ifdef CONFIG_USER_NS
56069 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
56070 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
56071 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
56072 if (!inode)
56073 goto out;
56074
56075 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56076 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
56077 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56078 + inode->i_gid = grsec_proc_gid;
56079 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
56080 +#else
56081 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
56082 +#endif
56083 inode->i_op = &proc_tgid_base_inode_operations;
56084 inode->i_fop = &proc_tgid_base_operations;
56085 inode->i_flags|=S_IMMUTABLE;
56086 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
56087 if (!task)
56088 goto out;
56089
56090 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
56091 + goto out_put_task;
56092 +
56093 result = proc_pid_instantiate(dir, dentry, task, NULL);
56094 +out_put_task:
56095 put_task_struct(task);
56096 out:
56097 return result;
56098 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
56099 static int fake_filldir(void *buf, const char *name, int namelen,
56100 loff_t offset, u64 ino, unsigned d_type)
56101 {
56102 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
56103 + __buf->error = -EINVAL;
56104 return 0;
56105 }
56106
56107 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
56108 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
56109 #endif
56110 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
56111 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
56112 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
56113 INF("syscall", S_IRUGO, proc_pid_syscall),
56114 #endif
56115 INF("cmdline", S_IRUGO, proc_pid_cmdline),
56116 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
56117 #ifdef CONFIG_SECURITY
56118 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
56119 #endif
56120 -#ifdef CONFIG_KALLSYMS
56121 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
56122 INF("wchan", S_IRUGO, proc_pid_wchan),
56123 #endif
56124 -#ifdef CONFIG_STACKTRACE
56125 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
56126 ONE("stack", S_IRUGO, proc_pid_stack),
56127 #endif
56128 #ifdef CONFIG_SCHEDSTATS
56129 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
56130 index 82676e3..5f8518a 100644
56131 --- a/fs/proc/cmdline.c
56132 +++ b/fs/proc/cmdline.c
56133 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
56134
56135 static int __init proc_cmdline_init(void)
56136 {
56137 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56138 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
56139 +#else
56140 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
56141 +#endif
56142 return 0;
56143 }
56144 module_init(proc_cmdline_init);
56145 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
56146 index b143471..bb105e5 100644
56147 --- a/fs/proc/devices.c
56148 +++ b/fs/proc/devices.c
56149 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
56150
56151 static int __init proc_devices_init(void)
56152 {
56153 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56154 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
56155 +#else
56156 proc_create("devices", 0, NULL, &proc_devinfo_operations);
56157 +#endif
56158 return 0;
56159 }
56160 module_init(proc_devices_init);
56161 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
56162 index d7a4a28..0201742 100644
56163 --- a/fs/proc/fd.c
56164 +++ b/fs/proc/fd.c
56165 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
56166 if (!task)
56167 return -ENOENT;
56168
56169 - files = get_files_struct(task);
56170 + if (!gr_acl_handle_procpidmem(task))
56171 + files = get_files_struct(task);
56172 put_task_struct(task);
56173
56174 if (files) {
56175 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
56176 */
56177 int proc_fd_permission(struct inode *inode, int mask)
56178 {
56179 + struct task_struct *task;
56180 int rv = generic_permission(inode, mask);
56181 - if (rv == 0)
56182 - return 0;
56183 +
56184 if (task_pid(current) == proc_pid(inode))
56185 rv = 0;
56186 +
56187 + task = get_proc_task(inode);
56188 + if (task == NULL)
56189 + return rv;
56190 +
56191 + if (gr_acl_handle_procpidmem(task))
56192 + rv = -EACCES;
56193 +
56194 + put_task_struct(task);
56195 +
56196 return rv;
56197 }
56198
56199 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
56200 index 0ac1e1b..0497e58 100644
56201 --- a/fs/proc/inode.c
56202 +++ b/fs/proc/inode.c
56203 @@ -21,11 +21,17 @@
56204 #include <linux/seq_file.h>
56205 #include <linux/slab.h>
56206 #include <linux/mount.h>
56207 +#include <linux/grsecurity.h>
56208
56209 #include <asm/uaccess.h>
56210
56211 #include "internal.h"
56212
56213 +#ifdef CONFIG_PROC_SYSCTL
56214 +extern const struct inode_operations proc_sys_inode_operations;
56215 +extern const struct inode_operations proc_sys_dir_operations;
56216 +#endif
56217 +
56218 static void proc_evict_inode(struct inode *inode)
56219 {
56220 struct proc_dir_entry *de;
56221 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
56222 ns = PROC_I(inode)->ns;
56223 if (ns_ops && ns)
56224 ns_ops->put(ns);
56225 +
56226 +#ifdef CONFIG_PROC_SYSCTL
56227 + if (inode->i_op == &proc_sys_inode_operations ||
56228 + inode->i_op == &proc_sys_dir_operations)
56229 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
56230 +#endif
56231 +
56232 }
56233
56234 static struct kmem_cache * proc_inode_cachep;
56235 @@ -455,7 +468,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
56236 if (de->mode) {
56237 inode->i_mode = de->mode;
56238 inode->i_uid = de->uid;
56239 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
56240 + inode->i_gid = grsec_proc_gid;
56241 +#else
56242 inode->i_gid = de->gid;
56243 +#endif
56244 }
56245 if (de->size)
56246 inode->i_size = de->size;
56247 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
56248 index 252544c..04395b9 100644
56249 --- a/fs/proc/internal.h
56250 +++ b/fs/proc/internal.h
56251 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
56252 struct pid *pid, struct task_struct *task);
56253 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
56254 struct pid *pid, struct task_struct *task);
56255 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
56256 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
56257 +#endif
56258 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
56259
56260 extern const struct file_operations proc_tid_children_operations;
56261 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
56262 index e96d4f1..8b116ed 100644
56263 --- a/fs/proc/kcore.c
56264 +++ b/fs/proc/kcore.c
56265 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
56266 * the addresses in the elf_phdr on our list.
56267 */
56268 start = kc_offset_to_vaddr(*fpos - elf_buflen);
56269 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
56270 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
56271 + if (tsz > buflen)
56272 tsz = buflen;
56273 -
56274 +
56275 while (buflen) {
56276 struct kcore_list *m;
56277
56278 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
56279 kfree(elf_buf);
56280 } else {
56281 if (kern_addr_valid(start)) {
56282 - unsigned long n;
56283 + char *elf_buf;
56284 + mm_segment_t oldfs;
56285
56286 - n = copy_to_user(buffer, (char *)start, tsz);
56287 - /*
56288 - * We cannot distinguish between fault on source
56289 - * and fault on destination. When this happens
56290 - * we clear too and hope it will trigger the
56291 - * EFAULT again.
56292 - */
56293 - if (n) {
56294 - if (clear_user(buffer + tsz - n,
56295 - n))
56296 + elf_buf = kmalloc(tsz, GFP_KERNEL);
56297 + if (!elf_buf)
56298 + return -ENOMEM;
56299 + oldfs = get_fs();
56300 + set_fs(KERNEL_DS);
56301 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
56302 + set_fs(oldfs);
56303 + if (copy_to_user(buffer, elf_buf, tsz)) {
56304 + kfree(elf_buf);
56305 return -EFAULT;
56306 + }
56307 }
56308 + set_fs(oldfs);
56309 + kfree(elf_buf);
56310 } else {
56311 if (clear_user(buffer, tsz))
56312 return -EFAULT;
56313 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
56314
56315 static int open_kcore(struct inode *inode, struct file *filp)
56316 {
56317 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
56318 + return -EPERM;
56319 +#endif
56320 if (!capable(CAP_SYS_RAWIO))
56321 return -EPERM;
56322 if (kcore_need_update)
56323 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
56324 index 80e4645..53e5fcf 100644
56325 --- a/fs/proc/meminfo.c
56326 +++ b/fs/proc/meminfo.c
56327 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
56328 vmi.used >> 10,
56329 vmi.largest_chunk >> 10
56330 #ifdef CONFIG_MEMORY_FAILURE
56331 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
56332 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
56333 #endif
56334 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
56335 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
56336 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
56337 index b1822dd..df622cb 100644
56338 --- a/fs/proc/nommu.c
56339 +++ b/fs/proc/nommu.c
56340 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
56341 if (len < 1)
56342 len = 1;
56343 seq_printf(m, "%*c", len, ' ');
56344 - seq_path(m, &file->f_path, "");
56345 + seq_path(m, &file->f_path, "\n\\");
56346 }
56347
56348 seq_putc(m, '\n');
56349 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
56350 index fe72cd0..21b52ff 100644
56351 --- a/fs/proc/proc_net.c
56352 +++ b/fs/proc/proc_net.c
56353 @@ -23,6 +23,7 @@
56354 #include <linux/nsproxy.h>
56355 #include <net/net_namespace.h>
56356 #include <linux/seq_file.h>
56357 +#include <linux/grsecurity.h>
56358
56359 #include "internal.h"
56360
56361 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
56362 struct task_struct *task;
56363 struct nsproxy *ns;
56364 struct net *net = NULL;
56365 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56366 + const struct cred *cred = current_cred();
56367 +#endif
56368 +
56369 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56370 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
56371 + return net;
56372 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56373 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
56374 + return net;
56375 +#endif
56376
56377 rcu_read_lock();
56378 task = pid_task(proc_pid(dir), PIDTYPE_PID);
56379 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
56380 index 1827d88..43b0279 100644
56381 --- a/fs/proc/proc_sysctl.c
56382 +++ b/fs/proc/proc_sysctl.c
56383 @@ -12,11 +12,15 @@
56384 #include <linux/module.h>
56385 #include "internal.h"
56386
56387 +extern int gr_handle_chroot_sysctl(const int op);
56388 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
56389 + const int op);
56390 +
56391 static const struct dentry_operations proc_sys_dentry_operations;
56392 static const struct file_operations proc_sys_file_operations;
56393 -static const struct inode_operations proc_sys_inode_operations;
56394 +const struct inode_operations proc_sys_inode_operations;
56395 static const struct file_operations proc_sys_dir_file_operations;
56396 -static const struct inode_operations proc_sys_dir_operations;
56397 +const struct inode_operations proc_sys_dir_operations;
56398
56399 void proc_sys_poll_notify(struct ctl_table_poll *poll)
56400 {
56401 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
56402
56403 err = NULL;
56404 d_set_d_op(dentry, &proc_sys_dentry_operations);
56405 +
56406 + gr_handle_proc_create(dentry, inode);
56407 +
56408 d_add(dentry, inode);
56409
56410 out:
56411 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
56412 struct inode *inode = filp->f_path.dentry->d_inode;
56413 struct ctl_table_header *head = grab_header(inode);
56414 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
56415 + int op = write ? MAY_WRITE : MAY_READ;
56416 ssize_t error;
56417 size_t res;
56418
56419 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
56420 * and won't be until we finish.
56421 */
56422 error = -EPERM;
56423 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
56424 + if (sysctl_perm(head, table, op))
56425 goto out;
56426
56427 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
56428 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
56429 if (!table->proc_handler)
56430 goto out;
56431
56432 +#ifdef CONFIG_GRKERNSEC
56433 + error = -EPERM;
56434 + if (gr_handle_chroot_sysctl(op))
56435 + goto out;
56436 + dget(filp->f_path.dentry);
56437 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
56438 + dput(filp->f_path.dentry);
56439 + goto out;
56440 + }
56441 + dput(filp->f_path.dentry);
56442 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
56443 + goto out;
56444 + if (write && !capable(CAP_SYS_ADMIN))
56445 + goto out;
56446 +#endif
56447 +
56448 /* careful: calling conventions are nasty here */
56449 res = count;
56450 error = table->proc_handler(table, write, buf, &res, ppos);
56451 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
56452 return -ENOMEM;
56453 } else {
56454 d_set_d_op(child, &proc_sys_dentry_operations);
56455 +
56456 + gr_handle_proc_create(child, inode);
56457 +
56458 d_add(child, inode);
56459 }
56460 } else {
56461 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
56462 if ((*pos)++ < file->f_pos)
56463 return 0;
56464
56465 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
56466 + return 0;
56467 +
56468 if (unlikely(S_ISLNK(table->mode)))
56469 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
56470 else
56471 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
56472 if (IS_ERR(head))
56473 return PTR_ERR(head);
56474
56475 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
56476 + return -ENOENT;
56477 +
56478 generic_fillattr(inode, stat);
56479 if (table)
56480 stat->mode = (stat->mode & S_IFMT) | table->mode;
56481 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
56482 .llseek = generic_file_llseek,
56483 };
56484
56485 -static const struct inode_operations proc_sys_inode_operations = {
56486 +const struct inode_operations proc_sys_inode_operations = {
56487 .permission = proc_sys_permission,
56488 .setattr = proc_sys_setattr,
56489 .getattr = proc_sys_getattr,
56490 };
56491
56492 -static const struct inode_operations proc_sys_dir_operations = {
56493 +const struct inode_operations proc_sys_dir_operations = {
56494 .lookup = proc_sys_lookup,
56495 .permission = proc_sys_permission,
56496 .setattr = proc_sys_setattr,
56497 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
56498 static struct ctl_dir *new_dir(struct ctl_table_set *set,
56499 const char *name, int namelen)
56500 {
56501 - struct ctl_table *table;
56502 + ctl_table_no_const *table;
56503 struct ctl_dir *new;
56504 struct ctl_node *node;
56505 char *new_name;
56506 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
56507 return NULL;
56508
56509 node = (struct ctl_node *)(new + 1);
56510 - table = (struct ctl_table *)(node + 1);
56511 + table = (ctl_table_no_const *)(node + 1);
56512 new_name = (char *)(table + 2);
56513 memcpy(new_name, name, namelen);
56514 new_name[namelen] = '\0';
56515 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
56516 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
56517 struct ctl_table_root *link_root)
56518 {
56519 - struct ctl_table *link_table, *entry, *link;
56520 + ctl_table_no_const *link_table, *link;
56521 + struct ctl_table *entry;
56522 struct ctl_table_header *links;
56523 struct ctl_node *node;
56524 char *link_name;
56525 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
56526 return NULL;
56527
56528 node = (struct ctl_node *)(links + 1);
56529 - link_table = (struct ctl_table *)(node + nr_entries);
56530 + link_table = (ctl_table_no_const *)(node + nr_entries);
56531 link_name = (char *)&link_table[nr_entries + 1];
56532
56533 for (link = link_table, entry = table; entry->procname; link++, entry++) {
56534 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56535 struct ctl_table_header ***subheader, struct ctl_table_set *set,
56536 struct ctl_table *table)
56537 {
56538 - struct ctl_table *ctl_table_arg = NULL;
56539 - struct ctl_table *entry, *files;
56540 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
56541 + struct ctl_table *entry;
56542 int nr_files = 0;
56543 int nr_dirs = 0;
56544 int err = -ENOMEM;
56545 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56546 nr_files++;
56547 }
56548
56549 - files = table;
56550 /* If there are mixed files and directories we need a new table */
56551 if (nr_dirs && nr_files) {
56552 - struct ctl_table *new;
56553 + ctl_table_no_const *new;
56554 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
56555 GFP_KERNEL);
56556 if (!files)
56557 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56558 /* Register everything except a directory full of subdirectories */
56559 if (nr_files || !nr_dirs) {
56560 struct ctl_table_header *header;
56561 - header = __register_sysctl_table(set, path, files);
56562 + header = __register_sysctl_table(set, path, files ? files : table);
56563 if (!header) {
56564 kfree(ctl_table_arg);
56565 goto out;
56566 diff --git a/fs/proc/root.c b/fs/proc/root.c
56567 index 9c7fab1..ed1c8e0 100644
56568 --- a/fs/proc/root.c
56569 +++ b/fs/proc/root.c
56570 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
56571 #ifdef CONFIG_PROC_DEVICETREE
56572 proc_device_tree_init();
56573 #endif
56574 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56575 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56576 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
56577 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56578 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
56579 +#endif
56580 +#else
56581 proc_mkdir("bus", NULL);
56582 +#endif
56583 proc_sys_init();
56584 }
56585
56586 diff --git a/fs/proc/self.c b/fs/proc/self.c
56587 index aa5cc3b..c91a5d0 100644
56588 --- a/fs/proc/self.c
56589 +++ b/fs/proc/self.c
56590 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
56591 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
56592 void *cookie)
56593 {
56594 - char *s = nd_get_link(nd);
56595 + const char *s = nd_get_link(nd);
56596 if (!IS_ERR(s))
56597 kfree(s);
56598 }
56599 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
56600 index ca5ce7f..02c1cf0 100644
56601 --- a/fs/proc/task_mmu.c
56602 +++ b/fs/proc/task_mmu.c
56603 @@ -11,12 +11,19 @@
56604 #include <linux/rmap.h>
56605 #include <linux/swap.h>
56606 #include <linux/swapops.h>
56607 +#include <linux/grsecurity.h>
56608
56609 #include <asm/elf.h>
56610 #include <asm/uaccess.h>
56611 #include <asm/tlbflush.h>
56612 #include "internal.h"
56613
56614 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56615 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
56616 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
56617 + _mm->pax_flags & MF_PAX_SEGMEXEC))
56618 +#endif
56619 +
56620 void task_mem(struct seq_file *m, struct mm_struct *mm)
56621 {
56622 unsigned long data, text, lib, swap;
56623 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56624 "VmExe:\t%8lu kB\n"
56625 "VmLib:\t%8lu kB\n"
56626 "VmPTE:\t%8lu kB\n"
56627 - "VmSwap:\t%8lu kB\n",
56628 - hiwater_vm << (PAGE_SHIFT-10),
56629 + "VmSwap:\t%8lu kB\n"
56630 +
56631 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56632 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56633 +#endif
56634 +
56635 + ,hiwater_vm << (PAGE_SHIFT-10),
56636 total_vm << (PAGE_SHIFT-10),
56637 mm->locked_vm << (PAGE_SHIFT-10),
56638 mm->pinned_vm << (PAGE_SHIFT-10),
56639 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56640 data << (PAGE_SHIFT-10),
56641 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56642 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56643 - swap << (PAGE_SHIFT-10));
56644 + swap << (PAGE_SHIFT-10)
56645 +
56646 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56647 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56648 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56649 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56650 +#else
56651 + , mm->context.user_cs_base
56652 + , mm->context.user_cs_limit
56653 +#endif
56654 +#endif
56655 +
56656 + );
56657 }
56658
56659 unsigned long task_vsize(struct mm_struct *mm)
56660 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56661 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56662 }
56663
56664 - /* We don't show the stack guard page in /proc/maps */
56665 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56666 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56667 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56668 +#else
56669 start = vma->vm_start;
56670 - if (stack_guard_page_start(vma, start))
56671 - start += PAGE_SIZE;
56672 end = vma->vm_end;
56673 - if (stack_guard_page_end(vma, end))
56674 - end -= PAGE_SIZE;
56675 +#endif
56676
56677 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56678 start,
56679 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56680 flags & VM_WRITE ? 'w' : '-',
56681 flags & VM_EXEC ? 'x' : '-',
56682 flags & VM_MAYSHARE ? 's' : 'p',
56683 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56684 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56685 +#else
56686 pgoff,
56687 +#endif
56688 MAJOR(dev), MINOR(dev), ino, &len);
56689
56690 /*
56691 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56692 */
56693 if (file) {
56694 pad_len_spaces(m, len);
56695 - seq_path(m, &file->f_path, "\n");
56696 + seq_path(m, &file->f_path, "\n\\");
56697 goto done;
56698 }
56699
56700 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56701 * Thread stack in /proc/PID/task/TID/maps or
56702 * the main process stack.
56703 */
56704 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56705 - vma->vm_end >= mm->start_stack)) {
56706 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56707 + (vma->vm_start <= mm->start_stack &&
56708 + vma->vm_end >= mm->start_stack)) {
56709 name = "[stack]";
56710 } else {
56711 /* Thread stack in /proc/PID/maps */
56712 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56713 struct proc_maps_private *priv = m->private;
56714 struct task_struct *task = priv->task;
56715
56716 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56717 + if (current->exec_id != m->exec_id) {
56718 + gr_log_badprocpid("maps");
56719 + return 0;
56720 + }
56721 +#endif
56722 +
56723 show_map_vma(m, vma, is_pid);
56724
56725 if (m->count < m->size) /* vma is copied successfully */
56726 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56727 .private = &mss,
56728 };
56729
56730 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56731 + if (current->exec_id != m->exec_id) {
56732 + gr_log_badprocpid("smaps");
56733 + return 0;
56734 + }
56735 +#endif
56736 memset(&mss, 0, sizeof mss);
56737 - mss.vma = vma;
56738 - /* mmap_sem is held in m_start */
56739 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56740 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56741 -
56742 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56743 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56744 +#endif
56745 + mss.vma = vma;
56746 + /* mmap_sem is held in m_start */
56747 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56748 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56749 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56750 + }
56751 +#endif
56752 show_map_vma(m, vma, is_pid);
56753
56754 seq_printf(m,
56755 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56756 "KernelPageSize: %8lu kB\n"
56757 "MMUPageSize: %8lu kB\n"
56758 "Locked: %8lu kB\n",
56759 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56760 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56761 +#else
56762 (vma->vm_end - vma->vm_start) >> 10,
56763 +#endif
56764 mss.resident >> 10,
56765 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56766 mss.shared_clean >> 10,
56767 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56768 int n;
56769 char buffer[50];
56770
56771 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56772 + if (current->exec_id != m->exec_id) {
56773 + gr_log_badprocpid("numa_maps");
56774 + return 0;
56775 + }
56776 +#endif
56777 +
56778 if (!mm)
56779 return 0;
56780
56781 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56782 mpol_to_str(buffer, sizeof(buffer), pol);
56783 mpol_cond_put(pol);
56784
56785 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56786 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56787 +#else
56788 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56789 +#endif
56790
56791 if (file) {
56792 seq_printf(m, " file=");
56793 - seq_path(m, &file->f_path, "\n\t= ");
56794 + seq_path(m, &file->f_path, "\n\t\\= ");
56795 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56796 seq_printf(m, " heap");
56797 } else {
56798 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56799 index 1ccfa53..0848f95 100644
56800 --- a/fs/proc/task_nommu.c
56801 +++ b/fs/proc/task_nommu.c
56802 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56803 else
56804 bytes += kobjsize(mm);
56805
56806 - if (current->fs && current->fs->users > 1)
56807 + if (current->fs && atomic_read(&current->fs->users) > 1)
56808 sbytes += kobjsize(current->fs);
56809 else
56810 bytes += kobjsize(current->fs);
56811 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56812
56813 if (file) {
56814 pad_len_spaces(m, len);
56815 - seq_path(m, &file->f_path, "");
56816 + seq_path(m, &file->f_path, "\n\\");
56817 } else if (mm) {
56818 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56819
56820 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56821 index b00fcc9..e0c6381 100644
56822 --- a/fs/qnx6/qnx6.h
56823 +++ b/fs/qnx6/qnx6.h
56824 @@ -74,7 +74,7 @@ enum {
56825 BYTESEX_BE,
56826 };
56827
56828 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56829 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56830 {
56831 if (sbi->s_bytesex == BYTESEX_LE)
56832 return le64_to_cpu((__force __le64)n);
56833 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56834 return (__force __fs64)cpu_to_be64(n);
56835 }
56836
56837 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56838 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56839 {
56840 if (sbi->s_bytesex == BYTESEX_LE)
56841 return le32_to_cpu((__force __le32)n);
56842 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56843 index 16e8abb..2dcf914 100644
56844 --- a/fs/quota/netlink.c
56845 +++ b/fs/quota/netlink.c
56846 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56847 void quota_send_warning(struct kqid qid, dev_t dev,
56848 const char warntype)
56849 {
56850 - static atomic_t seq;
56851 + static atomic_unchecked_t seq;
56852 struct sk_buff *skb;
56853 void *msg_head;
56854 int ret;
56855 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56856 "VFS: Not enough memory to send quota warning.\n");
56857 return;
56858 }
56859 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56860 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56861 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56862 if (!msg_head) {
56863 printk(KERN_ERR
56864 diff --git a/fs/readdir.c b/fs/readdir.c
56865 index 5e69ef5..e5d9099 100644
56866 --- a/fs/readdir.c
56867 +++ b/fs/readdir.c
56868 @@ -17,6 +17,7 @@
56869 #include <linux/security.h>
56870 #include <linux/syscalls.h>
56871 #include <linux/unistd.h>
56872 +#include <linux/namei.h>
56873
56874 #include <asm/uaccess.h>
56875
56876 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56877
56878 struct readdir_callback {
56879 struct old_linux_dirent __user * dirent;
56880 + struct file * file;
56881 int result;
56882 };
56883
56884 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56885 buf->result = -EOVERFLOW;
56886 return -EOVERFLOW;
56887 }
56888 +
56889 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56890 + return 0;
56891 +
56892 buf->result++;
56893 dirent = buf->dirent;
56894 if (!access_ok(VERIFY_WRITE, dirent,
56895 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56896
56897 buf.result = 0;
56898 buf.dirent = dirent;
56899 + buf.file = f.file;
56900
56901 error = vfs_readdir(f.file, fillonedir, &buf);
56902 if (buf.result)
56903 @@ -139,6 +146,7 @@ struct linux_dirent {
56904 struct getdents_callback {
56905 struct linux_dirent __user * current_dir;
56906 struct linux_dirent __user * previous;
56907 + struct file * file;
56908 int count;
56909 int error;
56910 };
56911 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56912 buf->error = -EOVERFLOW;
56913 return -EOVERFLOW;
56914 }
56915 +
56916 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56917 + return 0;
56918 +
56919 dirent = buf->previous;
56920 if (dirent) {
56921 if (__put_user(offset, &dirent->d_off))
56922 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56923 buf.previous = NULL;
56924 buf.count = count;
56925 buf.error = 0;
56926 + buf.file = f.file;
56927
56928 error = vfs_readdir(f.file, filldir, &buf);
56929 if (error >= 0)
56930 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56931 struct getdents_callback64 {
56932 struct linux_dirent64 __user * current_dir;
56933 struct linux_dirent64 __user * previous;
56934 + struct file *file;
56935 int count;
56936 int error;
56937 };
56938 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56939 buf->error = -EINVAL; /* only used if we fail.. */
56940 if (reclen > buf->count)
56941 return -EINVAL;
56942 +
56943 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56944 + return 0;
56945 +
56946 dirent = buf->previous;
56947 if (dirent) {
56948 if (__put_user(offset, &dirent->d_off))
56949 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56950
56951 buf.current_dir = dirent;
56952 buf.previous = NULL;
56953 + buf.file = f.file;
56954 buf.count = count;
56955 buf.error = 0;
56956
56957 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56958 error = buf.error;
56959 lastdirent = buf.previous;
56960 if (lastdirent) {
56961 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56962 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56963 if (__put_user(d_off, &lastdirent->d_off))
56964 error = -EFAULT;
56965 else
56966 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56967 index 2b7882b..1c5ef48 100644
56968 --- a/fs/reiserfs/do_balan.c
56969 +++ b/fs/reiserfs/do_balan.c
56970 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56971 return;
56972 }
56973
56974 - atomic_inc(&(fs_generation(tb->tb_sb)));
56975 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56976 do_balance_starts(tb);
56977
56978 /* balance leaf returns 0 except if combining L R and S into
56979 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56980 index e60e870..f40ac16 100644
56981 --- a/fs/reiserfs/procfs.c
56982 +++ b/fs/reiserfs/procfs.c
56983 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56984 "SMALL_TAILS " : "NO_TAILS ",
56985 replay_only(sb) ? "REPLAY_ONLY " : "",
56986 convert_reiserfs(sb) ? "CONV " : "",
56987 - atomic_read(&r->s_generation_counter),
56988 + atomic_read_unchecked(&r->s_generation_counter),
56989 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56990 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56991 SF(s_good_search_by_key_reada), SF(s_bmaps),
56992 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56993 index 157e474..65a6114 100644
56994 --- a/fs/reiserfs/reiserfs.h
56995 +++ b/fs/reiserfs/reiserfs.h
56996 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56997 /* Comment? -Hans */
56998 wait_queue_head_t s_wait;
56999 /* To be obsoleted soon by per buffer seals.. -Hans */
57000 - atomic_t s_generation_counter; // increased by one every time the
57001 + atomic_unchecked_t s_generation_counter; // increased by one every time the
57002 // tree gets re-balanced
57003 unsigned long s_properties; /* File system properties. Currently holds
57004 on-disk FS format */
57005 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
57006 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
57007
57008 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
57009 -#define get_generation(s) atomic_read (&fs_generation(s))
57010 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
57011 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
57012 #define __fs_changed(gen,s) (gen != get_generation (s))
57013 #define fs_changed(gen,s) \
57014 diff --git a/fs/select.c b/fs/select.c
57015 index 2ef72d9..f213b17 100644
57016 --- a/fs/select.c
57017 +++ b/fs/select.c
57018 @@ -20,6 +20,7 @@
57019 #include <linux/export.h>
57020 #include <linux/slab.h>
57021 #include <linux/poll.h>
57022 +#include <linux/security.h>
57023 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
57024 #include <linux/file.h>
57025 #include <linux/fdtable.h>
57026 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
57027 struct poll_list *walk = head;
57028 unsigned long todo = nfds;
57029
57030 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
57031 if (nfds > rlimit(RLIMIT_NOFILE))
57032 return -EINVAL;
57033
57034 diff --git a/fs/seq_file.c b/fs/seq_file.c
57035 index f2bc3df..239d4f6 100644
57036 --- a/fs/seq_file.c
57037 +++ b/fs/seq_file.c
57038 @@ -10,6 +10,7 @@
57039 #include <linux/seq_file.h>
57040 #include <linux/slab.h>
57041 #include <linux/cred.h>
57042 +#include <linux/sched.h>
57043
57044 #include <asm/uaccess.h>
57045 #include <asm/page.h>
57046 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
57047 #ifdef CONFIG_USER_NS
57048 p->user_ns = file->f_cred->user_ns;
57049 #endif
57050 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57051 + p->exec_id = current->exec_id;
57052 +#endif
57053
57054 /*
57055 * Wrappers around seq_open(e.g. swaps_open) need to be
57056 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
57057 return 0;
57058 }
57059 if (!m->buf) {
57060 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
57061 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
57062 if (!m->buf)
57063 return -ENOMEM;
57064 }
57065 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
57066 Eoverflow:
57067 m->op->stop(m, p);
57068 kfree(m->buf);
57069 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
57070 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
57071 return !m->buf ? -ENOMEM : -EAGAIN;
57072 }
57073
57074 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
57075
57076 /* grab buffer if we didn't have one */
57077 if (!m->buf) {
57078 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
57079 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
57080 if (!m->buf)
57081 goto Enomem;
57082 }
57083 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
57084 goto Fill;
57085 m->op->stop(m, p);
57086 kfree(m->buf);
57087 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
57088 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
57089 if (!m->buf)
57090 goto Enomem;
57091 m->count = 0;
57092 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
57093 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
57094 void *data)
57095 {
57096 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
57097 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
57098 int res = -ENOMEM;
57099
57100 if (op) {
57101 diff --git a/fs/splice.c b/fs/splice.c
57102 index 6909d89..5b2e8f9 100644
57103 --- a/fs/splice.c
57104 +++ b/fs/splice.c
57105 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
57106 pipe_lock(pipe);
57107
57108 for (;;) {
57109 - if (!pipe->readers) {
57110 + if (!atomic_read(&pipe->readers)) {
57111 send_sig(SIGPIPE, current, 0);
57112 if (!ret)
57113 ret = -EPIPE;
57114 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
57115 do_wakeup = 0;
57116 }
57117
57118 - pipe->waiting_writers++;
57119 + atomic_inc(&pipe->waiting_writers);
57120 pipe_wait(pipe);
57121 - pipe->waiting_writers--;
57122 + atomic_dec(&pipe->waiting_writers);
57123 }
57124
57125 pipe_unlock(pipe);
57126 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
57127 old_fs = get_fs();
57128 set_fs(get_ds());
57129 /* The cast to a user pointer is valid due to the set_fs() */
57130 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
57131 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
57132 set_fs(old_fs);
57133
57134 return res;
57135 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
57136 old_fs = get_fs();
57137 set_fs(get_ds());
57138 /* The cast to a user pointer is valid due to the set_fs() */
57139 - res = vfs_write(file, (const char __user *)buf, count, &pos);
57140 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
57141 set_fs(old_fs);
57142
57143 return res;
57144 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
57145 goto err;
57146
57147 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
57148 - vec[i].iov_base = (void __user *) page_address(page);
57149 + vec[i].iov_base = (void __force_user *) page_address(page);
57150 vec[i].iov_len = this_len;
57151 spd.pages[i] = page;
57152 spd.nr_pages++;
57153 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
57154 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
57155 {
57156 while (!pipe->nrbufs) {
57157 - if (!pipe->writers)
57158 + if (!atomic_read(&pipe->writers))
57159 return 0;
57160
57161 - if (!pipe->waiting_writers && sd->num_spliced)
57162 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
57163 return 0;
57164
57165 if (sd->flags & SPLICE_F_NONBLOCK)
57166 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
57167 * out of the pipe right after the splice_to_pipe(). So set
57168 * PIPE_READERS appropriately.
57169 */
57170 - pipe->readers = 1;
57171 + atomic_set(&pipe->readers, 1);
57172
57173 current->splice_pipe = pipe;
57174 }
57175 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
57176 ret = -ERESTARTSYS;
57177 break;
57178 }
57179 - if (!pipe->writers)
57180 + if (!atomic_read(&pipe->writers))
57181 break;
57182 - if (!pipe->waiting_writers) {
57183 + if (!atomic_read(&pipe->waiting_writers)) {
57184 if (flags & SPLICE_F_NONBLOCK) {
57185 ret = -EAGAIN;
57186 break;
57187 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
57188 pipe_lock(pipe);
57189
57190 while (pipe->nrbufs >= pipe->buffers) {
57191 - if (!pipe->readers) {
57192 + if (!atomic_read(&pipe->readers)) {
57193 send_sig(SIGPIPE, current, 0);
57194 ret = -EPIPE;
57195 break;
57196 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
57197 ret = -ERESTARTSYS;
57198 break;
57199 }
57200 - pipe->waiting_writers++;
57201 + atomic_inc(&pipe->waiting_writers);
57202 pipe_wait(pipe);
57203 - pipe->waiting_writers--;
57204 + atomic_dec(&pipe->waiting_writers);
57205 }
57206
57207 pipe_unlock(pipe);
57208 @@ -1823,14 +1823,14 @@ retry:
57209 pipe_double_lock(ipipe, opipe);
57210
57211 do {
57212 - if (!opipe->readers) {
57213 + if (!atomic_read(&opipe->readers)) {
57214 send_sig(SIGPIPE, current, 0);
57215 if (!ret)
57216 ret = -EPIPE;
57217 break;
57218 }
57219
57220 - if (!ipipe->nrbufs && !ipipe->writers)
57221 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
57222 break;
57223
57224 /*
57225 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
57226 pipe_double_lock(ipipe, opipe);
57227
57228 do {
57229 - if (!opipe->readers) {
57230 + if (!atomic_read(&opipe->readers)) {
57231 send_sig(SIGPIPE, current, 0);
57232 if (!ret)
57233 ret = -EPIPE;
57234 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
57235 * return EAGAIN if we have the potential of some data in the
57236 * future, otherwise just return 0
57237 */
57238 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
57239 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
57240 ret = -EAGAIN;
57241
57242 pipe_unlock(ipipe);
57243 diff --git a/fs/stat.c b/fs/stat.c
57244 index 14f4545..9b7f55b 100644
57245 --- a/fs/stat.c
57246 +++ b/fs/stat.c
57247 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
57248 stat->gid = inode->i_gid;
57249 stat->rdev = inode->i_rdev;
57250 stat->size = i_size_read(inode);
57251 - stat->atime = inode->i_atime;
57252 - stat->mtime = inode->i_mtime;
57253 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
57254 + stat->atime = inode->i_ctime;
57255 + stat->mtime = inode->i_ctime;
57256 + } else {
57257 + stat->atime = inode->i_atime;
57258 + stat->mtime = inode->i_mtime;
57259 + }
57260 stat->ctime = inode->i_ctime;
57261 stat->blksize = (1 << inode->i_blkbits);
57262 stat->blocks = inode->i_blocks;
57263 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
57264 if (retval)
57265 return retval;
57266
57267 - if (inode->i_op->getattr)
57268 - return inode->i_op->getattr(mnt, dentry, stat);
57269 + if (inode->i_op->getattr) {
57270 + retval = inode->i_op->getattr(mnt, dentry, stat);
57271 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
57272 + stat->atime = stat->ctime;
57273 + stat->mtime = stat->ctime;
57274 + }
57275 + return retval;
57276 + }
57277
57278 generic_fillattr(inode, stat);
57279 return 0;
57280 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
57281 index 614b2b5..4d321e6 100644
57282 --- a/fs/sysfs/bin.c
57283 +++ b/fs/sysfs/bin.c
57284 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
57285 return ret;
57286 }
57287
57288 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
57289 - void *buf, int len, int write)
57290 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
57291 + void *buf, size_t len, int write)
57292 {
57293 struct file *file = vma->vm_file;
57294 struct bin_buffer *bb = file->private_data;
57295 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
57296 - int ret;
57297 + ssize_t ret;
57298
57299 if (!bb->vm_ops)
57300 return -EINVAL;
57301 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
57302 index 1f8c823..ed57cfe 100644
57303 --- a/fs/sysfs/dir.c
57304 +++ b/fs/sysfs/dir.c
57305 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
57306 *
57307 * Returns 31 bit hash of ns + name (so it fits in an off_t )
57308 */
57309 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
57310 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
57311 {
57312 unsigned long hash = init_name_hash();
57313 unsigned int len = strlen(name);
57314 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
57315 struct sysfs_dirent *sd;
57316 int rc;
57317
57318 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
57319 + const char *parent_name = parent_sd->s_name;
57320 +
57321 + mode = S_IFDIR | S_IRWXU;
57322 +
57323 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
57324 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
57325 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
57326 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
57327 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
57328 +#endif
57329 +
57330 /* allocate */
57331 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
57332 if (!sd)
57333 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
57334 index 602f56d..6853db8 100644
57335 --- a/fs/sysfs/file.c
57336 +++ b/fs/sysfs/file.c
57337 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
57338
57339 struct sysfs_open_dirent {
57340 atomic_t refcnt;
57341 - atomic_t event;
57342 + atomic_unchecked_t event;
57343 wait_queue_head_t poll;
57344 struct list_head buffers; /* goes through sysfs_buffer.list */
57345 };
57346 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
57347 if (!sysfs_get_active(attr_sd))
57348 return -ENODEV;
57349
57350 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
57351 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
57352 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
57353
57354 sysfs_put_active(attr_sd);
57355 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
57356 return -ENOMEM;
57357
57358 atomic_set(&new_od->refcnt, 0);
57359 - atomic_set(&new_od->event, 1);
57360 + atomic_set_unchecked(&new_od->event, 1);
57361 init_waitqueue_head(&new_od->poll);
57362 INIT_LIST_HEAD(&new_od->buffers);
57363 goto retry;
57364 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
57365
57366 sysfs_put_active(attr_sd);
57367
57368 - if (buffer->event != atomic_read(&od->event))
57369 + if (buffer->event != atomic_read_unchecked(&od->event))
57370 goto trigger;
57371
57372 return DEFAULT_POLLMASK;
57373 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
57374
57375 od = sd->s_attr.open;
57376 if (od) {
57377 - atomic_inc(&od->event);
57378 + atomic_inc_unchecked(&od->event);
57379 wake_up_interruptible(&od->poll);
57380 }
57381
57382 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
57383 index 3c9eb56..9dea5be 100644
57384 --- a/fs/sysfs/symlink.c
57385 +++ b/fs/sysfs/symlink.c
57386 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
57387
57388 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
57389 {
57390 - char *page = nd_get_link(nd);
57391 + const char *page = nd_get_link(nd);
57392 if (!IS_ERR(page))
57393 free_page((unsigned long)page);
57394 }
57395 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
57396 index 69d4889..a810bd4 100644
57397 --- a/fs/sysv/sysv.h
57398 +++ b/fs/sysv/sysv.h
57399 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
57400 #endif
57401 }
57402
57403 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
57404 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
57405 {
57406 if (sbi->s_bytesex == BYTESEX_PDP)
57407 return PDP_swab((__force __u32)n);
57408 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
57409 index e18b988..f1d4ad0f 100644
57410 --- a/fs/ubifs/io.c
57411 +++ b/fs/ubifs/io.c
57412 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
57413 return err;
57414 }
57415
57416 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
57417 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
57418 {
57419 int err;
57420
57421 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
57422 index c175b4d..8f36a16 100644
57423 --- a/fs/udf/misc.c
57424 +++ b/fs/udf/misc.c
57425 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
57426
57427 u8 udf_tag_checksum(const struct tag *t)
57428 {
57429 - u8 *data = (u8 *)t;
57430 + const u8 *data = (const u8 *)t;
57431 u8 checksum = 0;
57432 int i;
57433 for (i = 0; i < sizeof(struct tag); ++i)
57434 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
57435 index 8d974c4..b82f6ec 100644
57436 --- a/fs/ufs/swab.h
57437 +++ b/fs/ufs/swab.h
57438 @@ -22,7 +22,7 @@ enum {
57439 BYTESEX_BE
57440 };
57441
57442 -static inline u64
57443 +static inline u64 __intentional_overflow(-1)
57444 fs64_to_cpu(struct super_block *sbp, __fs64 n)
57445 {
57446 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
57447 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
57448 return (__force __fs64)cpu_to_be64(n);
57449 }
57450
57451 -static inline u32
57452 +static inline u32 __intentional_overflow(-1)
57453 fs32_to_cpu(struct super_block *sbp, __fs32 n)
57454 {
57455 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
57456 diff --git a/fs/utimes.c b/fs/utimes.c
57457 index f4fb7ec..3fe03c0 100644
57458 --- a/fs/utimes.c
57459 +++ b/fs/utimes.c
57460 @@ -1,6 +1,7 @@
57461 #include <linux/compiler.h>
57462 #include <linux/file.h>
57463 #include <linux/fs.h>
57464 +#include <linux/security.h>
57465 #include <linux/linkage.h>
57466 #include <linux/mount.h>
57467 #include <linux/namei.h>
57468 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
57469 goto mnt_drop_write_and_out;
57470 }
57471 }
57472 +
57473 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
57474 + error = -EACCES;
57475 + goto mnt_drop_write_and_out;
57476 + }
57477 +
57478 mutex_lock(&inode->i_mutex);
57479 error = notify_change(path->dentry, &newattrs);
57480 mutex_unlock(&inode->i_mutex);
57481 diff --git a/fs/xattr.c b/fs/xattr.c
57482 index 3377dff..4feded6 100644
57483 --- a/fs/xattr.c
57484 +++ b/fs/xattr.c
57485 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
57486 * Extended attribute SET operations
57487 */
57488 static long
57489 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
57490 +setxattr(struct path *path, const char __user *name, const void __user *value,
57491 size_t size, int flags)
57492 {
57493 int error;
57494 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
57495 posix_acl_fix_xattr_from_user(kvalue, size);
57496 }
57497
57498 - error = vfs_setxattr(d, kname, kvalue, size, flags);
57499 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
57500 + error = -EACCES;
57501 + goto out;
57502 + }
57503 +
57504 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
57505 out:
57506 if (vvalue)
57507 vfree(vvalue);
57508 @@ -377,7 +382,7 @@ retry:
57509 return error;
57510 error = mnt_want_write(path.mnt);
57511 if (!error) {
57512 - error = setxattr(path.dentry, name, value, size, flags);
57513 + error = setxattr(&path, name, value, size, flags);
57514 mnt_drop_write(path.mnt);
57515 }
57516 path_put(&path);
57517 @@ -401,7 +406,7 @@ retry:
57518 return error;
57519 error = mnt_want_write(path.mnt);
57520 if (!error) {
57521 - error = setxattr(path.dentry, name, value, size, flags);
57522 + error = setxattr(&path, name, value, size, flags);
57523 mnt_drop_write(path.mnt);
57524 }
57525 path_put(&path);
57526 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
57527 const void __user *,value, size_t, size, int, flags)
57528 {
57529 struct fd f = fdget(fd);
57530 - struct dentry *dentry;
57531 int error = -EBADF;
57532
57533 if (!f.file)
57534 return error;
57535 - dentry = f.file->f_path.dentry;
57536 - audit_inode(NULL, dentry, 0);
57537 + audit_inode(NULL, f.file->f_path.dentry, 0);
57538 error = mnt_want_write_file(f.file);
57539 if (!error) {
57540 - error = setxattr(dentry, name, value, size, flags);
57541 + error = setxattr(&f.file->f_path, name, value, size, flags);
57542 mnt_drop_write_file(f.file);
57543 }
57544 fdput(f);
57545 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
57546 index 9fbea87..6b19972 100644
57547 --- a/fs/xattr_acl.c
57548 +++ b/fs/xattr_acl.c
57549 @@ -76,8 +76,8 @@ struct posix_acl *
57550 posix_acl_from_xattr(struct user_namespace *user_ns,
57551 const void *value, size_t size)
57552 {
57553 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
57554 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
57555 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
57556 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
57557 int count;
57558 struct posix_acl *acl;
57559 struct posix_acl_entry *acl_e;
57560 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
57561 index 572a858..12a9b0d 100644
57562 --- a/fs/xfs/xfs_bmap.c
57563 +++ b/fs/xfs/xfs_bmap.c
57564 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
57565 int nmap,
57566 int ret_nmap);
57567 #else
57568 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
57569 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
57570 #endif /* DEBUG */
57571
57572 STATIC int
57573 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
57574 index 1b9fc3e..e1bdde0 100644
57575 --- a/fs/xfs/xfs_dir2_sf.c
57576 +++ b/fs/xfs/xfs_dir2_sf.c
57577 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
57578 }
57579
57580 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
57581 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57582 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
57583 + char name[sfep->namelen];
57584 + memcpy(name, sfep->name, sfep->namelen);
57585 + if (filldir(dirent, name, sfep->namelen,
57586 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
57587 + *offset = off & 0x7fffffff;
57588 + return 0;
57589 + }
57590 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57591 off & 0x7fffffff, ino, DT_UNKNOWN)) {
57592 *offset = off & 0x7fffffff;
57593 return 0;
57594 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
57595 index c1c3ef8..0952438 100644
57596 --- a/fs/xfs/xfs_ioctl.c
57597 +++ b/fs/xfs/xfs_ioctl.c
57598 @@ -127,7 +127,7 @@ xfs_find_handle(
57599 }
57600
57601 error = -EFAULT;
57602 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
57603 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
57604 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
57605 goto out_put;
57606
57607 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
57608 index d82efaa..0904a8e 100644
57609 --- a/fs/xfs/xfs_iops.c
57610 +++ b/fs/xfs/xfs_iops.c
57611 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57612 struct nameidata *nd,
57613 void *p)
57614 {
57615 - char *s = nd_get_link(nd);
57616 + const char *s = nd_get_link(nd);
57617
57618 if (!IS_ERR(s))
57619 kfree(s);
57620 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57621 new file mode 100644
57622 index 0000000..92247e4
57623 --- /dev/null
57624 +++ b/grsecurity/Kconfig
57625 @@ -0,0 +1,1021 @@
57626 +#
57627 +# grecurity configuration
57628 +#
57629 +menu "Memory Protections"
57630 +depends on GRKERNSEC
57631 +
57632 +config GRKERNSEC_KMEM
57633 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57634 + default y if GRKERNSEC_CONFIG_AUTO
57635 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57636 + help
57637 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57638 + be written to or read from to modify or leak the contents of the running
57639 + kernel. /dev/port will also not be allowed to be opened and support
57640 + for /dev/cpu/*/msr will be removed. If you have module
57641 + support disabled, enabling this will close up five ways that are
57642 + currently used to insert malicious code into the running kernel.
57643 +
57644 + Even with all these features enabled, we still highly recommend that
57645 + you use the RBAC system, as it is still possible for an attacker to
57646 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57647 +
57648 + If you are not using XFree86, you may be able to stop this additional
57649 + case by enabling the 'Disable privileged I/O' option. Though nothing
57650 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57651 + but only to video memory, which is the only writing we allow in this
57652 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57653 + not be allowed to mprotect it with PROT_WRITE later.
57654 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57655 + from working.
57656 +
57657 + It is highly recommended that you say Y here if you meet all the
57658 + conditions above.
57659 +
57660 +config GRKERNSEC_VM86
57661 + bool "Restrict VM86 mode"
57662 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57663 + depends on X86_32
57664 +
57665 + help
57666 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57667 + make use of a special execution mode on 32bit x86 processors called
57668 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57669 + video cards and will still work with this option enabled. The purpose
57670 + of the option is to prevent exploitation of emulation errors in
57671 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57672 + Nearly all users should be able to enable this option.
57673 +
57674 +config GRKERNSEC_IO
57675 + bool "Disable privileged I/O"
57676 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57677 + depends on X86
57678 + select RTC_CLASS
57679 + select RTC_INTF_DEV
57680 + select RTC_DRV_CMOS
57681 +
57682 + help
57683 + If you say Y here, all ioperm and iopl calls will return an error.
57684 + Ioperm and iopl can be used to modify the running kernel.
57685 + Unfortunately, some programs need this access to operate properly,
57686 + the most notable of which are XFree86 and hwclock. hwclock can be
57687 + remedied by having RTC support in the kernel, so real-time
57688 + clock support is enabled if this option is enabled, to ensure
57689 + that hwclock operates correctly. XFree86 still will not
57690 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57691 + IF YOU USE XFree86. If you use XFree86 and you still want to
57692 + protect your kernel against modification, use the RBAC system.
57693 +
57694 +config GRKERNSEC_JIT_HARDEN
57695 + bool "Harden BPF JIT against spray attacks"
57696 + default y if GRKERNSEC_CONFIG_AUTO
57697 + depends on BPF_JIT
57698 + help
57699 + If you say Y here, the native code generated by the kernel's Berkeley
57700 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57701 + attacks that attempt to fit attacker-beneficial instructions in
57702 + 32bit immediate fields of JIT-generated native instructions. The
57703 + attacker will generally aim to cause an unintended instruction sequence
57704 + of JIT-generated native code to execute by jumping into the middle of
57705 + a generated instruction. This feature effectively randomizes the 32bit
57706 + immediate constants present in the generated code to thwart such attacks.
57707 +
57708 + If you're using KERNEXEC, it's recommended that you enable this option
57709 + to supplement the hardening of the kernel.
57710 +
57711 +config GRKERNSEC_RAND_THREADSTACK
57712 + bool "Insert random gaps between thread stacks"
57713 + default y if GRKERNSEC_CONFIG_AUTO
57714 + depends on PAX_RANDMMAP && !PPC
57715 + help
57716 + If you say Y here, a random-sized gap will be enforced between allocated
57717 + thread stacks. Glibc's NPTL and other threading libraries that
57718 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57719 + The implementation currently provides 8 bits of entropy for the gap.
57720 +
57721 + Many distributions do not compile threaded remote services with the
57722 + -fstack-check argument to GCC, causing the variable-sized stack-based
57723 + allocator, alloca(), to not probe the stack on allocation. This
57724 + permits an unbounded alloca() to skip over any guard page and potentially
57725 + modify another thread's stack reliably. An enforced random gap
57726 + reduces the reliability of such an attack and increases the chance
57727 + that such a read/write to another thread's stack instead lands in
57728 + an unmapped area, causing a crash and triggering grsecurity's
57729 + anti-bruteforcing logic.
57730 +
57731 +config GRKERNSEC_PROC_MEMMAP
57732 + bool "Harden ASLR against information leaks and entropy reduction"
57733 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57734 + depends on PAX_NOEXEC || PAX_ASLR
57735 + help
57736 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57737 + give no information about the addresses of its mappings if
57738 + PaX features that rely on random addresses are enabled on the task.
57739 + In addition to sanitizing this information and disabling other
57740 + dangerous sources of information, this option causes reads of sensitive
57741 + /proc/<pid> entries where the file descriptor was opened in a different
57742 + task than the one performing the read. Such attempts are logged.
57743 + This option also limits argv/env strings for suid/sgid binaries
57744 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57745 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57746 + binaries to prevent alternative mmap layouts from being abused.
57747 +
57748 + If you use PaX it is essential that you say Y here as it closes up
57749 + several holes that make full ASLR useless locally.
57750 +
57751 +config GRKERNSEC_BRUTE
57752 + bool "Deter exploit bruteforcing"
57753 + default y if GRKERNSEC_CONFIG_AUTO
57754 + help
57755 + If you say Y here, attempts to bruteforce exploits against forking
57756 + daemons such as apache or sshd, as well as against suid/sgid binaries
57757 + will be deterred. When a child of a forking daemon is killed by PaX
57758 + or crashes due to an illegal instruction or other suspicious signal,
57759 + the parent process will be delayed 30 seconds upon every subsequent
57760 + fork until the administrator is able to assess the situation and
57761 + restart the daemon.
57762 + In the suid/sgid case, the attempt is logged, the user has all their
57763 + processes terminated, and they are prevented from executing any further
57764 + processes for 15 minutes.
57765 + It is recommended that you also enable signal logging in the auditing
57766 + section so that logs are generated when a process triggers a suspicious
57767 + signal.
57768 + If the sysctl option is enabled, a sysctl option with name
57769 + "deter_bruteforce" is created.
57770 +
57771 +
57772 +config GRKERNSEC_MODHARDEN
57773 + bool "Harden module auto-loading"
57774 + default y if GRKERNSEC_CONFIG_AUTO
57775 + depends on MODULES
57776 + help
57777 + If you say Y here, module auto-loading in response to use of some
57778 + feature implemented by an unloaded module will be restricted to
57779 + root users. Enabling this option helps defend against attacks
57780 + by unprivileged users who abuse the auto-loading behavior to
57781 + cause a vulnerable module to load that is then exploited.
57782 +
57783 + If this option prevents a legitimate use of auto-loading for a
57784 + non-root user, the administrator can execute modprobe manually
57785 + with the exact name of the module mentioned in the alert log.
57786 + Alternatively, the administrator can add the module to the list
57787 + of modules loaded at boot by modifying init scripts.
57788 +
57789 + Modification of init scripts will most likely be needed on
57790 + Ubuntu servers with encrypted home directory support enabled,
57791 + as the first non-root user logging in will cause the ecb(aes),
57792 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57793 +
57794 +config GRKERNSEC_HIDESYM
57795 + bool "Hide kernel symbols"
57796 + default y if GRKERNSEC_CONFIG_AUTO
57797 + select PAX_USERCOPY_SLABS
57798 + help
57799 + If you say Y here, getting information on loaded modules, and
57800 + displaying all kernel symbols through a syscall will be restricted
57801 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57802 + /proc/kallsyms will be restricted to the root user. The RBAC
57803 + system can hide that entry even from root.
57804 +
57805 + This option also prevents leaking of kernel addresses through
57806 + several /proc entries.
57807 +
57808 + Note that this option is only effective provided the following
57809 + conditions are met:
57810 + 1) The kernel using grsecurity is not precompiled by some distribution
57811 + 2) You have also enabled GRKERNSEC_DMESG
57812 + 3) You are using the RBAC system and hiding other files such as your
57813 + kernel image and System.map. Alternatively, enabling this option
57814 + causes the permissions on /boot, /lib/modules, and the kernel
57815 + source directory to change at compile time to prevent
57816 + reading by non-root users.
57817 + If the above conditions are met, this option will aid in providing a
57818 + useful protection against local kernel exploitation of overflows
57819 + and arbitrary read/write vulnerabilities.
57820 +
57821 +config GRKERNSEC_KERN_LOCKOUT
57822 + bool "Active kernel exploit response"
57823 + default y if GRKERNSEC_CONFIG_AUTO
57824 + depends on X86 || ARM || PPC || SPARC
57825 + help
57826 + If you say Y here, when a PaX alert is triggered due to suspicious
57827 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57828 + or an OOPS occurs due to bad memory accesses, instead of just
57829 + terminating the offending process (and potentially allowing
57830 + a subsequent exploit from the same user), we will take one of two
57831 + actions:
57832 + If the user was root, we will panic the system
57833 + If the user was non-root, we will log the attempt, terminate
57834 + all processes owned by the user, then prevent them from creating
57835 + any new processes until the system is restarted
57836 + This deters repeated kernel exploitation/bruteforcing attempts
57837 + and is useful for later forensics.
57838 +
57839 +endmenu
57840 +menu "Role Based Access Control Options"
57841 +depends on GRKERNSEC
57842 +
57843 +config GRKERNSEC_RBAC_DEBUG
57844 + bool
57845 +
57846 +config GRKERNSEC_NO_RBAC
57847 + bool "Disable RBAC system"
57848 + help
57849 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57850 + preventing the RBAC system from being enabled. You should only say Y
57851 + here if you have no intention of using the RBAC system, so as to prevent
57852 + an attacker with root access from misusing the RBAC system to hide files
57853 + and processes when loadable module support and /dev/[k]mem have been
57854 + locked down.
57855 +
57856 +config GRKERNSEC_ACL_HIDEKERN
57857 + bool "Hide kernel processes"
57858 + help
57859 + If you say Y here, all kernel threads will be hidden to all
57860 + processes but those whose subject has the "view hidden processes"
57861 + flag.
57862 +
57863 +config GRKERNSEC_ACL_MAXTRIES
57864 + int "Maximum tries before password lockout"
57865 + default 3
57866 + help
57867 + This option enforces the maximum number of times a user can attempt
57868 + to authorize themselves with the grsecurity RBAC system before being
57869 + denied the ability to attempt authorization again for a specified time.
57870 + The lower the number, the harder it will be to brute-force a password.
57871 +
57872 +config GRKERNSEC_ACL_TIMEOUT
57873 + int "Time to wait after max password tries, in seconds"
57874 + default 30
57875 + help
57876 + This option specifies the time the user must wait after attempting to
57877 + authorize to the RBAC system with the maximum number of invalid
57878 + passwords. The higher the number, the harder it will be to brute-force
57879 + a password.
57880 +
57881 +endmenu
57882 +menu "Filesystem Protections"
57883 +depends on GRKERNSEC
57884 +
57885 +config GRKERNSEC_PROC
57886 + bool "Proc restrictions"
57887 + default y if GRKERNSEC_CONFIG_AUTO
57888 + help
57889 + If you say Y here, the permissions of the /proc filesystem
57890 + will be altered to enhance system security and privacy. You MUST
57891 + choose either a user only restriction or a user and group restriction.
57892 + Depending upon the option you choose, you can either restrict users to
57893 + see only the processes they themselves run, or choose a group that can
57894 + view all processes and files normally restricted to root if you choose
57895 + the "restrict to user only" option. NOTE: If you're running identd or
57896 + ntpd as a non-root user, you will have to run it as the group you
57897 + specify here.
57898 +
57899 +config GRKERNSEC_PROC_USER
57900 + bool "Restrict /proc to user only"
57901 + depends on GRKERNSEC_PROC
57902 + help
57903 + If you say Y here, non-root users will only be able to view their own
57904 + processes, and restricts them from viewing network-related information,
57905 + and viewing kernel symbol and module information.
57906 +
57907 +config GRKERNSEC_PROC_USERGROUP
57908 + bool "Allow special group"
57909 + default y if GRKERNSEC_CONFIG_AUTO
57910 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57911 + help
57912 + If you say Y here, you will be able to select a group that will be
57913 + able to view all processes and network-related information. If you've
57914 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57915 + remain hidden. This option is useful if you want to run identd as
57916 + a non-root user. The group you select may also be chosen at boot time
57917 + via "grsec_proc_gid=" on the kernel commandline.
57918 +
57919 +config GRKERNSEC_PROC_GID
57920 + int "GID for special group"
57921 + depends on GRKERNSEC_PROC_USERGROUP
57922 + default 1001
57923 +
57924 +config GRKERNSEC_PROC_ADD
57925 + bool "Additional restrictions"
57926 + default y if GRKERNSEC_CONFIG_AUTO
57927 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57928 + help
57929 + If you say Y here, additional restrictions will be placed on
57930 + /proc that keep normal users from viewing device information and
57931 + slabinfo information that could be useful for exploits.
57932 +
57933 +config GRKERNSEC_LINK
57934 + bool "Linking restrictions"
57935 + default y if GRKERNSEC_CONFIG_AUTO
57936 + help
57937 + If you say Y here, /tmp race exploits will be prevented, since users
57938 + will no longer be able to follow symlinks owned by other users in
57939 + world-writable +t directories (e.g. /tmp), unless the owner of the
57940 + symlink is the owner of the directory. users will also not be
57941 + able to hardlink to files they do not own. If the sysctl option is
57942 + enabled, a sysctl option with name "linking_restrictions" is created.
57943 +
57944 +config GRKERNSEC_SYMLINKOWN
57945 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57946 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57947 + help
57948 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57949 + that prevents it from being used as a security feature. As Apache
57950 + verifies the symlink by performing a stat() against the target of
57951 + the symlink before it is followed, an attacker can setup a symlink
57952 + to point to a same-owned file, then replace the symlink with one
57953 + that targets another user's file just after Apache "validates" the
57954 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57955 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57956 + will be in place for the group you specify. If the sysctl option
57957 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57958 + created.
57959 +
57960 +config GRKERNSEC_SYMLINKOWN_GID
57961 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57962 + depends on GRKERNSEC_SYMLINKOWN
57963 + default 1006
57964 + help
57965 + Setting this GID determines what group kernel-enforced
57966 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57967 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57968 +
57969 +config GRKERNSEC_FIFO
57970 + bool "FIFO restrictions"
57971 + default y if GRKERNSEC_CONFIG_AUTO
57972 + help
57973 + If you say Y here, users will not be able to write to FIFOs they don't
57974 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57975 + the FIFO is the same owner of the directory it's held in. If the sysctl
57976 + option is enabled, a sysctl option with name "fifo_restrictions" is
57977 + created.
57978 +
57979 +config GRKERNSEC_SYSFS_RESTRICT
57980 + bool "Sysfs/debugfs restriction"
57981 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57982 + depends on SYSFS
57983 + help
57984 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57985 + any filesystem normally mounted under it (e.g. debugfs) will be
57986 + mostly accessible only by root. These filesystems generally provide access
57987 + to hardware and debug information that isn't appropriate for unprivileged
57988 + users of the system. Sysfs and debugfs have also become a large source
57989 + of new vulnerabilities, ranging from infoleaks to local compromise.
57990 + There has been very little oversight with an eye toward security involved
57991 + in adding new exporters of information to these filesystems, so their
57992 + use is discouraged.
57993 + For reasons of compatibility, a few directories have been whitelisted
57994 + for access by non-root users:
57995 + /sys/fs/selinux
57996 + /sys/fs/fuse
57997 + /sys/devices/system/cpu
57998 +
57999 +config GRKERNSEC_ROFS
58000 + bool "Runtime read-only mount protection"
58001 + help
58002 + If you say Y here, a sysctl option with name "romount_protect" will
58003 + be created. By setting this option to 1 at runtime, filesystems
58004 + will be protected in the following ways:
58005 + * No new writable mounts will be allowed
58006 + * Existing read-only mounts won't be able to be remounted read/write
58007 + * Write operations will be denied on all block devices
58008 + This option acts independently of grsec_lock: once it is set to 1,
58009 + it cannot be turned off. Therefore, please be mindful of the resulting
58010 + behavior if this option is enabled in an init script on a read-only
58011 + filesystem. This feature is mainly intended for secure embedded systems.
58012 +
58013 +config GRKERNSEC_DEVICE_SIDECHANNEL
58014 + bool "Eliminate stat/notify-based device sidechannels"
58015 + default y if GRKERNSEC_CONFIG_AUTO
58016 + help
58017 + If you say Y here, timing analyses on block or character
58018 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
58019 + will be thwarted for unprivileged users. If a process without
58020 + CAP_MKNOD stats such a device, the last access and last modify times
58021 + will match the device's create time. No access or modify events
58022 + will be triggered through inotify/dnotify/fanotify for such devices.
58023 + This feature will prevent attacks that may at a minimum
58024 + allow an attacker to determine the administrator's password length.
58025 +
58026 +config GRKERNSEC_CHROOT
58027 + bool "Chroot jail restrictions"
58028 + default y if GRKERNSEC_CONFIG_AUTO
58029 + help
58030 + If you say Y here, you will be able to choose several options that will
58031 + make breaking out of a chrooted jail much more difficult. If you
58032 + encounter no software incompatibilities with the following options, it
58033 + is recommended that you enable each one.
58034 +
58035 +config GRKERNSEC_CHROOT_MOUNT
58036 + bool "Deny mounts"
58037 + default y if GRKERNSEC_CONFIG_AUTO
58038 + depends on GRKERNSEC_CHROOT
58039 + help
58040 + If you say Y here, processes inside a chroot will not be able to
58041 + mount or remount filesystems. If the sysctl option is enabled, a
58042 + sysctl option with name "chroot_deny_mount" is created.
58043 +
58044 +config GRKERNSEC_CHROOT_DOUBLE
58045 + bool "Deny double-chroots"
58046 + default y if GRKERNSEC_CONFIG_AUTO
58047 + depends on GRKERNSEC_CHROOT
58048 + help
58049 + If you say Y here, processes inside a chroot will not be able to chroot
58050 + again outside the chroot. This is a widely used method of breaking
58051 + out of a chroot jail and should not be allowed. If the sysctl
58052 + option is enabled, a sysctl option with name
58053 + "chroot_deny_chroot" is created.
58054 +
58055 +config GRKERNSEC_CHROOT_PIVOT
58056 + bool "Deny pivot_root in chroot"
58057 + default y if GRKERNSEC_CONFIG_AUTO
58058 + depends on GRKERNSEC_CHROOT
58059 + help
58060 + If you say Y here, processes inside a chroot will not be able to use
58061 + a function called pivot_root() that was introduced in Linux 2.3.41. It
58062 + works similar to chroot in that it changes the root filesystem. This
58063 + function could be misused in a chrooted process to attempt to break out
58064 + of the chroot, and therefore should not be allowed. If the sysctl
58065 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
58066 + created.
58067 +
58068 +config GRKERNSEC_CHROOT_CHDIR
58069 + bool "Enforce chdir(\"/\") on all chroots"
58070 + default y if GRKERNSEC_CONFIG_AUTO
58071 + depends on GRKERNSEC_CHROOT
58072 + help
58073 + If you say Y here, the current working directory of all newly-chrooted
58074 + applications will be set to the the root directory of the chroot.
58075 + The man page on chroot(2) states:
58076 + Note that this call does not change the current working
58077 + directory, so that `.' can be outside the tree rooted at
58078 + `/'. In particular, the super-user can escape from a
58079 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
58080 +
58081 + It is recommended that you say Y here, since it's not known to break
58082 + any software. If the sysctl option is enabled, a sysctl option with
58083 + name "chroot_enforce_chdir" is created.
58084 +
58085 +config GRKERNSEC_CHROOT_CHMOD
58086 + bool "Deny (f)chmod +s"
58087 + default y if GRKERNSEC_CONFIG_AUTO
58088 + depends on GRKERNSEC_CHROOT
58089 + help
58090 + If you say Y here, processes inside a chroot will not be able to chmod
58091 + or fchmod files to make them have suid or sgid bits. This protects
58092 + against another published method of breaking a chroot. If the sysctl
58093 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
58094 + created.
58095 +
58096 +config GRKERNSEC_CHROOT_FCHDIR
58097 + bool "Deny fchdir out of chroot"
58098 + default y if GRKERNSEC_CONFIG_AUTO
58099 + depends on GRKERNSEC_CHROOT
58100 + help
58101 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
58102 + to a file descriptor of the chrooting process that points to a directory
58103 + outside the filesystem will be stopped. If the sysctl option
58104 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
58105 +
58106 +config GRKERNSEC_CHROOT_MKNOD
58107 + bool "Deny mknod"
58108 + default y if GRKERNSEC_CONFIG_AUTO
58109 + depends on GRKERNSEC_CHROOT
58110 + help
58111 + If you say Y here, processes inside a chroot will not be allowed to
58112 + mknod. The problem with using mknod inside a chroot is that it
58113 + would allow an attacker to create a device entry that is the same
58114 + as one on the physical root of your system, which could range from
58115 + anything from the console device to a device for your harddrive (which
58116 + they could then use to wipe the drive or steal data). It is recommended
58117 + that you say Y here, unless you run into software incompatibilities.
58118 + If the sysctl option is enabled, a sysctl option with name
58119 + "chroot_deny_mknod" is created.
58120 +
58121 +config GRKERNSEC_CHROOT_SHMAT
58122 + bool "Deny shmat() out of chroot"
58123 + default y if GRKERNSEC_CONFIG_AUTO
58124 + depends on GRKERNSEC_CHROOT
58125 + help
58126 + If you say Y here, processes inside a chroot will not be able to attach
58127 + to shared memory segments that were created outside of the chroot jail.
58128 + It is recommended that you say Y here. If the sysctl option is enabled,
58129 + a sysctl option with name "chroot_deny_shmat" is created.
58130 +
58131 +config GRKERNSEC_CHROOT_UNIX
58132 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
58133 + default y if GRKERNSEC_CONFIG_AUTO
58134 + depends on GRKERNSEC_CHROOT
58135 + help
58136 + If you say Y here, processes inside a chroot will not be able to
58137 + connect to abstract (meaning not belonging to a filesystem) Unix
58138 + domain sockets that were bound outside of a chroot. It is recommended
58139 + that you say Y here. If the sysctl option is enabled, a sysctl option
58140 + with name "chroot_deny_unix" is created.
58141 +
58142 +config GRKERNSEC_CHROOT_FINDTASK
58143 + bool "Protect outside processes"
58144 + default y if GRKERNSEC_CONFIG_AUTO
58145 + depends on GRKERNSEC_CHROOT
58146 + help
58147 + If you say Y here, processes inside a chroot will not be able to
58148 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
58149 + getsid, or view any process outside of the chroot. If the sysctl
58150 + option is enabled, a sysctl option with name "chroot_findtask" is
58151 + created.
58152 +
58153 +config GRKERNSEC_CHROOT_NICE
58154 + bool "Restrict priority changes"
58155 + default y if GRKERNSEC_CONFIG_AUTO
58156 + depends on GRKERNSEC_CHROOT
58157 + help
58158 + If you say Y here, processes inside a chroot will not be able to raise
58159 + the priority of processes in the chroot, or alter the priority of
58160 + processes outside the chroot. This provides more security than simply
58161 + removing CAP_SYS_NICE from the process' capability set. If the
58162 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
58163 + is created.
58164 +
58165 +config GRKERNSEC_CHROOT_SYSCTL
58166 + bool "Deny sysctl writes"
58167 + default y if GRKERNSEC_CONFIG_AUTO
58168 + depends on GRKERNSEC_CHROOT
58169 + help
58170 + If you say Y here, an attacker in a chroot will not be able to
58171 + write to sysctl entries, either by sysctl(2) or through a /proc
58172 + interface. It is strongly recommended that you say Y here. If the
58173 + sysctl option is enabled, a sysctl option with name
58174 + "chroot_deny_sysctl" is created.
58175 +
58176 +config GRKERNSEC_CHROOT_CAPS
58177 + bool "Capability restrictions"
58178 + default y if GRKERNSEC_CONFIG_AUTO
58179 + depends on GRKERNSEC_CHROOT
58180 + help
58181 + If you say Y here, the capabilities on all processes within a
58182 + chroot jail will be lowered to stop module insertion, raw i/o,
58183 + system and net admin tasks, rebooting the system, modifying immutable
58184 + files, modifying IPC owned by another, and changing the system time.
58185 + This is left an option because it can break some apps. Disable this
58186 + if your chrooted apps are having problems performing those kinds of
58187 + tasks. If the sysctl option is enabled, a sysctl option with
58188 + name "chroot_caps" is created.
58189 +
58190 +endmenu
58191 +menu "Kernel Auditing"
58192 +depends on GRKERNSEC
58193 +
58194 +config GRKERNSEC_AUDIT_GROUP
58195 + bool "Single group for auditing"
58196 + help
58197 + If you say Y here, the exec and chdir logging features will only operate
58198 + on a group you specify. This option is recommended if you only want to
58199 + watch certain users instead of having a large amount of logs from the
58200 + entire system. If the sysctl option is enabled, a sysctl option with
58201 + name "audit_group" is created.
58202 +
58203 +config GRKERNSEC_AUDIT_GID
58204 + int "GID for auditing"
58205 + depends on GRKERNSEC_AUDIT_GROUP
58206 + default 1007
58207 +
58208 +config GRKERNSEC_EXECLOG
58209 + bool "Exec logging"
58210 + help
58211 + If you say Y here, all execve() calls will be logged (since the
58212 + other exec*() calls are frontends to execve(), all execution
58213 + will be logged). Useful for shell-servers that like to keep track
58214 + of their users. If the sysctl option is enabled, a sysctl option with
58215 + name "exec_logging" is created.
58216 + WARNING: This option when enabled will produce a LOT of logs, especially
58217 + on an active system.
58218 +
58219 +config GRKERNSEC_RESLOG
58220 + bool "Resource logging"
58221 + default y if GRKERNSEC_CONFIG_AUTO
58222 + help
58223 + If you say Y here, all attempts to overstep resource limits will
58224 + be logged with the resource name, the requested size, and the current
58225 + limit. It is highly recommended that you say Y here. If the sysctl
58226 + option is enabled, a sysctl option with name "resource_logging" is
58227 + created. If the RBAC system is enabled, the sysctl value is ignored.
58228 +
58229 +config GRKERNSEC_CHROOT_EXECLOG
58230 + bool "Log execs within chroot"
58231 + help
58232 + If you say Y here, all executions inside a chroot jail will be logged
58233 + to syslog. This can cause a large amount of logs if certain
58234 + applications (eg. djb's daemontools) are installed on the system, and
58235 + is therefore left as an option. If the sysctl option is enabled, a
58236 + sysctl option with name "chroot_execlog" is created.
58237 +
58238 +config GRKERNSEC_AUDIT_PTRACE
58239 + bool "Ptrace logging"
58240 + help
58241 + If you say Y here, all attempts to attach to a process via ptrace
58242 + will be logged. If the sysctl option is enabled, a sysctl option
58243 + with name "audit_ptrace" is created.
58244 +
58245 +config GRKERNSEC_AUDIT_CHDIR
58246 + bool "Chdir logging"
58247 + help
58248 + If you say Y here, all chdir() calls will be logged. If the sysctl
58249 + option is enabled, a sysctl option with name "audit_chdir" is created.
58250 +
58251 +config GRKERNSEC_AUDIT_MOUNT
58252 + bool "(Un)Mount logging"
58253 + help
58254 + If you say Y here, all mounts and unmounts will be logged. If the
58255 + sysctl option is enabled, a sysctl option with name "audit_mount" is
58256 + created.
58257 +
58258 +config GRKERNSEC_SIGNAL
58259 + bool "Signal logging"
58260 + default y if GRKERNSEC_CONFIG_AUTO
58261 + help
58262 + If you say Y here, certain important signals will be logged, such as
58263 + SIGSEGV, which will as a result inform you of when a error in a program
58264 + occurred, which in some cases could mean a possible exploit attempt.
58265 + If the sysctl option is enabled, a sysctl option with name
58266 + "signal_logging" is created.
58267 +
58268 +config GRKERNSEC_FORKFAIL
58269 + bool "Fork failure logging"
58270 + help
58271 + If you say Y here, all failed fork() attempts will be logged.
58272 + This could suggest a fork bomb, or someone attempting to overstep
58273 + their process limit. If the sysctl option is enabled, a sysctl option
58274 + with name "forkfail_logging" is created.
58275 +
58276 +config GRKERNSEC_TIME
58277 + bool "Time change logging"
58278 + default y if GRKERNSEC_CONFIG_AUTO
58279 + help
58280 + If you say Y here, any changes of the system clock will be logged.
58281 + If the sysctl option is enabled, a sysctl option with name
58282 + "timechange_logging" is created.
58283 +
58284 +config GRKERNSEC_PROC_IPADDR
58285 + bool "/proc/<pid>/ipaddr support"
58286 + default y if GRKERNSEC_CONFIG_AUTO
58287 + help
58288 + If you say Y here, a new entry will be added to each /proc/<pid>
58289 + directory that contains the IP address of the person using the task.
58290 + The IP is carried across local TCP and AF_UNIX stream sockets.
58291 + This information can be useful for IDS/IPSes to perform remote response
58292 + to a local attack. The entry is readable by only the owner of the
58293 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
58294 + the RBAC system), and thus does not create privacy concerns.
58295 +
58296 +config GRKERNSEC_RWXMAP_LOG
58297 + bool 'Denied RWX mmap/mprotect logging'
58298 + default y if GRKERNSEC_CONFIG_AUTO
58299 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
58300 + help
58301 + If you say Y here, calls to mmap() and mprotect() with explicit
58302 + usage of PROT_WRITE and PROT_EXEC together will be logged when
58303 + denied by the PAX_MPROTECT feature. If the sysctl option is
58304 + enabled, a sysctl option with name "rwxmap_logging" is created.
58305 +
58306 +config GRKERNSEC_AUDIT_TEXTREL
58307 + bool 'ELF text relocations logging (READ HELP)'
58308 + depends on PAX_MPROTECT
58309 + help
58310 + If you say Y here, text relocations will be logged with the filename
58311 + of the offending library or binary. The purpose of the feature is
58312 + to help Linux distribution developers get rid of libraries and
58313 + binaries that need text relocations which hinder the future progress
58314 + of PaX. Only Linux distribution developers should say Y here, and
58315 + never on a production machine, as this option creates an information
58316 + leak that could aid an attacker in defeating the randomization of
58317 + a single memory region. If the sysctl option is enabled, a sysctl
58318 + option with name "audit_textrel" is created.
58319 +
58320 +endmenu
58321 +
58322 +menu "Executable Protections"
58323 +depends on GRKERNSEC
58324 +
58325 +config GRKERNSEC_DMESG
58326 + bool "Dmesg(8) restriction"
58327 + default y if GRKERNSEC_CONFIG_AUTO
58328 + help
58329 + If you say Y here, non-root users will not be able to use dmesg(8)
58330 + to view the contents of the kernel's circular log buffer.
58331 + The kernel's log buffer often contains kernel addresses and other
58332 + identifying information useful to an attacker in fingerprinting a
58333 + system for a targeted exploit.
58334 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
58335 + created.
58336 +
58337 +config GRKERNSEC_HARDEN_PTRACE
58338 + bool "Deter ptrace-based process snooping"
58339 + default y if GRKERNSEC_CONFIG_AUTO
58340 + help
58341 + If you say Y here, TTY sniffers and other malicious monitoring
58342 + programs implemented through ptrace will be defeated. If you
58343 + have been using the RBAC system, this option has already been
58344 + enabled for several years for all users, with the ability to make
58345 + fine-grained exceptions.
58346 +
58347 + This option only affects the ability of non-root users to ptrace
58348 + processes that are not a descendent of the ptracing process.
58349 + This means that strace ./binary and gdb ./binary will still work,
58350 + but attaching to arbitrary processes will not. If the sysctl
58351 + option is enabled, a sysctl option with name "harden_ptrace" is
58352 + created.
58353 +
58354 +config GRKERNSEC_PTRACE_READEXEC
58355 + bool "Require read access to ptrace sensitive binaries"
58356 + default y if GRKERNSEC_CONFIG_AUTO
58357 + help
58358 + If you say Y here, unprivileged users will not be able to ptrace unreadable
58359 + binaries. This option is useful in environments that
58360 + remove the read bits (e.g. file mode 4711) from suid binaries to
58361 + prevent infoleaking of their contents. This option adds
58362 + consistency to the use of that file mode, as the binary could normally
58363 + be read out when run without privileges while ptracing.
58364 +
58365 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
58366 + is created.
58367 +
58368 +config GRKERNSEC_SETXID
58369 + bool "Enforce consistent multithreaded privileges"
58370 + default y if GRKERNSEC_CONFIG_AUTO
58371 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
58372 + help
58373 + If you say Y here, a change from a root uid to a non-root uid
58374 + in a multithreaded application will cause the resulting uids,
58375 + gids, supplementary groups, and capabilities in that thread
58376 + to be propagated to the other threads of the process. In most
58377 + cases this is unnecessary, as glibc will emulate this behavior
58378 + on behalf of the application. Other libcs do not act in the
58379 + same way, allowing the other threads of the process to continue
58380 + running with root privileges. If the sysctl option is enabled,
58381 + a sysctl option with name "consistent_setxid" is created.
58382 +
58383 +config GRKERNSEC_TPE
58384 + bool "Trusted Path Execution (TPE)"
58385 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
58386 + help
58387 + If you say Y here, you will be able to choose a gid to add to the
58388 + supplementary groups of users you want to mark as "untrusted."
58389 + These users will not be able to execute any files that are not in
58390 + root-owned directories writable only by root. If the sysctl option
58391 + is enabled, a sysctl option with name "tpe" is created.
58392 +
58393 +config GRKERNSEC_TPE_ALL
58394 + bool "Partially restrict all non-root users"
58395 + depends on GRKERNSEC_TPE
58396 + help
58397 + If you say Y here, all non-root users will be covered under
58398 + a weaker TPE restriction. This is separate from, and in addition to,
58399 + the main TPE options that you have selected elsewhere. Thus, if a
58400 + "trusted" GID is chosen, this restriction applies to even that GID.
58401 + Under this restriction, all non-root users will only be allowed to
58402 + execute files in directories they own that are not group or
58403 + world-writable, or in directories owned by root and writable only by
58404 + root. If the sysctl option is enabled, a sysctl option with name
58405 + "tpe_restrict_all" is created.
58406 +
58407 +config GRKERNSEC_TPE_INVERT
58408 + bool "Invert GID option"
58409 + depends on GRKERNSEC_TPE
58410 + help
58411 + If you say Y here, the group you specify in the TPE configuration will
58412 + decide what group TPE restrictions will be *disabled* for. This
58413 + option is useful if you want TPE restrictions to be applied to most
58414 + users on the system. If the sysctl option is enabled, a sysctl option
58415 + with name "tpe_invert" is created. Unlike other sysctl options, this
58416 + entry will default to on for backward-compatibility.
58417 +
58418 +config GRKERNSEC_TPE_GID
58419 + int
58420 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
58421 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
58422 +
58423 +config GRKERNSEC_TPE_UNTRUSTED_GID
58424 + int "GID for TPE-untrusted users"
58425 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
58426 + default 1005
58427 + help
58428 + Setting this GID determines what group TPE restrictions will be
58429 + *enabled* for. If the sysctl option is enabled, a sysctl option
58430 + with name "tpe_gid" is created.
58431 +
58432 +config GRKERNSEC_TPE_TRUSTED_GID
58433 + int "GID for TPE-trusted users"
58434 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
58435 + default 1005
58436 + help
58437 + Setting this GID determines what group TPE restrictions will be
58438 + *disabled* for. If the sysctl option is enabled, a sysctl option
58439 + with name "tpe_gid" is created.
58440 +
58441 +endmenu
58442 +menu "Network Protections"
58443 +depends on GRKERNSEC
58444 +
58445 +config GRKERNSEC_RANDNET
58446 + bool "Larger entropy pools"
58447 + default y if GRKERNSEC_CONFIG_AUTO
58448 + help
58449 + If you say Y here, the entropy pools used for many features of Linux
58450 + and grsecurity will be doubled in size. Since several grsecurity
58451 + features use additional randomness, it is recommended that you say Y
58452 + here. Saying Y here has a similar effect as modifying
58453 + /proc/sys/kernel/random/poolsize.
58454 +
58455 +config GRKERNSEC_BLACKHOLE
58456 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
58457 + default y if GRKERNSEC_CONFIG_AUTO
58458 + depends on NET
58459 + help
58460 + If you say Y here, neither TCP resets nor ICMP
58461 + destination-unreachable packets will be sent in response to packets
58462 + sent to ports for which no associated listening process exists.
58463 + This feature supports both IPV4 and IPV6 and exempts the
58464 + loopback interface from blackholing. Enabling this feature
58465 + makes a host more resilient to DoS attacks and reduces network
58466 + visibility against scanners.
58467 +
58468 + The blackhole feature as-implemented is equivalent to the FreeBSD
58469 + blackhole feature, as it prevents RST responses to all packets, not
58470 + just SYNs. Under most application behavior this causes no
58471 + problems, but applications (like haproxy) may not close certain
58472 + connections in a way that cleanly terminates them on the remote
58473 + end, leaving the remote host in LAST_ACK state. Because of this
58474 + side-effect and to prevent intentional LAST_ACK DoSes, this
58475 + feature also adds automatic mitigation against such attacks.
58476 + The mitigation drastically reduces the amount of time a socket
58477 + can spend in LAST_ACK state. If you're using haproxy and not
58478 + all servers it connects to have this option enabled, consider
58479 + disabling this feature on the haproxy host.
58480 +
58481 + If the sysctl option is enabled, two sysctl options with names
58482 + "ip_blackhole" and "lastack_retries" will be created.
58483 + While "ip_blackhole" takes the standard zero/non-zero on/off
58484 + toggle, "lastack_retries" uses the same kinds of values as
58485 + "tcp_retries1" and "tcp_retries2". The default value of 4
58486 + prevents a socket from lasting more than 45 seconds in LAST_ACK
58487 + state.
58488 +
58489 +config GRKERNSEC_NO_SIMULT_CONNECT
58490 + bool "Disable TCP Simultaneous Connect"
58491 + default y if GRKERNSEC_CONFIG_AUTO
58492 + depends on NET
58493 + help
58494 + If you say Y here, a feature by Willy Tarreau will be enabled that
58495 + removes a weakness in Linux's strict implementation of TCP that
58496 + allows two clients to connect to each other without either entering
58497 + a listening state. The weakness allows an attacker to easily prevent
58498 + a client from connecting to a known server provided the source port
58499 + for the connection is guessed correctly.
58500 +
58501 + As the weakness could be used to prevent an antivirus or IPS from
58502 + fetching updates, or prevent an SSL gateway from fetching a CRL,
58503 + it should be eliminated by enabling this option. Though Linux is
58504 + one of few operating systems supporting simultaneous connect, it
58505 + has no legitimate use in practice and is rarely supported by firewalls.
58506 +
58507 +config GRKERNSEC_SOCKET
58508 + bool "Socket restrictions"
58509 + depends on NET
58510 + help
58511 + If you say Y here, you will be able to choose from several options.
58512 + If you assign a GID on your system and add it to the supplementary
58513 + groups of users you want to restrict socket access to, this patch
58514 + will perform up to three things, based on the option(s) you choose.
58515 +
58516 +config GRKERNSEC_SOCKET_ALL
58517 + bool "Deny any sockets to group"
58518 + depends on GRKERNSEC_SOCKET
58519 + help
58520 + If you say Y here, you will be able to choose a GID of whose users will
58521 + be unable to connect to other hosts from your machine or run server
58522 + applications from your machine. If the sysctl option is enabled, a
58523 + sysctl option with name "socket_all" is created.
58524 +
58525 +config GRKERNSEC_SOCKET_ALL_GID
58526 + int "GID to deny all sockets for"
58527 + depends on GRKERNSEC_SOCKET_ALL
58528 + default 1004
58529 + help
58530 + Here you can choose the GID to disable socket access for. Remember to
58531 + add the users you want socket access disabled for to the GID
58532 + specified here. If the sysctl option is enabled, a sysctl option
58533 + with name "socket_all_gid" is created.
58534 +
58535 +config GRKERNSEC_SOCKET_CLIENT
58536 + bool "Deny client sockets to group"
58537 + depends on GRKERNSEC_SOCKET
58538 + help
58539 + If you say Y here, you will be able to choose a GID of whose users will
58540 + be unable to connect to other hosts from your machine, but will be
58541 + able to run servers. If this option is enabled, all users in the group
58542 + you specify will have to use passive mode when initiating ftp transfers
58543 + from the shell on your machine. If the sysctl option is enabled, a
58544 + sysctl option with name "socket_client" is created.
58545 +
58546 +config GRKERNSEC_SOCKET_CLIENT_GID
58547 + int "GID to deny client sockets for"
58548 + depends on GRKERNSEC_SOCKET_CLIENT
58549 + default 1003
58550 + help
58551 + Here you can choose the GID to disable client socket access for.
58552 + Remember to add the users you want client socket access disabled for to
58553 + the GID specified here. If the sysctl option is enabled, a sysctl
58554 + option with name "socket_client_gid" is created.
58555 +
58556 +config GRKERNSEC_SOCKET_SERVER
58557 + bool "Deny server sockets to group"
58558 + depends on GRKERNSEC_SOCKET
58559 + help
58560 + If you say Y here, you will be able to choose a GID of whose users will
58561 + be unable to run server applications from your machine. If the sysctl
58562 + option is enabled, a sysctl option with name "socket_server" is created.
58563 +
58564 +config GRKERNSEC_SOCKET_SERVER_GID
58565 + int "GID to deny server sockets for"
58566 + depends on GRKERNSEC_SOCKET_SERVER
58567 + default 1002
58568 + help
58569 + Here you can choose the GID to disable server socket access for.
58570 + Remember to add the users you want server socket access disabled for to
58571 + the GID specified here. If the sysctl option is enabled, a sysctl
58572 + option with name "socket_server_gid" is created.
58573 +
58574 +endmenu
58575 +menu "Sysctl Support"
58576 +depends on GRKERNSEC && SYSCTL
58577 +
58578 +config GRKERNSEC_SYSCTL
58579 + bool "Sysctl support"
58580 + default y if GRKERNSEC_CONFIG_AUTO
58581 + help
58582 + If you say Y here, you will be able to change the options that
58583 + grsecurity runs with at bootup, without having to recompile your
58584 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
58585 + to enable (1) or disable (0) various features. All the sysctl entries
58586 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58587 + All features enabled in the kernel configuration are disabled at boot
58588 + if you do not say Y to the "Turn on features by default" option.
58589 + All options should be set at startup, and the grsec_lock entry should
58590 + be set to a non-zero value after all the options are set.
58591 + *THIS IS EXTREMELY IMPORTANT*
58592 +
58593 +config GRKERNSEC_SYSCTL_DISTRO
58594 + bool "Extra sysctl support for distro makers (READ HELP)"
58595 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58596 + help
58597 + If you say Y here, additional sysctl options will be created
58598 + for features that affect processes running as root. Therefore,
58599 + it is critical when using this option that the grsec_lock entry be
58600 + enabled after boot. Only distros with prebuilt kernel packages
58601 + with this option enabled that can ensure grsec_lock is enabled
58602 + after boot should use this option.
58603 + *Failure to set grsec_lock after boot makes all grsec features
58604 + this option covers useless*
58605 +
58606 + Currently this option creates the following sysctl entries:
58607 + "Disable Privileged I/O": "disable_priv_io"
58608 +
58609 +config GRKERNSEC_SYSCTL_ON
58610 + bool "Turn on features by default"
58611 + default y if GRKERNSEC_CONFIG_AUTO
58612 + depends on GRKERNSEC_SYSCTL
58613 + help
58614 + If you say Y here, instead of having all features enabled in the
58615 + kernel configuration disabled at boot time, the features will be
58616 + enabled at boot time. It is recommended you say Y here unless
58617 + there is some reason you would want all sysctl-tunable features to
58618 + be disabled by default. As mentioned elsewhere, it is important
58619 + to enable the grsec_lock entry once you have finished modifying
58620 + the sysctl entries.
58621 +
58622 +endmenu
58623 +menu "Logging Options"
58624 +depends on GRKERNSEC
58625 +
58626 +config GRKERNSEC_FLOODTIME
58627 + int "Seconds in between log messages (minimum)"
58628 + default 10
58629 + help
58630 + This option allows you to enforce the number of seconds between
58631 + grsecurity log messages. The default should be suitable for most
58632 + people, however, if you choose to change it, choose a value small enough
58633 + to allow informative logs to be produced, but large enough to
58634 + prevent flooding.
58635 +
58636 +config GRKERNSEC_FLOODBURST
58637 + int "Number of messages in a burst (maximum)"
58638 + default 6
58639 + help
58640 + This option allows you to choose the maximum number of messages allowed
58641 + within the flood time interval you chose in a separate option. The
58642 + default should be suitable for most people, however if you find that
58643 + many of your logs are being interpreted as flooding, you may want to
58644 + raise this value.
58645 +
58646 +endmenu
58647 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58648 new file mode 100644
58649 index 0000000..1b9afa9
58650 --- /dev/null
58651 +++ b/grsecurity/Makefile
58652 @@ -0,0 +1,38 @@
58653 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58654 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58655 +# into an RBAC system
58656 +#
58657 +# All code in this directory and various hooks inserted throughout the kernel
58658 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58659 +# under the GPL v2 or higher
58660 +
58661 +KBUILD_CFLAGS += -Werror
58662 +
58663 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58664 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58665 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58666 +
58667 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58668 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58669 + gracl_learn.o grsec_log.o
58670 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58671 +
58672 +ifdef CONFIG_NET
58673 +obj-y += grsec_sock.o
58674 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58675 +endif
58676 +
58677 +ifndef CONFIG_GRKERNSEC
58678 +obj-y += grsec_disabled.o
58679 +endif
58680 +
58681 +ifdef CONFIG_GRKERNSEC_HIDESYM
58682 +extra-y := grsec_hidesym.o
58683 +$(obj)/grsec_hidesym.o:
58684 + @-chmod -f 500 /boot
58685 + @-chmod -f 500 /lib/modules
58686 + @-chmod -f 500 /lib64/modules
58687 + @-chmod -f 500 /lib32/modules
58688 + @-chmod -f 700 .
58689 + @echo ' grsec: protected kernel image paths'
58690 +endif
58691 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58692 new file mode 100644
58693 index 0000000..b306b36
58694 --- /dev/null
58695 +++ b/grsecurity/gracl.c
58696 @@ -0,0 +1,4071 @@
58697 +#include <linux/kernel.h>
58698 +#include <linux/module.h>
58699 +#include <linux/sched.h>
58700 +#include <linux/mm.h>
58701 +#include <linux/file.h>
58702 +#include <linux/fs.h>
58703 +#include <linux/namei.h>
58704 +#include <linux/mount.h>
58705 +#include <linux/tty.h>
58706 +#include <linux/proc_fs.h>
58707 +#include <linux/lglock.h>
58708 +#include <linux/slab.h>
58709 +#include <linux/vmalloc.h>
58710 +#include <linux/types.h>
58711 +#include <linux/sysctl.h>
58712 +#include <linux/netdevice.h>
58713 +#include <linux/ptrace.h>
58714 +#include <linux/gracl.h>
58715 +#include <linux/gralloc.h>
58716 +#include <linux/security.h>
58717 +#include <linux/grinternal.h>
58718 +#include <linux/pid_namespace.h>
58719 +#include <linux/stop_machine.h>
58720 +#include <linux/fdtable.h>
58721 +#include <linux/percpu.h>
58722 +#include <linux/lglock.h>
58723 +#include <linux/hugetlb.h>
58724 +#include <linux/posix-timers.h>
58725 +#include "../fs/mount.h"
58726 +
58727 +#include <asm/uaccess.h>
58728 +#include <asm/errno.h>
58729 +#include <asm/mman.h>
58730 +
58731 +extern struct lglock vfsmount_lock;
58732 +
58733 +static struct acl_role_db acl_role_set;
58734 +static struct name_db name_set;
58735 +static struct inodev_db inodev_set;
58736 +
58737 +/* for keeping track of userspace pointers used for subjects, so we
58738 + can share references in the kernel as well
58739 +*/
58740 +
58741 +static struct path real_root;
58742 +
58743 +static struct acl_subj_map_db subj_map_set;
58744 +
58745 +static struct acl_role_label *default_role;
58746 +
58747 +static struct acl_role_label *role_list;
58748 +
58749 +static u16 acl_sp_role_value;
58750 +
58751 +extern char *gr_shared_page[4];
58752 +static DEFINE_MUTEX(gr_dev_mutex);
58753 +DEFINE_RWLOCK(gr_inode_lock);
58754 +
58755 +struct gr_arg *gr_usermode;
58756 +
58757 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58758 +
58759 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58760 +extern void gr_clear_learn_entries(void);
58761 +
58762 +unsigned char *gr_system_salt;
58763 +unsigned char *gr_system_sum;
58764 +
58765 +static struct sprole_pw **acl_special_roles = NULL;
58766 +static __u16 num_sprole_pws = 0;
58767 +
58768 +static struct acl_role_label *kernel_role = NULL;
58769 +
58770 +static unsigned int gr_auth_attempts = 0;
58771 +static unsigned long gr_auth_expires = 0UL;
58772 +
58773 +#ifdef CONFIG_NET
58774 +extern struct vfsmount *sock_mnt;
58775 +#endif
58776 +
58777 +extern struct vfsmount *pipe_mnt;
58778 +extern struct vfsmount *shm_mnt;
58779 +
58780 +#ifdef CONFIG_HUGETLBFS
58781 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58782 +#endif
58783 +
58784 +static struct acl_object_label *fakefs_obj_rw;
58785 +static struct acl_object_label *fakefs_obj_rwx;
58786 +
58787 +extern int gr_init_uidset(void);
58788 +extern void gr_free_uidset(void);
58789 +extern void gr_remove_uid(uid_t uid);
58790 +extern int gr_find_uid(uid_t uid);
58791 +
58792 +__inline__ int
58793 +gr_acl_is_enabled(void)
58794 +{
58795 + return (gr_status & GR_READY);
58796 +}
58797 +
58798 +#ifdef CONFIG_BTRFS_FS
58799 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
58800 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
58801 +#endif
58802 +
58803 +static inline dev_t __get_dev(const struct dentry *dentry)
58804 +{
58805 +#ifdef CONFIG_BTRFS_FS
58806 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
58807 + return get_btrfs_dev_from_inode(dentry->d_inode);
58808 + else
58809 +#endif
58810 + return dentry->d_inode->i_sb->s_dev;
58811 +}
58812 +
58813 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58814 +{
58815 + return __get_dev(dentry);
58816 +}
58817 +
58818 +static char gr_task_roletype_to_char(struct task_struct *task)
58819 +{
58820 + switch (task->role->roletype &
58821 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58822 + GR_ROLE_SPECIAL)) {
58823 + case GR_ROLE_DEFAULT:
58824 + return 'D';
58825 + case GR_ROLE_USER:
58826 + return 'U';
58827 + case GR_ROLE_GROUP:
58828 + return 'G';
58829 + case GR_ROLE_SPECIAL:
58830 + return 'S';
58831 + }
58832 +
58833 + return 'X';
58834 +}
58835 +
58836 +char gr_roletype_to_char(void)
58837 +{
58838 + return gr_task_roletype_to_char(current);
58839 +}
58840 +
58841 +__inline__ int
58842 +gr_acl_tpe_check(void)
58843 +{
58844 + if (unlikely(!(gr_status & GR_READY)))
58845 + return 0;
58846 + if (current->role->roletype & GR_ROLE_TPE)
58847 + return 1;
58848 + else
58849 + return 0;
58850 +}
58851 +
58852 +int
58853 +gr_handle_rawio(const struct inode *inode)
58854 +{
58855 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58856 + if (inode && S_ISBLK(inode->i_mode) &&
58857 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58858 + !capable(CAP_SYS_RAWIO))
58859 + return 1;
58860 +#endif
58861 + return 0;
58862 +}
58863 +
58864 +static int
58865 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58866 +{
58867 + if (likely(lena != lenb))
58868 + return 0;
58869 +
58870 + return !memcmp(a, b, lena);
58871 +}
58872 +
58873 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58874 +{
58875 + *buflen -= namelen;
58876 + if (*buflen < 0)
58877 + return -ENAMETOOLONG;
58878 + *buffer -= namelen;
58879 + memcpy(*buffer, str, namelen);
58880 + return 0;
58881 +}
58882 +
58883 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58884 +{
58885 + return prepend(buffer, buflen, name->name, name->len);
58886 +}
58887 +
58888 +static int prepend_path(const struct path *path, struct path *root,
58889 + char **buffer, int *buflen)
58890 +{
58891 + struct dentry *dentry = path->dentry;
58892 + struct vfsmount *vfsmnt = path->mnt;
58893 + struct mount *mnt = real_mount(vfsmnt);
58894 + bool slash = false;
58895 + int error = 0;
58896 +
58897 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58898 + struct dentry * parent;
58899 +
58900 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58901 + /* Global root? */
58902 + if (!mnt_has_parent(mnt)) {
58903 + goto out;
58904 + }
58905 + dentry = mnt->mnt_mountpoint;
58906 + mnt = mnt->mnt_parent;
58907 + vfsmnt = &mnt->mnt;
58908 + continue;
58909 + }
58910 + parent = dentry->d_parent;
58911 + prefetch(parent);
58912 + spin_lock(&dentry->d_lock);
58913 + error = prepend_name(buffer, buflen, &dentry->d_name);
58914 + spin_unlock(&dentry->d_lock);
58915 + if (!error)
58916 + error = prepend(buffer, buflen, "/", 1);
58917 + if (error)
58918 + break;
58919 +
58920 + slash = true;
58921 + dentry = parent;
58922 + }
58923 +
58924 +out:
58925 + if (!error && !slash)
58926 + error = prepend(buffer, buflen, "/", 1);
58927 +
58928 + return error;
58929 +}
58930 +
58931 +/* this must be called with vfsmount_lock and rename_lock held */
58932 +
58933 +static char *__our_d_path(const struct path *path, struct path *root,
58934 + char *buf, int buflen)
58935 +{
58936 + char *res = buf + buflen;
58937 + int error;
58938 +
58939 + prepend(&res, &buflen, "\0", 1);
58940 + error = prepend_path(path, root, &res, &buflen);
58941 + if (error)
58942 + return ERR_PTR(error);
58943 +
58944 + return res;
58945 +}
58946 +
58947 +static char *
58948 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58949 +{
58950 + char *retval;
58951 +
58952 + retval = __our_d_path(path, root, buf, buflen);
58953 + if (unlikely(IS_ERR(retval)))
58954 + retval = strcpy(buf, "<path too long>");
58955 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58956 + retval[1] = '\0';
58957 +
58958 + return retval;
58959 +}
58960 +
58961 +static char *
58962 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58963 + char *buf, int buflen)
58964 +{
58965 + struct path path;
58966 + char *res;
58967 +
58968 + path.dentry = (struct dentry *)dentry;
58969 + path.mnt = (struct vfsmount *)vfsmnt;
58970 +
58971 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58972 + by the RBAC system */
58973 + res = gen_full_path(&path, &real_root, buf, buflen);
58974 +
58975 + return res;
58976 +}
58977 +
58978 +static char *
58979 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58980 + char *buf, int buflen)
58981 +{
58982 + char *res;
58983 + struct path path;
58984 + struct path root;
58985 + struct task_struct *reaper = init_pid_ns.child_reaper;
58986 +
58987 + path.dentry = (struct dentry *)dentry;
58988 + path.mnt = (struct vfsmount *)vfsmnt;
58989 +
58990 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58991 + get_fs_root(reaper->fs, &root);
58992 +
58993 + br_read_lock(&vfsmount_lock);
58994 + write_seqlock(&rename_lock);
58995 + res = gen_full_path(&path, &root, buf, buflen);
58996 + write_sequnlock(&rename_lock);
58997 + br_read_unlock(&vfsmount_lock);
58998 +
58999 + path_put(&root);
59000 + return res;
59001 +}
59002 +
59003 +static char *
59004 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
59005 +{
59006 + char *ret;
59007 + br_read_lock(&vfsmount_lock);
59008 + write_seqlock(&rename_lock);
59009 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
59010 + PAGE_SIZE);
59011 + write_sequnlock(&rename_lock);
59012 + br_read_unlock(&vfsmount_lock);
59013 + return ret;
59014 +}
59015 +
59016 +static char *
59017 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
59018 +{
59019 + char *ret;
59020 + char *buf;
59021 + int buflen;
59022 +
59023 + br_read_lock(&vfsmount_lock);
59024 + write_seqlock(&rename_lock);
59025 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
59026 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
59027 + buflen = (int)(ret - buf);
59028 + if (buflen >= 5)
59029 + prepend(&ret, &buflen, "/proc", 5);
59030 + else
59031 + ret = strcpy(buf, "<path too long>");
59032 + write_sequnlock(&rename_lock);
59033 + br_read_unlock(&vfsmount_lock);
59034 + return ret;
59035 +}
59036 +
59037 +char *
59038 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
59039 +{
59040 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
59041 + PAGE_SIZE);
59042 +}
59043 +
59044 +char *
59045 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
59046 +{
59047 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
59048 + PAGE_SIZE);
59049 +}
59050 +
59051 +char *
59052 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
59053 +{
59054 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
59055 + PAGE_SIZE);
59056 +}
59057 +
59058 +char *
59059 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
59060 +{
59061 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
59062 + PAGE_SIZE);
59063 +}
59064 +
59065 +char *
59066 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
59067 +{
59068 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
59069 + PAGE_SIZE);
59070 +}
59071 +
59072 +__inline__ __u32
59073 +to_gr_audit(const __u32 reqmode)
59074 +{
59075 + /* masks off auditable permission flags, then shifts them to create
59076 + auditing flags, and adds the special case of append auditing if
59077 + we're requesting write */
59078 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
59079 +}
59080 +
59081 +struct acl_subject_label *
59082 +lookup_subject_map(const struct acl_subject_label *userp)
59083 +{
59084 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
59085 + struct subject_map *match;
59086 +
59087 + match = subj_map_set.s_hash[index];
59088 +
59089 + while (match && match->user != userp)
59090 + match = match->next;
59091 +
59092 + if (match != NULL)
59093 + return match->kernel;
59094 + else
59095 + return NULL;
59096 +}
59097 +
59098 +static void
59099 +insert_subj_map_entry(struct subject_map *subjmap)
59100 +{
59101 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
59102 + struct subject_map **curr;
59103 +
59104 + subjmap->prev = NULL;
59105 +
59106 + curr = &subj_map_set.s_hash[index];
59107 + if (*curr != NULL)
59108 + (*curr)->prev = subjmap;
59109 +
59110 + subjmap->next = *curr;
59111 + *curr = subjmap;
59112 +
59113 + return;
59114 +}
59115 +
59116 +static struct acl_role_label *
59117 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
59118 + const gid_t gid)
59119 +{
59120 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
59121 + struct acl_role_label *match;
59122 + struct role_allowed_ip *ipp;
59123 + unsigned int x;
59124 + u32 curr_ip = task->signal->curr_ip;
59125 +
59126 + task->signal->saved_ip = curr_ip;
59127 +
59128 + match = acl_role_set.r_hash[index];
59129 +
59130 + while (match) {
59131 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
59132 + for (x = 0; x < match->domain_child_num; x++) {
59133 + if (match->domain_children[x] == uid)
59134 + goto found;
59135 + }
59136 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
59137 + break;
59138 + match = match->next;
59139 + }
59140 +found:
59141 + if (match == NULL) {
59142 + try_group:
59143 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
59144 + match = acl_role_set.r_hash[index];
59145 +
59146 + while (match) {
59147 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
59148 + for (x = 0; x < match->domain_child_num; x++) {
59149 + if (match->domain_children[x] == gid)
59150 + goto found2;
59151 + }
59152 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
59153 + break;
59154 + match = match->next;
59155 + }
59156 +found2:
59157 + if (match == NULL)
59158 + match = default_role;
59159 + if (match->allowed_ips == NULL)
59160 + return match;
59161 + else {
59162 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
59163 + if (likely
59164 + ((ntohl(curr_ip) & ipp->netmask) ==
59165 + (ntohl(ipp->addr) & ipp->netmask)))
59166 + return match;
59167 + }
59168 + match = default_role;
59169 + }
59170 + } else if (match->allowed_ips == NULL) {
59171 + return match;
59172 + } else {
59173 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
59174 + if (likely
59175 + ((ntohl(curr_ip) & ipp->netmask) ==
59176 + (ntohl(ipp->addr) & ipp->netmask)))
59177 + return match;
59178 + }
59179 + goto try_group;
59180 + }
59181 +
59182 + return match;
59183 +}
59184 +
59185 +struct acl_subject_label *
59186 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
59187 + const struct acl_role_label *role)
59188 +{
59189 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
59190 + struct acl_subject_label *match;
59191 +
59192 + match = role->subj_hash[index];
59193 +
59194 + while (match && (match->inode != ino || match->device != dev ||
59195 + (match->mode & GR_DELETED))) {
59196 + match = match->next;
59197 + }
59198 +
59199 + if (match && !(match->mode & GR_DELETED))
59200 + return match;
59201 + else
59202 + return NULL;
59203 +}
59204 +
59205 +struct acl_subject_label *
59206 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
59207 + const struct acl_role_label *role)
59208 +{
59209 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
59210 + struct acl_subject_label *match;
59211 +
59212 + match = role->subj_hash[index];
59213 +
59214 + while (match && (match->inode != ino || match->device != dev ||
59215 + !(match->mode & GR_DELETED))) {
59216 + match = match->next;
59217 + }
59218 +
59219 + if (match && (match->mode & GR_DELETED))
59220 + return match;
59221 + else
59222 + return NULL;
59223 +}
59224 +
59225 +static struct acl_object_label *
59226 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
59227 + const struct acl_subject_label *subj)
59228 +{
59229 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
59230 + struct acl_object_label *match;
59231 +
59232 + match = subj->obj_hash[index];
59233 +
59234 + while (match && (match->inode != ino || match->device != dev ||
59235 + (match->mode & GR_DELETED))) {
59236 + match = match->next;
59237 + }
59238 +
59239 + if (match && !(match->mode & GR_DELETED))
59240 + return match;
59241 + else
59242 + return NULL;
59243 +}
59244 +
59245 +static struct acl_object_label *
59246 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
59247 + const struct acl_subject_label *subj)
59248 +{
59249 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
59250 + struct acl_object_label *match;
59251 +
59252 + match = subj->obj_hash[index];
59253 +
59254 + while (match && (match->inode != ino || match->device != dev ||
59255 + !(match->mode & GR_DELETED))) {
59256 + match = match->next;
59257 + }
59258 +
59259 + if (match && (match->mode & GR_DELETED))
59260 + return match;
59261 +
59262 + match = subj->obj_hash[index];
59263 +
59264 + while (match && (match->inode != ino || match->device != dev ||
59265 + (match->mode & GR_DELETED))) {
59266 + match = match->next;
59267 + }
59268 +
59269 + if (match && !(match->mode & GR_DELETED))
59270 + return match;
59271 + else
59272 + return NULL;
59273 +}
59274 +
59275 +static struct name_entry *
59276 +lookup_name_entry(const char *name)
59277 +{
59278 + unsigned int len = strlen(name);
59279 + unsigned int key = full_name_hash(name, len);
59280 + unsigned int index = key % name_set.n_size;
59281 + struct name_entry *match;
59282 +
59283 + match = name_set.n_hash[index];
59284 +
59285 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
59286 + match = match->next;
59287 +
59288 + return match;
59289 +}
59290 +
59291 +static struct name_entry *
59292 +lookup_name_entry_create(const char *name)
59293 +{
59294 + unsigned int len = strlen(name);
59295 + unsigned int key = full_name_hash(name, len);
59296 + unsigned int index = key % name_set.n_size;
59297 + struct name_entry *match;
59298 +
59299 + match = name_set.n_hash[index];
59300 +
59301 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
59302 + !match->deleted))
59303 + match = match->next;
59304 +
59305 + if (match && match->deleted)
59306 + return match;
59307 +
59308 + match = name_set.n_hash[index];
59309 +
59310 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
59311 + match->deleted))
59312 + match = match->next;
59313 +
59314 + if (match && !match->deleted)
59315 + return match;
59316 + else
59317 + return NULL;
59318 +}
59319 +
59320 +static struct inodev_entry *
59321 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
59322 +{
59323 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
59324 + struct inodev_entry *match;
59325 +
59326 + match = inodev_set.i_hash[index];
59327 +
59328 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
59329 + match = match->next;
59330 +
59331 + return match;
59332 +}
59333 +
59334 +static void
59335 +insert_inodev_entry(struct inodev_entry *entry)
59336 +{
59337 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
59338 + inodev_set.i_size);
59339 + struct inodev_entry **curr;
59340 +
59341 + entry->prev = NULL;
59342 +
59343 + curr = &inodev_set.i_hash[index];
59344 + if (*curr != NULL)
59345 + (*curr)->prev = entry;
59346 +
59347 + entry->next = *curr;
59348 + *curr = entry;
59349 +
59350 + return;
59351 +}
59352 +
59353 +static void
59354 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
59355 +{
59356 + unsigned int index =
59357 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
59358 + struct acl_role_label **curr;
59359 + struct acl_role_label *tmp, *tmp2;
59360 +
59361 + curr = &acl_role_set.r_hash[index];
59362 +
59363 + /* simple case, slot is empty, just set it to our role */
59364 + if (*curr == NULL) {
59365 + *curr = role;
59366 + } else {
59367 + /* example:
59368 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
59369 + 2 -> 3
59370 + */
59371 + /* first check to see if we can already be reached via this slot */
59372 + tmp = *curr;
59373 + while (tmp && tmp != role)
59374 + tmp = tmp->next;
59375 + if (tmp == role) {
59376 + /* we don't need to add ourselves to this slot's chain */
59377 + return;
59378 + }
59379 + /* we need to add ourselves to this chain, two cases */
59380 + if (role->next == NULL) {
59381 + /* simple case, append the current chain to our role */
59382 + role->next = *curr;
59383 + *curr = role;
59384 + } else {
59385 + /* 1 -> 2 -> 3 -> 4
59386 + 2 -> 3 -> 4
59387 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
59388 + */
59389 + /* trickier case: walk our role's chain until we find
59390 + the role for the start of the current slot's chain */
59391 + tmp = role;
59392 + tmp2 = *curr;
59393 + while (tmp->next && tmp->next != tmp2)
59394 + tmp = tmp->next;
59395 + if (tmp->next == tmp2) {
59396 + /* from example above, we found 3, so just
59397 + replace this slot's chain with ours */
59398 + *curr = role;
59399 + } else {
59400 + /* we didn't find a subset of our role's chain
59401 + in the current slot's chain, so append their
59402 + chain to ours, and set us as the first role in
59403 + the slot's chain
59404 +
59405 + we could fold this case with the case above,
59406 + but making it explicit for clarity
59407 + */
59408 + tmp->next = tmp2;
59409 + *curr = role;
59410 + }
59411 + }
59412 + }
59413 +
59414 + return;
59415 +}
59416 +
59417 +static void
59418 +insert_acl_role_label(struct acl_role_label *role)
59419 +{
59420 + int i;
59421 +
59422 + if (role_list == NULL) {
59423 + role_list = role;
59424 + role->prev = NULL;
59425 + } else {
59426 + role->prev = role_list;
59427 + role_list = role;
59428 + }
59429 +
59430 + /* used for hash chains */
59431 + role->next = NULL;
59432 +
59433 + if (role->roletype & GR_ROLE_DOMAIN) {
59434 + for (i = 0; i < role->domain_child_num; i++)
59435 + __insert_acl_role_label(role, role->domain_children[i]);
59436 + } else
59437 + __insert_acl_role_label(role, role->uidgid);
59438 +}
59439 +
59440 +static int
59441 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
59442 +{
59443 + struct name_entry **curr, *nentry;
59444 + struct inodev_entry *ientry;
59445 + unsigned int len = strlen(name);
59446 + unsigned int key = full_name_hash(name, len);
59447 + unsigned int index = key % name_set.n_size;
59448 +
59449 + curr = &name_set.n_hash[index];
59450 +
59451 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
59452 + curr = &((*curr)->next);
59453 +
59454 + if (*curr != NULL)
59455 + return 1;
59456 +
59457 + nentry = acl_alloc(sizeof (struct name_entry));
59458 + if (nentry == NULL)
59459 + return 0;
59460 + ientry = acl_alloc(sizeof (struct inodev_entry));
59461 + if (ientry == NULL)
59462 + return 0;
59463 + ientry->nentry = nentry;
59464 +
59465 + nentry->key = key;
59466 + nentry->name = name;
59467 + nentry->inode = inode;
59468 + nentry->device = device;
59469 + nentry->len = len;
59470 + nentry->deleted = deleted;
59471 +
59472 + nentry->prev = NULL;
59473 + curr = &name_set.n_hash[index];
59474 + if (*curr != NULL)
59475 + (*curr)->prev = nentry;
59476 + nentry->next = *curr;
59477 + *curr = nentry;
59478 +
59479 + /* insert us into the table searchable by inode/dev */
59480 + insert_inodev_entry(ientry);
59481 +
59482 + return 1;
59483 +}
59484 +
59485 +static void
59486 +insert_acl_obj_label(struct acl_object_label *obj,
59487 + struct acl_subject_label *subj)
59488 +{
59489 + unsigned int index =
59490 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
59491 + struct acl_object_label **curr;
59492 +
59493 +
59494 + obj->prev = NULL;
59495 +
59496 + curr = &subj->obj_hash[index];
59497 + if (*curr != NULL)
59498 + (*curr)->prev = obj;
59499 +
59500 + obj->next = *curr;
59501 + *curr = obj;
59502 +
59503 + return;
59504 +}
59505 +
59506 +static void
59507 +insert_acl_subj_label(struct acl_subject_label *obj,
59508 + struct acl_role_label *role)
59509 +{
59510 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
59511 + struct acl_subject_label **curr;
59512 +
59513 + obj->prev = NULL;
59514 +
59515 + curr = &role->subj_hash[index];
59516 + if (*curr != NULL)
59517 + (*curr)->prev = obj;
59518 +
59519 + obj->next = *curr;
59520 + *curr = obj;
59521 +
59522 + return;
59523 +}
59524 +
59525 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
59526 +
59527 +static void *
59528 +create_table(__u32 * len, int elementsize)
59529 +{
59530 + unsigned int table_sizes[] = {
59531 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
59532 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
59533 + 4194301, 8388593, 16777213, 33554393, 67108859
59534 + };
59535 + void *newtable = NULL;
59536 + unsigned int pwr = 0;
59537 +
59538 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
59539 + table_sizes[pwr] <= *len)
59540 + pwr++;
59541 +
59542 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
59543 + return newtable;
59544 +
59545 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
59546 + newtable =
59547 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
59548 + else
59549 + newtable = vmalloc(table_sizes[pwr] * elementsize);
59550 +
59551 + *len = table_sizes[pwr];
59552 +
59553 + return newtable;
59554 +}
59555 +
59556 +static int
59557 +init_variables(const struct gr_arg *arg)
59558 +{
59559 + struct task_struct *reaper = init_pid_ns.child_reaper;
59560 + unsigned int stacksize;
59561 +
59562 + subj_map_set.s_size = arg->role_db.num_subjects;
59563 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
59564 + name_set.n_size = arg->role_db.num_objects;
59565 + inodev_set.i_size = arg->role_db.num_objects;
59566 +
59567 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
59568 + !name_set.n_size || !inodev_set.i_size)
59569 + return 1;
59570 +
59571 + if (!gr_init_uidset())
59572 + return 1;
59573 +
59574 + /* set up the stack that holds allocation info */
59575 +
59576 + stacksize = arg->role_db.num_pointers + 5;
59577 +
59578 + if (!acl_alloc_stack_init(stacksize))
59579 + return 1;
59580 +
59581 + /* grab reference for the real root dentry and vfsmount */
59582 + get_fs_root(reaper->fs, &real_root);
59583 +
59584 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59585 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59586 +#endif
59587 +
59588 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59589 + if (fakefs_obj_rw == NULL)
59590 + return 1;
59591 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59592 +
59593 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59594 + if (fakefs_obj_rwx == NULL)
59595 + return 1;
59596 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59597 +
59598 + subj_map_set.s_hash =
59599 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59600 + acl_role_set.r_hash =
59601 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59602 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59603 + inodev_set.i_hash =
59604 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59605 +
59606 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59607 + !name_set.n_hash || !inodev_set.i_hash)
59608 + return 1;
59609 +
59610 + memset(subj_map_set.s_hash, 0,
59611 + sizeof(struct subject_map *) * subj_map_set.s_size);
59612 + memset(acl_role_set.r_hash, 0,
59613 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59614 + memset(name_set.n_hash, 0,
59615 + sizeof (struct name_entry *) * name_set.n_size);
59616 + memset(inodev_set.i_hash, 0,
59617 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59618 +
59619 + return 0;
59620 +}
59621 +
59622 +/* free information not needed after startup
59623 + currently contains user->kernel pointer mappings for subjects
59624 +*/
59625 +
59626 +static void
59627 +free_init_variables(void)
59628 +{
59629 + __u32 i;
59630 +
59631 + if (subj_map_set.s_hash) {
59632 + for (i = 0; i < subj_map_set.s_size; i++) {
59633 + if (subj_map_set.s_hash[i]) {
59634 + kfree(subj_map_set.s_hash[i]);
59635 + subj_map_set.s_hash[i] = NULL;
59636 + }
59637 + }
59638 +
59639 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59640 + PAGE_SIZE)
59641 + kfree(subj_map_set.s_hash);
59642 + else
59643 + vfree(subj_map_set.s_hash);
59644 + }
59645 +
59646 + return;
59647 +}
59648 +
59649 +static void
59650 +free_variables(void)
59651 +{
59652 + struct acl_subject_label *s;
59653 + struct acl_role_label *r;
59654 + struct task_struct *task, *task2;
59655 + unsigned int x;
59656 +
59657 + gr_clear_learn_entries();
59658 +
59659 + read_lock(&tasklist_lock);
59660 + do_each_thread(task2, task) {
59661 + task->acl_sp_role = 0;
59662 + task->acl_role_id = 0;
59663 + task->acl = NULL;
59664 + task->role = NULL;
59665 + } while_each_thread(task2, task);
59666 + read_unlock(&tasklist_lock);
59667 +
59668 + /* release the reference to the real root dentry and vfsmount */
59669 + path_put(&real_root);
59670 + memset(&real_root, 0, sizeof(real_root));
59671 +
59672 + /* free all object hash tables */
59673 +
59674 + FOR_EACH_ROLE_START(r)
59675 + if (r->subj_hash == NULL)
59676 + goto next_role;
59677 + FOR_EACH_SUBJECT_START(r, s, x)
59678 + if (s->obj_hash == NULL)
59679 + break;
59680 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59681 + kfree(s->obj_hash);
59682 + else
59683 + vfree(s->obj_hash);
59684 + FOR_EACH_SUBJECT_END(s, x)
59685 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59686 + if (s->obj_hash == NULL)
59687 + break;
59688 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59689 + kfree(s->obj_hash);
59690 + else
59691 + vfree(s->obj_hash);
59692 + FOR_EACH_NESTED_SUBJECT_END(s)
59693 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59694 + kfree(r->subj_hash);
59695 + else
59696 + vfree(r->subj_hash);
59697 + r->subj_hash = NULL;
59698 +next_role:
59699 + FOR_EACH_ROLE_END(r)
59700 +
59701 + acl_free_all();
59702 +
59703 + if (acl_role_set.r_hash) {
59704 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59705 + PAGE_SIZE)
59706 + kfree(acl_role_set.r_hash);
59707 + else
59708 + vfree(acl_role_set.r_hash);
59709 + }
59710 + if (name_set.n_hash) {
59711 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59712 + PAGE_SIZE)
59713 + kfree(name_set.n_hash);
59714 + else
59715 + vfree(name_set.n_hash);
59716 + }
59717 +
59718 + if (inodev_set.i_hash) {
59719 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59720 + PAGE_SIZE)
59721 + kfree(inodev_set.i_hash);
59722 + else
59723 + vfree(inodev_set.i_hash);
59724 + }
59725 +
59726 + gr_free_uidset();
59727 +
59728 + memset(&name_set, 0, sizeof (struct name_db));
59729 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59730 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59731 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59732 +
59733 + default_role = NULL;
59734 + kernel_role = NULL;
59735 + role_list = NULL;
59736 +
59737 + return;
59738 +}
59739 +
59740 +static __u32
59741 +count_user_objs(struct acl_object_label *userp)
59742 +{
59743 + struct acl_object_label o_tmp;
59744 + __u32 num = 0;
59745 +
59746 + while (userp) {
59747 + if (copy_from_user(&o_tmp, userp,
59748 + sizeof (struct acl_object_label)))
59749 + break;
59750 +
59751 + userp = o_tmp.prev;
59752 + num++;
59753 + }
59754 +
59755 + return num;
59756 +}
59757 +
59758 +static struct acl_subject_label *
59759 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59760 +
59761 +static int
59762 +copy_user_glob(struct acl_object_label *obj)
59763 +{
59764 + struct acl_object_label *g_tmp, **guser;
59765 + unsigned int len;
59766 + char *tmp;
59767 +
59768 + if (obj->globbed == NULL)
59769 + return 0;
59770 +
59771 + guser = &obj->globbed;
59772 + while (*guser) {
59773 + g_tmp = (struct acl_object_label *)
59774 + acl_alloc(sizeof (struct acl_object_label));
59775 + if (g_tmp == NULL)
59776 + return -ENOMEM;
59777 +
59778 + if (copy_from_user(g_tmp, *guser,
59779 + sizeof (struct acl_object_label)))
59780 + return -EFAULT;
59781 +
59782 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59783 +
59784 + if (!len || len >= PATH_MAX)
59785 + return -EINVAL;
59786 +
59787 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59788 + return -ENOMEM;
59789 +
59790 + if (copy_from_user(tmp, g_tmp->filename, len))
59791 + return -EFAULT;
59792 + tmp[len-1] = '\0';
59793 + g_tmp->filename = tmp;
59794 +
59795 + *guser = g_tmp;
59796 + guser = &(g_tmp->next);
59797 + }
59798 +
59799 + return 0;
59800 +}
59801 +
59802 +static int
59803 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59804 + struct acl_role_label *role)
59805 +{
59806 + struct acl_object_label *o_tmp;
59807 + unsigned int len;
59808 + int ret;
59809 + char *tmp;
59810 +
59811 + while (userp) {
59812 + if ((o_tmp = (struct acl_object_label *)
59813 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59814 + return -ENOMEM;
59815 +
59816 + if (copy_from_user(o_tmp, userp,
59817 + sizeof (struct acl_object_label)))
59818 + return -EFAULT;
59819 +
59820 + userp = o_tmp->prev;
59821 +
59822 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59823 +
59824 + if (!len || len >= PATH_MAX)
59825 + return -EINVAL;
59826 +
59827 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59828 + return -ENOMEM;
59829 +
59830 + if (copy_from_user(tmp, o_tmp->filename, len))
59831 + return -EFAULT;
59832 + tmp[len-1] = '\0';
59833 + o_tmp->filename = tmp;
59834 +
59835 + insert_acl_obj_label(o_tmp, subj);
59836 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59837 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59838 + return -ENOMEM;
59839 +
59840 + ret = copy_user_glob(o_tmp);
59841 + if (ret)
59842 + return ret;
59843 +
59844 + if (o_tmp->nested) {
59845 + int already_copied;
59846 +
59847 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59848 + if (IS_ERR(o_tmp->nested))
59849 + return PTR_ERR(o_tmp->nested);
59850 +
59851 + /* insert into nested subject list if we haven't copied this one yet
59852 + to prevent duplicate entries */
59853 + if (!already_copied) {
59854 + o_tmp->nested->next = role->hash->first;
59855 + role->hash->first = o_tmp->nested;
59856 + }
59857 + }
59858 + }
59859 +
59860 + return 0;
59861 +}
59862 +
59863 +static __u32
59864 +count_user_subjs(struct acl_subject_label *userp)
59865 +{
59866 + struct acl_subject_label s_tmp;
59867 + __u32 num = 0;
59868 +
59869 + while (userp) {
59870 + if (copy_from_user(&s_tmp, userp,
59871 + sizeof (struct acl_subject_label)))
59872 + break;
59873 +
59874 + userp = s_tmp.prev;
59875 + }
59876 +
59877 + return num;
59878 +}
59879 +
59880 +static int
59881 +copy_user_allowedips(struct acl_role_label *rolep)
59882 +{
59883 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59884 +
59885 + ruserip = rolep->allowed_ips;
59886 +
59887 + while (ruserip) {
59888 + rlast = rtmp;
59889 +
59890 + if ((rtmp = (struct role_allowed_ip *)
59891 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59892 + return -ENOMEM;
59893 +
59894 + if (copy_from_user(rtmp, ruserip,
59895 + sizeof (struct role_allowed_ip)))
59896 + return -EFAULT;
59897 +
59898 + ruserip = rtmp->prev;
59899 +
59900 + if (!rlast) {
59901 + rtmp->prev = NULL;
59902 + rolep->allowed_ips = rtmp;
59903 + } else {
59904 + rlast->next = rtmp;
59905 + rtmp->prev = rlast;
59906 + }
59907 +
59908 + if (!ruserip)
59909 + rtmp->next = NULL;
59910 + }
59911 +
59912 + return 0;
59913 +}
59914 +
59915 +static int
59916 +copy_user_transitions(struct acl_role_label *rolep)
59917 +{
59918 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59919 +
59920 + unsigned int len;
59921 + char *tmp;
59922 +
59923 + rusertp = rolep->transitions;
59924 +
59925 + while (rusertp) {
59926 + rlast = rtmp;
59927 +
59928 + if ((rtmp = (struct role_transition *)
59929 + acl_alloc(sizeof (struct role_transition))) == NULL)
59930 + return -ENOMEM;
59931 +
59932 + if (copy_from_user(rtmp, rusertp,
59933 + sizeof (struct role_transition)))
59934 + return -EFAULT;
59935 +
59936 + rusertp = rtmp->prev;
59937 +
59938 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59939 +
59940 + if (!len || len >= GR_SPROLE_LEN)
59941 + return -EINVAL;
59942 +
59943 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59944 + return -ENOMEM;
59945 +
59946 + if (copy_from_user(tmp, rtmp->rolename, len))
59947 + return -EFAULT;
59948 + tmp[len-1] = '\0';
59949 + rtmp->rolename = tmp;
59950 +
59951 + if (!rlast) {
59952 + rtmp->prev = NULL;
59953 + rolep->transitions = rtmp;
59954 + } else {
59955 + rlast->next = rtmp;
59956 + rtmp->prev = rlast;
59957 + }
59958 +
59959 + if (!rusertp)
59960 + rtmp->next = NULL;
59961 + }
59962 +
59963 + return 0;
59964 +}
59965 +
59966 +static struct acl_subject_label *
59967 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59968 +{
59969 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59970 + unsigned int len;
59971 + char *tmp;
59972 + __u32 num_objs;
59973 + struct acl_ip_label **i_tmp, *i_utmp2;
59974 + struct gr_hash_struct ghash;
59975 + struct subject_map *subjmap;
59976 + unsigned int i_num;
59977 + int err;
59978 +
59979 + if (already_copied != NULL)
59980 + *already_copied = 0;
59981 +
59982 + s_tmp = lookup_subject_map(userp);
59983 +
59984 + /* we've already copied this subject into the kernel, just return
59985 + the reference to it, and don't copy it over again
59986 + */
59987 + if (s_tmp) {
59988 + if (already_copied != NULL)
59989 + *already_copied = 1;
59990 + return(s_tmp);
59991 + }
59992 +
59993 + if ((s_tmp = (struct acl_subject_label *)
59994 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59995 + return ERR_PTR(-ENOMEM);
59996 +
59997 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59998 + if (subjmap == NULL)
59999 + return ERR_PTR(-ENOMEM);
60000 +
60001 + subjmap->user = userp;
60002 + subjmap->kernel = s_tmp;
60003 + insert_subj_map_entry(subjmap);
60004 +
60005 + if (copy_from_user(s_tmp, userp,
60006 + sizeof (struct acl_subject_label)))
60007 + return ERR_PTR(-EFAULT);
60008 +
60009 + len = strnlen_user(s_tmp->filename, PATH_MAX);
60010 +
60011 + if (!len || len >= PATH_MAX)
60012 + return ERR_PTR(-EINVAL);
60013 +
60014 + if ((tmp = (char *) acl_alloc(len)) == NULL)
60015 + return ERR_PTR(-ENOMEM);
60016 +
60017 + if (copy_from_user(tmp, s_tmp->filename, len))
60018 + return ERR_PTR(-EFAULT);
60019 + tmp[len-1] = '\0';
60020 + s_tmp->filename = tmp;
60021 +
60022 + if (!strcmp(s_tmp->filename, "/"))
60023 + role->root_label = s_tmp;
60024 +
60025 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
60026 + return ERR_PTR(-EFAULT);
60027 +
60028 + /* copy user and group transition tables */
60029 +
60030 + if (s_tmp->user_trans_num) {
60031 + uid_t *uidlist;
60032 +
60033 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
60034 + if (uidlist == NULL)
60035 + return ERR_PTR(-ENOMEM);
60036 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
60037 + return ERR_PTR(-EFAULT);
60038 +
60039 + s_tmp->user_transitions = uidlist;
60040 + }
60041 +
60042 + if (s_tmp->group_trans_num) {
60043 + gid_t *gidlist;
60044 +
60045 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
60046 + if (gidlist == NULL)
60047 + return ERR_PTR(-ENOMEM);
60048 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
60049 + return ERR_PTR(-EFAULT);
60050 +
60051 + s_tmp->group_transitions = gidlist;
60052 + }
60053 +
60054 + /* set up object hash table */
60055 + num_objs = count_user_objs(ghash.first);
60056 +
60057 + s_tmp->obj_hash_size = num_objs;
60058 + s_tmp->obj_hash =
60059 + (struct acl_object_label **)
60060 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
60061 +
60062 + if (!s_tmp->obj_hash)
60063 + return ERR_PTR(-ENOMEM);
60064 +
60065 + memset(s_tmp->obj_hash, 0,
60066 + s_tmp->obj_hash_size *
60067 + sizeof (struct acl_object_label *));
60068 +
60069 + /* add in objects */
60070 + err = copy_user_objs(ghash.first, s_tmp, role);
60071 +
60072 + if (err)
60073 + return ERR_PTR(err);
60074 +
60075 + /* set pointer for parent subject */
60076 + if (s_tmp->parent_subject) {
60077 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
60078 +
60079 + if (IS_ERR(s_tmp2))
60080 + return s_tmp2;
60081 +
60082 + s_tmp->parent_subject = s_tmp2;
60083 + }
60084 +
60085 + /* add in ip acls */
60086 +
60087 + if (!s_tmp->ip_num) {
60088 + s_tmp->ips = NULL;
60089 + goto insert;
60090 + }
60091 +
60092 + i_tmp =
60093 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
60094 + sizeof (struct acl_ip_label *));
60095 +
60096 + if (!i_tmp)
60097 + return ERR_PTR(-ENOMEM);
60098 +
60099 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
60100 + *(i_tmp + i_num) =
60101 + (struct acl_ip_label *)
60102 + acl_alloc(sizeof (struct acl_ip_label));
60103 + if (!*(i_tmp + i_num))
60104 + return ERR_PTR(-ENOMEM);
60105 +
60106 + if (copy_from_user
60107 + (&i_utmp2, s_tmp->ips + i_num,
60108 + sizeof (struct acl_ip_label *)))
60109 + return ERR_PTR(-EFAULT);
60110 +
60111 + if (copy_from_user
60112 + (*(i_tmp + i_num), i_utmp2,
60113 + sizeof (struct acl_ip_label)))
60114 + return ERR_PTR(-EFAULT);
60115 +
60116 + if ((*(i_tmp + i_num))->iface == NULL)
60117 + continue;
60118 +
60119 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
60120 + if (!len || len >= IFNAMSIZ)
60121 + return ERR_PTR(-EINVAL);
60122 + tmp = acl_alloc(len);
60123 + if (tmp == NULL)
60124 + return ERR_PTR(-ENOMEM);
60125 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
60126 + return ERR_PTR(-EFAULT);
60127 + (*(i_tmp + i_num))->iface = tmp;
60128 + }
60129 +
60130 + s_tmp->ips = i_tmp;
60131 +
60132 +insert:
60133 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
60134 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
60135 + return ERR_PTR(-ENOMEM);
60136 +
60137 + return s_tmp;
60138 +}
60139 +
60140 +static int
60141 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
60142 +{
60143 + struct acl_subject_label s_pre;
60144 + struct acl_subject_label * ret;
60145 + int err;
60146 +
60147 + while (userp) {
60148 + if (copy_from_user(&s_pre, userp,
60149 + sizeof (struct acl_subject_label)))
60150 + return -EFAULT;
60151 +
60152 + ret = do_copy_user_subj(userp, role, NULL);
60153 +
60154 + err = PTR_ERR(ret);
60155 + if (IS_ERR(ret))
60156 + return err;
60157 +
60158 + insert_acl_subj_label(ret, role);
60159 +
60160 + userp = s_pre.prev;
60161 + }
60162 +
60163 + return 0;
60164 +}
60165 +
60166 +static int
60167 +copy_user_acl(struct gr_arg *arg)
60168 +{
60169 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
60170 + struct acl_subject_label *subj_list;
60171 + struct sprole_pw *sptmp;
60172 + struct gr_hash_struct *ghash;
60173 + uid_t *domainlist;
60174 + unsigned int r_num;
60175 + unsigned int len;
60176 + char *tmp;
60177 + int err = 0;
60178 + __u16 i;
60179 + __u32 num_subjs;
60180 +
60181 + /* we need a default and kernel role */
60182 + if (arg->role_db.num_roles < 2)
60183 + return -EINVAL;
60184 +
60185 + /* copy special role authentication info from userspace */
60186 +
60187 + num_sprole_pws = arg->num_sprole_pws;
60188 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
60189 +
60190 + if (!acl_special_roles && num_sprole_pws)
60191 + return -ENOMEM;
60192 +
60193 + for (i = 0; i < num_sprole_pws; i++) {
60194 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
60195 + if (!sptmp)
60196 + return -ENOMEM;
60197 + if (copy_from_user(sptmp, arg->sprole_pws + i,
60198 + sizeof (struct sprole_pw)))
60199 + return -EFAULT;
60200 +
60201 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
60202 +
60203 + if (!len || len >= GR_SPROLE_LEN)
60204 + return -EINVAL;
60205 +
60206 + if ((tmp = (char *) acl_alloc(len)) == NULL)
60207 + return -ENOMEM;
60208 +
60209 + if (copy_from_user(tmp, sptmp->rolename, len))
60210 + return -EFAULT;
60211 +
60212 + tmp[len-1] = '\0';
60213 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60214 + printk(KERN_ALERT "Copying special role %s\n", tmp);
60215 +#endif
60216 + sptmp->rolename = tmp;
60217 + acl_special_roles[i] = sptmp;
60218 + }
60219 +
60220 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
60221 +
60222 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
60223 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
60224 +
60225 + if (!r_tmp)
60226 + return -ENOMEM;
60227 +
60228 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
60229 + sizeof (struct acl_role_label *)))
60230 + return -EFAULT;
60231 +
60232 + if (copy_from_user(r_tmp, r_utmp2,
60233 + sizeof (struct acl_role_label)))
60234 + return -EFAULT;
60235 +
60236 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
60237 +
60238 + if (!len || len >= PATH_MAX)
60239 + return -EINVAL;
60240 +
60241 + if ((tmp = (char *) acl_alloc(len)) == NULL)
60242 + return -ENOMEM;
60243 +
60244 + if (copy_from_user(tmp, r_tmp->rolename, len))
60245 + return -EFAULT;
60246 +
60247 + tmp[len-1] = '\0';
60248 + r_tmp->rolename = tmp;
60249 +
60250 + if (!strcmp(r_tmp->rolename, "default")
60251 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
60252 + default_role = r_tmp;
60253 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
60254 + kernel_role = r_tmp;
60255 + }
60256 +
60257 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
60258 + return -ENOMEM;
60259 +
60260 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
60261 + return -EFAULT;
60262 +
60263 + r_tmp->hash = ghash;
60264 +
60265 + num_subjs = count_user_subjs(r_tmp->hash->first);
60266 +
60267 + r_tmp->subj_hash_size = num_subjs;
60268 + r_tmp->subj_hash =
60269 + (struct acl_subject_label **)
60270 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
60271 +
60272 + if (!r_tmp->subj_hash)
60273 + return -ENOMEM;
60274 +
60275 + err = copy_user_allowedips(r_tmp);
60276 + if (err)
60277 + return err;
60278 +
60279 + /* copy domain info */
60280 + if (r_tmp->domain_children != NULL) {
60281 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
60282 + if (domainlist == NULL)
60283 + return -ENOMEM;
60284 +
60285 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
60286 + return -EFAULT;
60287 +
60288 + r_tmp->domain_children = domainlist;
60289 + }
60290 +
60291 + err = copy_user_transitions(r_tmp);
60292 + if (err)
60293 + return err;
60294 +
60295 + memset(r_tmp->subj_hash, 0,
60296 + r_tmp->subj_hash_size *
60297 + sizeof (struct acl_subject_label *));
60298 +
60299 + /* acquire the list of subjects, then NULL out
60300 + the list prior to parsing the subjects for this role,
60301 + as during this parsing the list is replaced with a list
60302 + of *nested* subjects for the role
60303 + */
60304 + subj_list = r_tmp->hash->first;
60305 +
60306 + /* set nested subject list to null */
60307 + r_tmp->hash->first = NULL;
60308 +
60309 + err = copy_user_subjs(subj_list, r_tmp);
60310 +
60311 + if (err)
60312 + return err;
60313 +
60314 + insert_acl_role_label(r_tmp);
60315 + }
60316 +
60317 + if (default_role == NULL || kernel_role == NULL)
60318 + return -EINVAL;
60319 +
60320 + return err;
60321 +}
60322 +
60323 +static int
60324 +gracl_init(struct gr_arg *args)
60325 +{
60326 + int error = 0;
60327 +
60328 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
60329 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
60330 +
60331 + if (init_variables(args)) {
60332 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
60333 + error = -ENOMEM;
60334 + free_variables();
60335 + goto out;
60336 + }
60337 +
60338 + error = copy_user_acl(args);
60339 + free_init_variables();
60340 + if (error) {
60341 + free_variables();
60342 + goto out;
60343 + }
60344 +
60345 + if ((error = gr_set_acls(0))) {
60346 + free_variables();
60347 + goto out;
60348 + }
60349 +
60350 + pax_open_kernel();
60351 + gr_status |= GR_READY;
60352 + pax_close_kernel();
60353 +
60354 + out:
60355 + return error;
60356 +}
60357 +
60358 +/* derived from glibc fnmatch() 0: match, 1: no match*/
60359 +
60360 +static int
60361 +glob_match(const char *p, const char *n)
60362 +{
60363 + char c;
60364 +
60365 + while ((c = *p++) != '\0') {
60366 + switch (c) {
60367 + case '?':
60368 + if (*n == '\0')
60369 + return 1;
60370 + else if (*n == '/')
60371 + return 1;
60372 + break;
60373 + case '\\':
60374 + if (*n != c)
60375 + return 1;
60376 + break;
60377 + case '*':
60378 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
60379 + if (*n == '/')
60380 + return 1;
60381 + else if (c == '?') {
60382 + if (*n == '\0')
60383 + return 1;
60384 + else
60385 + ++n;
60386 + }
60387 + }
60388 + if (c == '\0') {
60389 + return 0;
60390 + } else {
60391 + const char *endp;
60392 +
60393 + if ((endp = strchr(n, '/')) == NULL)
60394 + endp = n + strlen(n);
60395 +
60396 + if (c == '[') {
60397 + for (--p; n < endp; ++n)
60398 + if (!glob_match(p, n))
60399 + return 0;
60400 + } else if (c == '/') {
60401 + while (*n != '\0' && *n != '/')
60402 + ++n;
60403 + if (*n == '/' && !glob_match(p, n + 1))
60404 + return 0;
60405 + } else {
60406 + for (--p; n < endp; ++n)
60407 + if (*n == c && !glob_match(p, n))
60408 + return 0;
60409 + }
60410 +
60411 + return 1;
60412 + }
60413 + case '[':
60414 + {
60415 + int not;
60416 + char cold;
60417 +
60418 + if (*n == '\0' || *n == '/')
60419 + return 1;
60420 +
60421 + not = (*p == '!' || *p == '^');
60422 + if (not)
60423 + ++p;
60424 +
60425 + c = *p++;
60426 + for (;;) {
60427 + unsigned char fn = (unsigned char)*n;
60428 +
60429 + if (c == '\0')
60430 + return 1;
60431 + else {
60432 + if (c == fn)
60433 + goto matched;
60434 + cold = c;
60435 + c = *p++;
60436 +
60437 + if (c == '-' && *p != ']') {
60438 + unsigned char cend = *p++;
60439 +
60440 + if (cend == '\0')
60441 + return 1;
60442 +
60443 + if (cold <= fn && fn <= cend)
60444 + goto matched;
60445 +
60446 + c = *p++;
60447 + }
60448 + }
60449 +
60450 + if (c == ']')
60451 + break;
60452 + }
60453 + if (!not)
60454 + return 1;
60455 + break;
60456 + matched:
60457 + while (c != ']') {
60458 + if (c == '\0')
60459 + return 1;
60460 +
60461 + c = *p++;
60462 + }
60463 + if (not)
60464 + return 1;
60465 + }
60466 + break;
60467 + default:
60468 + if (c != *n)
60469 + return 1;
60470 + }
60471 +
60472 + ++n;
60473 + }
60474 +
60475 + if (*n == '\0')
60476 + return 0;
60477 +
60478 + if (*n == '/')
60479 + return 0;
60480 +
60481 + return 1;
60482 +}
60483 +
60484 +static struct acl_object_label *
60485 +chk_glob_label(struct acl_object_label *globbed,
60486 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
60487 +{
60488 + struct acl_object_label *tmp;
60489 +
60490 + if (*path == NULL)
60491 + *path = gr_to_filename_nolock(dentry, mnt);
60492 +
60493 + tmp = globbed;
60494 +
60495 + while (tmp) {
60496 + if (!glob_match(tmp->filename, *path))
60497 + return tmp;
60498 + tmp = tmp->next;
60499 + }
60500 +
60501 + return NULL;
60502 +}
60503 +
60504 +static struct acl_object_label *
60505 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60506 + const ino_t curr_ino, const dev_t curr_dev,
60507 + const struct acl_subject_label *subj, char **path, const int checkglob)
60508 +{
60509 + struct acl_subject_label *tmpsubj;
60510 + struct acl_object_label *retval;
60511 + struct acl_object_label *retval2;
60512 +
60513 + tmpsubj = (struct acl_subject_label *) subj;
60514 + read_lock(&gr_inode_lock);
60515 + do {
60516 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
60517 + if (retval) {
60518 + if (checkglob && retval->globbed) {
60519 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
60520 + if (retval2)
60521 + retval = retval2;
60522 + }
60523 + break;
60524 + }
60525 + } while ((tmpsubj = tmpsubj->parent_subject));
60526 + read_unlock(&gr_inode_lock);
60527 +
60528 + return retval;
60529 +}
60530 +
60531 +static __inline__ struct acl_object_label *
60532 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60533 + struct dentry *curr_dentry,
60534 + const struct acl_subject_label *subj, char **path, const int checkglob)
60535 +{
60536 + int newglob = checkglob;
60537 + ino_t inode;
60538 + dev_t device;
60539 +
60540 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
60541 + as we don't want a / * rule to match instead of the / object
60542 + don't do this for create lookups that call this function though, since they're looking up
60543 + on the parent and thus need globbing checks on all paths
60544 + */
60545 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
60546 + newglob = GR_NO_GLOB;
60547 +
60548 + spin_lock(&curr_dentry->d_lock);
60549 + inode = curr_dentry->d_inode->i_ino;
60550 + device = __get_dev(curr_dentry);
60551 + spin_unlock(&curr_dentry->d_lock);
60552 +
60553 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
60554 +}
60555 +
60556 +#ifdef CONFIG_HUGETLBFS
60557 +static inline bool
60558 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
60559 +{
60560 + int i;
60561 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
60562 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
60563 + return true;
60564 + }
60565 +
60566 + return false;
60567 +}
60568 +#endif
60569 +
60570 +static struct acl_object_label *
60571 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60572 + const struct acl_subject_label *subj, char *path, const int checkglob)
60573 +{
60574 + struct dentry *dentry = (struct dentry *) l_dentry;
60575 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60576 + struct mount *real_mnt = real_mount(mnt);
60577 + struct acl_object_label *retval;
60578 + struct dentry *parent;
60579 +
60580 + br_read_lock(&vfsmount_lock);
60581 + write_seqlock(&rename_lock);
60582 +
60583 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
60584 +#ifdef CONFIG_NET
60585 + mnt == sock_mnt ||
60586 +#endif
60587 +#ifdef CONFIG_HUGETLBFS
60588 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60589 +#endif
60590 + /* ignore Eric Biederman */
60591 + IS_PRIVATE(l_dentry->d_inode))) {
60592 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60593 + goto out;
60594 + }
60595 +
60596 + for (;;) {
60597 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60598 + break;
60599 +
60600 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60601 + if (!mnt_has_parent(real_mnt))
60602 + break;
60603 +
60604 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60605 + if (retval != NULL)
60606 + goto out;
60607 +
60608 + dentry = real_mnt->mnt_mountpoint;
60609 + real_mnt = real_mnt->mnt_parent;
60610 + mnt = &real_mnt->mnt;
60611 + continue;
60612 + }
60613 +
60614 + parent = dentry->d_parent;
60615 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60616 + if (retval != NULL)
60617 + goto out;
60618 +
60619 + dentry = parent;
60620 + }
60621 +
60622 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60623 +
60624 + /* real_root is pinned so we don't have to hold a reference */
60625 + if (retval == NULL)
60626 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60627 +out:
60628 + write_sequnlock(&rename_lock);
60629 + br_read_unlock(&vfsmount_lock);
60630 +
60631 + BUG_ON(retval == NULL);
60632 +
60633 + return retval;
60634 +}
60635 +
60636 +static __inline__ struct acl_object_label *
60637 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60638 + const struct acl_subject_label *subj)
60639 +{
60640 + char *path = NULL;
60641 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60642 +}
60643 +
60644 +static __inline__ struct acl_object_label *
60645 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60646 + const struct acl_subject_label *subj)
60647 +{
60648 + char *path = NULL;
60649 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60650 +}
60651 +
60652 +static __inline__ struct acl_object_label *
60653 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60654 + const struct acl_subject_label *subj, char *path)
60655 +{
60656 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60657 +}
60658 +
60659 +static struct acl_subject_label *
60660 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60661 + const struct acl_role_label *role)
60662 +{
60663 + struct dentry *dentry = (struct dentry *) l_dentry;
60664 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60665 + struct mount *real_mnt = real_mount(mnt);
60666 + struct acl_subject_label *retval;
60667 + struct dentry *parent;
60668 +
60669 + br_read_lock(&vfsmount_lock);
60670 + write_seqlock(&rename_lock);
60671 +
60672 + for (;;) {
60673 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60674 + break;
60675 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60676 + if (!mnt_has_parent(real_mnt))
60677 + break;
60678 +
60679 + spin_lock(&dentry->d_lock);
60680 + read_lock(&gr_inode_lock);
60681 + retval =
60682 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60683 + __get_dev(dentry), role);
60684 + read_unlock(&gr_inode_lock);
60685 + spin_unlock(&dentry->d_lock);
60686 + if (retval != NULL)
60687 + goto out;
60688 +
60689 + dentry = real_mnt->mnt_mountpoint;
60690 + real_mnt = real_mnt->mnt_parent;
60691 + mnt = &real_mnt->mnt;
60692 + continue;
60693 + }
60694 +
60695 + spin_lock(&dentry->d_lock);
60696 + read_lock(&gr_inode_lock);
60697 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60698 + __get_dev(dentry), role);
60699 + read_unlock(&gr_inode_lock);
60700 + parent = dentry->d_parent;
60701 + spin_unlock(&dentry->d_lock);
60702 +
60703 + if (retval != NULL)
60704 + goto out;
60705 +
60706 + dentry = parent;
60707 + }
60708 +
60709 + spin_lock(&dentry->d_lock);
60710 + read_lock(&gr_inode_lock);
60711 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60712 + __get_dev(dentry), role);
60713 + read_unlock(&gr_inode_lock);
60714 + spin_unlock(&dentry->d_lock);
60715 +
60716 + if (unlikely(retval == NULL)) {
60717 + /* real_root is pinned, we don't need to hold a reference */
60718 + read_lock(&gr_inode_lock);
60719 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60720 + __get_dev(real_root.dentry), role);
60721 + read_unlock(&gr_inode_lock);
60722 + }
60723 +out:
60724 + write_sequnlock(&rename_lock);
60725 + br_read_unlock(&vfsmount_lock);
60726 +
60727 + BUG_ON(retval == NULL);
60728 +
60729 + return retval;
60730 +}
60731 +
60732 +static void
60733 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60734 +{
60735 + struct task_struct *task = current;
60736 + const struct cred *cred = current_cred();
60737 +
60738 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60739 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60740 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60741 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60742 +
60743 + return;
60744 +}
60745 +
60746 +static void
60747 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60748 +{
60749 + struct task_struct *task = current;
60750 + const struct cred *cred = current_cred();
60751 +
60752 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60753 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60754 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60755 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60756 +
60757 + return;
60758 +}
60759 +
60760 +static void
60761 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60762 +{
60763 + struct task_struct *task = current;
60764 + const struct cred *cred = current_cred();
60765 +
60766 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60767 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60768 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60769 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60770 +
60771 + return;
60772 +}
60773 +
60774 +__u32
60775 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60776 + const struct vfsmount * mnt)
60777 +{
60778 + __u32 retval = mode;
60779 + struct acl_subject_label *curracl;
60780 + struct acl_object_label *currobj;
60781 +
60782 + if (unlikely(!(gr_status & GR_READY)))
60783 + return (mode & ~GR_AUDITS);
60784 +
60785 + curracl = current->acl;
60786 +
60787 + currobj = chk_obj_label(dentry, mnt, curracl);
60788 + retval = currobj->mode & mode;
60789 +
60790 + /* if we're opening a specified transfer file for writing
60791 + (e.g. /dev/initctl), then transfer our role to init
60792 + */
60793 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60794 + current->role->roletype & GR_ROLE_PERSIST)) {
60795 + struct task_struct *task = init_pid_ns.child_reaper;
60796 +
60797 + if (task->role != current->role) {
60798 + task->acl_sp_role = 0;
60799 + task->acl_role_id = current->acl_role_id;
60800 + task->role = current->role;
60801 + rcu_read_lock();
60802 + read_lock(&grsec_exec_file_lock);
60803 + gr_apply_subject_to_task(task);
60804 + read_unlock(&grsec_exec_file_lock);
60805 + rcu_read_unlock();
60806 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60807 + }
60808 + }
60809 +
60810 + if (unlikely
60811 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60812 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60813 + __u32 new_mode = mode;
60814 +
60815 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60816 +
60817 + retval = new_mode;
60818 +
60819 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60820 + new_mode |= GR_INHERIT;
60821 +
60822 + if (!(mode & GR_NOLEARN))
60823 + gr_log_learn(dentry, mnt, new_mode);
60824 + }
60825 +
60826 + return retval;
60827 +}
60828 +
60829 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60830 + const struct dentry *parent,
60831 + const struct vfsmount *mnt)
60832 +{
60833 + struct name_entry *match;
60834 + struct acl_object_label *matchpo;
60835 + struct acl_subject_label *curracl;
60836 + char *path;
60837 +
60838 + if (unlikely(!(gr_status & GR_READY)))
60839 + return NULL;
60840 +
60841 + preempt_disable();
60842 + path = gr_to_filename_rbac(new_dentry, mnt);
60843 + match = lookup_name_entry_create(path);
60844 +
60845 + curracl = current->acl;
60846 +
60847 + if (match) {
60848 + read_lock(&gr_inode_lock);
60849 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60850 + read_unlock(&gr_inode_lock);
60851 +
60852 + if (matchpo) {
60853 + preempt_enable();
60854 + return matchpo;
60855 + }
60856 + }
60857 +
60858 + // lookup parent
60859 +
60860 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60861 +
60862 + preempt_enable();
60863 + return matchpo;
60864 +}
60865 +
60866 +__u32
60867 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60868 + const struct vfsmount * mnt, const __u32 mode)
60869 +{
60870 + struct acl_object_label *matchpo;
60871 + __u32 retval;
60872 +
60873 + if (unlikely(!(gr_status & GR_READY)))
60874 + return (mode & ~GR_AUDITS);
60875 +
60876 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60877 +
60878 + retval = matchpo->mode & mode;
60879 +
60880 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60881 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60882 + __u32 new_mode = mode;
60883 +
60884 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60885 +
60886 + gr_log_learn(new_dentry, mnt, new_mode);
60887 + return new_mode;
60888 + }
60889 +
60890 + return retval;
60891 +}
60892 +
60893 +__u32
60894 +gr_check_link(const struct dentry * new_dentry,
60895 + const struct dentry * parent_dentry,
60896 + const struct vfsmount * parent_mnt,
60897 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60898 +{
60899 + struct acl_object_label *obj;
60900 + __u32 oldmode, newmode;
60901 + __u32 needmode;
60902 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60903 + GR_DELETE | GR_INHERIT;
60904 +
60905 + if (unlikely(!(gr_status & GR_READY)))
60906 + return (GR_CREATE | GR_LINK);
60907 +
60908 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60909 + oldmode = obj->mode;
60910 +
60911 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60912 + newmode = obj->mode;
60913 +
60914 + needmode = newmode & checkmodes;
60915 +
60916 + // old name for hardlink must have at least the permissions of the new name
60917 + if ((oldmode & needmode) != needmode)
60918 + goto bad;
60919 +
60920 + // if old name had restrictions/auditing, make sure the new name does as well
60921 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60922 +
60923 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60924 + if (is_privileged_binary(old_dentry))
60925 + needmode |= GR_SETID;
60926 +
60927 + if ((newmode & needmode) != needmode)
60928 + goto bad;
60929 +
60930 + // enforce minimum permissions
60931 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60932 + return newmode;
60933 +bad:
60934 + needmode = oldmode;
60935 + if (is_privileged_binary(old_dentry))
60936 + needmode |= GR_SETID;
60937 +
60938 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60939 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60940 + return (GR_CREATE | GR_LINK);
60941 + } else if (newmode & GR_SUPPRESS)
60942 + return GR_SUPPRESS;
60943 + else
60944 + return 0;
60945 +}
60946 +
60947 +int
60948 +gr_check_hidden_task(const struct task_struct *task)
60949 +{
60950 + if (unlikely(!(gr_status & GR_READY)))
60951 + return 0;
60952 +
60953 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60954 + return 1;
60955 +
60956 + return 0;
60957 +}
60958 +
60959 +int
60960 +gr_check_protected_task(const struct task_struct *task)
60961 +{
60962 + if (unlikely(!(gr_status & GR_READY) || !task))
60963 + return 0;
60964 +
60965 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60966 + task->acl != current->acl)
60967 + return 1;
60968 +
60969 + return 0;
60970 +}
60971 +
60972 +int
60973 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60974 +{
60975 + struct task_struct *p;
60976 + int ret = 0;
60977 +
60978 + if (unlikely(!(gr_status & GR_READY) || !pid))
60979 + return ret;
60980 +
60981 + read_lock(&tasklist_lock);
60982 + do_each_pid_task(pid, type, p) {
60983 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60984 + p->acl != current->acl) {
60985 + ret = 1;
60986 + goto out;
60987 + }
60988 + } while_each_pid_task(pid, type, p);
60989 +out:
60990 + read_unlock(&tasklist_lock);
60991 +
60992 + return ret;
60993 +}
60994 +
60995 +void
60996 +gr_copy_label(struct task_struct *tsk)
60997 +{
60998 + tsk->signal->used_accept = 0;
60999 + tsk->acl_sp_role = 0;
61000 + tsk->acl_role_id = current->acl_role_id;
61001 + tsk->acl = current->acl;
61002 + tsk->role = current->role;
61003 + tsk->signal->curr_ip = current->signal->curr_ip;
61004 + tsk->signal->saved_ip = current->signal->saved_ip;
61005 + if (current->exec_file)
61006 + get_file(current->exec_file);
61007 + tsk->exec_file = current->exec_file;
61008 + tsk->is_writable = current->is_writable;
61009 + if (unlikely(current->signal->used_accept)) {
61010 + current->signal->curr_ip = 0;
61011 + current->signal->saved_ip = 0;
61012 + }
61013 +
61014 + return;
61015 +}
61016 +
61017 +static void
61018 +gr_set_proc_res(struct task_struct *task)
61019 +{
61020 + struct acl_subject_label *proc;
61021 + unsigned short i;
61022 +
61023 + proc = task->acl;
61024 +
61025 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
61026 + return;
61027 +
61028 + for (i = 0; i < RLIM_NLIMITS; i++) {
61029 + if (!(proc->resmask & (1U << i)))
61030 + continue;
61031 +
61032 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
61033 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
61034 +
61035 + if (i == RLIMIT_CPU)
61036 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
61037 + }
61038 +
61039 + return;
61040 +}
61041 +
61042 +extern int __gr_process_user_ban(struct user_struct *user);
61043 +
61044 +int
61045 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
61046 +{
61047 + unsigned int i;
61048 + __u16 num;
61049 + uid_t *uidlist;
61050 + uid_t curuid;
61051 + int realok = 0;
61052 + int effectiveok = 0;
61053 + int fsok = 0;
61054 + uid_t globalreal, globaleffective, globalfs;
61055 +
61056 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
61057 + struct user_struct *user;
61058 +
61059 + if (!uid_valid(real))
61060 + goto skipit;
61061 +
61062 + /* find user based on global namespace */
61063 +
61064 + globalreal = GR_GLOBAL_UID(real);
61065 +
61066 + user = find_user(make_kuid(&init_user_ns, globalreal));
61067 + if (user == NULL)
61068 + goto skipit;
61069 +
61070 + if (__gr_process_user_ban(user)) {
61071 + /* for find_user */
61072 + free_uid(user);
61073 + return 1;
61074 + }
61075 +
61076 + /* for find_user */
61077 + free_uid(user);
61078 +
61079 +skipit:
61080 +#endif
61081 +
61082 + if (unlikely(!(gr_status & GR_READY)))
61083 + return 0;
61084 +
61085 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61086 + gr_log_learn_uid_change(real, effective, fs);
61087 +
61088 + num = current->acl->user_trans_num;
61089 + uidlist = current->acl->user_transitions;
61090 +
61091 + if (uidlist == NULL)
61092 + return 0;
61093 +
61094 + if (!uid_valid(real)) {
61095 + realok = 1;
61096 + globalreal = (uid_t)-1;
61097 + } else {
61098 + globalreal = GR_GLOBAL_UID(real);
61099 + }
61100 + if (!uid_valid(effective)) {
61101 + effectiveok = 1;
61102 + globaleffective = (uid_t)-1;
61103 + } else {
61104 + globaleffective = GR_GLOBAL_UID(effective);
61105 + }
61106 + if (!uid_valid(fs)) {
61107 + fsok = 1;
61108 + globalfs = (uid_t)-1;
61109 + } else {
61110 + globalfs = GR_GLOBAL_UID(fs);
61111 + }
61112 +
61113 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
61114 + for (i = 0; i < num; i++) {
61115 + curuid = uidlist[i];
61116 + if (globalreal == curuid)
61117 + realok = 1;
61118 + if (globaleffective == curuid)
61119 + effectiveok = 1;
61120 + if (globalfs == curuid)
61121 + fsok = 1;
61122 + }
61123 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
61124 + for (i = 0; i < num; i++) {
61125 + curuid = uidlist[i];
61126 + if (globalreal == curuid)
61127 + break;
61128 + if (globaleffective == curuid)
61129 + break;
61130 + if (globalfs == curuid)
61131 + break;
61132 + }
61133 + /* not in deny list */
61134 + if (i == num) {
61135 + realok = 1;
61136 + effectiveok = 1;
61137 + fsok = 1;
61138 + }
61139 + }
61140 +
61141 + if (realok && effectiveok && fsok)
61142 + return 0;
61143 + else {
61144 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
61145 + return 1;
61146 + }
61147 +}
61148 +
61149 +int
61150 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
61151 +{
61152 + unsigned int i;
61153 + __u16 num;
61154 + gid_t *gidlist;
61155 + gid_t curgid;
61156 + int realok = 0;
61157 + int effectiveok = 0;
61158 + int fsok = 0;
61159 + gid_t globalreal, globaleffective, globalfs;
61160 +
61161 + if (unlikely(!(gr_status & GR_READY)))
61162 + return 0;
61163 +
61164 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
61165 + gr_log_learn_gid_change(real, effective, fs);
61166 +
61167 + num = current->acl->group_trans_num;
61168 + gidlist = current->acl->group_transitions;
61169 +
61170 + if (gidlist == NULL)
61171 + return 0;
61172 +
61173 + if (!gid_valid(real)) {
61174 + realok = 1;
61175 + globalreal = (gid_t)-1;
61176 + } else {
61177 + globalreal = GR_GLOBAL_GID(real);
61178 + }
61179 + if (!gid_valid(effective)) {
61180 + effectiveok = 1;
61181 + globaleffective = (gid_t)-1;
61182 + } else {
61183 + globaleffective = GR_GLOBAL_GID(effective);
61184 + }
61185 + if (!gid_valid(fs)) {
61186 + fsok = 1;
61187 + globalfs = (gid_t)-1;
61188 + } else {
61189 + globalfs = GR_GLOBAL_GID(fs);
61190 + }
61191 +
61192 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
61193 + for (i = 0; i < num; i++) {
61194 + curgid = gidlist[i];
61195 + if (globalreal == curgid)
61196 + realok = 1;
61197 + if (globaleffective == curgid)
61198 + effectiveok = 1;
61199 + if (globalfs == curgid)
61200 + fsok = 1;
61201 + }
61202 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
61203 + for (i = 0; i < num; i++) {
61204 + curgid = gidlist[i];
61205 + if (globalreal == curgid)
61206 + break;
61207 + if (globaleffective == curgid)
61208 + break;
61209 + if (globalfs == curgid)
61210 + break;
61211 + }
61212 + /* not in deny list */
61213 + if (i == num) {
61214 + realok = 1;
61215 + effectiveok = 1;
61216 + fsok = 1;
61217 + }
61218 + }
61219 +
61220 + if (realok && effectiveok && fsok)
61221 + return 0;
61222 + else {
61223 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
61224 + return 1;
61225 + }
61226 +}
61227 +
61228 +extern int gr_acl_is_capable(const int cap);
61229 +
61230 +void
61231 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
61232 +{
61233 + struct acl_role_label *role = task->role;
61234 + struct acl_subject_label *subj = NULL;
61235 + struct acl_object_label *obj;
61236 + struct file *filp;
61237 + uid_t uid;
61238 + gid_t gid;
61239 +
61240 + if (unlikely(!(gr_status & GR_READY)))
61241 + return;
61242 +
61243 + uid = GR_GLOBAL_UID(kuid);
61244 + gid = GR_GLOBAL_GID(kgid);
61245 +
61246 + filp = task->exec_file;
61247 +
61248 + /* kernel process, we'll give them the kernel role */
61249 + if (unlikely(!filp)) {
61250 + task->role = kernel_role;
61251 + task->acl = kernel_role->root_label;
61252 + return;
61253 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
61254 + role = lookup_acl_role_label(task, uid, gid);
61255 +
61256 + /* don't change the role if we're not a privileged process */
61257 + if (role && task->role != role &&
61258 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
61259 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
61260 + return;
61261 +
61262 + /* perform subject lookup in possibly new role
61263 + we can use this result below in the case where role == task->role
61264 + */
61265 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
61266 +
61267 + /* if we changed uid/gid, but result in the same role
61268 + and are using inheritance, don't lose the inherited subject
61269 + if current subject is other than what normal lookup
61270 + would result in, we arrived via inheritance, don't
61271 + lose subject
61272 + */
61273 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
61274 + (subj == task->acl)))
61275 + task->acl = subj;
61276 +
61277 + task->role = role;
61278 +
61279 + task->is_writable = 0;
61280 +
61281 + /* ignore additional mmap checks for processes that are writable
61282 + by the default ACL */
61283 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61284 + if (unlikely(obj->mode & GR_WRITE))
61285 + task->is_writable = 1;
61286 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61287 + if (unlikely(obj->mode & GR_WRITE))
61288 + task->is_writable = 1;
61289 +
61290 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61291 + 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);
61292 +#endif
61293 +
61294 + gr_set_proc_res(task);
61295 +
61296 + return;
61297 +}
61298 +
61299 +int
61300 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
61301 + const int unsafe_flags)
61302 +{
61303 + struct task_struct *task = current;
61304 + struct acl_subject_label *newacl;
61305 + struct acl_object_label *obj;
61306 + __u32 retmode;
61307 +
61308 + if (unlikely(!(gr_status & GR_READY)))
61309 + return 0;
61310 +
61311 + newacl = chk_subj_label(dentry, mnt, task->role);
61312 +
61313 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
61314 + did an exec
61315 + */
61316 + rcu_read_lock();
61317 + read_lock(&tasklist_lock);
61318 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
61319 + (task->parent->acl->mode & GR_POVERRIDE))) {
61320 + read_unlock(&tasklist_lock);
61321 + rcu_read_unlock();
61322 + goto skip_check;
61323 + }
61324 + read_unlock(&tasklist_lock);
61325 + rcu_read_unlock();
61326 +
61327 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
61328 + !(task->role->roletype & GR_ROLE_GOD) &&
61329 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
61330 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
61331 + if (unsafe_flags & LSM_UNSAFE_SHARE)
61332 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
61333 + else
61334 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
61335 + return -EACCES;
61336 + }
61337 +
61338 +skip_check:
61339 +
61340 + obj = chk_obj_label(dentry, mnt, task->acl);
61341 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
61342 +
61343 + if (!(task->acl->mode & GR_INHERITLEARN) &&
61344 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
61345 + if (obj->nested)
61346 + task->acl = obj->nested;
61347 + else
61348 + task->acl = newacl;
61349 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
61350 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
61351 +
61352 + task->is_writable = 0;
61353 +
61354 + /* ignore additional mmap checks for processes that are writable
61355 + by the default ACL */
61356 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
61357 + if (unlikely(obj->mode & GR_WRITE))
61358 + task->is_writable = 1;
61359 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
61360 + if (unlikely(obj->mode & GR_WRITE))
61361 + task->is_writable = 1;
61362 +
61363 + gr_set_proc_res(task);
61364 +
61365 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61366 + 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);
61367 +#endif
61368 + return 0;
61369 +}
61370 +
61371 +/* always called with valid inodev ptr */
61372 +static void
61373 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
61374 +{
61375 + struct acl_object_label *matchpo;
61376 + struct acl_subject_label *matchps;
61377 + struct acl_subject_label *subj;
61378 + struct acl_role_label *role;
61379 + unsigned int x;
61380 +
61381 + FOR_EACH_ROLE_START(role)
61382 + FOR_EACH_SUBJECT_START(role, subj, x)
61383 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
61384 + matchpo->mode |= GR_DELETED;
61385 + FOR_EACH_SUBJECT_END(subj,x)
61386 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61387 + /* nested subjects aren't in the role's subj_hash table */
61388 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
61389 + matchpo->mode |= GR_DELETED;
61390 + FOR_EACH_NESTED_SUBJECT_END(subj)
61391 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
61392 + matchps->mode |= GR_DELETED;
61393 + FOR_EACH_ROLE_END(role)
61394 +
61395 + inodev->nentry->deleted = 1;
61396 +
61397 + return;
61398 +}
61399 +
61400 +void
61401 +gr_handle_delete(const ino_t ino, const dev_t dev)
61402 +{
61403 + struct inodev_entry *inodev;
61404 +
61405 + if (unlikely(!(gr_status & GR_READY)))
61406 + return;
61407 +
61408 + write_lock(&gr_inode_lock);
61409 + inodev = lookup_inodev_entry(ino, dev);
61410 + if (inodev != NULL)
61411 + do_handle_delete(inodev, ino, dev);
61412 + write_unlock(&gr_inode_lock);
61413 +
61414 + return;
61415 +}
61416 +
61417 +static void
61418 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
61419 + const ino_t newinode, const dev_t newdevice,
61420 + struct acl_subject_label *subj)
61421 +{
61422 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
61423 + struct acl_object_label *match;
61424 +
61425 + match = subj->obj_hash[index];
61426 +
61427 + while (match && (match->inode != oldinode ||
61428 + match->device != olddevice ||
61429 + !(match->mode & GR_DELETED)))
61430 + match = match->next;
61431 +
61432 + if (match && (match->inode == oldinode)
61433 + && (match->device == olddevice)
61434 + && (match->mode & GR_DELETED)) {
61435 + if (match->prev == NULL) {
61436 + subj->obj_hash[index] = match->next;
61437 + if (match->next != NULL)
61438 + match->next->prev = NULL;
61439 + } else {
61440 + match->prev->next = match->next;
61441 + if (match->next != NULL)
61442 + match->next->prev = match->prev;
61443 + }
61444 + match->prev = NULL;
61445 + match->next = NULL;
61446 + match->inode = newinode;
61447 + match->device = newdevice;
61448 + match->mode &= ~GR_DELETED;
61449 +
61450 + insert_acl_obj_label(match, subj);
61451 + }
61452 +
61453 + return;
61454 +}
61455 +
61456 +static void
61457 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
61458 + const ino_t newinode, const dev_t newdevice,
61459 + struct acl_role_label *role)
61460 +{
61461 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
61462 + struct acl_subject_label *match;
61463 +
61464 + match = role->subj_hash[index];
61465 +
61466 + while (match && (match->inode != oldinode ||
61467 + match->device != olddevice ||
61468 + !(match->mode & GR_DELETED)))
61469 + match = match->next;
61470 +
61471 + if (match && (match->inode == oldinode)
61472 + && (match->device == olddevice)
61473 + && (match->mode & GR_DELETED)) {
61474 + if (match->prev == NULL) {
61475 + role->subj_hash[index] = match->next;
61476 + if (match->next != NULL)
61477 + match->next->prev = NULL;
61478 + } else {
61479 + match->prev->next = match->next;
61480 + if (match->next != NULL)
61481 + match->next->prev = match->prev;
61482 + }
61483 + match->prev = NULL;
61484 + match->next = NULL;
61485 + match->inode = newinode;
61486 + match->device = newdevice;
61487 + match->mode &= ~GR_DELETED;
61488 +
61489 + insert_acl_subj_label(match, role);
61490 + }
61491 +
61492 + return;
61493 +}
61494 +
61495 +static void
61496 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
61497 + const ino_t newinode, const dev_t newdevice)
61498 +{
61499 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
61500 + struct inodev_entry *match;
61501 +
61502 + match = inodev_set.i_hash[index];
61503 +
61504 + while (match && (match->nentry->inode != oldinode ||
61505 + match->nentry->device != olddevice || !match->nentry->deleted))
61506 + match = match->next;
61507 +
61508 + if (match && (match->nentry->inode == oldinode)
61509 + && (match->nentry->device == olddevice) &&
61510 + match->nentry->deleted) {
61511 + if (match->prev == NULL) {
61512 + inodev_set.i_hash[index] = match->next;
61513 + if (match->next != NULL)
61514 + match->next->prev = NULL;
61515 + } else {
61516 + match->prev->next = match->next;
61517 + if (match->next != NULL)
61518 + match->next->prev = match->prev;
61519 + }
61520 + match->prev = NULL;
61521 + match->next = NULL;
61522 + match->nentry->inode = newinode;
61523 + match->nentry->device = newdevice;
61524 + match->nentry->deleted = 0;
61525 +
61526 + insert_inodev_entry(match);
61527 + }
61528 +
61529 + return;
61530 +}
61531 +
61532 +static void
61533 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
61534 +{
61535 + struct acl_subject_label *subj;
61536 + struct acl_role_label *role;
61537 + unsigned int x;
61538 +
61539 + FOR_EACH_ROLE_START(role)
61540 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
61541 +
61542 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61543 + if ((subj->inode == ino) && (subj->device == dev)) {
61544 + subj->inode = ino;
61545 + subj->device = dev;
61546 + }
61547 + /* nested subjects aren't in the role's subj_hash table */
61548 + update_acl_obj_label(matchn->inode, matchn->device,
61549 + ino, dev, subj);
61550 + FOR_EACH_NESTED_SUBJECT_END(subj)
61551 + FOR_EACH_SUBJECT_START(role, subj, x)
61552 + update_acl_obj_label(matchn->inode, matchn->device,
61553 + ino, dev, subj);
61554 + FOR_EACH_SUBJECT_END(subj,x)
61555 + FOR_EACH_ROLE_END(role)
61556 +
61557 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
61558 +
61559 + return;
61560 +}
61561 +
61562 +static void
61563 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
61564 + const struct vfsmount *mnt)
61565 +{
61566 + ino_t ino = dentry->d_inode->i_ino;
61567 + dev_t dev = __get_dev(dentry);
61568 +
61569 + __do_handle_create(matchn, ino, dev);
61570 +
61571 + return;
61572 +}
61573 +
61574 +void
61575 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
61576 +{
61577 + struct name_entry *matchn;
61578 +
61579 + if (unlikely(!(gr_status & GR_READY)))
61580 + return;
61581 +
61582 + preempt_disable();
61583 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
61584 +
61585 + if (unlikely((unsigned long)matchn)) {
61586 + write_lock(&gr_inode_lock);
61587 + do_handle_create(matchn, dentry, mnt);
61588 + write_unlock(&gr_inode_lock);
61589 + }
61590 + preempt_enable();
61591 +
61592 + return;
61593 +}
61594 +
61595 +void
61596 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61597 +{
61598 + struct name_entry *matchn;
61599 +
61600 + if (unlikely(!(gr_status & GR_READY)))
61601 + return;
61602 +
61603 + preempt_disable();
61604 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61605 +
61606 + if (unlikely((unsigned long)matchn)) {
61607 + write_lock(&gr_inode_lock);
61608 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61609 + write_unlock(&gr_inode_lock);
61610 + }
61611 + preempt_enable();
61612 +
61613 + return;
61614 +}
61615 +
61616 +void
61617 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61618 + struct dentry *old_dentry,
61619 + struct dentry *new_dentry,
61620 + struct vfsmount *mnt, const __u8 replace)
61621 +{
61622 + struct name_entry *matchn;
61623 + struct inodev_entry *inodev;
61624 + struct inode *inode = new_dentry->d_inode;
61625 + ino_t old_ino = old_dentry->d_inode->i_ino;
61626 + dev_t old_dev = __get_dev(old_dentry);
61627 +
61628 + /* vfs_rename swaps the name and parent link for old_dentry and
61629 + new_dentry
61630 + at this point, old_dentry has the new name, parent link, and inode
61631 + for the renamed file
61632 + if a file is being replaced by a rename, new_dentry has the inode
61633 + and name for the replaced file
61634 + */
61635 +
61636 + if (unlikely(!(gr_status & GR_READY)))
61637 + return;
61638 +
61639 + preempt_disable();
61640 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61641 +
61642 + /* we wouldn't have to check d_inode if it weren't for
61643 + NFS silly-renaming
61644 + */
61645 +
61646 + write_lock(&gr_inode_lock);
61647 + if (unlikely(replace && inode)) {
61648 + ino_t new_ino = inode->i_ino;
61649 + dev_t new_dev = __get_dev(new_dentry);
61650 +
61651 + inodev = lookup_inodev_entry(new_ino, new_dev);
61652 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61653 + do_handle_delete(inodev, new_ino, new_dev);
61654 + }
61655 +
61656 + inodev = lookup_inodev_entry(old_ino, old_dev);
61657 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61658 + do_handle_delete(inodev, old_ino, old_dev);
61659 +
61660 + if (unlikely((unsigned long)matchn))
61661 + do_handle_create(matchn, old_dentry, mnt);
61662 +
61663 + write_unlock(&gr_inode_lock);
61664 + preempt_enable();
61665 +
61666 + return;
61667 +}
61668 +
61669 +static int
61670 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61671 + unsigned char **sum)
61672 +{
61673 + struct acl_role_label *r;
61674 + struct role_allowed_ip *ipp;
61675 + struct role_transition *trans;
61676 + unsigned int i;
61677 + int found = 0;
61678 + u32 curr_ip = current->signal->curr_ip;
61679 +
61680 + current->signal->saved_ip = curr_ip;
61681 +
61682 + /* check transition table */
61683 +
61684 + for (trans = current->role->transitions; trans; trans = trans->next) {
61685 + if (!strcmp(rolename, trans->rolename)) {
61686 + found = 1;
61687 + break;
61688 + }
61689 + }
61690 +
61691 + if (!found)
61692 + return 0;
61693 +
61694 + /* handle special roles that do not require authentication
61695 + and check ip */
61696 +
61697 + FOR_EACH_ROLE_START(r)
61698 + if (!strcmp(rolename, r->rolename) &&
61699 + (r->roletype & GR_ROLE_SPECIAL)) {
61700 + found = 0;
61701 + if (r->allowed_ips != NULL) {
61702 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61703 + if ((ntohl(curr_ip) & ipp->netmask) ==
61704 + (ntohl(ipp->addr) & ipp->netmask))
61705 + found = 1;
61706 + }
61707 + } else
61708 + found = 2;
61709 + if (!found)
61710 + return 0;
61711 +
61712 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61713 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61714 + *salt = NULL;
61715 + *sum = NULL;
61716 + return 1;
61717 + }
61718 + }
61719 + FOR_EACH_ROLE_END(r)
61720 +
61721 + for (i = 0; i < num_sprole_pws; i++) {
61722 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61723 + *salt = acl_special_roles[i]->salt;
61724 + *sum = acl_special_roles[i]->sum;
61725 + return 1;
61726 + }
61727 + }
61728 +
61729 + return 0;
61730 +}
61731 +
61732 +static void
61733 +assign_special_role(char *rolename)
61734 +{
61735 + struct acl_object_label *obj;
61736 + struct acl_role_label *r;
61737 + struct acl_role_label *assigned = NULL;
61738 + struct task_struct *tsk;
61739 + struct file *filp;
61740 +
61741 + FOR_EACH_ROLE_START(r)
61742 + if (!strcmp(rolename, r->rolename) &&
61743 + (r->roletype & GR_ROLE_SPECIAL)) {
61744 + assigned = r;
61745 + break;
61746 + }
61747 + FOR_EACH_ROLE_END(r)
61748 +
61749 + if (!assigned)
61750 + return;
61751 +
61752 + read_lock(&tasklist_lock);
61753 + read_lock(&grsec_exec_file_lock);
61754 +
61755 + tsk = current->real_parent;
61756 + if (tsk == NULL)
61757 + goto out_unlock;
61758 +
61759 + filp = tsk->exec_file;
61760 + if (filp == NULL)
61761 + goto out_unlock;
61762 +
61763 + tsk->is_writable = 0;
61764 +
61765 + tsk->acl_sp_role = 1;
61766 + tsk->acl_role_id = ++acl_sp_role_value;
61767 + tsk->role = assigned;
61768 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61769 +
61770 + /* ignore additional mmap checks for processes that are writable
61771 + by the default ACL */
61772 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61773 + if (unlikely(obj->mode & GR_WRITE))
61774 + tsk->is_writable = 1;
61775 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61776 + if (unlikely(obj->mode & GR_WRITE))
61777 + tsk->is_writable = 1;
61778 +
61779 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61780 + 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));
61781 +#endif
61782 +
61783 +out_unlock:
61784 + read_unlock(&grsec_exec_file_lock);
61785 + read_unlock(&tasklist_lock);
61786 + return;
61787 +}
61788 +
61789 +int gr_check_secure_terminal(struct task_struct *task)
61790 +{
61791 + struct task_struct *p, *p2, *p3;
61792 + struct files_struct *files;
61793 + struct fdtable *fdt;
61794 + struct file *our_file = NULL, *file;
61795 + int i;
61796 +
61797 + if (task->signal->tty == NULL)
61798 + return 1;
61799 +
61800 + files = get_files_struct(task);
61801 + if (files != NULL) {
61802 + rcu_read_lock();
61803 + fdt = files_fdtable(files);
61804 + for (i=0; i < fdt->max_fds; i++) {
61805 + file = fcheck_files(files, i);
61806 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61807 + get_file(file);
61808 + our_file = file;
61809 + }
61810 + }
61811 + rcu_read_unlock();
61812 + put_files_struct(files);
61813 + }
61814 +
61815 + if (our_file == NULL)
61816 + return 1;
61817 +
61818 + read_lock(&tasklist_lock);
61819 + do_each_thread(p2, p) {
61820 + files = get_files_struct(p);
61821 + if (files == NULL ||
61822 + (p->signal && p->signal->tty == task->signal->tty)) {
61823 + if (files != NULL)
61824 + put_files_struct(files);
61825 + continue;
61826 + }
61827 + rcu_read_lock();
61828 + fdt = files_fdtable(files);
61829 + for (i=0; i < fdt->max_fds; i++) {
61830 + file = fcheck_files(files, i);
61831 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61832 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61833 + p3 = task;
61834 + while (task_pid_nr(p3) > 0) {
61835 + if (p3 == p)
61836 + break;
61837 + p3 = p3->real_parent;
61838 + }
61839 + if (p3 == p)
61840 + break;
61841 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61842 + gr_handle_alertkill(p);
61843 + rcu_read_unlock();
61844 + put_files_struct(files);
61845 + read_unlock(&tasklist_lock);
61846 + fput(our_file);
61847 + return 0;
61848 + }
61849 + }
61850 + rcu_read_unlock();
61851 + put_files_struct(files);
61852 + } while_each_thread(p2, p);
61853 + read_unlock(&tasklist_lock);
61854 +
61855 + fput(our_file);
61856 + return 1;
61857 +}
61858 +
61859 +static int gr_rbac_disable(void *unused)
61860 +{
61861 + pax_open_kernel();
61862 + gr_status &= ~GR_READY;
61863 + pax_close_kernel();
61864 +
61865 + return 0;
61866 +}
61867 +
61868 +ssize_t
61869 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61870 +{
61871 + struct gr_arg_wrapper uwrap;
61872 + unsigned char *sprole_salt = NULL;
61873 + unsigned char *sprole_sum = NULL;
61874 + int error = sizeof (struct gr_arg_wrapper);
61875 + int error2 = 0;
61876 +
61877 + mutex_lock(&gr_dev_mutex);
61878 +
61879 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61880 + error = -EPERM;
61881 + goto out;
61882 + }
61883 +
61884 + if (count != sizeof (struct gr_arg_wrapper)) {
61885 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61886 + error = -EINVAL;
61887 + goto out;
61888 + }
61889 +
61890 +
61891 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61892 + gr_auth_expires = 0;
61893 + gr_auth_attempts = 0;
61894 + }
61895 +
61896 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61897 + error = -EFAULT;
61898 + goto out;
61899 + }
61900 +
61901 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61902 + error = -EINVAL;
61903 + goto out;
61904 + }
61905 +
61906 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61907 + error = -EFAULT;
61908 + goto out;
61909 + }
61910 +
61911 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61912 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61913 + time_after(gr_auth_expires, get_seconds())) {
61914 + error = -EBUSY;
61915 + goto out;
61916 + }
61917 +
61918 + /* if non-root trying to do anything other than use a special role,
61919 + do not attempt authentication, do not count towards authentication
61920 + locking
61921 + */
61922 +
61923 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61924 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61925 + gr_is_global_nonroot(current_uid())) {
61926 + error = -EPERM;
61927 + goto out;
61928 + }
61929 +
61930 + /* ensure pw and special role name are null terminated */
61931 +
61932 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61933 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61934 +
61935 + /* Okay.
61936 + * We have our enough of the argument structure..(we have yet
61937 + * to copy_from_user the tables themselves) . Copy the tables
61938 + * only if we need them, i.e. for loading operations. */
61939 +
61940 + switch (gr_usermode->mode) {
61941 + case GR_STATUS:
61942 + if (gr_status & GR_READY) {
61943 + error = 1;
61944 + if (!gr_check_secure_terminal(current))
61945 + error = 3;
61946 + } else
61947 + error = 2;
61948 + goto out;
61949 + case GR_SHUTDOWN:
61950 + if ((gr_status & GR_READY)
61951 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61952 + stop_machine(gr_rbac_disable, NULL, NULL);
61953 + free_variables();
61954 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61955 + memset(gr_system_salt, 0, GR_SALT_LEN);
61956 + memset(gr_system_sum, 0, GR_SHA_LEN);
61957 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61958 + } else if (gr_status & GR_READY) {
61959 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61960 + error = -EPERM;
61961 + } else {
61962 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61963 + error = -EAGAIN;
61964 + }
61965 + break;
61966 + case GR_ENABLE:
61967 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61968 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61969 + else {
61970 + if (gr_status & GR_READY)
61971 + error = -EAGAIN;
61972 + else
61973 + error = error2;
61974 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61975 + }
61976 + break;
61977 + case GR_RELOAD:
61978 + if (!(gr_status & GR_READY)) {
61979 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61980 + error = -EAGAIN;
61981 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61982 + stop_machine(gr_rbac_disable, NULL, NULL);
61983 + free_variables();
61984 + error2 = gracl_init(gr_usermode);
61985 + if (!error2)
61986 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61987 + else {
61988 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61989 + error = error2;
61990 + }
61991 + } else {
61992 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61993 + error = -EPERM;
61994 + }
61995 + break;
61996 + case GR_SEGVMOD:
61997 + if (unlikely(!(gr_status & GR_READY))) {
61998 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61999 + error = -EAGAIN;
62000 + break;
62001 + }
62002 +
62003 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
62004 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
62005 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
62006 + struct acl_subject_label *segvacl;
62007 + segvacl =
62008 + lookup_acl_subj_label(gr_usermode->segv_inode,
62009 + gr_usermode->segv_device,
62010 + current->role);
62011 + if (segvacl) {
62012 + segvacl->crashes = 0;
62013 + segvacl->expires = 0;
62014 + }
62015 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
62016 + gr_remove_uid(gr_usermode->segv_uid);
62017 + }
62018 + } else {
62019 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
62020 + error = -EPERM;
62021 + }
62022 + break;
62023 + case GR_SPROLE:
62024 + case GR_SPROLEPAM:
62025 + if (unlikely(!(gr_status & GR_READY))) {
62026 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
62027 + error = -EAGAIN;
62028 + break;
62029 + }
62030 +
62031 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
62032 + current->role->expires = 0;
62033 + current->role->auth_attempts = 0;
62034 + }
62035 +
62036 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
62037 + time_after(current->role->expires, get_seconds())) {
62038 + error = -EBUSY;
62039 + goto out;
62040 + }
62041 +
62042 + if (lookup_special_role_auth
62043 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
62044 + && ((!sprole_salt && !sprole_sum)
62045 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
62046 + char *p = "";
62047 + assign_special_role(gr_usermode->sp_role);
62048 + read_lock(&tasklist_lock);
62049 + if (current->real_parent)
62050 + p = current->real_parent->role->rolename;
62051 + read_unlock(&tasklist_lock);
62052 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
62053 + p, acl_sp_role_value);
62054 + } else {
62055 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
62056 + error = -EPERM;
62057 + if(!(current->role->auth_attempts++))
62058 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
62059 +
62060 + goto out;
62061 + }
62062 + break;
62063 + case GR_UNSPROLE:
62064 + if (unlikely(!(gr_status & GR_READY))) {
62065 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
62066 + error = -EAGAIN;
62067 + break;
62068 + }
62069 +
62070 + if (current->role->roletype & GR_ROLE_SPECIAL) {
62071 + char *p = "";
62072 + int i = 0;
62073 +
62074 + read_lock(&tasklist_lock);
62075 + if (current->real_parent) {
62076 + p = current->real_parent->role->rolename;
62077 + i = current->real_parent->acl_role_id;
62078 + }
62079 + read_unlock(&tasklist_lock);
62080 +
62081 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
62082 + gr_set_acls(1);
62083 + } else {
62084 + error = -EPERM;
62085 + goto out;
62086 + }
62087 + break;
62088 + default:
62089 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
62090 + error = -EINVAL;
62091 + break;
62092 + }
62093 +
62094 + if (error != -EPERM)
62095 + goto out;
62096 +
62097 + if(!(gr_auth_attempts++))
62098 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
62099 +
62100 + out:
62101 + mutex_unlock(&gr_dev_mutex);
62102 + return error;
62103 +}
62104 +
62105 +/* must be called with
62106 + rcu_read_lock();
62107 + read_lock(&tasklist_lock);
62108 + read_lock(&grsec_exec_file_lock);
62109 +*/
62110 +int gr_apply_subject_to_task(struct task_struct *task)
62111 +{
62112 + struct acl_object_label *obj;
62113 + char *tmpname;
62114 + struct acl_subject_label *tmpsubj;
62115 + struct file *filp;
62116 + struct name_entry *nmatch;
62117 +
62118 + filp = task->exec_file;
62119 + if (filp == NULL)
62120 + return 0;
62121 +
62122 + /* the following is to apply the correct subject
62123 + on binaries running when the RBAC system
62124 + is enabled, when the binaries have been
62125 + replaced or deleted since their execution
62126 + -----
62127 + when the RBAC system starts, the inode/dev
62128 + from exec_file will be one the RBAC system
62129 + is unaware of. It only knows the inode/dev
62130 + of the present file on disk, or the absence
62131 + of it.
62132 + */
62133 + preempt_disable();
62134 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
62135 +
62136 + nmatch = lookup_name_entry(tmpname);
62137 + preempt_enable();
62138 + tmpsubj = NULL;
62139 + if (nmatch) {
62140 + if (nmatch->deleted)
62141 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
62142 + else
62143 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
62144 + if (tmpsubj != NULL)
62145 + task->acl = tmpsubj;
62146 + }
62147 + if (tmpsubj == NULL)
62148 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
62149 + task->role);
62150 + if (task->acl) {
62151 + task->is_writable = 0;
62152 + /* ignore additional mmap checks for processes that are writable
62153 + by the default ACL */
62154 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
62155 + if (unlikely(obj->mode & GR_WRITE))
62156 + task->is_writable = 1;
62157 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
62158 + if (unlikely(obj->mode & GR_WRITE))
62159 + task->is_writable = 1;
62160 +
62161 + gr_set_proc_res(task);
62162 +
62163 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
62164 + 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);
62165 +#endif
62166 + } else {
62167 + return 1;
62168 + }
62169 +
62170 + return 0;
62171 +}
62172 +
62173 +int
62174 +gr_set_acls(const int type)
62175 +{
62176 + struct task_struct *task, *task2;
62177 + struct acl_role_label *role = current->role;
62178 + __u16 acl_role_id = current->acl_role_id;
62179 + const struct cred *cred;
62180 + int ret;
62181 +
62182 + rcu_read_lock();
62183 + read_lock(&tasklist_lock);
62184 + read_lock(&grsec_exec_file_lock);
62185 + do_each_thread(task2, task) {
62186 + /* check to see if we're called from the exit handler,
62187 + if so, only replace ACLs that have inherited the admin
62188 + ACL */
62189 +
62190 + if (type && (task->role != role ||
62191 + task->acl_role_id != acl_role_id))
62192 + continue;
62193 +
62194 + task->acl_role_id = 0;
62195 + task->acl_sp_role = 0;
62196 +
62197 + if (task->exec_file) {
62198 + cred = __task_cred(task);
62199 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
62200 + ret = gr_apply_subject_to_task(task);
62201 + if (ret) {
62202 + read_unlock(&grsec_exec_file_lock);
62203 + read_unlock(&tasklist_lock);
62204 + rcu_read_unlock();
62205 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
62206 + return ret;
62207 + }
62208 + } else {
62209 + // it's a kernel process
62210 + task->role = kernel_role;
62211 + task->acl = kernel_role->root_label;
62212 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
62213 + task->acl->mode &= ~GR_PROCFIND;
62214 +#endif
62215 + }
62216 + } while_each_thread(task2, task);
62217 + read_unlock(&grsec_exec_file_lock);
62218 + read_unlock(&tasklist_lock);
62219 + rcu_read_unlock();
62220 +
62221 + return 0;
62222 +}
62223 +
62224 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
62225 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
62226 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
62227 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
62228 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
62229 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
62230 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
62231 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
62232 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
62233 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
62234 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
62235 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
62236 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
62237 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
62238 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
62239 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
62240 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
62241 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
62242 +};
62243 +
62244 +void
62245 +gr_learn_resource(const struct task_struct *task,
62246 + const int res, const unsigned long wanted, const int gt)
62247 +{
62248 + struct acl_subject_label *acl;
62249 + const struct cred *cred;
62250 +
62251 + if (unlikely((gr_status & GR_READY) &&
62252 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
62253 + goto skip_reslog;
62254 +
62255 + gr_log_resource(task, res, wanted, gt);
62256 +skip_reslog:
62257 +
62258 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
62259 + return;
62260 +
62261 + acl = task->acl;
62262 +
62263 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
62264 + !(acl->resmask & (1U << (unsigned short) res))))
62265 + return;
62266 +
62267 + if (wanted >= acl->res[res].rlim_cur) {
62268 + unsigned long res_add;
62269 +
62270 + res_add = wanted + res_learn_bumps[res];
62271 +
62272 + acl->res[res].rlim_cur = res_add;
62273 +
62274 + if (wanted > acl->res[res].rlim_max)
62275 + acl->res[res].rlim_max = res_add;
62276 +
62277 + /* only log the subject filename, since resource logging is supported for
62278 + single-subject learning only */
62279 + rcu_read_lock();
62280 + cred = __task_cred(task);
62281 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62282 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
62283 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
62284 + "", (unsigned long) res, &task->signal->saved_ip);
62285 + rcu_read_unlock();
62286 + }
62287 +
62288 + return;
62289 +}
62290 +EXPORT_SYMBOL(gr_learn_resource);
62291 +#endif
62292 +
62293 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
62294 +void
62295 +pax_set_initial_flags(struct linux_binprm *bprm)
62296 +{
62297 + struct task_struct *task = current;
62298 + struct acl_subject_label *proc;
62299 + unsigned long flags;
62300 +
62301 + if (unlikely(!(gr_status & GR_READY)))
62302 + return;
62303 +
62304 + flags = pax_get_flags(task);
62305 +
62306 + proc = task->acl;
62307 +
62308 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
62309 + flags &= ~MF_PAX_PAGEEXEC;
62310 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
62311 + flags &= ~MF_PAX_SEGMEXEC;
62312 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
62313 + flags &= ~MF_PAX_RANDMMAP;
62314 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
62315 + flags &= ~MF_PAX_EMUTRAMP;
62316 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
62317 + flags &= ~MF_PAX_MPROTECT;
62318 +
62319 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
62320 + flags |= MF_PAX_PAGEEXEC;
62321 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
62322 + flags |= MF_PAX_SEGMEXEC;
62323 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
62324 + flags |= MF_PAX_RANDMMAP;
62325 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
62326 + flags |= MF_PAX_EMUTRAMP;
62327 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
62328 + flags |= MF_PAX_MPROTECT;
62329 +
62330 + pax_set_flags(task, flags);
62331 +
62332 + return;
62333 +}
62334 +#endif
62335 +
62336 +int
62337 +gr_handle_proc_ptrace(struct task_struct *task)
62338 +{
62339 + struct file *filp;
62340 + struct task_struct *tmp = task;
62341 + struct task_struct *curtemp = current;
62342 + __u32 retmode;
62343 +
62344 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
62345 + if (unlikely(!(gr_status & GR_READY)))
62346 + return 0;
62347 +#endif
62348 +
62349 + read_lock(&tasklist_lock);
62350 + read_lock(&grsec_exec_file_lock);
62351 + filp = task->exec_file;
62352 +
62353 + while (task_pid_nr(tmp) > 0) {
62354 + if (tmp == curtemp)
62355 + break;
62356 + tmp = tmp->real_parent;
62357 + }
62358 +
62359 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
62360 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
62361 + read_unlock(&grsec_exec_file_lock);
62362 + read_unlock(&tasklist_lock);
62363 + return 1;
62364 + }
62365 +
62366 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
62367 + if (!(gr_status & GR_READY)) {
62368 + read_unlock(&grsec_exec_file_lock);
62369 + read_unlock(&tasklist_lock);
62370 + return 0;
62371 + }
62372 +#endif
62373 +
62374 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
62375 + read_unlock(&grsec_exec_file_lock);
62376 + read_unlock(&tasklist_lock);
62377 +
62378 + if (retmode & GR_NOPTRACE)
62379 + return 1;
62380 +
62381 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
62382 + && (current->acl != task->acl || (current->acl != current->role->root_label
62383 + && task_pid_nr(current) != task_pid_nr(task))))
62384 + return 1;
62385 +
62386 + return 0;
62387 +}
62388 +
62389 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
62390 +{
62391 + if (unlikely(!(gr_status & GR_READY)))
62392 + return;
62393 +
62394 + if (!(current->role->roletype & GR_ROLE_GOD))
62395 + return;
62396 +
62397 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
62398 + p->role->rolename, gr_task_roletype_to_char(p),
62399 + p->acl->filename);
62400 +}
62401 +
62402 +int
62403 +gr_handle_ptrace(struct task_struct *task, const long request)
62404 +{
62405 + struct task_struct *tmp = task;
62406 + struct task_struct *curtemp = current;
62407 + __u32 retmode;
62408 +
62409 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
62410 + if (unlikely(!(gr_status & GR_READY)))
62411 + return 0;
62412 +#endif
62413 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
62414 + read_lock(&tasklist_lock);
62415 + while (task_pid_nr(tmp) > 0) {
62416 + if (tmp == curtemp)
62417 + break;
62418 + tmp = tmp->real_parent;
62419 + }
62420 +
62421 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
62422 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
62423 + read_unlock(&tasklist_lock);
62424 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62425 + return 1;
62426 + }
62427 + read_unlock(&tasklist_lock);
62428 + }
62429 +
62430 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
62431 + if (!(gr_status & GR_READY))
62432 + return 0;
62433 +#endif
62434 +
62435 + read_lock(&grsec_exec_file_lock);
62436 + if (unlikely(!task->exec_file)) {
62437 + read_unlock(&grsec_exec_file_lock);
62438 + return 0;
62439 + }
62440 +
62441 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
62442 + read_unlock(&grsec_exec_file_lock);
62443 +
62444 + if (retmode & GR_NOPTRACE) {
62445 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62446 + return 1;
62447 + }
62448 +
62449 + if (retmode & GR_PTRACERD) {
62450 + switch (request) {
62451 + case PTRACE_SEIZE:
62452 + case PTRACE_POKETEXT:
62453 + case PTRACE_POKEDATA:
62454 + case PTRACE_POKEUSR:
62455 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
62456 + case PTRACE_SETREGS:
62457 + case PTRACE_SETFPREGS:
62458 +#endif
62459 +#ifdef CONFIG_X86
62460 + case PTRACE_SETFPXREGS:
62461 +#endif
62462 +#ifdef CONFIG_ALTIVEC
62463 + case PTRACE_SETVRREGS:
62464 +#endif
62465 + return 1;
62466 + default:
62467 + return 0;
62468 + }
62469 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
62470 + !(current->role->roletype & GR_ROLE_GOD) &&
62471 + (current->acl != task->acl)) {
62472 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
62473 + return 1;
62474 + }
62475 +
62476 + return 0;
62477 +}
62478 +
62479 +static int is_writable_mmap(const struct file *filp)
62480 +{
62481 + struct task_struct *task = current;
62482 + struct acl_object_label *obj, *obj2;
62483 +
62484 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
62485 + !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))) {
62486 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
62487 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
62488 + task->role->root_label);
62489 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
62490 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
62491 + return 1;
62492 + }
62493 + }
62494 + return 0;
62495 +}
62496 +
62497 +int
62498 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
62499 +{
62500 + __u32 mode;
62501 +
62502 + if (unlikely(!file || !(prot & PROT_EXEC)))
62503 + return 1;
62504 +
62505 + if (is_writable_mmap(file))
62506 + return 0;
62507 +
62508 + mode =
62509 + gr_search_file(file->f_path.dentry,
62510 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62511 + file->f_path.mnt);
62512 +
62513 + if (!gr_tpe_allow(file))
62514 + return 0;
62515 +
62516 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62517 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62518 + return 0;
62519 + } else if (unlikely(!(mode & GR_EXEC))) {
62520 + return 0;
62521 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62522 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62523 + return 1;
62524 + }
62525 +
62526 + return 1;
62527 +}
62528 +
62529 +int
62530 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
62531 +{
62532 + __u32 mode;
62533 +
62534 + if (unlikely(!file || !(prot & PROT_EXEC)))
62535 + return 1;
62536 +
62537 + if (is_writable_mmap(file))
62538 + return 0;
62539 +
62540 + mode =
62541 + gr_search_file(file->f_path.dentry,
62542 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62543 + file->f_path.mnt);
62544 +
62545 + if (!gr_tpe_allow(file))
62546 + return 0;
62547 +
62548 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62549 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62550 + return 0;
62551 + } else if (unlikely(!(mode & GR_EXEC))) {
62552 + return 0;
62553 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62554 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62555 + return 1;
62556 + }
62557 +
62558 + return 1;
62559 +}
62560 +
62561 +void
62562 +gr_acl_handle_psacct(struct task_struct *task, const long code)
62563 +{
62564 + unsigned long runtime;
62565 + unsigned long cputime;
62566 + unsigned int wday, cday;
62567 + __u8 whr, chr;
62568 + __u8 wmin, cmin;
62569 + __u8 wsec, csec;
62570 + struct timespec timeval;
62571 +
62572 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
62573 + !(task->acl->mode & GR_PROCACCT)))
62574 + return;
62575 +
62576 + do_posix_clock_monotonic_gettime(&timeval);
62577 + runtime = timeval.tv_sec - task->start_time.tv_sec;
62578 + wday = runtime / (3600 * 24);
62579 + runtime -= wday * (3600 * 24);
62580 + whr = runtime / 3600;
62581 + runtime -= whr * 3600;
62582 + wmin = runtime / 60;
62583 + runtime -= wmin * 60;
62584 + wsec = runtime;
62585 +
62586 + cputime = (task->utime + task->stime) / HZ;
62587 + cday = cputime / (3600 * 24);
62588 + cputime -= cday * (3600 * 24);
62589 + chr = cputime / 3600;
62590 + cputime -= chr * 3600;
62591 + cmin = cputime / 60;
62592 + cputime -= cmin * 60;
62593 + csec = cputime;
62594 +
62595 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62596 +
62597 + return;
62598 +}
62599 +
62600 +void gr_set_kernel_label(struct task_struct *task)
62601 +{
62602 + if (gr_status & GR_READY) {
62603 + task->role = kernel_role;
62604 + task->acl = kernel_role->root_label;
62605 + }
62606 + return;
62607 +}
62608 +
62609 +#ifdef CONFIG_TASKSTATS
62610 +int gr_is_taskstats_denied(int pid)
62611 +{
62612 + struct task_struct *task;
62613 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62614 + const struct cred *cred;
62615 +#endif
62616 + int ret = 0;
62617 +
62618 + /* restrict taskstats viewing to un-chrooted root users
62619 + who have the 'view' subject flag if the RBAC system is enabled
62620 + */
62621 +
62622 + rcu_read_lock();
62623 + read_lock(&tasklist_lock);
62624 + task = find_task_by_vpid(pid);
62625 + if (task) {
62626 +#ifdef CONFIG_GRKERNSEC_CHROOT
62627 + if (proc_is_chrooted(task))
62628 + ret = -EACCES;
62629 +#endif
62630 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62631 + cred = __task_cred(task);
62632 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62633 + if (gr_is_global_nonroot(cred->uid))
62634 + ret = -EACCES;
62635 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62636 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62637 + ret = -EACCES;
62638 +#endif
62639 +#endif
62640 + if (gr_status & GR_READY) {
62641 + if (!(task->acl->mode & GR_VIEW))
62642 + ret = -EACCES;
62643 + }
62644 + } else
62645 + ret = -ENOENT;
62646 +
62647 + read_unlock(&tasklist_lock);
62648 + rcu_read_unlock();
62649 +
62650 + return ret;
62651 +}
62652 +#endif
62653 +
62654 +/* AUXV entries are filled via a descendant of search_binary_handler
62655 + after we've already applied the subject for the target
62656 +*/
62657 +int gr_acl_enable_at_secure(void)
62658 +{
62659 + if (unlikely(!(gr_status & GR_READY)))
62660 + return 0;
62661 +
62662 + if (current->acl->mode & GR_ATSECURE)
62663 + return 1;
62664 +
62665 + return 0;
62666 +}
62667 +
62668 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62669 +{
62670 + struct task_struct *task = current;
62671 + struct dentry *dentry = file->f_path.dentry;
62672 + struct vfsmount *mnt = file->f_path.mnt;
62673 + struct acl_object_label *obj, *tmp;
62674 + struct acl_subject_label *subj;
62675 + unsigned int bufsize;
62676 + int is_not_root;
62677 + char *path;
62678 + dev_t dev = __get_dev(dentry);
62679 +
62680 + if (unlikely(!(gr_status & GR_READY)))
62681 + return 1;
62682 +
62683 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62684 + return 1;
62685 +
62686 + /* ignore Eric Biederman */
62687 + if (IS_PRIVATE(dentry->d_inode))
62688 + return 1;
62689 +
62690 + subj = task->acl;
62691 + read_lock(&gr_inode_lock);
62692 + do {
62693 + obj = lookup_acl_obj_label(ino, dev, subj);
62694 + if (obj != NULL) {
62695 + read_unlock(&gr_inode_lock);
62696 + return (obj->mode & GR_FIND) ? 1 : 0;
62697 + }
62698 + } while ((subj = subj->parent_subject));
62699 + read_unlock(&gr_inode_lock);
62700 +
62701 + /* this is purely an optimization since we're looking for an object
62702 + for the directory we're doing a readdir on
62703 + if it's possible for any globbed object to match the entry we're
62704 + filling into the directory, then the object we find here will be
62705 + an anchor point with attached globbed objects
62706 + */
62707 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62708 + if (obj->globbed == NULL)
62709 + return (obj->mode & GR_FIND) ? 1 : 0;
62710 +
62711 + is_not_root = ((obj->filename[0] == '/') &&
62712 + (obj->filename[1] == '\0')) ? 0 : 1;
62713 + bufsize = PAGE_SIZE - namelen - is_not_root;
62714 +
62715 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62716 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62717 + return 1;
62718 +
62719 + preempt_disable();
62720 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62721 + bufsize);
62722 +
62723 + bufsize = strlen(path);
62724 +
62725 + /* if base is "/", don't append an additional slash */
62726 + if (is_not_root)
62727 + *(path + bufsize) = '/';
62728 + memcpy(path + bufsize + is_not_root, name, namelen);
62729 + *(path + bufsize + namelen + is_not_root) = '\0';
62730 +
62731 + tmp = obj->globbed;
62732 + while (tmp) {
62733 + if (!glob_match(tmp->filename, path)) {
62734 + preempt_enable();
62735 + return (tmp->mode & GR_FIND) ? 1 : 0;
62736 + }
62737 + tmp = tmp->next;
62738 + }
62739 + preempt_enable();
62740 + return (obj->mode & GR_FIND) ? 1 : 0;
62741 +}
62742 +
62743 +void gr_put_exec_file(struct task_struct *task)
62744 +{
62745 + struct file *filp;
62746 +
62747 + write_lock(&grsec_exec_file_lock);
62748 + filp = task->exec_file;
62749 + task->exec_file = NULL;
62750 + write_unlock(&grsec_exec_file_lock);
62751 +
62752 + if (filp)
62753 + fput(filp);
62754 +
62755 + return;
62756 +}
62757 +
62758 +
62759 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62760 +EXPORT_SYMBOL(gr_acl_is_enabled);
62761 +#endif
62762 +EXPORT_SYMBOL(gr_set_kernel_label);
62763 +#ifdef CONFIG_SECURITY
62764 +EXPORT_SYMBOL(gr_check_user_change);
62765 +EXPORT_SYMBOL(gr_check_group_change);
62766 +#endif
62767 +
62768 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62769 new file mode 100644
62770 index 0000000..34fefda
62771 --- /dev/null
62772 +++ b/grsecurity/gracl_alloc.c
62773 @@ -0,0 +1,105 @@
62774 +#include <linux/kernel.h>
62775 +#include <linux/mm.h>
62776 +#include <linux/slab.h>
62777 +#include <linux/vmalloc.h>
62778 +#include <linux/gracl.h>
62779 +#include <linux/grsecurity.h>
62780 +
62781 +static unsigned long alloc_stack_next = 1;
62782 +static unsigned long alloc_stack_size = 1;
62783 +static void **alloc_stack;
62784 +
62785 +static __inline__ int
62786 +alloc_pop(void)
62787 +{
62788 + if (alloc_stack_next == 1)
62789 + return 0;
62790 +
62791 + kfree(alloc_stack[alloc_stack_next - 2]);
62792 +
62793 + alloc_stack_next--;
62794 +
62795 + return 1;
62796 +}
62797 +
62798 +static __inline__ int
62799 +alloc_push(void *buf)
62800 +{
62801 + if (alloc_stack_next >= alloc_stack_size)
62802 + return 1;
62803 +
62804 + alloc_stack[alloc_stack_next - 1] = buf;
62805 +
62806 + alloc_stack_next++;
62807 +
62808 + return 0;
62809 +}
62810 +
62811 +void *
62812 +acl_alloc(unsigned long len)
62813 +{
62814 + void *ret = NULL;
62815 +
62816 + if (!len || len > PAGE_SIZE)
62817 + goto out;
62818 +
62819 + ret = kmalloc(len, GFP_KERNEL);
62820 +
62821 + if (ret) {
62822 + if (alloc_push(ret)) {
62823 + kfree(ret);
62824 + ret = NULL;
62825 + }
62826 + }
62827 +
62828 +out:
62829 + return ret;
62830 +}
62831 +
62832 +void *
62833 +acl_alloc_num(unsigned long num, unsigned long len)
62834 +{
62835 + if (!len || (num > (PAGE_SIZE / len)))
62836 + return NULL;
62837 +
62838 + return acl_alloc(num * len);
62839 +}
62840 +
62841 +void
62842 +acl_free_all(void)
62843 +{
62844 + if (gr_acl_is_enabled() || !alloc_stack)
62845 + return;
62846 +
62847 + while (alloc_pop()) ;
62848 +
62849 + if (alloc_stack) {
62850 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62851 + kfree(alloc_stack);
62852 + else
62853 + vfree(alloc_stack);
62854 + }
62855 +
62856 + alloc_stack = NULL;
62857 + alloc_stack_size = 1;
62858 + alloc_stack_next = 1;
62859 +
62860 + return;
62861 +}
62862 +
62863 +int
62864 +acl_alloc_stack_init(unsigned long size)
62865 +{
62866 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62867 + alloc_stack =
62868 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62869 + else
62870 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62871 +
62872 + alloc_stack_size = size;
62873 +
62874 + if (!alloc_stack)
62875 + return 0;
62876 + else
62877 + return 1;
62878 +}
62879 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62880 new file mode 100644
62881 index 0000000..bdd51ea
62882 --- /dev/null
62883 +++ b/grsecurity/gracl_cap.c
62884 @@ -0,0 +1,110 @@
62885 +#include <linux/kernel.h>
62886 +#include <linux/module.h>
62887 +#include <linux/sched.h>
62888 +#include <linux/gracl.h>
62889 +#include <linux/grsecurity.h>
62890 +#include <linux/grinternal.h>
62891 +
62892 +extern const char *captab_log[];
62893 +extern int captab_log_entries;
62894 +
62895 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62896 +{
62897 + struct acl_subject_label *curracl;
62898 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62899 + kernel_cap_t cap_audit = __cap_empty_set;
62900 +
62901 + if (!gr_acl_is_enabled())
62902 + return 1;
62903 +
62904 + curracl = task->acl;
62905 +
62906 + cap_drop = curracl->cap_lower;
62907 + cap_mask = curracl->cap_mask;
62908 + cap_audit = curracl->cap_invert_audit;
62909 +
62910 + while ((curracl = curracl->parent_subject)) {
62911 + /* if the cap isn't specified in the current computed mask but is specified in the
62912 + current level subject, and is lowered in the current level subject, then add
62913 + it to the set of dropped capabilities
62914 + otherwise, add the current level subject's mask to the current computed mask
62915 + */
62916 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62917 + cap_raise(cap_mask, cap);
62918 + if (cap_raised(curracl->cap_lower, cap))
62919 + cap_raise(cap_drop, cap);
62920 + if (cap_raised(curracl->cap_invert_audit, cap))
62921 + cap_raise(cap_audit, cap);
62922 + }
62923 + }
62924 +
62925 + if (!cap_raised(cap_drop, cap)) {
62926 + if (cap_raised(cap_audit, cap))
62927 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62928 + return 1;
62929 + }
62930 +
62931 + curracl = task->acl;
62932 +
62933 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62934 + && cap_raised(cred->cap_effective, cap)) {
62935 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62936 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62937 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62938 + gr_to_filename(task->exec_file->f_path.dentry,
62939 + task->exec_file->f_path.mnt) : curracl->filename,
62940 + curracl->filename, 0UL,
62941 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62942 + return 1;
62943 + }
62944 +
62945 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62946 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62947 +
62948 + return 0;
62949 +}
62950 +
62951 +int
62952 +gr_acl_is_capable(const int cap)
62953 +{
62954 + return gr_task_acl_is_capable(current, current_cred(), cap);
62955 +}
62956 +
62957 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62958 +{
62959 + struct acl_subject_label *curracl;
62960 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62961 +
62962 + if (!gr_acl_is_enabled())
62963 + return 1;
62964 +
62965 + curracl = task->acl;
62966 +
62967 + cap_drop = curracl->cap_lower;
62968 + cap_mask = curracl->cap_mask;
62969 +
62970 + while ((curracl = curracl->parent_subject)) {
62971 + /* if the cap isn't specified in the current computed mask but is specified in the
62972 + current level subject, and is lowered in the current level subject, then add
62973 + it to the set of dropped capabilities
62974 + otherwise, add the current level subject's mask to the current computed mask
62975 + */
62976 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62977 + cap_raise(cap_mask, cap);
62978 + if (cap_raised(curracl->cap_lower, cap))
62979 + cap_raise(cap_drop, cap);
62980 + }
62981 + }
62982 +
62983 + if (!cap_raised(cap_drop, cap))
62984 + return 1;
62985 +
62986 + return 0;
62987 +}
62988 +
62989 +int
62990 +gr_acl_is_capable_nolog(const int cap)
62991 +{
62992 + return gr_task_acl_is_capable_nolog(current, cap);
62993 +}
62994 +
62995 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62996 new file mode 100644
62997 index 0000000..a340c17
62998 --- /dev/null
62999 +++ b/grsecurity/gracl_fs.c
63000 @@ -0,0 +1,431 @@
63001 +#include <linux/kernel.h>
63002 +#include <linux/sched.h>
63003 +#include <linux/types.h>
63004 +#include <linux/fs.h>
63005 +#include <linux/file.h>
63006 +#include <linux/stat.h>
63007 +#include <linux/grsecurity.h>
63008 +#include <linux/grinternal.h>
63009 +#include <linux/gracl.h>
63010 +
63011 +umode_t
63012 +gr_acl_umask(void)
63013 +{
63014 + if (unlikely(!gr_acl_is_enabled()))
63015 + return 0;
63016 +
63017 + return current->role->umask;
63018 +}
63019 +
63020 +__u32
63021 +gr_acl_handle_hidden_file(const struct dentry * dentry,
63022 + const struct vfsmount * mnt)
63023 +{
63024 + __u32 mode;
63025 +
63026 + if (unlikely(!dentry->d_inode))
63027 + return GR_FIND;
63028 +
63029 + mode =
63030 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
63031 +
63032 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
63033 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
63034 + return mode;
63035 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
63036 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
63037 + return 0;
63038 + } else if (unlikely(!(mode & GR_FIND)))
63039 + return 0;
63040 +
63041 + return GR_FIND;
63042 +}
63043 +
63044 +__u32
63045 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
63046 + int acc_mode)
63047 +{
63048 + __u32 reqmode = GR_FIND;
63049 + __u32 mode;
63050 +
63051 + if (unlikely(!dentry->d_inode))
63052 + return reqmode;
63053 +
63054 + if (acc_mode & MAY_APPEND)
63055 + reqmode |= GR_APPEND;
63056 + else if (acc_mode & MAY_WRITE)
63057 + reqmode |= GR_WRITE;
63058 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
63059 + reqmode |= GR_READ;
63060 +
63061 + mode =
63062 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
63063 + mnt);
63064 +
63065 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
63066 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
63067 + reqmode & GR_READ ? " reading" : "",
63068 + reqmode & GR_WRITE ? " writing" : reqmode &
63069 + GR_APPEND ? " appending" : "");
63070 + return reqmode;
63071 + } else
63072 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
63073 + {
63074 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
63075 + reqmode & GR_READ ? " reading" : "",
63076 + reqmode & GR_WRITE ? " writing" : reqmode &
63077 + GR_APPEND ? " appending" : "");
63078 + return 0;
63079 + } else if (unlikely((mode & reqmode) != reqmode))
63080 + return 0;
63081 +
63082 + return reqmode;
63083 +}
63084 +
63085 +__u32
63086 +gr_acl_handle_creat(const struct dentry * dentry,
63087 + const struct dentry * p_dentry,
63088 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
63089 + const int imode)
63090 +{
63091 + __u32 reqmode = GR_WRITE | GR_CREATE;
63092 + __u32 mode;
63093 +
63094 + if (acc_mode & MAY_APPEND)
63095 + reqmode |= GR_APPEND;
63096 + // if a directory was required or the directory already exists, then
63097 + // don't count this open as a read
63098 + if ((acc_mode & MAY_READ) &&
63099 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
63100 + reqmode |= GR_READ;
63101 + if ((open_flags & O_CREAT) &&
63102 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
63103 + reqmode |= GR_SETID;
63104 +
63105 + mode =
63106 + gr_check_create(dentry, p_dentry, p_mnt,
63107 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
63108 +
63109 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
63110 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
63111 + reqmode & GR_READ ? " reading" : "",
63112 + reqmode & GR_WRITE ? " writing" : reqmode &
63113 + GR_APPEND ? " appending" : "");
63114 + return reqmode;
63115 + } else
63116 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
63117 + {
63118 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
63119 + reqmode & GR_READ ? " reading" : "",
63120 + reqmode & GR_WRITE ? " writing" : reqmode &
63121 + GR_APPEND ? " appending" : "");
63122 + return 0;
63123 + } else if (unlikely((mode & reqmode) != reqmode))
63124 + return 0;
63125 +
63126 + return reqmode;
63127 +}
63128 +
63129 +__u32
63130 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
63131 + const int fmode)
63132 +{
63133 + __u32 mode, reqmode = GR_FIND;
63134 +
63135 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
63136 + reqmode |= GR_EXEC;
63137 + if (fmode & S_IWOTH)
63138 + reqmode |= GR_WRITE;
63139 + if (fmode & S_IROTH)
63140 + reqmode |= GR_READ;
63141 +
63142 + mode =
63143 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
63144 + mnt);
63145 +
63146 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
63147 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
63148 + reqmode & GR_READ ? " reading" : "",
63149 + reqmode & GR_WRITE ? " writing" : "",
63150 + reqmode & GR_EXEC ? " executing" : "");
63151 + return reqmode;
63152 + } else
63153 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
63154 + {
63155 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
63156 + reqmode & GR_READ ? " reading" : "",
63157 + reqmode & GR_WRITE ? " writing" : "",
63158 + reqmode & GR_EXEC ? " executing" : "");
63159 + return 0;
63160 + } else if (unlikely((mode & reqmode) != reqmode))
63161 + return 0;
63162 +
63163 + return reqmode;
63164 +}
63165 +
63166 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
63167 +{
63168 + __u32 mode;
63169 +
63170 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
63171 +
63172 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
63173 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
63174 + return mode;
63175 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
63176 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
63177 + return 0;
63178 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
63179 + return 0;
63180 +
63181 + return (reqmode);
63182 +}
63183 +
63184 +__u32
63185 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
63186 +{
63187 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
63188 +}
63189 +
63190 +__u32
63191 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
63192 +{
63193 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
63194 +}
63195 +
63196 +__u32
63197 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
63198 +{
63199 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
63200 +}
63201 +
63202 +__u32
63203 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
63204 +{
63205 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
63206 +}
63207 +
63208 +__u32
63209 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
63210 + umode_t *modeptr)
63211 +{
63212 + umode_t mode;
63213 +
63214 + *modeptr &= ~gr_acl_umask();
63215 + mode = *modeptr;
63216 +
63217 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
63218 + return 1;
63219 +
63220 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
63221 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
63222 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
63223 + GR_CHMOD_ACL_MSG);
63224 + } else {
63225 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
63226 + }
63227 +}
63228 +
63229 +__u32
63230 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
63231 +{
63232 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
63233 +}
63234 +
63235 +__u32
63236 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
63237 +{
63238 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
63239 +}
63240 +
63241 +__u32
63242 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
63243 +{
63244 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
63245 +}
63246 +
63247 +__u32
63248 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
63249 +{
63250 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
63251 + GR_UNIXCONNECT_ACL_MSG);
63252 +}
63253 +
63254 +/* hardlinks require at minimum create and link permission,
63255 + any additional privilege required is based on the
63256 + privilege of the file being linked to
63257 +*/
63258 +__u32
63259 +gr_acl_handle_link(const struct dentry * new_dentry,
63260 + const struct dentry * parent_dentry,
63261 + const struct vfsmount * parent_mnt,
63262 + const struct dentry * old_dentry,
63263 + const struct vfsmount * old_mnt, const struct filename *to)
63264 +{
63265 + __u32 mode;
63266 + __u32 needmode = GR_CREATE | GR_LINK;
63267 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
63268 +
63269 + mode =
63270 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
63271 + old_mnt);
63272 +
63273 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
63274 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
63275 + return mode;
63276 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
63277 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
63278 + return 0;
63279 + } else if (unlikely((mode & needmode) != needmode))
63280 + return 0;
63281 +
63282 + return 1;
63283 +}
63284 +
63285 +__u32
63286 +gr_acl_handle_symlink(const struct dentry * new_dentry,
63287 + const struct dentry * parent_dentry,
63288 + const struct vfsmount * parent_mnt, const struct filename *from)
63289 +{
63290 + __u32 needmode = GR_WRITE | GR_CREATE;
63291 + __u32 mode;
63292 +
63293 + mode =
63294 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
63295 + GR_CREATE | GR_AUDIT_CREATE |
63296 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
63297 +
63298 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
63299 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
63300 + return mode;
63301 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
63302 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
63303 + return 0;
63304 + } else if (unlikely((mode & needmode) != needmode))
63305 + return 0;
63306 +
63307 + return (GR_WRITE | GR_CREATE);
63308 +}
63309 +
63310 +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)
63311 +{
63312 + __u32 mode;
63313 +
63314 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
63315 +
63316 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
63317 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
63318 + return mode;
63319 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
63320 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
63321 + return 0;
63322 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
63323 + return 0;
63324 +
63325 + return (reqmode);
63326 +}
63327 +
63328 +__u32
63329 +gr_acl_handle_mknod(const struct dentry * new_dentry,
63330 + const struct dentry * parent_dentry,
63331 + const struct vfsmount * parent_mnt,
63332 + const int mode)
63333 +{
63334 + __u32 reqmode = GR_WRITE | GR_CREATE;
63335 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
63336 + reqmode |= GR_SETID;
63337 +
63338 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
63339 + reqmode, GR_MKNOD_ACL_MSG);
63340 +}
63341 +
63342 +__u32
63343 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
63344 + const struct dentry *parent_dentry,
63345 + const struct vfsmount *parent_mnt)
63346 +{
63347 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
63348 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
63349 +}
63350 +
63351 +#define RENAME_CHECK_SUCCESS(old, new) \
63352 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
63353 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
63354 +
63355 +int
63356 +gr_acl_handle_rename(struct dentry *new_dentry,
63357 + struct dentry *parent_dentry,
63358 + const struct vfsmount *parent_mnt,
63359 + struct dentry *old_dentry,
63360 + struct inode *old_parent_inode,
63361 + struct vfsmount *old_mnt, const struct filename *newname)
63362 +{
63363 + __u32 comp1, comp2;
63364 + int error = 0;
63365 +
63366 + if (unlikely(!gr_acl_is_enabled()))
63367 + return 0;
63368 +
63369 + if (!new_dentry->d_inode) {
63370 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
63371 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
63372 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
63373 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
63374 + GR_DELETE | GR_AUDIT_DELETE |
63375 + GR_AUDIT_READ | GR_AUDIT_WRITE |
63376 + GR_SUPPRESS, old_mnt);
63377 + } else {
63378 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
63379 + GR_CREATE | GR_DELETE |
63380 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
63381 + GR_AUDIT_READ | GR_AUDIT_WRITE |
63382 + GR_SUPPRESS, parent_mnt);
63383 + comp2 =
63384 + gr_search_file(old_dentry,
63385 + GR_READ | GR_WRITE | GR_AUDIT_READ |
63386 + GR_DELETE | GR_AUDIT_DELETE |
63387 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
63388 + }
63389 +
63390 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
63391 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
63392 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
63393 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
63394 + && !(comp2 & GR_SUPPRESS)) {
63395 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
63396 + error = -EACCES;
63397 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
63398 + error = -EACCES;
63399 +
63400 + return error;
63401 +}
63402 +
63403 +void
63404 +gr_acl_handle_exit(void)
63405 +{
63406 + u16 id;
63407 + char *rolename;
63408 +
63409 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
63410 + !(current->role->roletype & GR_ROLE_PERSIST))) {
63411 + id = current->acl_role_id;
63412 + rolename = current->role->rolename;
63413 + gr_set_acls(1);
63414 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
63415 + }
63416 +
63417 + gr_put_exec_file(current);
63418 + return;
63419 +}
63420 +
63421 +int
63422 +gr_acl_handle_procpidmem(const struct task_struct *task)
63423 +{
63424 + if (unlikely(!gr_acl_is_enabled()))
63425 + return 0;
63426 +
63427 + if (task != current && task->acl->mode & GR_PROTPROCFD)
63428 + return -EACCES;
63429 +
63430 + return 0;
63431 +}
63432 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
63433 new file mode 100644
63434 index 0000000..8132048
63435 --- /dev/null
63436 +++ b/grsecurity/gracl_ip.c
63437 @@ -0,0 +1,387 @@
63438 +#include <linux/kernel.h>
63439 +#include <asm/uaccess.h>
63440 +#include <asm/errno.h>
63441 +#include <net/sock.h>
63442 +#include <linux/file.h>
63443 +#include <linux/fs.h>
63444 +#include <linux/net.h>
63445 +#include <linux/in.h>
63446 +#include <linux/skbuff.h>
63447 +#include <linux/ip.h>
63448 +#include <linux/udp.h>
63449 +#include <linux/types.h>
63450 +#include <linux/sched.h>
63451 +#include <linux/netdevice.h>
63452 +#include <linux/inetdevice.h>
63453 +#include <linux/gracl.h>
63454 +#include <linux/grsecurity.h>
63455 +#include <linux/grinternal.h>
63456 +
63457 +#define GR_BIND 0x01
63458 +#define GR_CONNECT 0x02
63459 +#define GR_INVERT 0x04
63460 +#define GR_BINDOVERRIDE 0x08
63461 +#define GR_CONNECTOVERRIDE 0x10
63462 +#define GR_SOCK_FAMILY 0x20
63463 +
63464 +static const char * gr_protocols[IPPROTO_MAX] = {
63465 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
63466 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
63467 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
63468 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
63469 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
63470 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
63471 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
63472 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
63473 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
63474 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
63475 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
63476 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
63477 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
63478 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
63479 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
63480 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
63481 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
63482 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
63483 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
63484 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
63485 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
63486 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
63487 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
63488 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
63489 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
63490 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
63491 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
63492 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
63493 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
63494 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
63495 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
63496 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
63497 + };
63498 +
63499 +static const char * gr_socktypes[SOCK_MAX] = {
63500 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
63501 + "unknown:7", "unknown:8", "unknown:9", "packet"
63502 + };
63503 +
63504 +static const char * gr_sockfamilies[AF_MAX+1] = {
63505 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
63506 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
63507 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
63508 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
63509 + };
63510 +
63511 +const char *
63512 +gr_proto_to_name(unsigned char proto)
63513 +{
63514 + return gr_protocols[proto];
63515 +}
63516 +
63517 +const char *
63518 +gr_socktype_to_name(unsigned char type)
63519 +{
63520 + return gr_socktypes[type];
63521 +}
63522 +
63523 +const char *
63524 +gr_sockfamily_to_name(unsigned char family)
63525 +{
63526 + return gr_sockfamilies[family];
63527 +}
63528 +
63529 +int
63530 +gr_search_socket(const int domain, const int type, const int protocol)
63531 +{
63532 + struct acl_subject_label *curr;
63533 + const struct cred *cred = current_cred();
63534 +
63535 + if (unlikely(!gr_acl_is_enabled()))
63536 + goto exit;
63537 +
63538 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
63539 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
63540 + goto exit; // let the kernel handle it
63541 +
63542 + curr = current->acl;
63543 +
63544 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
63545 + /* the family is allowed, if this is PF_INET allow it only if
63546 + the extra sock type/protocol checks pass */
63547 + if (domain == PF_INET)
63548 + goto inet_check;
63549 + goto exit;
63550 + } else {
63551 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63552 + __u32 fakeip = 0;
63553 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63554 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63555 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63556 + gr_to_filename(current->exec_file->f_path.dentry,
63557 + current->exec_file->f_path.mnt) :
63558 + curr->filename, curr->filename,
63559 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
63560 + &current->signal->saved_ip);
63561 + goto exit;
63562 + }
63563 + goto exit_fail;
63564 + }
63565 +
63566 +inet_check:
63567 + /* the rest of this checking is for IPv4 only */
63568 + if (!curr->ips)
63569 + goto exit;
63570 +
63571 + if ((curr->ip_type & (1U << type)) &&
63572 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
63573 + goto exit;
63574 +
63575 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63576 + /* we don't place acls on raw sockets , and sometimes
63577 + dgram/ip sockets are opened for ioctl and not
63578 + bind/connect, so we'll fake a bind learn log */
63579 + if (type == SOCK_RAW || type == SOCK_PACKET) {
63580 + __u32 fakeip = 0;
63581 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63582 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63583 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63584 + gr_to_filename(current->exec_file->f_path.dentry,
63585 + current->exec_file->f_path.mnt) :
63586 + curr->filename, curr->filename,
63587 + &fakeip, 0, type,
63588 + protocol, GR_CONNECT, &current->signal->saved_ip);
63589 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63590 + __u32 fakeip = 0;
63591 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63592 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63593 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63594 + gr_to_filename(current->exec_file->f_path.dentry,
63595 + current->exec_file->f_path.mnt) :
63596 + curr->filename, curr->filename,
63597 + &fakeip, 0, type,
63598 + protocol, GR_BIND, &current->signal->saved_ip);
63599 + }
63600 + /* we'll log when they use connect or bind */
63601 + goto exit;
63602 + }
63603 +
63604 +exit_fail:
63605 + if (domain == PF_INET)
63606 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63607 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63608 + else
63609 +#ifndef CONFIG_IPV6
63610 + if (domain != PF_INET6)
63611 +#endif
63612 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63613 + gr_socktype_to_name(type), protocol);
63614 +
63615 + return 0;
63616 +exit:
63617 + return 1;
63618 +}
63619 +
63620 +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)
63621 +{
63622 + if ((ip->mode & mode) &&
63623 + (ip_port >= ip->low) &&
63624 + (ip_port <= ip->high) &&
63625 + ((ntohl(ip_addr) & our_netmask) ==
63626 + (ntohl(our_addr) & our_netmask))
63627 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63628 + && (ip->type & (1U << type))) {
63629 + if (ip->mode & GR_INVERT)
63630 + return 2; // specifically denied
63631 + else
63632 + return 1; // allowed
63633 + }
63634 +
63635 + return 0; // not specifically allowed, may continue parsing
63636 +}
63637 +
63638 +static int
63639 +gr_search_connectbind(const int full_mode, struct sock *sk,
63640 + struct sockaddr_in *addr, const int type)
63641 +{
63642 + char iface[IFNAMSIZ] = {0};
63643 + struct acl_subject_label *curr;
63644 + struct acl_ip_label *ip;
63645 + struct inet_sock *isk;
63646 + struct net_device *dev;
63647 + struct in_device *idev;
63648 + unsigned long i;
63649 + int ret;
63650 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63651 + __u32 ip_addr = 0;
63652 + __u32 our_addr;
63653 + __u32 our_netmask;
63654 + char *p;
63655 + __u16 ip_port = 0;
63656 + const struct cred *cred = current_cred();
63657 +
63658 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63659 + return 0;
63660 +
63661 + curr = current->acl;
63662 + isk = inet_sk(sk);
63663 +
63664 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63665 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63666 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63667 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63668 + struct sockaddr_in saddr;
63669 + int err;
63670 +
63671 + saddr.sin_family = AF_INET;
63672 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63673 + saddr.sin_port = isk->inet_sport;
63674 +
63675 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63676 + if (err)
63677 + return err;
63678 +
63679 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63680 + if (err)
63681 + return err;
63682 + }
63683 +
63684 + if (!curr->ips)
63685 + return 0;
63686 +
63687 + ip_addr = addr->sin_addr.s_addr;
63688 + ip_port = ntohs(addr->sin_port);
63689 +
63690 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63691 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63692 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63693 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63694 + gr_to_filename(current->exec_file->f_path.dentry,
63695 + current->exec_file->f_path.mnt) :
63696 + curr->filename, curr->filename,
63697 + &ip_addr, ip_port, type,
63698 + sk->sk_protocol, mode, &current->signal->saved_ip);
63699 + return 0;
63700 + }
63701 +
63702 + for (i = 0; i < curr->ip_num; i++) {
63703 + ip = *(curr->ips + i);
63704 + if (ip->iface != NULL) {
63705 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63706 + p = strchr(iface, ':');
63707 + if (p != NULL)
63708 + *p = '\0';
63709 + dev = dev_get_by_name(sock_net(sk), iface);
63710 + if (dev == NULL)
63711 + continue;
63712 + idev = in_dev_get(dev);
63713 + if (idev == NULL) {
63714 + dev_put(dev);
63715 + continue;
63716 + }
63717 + rcu_read_lock();
63718 + for_ifa(idev) {
63719 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63720 + our_addr = ifa->ifa_address;
63721 + our_netmask = 0xffffffff;
63722 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63723 + if (ret == 1) {
63724 + rcu_read_unlock();
63725 + in_dev_put(idev);
63726 + dev_put(dev);
63727 + return 0;
63728 + } else if (ret == 2) {
63729 + rcu_read_unlock();
63730 + in_dev_put(idev);
63731 + dev_put(dev);
63732 + goto denied;
63733 + }
63734 + }
63735 + } endfor_ifa(idev);
63736 + rcu_read_unlock();
63737 + in_dev_put(idev);
63738 + dev_put(dev);
63739 + } else {
63740 + our_addr = ip->addr;
63741 + our_netmask = ip->netmask;
63742 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63743 + if (ret == 1)
63744 + return 0;
63745 + else if (ret == 2)
63746 + goto denied;
63747 + }
63748 + }
63749 +
63750 +denied:
63751 + if (mode == GR_BIND)
63752 + 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));
63753 + else if (mode == GR_CONNECT)
63754 + 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));
63755 +
63756 + return -EACCES;
63757 +}
63758 +
63759 +int
63760 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63761 +{
63762 + /* always allow disconnection of dgram sockets with connect */
63763 + if (addr->sin_family == AF_UNSPEC)
63764 + return 0;
63765 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63766 +}
63767 +
63768 +int
63769 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63770 +{
63771 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63772 +}
63773 +
63774 +int gr_search_listen(struct socket *sock)
63775 +{
63776 + struct sock *sk = sock->sk;
63777 + struct sockaddr_in addr;
63778 +
63779 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63780 + addr.sin_port = inet_sk(sk)->inet_sport;
63781 +
63782 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63783 +}
63784 +
63785 +int gr_search_accept(struct socket *sock)
63786 +{
63787 + struct sock *sk = sock->sk;
63788 + struct sockaddr_in addr;
63789 +
63790 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63791 + addr.sin_port = inet_sk(sk)->inet_sport;
63792 +
63793 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63794 +}
63795 +
63796 +int
63797 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63798 +{
63799 + if (addr)
63800 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63801 + else {
63802 + struct sockaddr_in sin;
63803 + const struct inet_sock *inet = inet_sk(sk);
63804 +
63805 + sin.sin_addr.s_addr = inet->inet_daddr;
63806 + sin.sin_port = inet->inet_dport;
63807 +
63808 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63809 + }
63810 +}
63811 +
63812 +int
63813 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63814 +{
63815 + struct sockaddr_in sin;
63816 +
63817 + if (unlikely(skb->len < sizeof (struct udphdr)))
63818 + return 0; // skip this packet
63819 +
63820 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63821 + sin.sin_port = udp_hdr(skb)->source;
63822 +
63823 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63824 +}
63825 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63826 new file mode 100644
63827 index 0000000..25f54ef
63828 --- /dev/null
63829 +++ b/grsecurity/gracl_learn.c
63830 @@ -0,0 +1,207 @@
63831 +#include <linux/kernel.h>
63832 +#include <linux/mm.h>
63833 +#include <linux/sched.h>
63834 +#include <linux/poll.h>
63835 +#include <linux/string.h>
63836 +#include <linux/file.h>
63837 +#include <linux/types.h>
63838 +#include <linux/vmalloc.h>
63839 +#include <linux/grinternal.h>
63840 +
63841 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63842 + size_t count, loff_t *ppos);
63843 +extern int gr_acl_is_enabled(void);
63844 +
63845 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63846 +static int gr_learn_attached;
63847 +
63848 +/* use a 512k buffer */
63849 +#define LEARN_BUFFER_SIZE (512 * 1024)
63850 +
63851 +static DEFINE_SPINLOCK(gr_learn_lock);
63852 +static DEFINE_MUTEX(gr_learn_user_mutex);
63853 +
63854 +/* we need to maintain two buffers, so that the kernel context of grlearn
63855 + uses a semaphore around the userspace copying, and the other kernel contexts
63856 + use a spinlock when copying into the buffer, since they cannot sleep
63857 +*/
63858 +static char *learn_buffer;
63859 +static char *learn_buffer_user;
63860 +static int learn_buffer_len;
63861 +static int learn_buffer_user_len;
63862 +
63863 +static ssize_t
63864 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63865 +{
63866 + DECLARE_WAITQUEUE(wait, current);
63867 + ssize_t retval = 0;
63868 +
63869 + add_wait_queue(&learn_wait, &wait);
63870 + set_current_state(TASK_INTERRUPTIBLE);
63871 + do {
63872 + mutex_lock(&gr_learn_user_mutex);
63873 + spin_lock(&gr_learn_lock);
63874 + if (learn_buffer_len)
63875 + break;
63876 + spin_unlock(&gr_learn_lock);
63877 + mutex_unlock(&gr_learn_user_mutex);
63878 + if (file->f_flags & O_NONBLOCK) {
63879 + retval = -EAGAIN;
63880 + goto out;
63881 + }
63882 + if (signal_pending(current)) {
63883 + retval = -ERESTARTSYS;
63884 + goto out;
63885 + }
63886 +
63887 + schedule();
63888 + } while (1);
63889 +
63890 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63891 + learn_buffer_user_len = learn_buffer_len;
63892 + retval = learn_buffer_len;
63893 + learn_buffer_len = 0;
63894 +
63895 + spin_unlock(&gr_learn_lock);
63896 +
63897 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63898 + retval = -EFAULT;
63899 +
63900 + mutex_unlock(&gr_learn_user_mutex);
63901 +out:
63902 + set_current_state(TASK_RUNNING);
63903 + remove_wait_queue(&learn_wait, &wait);
63904 + return retval;
63905 +}
63906 +
63907 +static unsigned int
63908 +poll_learn(struct file * file, poll_table * wait)
63909 +{
63910 + poll_wait(file, &learn_wait, wait);
63911 +
63912 + if (learn_buffer_len)
63913 + return (POLLIN | POLLRDNORM);
63914 +
63915 + return 0;
63916 +}
63917 +
63918 +void
63919 +gr_clear_learn_entries(void)
63920 +{
63921 + char *tmp;
63922 +
63923 + mutex_lock(&gr_learn_user_mutex);
63924 + spin_lock(&gr_learn_lock);
63925 + tmp = learn_buffer;
63926 + learn_buffer = NULL;
63927 + spin_unlock(&gr_learn_lock);
63928 + if (tmp)
63929 + vfree(tmp);
63930 + if (learn_buffer_user != NULL) {
63931 + vfree(learn_buffer_user);
63932 + learn_buffer_user = NULL;
63933 + }
63934 + learn_buffer_len = 0;
63935 + mutex_unlock(&gr_learn_user_mutex);
63936 +
63937 + return;
63938 +}
63939 +
63940 +void
63941 +gr_add_learn_entry(const char *fmt, ...)
63942 +{
63943 + va_list args;
63944 + unsigned int len;
63945 +
63946 + if (!gr_learn_attached)
63947 + return;
63948 +
63949 + spin_lock(&gr_learn_lock);
63950 +
63951 + /* leave a gap at the end so we know when it's "full" but don't have to
63952 + compute the exact length of the string we're trying to append
63953 + */
63954 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63955 + spin_unlock(&gr_learn_lock);
63956 + wake_up_interruptible(&learn_wait);
63957 + return;
63958 + }
63959 + if (learn_buffer == NULL) {
63960 + spin_unlock(&gr_learn_lock);
63961 + return;
63962 + }
63963 +
63964 + va_start(args, fmt);
63965 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63966 + va_end(args);
63967 +
63968 + learn_buffer_len += len + 1;
63969 +
63970 + spin_unlock(&gr_learn_lock);
63971 + wake_up_interruptible(&learn_wait);
63972 +
63973 + return;
63974 +}
63975 +
63976 +static int
63977 +open_learn(struct inode *inode, struct file *file)
63978 +{
63979 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63980 + return -EBUSY;
63981 + if (file->f_mode & FMODE_READ) {
63982 + int retval = 0;
63983 + mutex_lock(&gr_learn_user_mutex);
63984 + if (learn_buffer == NULL)
63985 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63986 + if (learn_buffer_user == NULL)
63987 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63988 + if (learn_buffer == NULL) {
63989 + retval = -ENOMEM;
63990 + goto out_error;
63991 + }
63992 + if (learn_buffer_user == NULL) {
63993 + retval = -ENOMEM;
63994 + goto out_error;
63995 + }
63996 + learn_buffer_len = 0;
63997 + learn_buffer_user_len = 0;
63998 + gr_learn_attached = 1;
63999 +out_error:
64000 + mutex_unlock(&gr_learn_user_mutex);
64001 + return retval;
64002 + }
64003 + return 0;
64004 +}
64005 +
64006 +static int
64007 +close_learn(struct inode *inode, struct file *file)
64008 +{
64009 + if (file->f_mode & FMODE_READ) {
64010 + char *tmp = NULL;
64011 + mutex_lock(&gr_learn_user_mutex);
64012 + spin_lock(&gr_learn_lock);
64013 + tmp = learn_buffer;
64014 + learn_buffer = NULL;
64015 + spin_unlock(&gr_learn_lock);
64016 + if (tmp)
64017 + vfree(tmp);
64018 + if (learn_buffer_user != NULL) {
64019 + vfree(learn_buffer_user);
64020 + learn_buffer_user = NULL;
64021 + }
64022 + learn_buffer_len = 0;
64023 + learn_buffer_user_len = 0;
64024 + gr_learn_attached = 0;
64025 + mutex_unlock(&gr_learn_user_mutex);
64026 + }
64027 +
64028 + return 0;
64029 +}
64030 +
64031 +const struct file_operations grsec_fops = {
64032 + .read = read_learn,
64033 + .write = write_grsec_handler,
64034 + .open = open_learn,
64035 + .release = close_learn,
64036 + .poll = poll_learn,
64037 +};
64038 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
64039 new file mode 100644
64040 index 0000000..39645c9
64041 --- /dev/null
64042 +++ b/grsecurity/gracl_res.c
64043 @@ -0,0 +1,68 @@
64044 +#include <linux/kernel.h>
64045 +#include <linux/sched.h>
64046 +#include <linux/gracl.h>
64047 +#include <linux/grinternal.h>
64048 +
64049 +static const char *restab_log[] = {
64050 + [RLIMIT_CPU] = "RLIMIT_CPU",
64051 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
64052 + [RLIMIT_DATA] = "RLIMIT_DATA",
64053 + [RLIMIT_STACK] = "RLIMIT_STACK",
64054 + [RLIMIT_CORE] = "RLIMIT_CORE",
64055 + [RLIMIT_RSS] = "RLIMIT_RSS",
64056 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
64057 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
64058 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
64059 + [RLIMIT_AS] = "RLIMIT_AS",
64060 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
64061 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
64062 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
64063 + [RLIMIT_NICE] = "RLIMIT_NICE",
64064 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
64065 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
64066 + [GR_CRASH_RES] = "RLIMIT_CRASH"
64067 +};
64068 +
64069 +void
64070 +gr_log_resource(const struct task_struct *task,
64071 + const int res, const unsigned long wanted, const int gt)
64072 +{
64073 + const struct cred *cred;
64074 + unsigned long rlim;
64075 +
64076 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
64077 + return;
64078 +
64079 + // not yet supported resource
64080 + if (unlikely(!restab_log[res]))
64081 + return;
64082 +
64083 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
64084 + rlim = task_rlimit_max(task, res);
64085 + else
64086 + rlim = task_rlimit(task, res);
64087 +
64088 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
64089 + return;
64090 +
64091 + rcu_read_lock();
64092 + cred = __task_cred(task);
64093 +
64094 + if (res == RLIMIT_NPROC &&
64095 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
64096 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
64097 + goto out_rcu_unlock;
64098 + else if (res == RLIMIT_MEMLOCK &&
64099 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
64100 + goto out_rcu_unlock;
64101 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
64102 + goto out_rcu_unlock;
64103 + rcu_read_unlock();
64104 +
64105 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
64106 +
64107 + return;
64108 +out_rcu_unlock:
64109 + rcu_read_unlock();
64110 + return;
64111 +}
64112 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
64113 new file mode 100644
64114 index 0000000..cb1e5ab
64115 --- /dev/null
64116 +++ b/grsecurity/gracl_segv.c
64117 @@ -0,0 +1,303 @@
64118 +#include <linux/kernel.h>
64119 +#include <linux/mm.h>
64120 +#include <asm/uaccess.h>
64121 +#include <asm/errno.h>
64122 +#include <asm/mman.h>
64123 +#include <net/sock.h>
64124 +#include <linux/file.h>
64125 +#include <linux/fs.h>
64126 +#include <linux/net.h>
64127 +#include <linux/in.h>
64128 +#include <linux/slab.h>
64129 +#include <linux/types.h>
64130 +#include <linux/sched.h>
64131 +#include <linux/timer.h>
64132 +#include <linux/gracl.h>
64133 +#include <linux/grsecurity.h>
64134 +#include <linux/grinternal.h>
64135 +
64136 +static struct crash_uid *uid_set;
64137 +static unsigned short uid_used;
64138 +static DEFINE_SPINLOCK(gr_uid_lock);
64139 +extern rwlock_t gr_inode_lock;
64140 +extern struct acl_subject_label *
64141 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
64142 + struct acl_role_label *role);
64143 +
64144 +#ifdef CONFIG_BTRFS_FS
64145 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
64146 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
64147 +#endif
64148 +
64149 +static inline dev_t __get_dev(const struct dentry *dentry)
64150 +{
64151 +#ifdef CONFIG_BTRFS_FS
64152 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
64153 + return get_btrfs_dev_from_inode(dentry->d_inode);
64154 + else
64155 +#endif
64156 + return dentry->d_inode->i_sb->s_dev;
64157 +}
64158 +
64159 +int
64160 +gr_init_uidset(void)
64161 +{
64162 + uid_set =
64163 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
64164 + uid_used = 0;
64165 +
64166 + return uid_set ? 1 : 0;
64167 +}
64168 +
64169 +void
64170 +gr_free_uidset(void)
64171 +{
64172 + if (uid_set)
64173 + kfree(uid_set);
64174 +
64175 + return;
64176 +}
64177 +
64178 +int
64179 +gr_find_uid(const uid_t uid)
64180 +{
64181 + struct crash_uid *tmp = uid_set;
64182 + uid_t buid;
64183 + int low = 0, high = uid_used - 1, mid;
64184 +
64185 + while (high >= low) {
64186 + mid = (low + high) >> 1;
64187 + buid = tmp[mid].uid;
64188 + if (buid == uid)
64189 + return mid;
64190 + if (buid > uid)
64191 + high = mid - 1;
64192 + if (buid < uid)
64193 + low = mid + 1;
64194 + }
64195 +
64196 + return -1;
64197 +}
64198 +
64199 +static __inline__ void
64200 +gr_insertsort(void)
64201 +{
64202 + unsigned short i, j;
64203 + struct crash_uid index;
64204 +
64205 + for (i = 1; i < uid_used; i++) {
64206 + index = uid_set[i];
64207 + j = i;
64208 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
64209 + uid_set[j] = uid_set[j - 1];
64210 + j--;
64211 + }
64212 + uid_set[j] = index;
64213 + }
64214 +
64215 + return;
64216 +}
64217 +
64218 +static __inline__ void
64219 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
64220 +{
64221 + int loc;
64222 + uid_t uid = GR_GLOBAL_UID(kuid);
64223 +
64224 + if (uid_used == GR_UIDTABLE_MAX)
64225 + return;
64226 +
64227 + loc = gr_find_uid(uid);
64228 +
64229 + if (loc >= 0) {
64230 + uid_set[loc].expires = expires;
64231 + return;
64232 + }
64233 +
64234 + uid_set[uid_used].uid = uid;
64235 + uid_set[uid_used].expires = expires;
64236 + uid_used++;
64237 +
64238 + gr_insertsort();
64239 +
64240 + return;
64241 +}
64242 +
64243 +void
64244 +gr_remove_uid(const unsigned short loc)
64245 +{
64246 + unsigned short i;
64247 +
64248 + for (i = loc + 1; i < uid_used; i++)
64249 + uid_set[i - 1] = uid_set[i];
64250 +
64251 + uid_used--;
64252 +
64253 + return;
64254 +}
64255 +
64256 +int
64257 +gr_check_crash_uid(const kuid_t kuid)
64258 +{
64259 + int loc;
64260 + int ret = 0;
64261 + uid_t uid;
64262 +
64263 + if (unlikely(!gr_acl_is_enabled()))
64264 + return 0;
64265 +
64266 + uid = GR_GLOBAL_UID(kuid);
64267 +
64268 + spin_lock(&gr_uid_lock);
64269 + loc = gr_find_uid(uid);
64270 +
64271 + if (loc < 0)
64272 + goto out_unlock;
64273 +
64274 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
64275 + gr_remove_uid(loc);
64276 + else
64277 + ret = 1;
64278 +
64279 +out_unlock:
64280 + spin_unlock(&gr_uid_lock);
64281 + return ret;
64282 +}
64283 +
64284 +static __inline__ int
64285 +proc_is_setxid(const struct cred *cred)
64286 +{
64287 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
64288 + !uid_eq(cred->uid, cred->fsuid))
64289 + return 1;
64290 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
64291 + !gid_eq(cred->gid, cred->fsgid))
64292 + return 1;
64293 +
64294 + return 0;
64295 +}
64296 +
64297 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
64298 +
64299 +void
64300 +gr_handle_crash(struct task_struct *task, const int sig)
64301 +{
64302 + struct acl_subject_label *curr;
64303 + struct task_struct *tsk, *tsk2;
64304 + const struct cred *cred;
64305 + const struct cred *cred2;
64306 +
64307 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
64308 + return;
64309 +
64310 + if (unlikely(!gr_acl_is_enabled()))
64311 + return;
64312 +
64313 + curr = task->acl;
64314 +
64315 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
64316 + return;
64317 +
64318 + if (time_before_eq(curr->expires, get_seconds())) {
64319 + curr->expires = 0;
64320 + curr->crashes = 0;
64321 + }
64322 +
64323 + curr->crashes++;
64324 +
64325 + if (!curr->expires)
64326 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
64327 +
64328 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
64329 + time_after(curr->expires, get_seconds())) {
64330 + rcu_read_lock();
64331 + cred = __task_cred(task);
64332 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
64333 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
64334 + spin_lock(&gr_uid_lock);
64335 + gr_insert_uid(cred->uid, curr->expires);
64336 + spin_unlock(&gr_uid_lock);
64337 + curr->expires = 0;
64338 + curr->crashes = 0;
64339 + read_lock(&tasklist_lock);
64340 + do_each_thread(tsk2, tsk) {
64341 + cred2 = __task_cred(tsk);
64342 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
64343 + gr_fake_force_sig(SIGKILL, tsk);
64344 + } while_each_thread(tsk2, tsk);
64345 + read_unlock(&tasklist_lock);
64346 + } else {
64347 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
64348 + read_lock(&tasklist_lock);
64349 + read_lock(&grsec_exec_file_lock);
64350 + do_each_thread(tsk2, tsk) {
64351 + if (likely(tsk != task)) {
64352 + // if this thread has the same subject as the one that triggered
64353 + // RES_CRASH and it's the same binary, kill it
64354 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
64355 + gr_fake_force_sig(SIGKILL, tsk);
64356 + }
64357 + } while_each_thread(tsk2, tsk);
64358 + read_unlock(&grsec_exec_file_lock);
64359 + read_unlock(&tasklist_lock);
64360 + }
64361 + rcu_read_unlock();
64362 + }
64363 +
64364 + return;
64365 +}
64366 +
64367 +int
64368 +gr_check_crash_exec(const struct file *filp)
64369 +{
64370 + struct acl_subject_label *curr;
64371 +
64372 + if (unlikely(!gr_acl_is_enabled()))
64373 + return 0;
64374 +
64375 + read_lock(&gr_inode_lock);
64376 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
64377 + __get_dev(filp->f_path.dentry),
64378 + current->role);
64379 + read_unlock(&gr_inode_lock);
64380 +
64381 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
64382 + (!curr->crashes && !curr->expires))
64383 + return 0;
64384 +
64385 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
64386 + time_after(curr->expires, get_seconds()))
64387 + return 1;
64388 + else if (time_before_eq(curr->expires, get_seconds())) {
64389 + curr->crashes = 0;
64390 + curr->expires = 0;
64391 + }
64392 +
64393 + return 0;
64394 +}
64395 +
64396 +void
64397 +gr_handle_alertkill(struct task_struct *task)
64398 +{
64399 + struct acl_subject_label *curracl;
64400 + __u32 curr_ip;
64401 + struct task_struct *p, *p2;
64402 +
64403 + if (unlikely(!gr_acl_is_enabled()))
64404 + return;
64405 +
64406 + curracl = task->acl;
64407 + curr_ip = task->signal->curr_ip;
64408 +
64409 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
64410 + read_lock(&tasklist_lock);
64411 + do_each_thread(p2, p) {
64412 + if (p->signal->curr_ip == curr_ip)
64413 + gr_fake_force_sig(SIGKILL, p);
64414 + } while_each_thread(p2, p);
64415 + read_unlock(&tasklist_lock);
64416 + } else if (curracl->mode & GR_KILLPROC)
64417 + gr_fake_force_sig(SIGKILL, task);
64418 +
64419 + return;
64420 +}
64421 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
64422 new file mode 100644
64423 index 0000000..98011b0
64424 --- /dev/null
64425 +++ b/grsecurity/gracl_shm.c
64426 @@ -0,0 +1,40 @@
64427 +#include <linux/kernel.h>
64428 +#include <linux/mm.h>
64429 +#include <linux/sched.h>
64430 +#include <linux/file.h>
64431 +#include <linux/ipc.h>
64432 +#include <linux/gracl.h>
64433 +#include <linux/grsecurity.h>
64434 +#include <linux/grinternal.h>
64435 +
64436 +int
64437 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64438 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64439 +{
64440 + struct task_struct *task;
64441 +
64442 + if (!gr_acl_is_enabled())
64443 + return 1;
64444 +
64445 + rcu_read_lock();
64446 + read_lock(&tasklist_lock);
64447 +
64448 + task = find_task_by_vpid(shm_cprid);
64449 +
64450 + if (unlikely(!task))
64451 + task = find_task_by_vpid(shm_lapid);
64452 +
64453 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
64454 + (task_pid_nr(task) == shm_lapid)) &&
64455 + (task->acl->mode & GR_PROTSHM) &&
64456 + (task->acl != current->acl))) {
64457 + read_unlock(&tasklist_lock);
64458 + rcu_read_unlock();
64459 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
64460 + return 0;
64461 + }
64462 + read_unlock(&tasklist_lock);
64463 + rcu_read_unlock();
64464 +
64465 + return 1;
64466 +}
64467 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
64468 new file mode 100644
64469 index 0000000..bc0be01
64470 --- /dev/null
64471 +++ b/grsecurity/grsec_chdir.c
64472 @@ -0,0 +1,19 @@
64473 +#include <linux/kernel.h>
64474 +#include <linux/sched.h>
64475 +#include <linux/fs.h>
64476 +#include <linux/file.h>
64477 +#include <linux/grsecurity.h>
64478 +#include <linux/grinternal.h>
64479 +
64480 +void
64481 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
64482 +{
64483 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
64484 + if ((grsec_enable_chdir && grsec_enable_group &&
64485 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
64486 + !grsec_enable_group)) {
64487 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
64488 + }
64489 +#endif
64490 + return;
64491 +}
64492 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
64493 new file mode 100644
64494 index 0000000..6d2de57
64495 --- /dev/null
64496 +++ b/grsecurity/grsec_chroot.c
64497 @@ -0,0 +1,357 @@
64498 +#include <linux/kernel.h>
64499 +#include <linux/module.h>
64500 +#include <linux/sched.h>
64501 +#include <linux/file.h>
64502 +#include <linux/fs.h>
64503 +#include <linux/mount.h>
64504 +#include <linux/types.h>
64505 +#include "../fs/mount.h"
64506 +#include <linux/grsecurity.h>
64507 +#include <linux/grinternal.h>
64508 +
64509 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
64510 +{
64511 +#ifdef CONFIG_GRKERNSEC
64512 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
64513 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
64514 + task->gr_is_chrooted = 1;
64515 + else
64516 + task->gr_is_chrooted = 0;
64517 +
64518 + task->gr_chroot_dentry = path->dentry;
64519 +#endif
64520 + return;
64521 +}
64522 +
64523 +void gr_clear_chroot_entries(struct task_struct *task)
64524 +{
64525 +#ifdef CONFIG_GRKERNSEC
64526 + task->gr_is_chrooted = 0;
64527 + task->gr_chroot_dentry = NULL;
64528 +#endif
64529 + return;
64530 +}
64531 +
64532 +int
64533 +gr_handle_chroot_unix(const pid_t pid)
64534 +{
64535 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64536 + struct task_struct *p;
64537 +
64538 + if (unlikely(!grsec_enable_chroot_unix))
64539 + return 1;
64540 +
64541 + if (likely(!proc_is_chrooted(current)))
64542 + return 1;
64543 +
64544 + rcu_read_lock();
64545 + read_lock(&tasklist_lock);
64546 + p = find_task_by_vpid_unrestricted(pid);
64547 + if (unlikely(p && !have_same_root(current, p))) {
64548 + read_unlock(&tasklist_lock);
64549 + rcu_read_unlock();
64550 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
64551 + return 0;
64552 + }
64553 + read_unlock(&tasklist_lock);
64554 + rcu_read_unlock();
64555 +#endif
64556 + return 1;
64557 +}
64558 +
64559 +int
64560 +gr_handle_chroot_nice(void)
64561 +{
64562 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64563 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
64564 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
64565 + return -EPERM;
64566 + }
64567 +#endif
64568 + return 0;
64569 +}
64570 +
64571 +int
64572 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64573 +{
64574 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64575 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64576 + && proc_is_chrooted(current)) {
64577 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64578 + return -EACCES;
64579 + }
64580 +#endif
64581 + return 0;
64582 +}
64583 +
64584 +int
64585 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64586 +{
64587 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64588 + struct task_struct *p;
64589 + int ret = 0;
64590 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64591 + return ret;
64592 +
64593 + read_lock(&tasklist_lock);
64594 + do_each_pid_task(pid, type, p) {
64595 + if (!have_same_root(current, p)) {
64596 + ret = 1;
64597 + goto out;
64598 + }
64599 + } while_each_pid_task(pid, type, p);
64600 +out:
64601 + read_unlock(&tasklist_lock);
64602 + return ret;
64603 +#endif
64604 + return 0;
64605 +}
64606 +
64607 +int
64608 +gr_pid_is_chrooted(struct task_struct *p)
64609 +{
64610 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64611 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64612 + return 0;
64613 +
64614 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64615 + !have_same_root(current, p)) {
64616 + return 1;
64617 + }
64618 +#endif
64619 + return 0;
64620 +}
64621 +
64622 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64623 +
64624 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64625 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64626 +{
64627 + struct path path, currentroot;
64628 + int ret = 0;
64629 +
64630 + path.dentry = (struct dentry *)u_dentry;
64631 + path.mnt = (struct vfsmount *)u_mnt;
64632 + get_fs_root(current->fs, &currentroot);
64633 + if (path_is_under(&path, &currentroot))
64634 + ret = 1;
64635 + path_put(&currentroot);
64636 +
64637 + return ret;
64638 +}
64639 +#endif
64640 +
64641 +int
64642 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64643 +{
64644 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64645 + if (!grsec_enable_chroot_fchdir)
64646 + return 1;
64647 +
64648 + if (!proc_is_chrooted(current))
64649 + return 1;
64650 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64651 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64652 + return 0;
64653 + }
64654 +#endif
64655 + return 1;
64656 +}
64657 +
64658 +int
64659 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64660 + const time_t shm_createtime)
64661 +{
64662 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64663 + struct task_struct *p;
64664 + time_t starttime;
64665 +
64666 + if (unlikely(!grsec_enable_chroot_shmat))
64667 + return 1;
64668 +
64669 + if (likely(!proc_is_chrooted(current)))
64670 + return 1;
64671 +
64672 + rcu_read_lock();
64673 + read_lock(&tasklist_lock);
64674 +
64675 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64676 + starttime = p->start_time.tv_sec;
64677 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64678 + if (have_same_root(current, p)) {
64679 + goto allow;
64680 + } else {
64681 + read_unlock(&tasklist_lock);
64682 + rcu_read_unlock();
64683 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64684 + return 0;
64685 + }
64686 + }
64687 + /* creator exited, pid reuse, fall through to next check */
64688 + }
64689 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64690 + if (unlikely(!have_same_root(current, p))) {
64691 + read_unlock(&tasklist_lock);
64692 + rcu_read_unlock();
64693 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64694 + return 0;
64695 + }
64696 + }
64697 +
64698 +allow:
64699 + read_unlock(&tasklist_lock);
64700 + rcu_read_unlock();
64701 +#endif
64702 + return 1;
64703 +}
64704 +
64705 +void
64706 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64707 +{
64708 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64709 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64710 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64711 +#endif
64712 + return;
64713 +}
64714 +
64715 +int
64716 +gr_handle_chroot_mknod(const struct dentry *dentry,
64717 + const struct vfsmount *mnt, const int mode)
64718 +{
64719 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64720 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64721 + proc_is_chrooted(current)) {
64722 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64723 + return -EPERM;
64724 + }
64725 +#endif
64726 + return 0;
64727 +}
64728 +
64729 +int
64730 +gr_handle_chroot_mount(const struct dentry *dentry,
64731 + const struct vfsmount *mnt, const char *dev_name)
64732 +{
64733 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64734 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64735 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64736 + return -EPERM;
64737 + }
64738 +#endif
64739 + return 0;
64740 +}
64741 +
64742 +int
64743 +gr_handle_chroot_pivot(void)
64744 +{
64745 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64746 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64747 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64748 + return -EPERM;
64749 + }
64750 +#endif
64751 + return 0;
64752 +}
64753 +
64754 +int
64755 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64756 +{
64757 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64758 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64759 + !gr_is_outside_chroot(dentry, mnt)) {
64760 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64761 + return -EPERM;
64762 + }
64763 +#endif
64764 + return 0;
64765 +}
64766 +
64767 +extern const char *captab_log[];
64768 +extern int captab_log_entries;
64769 +
64770 +int
64771 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64772 +{
64773 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64774 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64775 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64776 + if (cap_raised(chroot_caps, cap)) {
64777 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64778 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64779 + }
64780 + return 0;
64781 + }
64782 + }
64783 +#endif
64784 + return 1;
64785 +}
64786 +
64787 +int
64788 +gr_chroot_is_capable(const int cap)
64789 +{
64790 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64791 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64792 +#endif
64793 + return 1;
64794 +}
64795 +
64796 +int
64797 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64798 +{
64799 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64800 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64801 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64802 + if (cap_raised(chroot_caps, cap)) {
64803 + return 0;
64804 + }
64805 + }
64806 +#endif
64807 + return 1;
64808 +}
64809 +
64810 +int
64811 +gr_chroot_is_capable_nolog(const int cap)
64812 +{
64813 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64814 + return gr_task_chroot_is_capable_nolog(current, cap);
64815 +#endif
64816 + return 1;
64817 +}
64818 +
64819 +int
64820 +gr_handle_chroot_sysctl(const int op)
64821 +{
64822 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64823 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64824 + proc_is_chrooted(current))
64825 + return -EACCES;
64826 +#endif
64827 + return 0;
64828 +}
64829 +
64830 +void
64831 +gr_handle_chroot_chdir(struct path *path)
64832 +{
64833 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64834 + if (grsec_enable_chroot_chdir)
64835 + set_fs_pwd(current->fs, path);
64836 +#endif
64837 + return;
64838 +}
64839 +
64840 +int
64841 +gr_handle_chroot_chmod(const struct dentry *dentry,
64842 + const struct vfsmount *mnt, const int mode)
64843 +{
64844 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64845 + /* allow chmod +s on directories, but not files */
64846 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64847 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64848 + proc_is_chrooted(current)) {
64849 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64850 + return -EPERM;
64851 + }
64852 +#endif
64853 + return 0;
64854 +}
64855 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64856 new file mode 100644
64857 index 0000000..207d409
64858 --- /dev/null
64859 +++ b/grsecurity/grsec_disabled.c
64860 @@ -0,0 +1,434 @@
64861 +#include <linux/kernel.h>
64862 +#include <linux/module.h>
64863 +#include <linux/sched.h>
64864 +#include <linux/file.h>
64865 +#include <linux/fs.h>
64866 +#include <linux/kdev_t.h>
64867 +#include <linux/net.h>
64868 +#include <linux/in.h>
64869 +#include <linux/ip.h>
64870 +#include <linux/skbuff.h>
64871 +#include <linux/sysctl.h>
64872 +
64873 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64874 +void
64875 +pax_set_initial_flags(struct linux_binprm *bprm)
64876 +{
64877 + return;
64878 +}
64879 +#endif
64880 +
64881 +#ifdef CONFIG_SYSCTL
64882 +__u32
64883 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64884 +{
64885 + return 0;
64886 +}
64887 +#endif
64888 +
64889 +#ifdef CONFIG_TASKSTATS
64890 +int gr_is_taskstats_denied(int pid)
64891 +{
64892 + return 0;
64893 +}
64894 +#endif
64895 +
64896 +int
64897 +gr_acl_is_enabled(void)
64898 +{
64899 + return 0;
64900 +}
64901 +
64902 +void
64903 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64904 +{
64905 + return;
64906 +}
64907 +
64908 +int
64909 +gr_handle_rawio(const struct inode *inode)
64910 +{
64911 + return 0;
64912 +}
64913 +
64914 +void
64915 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64916 +{
64917 + return;
64918 +}
64919 +
64920 +int
64921 +gr_handle_ptrace(struct task_struct *task, const long request)
64922 +{
64923 + return 0;
64924 +}
64925 +
64926 +int
64927 +gr_handle_proc_ptrace(struct task_struct *task)
64928 +{
64929 + return 0;
64930 +}
64931 +
64932 +int
64933 +gr_set_acls(const int type)
64934 +{
64935 + return 0;
64936 +}
64937 +
64938 +int
64939 +gr_check_hidden_task(const struct task_struct *tsk)
64940 +{
64941 + return 0;
64942 +}
64943 +
64944 +int
64945 +gr_check_protected_task(const struct task_struct *task)
64946 +{
64947 + return 0;
64948 +}
64949 +
64950 +int
64951 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64952 +{
64953 + return 0;
64954 +}
64955 +
64956 +void
64957 +gr_copy_label(struct task_struct *tsk)
64958 +{
64959 + return;
64960 +}
64961 +
64962 +void
64963 +gr_set_pax_flags(struct task_struct *task)
64964 +{
64965 + return;
64966 +}
64967 +
64968 +int
64969 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64970 + const int unsafe_share)
64971 +{
64972 + return 0;
64973 +}
64974 +
64975 +void
64976 +gr_handle_delete(const ino_t ino, const dev_t dev)
64977 +{
64978 + return;
64979 +}
64980 +
64981 +void
64982 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64983 +{
64984 + return;
64985 +}
64986 +
64987 +void
64988 +gr_handle_crash(struct task_struct *task, const int sig)
64989 +{
64990 + return;
64991 +}
64992 +
64993 +int
64994 +gr_check_crash_exec(const struct file *filp)
64995 +{
64996 + return 0;
64997 +}
64998 +
64999 +int
65000 +gr_check_crash_uid(const kuid_t uid)
65001 +{
65002 + return 0;
65003 +}
65004 +
65005 +void
65006 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65007 + struct dentry *old_dentry,
65008 + struct dentry *new_dentry,
65009 + struct vfsmount *mnt, const __u8 replace)
65010 +{
65011 + return;
65012 +}
65013 +
65014 +int
65015 +gr_search_socket(const int family, const int type, const int protocol)
65016 +{
65017 + return 1;
65018 +}
65019 +
65020 +int
65021 +gr_search_connectbind(const int mode, const struct socket *sock,
65022 + const struct sockaddr_in *addr)
65023 +{
65024 + return 0;
65025 +}
65026 +
65027 +void
65028 +gr_handle_alertkill(struct task_struct *task)
65029 +{
65030 + return;
65031 +}
65032 +
65033 +__u32
65034 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
65035 +{
65036 + return 1;
65037 +}
65038 +
65039 +__u32
65040 +gr_acl_handle_hidden_file(const struct dentry * dentry,
65041 + const struct vfsmount * mnt)
65042 +{
65043 + return 1;
65044 +}
65045 +
65046 +__u32
65047 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
65048 + int acc_mode)
65049 +{
65050 + return 1;
65051 +}
65052 +
65053 +__u32
65054 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
65055 +{
65056 + return 1;
65057 +}
65058 +
65059 +__u32
65060 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
65061 +{
65062 + return 1;
65063 +}
65064 +
65065 +int
65066 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
65067 + unsigned int *vm_flags)
65068 +{
65069 + return 1;
65070 +}
65071 +
65072 +__u32
65073 +gr_acl_handle_truncate(const struct dentry * dentry,
65074 + const struct vfsmount * mnt)
65075 +{
65076 + return 1;
65077 +}
65078 +
65079 +__u32
65080 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
65081 +{
65082 + return 1;
65083 +}
65084 +
65085 +__u32
65086 +gr_acl_handle_access(const struct dentry * dentry,
65087 + const struct vfsmount * mnt, const int fmode)
65088 +{
65089 + return 1;
65090 +}
65091 +
65092 +__u32
65093 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
65094 + umode_t *mode)
65095 +{
65096 + return 1;
65097 +}
65098 +
65099 +__u32
65100 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
65101 +{
65102 + return 1;
65103 +}
65104 +
65105 +__u32
65106 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
65107 +{
65108 + return 1;
65109 +}
65110 +
65111 +void
65112 +grsecurity_init(void)
65113 +{
65114 + return;
65115 +}
65116 +
65117 +umode_t gr_acl_umask(void)
65118 +{
65119 + return 0;
65120 +}
65121 +
65122 +__u32
65123 +gr_acl_handle_mknod(const struct dentry * new_dentry,
65124 + const struct dentry * parent_dentry,
65125 + const struct vfsmount * parent_mnt,
65126 + const int mode)
65127 +{
65128 + return 1;
65129 +}
65130 +
65131 +__u32
65132 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
65133 + const struct dentry * parent_dentry,
65134 + const struct vfsmount * parent_mnt)
65135 +{
65136 + return 1;
65137 +}
65138 +
65139 +__u32
65140 +gr_acl_handle_symlink(const struct dentry * new_dentry,
65141 + const struct dentry * parent_dentry,
65142 + const struct vfsmount * parent_mnt, const struct filename *from)
65143 +{
65144 + return 1;
65145 +}
65146 +
65147 +__u32
65148 +gr_acl_handle_link(const struct dentry * new_dentry,
65149 + const struct dentry * parent_dentry,
65150 + const struct vfsmount * parent_mnt,
65151 + const struct dentry * old_dentry,
65152 + const struct vfsmount * old_mnt, const struct filename *to)
65153 +{
65154 + return 1;
65155 +}
65156 +
65157 +int
65158 +gr_acl_handle_rename(const struct dentry *new_dentry,
65159 + const struct dentry *parent_dentry,
65160 + const struct vfsmount *parent_mnt,
65161 + const struct dentry *old_dentry,
65162 + const struct inode *old_parent_inode,
65163 + const struct vfsmount *old_mnt, const struct filename *newname)
65164 +{
65165 + return 0;
65166 +}
65167 +
65168 +int
65169 +gr_acl_handle_filldir(const struct file *file, const char *name,
65170 + const int namelen, const ino_t ino)
65171 +{
65172 + return 1;
65173 +}
65174 +
65175 +int
65176 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
65177 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
65178 +{
65179 + return 1;
65180 +}
65181 +
65182 +int
65183 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
65184 +{
65185 + return 0;
65186 +}
65187 +
65188 +int
65189 +gr_search_accept(const struct socket *sock)
65190 +{
65191 + return 0;
65192 +}
65193 +
65194 +int
65195 +gr_search_listen(const struct socket *sock)
65196 +{
65197 + return 0;
65198 +}
65199 +
65200 +int
65201 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
65202 +{
65203 + return 0;
65204 +}
65205 +
65206 +__u32
65207 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
65208 +{
65209 + return 1;
65210 +}
65211 +
65212 +__u32
65213 +gr_acl_handle_creat(const struct dentry * dentry,
65214 + const struct dentry * p_dentry,
65215 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
65216 + const int imode)
65217 +{
65218 + return 1;
65219 +}
65220 +
65221 +void
65222 +gr_acl_handle_exit(void)
65223 +{
65224 + return;
65225 +}
65226 +
65227 +int
65228 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
65229 +{
65230 + return 1;
65231 +}
65232 +
65233 +void
65234 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
65235 +{
65236 + return;
65237 +}
65238 +
65239 +int
65240 +gr_acl_handle_procpidmem(const struct task_struct *task)
65241 +{
65242 + return 0;
65243 +}
65244 +
65245 +int
65246 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
65247 +{
65248 + return 0;
65249 +}
65250 +
65251 +int
65252 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
65253 +{
65254 + return 0;
65255 +}
65256 +
65257 +void
65258 +gr_set_kernel_label(struct task_struct *task)
65259 +{
65260 + return;
65261 +}
65262 +
65263 +int
65264 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
65265 +{
65266 + return 0;
65267 +}
65268 +
65269 +int
65270 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
65271 +{
65272 + return 0;
65273 +}
65274 +
65275 +int gr_acl_enable_at_secure(void)
65276 +{
65277 + return 0;
65278 +}
65279 +
65280 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
65281 +{
65282 + return dentry->d_inode->i_sb->s_dev;
65283 +}
65284 +
65285 +void gr_put_exec_file(struct task_struct *task)
65286 +{
65287 + return;
65288 +}
65289 +
65290 +EXPORT_SYMBOL(gr_set_kernel_label);
65291 +#ifdef CONFIG_SECURITY
65292 +EXPORT_SYMBOL(gr_check_user_change);
65293 +EXPORT_SYMBOL(gr_check_group_change);
65294 +#endif
65295 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
65296 new file mode 100644
65297 index 0000000..387032b
65298 --- /dev/null
65299 +++ b/grsecurity/grsec_exec.c
65300 @@ -0,0 +1,187 @@
65301 +#include <linux/kernel.h>
65302 +#include <linux/sched.h>
65303 +#include <linux/file.h>
65304 +#include <linux/binfmts.h>
65305 +#include <linux/fs.h>
65306 +#include <linux/types.h>
65307 +#include <linux/grdefs.h>
65308 +#include <linux/grsecurity.h>
65309 +#include <linux/grinternal.h>
65310 +#include <linux/capability.h>
65311 +#include <linux/module.h>
65312 +#include <linux/compat.h>
65313 +
65314 +#include <asm/uaccess.h>
65315 +
65316 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65317 +static char gr_exec_arg_buf[132];
65318 +static DEFINE_MUTEX(gr_exec_arg_mutex);
65319 +#endif
65320 +
65321 +struct user_arg_ptr {
65322 +#ifdef CONFIG_COMPAT
65323 + bool is_compat;
65324 +#endif
65325 + union {
65326 + const char __user *const __user *native;
65327 +#ifdef CONFIG_COMPAT
65328 + const compat_uptr_t __user *compat;
65329 +#endif
65330 + } ptr;
65331 +};
65332 +
65333 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
65334 +
65335 +void
65336 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
65337 +{
65338 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65339 + char *grarg = gr_exec_arg_buf;
65340 + unsigned int i, x, execlen = 0;
65341 + char c;
65342 +
65343 + if (!((grsec_enable_execlog && grsec_enable_group &&
65344 + in_group_p(grsec_audit_gid))
65345 + || (grsec_enable_execlog && !grsec_enable_group)))
65346 + return;
65347 +
65348 + mutex_lock(&gr_exec_arg_mutex);
65349 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
65350 +
65351 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
65352 + const char __user *p;
65353 + unsigned int len;
65354 +
65355 + p = get_user_arg_ptr(argv, i);
65356 + if (IS_ERR(p))
65357 + goto log;
65358 +
65359 + len = strnlen_user(p, 128 - execlen);
65360 + if (len > 128 - execlen)
65361 + len = 128 - execlen;
65362 + else if (len > 0)
65363 + len--;
65364 + if (copy_from_user(grarg + execlen, p, len))
65365 + goto log;
65366 +
65367 + /* rewrite unprintable characters */
65368 + for (x = 0; x < len; x++) {
65369 + c = *(grarg + execlen + x);
65370 + if (c < 32 || c > 126)
65371 + *(grarg + execlen + x) = ' ';
65372 + }
65373 +
65374 + execlen += len;
65375 + *(grarg + execlen) = ' ';
65376 + *(grarg + execlen + 1) = '\0';
65377 + execlen++;
65378 + }
65379 +
65380 + log:
65381 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
65382 + bprm->file->f_path.mnt, grarg);
65383 + mutex_unlock(&gr_exec_arg_mutex);
65384 +#endif
65385 + return;
65386 +}
65387 +
65388 +#ifdef CONFIG_GRKERNSEC
65389 +extern int gr_acl_is_capable(const int cap);
65390 +extern int gr_acl_is_capable_nolog(const int cap);
65391 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
65392 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
65393 +extern int gr_chroot_is_capable(const int cap);
65394 +extern int gr_chroot_is_capable_nolog(const int cap);
65395 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
65396 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
65397 +#endif
65398 +
65399 +const char *captab_log[] = {
65400 + "CAP_CHOWN",
65401 + "CAP_DAC_OVERRIDE",
65402 + "CAP_DAC_READ_SEARCH",
65403 + "CAP_FOWNER",
65404 + "CAP_FSETID",
65405 + "CAP_KILL",
65406 + "CAP_SETGID",
65407 + "CAP_SETUID",
65408 + "CAP_SETPCAP",
65409 + "CAP_LINUX_IMMUTABLE",
65410 + "CAP_NET_BIND_SERVICE",
65411 + "CAP_NET_BROADCAST",
65412 + "CAP_NET_ADMIN",
65413 + "CAP_NET_RAW",
65414 + "CAP_IPC_LOCK",
65415 + "CAP_IPC_OWNER",
65416 + "CAP_SYS_MODULE",
65417 + "CAP_SYS_RAWIO",
65418 + "CAP_SYS_CHROOT",
65419 + "CAP_SYS_PTRACE",
65420 + "CAP_SYS_PACCT",
65421 + "CAP_SYS_ADMIN",
65422 + "CAP_SYS_BOOT",
65423 + "CAP_SYS_NICE",
65424 + "CAP_SYS_RESOURCE",
65425 + "CAP_SYS_TIME",
65426 + "CAP_SYS_TTY_CONFIG",
65427 + "CAP_MKNOD",
65428 + "CAP_LEASE",
65429 + "CAP_AUDIT_WRITE",
65430 + "CAP_AUDIT_CONTROL",
65431 + "CAP_SETFCAP",
65432 + "CAP_MAC_OVERRIDE",
65433 + "CAP_MAC_ADMIN",
65434 + "CAP_SYSLOG",
65435 + "CAP_WAKE_ALARM"
65436 +};
65437 +
65438 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
65439 +
65440 +int gr_is_capable(const int cap)
65441 +{
65442 +#ifdef CONFIG_GRKERNSEC
65443 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
65444 + return 1;
65445 + return 0;
65446 +#else
65447 + return 1;
65448 +#endif
65449 +}
65450 +
65451 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
65452 +{
65453 +#ifdef CONFIG_GRKERNSEC
65454 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
65455 + return 1;
65456 + return 0;
65457 +#else
65458 + return 1;
65459 +#endif
65460 +}
65461 +
65462 +int gr_is_capable_nolog(const int cap)
65463 +{
65464 +#ifdef CONFIG_GRKERNSEC
65465 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
65466 + return 1;
65467 + return 0;
65468 +#else
65469 + return 1;
65470 +#endif
65471 +}
65472 +
65473 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
65474 +{
65475 +#ifdef CONFIG_GRKERNSEC
65476 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
65477 + return 1;
65478 + return 0;
65479 +#else
65480 + return 1;
65481 +#endif
65482 +}
65483 +
65484 +EXPORT_SYMBOL(gr_is_capable);
65485 +EXPORT_SYMBOL(gr_is_capable_nolog);
65486 +EXPORT_SYMBOL(gr_task_is_capable);
65487 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
65488 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
65489 new file mode 100644
65490 index 0000000..06cc6ea
65491 --- /dev/null
65492 +++ b/grsecurity/grsec_fifo.c
65493 @@ -0,0 +1,24 @@
65494 +#include <linux/kernel.h>
65495 +#include <linux/sched.h>
65496 +#include <linux/fs.h>
65497 +#include <linux/file.h>
65498 +#include <linux/grinternal.h>
65499 +
65500 +int
65501 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
65502 + const struct dentry *dir, const int flag, const int acc_mode)
65503 +{
65504 +#ifdef CONFIG_GRKERNSEC_FIFO
65505 + const struct cred *cred = current_cred();
65506 +
65507 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
65508 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
65509 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
65510 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
65511 + if (!inode_permission(dentry->d_inode, acc_mode))
65512 + 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));
65513 + return -EACCES;
65514 + }
65515 +#endif
65516 + return 0;
65517 +}
65518 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
65519 new file mode 100644
65520 index 0000000..8ca18bf
65521 --- /dev/null
65522 +++ b/grsecurity/grsec_fork.c
65523 @@ -0,0 +1,23 @@
65524 +#include <linux/kernel.h>
65525 +#include <linux/sched.h>
65526 +#include <linux/grsecurity.h>
65527 +#include <linux/grinternal.h>
65528 +#include <linux/errno.h>
65529 +
65530 +void
65531 +gr_log_forkfail(const int retval)
65532 +{
65533 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65534 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
65535 + switch (retval) {
65536 + case -EAGAIN:
65537 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
65538 + break;
65539 + case -ENOMEM:
65540 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
65541 + break;
65542 + }
65543 + }
65544 +#endif
65545 + return;
65546 +}
65547 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
65548 new file mode 100644
65549 index 0000000..a862e9f
65550 --- /dev/null
65551 +++ b/grsecurity/grsec_init.c
65552 @@ -0,0 +1,283 @@
65553 +#include <linux/kernel.h>
65554 +#include <linux/sched.h>
65555 +#include <linux/mm.h>
65556 +#include <linux/gracl.h>
65557 +#include <linux/slab.h>
65558 +#include <linux/vmalloc.h>
65559 +#include <linux/percpu.h>
65560 +#include <linux/module.h>
65561 +
65562 +int grsec_enable_ptrace_readexec;
65563 +int grsec_enable_setxid;
65564 +int grsec_enable_symlinkown;
65565 +kgid_t grsec_symlinkown_gid;
65566 +int grsec_enable_brute;
65567 +int grsec_enable_link;
65568 +int grsec_enable_dmesg;
65569 +int grsec_enable_harden_ptrace;
65570 +int grsec_enable_fifo;
65571 +int grsec_enable_execlog;
65572 +int grsec_enable_signal;
65573 +int grsec_enable_forkfail;
65574 +int grsec_enable_audit_ptrace;
65575 +int grsec_enable_time;
65576 +int grsec_enable_audit_textrel;
65577 +int grsec_enable_group;
65578 +kgid_t grsec_audit_gid;
65579 +int grsec_enable_chdir;
65580 +int grsec_enable_mount;
65581 +int grsec_enable_rofs;
65582 +int grsec_enable_chroot_findtask;
65583 +int grsec_enable_chroot_mount;
65584 +int grsec_enable_chroot_shmat;
65585 +int grsec_enable_chroot_fchdir;
65586 +int grsec_enable_chroot_double;
65587 +int grsec_enable_chroot_pivot;
65588 +int grsec_enable_chroot_chdir;
65589 +int grsec_enable_chroot_chmod;
65590 +int grsec_enable_chroot_mknod;
65591 +int grsec_enable_chroot_nice;
65592 +int grsec_enable_chroot_execlog;
65593 +int grsec_enable_chroot_caps;
65594 +int grsec_enable_chroot_sysctl;
65595 +int grsec_enable_chroot_unix;
65596 +int grsec_enable_tpe;
65597 +kgid_t grsec_tpe_gid;
65598 +int grsec_enable_blackhole;
65599 +#ifdef CONFIG_IPV6_MODULE
65600 +EXPORT_SYMBOL(grsec_enable_blackhole);
65601 +#endif
65602 +int grsec_lastack_retries;
65603 +int grsec_enable_tpe_all;
65604 +int grsec_enable_tpe_invert;
65605 +int grsec_enable_socket_all;
65606 +kgid_t grsec_socket_all_gid;
65607 +int grsec_enable_socket_client;
65608 +kgid_t grsec_socket_client_gid;
65609 +int grsec_enable_socket_server;
65610 +kgid_t grsec_socket_server_gid;
65611 +int grsec_resource_logging;
65612 +int grsec_disable_privio;
65613 +int grsec_enable_log_rwxmaps;
65614 +int grsec_lock;
65615 +
65616 +DEFINE_SPINLOCK(grsec_alert_lock);
65617 +unsigned long grsec_alert_wtime = 0;
65618 +unsigned long grsec_alert_fyet = 0;
65619 +
65620 +DEFINE_SPINLOCK(grsec_audit_lock);
65621 +
65622 +DEFINE_RWLOCK(grsec_exec_file_lock);
65623 +
65624 +char *gr_shared_page[4];
65625 +
65626 +char *gr_alert_log_fmt;
65627 +char *gr_audit_log_fmt;
65628 +char *gr_alert_log_buf;
65629 +char *gr_audit_log_buf;
65630 +
65631 +extern struct gr_arg *gr_usermode;
65632 +extern unsigned char *gr_system_salt;
65633 +extern unsigned char *gr_system_sum;
65634 +
65635 +void __init
65636 +grsecurity_init(void)
65637 +{
65638 + int j;
65639 + /* create the per-cpu shared pages */
65640 +
65641 +#ifdef CONFIG_X86
65642 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65643 +#endif
65644 +
65645 + for (j = 0; j < 4; j++) {
65646 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65647 + if (gr_shared_page[j] == NULL) {
65648 + panic("Unable to allocate grsecurity shared page");
65649 + return;
65650 + }
65651 + }
65652 +
65653 + /* allocate log buffers */
65654 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65655 + if (!gr_alert_log_fmt) {
65656 + panic("Unable to allocate grsecurity alert log format buffer");
65657 + return;
65658 + }
65659 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65660 + if (!gr_audit_log_fmt) {
65661 + panic("Unable to allocate grsecurity audit log format buffer");
65662 + return;
65663 + }
65664 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65665 + if (!gr_alert_log_buf) {
65666 + panic("Unable to allocate grsecurity alert log buffer");
65667 + return;
65668 + }
65669 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65670 + if (!gr_audit_log_buf) {
65671 + panic("Unable to allocate grsecurity audit log buffer");
65672 + return;
65673 + }
65674 +
65675 + /* allocate memory for authentication structure */
65676 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65677 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65678 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65679 +
65680 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65681 + panic("Unable to allocate grsecurity authentication structure");
65682 + return;
65683 + }
65684 +
65685 +
65686 +#ifdef CONFIG_GRKERNSEC_IO
65687 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65688 + grsec_disable_privio = 1;
65689 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65690 + grsec_disable_privio = 1;
65691 +#else
65692 + grsec_disable_privio = 0;
65693 +#endif
65694 +#endif
65695 +
65696 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65697 + /* for backward compatibility, tpe_invert always defaults to on if
65698 + enabled in the kernel
65699 + */
65700 + grsec_enable_tpe_invert = 1;
65701 +#endif
65702 +
65703 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65704 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65705 + grsec_lock = 1;
65706 +#endif
65707 +
65708 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65709 + grsec_enable_audit_textrel = 1;
65710 +#endif
65711 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65712 + grsec_enable_log_rwxmaps = 1;
65713 +#endif
65714 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65715 + grsec_enable_group = 1;
65716 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65717 +#endif
65718 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65719 + grsec_enable_ptrace_readexec = 1;
65720 +#endif
65721 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65722 + grsec_enable_chdir = 1;
65723 +#endif
65724 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65725 + grsec_enable_harden_ptrace = 1;
65726 +#endif
65727 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65728 + grsec_enable_mount = 1;
65729 +#endif
65730 +#ifdef CONFIG_GRKERNSEC_LINK
65731 + grsec_enable_link = 1;
65732 +#endif
65733 +#ifdef CONFIG_GRKERNSEC_BRUTE
65734 + grsec_enable_brute = 1;
65735 +#endif
65736 +#ifdef CONFIG_GRKERNSEC_DMESG
65737 + grsec_enable_dmesg = 1;
65738 +#endif
65739 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65740 + grsec_enable_blackhole = 1;
65741 + grsec_lastack_retries = 4;
65742 +#endif
65743 +#ifdef CONFIG_GRKERNSEC_FIFO
65744 + grsec_enable_fifo = 1;
65745 +#endif
65746 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65747 + grsec_enable_execlog = 1;
65748 +#endif
65749 +#ifdef CONFIG_GRKERNSEC_SETXID
65750 + grsec_enable_setxid = 1;
65751 +#endif
65752 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65753 + grsec_enable_signal = 1;
65754 +#endif
65755 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65756 + grsec_enable_forkfail = 1;
65757 +#endif
65758 +#ifdef CONFIG_GRKERNSEC_TIME
65759 + grsec_enable_time = 1;
65760 +#endif
65761 +#ifdef CONFIG_GRKERNSEC_RESLOG
65762 + grsec_resource_logging = 1;
65763 +#endif
65764 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65765 + grsec_enable_chroot_findtask = 1;
65766 +#endif
65767 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65768 + grsec_enable_chroot_unix = 1;
65769 +#endif
65770 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65771 + grsec_enable_chroot_mount = 1;
65772 +#endif
65773 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65774 + grsec_enable_chroot_fchdir = 1;
65775 +#endif
65776 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65777 + grsec_enable_chroot_shmat = 1;
65778 +#endif
65779 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65780 + grsec_enable_audit_ptrace = 1;
65781 +#endif
65782 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65783 + grsec_enable_chroot_double = 1;
65784 +#endif
65785 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65786 + grsec_enable_chroot_pivot = 1;
65787 +#endif
65788 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65789 + grsec_enable_chroot_chdir = 1;
65790 +#endif
65791 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65792 + grsec_enable_chroot_chmod = 1;
65793 +#endif
65794 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65795 + grsec_enable_chroot_mknod = 1;
65796 +#endif
65797 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65798 + grsec_enable_chroot_nice = 1;
65799 +#endif
65800 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65801 + grsec_enable_chroot_execlog = 1;
65802 +#endif
65803 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65804 + grsec_enable_chroot_caps = 1;
65805 +#endif
65806 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65807 + grsec_enable_chroot_sysctl = 1;
65808 +#endif
65809 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65810 + grsec_enable_symlinkown = 1;
65811 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65812 +#endif
65813 +#ifdef CONFIG_GRKERNSEC_TPE
65814 + grsec_enable_tpe = 1;
65815 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65816 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65817 + grsec_enable_tpe_all = 1;
65818 +#endif
65819 +#endif
65820 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65821 + grsec_enable_socket_all = 1;
65822 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65823 +#endif
65824 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65825 + grsec_enable_socket_client = 1;
65826 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65827 +#endif
65828 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65829 + grsec_enable_socket_server = 1;
65830 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65831 +#endif
65832 +#endif
65833 +
65834 + return;
65835 +}
65836 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65837 new file mode 100644
65838 index 0000000..5e05e20
65839 --- /dev/null
65840 +++ b/grsecurity/grsec_link.c
65841 @@ -0,0 +1,58 @@
65842 +#include <linux/kernel.h>
65843 +#include <linux/sched.h>
65844 +#include <linux/fs.h>
65845 +#include <linux/file.h>
65846 +#include <linux/grinternal.h>
65847 +
65848 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65849 +{
65850 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65851 + const struct inode *link_inode = link->dentry->d_inode;
65852 +
65853 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65854 + /* ignore root-owned links, e.g. /proc/self */
65855 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65856 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65857 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65858 + return 1;
65859 + }
65860 +#endif
65861 + return 0;
65862 +}
65863 +
65864 +int
65865 +gr_handle_follow_link(const struct inode *parent,
65866 + const struct inode *inode,
65867 + const struct dentry *dentry, const struct vfsmount *mnt)
65868 +{
65869 +#ifdef CONFIG_GRKERNSEC_LINK
65870 + const struct cred *cred = current_cred();
65871 +
65872 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65873 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65874 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65875 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65876 + return -EACCES;
65877 + }
65878 +#endif
65879 + return 0;
65880 +}
65881 +
65882 +int
65883 +gr_handle_hardlink(const struct dentry *dentry,
65884 + const struct vfsmount *mnt,
65885 + struct inode *inode, const int mode, const struct filename *to)
65886 +{
65887 +#ifdef CONFIG_GRKERNSEC_LINK
65888 + const struct cred *cred = current_cred();
65889 +
65890 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65891 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65892 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65893 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65894 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65895 + return -EPERM;
65896 + }
65897 +#endif
65898 + return 0;
65899 +}
65900 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65901 new file mode 100644
65902 index 0000000..7c06085
65903 --- /dev/null
65904 +++ b/grsecurity/grsec_log.c
65905 @@ -0,0 +1,326 @@
65906 +#include <linux/kernel.h>
65907 +#include <linux/sched.h>
65908 +#include <linux/file.h>
65909 +#include <linux/tty.h>
65910 +#include <linux/fs.h>
65911 +#include <linux/grinternal.h>
65912 +
65913 +#ifdef CONFIG_TREE_PREEMPT_RCU
65914 +#define DISABLE_PREEMPT() preempt_disable()
65915 +#define ENABLE_PREEMPT() preempt_enable()
65916 +#else
65917 +#define DISABLE_PREEMPT()
65918 +#define ENABLE_PREEMPT()
65919 +#endif
65920 +
65921 +#define BEGIN_LOCKS(x) \
65922 + DISABLE_PREEMPT(); \
65923 + rcu_read_lock(); \
65924 + read_lock(&tasklist_lock); \
65925 + read_lock(&grsec_exec_file_lock); \
65926 + if (x != GR_DO_AUDIT) \
65927 + spin_lock(&grsec_alert_lock); \
65928 + else \
65929 + spin_lock(&grsec_audit_lock)
65930 +
65931 +#define END_LOCKS(x) \
65932 + if (x != GR_DO_AUDIT) \
65933 + spin_unlock(&grsec_alert_lock); \
65934 + else \
65935 + spin_unlock(&grsec_audit_lock); \
65936 + read_unlock(&grsec_exec_file_lock); \
65937 + read_unlock(&tasklist_lock); \
65938 + rcu_read_unlock(); \
65939 + ENABLE_PREEMPT(); \
65940 + if (x == GR_DONT_AUDIT) \
65941 + gr_handle_alertkill(current)
65942 +
65943 +enum {
65944 + FLOODING,
65945 + NO_FLOODING
65946 +};
65947 +
65948 +extern char *gr_alert_log_fmt;
65949 +extern char *gr_audit_log_fmt;
65950 +extern char *gr_alert_log_buf;
65951 +extern char *gr_audit_log_buf;
65952 +
65953 +static int gr_log_start(int audit)
65954 +{
65955 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65956 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65957 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65958 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65959 + unsigned long curr_secs = get_seconds();
65960 +
65961 + if (audit == GR_DO_AUDIT)
65962 + goto set_fmt;
65963 +
65964 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65965 + grsec_alert_wtime = curr_secs;
65966 + grsec_alert_fyet = 0;
65967 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65968 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65969 + grsec_alert_fyet++;
65970 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65971 + grsec_alert_wtime = curr_secs;
65972 + grsec_alert_fyet++;
65973 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65974 + return FLOODING;
65975 + }
65976 + else return FLOODING;
65977 +
65978 +set_fmt:
65979 +#endif
65980 + memset(buf, 0, PAGE_SIZE);
65981 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65982 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65983 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65984 + } else if (current->signal->curr_ip) {
65985 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65986 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65987 + } else if (gr_acl_is_enabled()) {
65988 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65989 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65990 + } else {
65991 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65992 + strcpy(buf, fmt);
65993 + }
65994 +
65995 + return NO_FLOODING;
65996 +}
65997 +
65998 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65999 + __attribute__ ((format (printf, 2, 0)));
66000 +
66001 +static void gr_log_middle(int audit, const char *msg, va_list ap)
66002 +{
66003 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66004 + unsigned int len = strlen(buf);
66005 +
66006 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
66007 +
66008 + return;
66009 +}
66010 +
66011 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
66012 + __attribute__ ((format (printf, 2, 3)));
66013 +
66014 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
66015 +{
66016 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66017 + unsigned int len = strlen(buf);
66018 + va_list ap;
66019 +
66020 + va_start(ap, msg);
66021 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
66022 + va_end(ap);
66023 +
66024 + return;
66025 +}
66026 +
66027 +static void gr_log_end(int audit, int append_default)
66028 +{
66029 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
66030 + if (append_default) {
66031 + struct task_struct *task = current;
66032 + struct task_struct *parent = task->real_parent;
66033 + const struct cred *cred = __task_cred(task);
66034 + const struct cred *pcred = __task_cred(parent);
66035 + unsigned int len = strlen(buf);
66036 +
66037 + 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));
66038 + }
66039 +
66040 + printk("%s\n", buf);
66041 +
66042 + return;
66043 +}
66044 +
66045 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
66046 +{
66047 + int logtype;
66048 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
66049 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
66050 + void *voidptr = NULL;
66051 + int num1 = 0, num2 = 0;
66052 + unsigned long ulong1 = 0, ulong2 = 0;
66053 + struct dentry *dentry = NULL;
66054 + struct vfsmount *mnt = NULL;
66055 + struct file *file = NULL;
66056 + struct task_struct *task = NULL;
66057 + const struct cred *cred, *pcred;
66058 + va_list ap;
66059 +
66060 + BEGIN_LOCKS(audit);
66061 + logtype = gr_log_start(audit);
66062 + if (logtype == FLOODING) {
66063 + END_LOCKS(audit);
66064 + return;
66065 + }
66066 + va_start(ap, argtypes);
66067 + switch (argtypes) {
66068 + case GR_TTYSNIFF:
66069 + task = va_arg(ap, struct task_struct *);
66070 + 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));
66071 + break;
66072 + case GR_SYSCTL_HIDDEN:
66073 + str1 = va_arg(ap, char *);
66074 + gr_log_middle_varargs(audit, msg, result, str1);
66075 + break;
66076 + case GR_RBAC:
66077 + dentry = va_arg(ap, struct dentry *);
66078 + mnt = va_arg(ap, struct vfsmount *);
66079 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
66080 + break;
66081 + case GR_RBAC_STR:
66082 + dentry = va_arg(ap, struct dentry *);
66083 + mnt = va_arg(ap, struct vfsmount *);
66084 + str1 = va_arg(ap, char *);
66085 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
66086 + break;
66087 + case GR_STR_RBAC:
66088 + str1 = va_arg(ap, char *);
66089 + dentry = va_arg(ap, struct dentry *);
66090 + mnt = va_arg(ap, struct vfsmount *);
66091 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
66092 + break;
66093 + case GR_RBAC_MODE2:
66094 + dentry = va_arg(ap, struct dentry *);
66095 + mnt = va_arg(ap, struct vfsmount *);
66096 + str1 = va_arg(ap, char *);
66097 + str2 = va_arg(ap, char *);
66098 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
66099 + break;
66100 + case GR_RBAC_MODE3:
66101 + dentry = va_arg(ap, struct dentry *);
66102 + mnt = va_arg(ap, struct vfsmount *);
66103 + str1 = va_arg(ap, char *);
66104 + str2 = va_arg(ap, char *);
66105 + str3 = va_arg(ap, char *);
66106 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
66107 + break;
66108 + case GR_FILENAME:
66109 + dentry = va_arg(ap, struct dentry *);
66110 + mnt = va_arg(ap, struct vfsmount *);
66111 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
66112 + break;
66113 + case GR_STR_FILENAME:
66114 + str1 = va_arg(ap, char *);
66115 + dentry = va_arg(ap, struct dentry *);
66116 + mnt = va_arg(ap, struct vfsmount *);
66117 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
66118 + break;
66119 + case GR_FILENAME_STR:
66120 + dentry = va_arg(ap, struct dentry *);
66121 + mnt = va_arg(ap, struct vfsmount *);
66122 + str1 = va_arg(ap, char *);
66123 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
66124 + break;
66125 + case GR_FILENAME_TWO_INT:
66126 + dentry = va_arg(ap, struct dentry *);
66127 + mnt = va_arg(ap, struct vfsmount *);
66128 + num1 = va_arg(ap, int);
66129 + num2 = va_arg(ap, int);
66130 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
66131 + break;
66132 + case GR_FILENAME_TWO_INT_STR:
66133 + dentry = va_arg(ap, struct dentry *);
66134 + mnt = va_arg(ap, struct vfsmount *);
66135 + num1 = va_arg(ap, int);
66136 + num2 = va_arg(ap, int);
66137 + str1 = va_arg(ap, char *);
66138 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
66139 + break;
66140 + case GR_TEXTREL:
66141 + file = va_arg(ap, struct file *);
66142 + ulong1 = va_arg(ap, unsigned long);
66143 + ulong2 = va_arg(ap, unsigned long);
66144 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
66145 + break;
66146 + case GR_PTRACE:
66147 + task = va_arg(ap, struct task_struct *);
66148 + 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));
66149 + break;
66150 + case GR_RESOURCE:
66151 + task = va_arg(ap, struct task_struct *);
66152 + cred = __task_cred(task);
66153 + pcred = __task_cred(task->real_parent);
66154 + ulong1 = va_arg(ap, unsigned long);
66155 + str1 = va_arg(ap, char *);
66156 + ulong2 = va_arg(ap, unsigned long);
66157 + 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));
66158 + break;
66159 + case GR_CAP:
66160 + task = va_arg(ap, struct task_struct *);
66161 + cred = __task_cred(task);
66162 + pcred = __task_cred(task->real_parent);
66163 + str1 = va_arg(ap, char *);
66164 + 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));
66165 + break;
66166 + case GR_SIG:
66167 + str1 = va_arg(ap, char *);
66168 + voidptr = va_arg(ap, void *);
66169 + gr_log_middle_varargs(audit, msg, str1, voidptr);
66170 + break;
66171 + case GR_SIG2:
66172 + task = va_arg(ap, struct task_struct *);
66173 + cred = __task_cred(task);
66174 + pcred = __task_cred(task->real_parent);
66175 + num1 = va_arg(ap, int);
66176 + 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));
66177 + break;
66178 + case GR_CRASH1:
66179 + task = va_arg(ap, struct task_struct *);
66180 + cred = __task_cred(task);
66181 + pcred = __task_cred(task->real_parent);
66182 + ulong1 = va_arg(ap, unsigned long);
66183 + 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);
66184 + break;
66185 + case GR_CRASH2:
66186 + task = va_arg(ap, struct task_struct *);
66187 + cred = __task_cred(task);
66188 + pcred = __task_cred(task->real_parent);
66189 + ulong1 = va_arg(ap, unsigned long);
66190 + 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);
66191 + break;
66192 + case GR_RWXMAP:
66193 + file = va_arg(ap, struct file *);
66194 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
66195 + break;
66196 + case GR_PSACCT:
66197 + {
66198 + unsigned int wday, cday;
66199 + __u8 whr, chr;
66200 + __u8 wmin, cmin;
66201 + __u8 wsec, csec;
66202 + char cur_tty[64] = { 0 };
66203 + char parent_tty[64] = { 0 };
66204 +
66205 + task = va_arg(ap, struct task_struct *);
66206 + wday = va_arg(ap, unsigned int);
66207 + cday = va_arg(ap, unsigned int);
66208 + whr = va_arg(ap, int);
66209 + chr = va_arg(ap, int);
66210 + wmin = va_arg(ap, int);
66211 + cmin = va_arg(ap, int);
66212 + wsec = va_arg(ap, int);
66213 + csec = va_arg(ap, int);
66214 + ulong1 = va_arg(ap, unsigned long);
66215 + cred = __task_cred(task);
66216 + pcred = __task_cred(task->real_parent);
66217 +
66218 + 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));
66219 + }
66220 + break;
66221 + default:
66222 + gr_log_middle(audit, msg, ap);
66223 + }
66224 + va_end(ap);
66225 + // these don't need DEFAULTSECARGS printed on the end
66226 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
66227 + gr_log_end(audit, 0);
66228 + else
66229 + gr_log_end(audit, 1);
66230 + END_LOCKS(audit);
66231 +}
66232 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
66233 new file mode 100644
66234 index 0000000..f536303
66235 --- /dev/null
66236 +++ b/grsecurity/grsec_mem.c
66237 @@ -0,0 +1,40 @@
66238 +#include <linux/kernel.h>
66239 +#include <linux/sched.h>
66240 +#include <linux/mm.h>
66241 +#include <linux/mman.h>
66242 +#include <linux/grinternal.h>
66243 +
66244 +void
66245 +gr_handle_ioperm(void)
66246 +{
66247 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
66248 + return;
66249 +}
66250 +
66251 +void
66252 +gr_handle_iopl(void)
66253 +{
66254 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
66255 + return;
66256 +}
66257 +
66258 +void
66259 +gr_handle_mem_readwrite(u64 from, u64 to)
66260 +{
66261 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
66262 + return;
66263 +}
66264 +
66265 +void
66266 +gr_handle_vm86(void)
66267 +{
66268 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
66269 + return;
66270 +}
66271 +
66272 +void
66273 +gr_log_badprocpid(const char *entry)
66274 +{
66275 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
66276 + return;
66277 +}
66278 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
66279 new file mode 100644
66280 index 0000000..2131422
66281 --- /dev/null
66282 +++ b/grsecurity/grsec_mount.c
66283 @@ -0,0 +1,62 @@
66284 +#include <linux/kernel.h>
66285 +#include <linux/sched.h>
66286 +#include <linux/mount.h>
66287 +#include <linux/grsecurity.h>
66288 +#include <linux/grinternal.h>
66289 +
66290 +void
66291 +gr_log_remount(const char *devname, const int retval)
66292 +{
66293 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66294 + if (grsec_enable_mount && (retval >= 0))
66295 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
66296 +#endif
66297 + return;
66298 +}
66299 +
66300 +void
66301 +gr_log_unmount(const char *devname, const int retval)
66302 +{
66303 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66304 + if (grsec_enable_mount && (retval >= 0))
66305 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
66306 +#endif
66307 + return;
66308 +}
66309 +
66310 +void
66311 +gr_log_mount(const char *from, const char *to, const int retval)
66312 +{
66313 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66314 + if (grsec_enable_mount && (retval >= 0))
66315 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
66316 +#endif
66317 + return;
66318 +}
66319 +
66320 +int
66321 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
66322 +{
66323 +#ifdef CONFIG_GRKERNSEC_ROFS
66324 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
66325 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
66326 + return -EPERM;
66327 + } else
66328 + return 0;
66329 +#endif
66330 + return 0;
66331 +}
66332 +
66333 +int
66334 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
66335 +{
66336 +#ifdef CONFIG_GRKERNSEC_ROFS
66337 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
66338 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
66339 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
66340 + return -EPERM;
66341 + } else
66342 + return 0;
66343 +#endif
66344 + return 0;
66345 +}
66346 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
66347 new file mode 100644
66348 index 0000000..a3b12a0
66349 --- /dev/null
66350 +++ b/grsecurity/grsec_pax.c
66351 @@ -0,0 +1,36 @@
66352 +#include <linux/kernel.h>
66353 +#include <linux/sched.h>
66354 +#include <linux/mm.h>
66355 +#include <linux/file.h>
66356 +#include <linux/grinternal.h>
66357 +#include <linux/grsecurity.h>
66358 +
66359 +void
66360 +gr_log_textrel(struct vm_area_struct * vma)
66361 +{
66362 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66363 + if (grsec_enable_audit_textrel)
66364 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
66365 +#endif
66366 + return;
66367 +}
66368 +
66369 +void
66370 +gr_log_rwxmmap(struct file *file)
66371 +{
66372 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66373 + if (grsec_enable_log_rwxmaps)
66374 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
66375 +#endif
66376 + return;
66377 +}
66378 +
66379 +void
66380 +gr_log_rwxmprotect(struct file *file)
66381 +{
66382 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66383 + if (grsec_enable_log_rwxmaps)
66384 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
66385 +#endif
66386 + return;
66387 +}
66388 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
66389 new file mode 100644
66390 index 0000000..f7f29aa
66391 --- /dev/null
66392 +++ b/grsecurity/grsec_ptrace.c
66393 @@ -0,0 +1,30 @@
66394 +#include <linux/kernel.h>
66395 +#include <linux/sched.h>
66396 +#include <linux/grinternal.h>
66397 +#include <linux/security.h>
66398 +
66399 +void
66400 +gr_audit_ptrace(struct task_struct *task)
66401 +{
66402 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66403 + if (grsec_enable_audit_ptrace)
66404 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
66405 +#endif
66406 + return;
66407 +}
66408 +
66409 +int
66410 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
66411 +{
66412 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66413 + const struct dentry *dentry = file->f_path.dentry;
66414 + const struct vfsmount *mnt = file->f_path.mnt;
66415 +
66416 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
66417 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
66418 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
66419 + return -EACCES;
66420 + }
66421 +#endif
66422 + return 0;
66423 +}
66424 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
66425 new file mode 100644
66426 index 0000000..e09715a
66427 --- /dev/null
66428 +++ b/grsecurity/grsec_sig.c
66429 @@ -0,0 +1,222 @@
66430 +#include <linux/kernel.h>
66431 +#include <linux/sched.h>
66432 +#include <linux/delay.h>
66433 +#include <linux/grsecurity.h>
66434 +#include <linux/grinternal.h>
66435 +#include <linux/hardirq.h>
66436 +
66437 +char *signames[] = {
66438 + [SIGSEGV] = "Segmentation fault",
66439 + [SIGILL] = "Illegal instruction",
66440 + [SIGABRT] = "Abort",
66441 + [SIGBUS] = "Invalid alignment/Bus error"
66442 +};
66443 +
66444 +void
66445 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
66446 +{
66447 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66448 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
66449 + (sig == SIGABRT) || (sig == SIGBUS))) {
66450 + if (task_pid_nr(t) == task_pid_nr(current)) {
66451 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
66452 + } else {
66453 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
66454 + }
66455 + }
66456 +#endif
66457 + return;
66458 +}
66459 +
66460 +int
66461 +gr_handle_signal(const struct task_struct *p, const int sig)
66462 +{
66463 +#ifdef CONFIG_GRKERNSEC
66464 + /* ignore the 0 signal for protected task checks */
66465 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
66466 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
66467 + return -EPERM;
66468 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
66469 + return -EPERM;
66470 + }
66471 +#endif
66472 + return 0;
66473 +}
66474 +
66475 +#ifdef CONFIG_GRKERNSEC
66476 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
66477 +
66478 +int gr_fake_force_sig(int sig, struct task_struct *t)
66479 +{
66480 + unsigned long int flags;
66481 + int ret, blocked, ignored;
66482 + struct k_sigaction *action;
66483 +
66484 + spin_lock_irqsave(&t->sighand->siglock, flags);
66485 + action = &t->sighand->action[sig-1];
66486 + ignored = action->sa.sa_handler == SIG_IGN;
66487 + blocked = sigismember(&t->blocked, sig);
66488 + if (blocked || ignored) {
66489 + action->sa.sa_handler = SIG_DFL;
66490 + if (blocked) {
66491 + sigdelset(&t->blocked, sig);
66492 + recalc_sigpending_and_wake(t);
66493 + }
66494 + }
66495 + if (action->sa.sa_handler == SIG_DFL)
66496 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
66497 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
66498 +
66499 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
66500 +
66501 + return ret;
66502 +}
66503 +#endif
66504 +
66505 +#ifdef CONFIG_GRKERNSEC_BRUTE
66506 +#define GR_USER_BAN_TIME (15 * 60)
66507 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
66508 +
66509 +static int __get_dumpable(unsigned long mm_flags)
66510 +{
66511 + int ret;
66512 +
66513 + ret = mm_flags & MMF_DUMPABLE_MASK;
66514 + return (ret >= 2) ? 2 : ret;
66515 +}
66516 +#endif
66517 +
66518 +void gr_handle_brute_attach(unsigned long mm_flags)
66519 +{
66520 +#ifdef CONFIG_GRKERNSEC_BRUTE
66521 + struct task_struct *p = current;
66522 + kuid_t uid = GLOBAL_ROOT_UID;
66523 + int daemon = 0;
66524 +
66525 + if (!grsec_enable_brute)
66526 + return;
66527 +
66528 + rcu_read_lock();
66529 + read_lock(&tasklist_lock);
66530 + read_lock(&grsec_exec_file_lock);
66531 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
66532 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
66533 + p->real_parent->brute = 1;
66534 + daemon = 1;
66535 + } else {
66536 + const struct cred *cred = __task_cred(p), *cred2;
66537 + struct task_struct *tsk, *tsk2;
66538 +
66539 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
66540 + struct user_struct *user;
66541 +
66542 + uid = cred->uid;
66543 +
66544 + /* this is put upon execution past expiration */
66545 + user = find_user(uid);
66546 + if (user == NULL)
66547 + goto unlock;
66548 + user->banned = 1;
66549 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
66550 + if (user->ban_expires == ~0UL)
66551 + user->ban_expires--;
66552 +
66553 + do_each_thread(tsk2, tsk) {
66554 + cred2 = __task_cred(tsk);
66555 + if (tsk != p && uid_eq(cred2->uid, uid))
66556 + gr_fake_force_sig(SIGKILL, tsk);
66557 + } while_each_thread(tsk2, tsk);
66558 + }
66559 + }
66560 +unlock:
66561 + read_unlock(&grsec_exec_file_lock);
66562 + read_unlock(&tasklist_lock);
66563 + rcu_read_unlock();
66564 +
66565 + if (gr_is_global_nonroot(uid))
66566 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
66567 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
66568 + else if (daemon)
66569 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66570 +
66571 +#endif
66572 + return;
66573 +}
66574 +
66575 +void gr_handle_brute_check(void)
66576 +{
66577 +#ifdef CONFIG_GRKERNSEC_BRUTE
66578 + struct task_struct *p = current;
66579 +
66580 + if (unlikely(p->brute)) {
66581 + if (!grsec_enable_brute)
66582 + p->brute = 0;
66583 + else if (time_before(get_seconds(), p->brute_expires))
66584 + msleep(30 * 1000);
66585 + }
66586 +#endif
66587 + return;
66588 +}
66589 +
66590 +void gr_handle_kernel_exploit(void)
66591 +{
66592 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66593 + const struct cred *cred;
66594 + struct task_struct *tsk, *tsk2;
66595 + struct user_struct *user;
66596 + kuid_t uid;
66597 +
66598 + if (in_irq() || in_serving_softirq() || in_nmi())
66599 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66600 +
66601 + uid = current_uid();
66602 +
66603 + if (gr_is_global_root(uid))
66604 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66605 + else {
66606 + /* kill all the processes of this user, hold a reference
66607 + to their creds struct, and prevent them from creating
66608 + another process until system reset
66609 + */
66610 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66611 + GR_GLOBAL_UID(uid));
66612 + /* we intentionally leak this ref */
66613 + user = get_uid(current->cred->user);
66614 + if (user) {
66615 + user->banned = 1;
66616 + user->ban_expires = ~0UL;
66617 + }
66618 +
66619 + read_lock(&tasklist_lock);
66620 + do_each_thread(tsk2, tsk) {
66621 + cred = __task_cred(tsk);
66622 + if (uid_eq(cred->uid, uid))
66623 + gr_fake_force_sig(SIGKILL, tsk);
66624 + } while_each_thread(tsk2, tsk);
66625 + read_unlock(&tasklist_lock);
66626 + }
66627 +#endif
66628 +}
66629 +
66630 +int __gr_process_user_ban(struct user_struct *user)
66631 +{
66632 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66633 + if (unlikely(user->banned)) {
66634 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
66635 + user->banned = 0;
66636 + user->ban_expires = 0;
66637 + free_uid(user);
66638 + } else
66639 + return -EPERM;
66640 + }
66641 +#endif
66642 + return 0;
66643 +}
66644 +
66645 +int gr_process_user_ban(void)
66646 +{
66647 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66648 + return __gr_process_user_ban(current->cred->user);
66649 +#endif
66650 + return 0;
66651 +}
66652 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66653 new file mode 100644
66654 index 0000000..4030d57
66655 --- /dev/null
66656 +++ b/grsecurity/grsec_sock.c
66657 @@ -0,0 +1,244 @@
66658 +#include <linux/kernel.h>
66659 +#include <linux/module.h>
66660 +#include <linux/sched.h>
66661 +#include <linux/file.h>
66662 +#include <linux/net.h>
66663 +#include <linux/in.h>
66664 +#include <linux/ip.h>
66665 +#include <net/sock.h>
66666 +#include <net/inet_sock.h>
66667 +#include <linux/grsecurity.h>
66668 +#include <linux/grinternal.h>
66669 +#include <linux/gracl.h>
66670 +
66671 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66672 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66673 +
66674 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66675 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66676 +
66677 +#ifdef CONFIG_UNIX_MODULE
66678 +EXPORT_SYMBOL(gr_acl_handle_unix);
66679 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66680 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66681 +EXPORT_SYMBOL(gr_handle_create);
66682 +#endif
66683 +
66684 +#ifdef CONFIG_GRKERNSEC
66685 +#define gr_conn_table_size 32749
66686 +struct conn_table_entry {
66687 + struct conn_table_entry *next;
66688 + struct signal_struct *sig;
66689 +};
66690 +
66691 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66692 +DEFINE_SPINLOCK(gr_conn_table_lock);
66693 +
66694 +extern const char * gr_socktype_to_name(unsigned char type);
66695 +extern const char * gr_proto_to_name(unsigned char proto);
66696 +extern const char * gr_sockfamily_to_name(unsigned char family);
66697 +
66698 +static __inline__ int
66699 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66700 +{
66701 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66702 +}
66703 +
66704 +static __inline__ int
66705 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66706 + __u16 sport, __u16 dport)
66707 +{
66708 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66709 + sig->gr_sport == sport && sig->gr_dport == dport))
66710 + return 1;
66711 + else
66712 + return 0;
66713 +}
66714 +
66715 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66716 +{
66717 + struct conn_table_entry **match;
66718 + unsigned int index;
66719 +
66720 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66721 + sig->gr_sport, sig->gr_dport,
66722 + gr_conn_table_size);
66723 +
66724 + newent->sig = sig;
66725 +
66726 + match = &gr_conn_table[index];
66727 + newent->next = *match;
66728 + *match = newent;
66729 +
66730 + return;
66731 +}
66732 +
66733 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66734 +{
66735 + struct conn_table_entry *match, *last = NULL;
66736 + unsigned int index;
66737 +
66738 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66739 + sig->gr_sport, sig->gr_dport,
66740 + gr_conn_table_size);
66741 +
66742 + match = gr_conn_table[index];
66743 + while (match && !conn_match(match->sig,
66744 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66745 + sig->gr_dport)) {
66746 + last = match;
66747 + match = match->next;
66748 + }
66749 +
66750 + if (match) {
66751 + if (last)
66752 + last->next = match->next;
66753 + else
66754 + gr_conn_table[index] = NULL;
66755 + kfree(match);
66756 + }
66757 +
66758 + return;
66759 +}
66760 +
66761 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66762 + __u16 sport, __u16 dport)
66763 +{
66764 + struct conn_table_entry *match;
66765 + unsigned int index;
66766 +
66767 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66768 +
66769 + match = gr_conn_table[index];
66770 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66771 + match = match->next;
66772 +
66773 + if (match)
66774 + return match->sig;
66775 + else
66776 + return NULL;
66777 +}
66778 +
66779 +#endif
66780 +
66781 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66782 +{
66783 +#ifdef CONFIG_GRKERNSEC
66784 + struct signal_struct *sig = task->signal;
66785 + struct conn_table_entry *newent;
66786 +
66787 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66788 + if (newent == NULL)
66789 + return;
66790 + /* no bh lock needed since we are called with bh disabled */
66791 + spin_lock(&gr_conn_table_lock);
66792 + gr_del_task_from_ip_table_nolock(sig);
66793 + sig->gr_saddr = inet->inet_rcv_saddr;
66794 + sig->gr_daddr = inet->inet_daddr;
66795 + sig->gr_sport = inet->inet_sport;
66796 + sig->gr_dport = inet->inet_dport;
66797 + gr_add_to_task_ip_table_nolock(sig, newent);
66798 + spin_unlock(&gr_conn_table_lock);
66799 +#endif
66800 + return;
66801 +}
66802 +
66803 +void gr_del_task_from_ip_table(struct task_struct *task)
66804 +{
66805 +#ifdef CONFIG_GRKERNSEC
66806 + spin_lock_bh(&gr_conn_table_lock);
66807 + gr_del_task_from_ip_table_nolock(task->signal);
66808 + spin_unlock_bh(&gr_conn_table_lock);
66809 +#endif
66810 + return;
66811 +}
66812 +
66813 +void
66814 +gr_attach_curr_ip(const struct sock *sk)
66815 +{
66816 +#ifdef CONFIG_GRKERNSEC
66817 + struct signal_struct *p, *set;
66818 + const struct inet_sock *inet = inet_sk(sk);
66819 +
66820 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66821 + return;
66822 +
66823 + set = current->signal;
66824 +
66825 + spin_lock_bh(&gr_conn_table_lock);
66826 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66827 + inet->inet_dport, inet->inet_sport);
66828 + if (unlikely(p != NULL)) {
66829 + set->curr_ip = p->curr_ip;
66830 + set->used_accept = 1;
66831 + gr_del_task_from_ip_table_nolock(p);
66832 + spin_unlock_bh(&gr_conn_table_lock);
66833 + return;
66834 + }
66835 + spin_unlock_bh(&gr_conn_table_lock);
66836 +
66837 + set->curr_ip = inet->inet_daddr;
66838 + set->used_accept = 1;
66839 +#endif
66840 + return;
66841 +}
66842 +
66843 +int
66844 +gr_handle_sock_all(const int family, const int type, const int protocol)
66845 +{
66846 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66847 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66848 + (family != AF_UNIX)) {
66849 + if (family == AF_INET)
66850 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66851 + else
66852 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66853 + return -EACCES;
66854 + }
66855 +#endif
66856 + return 0;
66857 +}
66858 +
66859 +int
66860 +gr_handle_sock_server(const struct sockaddr *sck)
66861 +{
66862 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66863 + if (grsec_enable_socket_server &&
66864 + in_group_p(grsec_socket_server_gid) &&
66865 + sck && (sck->sa_family != AF_UNIX) &&
66866 + (sck->sa_family != AF_LOCAL)) {
66867 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66868 + return -EACCES;
66869 + }
66870 +#endif
66871 + return 0;
66872 +}
66873 +
66874 +int
66875 +gr_handle_sock_server_other(const struct sock *sck)
66876 +{
66877 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66878 + if (grsec_enable_socket_server &&
66879 + in_group_p(grsec_socket_server_gid) &&
66880 + sck && (sck->sk_family != AF_UNIX) &&
66881 + (sck->sk_family != AF_LOCAL)) {
66882 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66883 + return -EACCES;
66884 + }
66885 +#endif
66886 + return 0;
66887 +}
66888 +
66889 +int
66890 +gr_handle_sock_client(const struct sockaddr *sck)
66891 +{
66892 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66893 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66894 + sck && (sck->sa_family != AF_UNIX) &&
66895 + (sck->sa_family != AF_LOCAL)) {
66896 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66897 + return -EACCES;
66898 + }
66899 +#endif
66900 + return 0;
66901 +}
66902 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66903 new file mode 100644
66904 index 0000000..f55ef0f
66905 --- /dev/null
66906 +++ b/grsecurity/grsec_sysctl.c
66907 @@ -0,0 +1,469 @@
66908 +#include <linux/kernel.h>
66909 +#include <linux/sched.h>
66910 +#include <linux/sysctl.h>
66911 +#include <linux/grsecurity.h>
66912 +#include <linux/grinternal.h>
66913 +
66914 +int
66915 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66916 +{
66917 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66918 + if (dirname == NULL || name == NULL)
66919 + return 0;
66920 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66921 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66922 + return -EACCES;
66923 + }
66924 +#endif
66925 + return 0;
66926 +}
66927 +
66928 +#ifdef CONFIG_GRKERNSEC_ROFS
66929 +static int __maybe_unused one = 1;
66930 +#endif
66931 +
66932 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66933 +struct ctl_table grsecurity_table[] = {
66934 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66935 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66936 +#ifdef CONFIG_GRKERNSEC_IO
66937 + {
66938 + .procname = "disable_priv_io",
66939 + .data = &grsec_disable_privio,
66940 + .maxlen = sizeof(int),
66941 + .mode = 0600,
66942 + .proc_handler = &proc_dointvec,
66943 + },
66944 +#endif
66945 +#endif
66946 +#ifdef CONFIG_GRKERNSEC_LINK
66947 + {
66948 + .procname = "linking_restrictions",
66949 + .data = &grsec_enable_link,
66950 + .maxlen = sizeof(int),
66951 + .mode = 0600,
66952 + .proc_handler = &proc_dointvec,
66953 + },
66954 +#endif
66955 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66956 + {
66957 + .procname = "enforce_symlinksifowner",
66958 + .data = &grsec_enable_symlinkown,
66959 + .maxlen = sizeof(int),
66960 + .mode = 0600,
66961 + .proc_handler = &proc_dointvec,
66962 + },
66963 + {
66964 + .procname = "symlinkown_gid",
66965 + .data = &grsec_symlinkown_gid,
66966 + .maxlen = sizeof(int),
66967 + .mode = 0600,
66968 + .proc_handler = &proc_dointvec,
66969 + },
66970 +#endif
66971 +#ifdef CONFIG_GRKERNSEC_BRUTE
66972 + {
66973 + .procname = "deter_bruteforce",
66974 + .data = &grsec_enable_brute,
66975 + .maxlen = sizeof(int),
66976 + .mode = 0600,
66977 + .proc_handler = &proc_dointvec,
66978 + },
66979 +#endif
66980 +#ifdef CONFIG_GRKERNSEC_FIFO
66981 + {
66982 + .procname = "fifo_restrictions",
66983 + .data = &grsec_enable_fifo,
66984 + .maxlen = sizeof(int),
66985 + .mode = 0600,
66986 + .proc_handler = &proc_dointvec,
66987 + },
66988 +#endif
66989 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66990 + {
66991 + .procname = "ptrace_readexec",
66992 + .data = &grsec_enable_ptrace_readexec,
66993 + .maxlen = sizeof(int),
66994 + .mode = 0600,
66995 + .proc_handler = &proc_dointvec,
66996 + },
66997 +#endif
66998 +#ifdef CONFIG_GRKERNSEC_SETXID
66999 + {
67000 + .procname = "consistent_setxid",
67001 + .data = &grsec_enable_setxid,
67002 + .maxlen = sizeof(int),
67003 + .mode = 0600,
67004 + .proc_handler = &proc_dointvec,
67005 + },
67006 +#endif
67007 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
67008 + {
67009 + .procname = "ip_blackhole",
67010 + .data = &grsec_enable_blackhole,
67011 + .maxlen = sizeof(int),
67012 + .mode = 0600,
67013 + .proc_handler = &proc_dointvec,
67014 + },
67015 + {
67016 + .procname = "lastack_retries",
67017 + .data = &grsec_lastack_retries,
67018 + .maxlen = sizeof(int),
67019 + .mode = 0600,
67020 + .proc_handler = &proc_dointvec,
67021 + },
67022 +#endif
67023 +#ifdef CONFIG_GRKERNSEC_EXECLOG
67024 + {
67025 + .procname = "exec_logging",
67026 + .data = &grsec_enable_execlog,
67027 + .maxlen = sizeof(int),
67028 + .mode = 0600,
67029 + .proc_handler = &proc_dointvec,
67030 + },
67031 +#endif
67032 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
67033 + {
67034 + .procname = "rwxmap_logging",
67035 + .data = &grsec_enable_log_rwxmaps,
67036 + .maxlen = sizeof(int),
67037 + .mode = 0600,
67038 + .proc_handler = &proc_dointvec,
67039 + },
67040 +#endif
67041 +#ifdef CONFIG_GRKERNSEC_SIGNAL
67042 + {
67043 + .procname = "signal_logging",
67044 + .data = &grsec_enable_signal,
67045 + .maxlen = sizeof(int),
67046 + .mode = 0600,
67047 + .proc_handler = &proc_dointvec,
67048 + },
67049 +#endif
67050 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
67051 + {
67052 + .procname = "forkfail_logging",
67053 + .data = &grsec_enable_forkfail,
67054 + .maxlen = sizeof(int),
67055 + .mode = 0600,
67056 + .proc_handler = &proc_dointvec,
67057 + },
67058 +#endif
67059 +#ifdef CONFIG_GRKERNSEC_TIME
67060 + {
67061 + .procname = "timechange_logging",
67062 + .data = &grsec_enable_time,
67063 + .maxlen = sizeof(int),
67064 + .mode = 0600,
67065 + .proc_handler = &proc_dointvec,
67066 + },
67067 +#endif
67068 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
67069 + {
67070 + .procname = "chroot_deny_shmat",
67071 + .data = &grsec_enable_chroot_shmat,
67072 + .maxlen = sizeof(int),
67073 + .mode = 0600,
67074 + .proc_handler = &proc_dointvec,
67075 + },
67076 +#endif
67077 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
67078 + {
67079 + .procname = "chroot_deny_unix",
67080 + .data = &grsec_enable_chroot_unix,
67081 + .maxlen = sizeof(int),
67082 + .mode = 0600,
67083 + .proc_handler = &proc_dointvec,
67084 + },
67085 +#endif
67086 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
67087 + {
67088 + .procname = "chroot_deny_mount",
67089 + .data = &grsec_enable_chroot_mount,
67090 + .maxlen = sizeof(int),
67091 + .mode = 0600,
67092 + .proc_handler = &proc_dointvec,
67093 + },
67094 +#endif
67095 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
67096 + {
67097 + .procname = "chroot_deny_fchdir",
67098 + .data = &grsec_enable_chroot_fchdir,
67099 + .maxlen = sizeof(int),
67100 + .mode = 0600,
67101 + .proc_handler = &proc_dointvec,
67102 + },
67103 +#endif
67104 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
67105 + {
67106 + .procname = "chroot_deny_chroot",
67107 + .data = &grsec_enable_chroot_double,
67108 + .maxlen = sizeof(int),
67109 + .mode = 0600,
67110 + .proc_handler = &proc_dointvec,
67111 + },
67112 +#endif
67113 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
67114 + {
67115 + .procname = "chroot_deny_pivot",
67116 + .data = &grsec_enable_chroot_pivot,
67117 + .maxlen = sizeof(int),
67118 + .mode = 0600,
67119 + .proc_handler = &proc_dointvec,
67120 + },
67121 +#endif
67122 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
67123 + {
67124 + .procname = "chroot_enforce_chdir",
67125 + .data = &grsec_enable_chroot_chdir,
67126 + .maxlen = sizeof(int),
67127 + .mode = 0600,
67128 + .proc_handler = &proc_dointvec,
67129 + },
67130 +#endif
67131 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
67132 + {
67133 + .procname = "chroot_deny_chmod",
67134 + .data = &grsec_enable_chroot_chmod,
67135 + .maxlen = sizeof(int),
67136 + .mode = 0600,
67137 + .proc_handler = &proc_dointvec,
67138 + },
67139 +#endif
67140 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
67141 + {
67142 + .procname = "chroot_deny_mknod",
67143 + .data = &grsec_enable_chroot_mknod,
67144 + .maxlen = sizeof(int),
67145 + .mode = 0600,
67146 + .proc_handler = &proc_dointvec,
67147 + },
67148 +#endif
67149 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
67150 + {
67151 + .procname = "chroot_restrict_nice",
67152 + .data = &grsec_enable_chroot_nice,
67153 + .maxlen = sizeof(int),
67154 + .mode = 0600,
67155 + .proc_handler = &proc_dointvec,
67156 + },
67157 +#endif
67158 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
67159 + {
67160 + .procname = "chroot_execlog",
67161 + .data = &grsec_enable_chroot_execlog,
67162 + .maxlen = sizeof(int),
67163 + .mode = 0600,
67164 + .proc_handler = &proc_dointvec,
67165 + },
67166 +#endif
67167 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67168 + {
67169 + .procname = "chroot_caps",
67170 + .data = &grsec_enable_chroot_caps,
67171 + .maxlen = sizeof(int),
67172 + .mode = 0600,
67173 + .proc_handler = &proc_dointvec,
67174 + },
67175 +#endif
67176 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
67177 + {
67178 + .procname = "chroot_deny_sysctl",
67179 + .data = &grsec_enable_chroot_sysctl,
67180 + .maxlen = sizeof(int),
67181 + .mode = 0600,
67182 + .proc_handler = &proc_dointvec,
67183 + },
67184 +#endif
67185 +#ifdef CONFIG_GRKERNSEC_TPE
67186 + {
67187 + .procname = "tpe",
67188 + .data = &grsec_enable_tpe,
67189 + .maxlen = sizeof(int),
67190 + .mode = 0600,
67191 + .proc_handler = &proc_dointvec,
67192 + },
67193 + {
67194 + .procname = "tpe_gid",
67195 + .data = &grsec_tpe_gid,
67196 + .maxlen = sizeof(int),
67197 + .mode = 0600,
67198 + .proc_handler = &proc_dointvec,
67199 + },
67200 +#endif
67201 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
67202 + {
67203 + .procname = "tpe_invert",
67204 + .data = &grsec_enable_tpe_invert,
67205 + .maxlen = sizeof(int),
67206 + .mode = 0600,
67207 + .proc_handler = &proc_dointvec,
67208 + },
67209 +#endif
67210 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
67211 + {
67212 + .procname = "tpe_restrict_all",
67213 + .data = &grsec_enable_tpe_all,
67214 + .maxlen = sizeof(int),
67215 + .mode = 0600,
67216 + .proc_handler = &proc_dointvec,
67217 + },
67218 +#endif
67219 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
67220 + {
67221 + .procname = "socket_all",
67222 + .data = &grsec_enable_socket_all,
67223 + .maxlen = sizeof(int),
67224 + .mode = 0600,
67225 + .proc_handler = &proc_dointvec,
67226 + },
67227 + {
67228 + .procname = "socket_all_gid",
67229 + .data = &grsec_socket_all_gid,
67230 + .maxlen = sizeof(int),
67231 + .mode = 0600,
67232 + .proc_handler = &proc_dointvec,
67233 + },
67234 +#endif
67235 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
67236 + {
67237 + .procname = "socket_client",
67238 + .data = &grsec_enable_socket_client,
67239 + .maxlen = sizeof(int),
67240 + .mode = 0600,
67241 + .proc_handler = &proc_dointvec,
67242 + },
67243 + {
67244 + .procname = "socket_client_gid",
67245 + .data = &grsec_socket_client_gid,
67246 + .maxlen = sizeof(int),
67247 + .mode = 0600,
67248 + .proc_handler = &proc_dointvec,
67249 + },
67250 +#endif
67251 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
67252 + {
67253 + .procname = "socket_server",
67254 + .data = &grsec_enable_socket_server,
67255 + .maxlen = sizeof(int),
67256 + .mode = 0600,
67257 + .proc_handler = &proc_dointvec,
67258 + },
67259 + {
67260 + .procname = "socket_server_gid",
67261 + .data = &grsec_socket_server_gid,
67262 + .maxlen = sizeof(int),
67263 + .mode = 0600,
67264 + .proc_handler = &proc_dointvec,
67265 + },
67266 +#endif
67267 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
67268 + {
67269 + .procname = "audit_group",
67270 + .data = &grsec_enable_group,
67271 + .maxlen = sizeof(int),
67272 + .mode = 0600,
67273 + .proc_handler = &proc_dointvec,
67274 + },
67275 + {
67276 + .procname = "audit_gid",
67277 + .data = &grsec_audit_gid,
67278 + .maxlen = sizeof(int),
67279 + .mode = 0600,
67280 + .proc_handler = &proc_dointvec,
67281 + },
67282 +#endif
67283 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
67284 + {
67285 + .procname = "audit_chdir",
67286 + .data = &grsec_enable_chdir,
67287 + .maxlen = sizeof(int),
67288 + .mode = 0600,
67289 + .proc_handler = &proc_dointvec,
67290 + },
67291 +#endif
67292 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
67293 + {
67294 + .procname = "audit_mount",
67295 + .data = &grsec_enable_mount,
67296 + .maxlen = sizeof(int),
67297 + .mode = 0600,
67298 + .proc_handler = &proc_dointvec,
67299 + },
67300 +#endif
67301 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
67302 + {
67303 + .procname = "audit_textrel",
67304 + .data = &grsec_enable_audit_textrel,
67305 + .maxlen = sizeof(int),
67306 + .mode = 0600,
67307 + .proc_handler = &proc_dointvec,
67308 + },
67309 +#endif
67310 +#ifdef CONFIG_GRKERNSEC_DMESG
67311 + {
67312 + .procname = "dmesg",
67313 + .data = &grsec_enable_dmesg,
67314 + .maxlen = sizeof(int),
67315 + .mode = 0600,
67316 + .proc_handler = &proc_dointvec,
67317 + },
67318 +#endif
67319 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
67320 + {
67321 + .procname = "chroot_findtask",
67322 + .data = &grsec_enable_chroot_findtask,
67323 + .maxlen = sizeof(int),
67324 + .mode = 0600,
67325 + .proc_handler = &proc_dointvec,
67326 + },
67327 +#endif
67328 +#ifdef CONFIG_GRKERNSEC_RESLOG
67329 + {
67330 + .procname = "resource_logging",
67331 + .data = &grsec_resource_logging,
67332 + .maxlen = sizeof(int),
67333 + .mode = 0600,
67334 + .proc_handler = &proc_dointvec,
67335 + },
67336 +#endif
67337 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
67338 + {
67339 + .procname = "audit_ptrace",
67340 + .data = &grsec_enable_audit_ptrace,
67341 + .maxlen = sizeof(int),
67342 + .mode = 0600,
67343 + .proc_handler = &proc_dointvec,
67344 + },
67345 +#endif
67346 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
67347 + {
67348 + .procname = "harden_ptrace",
67349 + .data = &grsec_enable_harden_ptrace,
67350 + .maxlen = sizeof(int),
67351 + .mode = 0600,
67352 + .proc_handler = &proc_dointvec,
67353 + },
67354 +#endif
67355 + {
67356 + .procname = "grsec_lock",
67357 + .data = &grsec_lock,
67358 + .maxlen = sizeof(int),
67359 + .mode = 0600,
67360 + .proc_handler = &proc_dointvec,
67361 + },
67362 +#endif
67363 +#ifdef CONFIG_GRKERNSEC_ROFS
67364 + {
67365 + .procname = "romount_protect",
67366 + .data = &grsec_enable_rofs,
67367 + .maxlen = sizeof(int),
67368 + .mode = 0600,
67369 + .proc_handler = &proc_dointvec_minmax,
67370 + .extra1 = &one,
67371 + .extra2 = &one,
67372 + },
67373 +#endif
67374 + { }
67375 +};
67376 +#endif
67377 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
67378 new file mode 100644
67379 index 0000000..0dc13c3
67380 --- /dev/null
67381 +++ b/grsecurity/grsec_time.c
67382 @@ -0,0 +1,16 @@
67383 +#include <linux/kernel.h>
67384 +#include <linux/sched.h>
67385 +#include <linux/grinternal.h>
67386 +#include <linux/module.h>
67387 +
67388 +void
67389 +gr_log_timechange(void)
67390 +{
67391 +#ifdef CONFIG_GRKERNSEC_TIME
67392 + if (grsec_enable_time)
67393 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
67394 +#endif
67395 + return;
67396 +}
67397 +
67398 +EXPORT_SYMBOL(gr_log_timechange);
67399 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
67400 new file mode 100644
67401 index 0000000..ee57dcf
67402 --- /dev/null
67403 +++ b/grsecurity/grsec_tpe.c
67404 @@ -0,0 +1,73 @@
67405 +#include <linux/kernel.h>
67406 +#include <linux/sched.h>
67407 +#include <linux/file.h>
67408 +#include <linux/fs.h>
67409 +#include <linux/grinternal.h>
67410 +
67411 +extern int gr_acl_tpe_check(void);
67412 +
67413 +int
67414 +gr_tpe_allow(const struct file *file)
67415 +{
67416 +#ifdef CONFIG_GRKERNSEC
67417 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
67418 + const struct cred *cred = current_cred();
67419 + char *msg = NULL;
67420 + char *msg2 = NULL;
67421 +
67422 + // never restrict root
67423 + if (gr_is_global_root(cred->uid))
67424 + return 1;
67425 +
67426 + if (grsec_enable_tpe) {
67427 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
67428 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
67429 + msg = "not being in trusted group";
67430 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
67431 + msg = "being in untrusted group";
67432 +#else
67433 + if (in_group_p(grsec_tpe_gid))
67434 + msg = "being in untrusted group";
67435 +#endif
67436 + }
67437 + if (!msg && gr_acl_tpe_check())
67438 + msg = "being in untrusted role";
67439 +
67440 + // not in any affected group/role
67441 + if (!msg)
67442 + goto next_check;
67443 +
67444 + if (gr_is_global_nonroot(inode->i_uid))
67445 + msg2 = "file in non-root-owned directory";
67446 + else if (inode->i_mode & S_IWOTH)
67447 + msg2 = "file in world-writable directory";
67448 + else if (inode->i_mode & S_IWGRP)
67449 + msg2 = "file in group-writable directory";
67450 +
67451 + if (msg && msg2) {
67452 + char fullmsg[70] = {0};
67453 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
67454 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
67455 + return 0;
67456 + }
67457 + msg = NULL;
67458 +next_check:
67459 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
67460 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
67461 + return 1;
67462 +
67463 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
67464 + msg = "directory not owned by user";
67465 + else if (inode->i_mode & S_IWOTH)
67466 + msg = "file in world-writable directory";
67467 + else if (inode->i_mode & S_IWGRP)
67468 + msg = "file in group-writable directory";
67469 +
67470 + if (msg) {
67471 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
67472 + return 0;
67473 + }
67474 +#endif
67475 +#endif
67476 + return 1;
67477 +}
67478 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
67479 new file mode 100644
67480 index 0000000..9f7b1ac
67481 --- /dev/null
67482 +++ b/grsecurity/grsum.c
67483 @@ -0,0 +1,61 @@
67484 +#include <linux/err.h>
67485 +#include <linux/kernel.h>
67486 +#include <linux/sched.h>
67487 +#include <linux/mm.h>
67488 +#include <linux/scatterlist.h>
67489 +#include <linux/crypto.h>
67490 +#include <linux/gracl.h>
67491 +
67492 +
67493 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
67494 +#error "crypto and sha256 must be built into the kernel"
67495 +#endif
67496 +
67497 +int
67498 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
67499 +{
67500 + char *p;
67501 + struct crypto_hash *tfm;
67502 + struct hash_desc desc;
67503 + struct scatterlist sg;
67504 + unsigned char temp_sum[GR_SHA_LEN];
67505 + volatile int retval = 0;
67506 + volatile int dummy = 0;
67507 + unsigned int i;
67508 +
67509 + sg_init_table(&sg, 1);
67510 +
67511 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
67512 + if (IS_ERR(tfm)) {
67513 + /* should never happen, since sha256 should be built in */
67514 + return 1;
67515 + }
67516 +
67517 + desc.tfm = tfm;
67518 + desc.flags = 0;
67519 +
67520 + crypto_hash_init(&desc);
67521 +
67522 + p = salt;
67523 + sg_set_buf(&sg, p, GR_SALT_LEN);
67524 + crypto_hash_update(&desc, &sg, sg.length);
67525 +
67526 + p = entry->pw;
67527 + sg_set_buf(&sg, p, strlen(p));
67528 +
67529 + crypto_hash_update(&desc, &sg, sg.length);
67530 +
67531 + crypto_hash_final(&desc, temp_sum);
67532 +
67533 + memset(entry->pw, 0, GR_PW_LEN);
67534 +
67535 + for (i = 0; i < GR_SHA_LEN; i++)
67536 + if (sum[i] != temp_sum[i])
67537 + retval = 1;
67538 + else
67539 + dummy = 1; // waste a cycle
67540 +
67541 + crypto_free_hash(tfm);
67542 +
67543 + return retval;
67544 +}
67545 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
67546 index 77ff547..181834f 100644
67547 --- a/include/asm-generic/4level-fixup.h
67548 +++ b/include/asm-generic/4level-fixup.h
67549 @@ -13,8 +13,10 @@
67550 #define pmd_alloc(mm, pud, address) \
67551 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
67552 NULL: pmd_offset(pud, address))
67553 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
67554
67555 #define pud_alloc(mm, pgd, address) (pgd)
67556 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
67557 #define pud_offset(pgd, start) (pgd)
67558 #define pud_none(pud) 0
67559 #define pud_bad(pud) 0
67560 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
67561 index b7babf0..04ad282 100644
67562 --- a/include/asm-generic/atomic-long.h
67563 +++ b/include/asm-generic/atomic-long.h
67564 @@ -22,6 +22,12 @@
67565
67566 typedef atomic64_t atomic_long_t;
67567
67568 +#ifdef CONFIG_PAX_REFCOUNT
67569 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67570 +#else
67571 +typedef atomic64_t atomic_long_unchecked_t;
67572 +#endif
67573 +
67574 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67575
67576 static inline long atomic_long_read(atomic_long_t *l)
67577 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67578 return (long)atomic64_read(v);
67579 }
67580
67581 +#ifdef CONFIG_PAX_REFCOUNT
67582 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67583 +{
67584 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67585 +
67586 + return (long)atomic64_read_unchecked(v);
67587 +}
67588 +#endif
67589 +
67590 static inline void atomic_long_set(atomic_long_t *l, long i)
67591 {
67592 atomic64_t *v = (atomic64_t *)l;
67593 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67594 atomic64_set(v, i);
67595 }
67596
67597 +#ifdef CONFIG_PAX_REFCOUNT
67598 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67599 +{
67600 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67601 +
67602 + atomic64_set_unchecked(v, i);
67603 +}
67604 +#endif
67605 +
67606 static inline void atomic_long_inc(atomic_long_t *l)
67607 {
67608 atomic64_t *v = (atomic64_t *)l;
67609 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67610 atomic64_inc(v);
67611 }
67612
67613 +#ifdef CONFIG_PAX_REFCOUNT
67614 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67615 +{
67616 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67617 +
67618 + atomic64_inc_unchecked(v);
67619 +}
67620 +#endif
67621 +
67622 static inline void atomic_long_dec(atomic_long_t *l)
67623 {
67624 atomic64_t *v = (atomic64_t *)l;
67625 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67626 atomic64_dec(v);
67627 }
67628
67629 +#ifdef CONFIG_PAX_REFCOUNT
67630 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67631 +{
67632 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67633 +
67634 + atomic64_dec_unchecked(v);
67635 +}
67636 +#endif
67637 +
67638 static inline void atomic_long_add(long i, atomic_long_t *l)
67639 {
67640 atomic64_t *v = (atomic64_t *)l;
67641 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67642 atomic64_add(i, v);
67643 }
67644
67645 +#ifdef CONFIG_PAX_REFCOUNT
67646 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67647 +{
67648 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67649 +
67650 + atomic64_add_unchecked(i, v);
67651 +}
67652 +#endif
67653 +
67654 static inline void atomic_long_sub(long i, atomic_long_t *l)
67655 {
67656 atomic64_t *v = (atomic64_t *)l;
67657 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67658 atomic64_sub(i, v);
67659 }
67660
67661 +#ifdef CONFIG_PAX_REFCOUNT
67662 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67663 +{
67664 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67665 +
67666 + atomic64_sub_unchecked(i, v);
67667 +}
67668 +#endif
67669 +
67670 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67671 {
67672 atomic64_t *v = (atomic64_t *)l;
67673 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67674 return (long)atomic64_add_return(i, v);
67675 }
67676
67677 +#ifdef CONFIG_PAX_REFCOUNT
67678 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67679 +{
67680 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67681 +
67682 + return (long)atomic64_add_return_unchecked(i, v);
67683 +}
67684 +#endif
67685 +
67686 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67687 {
67688 atomic64_t *v = (atomic64_t *)l;
67689 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67690 return (long)atomic64_inc_return(v);
67691 }
67692
67693 +#ifdef CONFIG_PAX_REFCOUNT
67694 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67695 +{
67696 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67697 +
67698 + return (long)atomic64_inc_return_unchecked(v);
67699 +}
67700 +#endif
67701 +
67702 static inline long atomic_long_dec_return(atomic_long_t *l)
67703 {
67704 atomic64_t *v = (atomic64_t *)l;
67705 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67706
67707 typedef atomic_t atomic_long_t;
67708
67709 +#ifdef CONFIG_PAX_REFCOUNT
67710 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67711 +#else
67712 +typedef atomic_t atomic_long_unchecked_t;
67713 +#endif
67714 +
67715 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67716 static inline long atomic_long_read(atomic_long_t *l)
67717 {
67718 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67719 return (long)atomic_read(v);
67720 }
67721
67722 +#ifdef CONFIG_PAX_REFCOUNT
67723 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67724 +{
67725 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67726 +
67727 + return (long)atomic_read_unchecked(v);
67728 +}
67729 +#endif
67730 +
67731 static inline void atomic_long_set(atomic_long_t *l, long i)
67732 {
67733 atomic_t *v = (atomic_t *)l;
67734 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67735 atomic_set(v, i);
67736 }
67737
67738 +#ifdef CONFIG_PAX_REFCOUNT
67739 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67740 +{
67741 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67742 +
67743 + atomic_set_unchecked(v, i);
67744 +}
67745 +#endif
67746 +
67747 static inline void atomic_long_inc(atomic_long_t *l)
67748 {
67749 atomic_t *v = (atomic_t *)l;
67750 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67751 atomic_inc(v);
67752 }
67753
67754 +#ifdef CONFIG_PAX_REFCOUNT
67755 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67756 +{
67757 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67758 +
67759 + atomic_inc_unchecked(v);
67760 +}
67761 +#endif
67762 +
67763 static inline void atomic_long_dec(atomic_long_t *l)
67764 {
67765 atomic_t *v = (atomic_t *)l;
67766 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67767 atomic_dec(v);
67768 }
67769
67770 +#ifdef CONFIG_PAX_REFCOUNT
67771 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67772 +{
67773 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67774 +
67775 + atomic_dec_unchecked(v);
67776 +}
67777 +#endif
67778 +
67779 static inline void atomic_long_add(long i, atomic_long_t *l)
67780 {
67781 atomic_t *v = (atomic_t *)l;
67782 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67783 atomic_add(i, v);
67784 }
67785
67786 +#ifdef CONFIG_PAX_REFCOUNT
67787 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67788 +{
67789 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67790 +
67791 + atomic_add_unchecked(i, v);
67792 +}
67793 +#endif
67794 +
67795 static inline void atomic_long_sub(long i, atomic_long_t *l)
67796 {
67797 atomic_t *v = (atomic_t *)l;
67798 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67799 atomic_sub(i, v);
67800 }
67801
67802 +#ifdef CONFIG_PAX_REFCOUNT
67803 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67804 +{
67805 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67806 +
67807 + atomic_sub_unchecked(i, v);
67808 +}
67809 +#endif
67810 +
67811 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67812 {
67813 atomic_t *v = (atomic_t *)l;
67814 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67815 return (long)atomic_add_return(i, v);
67816 }
67817
67818 +#ifdef CONFIG_PAX_REFCOUNT
67819 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67820 +{
67821 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67822 +
67823 + return (long)atomic_add_return_unchecked(i, v);
67824 +}
67825 +
67826 +#endif
67827 +
67828 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67829 {
67830 atomic_t *v = (atomic_t *)l;
67831 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67832 return (long)atomic_inc_return(v);
67833 }
67834
67835 +#ifdef CONFIG_PAX_REFCOUNT
67836 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67837 +{
67838 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67839 +
67840 + return (long)atomic_inc_return_unchecked(v);
67841 +}
67842 +#endif
67843 +
67844 static inline long atomic_long_dec_return(atomic_long_t *l)
67845 {
67846 atomic_t *v = (atomic_t *)l;
67847 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67848
67849 #endif /* BITS_PER_LONG == 64 */
67850
67851 +#ifdef CONFIG_PAX_REFCOUNT
67852 +static inline void pax_refcount_needs_these_functions(void)
67853 +{
67854 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67855 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67856 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67857 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67858 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67859 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67860 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67861 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67862 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67863 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67864 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67865 +#ifdef CONFIG_X86
67866 + atomic_clear_mask_unchecked(0, NULL);
67867 + atomic_set_mask_unchecked(0, NULL);
67868 +#endif
67869 +
67870 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67871 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67872 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67873 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67874 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67875 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67876 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67877 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67878 +}
67879 +#else
67880 +#define atomic_read_unchecked(v) atomic_read(v)
67881 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67882 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67883 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67884 +#define atomic_inc_unchecked(v) atomic_inc(v)
67885 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67886 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67887 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67888 +#define atomic_dec_unchecked(v) atomic_dec(v)
67889 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67890 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67891 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67892 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67893 +
67894 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67895 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67896 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67897 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67898 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67899 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67900 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67901 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67902 +#endif
67903 +
67904 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67905 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67906 index 1ced641..c896ee8 100644
67907 --- a/include/asm-generic/atomic.h
67908 +++ b/include/asm-generic/atomic.h
67909 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67910 * Atomically clears the bits set in @mask from @v
67911 */
67912 #ifndef atomic_clear_mask
67913 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67914 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67915 {
67916 unsigned long flags;
67917
67918 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67919 index b18ce4f..2ee2843 100644
67920 --- a/include/asm-generic/atomic64.h
67921 +++ b/include/asm-generic/atomic64.h
67922 @@ -16,6 +16,8 @@ typedef struct {
67923 long long counter;
67924 } atomic64_t;
67925
67926 +typedef atomic64_t atomic64_unchecked_t;
67927 +
67928 #define ATOMIC64_INIT(i) { (i) }
67929
67930 extern long long atomic64_read(const atomic64_t *v);
67931 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67932 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67933 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67934
67935 +#define atomic64_read_unchecked(v) atomic64_read(v)
67936 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67937 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67938 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67939 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67940 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67941 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67942 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67943 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67944 +
67945 #endif /* _ASM_GENERIC_ATOMIC64_H */
67946 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67947 index 1bfcfe5..e04c5c9 100644
67948 --- a/include/asm-generic/cache.h
67949 +++ b/include/asm-generic/cache.h
67950 @@ -6,7 +6,7 @@
67951 * cache lines need to provide their own cache.h.
67952 */
67953
67954 -#define L1_CACHE_SHIFT 5
67955 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67956 +#define L1_CACHE_SHIFT 5UL
67957 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67958
67959 #endif /* __ASM_GENERIC_CACHE_H */
67960 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67961 index 0d68a1e..b74a761 100644
67962 --- a/include/asm-generic/emergency-restart.h
67963 +++ b/include/asm-generic/emergency-restart.h
67964 @@ -1,7 +1,7 @@
67965 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67966 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67967
67968 -static inline void machine_emergency_restart(void)
67969 +static inline __noreturn void machine_emergency_restart(void)
67970 {
67971 machine_restart(NULL);
67972 }
67973 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67974 index 90f99c7..00ce236 100644
67975 --- a/include/asm-generic/kmap_types.h
67976 +++ b/include/asm-generic/kmap_types.h
67977 @@ -2,9 +2,9 @@
67978 #define _ASM_GENERIC_KMAP_TYPES_H
67979
67980 #ifdef __WITH_KM_FENCE
67981 -# define KM_TYPE_NR 41
67982 +# define KM_TYPE_NR 42
67983 #else
67984 -# define KM_TYPE_NR 20
67985 +# define KM_TYPE_NR 21
67986 #endif
67987
67988 #endif
67989 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67990 index 9ceb03b..62b0b8f 100644
67991 --- a/include/asm-generic/local.h
67992 +++ b/include/asm-generic/local.h
67993 @@ -23,24 +23,37 @@ typedef struct
67994 atomic_long_t a;
67995 } local_t;
67996
67997 +typedef struct {
67998 + atomic_long_unchecked_t a;
67999 +} local_unchecked_t;
68000 +
68001 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
68002
68003 #define local_read(l) atomic_long_read(&(l)->a)
68004 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
68005 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
68006 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
68007 #define local_inc(l) atomic_long_inc(&(l)->a)
68008 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
68009 #define local_dec(l) atomic_long_dec(&(l)->a)
68010 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
68011 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
68012 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
68013 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
68014 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
68015
68016 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
68017 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
68018 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
68019 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
68020 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
68021 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
68022 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
68023 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
68024 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
68025
68026 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
68027 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
68028 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
68029 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
68030 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
68031 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
68032 index 725612b..9cc513a 100644
68033 --- a/include/asm-generic/pgtable-nopmd.h
68034 +++ b/include/asm-generic/pgtable-nopmd.h
68035 @@ -1,14 +1,19 @@
68036 #ifndef _PGTABLE_NOPMD_H
68037 #define _PGTABLE_NOPMD_H
68038
68039 -#ifndef __ASSEMBLY__
68040 -
68041 #include <asm-generic/pgtable-nopud.h>
68042
68043 -struct mm_struct;
68044 -
68045 #define __PAGETABLE_PMD_FOLDED
68046
68047 +#define PMD_SHIFT PUD_SHIFT
68048 +#define PTRS_PER_PMD 1
68049 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
68050 +#define PMD_MASK (~(PMD_SIZE-1))
68051 +
68052 +#ifndef __ASSEMBLY__
68053 +
68054 +struct mm_struct;
68055 +
68056 /*
68057 * Having the pmd type consist of a pud gets the size right, and allows
68058 * us to conceptually access the pud entry that this pmd is folded into
68059 @@ -16,11 +21,6 @@ struct mm_struct;
68060 */
68061 typedef struct { pud_t pud; } pmd_t;
68062
68063 -#define PMD_SHIFT PUD_SHIFT
68064 -#define PTRS_PER_PMD 1
68065 -#define PMD_SIZE (1UL << PMD_SHIFT)
68066 -#define PMD_MASK (~(PMD_SIZE-1))
68067 -
68068 /*
68069 * The "pud_xxx()" functions here are trivial for a folded two-level
68070 * setup: the pmd is never bad, and a pmd always exists (as it's folded
68071 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
68072 index 810431d..0ec4804f 100644
68073 --- a/include/asm-generic/pgtable-nopud.h
68074 +++ b/include/asm-generic/pgtable-nopud.h
68075 @@ -1,10 +1,15 @@
68076 #ifndef _PGTABLE_NOPUD_H
68077 #define _PGTABLE_NOPUD_H
68078
68079 -#ifndef __ASSEMBLY__
68080 -
68081 #define __PAGETABLE_PUD_FOLDED
68082
68083 +#define PUD_SHIFT PGDIR_SHIFT
68084 +#define PTRS_PER_PUD 1
68085 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
68086 +#define PUD_MASK (~(PUD_SIZE-1))
68087 +
68088 +#ifndef __ASSEMBLY__
68089 +
68090 /*
68091 * Having the pud type consist of a pgd gets the size right, and allows
68092 * us to conceptually access the pgd entry that this pud is folded into
68093 @@ -12,11 +17,6 @@
68094 */
68095 typedef struct { pgd_t pgd; } pud_t;
68096
68097 -#define PUD_SHIFT PGDIR_SHIFT
68098 -#define PTRS_PER_PUD 1
68099 -#define PUD_SIZE (1UL << PUD_SHIFT)
68100 -#define PUD_MASK (~(PUD_SIZE-1))
68101 -
68102 /*
68103 * The "pgd_xxx()" functions here are trivial for a folded two-level
68104 * setup: the pud is never bad, and a pud always exists (as it's folded
68105 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
68106 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
68107
68108 #define pgd_populate(mm, pgd, pud) do { } while (0)
68109 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
68110 /*
68111 * (puds are folded into pgds so this doesn't get actually called,
68112 * but the define is needed for a generic inline function.)
68113 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
68114 index 5cf680a..4b74d62 100644
68115 --- a/include/asm-generic/pgtable.h
68116 +++ b/include/asm-generic/pgtable.h
68117 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
68118 }
68119 #endif /* CONFIG_NUMA_BALANCING */
68120
68121 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
68122 +static inline unsigned long pax_open_kernel(void) { return 0; }
68123 +#endif
68124 +
68125 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
68126 +static inline unsigned long pax_close_kernel(void) { return 0; }
68127 +#endif
68128 +
68129 #endif /* CONFIG_MMU */
68130
68131 #endif /* !__ASSEMBLY__ */
68132 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
68133 index d1ea7ce..b1ebf2a 100644
68134 --- a/include/asm-generic/vmlinux.lds.h
68135 +++ b/include/asm-generic/vmlinux.lds.h
68136 @@ -218,6 +218,7 @@
68137 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
68138 VMLINUX_SYMBOL(__start_rodata) = .; \
68139 *(.rodata) *(.rodata.*) \
68140 + *(.data..read_only) \
68141 *(__vermagic) /* Kernel version magic */ \
68142 . = ALIGN(8); \
68143 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
68144 @@ -725,17 +726,18 @@
68145 * section in the linker script will go there too. @phdr should have
68146 * a leading colon.
68147 *
68148 - * Note that this macros defines __per_cpu_load as an absolute symbol.
68149 + * Note that this macros defines per_cpu_load as an absolute symbol.
68150 * If there is no need to put the percpu section at a predetermined
68151 * address, use PERCPU_SECTION.
68152 */
68153 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
68154 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
68155 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
68156 + per_cpu_load = .; \
68157 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
68158 - LOAD_OFFSET) { \
68159 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
68160 PERCPU_INPUT(cacheline) \
68161 } phdr \
68162 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
68163 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
68164
68165 /**
68166 * PERCPU_SECTION - define output section for percpu area, simple version
68167 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
68168 index 418d270..bfd2794 100644
68169 --- a/include/crypto/algapi.h
68170 +++ b/include/crypto/algapi.h
68171 @@ -34,7 +34,7 @@ struct crypto_type {
68172 unsigned int maskclear;
68173 unsigned int maskset;
68174 unsigned int tfmsize;
68175 -};
68176 +} __do_const;
68177
68178 struct crypto_instance {
68179 struct crypto_alg alg;
68180 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
68181 index fad21c9..ab858bc 100644
68182 --- a/include/drm/drmP.h
68183 +++ b/include/drm/drmP.h
68184 @@ -72,6 +72,7 @@
68185 #include <linux/workqueue.h>
68186 #include <linux/poll.h>
68187 #include <asm/pgalloc.h>
68188 +#include <asm/local.h>
68189 #include <drm/drm.h>
68190 #include <drm/drm_sarea.h>
68191
68192 @@ -293,10 +294,12 @@ do { \
68193 * \param cmd command.
68194 * \param arg argument.
68195 */
68196 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
68197 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
68198 + struct drm_file *file_priv);
68199 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
68200 struct drm_file *file_priv);
68201
68202 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
68203 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
68204 unsigned long arg);
68205
68206 #define DRM_IOCTL_NR(n) _IOC_NR(n)
68207 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
68208 struct drm_ioctl_desc {
68209 unsigned int cmd;
68210 int flags;
68211 - drm_ioctl_t *func;
68212 + drm_ioctl_t func;
68213 unsigned int cmd_drv;
68214 -};
68215 +} __do_const;
68216
68217 /**
68218 * Creates a driver or general drm_ioctl_desc array entry for the given
68219 @@ -995,7 +998,7 @@ struct drm_info_list {
68220 int (*show)(struct seq_file*, void*); /** show callback */
68221 u32 driver_features; /**< Required driver features for this entry */
68222 void *data;
68223 -};
68224 +} __do_const;
68225
68226 /**
68227 * debugfs node structure. This structure represents a debugfs file.
68228 @@ -1068,7 +1071,7 @@ struct drm_device {
68229
68230 /** \name Usage Counters */
68231 /*@{ */
68232 - int open_count; /**< Outstanding files open */
68233 + local_t open_count; /**< Outstanding files open */
68234 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
68235 atomic_t vma_count; /**< Outstanding vma areas open */
68236 int buf_use; /**< Buffers in use -- cannot alloc */
68237 @@ -1079,7 +1082,7 @@ struct drm_device {
68238 /*@{ */
68239 unsigned long counters;
68240 enum drm_stat_type types[15];
68241 - atomic_t counts[15];
68242 + atomic_unchecked_t counts[15];
68243 /*@} */
68244
68245 struct list_head filelist;
68246 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
68247 index f43d556..94d9343 100644
68248 --- a/include/drm/drm_crtc_helper.h
68249 +++ b/include/drm/drm_crtc_helper.h
68250 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
68251 struct drm_connector *connector);
68252 /* disable encoder when not in use - more explicit than dpms off */
68253 void (*disable)(struct drm_encoder *encoder);
68254 -};
68255 +} __no_const;
68256
68257 /**
68258 * drm_connector_helper_funcs - helper operations for connectors
68259 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
68260 index 72dcbe8..8db58d7 100644
68261 --- a/include/drm/ttm/ttm_memory.h
68262 +++ b/include/drm/ttm/ttm_memory.h
68263 @@ -48,7 +48,7 @@
68264
68265 struct ttm_mem_shrink {
68266 int (*do_shrink) (struct ttm_mem_shrink *);
68267 -};
68268 +} __no_const;
68269
68270 /**
68271 * struct ttm_mem_global - Global memory accounting structure.
68272 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
68273 index 4b840e8..155d235 100644
68274 --- a/include/keys/asymmetric-subtype.h
68275 +++ b/include/keys/asymmetric-subtype.h
68276 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
68277 /* Verify the signature on a key of this subtype (optional) */
68278 int (*verify_signature)(const struct key *key,
68279 const struct public_key_signature *sig);
68280 -};
68281 +} __do_const;
68282
68283 /**
68284 * asymmetric_key_subtype - Get the subtype from an asymmetric key
68285 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
68286 index c1da539..1dcec55 100644
68287 --- a/include/linux/atmdev.h
68288 +++ b/include/linux/atmdev.h
68289 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
68290 #endif
68291
68292 struct k_atm_aal_stats {
68293 -#define __HANDLE_ITEM(i) atomic_t i
68294 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
68295 __AAL_STAT_ITEMS
68296 #undef __HANDLE_ITEM
68297 };
68298 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
68299 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
68300 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
68301 struct module *owner;
68302 -};
68303 +} __do_const ;
68304
68305 struct atmphy_ops {
68306 int (*start)(struct atm_dev *dev);
68307 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
68308 index 0530b98..96a8ac0 100644
68309 --- a/include/linux/binfmts.h
68310 +++ b/include/linux/binfmts.h
68311 @@ -73,8 +73,9 @@ struct linux_binfmt {
68312 int (*load_binary)(struct linux_binprm *);
68313 int (*load_shlib)(struct file *);
68314 int (*core_dump)(struct coredump_params *cprm);
68315 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
68316 unsigned long min_coredump; /* minimal dump size */
68317 -};
68318 +} __do_const;
68319
68320 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
68321
68322 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
68323 index f94bc83..62b9cfe 100644
68324 --- a/include/linux/blkdev.h
68325 +++ b/include/linux/blkdev.h
68326 @@ -1498,7 +1498,7 @@ struct block_device_operations {
68327 /* this callback is with swap_lock and sometimes page table lock held */
68328 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
68329 struct module *owner;
68330 -};
68331 +} __do_const;
68332
68333 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
68334 unsigned long);
68335 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
68336 index 7c2e030..b72475d 100644
68337 --- a/include/linux/blktrace_api.h
68338 +++ b/include/linux/blktrace_api.h
68339 @@ -23,7 +23,7 @@ struct blk_trace {
68340 struct dentry *dir;
68341 struct dentry *dropped_file;
68342 struct dentry *msg_file;
68343 - atomic_t dropped;
68344 + atomic_unchecked_t dropped;
68345 };
68346
68347 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
68348 diff --git a/include/linux/cache.h b/include/linux/cache.h
68349 index 4c57065..4307975 100644
68350 --- a/include/linux/cache.h
68351 +++ b/include/linux/cache.h
68352 @@ -16,6 +16,10 @@
68353 #define __read_mostly
68354 #endif
68355
68356 +#ifndef __read_only
68357 +#define __read_only __read_mostly
68358 +#endif
68359 +
68360 #ifndef ____cacheline_aligned
68361 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
68362 #endif
68363 diff --git a/include/linux/capability.h b/include/linux/capability.h
68364 index d9a4f7f4..19f77d6 100644
68365 --- a/include/linux/capability.h
68366 +++ b/include/linux/capability.h
68367 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
68368 extern bool nsown_capable(int cap);
68369 extern bool inode_capable(const struct inode *inode, int cap);
68370 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
68371 +extern bool capable_nolog(int cap);
68372 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
68373 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
68374
68375 /* audit system wants to get cap info from files as well */
68376 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
68377
68378 +extern int is_privileged_binary(const struct dentry *dentry);
68379 +
68380 #endif /* !_LINUX_CAPABILITY_H */
68381 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
68382 index 8609d57..86e4d79 100644
68383 --- a/include/linux/cdrom.h
68384 +++ b/include/linux/cdrom.h
68385 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
68386
68387 /* driver specifications */
68388 const int capability; /* capability flags */
68389 - int n_minors; /* number of active minor devices */
68390 /* handle uniform packets for scsi type devices (scsi,atapi) */
68391 int (*generic_packet) (struct cdrom_device_info *,
68392 struct packet_command *);
68393 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
68394 index 42e55de..1cd0e66 100644
68395 --- a/include/linux/cleancache.h
68396 +++ b/include/linux/cleancache.h
68397 @@ -31,7 +31,7 @@ struct cleancache_ops {
68398 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
68399 void (*invalidate_inode)(int, struct cleancache_filekey);
68400 void (*invalidate_fs)(int);
68401 -};
68402 +} __no_const;
68403
68404 extern struct cleancache_ops
68405 cleancache_register_ops(struct cleancache_ops *ops);
68406 diff --git a/include/linux/compat.h b/include/linux/compat.h
68407 index dec7e2d..45db13f 100644
68408 --- a/include/linux/compat.h
68409 +++ b/include/linux/compat.h
68410 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
68411 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
68412 int version, void __user *uptr);
68413 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
68414 - void __user *uptr);
68415 + void __user *uptr) __intentional_overflow(0);
68416 #else
68417 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
68418 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
68419 compat_ssize_t msgsz, int msgflg);
68420 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
68421 compat_ssize_t msgsz, long msgtyp, int msgflg);
68422 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
68423 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
68424 #endif
68425 long compat_sys_msgctl(int first, int second, void __user *uptr);
68426 long compat_sys_shmctl(int first, int second, void __user *uptr);
68427 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
68428 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
68429 compat_ulong_t addr, compat_ulong_t data);
68430 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
68431 - compat_long_t addr, compat_long_t data);
68432 + compat_ulong_t addr, compat_ulong_t data);
68433
68434 /*
68435 * epoll (fs/eventpoll.c) compat bits follow ...
68436 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
68437 index 662fd1b..e801992 100644
68438 --- a/include/linux/compiler-gcc4.h
68439 +++ b/include/linux/compiler-gcc4.h
68440 @@ -34,6 +34,21 @@
68441 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
68442
68443 #if __GNUC_MINOR__ >= 5
68444 +
68445 +#ifdef CONSTIFY_PLUGIN
68446 +#define __no_const __attribute__((no_const))
68447 +#define __do_const __attribute__((do_const))
68448 +#endif
68449 +
68450 +#ifdef SIZE_OVERFLOW_PLUGIN
68451 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
68452 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
68453 +#endif
68454 +
68455 +#ifdef LATENT_ENTROPY_PLUGIN
68456 +#define __latent_entropy __attribute__((latent_entropy))
68457 +#endif
68458 +
68459 /*
68460 * Mark a position in code as unreachable. This can be used to
68461 * suppress control flow warnings after asm blocks that transfer
68462 @@ -49,6 +64,11 @@
68463 #define __noclone __attribute__((__noclone__))
68464
68465 #endif
68466 +
68467 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
68468 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
68469 +#define __bos0(ptr) __bos((ptr), 0)
68470 +#define __bos1(ptr) __bos((ptr), 1)
68471 #endif
68472
68473 #if __GNUC_MINOR__ >= 6
68474 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
68475 index dd852b7..1ad5fba 100644
68476 --- a/include/linux/compiler.h
68477 +++ b/include/linux/compiler.h
68478 @@ -5,11 +5,14 @@
68479
68480 #ifdef __CHECKER__
68481 # define __user __attribute__((noderef, address_space(1)))
68482 +# define __force_user __force __user
68483 # define __kernel __attribute__((address_space(0)))
68484 +# define __force_kernel __force __kernel
68485 # define __safe __attribute__((safe))
68486 # define __force __attribute__((force))
68487 # define __nocast __attribute__((nocast))
68488 # define __iomem __attribute__((noderef, address_space(2)))
68489 +# define __force_iomem __force __iomem
68490 # define __must_hold(x) __attribute__((context(x,1,1)))
68491 # define __acquires(x) __attribute__((context(x,0,1)))
68492 # define __releases(x) __attribute__((context(x,1,0)))
68493 @@ -17,20 +20,37 @@
68494 # define __release(x) __context__(x,-1)
68495 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
68496 # define __percpu __attribute__((noderef, address_space(3)))
68497 +# define __force_percpu __force __percpu
68498 #ifdef CONFIG_SPARSE_RCU_POINTER
68499 # define __rcu __attribute__((noderef, address_space(4)))
68500 +# define __force_rcu __force __rcu
68501 #else
68502 # define __rcu
68503 +# define __force_rcu
68504 #endif
68505 extern void __chk_user_ptr(const volatile void __user *);
68506 extern void __chk_io_ptr(const volatile void __iomem *);
68507 #else
68508 -# define __user
68509 -# define __kernel
68510 +# ifdef CHECKER_PLUGIN
68511 +//# define __user
68512 +//# define __force_user
68513 +//# define __kernel
68514 +//# define __force_kernel
68515 +# else
68516 +# ifdef STRUCTLEAK_PLUGIN
68517 +# define __user __attribute__((user))
68518 +# else
68519 +# define __user
68520 +# endif
68521 +# define __force_user
68522 +# define __kernel
68523 +# define __force_kernel
68524 +# endif
68525 # define __safe
68526 # define __force
68527 # define __nocast
68528 # define __iomem
68529 +# define __force_iomem
68530 # define __chk_user_ptr(x) (void)0
68531 # define __chk_io_ptr(x) (void)0
68532 # define __builtin_warning(x, y...) (1)
68533 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
68534 # define __release(x) (void)0
68535 # define __cond_lock(x,c) (c)
68536 # define __percpu
68537 +# define __force_percpu
68538 # define __rcu
68539 +# define __force_rcu
68540 #endif
68541
68542 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
68543 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68544 # define __attribute_const__ /* unimplemented */
68545 #endif
68546
68547 +#ifndef __no_const
68548 +# define __no_const
68549 +#endif
68550 +
68551 +#ifndef __do_const
68552 +# define __do_const
68553 +#endif
68554 +
68555 +#ifndef __size_overflow
68556 +# define __size_overflow(...)
68557 +#endif
68558 +
68559 +#ifndef __intentional_overflow
68560 +# define __intentional_overflow(...)
68561 +#endif
68562 +
68563 +#ifndef __latent_entropy
68564 +# define __latent_entropy
68565 +#endif
68566 +
68567 /*
68568 * Tell gcc if a function is cold. The compiler will assume any path
68569 * directly leading to the call is unlikely.
68570 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68571 #define __cold
68572 #endif
68573
68574 +#ifndef __alloc_size
68575 +#define __alloc_size(...)
68576 +#endif
68577 +
68578 +#ifndef __bos
68579 +#define __bos(ptr, arg)
68580 +#endif
68581 +
68582 +#ifndef __bos0
68583 +#define __bos0(ptr)
68584 +#endif
68585 +
68586 +#ifndef __bos1
68587 +#define __bos1(ptr)
68588 +#endif
68589 +
68590 /* Simple shorthand for a section definition */
68591 #ifndef __section
68592 # define __section(S) __attribute__ ((__section__(#S)))
68593 @@ -323,6 +381,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68594 * use is to mediate communication between process-level code and irq/NMI
68595 * handlers, all running on the same CPU.
68596 */
68597 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68598 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68599 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68600
68601 #endif /* __LINUX_COMPILER_H */
68602 diff --git a/include/linux/completion.h b/include/linux/completion.h
68603 index 51494e6..0fd1b61 100644
68604 --- a/include/linux/completion.h
68605 +++ b/include/linux/completion.h
68606 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
68607
68608 extern void wait_for_completion(struct completion *);
68609 extern int wait_for_completion_interruptible(struct completion *x);
68610 -extern int wait_for_completion_killable(struct completion *x);
68611 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68612 extern unsigned long wait_for_completion_timeout(struct completion *x,
68613 unsigned long timeout);
68614 extern long wait_for_completion_interruptible_timeout(
68615 - struct completion *x, unsigned long timeout);
68616 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68617 extern long wait_for_completion_killable_timeout(
68618 - struct completion *x, unsigned long timeout);
68619 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68620 extern bool try_wait_for_completion(struct completion *x);
68621 extern bool completion_done(struct completion *x);
68622
68623 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68624 index 34025df..d94bbbc 100644
68625 --- a/include/linux/configfs.h
68626 +++ b/include/linux/configfs.h
68627 @@ -125,7 +125,7 @@ struct configfs_attribute {
68628 const char *ca_name;
68629 struct module *ca_owner;
68630 umode_t ca_mode;
68631 -};
68632 +} __do_const;
68633
68634 /*
68635 * Users often need to create attribute structures for their configurable
68636 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68637 index ce7a074..01ab8ac 100644
68638 --- a/include/linux/cpu.h
68639 +++ b/include/linux/cpu.h
68640 @@ -115,7 +115,7 @@ enum {
68641 /* Need to know about CPUs going up/down? */
68642 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68643 #define cpu_notifier(fn, pri) { \
68644 - static struct notifier_block fn##_nb __cpuinitdata = \
68645 + static struct notifier_block fn##_nb = \
68646 { .notifier_call = fn, .priority = pri }; \
68647 register_cpu_notifier(&fn##_nb); \
68648 }
68649 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68650 index a55b88e..fba90c5 100644
68651 --- a/include/linux/cpufreq.h
68652 +++ b/include/linux/cpufreq.h
68653 @@ -240,7 +240,7 @@ struct cpufreq_driver {
68654 int (*suspend) (struct cpufreq_policy *policy);
68655 int (*resume) (struct cpufreq_policy *policy);
68656 struct freq_attr **attr;
68657 -};
68658 +} __do_const;
68659
68660 /* flags */
68661
68662 @@ -299,6 +299,7 @@ struct global_attr {
68663 ssize_t (*store)(struct kobject *a, struct attribute *b,
68664 const char *c, size_t count);
68665 };
68666 +typedef struct global_attr __no_const global_attr_no_const;
68667
68668 #define define_one_global_ro(_name) \
68669 static struct global_attr _name = \
68670 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68671 index 24cd1037..20a63aae 100644
68672 --- a/include/linux/cpuidle.h
68673 +++ b/include/linux/cpuidle.h
68674 @@ -54,7 +54,8 @@ struct cpuidle_state {
68675 int index);
68676
68677 int (*enter_dead) (struct cpuidle_device *dev, int index);
68678 -};
68679 +} __do_const;
68680 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68681
68682 /* Idle State Flags */
68683 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68684 @@ -216,7 +217,7 @@ struct cpuidle_governor {
68685 void (*reflect) (struct cpuidle_device *dev, int index);
68686
68687 struct module *owner;
68688 -};
68689 +} __do_const;
68690
68691 #ifdef CONFIG_CPU_IDLE
68692
68693 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68694 index 0325602..5e9feff 100644
68695 --- a/include/linux/cpumask.h
68696 +++ b/include/linux/cpumask.h
68697 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68698 }
68699
68700 /* Valid inputs for n are -1 and 0. */
68701 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68702 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68703 {
68704 return n+1;
68705 }
68706
68707 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68708 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68709 {
68710 return n+1;
68711 }
68712
68713 -static inline unsigned int cpumask_next_and(int n,
68714 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68715 const struct cpumask *srcp,
68716 const struct cpumask *andp)
68717 {
68718 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68719 *
68720 * Returns >= nr_cpu_ids if no further cpus set.
68721 */
68722 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68723 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68724 {
68725 /* -1 is a legal arg here. */
68726 if (n != -1)
68727 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68728 *
68729 * Returns >= nr_cpu_ids if no further cpus unset.
68730 */
68731 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68732 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68733 {
68734 /* -1 is a legal arg here. */
68735 if (n != -1)
68736 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68737 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68738 }
68739
68740 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68741 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68742 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68743
68744 /**
68745 diff --git a/include/linux/cred.h b/include/linux/cred.h
68746 index 04421e8..6bce4ef 100644
68747 --- a/include/linux/cred.h
68748 +++ b/include/linux/cred.h
68749 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68750 static inline void validate_process_creds(void)
68751 {
68752 }
68753 +static inline void validate_task_creds(struct task_struct *task)
68754 +{
68755 +}
68756 #endif
68757
68758 /**
68759 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68760 index b92eadf..b4ecdc1 100644
68761 --- a/include/linux/crypto.h
68762 +++ b/include/linux/crypto.h
68763 @@ -373,7 +373,7 @@ struct cipher_tfm {
68764 const u8 *key, unsigned int keylen);
68765 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68766 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68767 -};
68768 +} __no_const;
68769
68770 struct hash_tfm {
68771 int (*init)(struct hash_desc *desc);
68772 @@ -394,13 +394,13 @@ struct compress_tfm {
68773 int (*cot_decompress)(struct crypto_tfm *tfm,
68774 const u8 *src, unsigned int slen,
68775 u8 *dst, unsigned int *dlen);
68776 -};
68777 +} __no_const;
68778
68779 struct rng_tfm {
68780 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68781 unsigned int dlen);
68782 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68783 -};
68784 +} __no_const;
68785
68786 #define crt_ablkcipher crt_u.ablkcipher
68787 #define crt_aead crt_u.aead
68788 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68789 index 8acfe31..6ffccd63 100644
68790 --- a/include/linux/ctype.h
68791 +++ b/include/linux/ctype.h
68792 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68793 * Fast implementation of tolower() for internal usage. Do not use in your
68794 * code.
68795 */
68796 -static inline char _tolower(const char c)
68797 +static inline unsigned char _tolower(const unsigned char c)
68798 {
68799 return c | 0x20;
68800 }
68801 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68802 index 7925bf0..d5143d2 100644
68803 --- a/include/linux/decompress/mm.h
68804 +++ b/include/linux/decompress/mm.h
68805 @@ -77,7 +77,7 @@ static void free(void *where)
68806 * warnings when not needed (indeed large_malloc / large_free are not
68807 * needed by inflate */
68808
68809 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68810 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68811 #define free(a) kfree(a)
68812
68813 #define large_malloc(a) vmalloc(a)
68814 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68815 index e83ef39..33e0eb3 100644
68816 --- a/include/linux/devfreq.h
68817 +++ b/include/linux/devfreq.h
68818 @@ -114,7 +114,7 @@ struct devfreq_governor {
68819 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68820 int (*event_handler)(struct devfreq *devfreq,
68821 unsigned int event, void *data);
68822 -};
68823 +} __do_const;
68824
68825 /**
68826 * struct devfreq - Device devfreq structure
68827 diff --git a/include/linux/device.h b/include/linux/device.h
68828 index 43dcda9..7a1fb65 100644
68829 --- a/include/linux/device.h
68830 +++ b/include/linux/device.h
68831 @@ -294,7 +294,7 @@ struct subsys_interface {
68832 struct list_head node;
68833 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68834 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68835 -};
68836 +} __do_const;
68837
68838 int subsys_interface_register(struct subsys_interface *sif);
68839 void subsys_interface_unregister(struct subsys_interface *sif);
68840 @@ -474,7 +474,7 @@ struct device_type {
68841 void (*release)(struct device *dev);
68842
68843 const struct dev_pm_ops *pm;
68844 -};
68845 +} __do_const;
68846
68847 /* interface for exporting device attributes */
68848 struct device_attribute {
68849 @@ -484,11 +484,12 @@ struct device_attribute {
68850 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68851 const char *buf, size_t count);
68852 };
68853 +typedef struct device_attribute __no_const device_attribute_no_const;
68854
68855 struct dev_ext_attribute {
68856 struct device_attribute attr;
68857 void *var;
68858 -};
68859 +} __do_const;
68860
68861 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68862 char *buf);
68863 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68864 index 94af418..b1ca7a2 100644
68865 --- a/include/linux/dma-mapping.h
68866 +++ b/include/linux/dma-mapping.h
68867 @@ -54,7 +54,7 @@ struct dma_map_ops {
68868 u64 (*get_required_mask)(struct device *dev);
68869 #endif
68870 int is_phys;
68871 -};
68872 +} __do_const;
68873
68874 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68875
68876 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68877 index d3201e4..8281e63 100644
68878 --- a/include/linux/dmaengine.h
68879 +++ b/include/linux/dmaengine.h
68880 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
68881 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68882 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68883
68884 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68885 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68886 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68887 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68888 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68889 struct dma_pinned_list *pinned_list, struct page *page,
68890 unsigned int offset, size_t len);
68891
68892 diff --git a/include/linux/efi.h b/include/linux/efi.h
68893 index 7a9498a..155713d 100644
68894 --- a/include/linux/efi.h
68895 +++ b/include/linux/efi.h
68896 @@ -733,6 +733,7 @@ struct efivar_operations {
68897 efi_set_variable_t *set_variable;
68898 efi_query_variable_info_t *query_variable_info;
68899 };
68900 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68901
68902 struct efivars {
68903 /*
68904 diff --git a/include/linux/elf.h b/include/linux/elf.h
68905 index 8c9048e..16a4665 100644
68906 --- a/include/linux/elf.h
68907 +++ b/include/linux/elf.h
68908 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
68909 #define elf_note elf32_note
68910 #define elf_addr_t Elf32_Off
68911 #define Elf_Half Elf32_Half
68912 +#define elf_dyn Elf32_Dyn
68913
68914 #else
68915
68916 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
68917 #define elf_note elf64_note
68918 #define elf_addr_t Elf64_Off
68919 #define Elf_Half Elf64_Half
68920 +#define elf_dyn Elf64_Dyn
68921
68922 #endif
68923
68924 diff --git a/include/linux/err.h b/include/linux/err.h
68925 index f2edce2..cc2082c 100644
68926 --- a/include/linux/err.h
68927 +++ b/include/linux/err.h
68928 @@ -19,12 +19,12 @@
68929
68930 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68931
68932 -static inline void * __must_check ERR_PTR(long error)
68933 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68934 {
68935 return (void *) error;
68936 }
68937
68938 -static inline long __must_check PTR_ERR(const void *ptr)
68939 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68940 {
68941 return (long) ptr;
68942 }
68943 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68944 index fcb51c8..bdafcf6 100644
68945 --- a/include/linux/extcon.h
68946 +++ b/include/linux/extcon.h
68947 @@ -134,7 +134,7 @@ struct extcon_dev {
68948 /* /sys/class/extcon/.../mutually_exclusive/... */
68949 struct attribute_group attr_g_muex;
68950 struct attribute **attrs_muex;
68951 - struct device_attribute *d_attrs_muex;
68952 + device_attribute_no_const *d_attrs_muex;
68953 };
68954
68955 /**
68956 diff --git a/include/linux/fb.h b/include/linux/fb.h
68957 index c7a9571..02eeffe 100644
68958 --- a/include/linux/fb.h
68959 +++ b/include/linux/fb.h
68960 @@ -302,7 +302,7 @@ struct fb_ops {
68961 /* called at KDB enter and leave time to prepare the console */
68962 int (*fb_debug_enter)(struct fb_info *info);
68963 int (*fb_debug_leave)(struct fb_info *info);
68964 -};
68965 +} __do_const;
68966
68967 #ifdef CONFIG_FB_TILEBLITTING
68968 #define FB_TILE_CURSOR_NONE 0
68969 diff --git a/include/linux/filter.h b/include/linux/filter.h
68970 index c45eabc..baa0be5 100644
68971 --- a/include/linux/filter.h
68972 +++ b/include/linux/filter.h
68973 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68974
68975 struct sk_buff;
68976 struct sock;
68977 +struct bpf_jit_work;
68978
68979 struct sk_filter
68980 {
68981 @@ -27,6 +28,9 @@ struct sk_filter
68982 unsigned int len; /* Number of filter blocks */
68983 unsigned int (*bpf_func)(const struct sk_buff *skb,
68984 const struct sock_filter *filter);
68985 +#ifdef CONFIG_BPF_JIT
68986 + struct bpf_jit_work *work;
68987 +#endif
68988 struct rcu_head rcu;
68989 struct sock_filter insns[0];
68990 };
68991 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68992 index 3044254..9767f41 100644
68993 --- a/include/linux/frontswap.h
68994 +++ b/include/linux/frontswap.h
68995 @@ -11,7 +11,7 @@ struct frontswap_ops {
68996 int (*load)(unsigned, pgoff_t, struct page *);
68997 void (*invalidate_page)(unsigned, pgoff_t);
68998 void (*invalidate_area)(unsigned);
68999 -};
69000 +} __no_const;
69001
69002 extern bool frontswap_enabled;
69003 extern struct frontswap_ops
69004 diff --git a/include/linux/fs.h b/include/linux/fs.h
69005 index 7617ee0..b575199 100644
69006 --- a/include/linux/fs.h
69007 +++ b/include/linux/fs.h
69008 @@ -1541,7 +1541,8 @@ struct file_operations {
69009 long (*fallocate)(struct file *file, int mode, loff_t offset,
69010 loff_t len);
69011 int (*show_fdinfo)(struct seq_file *m, struct file *f);
69012 -};
69013 +} __do_const;
69014 +typedef struct file_operations __no_const file_operations_no_const;
69015
69016 struct inode_operations {
69017 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
69018 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
69019 inode->i_flags |= S_NOSEC;
69020 }
69021
69022 +static inline bool is_sidechannel_device(const struct inode *inode)
69023 +{
69024 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
69025 + umode_t mode = inode->i_mode;
69026 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
69027 +#else
69028 + return false;
69029 +#endif
69030 +}
69031 +
69032 #endif /* _LINUX_FS_H */
69033 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
69034 index 324f931..f292b65 100644
69035 --- a/include/linux/fs_struct.h
69036 +++ b/include/linux/fs_struct.h
69037 @@ -6,7 +6,7 @@
69038 #include <linux/seqlock.h>
69039
69040 struct fs_struct {
69041 - int users;
69042 + atomic_t users;
69043 spinlock_t lock;
69044 seqcount_t seq;
69045 int umask;
69046 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
69047 index 5dfa0aa..6acf322 100644
69048 --- a/include/linux/fscache-cache.h
69049 +++ b/include/linux/fscache-cache.h
69050 @@ -112,7 +112,7 @@ struct fscache_operation {
69051 fscache_operation_release_t release;
69052 };
69053
69054 -extern atomic_t fscache_op_debug_id;
69055 +extern atomic_unchecked_t fscache_op_debug_id;
69056 extern void fscache_op_work_func(struct work_struct *work);
69057
69058 extern void fscache_enqueue_operation(struct fscache_operation *);
69059 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
69060 INIT_WORK(&op->work, fscache_op_work_func);
69061 atomic_set(&op->usage, 1);
69062 op->state = FSCACHE_OP_ST_INITIALISED;
69063 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
69064 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
69065 op->processor = processor;
69066 op->release = release;
69067 INIT_LIST_HEAD(&op->pend_link);
69068 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
69069 index 7a08623..4c07b0f 100644
69070 --- a/include/linux/fscache.h
69071 +++ b/include/linux/fscache.h
69072 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
69073 * - this is mandatory for any object that may have data
69074 */
69075 void (*now_uncached)(void *cookie_netfs_data);
69076 -};
69077 +} __do_const;
69078
69079 /*
69080 * fscache cached network filesystem type
69081 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
69082 index 0fbfb46..508eb0d 100644
69083 --- a/include/linux/fsnotify.h
69084 +++ b/include/linux/fsnotify.h
69085 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
69086 struct inode *inode = path->dentry->d_inode;
69087 __u32 mask = FS_ACCESS;
69088
69089 + if (is_sidechannel_device(inode))
69090 + return;
69091 +
69092 if (S_ISDIR(inode->i_mode))
69093 mask |= FS_ISDIR;
69094
69095 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
69096 struct inode *inode = path->dentry->d_inode;
69097 __u32 mask = FS_MODIFY;
69098
69099 + if (is_sidechannel_device(inode))
69100 + return;
69101 +
69102 if (S_ISDIR(inode->i_mode))
69103 mask |= FS_ISDIR;
69104
69105 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
69106 */
69107 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
69108 {
69109 - return kstrdup(name, GFP_KERNEL);
69110 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
69111 }
69112
69113 /*
69114 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
69115 index a3d4895..ddd2a50 100644
69116 --- a/include/linux/ftrace_event.h
69117 +++ b/include/linux/ftrace_event.h
69118 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
69119 extern int trace_add_event_call(struct ftrace_event_call *call);
69120 extern void trace_remove_event_call(struct ftrace_event_call *call);
69121
69122 -#define is_signed_type(type) (((type)(-1)) < 0)
69123 +#define is_signed_type(type) (((type)(-1)) < (type)1)
69124
69125 int trace_set_clr_event(const char *system, const char *event, int set);
69126
69127 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
69128 index 79b8bba..86b539e 100644
69129 --- a/include/linux/genhd.h
69130 +++ b/include/linux/genhd.h
69131 @@ -194,7 +194,7 @@ struct gendisk {
69132 struct kobject *slave_dir;
69133
69134 struct timer_rand_state *random;
69135 - atomic_t sync_io; /* RAID */
69136 + atomic_unchecked_t sync_io; /* RAID */
69137 struct disk_events *ev;
69138 #ifdef CONFIG_BLK_DEV_INTEGRITY
69139 struct blk_integrity *integrity;
69140 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
69141 index 023bc34..b02b46a 100644
69142 --- a/include/linux/genl_magic_func.h
69143 +++ b/include/linux/genl_magic_func.h
69144 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
69145 },
69146
69147 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
69148 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
69149 +static struct genl_ops ZZZ_genl_ops[] = {
69150 #include GENL_MAGIC_INCLUDE_FILE
69151 };
69152
69153 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
69154 index 0f615eb..5c3832f 100644
69155 --- a/include/linux/gfp.h
69156 +++ b/include/linux/gfp.h
69157 @@ -35,6 +35,13 @@ struct vm_area_struct;
69158 #define ___GFP_NO_KSWAPD 0x400000u
69159 #define ___GFP_OTHER_NODE 0x800000u
69160 #define ___GFP_WRITE 0x1000000u
69161 +
69162 +#ifdef CONFIG_PAX_USERCOPY_SLABS
69163 +#define ___GFP_USERCOPY 0x2000000u
69164 +#else
69165 +#define ___GFP_USERCOPY 0
69166 +#endif
69167 +
69168 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
69169
69170 /*
69171 @@ -92,6 +99,7 @@ struct vm_area_struct;
69172 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
69173 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
69174 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
69175 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
69176
69177 /*
69178 * This may seem redundant, but it's a way of annotating false positives vs.
69179 @@ -99,7 +107,7 @@ struct vm_area_struct;
69180 */
69181 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
69182
69183 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
69184 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
69185 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
69186
69187 /* This equals 0, but use constants in case they ever change */
69188 @@ -153,6 +161,8 @@ struct vm_area_struct;
69189 /* 4GB DMA on some platforms */
69190 #define GFP_DMA32 __GFP_DMA32
69191
69192 +#define GFP_USERCOPY __GFP_USERCOPY
69193 +
69194 /* Convert GFP flags to their corresponding migrate type */
69195 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
69196 {
69197 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
69198 new file mode 100644
69199 index 0000000..ebe6d72
69200 --- /dev/null
69201 +++ b/include/linux/gracl.h
69202 @@ -0,0 +1,319 @@
69203 +#ifndef GR_ACL_H
69204 +#define GR_ACL_H
69205 +
69206 +#include <linux/grdefs.h>
69207 +#include <linux/resource.h>
69208 +#include <linux/capability.h>
69209 +#include <linux/dcache.h>
69210 +#include <asm/resource.h>
69211 +
69212 +/* Major status information */
69213 +
69214 +#define GR_VERSION "grsecurity 2.9.1"
69215 +#define GRSECURITY_VERSION 0x2901
69216 +
69217 +enum {
69218 + GR_SHUTDOWN = 0,
69219 + GR_ENABLE = 1,
69220 + GR_SPROLE = 2,
69221 + GR_RELOAD = 3,
69222 + GR_SEGVMOD = 4,
69223 + GR_STATUS = 5,
69224 + GR_UNSPROLE = 6,
69225 + GR_PASSSET = 7,
69226 + GR_SPROLEPAM = 8,
69227 +};
69228 +
69229 +/* Password setup definitions
69230 + * kernel/grhash.c */
69231 +enum {
69232 + GR_PW_LEN = 128,
69233 + GR_SALT_LEN = 16,
69234 + GR_SHA_LEN = 32,
69235 +};
69236 +
69237 +enum {
69238 + GR_SPROLE_LEN = 64,
69239 +};
69240 +
69241 +enum {
69242 + GR_NO_GLOB = 0,
69243 + GR_REG_GLOB,
69244 + GR_CREATE_GLOB
69245 +};
69246 +
69247 +#define GR_NLIMITS 32
69248 +
69249 +/* Begin Data Structures */
69250 +
69251 +struct sprole_pw {
69252 + unsigned char *rolename;
69253 + unsigned char salt[GR_SALT_LEN];
69254 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
69255 +};
69256 +
69257 +struct name_entry {
69258 + __u32 key;
69259 + ino_t inode;
69260 + dev_t device;
69261 + char *name;
69262 + __u16 len;
69263 + __u8 deleted;
69264 + struct name_entry *prev;
69265 + struct name_entry *next;
69266 +};
69267 +
69268 +struct inodev_entry {
69269 + struct name_entry *nentry;
69270 + struct inodev_entry *prev;
69271 + struct inodev_entry *next;
69272 +};
69273 +
69274 +struct acl_role_db {
69275 + struct acl_role_label **r_hash;
69276 + __u32 r_size;
69277 +};
69278 +
69279 +struct inodev_db {
69280 + struct inodev_entry **i_hash;
69281 + __u32 i_size;
69282 +};
69283 +
69284 +struct name_db {
69285 + struct name_entry **n_hash;
69286 + __u32 n_size;
69287 +};
69288 +
69289 +struct crash_uid {
69290 + uid_t uid;
69291 + unsigned long expires;
69292 +};
69293 +
69294 +struct gr_hash_struct {
69295 + void **table;
69296 + void **nametable;
69297 + void *first;
69298 + __u32 table_size;
69299 + __u32 used_size;
69300 + int type;
69301 +};
69302 +
69303 +/* Userspace Grsecurity ACL data structures */
69304 +
69305 +struct acl_subject_label {
69306 + char *filename;
69307 + ino_t inode;
69308 + dev_t device;
69309 + __u32 mode;
69310 + kernel_cap_t cap_mask;
69311 + kernel_cap_t cap_lower;
69312 + kernel_cap_t cap_invert_audit;
69313 +
69314 + struct rlimit res[GR_NLIMITS];
69315 + __u32 resmask;
69316 +
69317 + __u8 user_trans_type;
69318 + __u8 group_trans_type;
69319 + uid_t *user_transitions;
69320 + gid_t *group_transitions;
69321 + __u16 user_trans_num;
69322 + __u16 group_trans_num;
69323 +
69324 + __u32 sock_families[2];
69325 + __u32 ip_proto[8];
69326 + __u32 ip_type;
69327 + struct acl_ip_label **ips;
69328 + __u32 ip_num;
69329 + __u32 inaddr_any_override;
69330 +
69331 + __u32 crashes;
69332 + unsigned long expires;
69333 +
69334 + struct acl_subject_label *parent_subject;
69335 + struct gr_hash_struct *hash;
69336 + struct acl_subject_label *prev;
69337 + struct acl_subject_label *next;
69338 +
69339 + struct acl_object_label **obj_hash;
69340 + __u32 obj_hash_size;
69341 + __u16 pax_flags;
69342 +};
69343 +
69344 +struct role_allowed_ip {
69345 + __u32 addr;
69346 + __u32 netmask;
69347 +
69348 + struct role_allowed_ip *prev;
69349 + struct role_allowed_ip *next;
69350 +};
69351 +
69352 +struct role_transition {
69353 + char *rolename;
69354 +
69355 + struct role_transition *prev;
69356 + struct role_transition *next;
69357 +};
69358 +
69359 +struct acl_role_label {
69360 + char *rolename;
69361 + uid_t uidgid;
69362 + __u16 roletype;
69363 +
69364 + __u16 auth_attempts;
69365 + unsigned long expires;
69366 +
69367 + struct acl_subject_label *root_label;
69368 + struct gr_hash_struct *hash;
69369 +
69370 + struct acl_role_label *prev;
69371 + struct acl_role_label *next;
69372 +
69373 + struct role_transition *transitions;
69374 + struct role_allowed_ip *allowed_ips;
69375 + uid_t *domain_children;
69376 + __u16 domain_child_num;
69377 +
69378 + umode_t umask;
69379 +
69380 + struct acl_subject_label **subj_hash;
69381 + __u32 subj_hash_size;
69382 +};
69383 +
69384 +struct user_acl_role_db {
69385 + struct acl_role_label **r_table;
69386 + __u32 num_pointers; /* Number of allocations to track */
69387 + __u32 num_roles; /* Number of roles */
69388 + __u32 num_domain_children; /* Number of domain children */
69389 + __u32 num_subjects; /* Number of subjects */
69390 + __u32 num_objects; /* Number of objects */
69391 +};
69392 +
69393 +struct acl_object_label {
69394 + char *filename;
69395 + ino_t inode;
69396 + dev_t device;
69397 + __u32 mode;
69398 +
69399 + struct acl_subject_label *nested;
69400 + struct acl_object_label *globbed;
69401 +
69402 + /* next two structures not used */
69403 +
69404 + struct acl_object_label *prev;
69405 + struct acl_object_label *next;
69406 +};
69407 +
69408 +struct acl_ip_label {
69409 + char *iface;
69410 + __u32 addr;
69411 + __u32 netmask;
69412 + __u16 low, high;
69413 + __u8 mode;
69414 + __u32 type;
69415 + __u32 proto[8];
69416 +
69417 + /* next two structures not used */
69418 +
69419 + struct acl_ip_label *prev;
69420 + struct acl_ip_label *next;
69421 +};
69422 +
69423 +struct gr_arg {
69424 + struct user_acl_role_db role_db;
69425 + unsigned char pw[GR_PW_LEN];
69426 + unsigned char salt[GR_SALT_LEN];
69427 + unsigned char sum[GR_SHA_LEN];
69428 + unsigned char sp_role[GR_SPROLE_LEN];
69429 + struct sprole_pw *sprole_pws;
69430 + dev_t segv_device;
69431 + ino_t segv_inode;
69432 + uid_t segv_uid;
69433 + __u16 num_sprole_pws;
69434 + __u16 mode;
69435 +};
69436 +
69437 +struct gr_arg_wrapper {
69438 + struct gr_arg *arg;
69439 + __u32 version;
69440 + __u32 size;
69441 +};
69442 +
69443 +struct subject_map {
69444 + struct acl_subject_label *user;
69445 + struct acl_subject_label *kernel;
69446 + struct subject_map *prev;
69447 + struct subject_map *next;
69448 +};
69449 +
69450 +struct acl_subj_map_db {
69451 + struct subject_map **s_hash;
69452 + __u32 s_size;
69453 +};
69454 +
69455 +/* End Data Structures Section */
69456 +
69457 +/* Hash functions generated by empirical testing by Brad Spengler
69458 + Makes good use of the low bits of the inode. Generally 0-1 times
69459 + in loop for successful match. 0-3 for unsuccessful match.
69460 + Shift/add algorithm with modulus of table size and an XOR*/
69461 +
69462 +static __inline__ unsigned int
69463 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
69464 +{
69465 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
69466 +}
69467 +
69468 + static __inline__ unsigned int
69469 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
69470 +{
69471 + return ((const unsigned long)userp % sz);
69472 +}
69473 +
69474 +static __inline__ unsigned int
69475 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
69476 +{
69477 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
69478 +}
69479 +
69480 +static __inline__ unsigned int
69481 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
69482 +{
69483 + return full_name_hash((const unsigned char *)name, len) % sz;
69484 +}
69485 +
69486 +#define FOR_EACH_ROLE_START(role) \
69487 + role = role_list; \
69488 + while (role) {
69489 +
69490 +#define FOR_EACH_ROLE_END(role) \
69491 + role = role->prev; \
69492 + }
69493 +
69494 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
69495 + subj = NULL; \
69496 + iter = 0; \
69497 + while (iter < role->subj_hash_size) { \
69498 + if (subj == NULL) \
69499 + subj = role->subj_hash[iter]; \
69500 + if (subj == NULL) { \
69501 + iter++; \
69502 + continue; \
69503 + }
69504 +
69505 +#define FOR_EACH_SUBJECT_END(subj,iter) \
69506 + subj = subj->next; \
69507 + if (subj == NULL) \
69508 + iter++; \
69509 + }
69510 +
69511 +
69512 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
69513 + subj = role->hash->first; \
69514 + while (subj != NULL) {
69515 +
69516 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
69517 + subj = subj->next; \
69518 + }
69519 +
69520 +#endif
69521 +
69522 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
69523 new file mode 100644
69524 index 0000000..323ecf2
69525 --- /dev/null
69526 +++ b/include/linux/gralloc.h
69527 @@ -0,0 +1,9 @@
69528 +#ifndef __GRALLOC_H
69529 +#define __GRALLOC_H
69530 +
69531 +void acl_free_all(void);
69532 +int acl_alloc_stack_init(unsigned long size);
69533 +void *acl_alloc(unsigned long len);
69534 +void *acl_alloc_num(unsigned long num, unsigned long len);
69535 +
69536 +#endif
69537 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
69538 new file mode 100644
69539 index 0000000..be66033
69540 --- /dev/null
69541 +++ b/include/linux/grdefs.h
69542 @@ -0,0 +1,140 @@
69543 +#ifndef GRDEFS_H
69544 +#define GRDEFS_H
69545 +
69546 +/* Begin grsecurity status declarations */
69547 +
69548 +enum {
69549 + GR_READY = 0x01,
69550 + GR_STATUS_INIT = 0x00 // disabled state
69551 +};
69552 +
69553 +/* Begin ACL declarations */
69554 +
69555 +/* Role flags */
69556 +
69557 +enum {
69558 + GR_ROLE_USER = 0x0001,
69559 + GR_ROLE_GROUP = 0x0002,
69560 + GR_ROLE_DEFAULT = 0x0004,
69561 + GR_ROLE_SPECIAL = 0x0008,
69562 + GR_ROLE_AUTH = 0x0010,
69563 + GR_ROLE_NOPW = 0x0020,
69564 + GR_ROLE_GOD = 0x0040,
69565 + GR_ROLE_LEARN = 0x0080,
69566 + GR_ROLE_TPE = 0x0100,
69567 + GR_ROLE_DOMAIN = 0x0200,
69568 + GR_ROLE_PAM = 0x0400,
69569 + GR_ROLE_PERSIST = 0x0800
69570 +};
69571 +
69572 +/* ACL Subject and Object mode flags */
69573 +enum {
69574 + GR_DELETED = 0x80000000
69575 +};
69576 +
69577 +/* ACL Object-only mode flags */
69578 +enum {
69579 + GR_READ = 0x00000001,
69580 + GR_APPEND = 0x00000002,
69581 + GR_WRITE = 0x00000004,
69582 + GR_EXEC = 0x00000008,
69583 + GR_FIND = 0x00000010,
69584 + GR_INHERIT = 0x00000020,
69585 + GR_SETID = 0x00000040,
69586 + GR_CREATE = 0x00000080,
69587 + GR_DELETE = 0x00000100,
69588 + GR_LINK = 0x00000200,
69589 + GR_AUDIT_READ = 0x00000400,
69590 + GR_AUDIT_APPEND = 0x00000800,
69591 + GR_AUDIT_WRITE = 0x00001000,
69592 + GR_AUDIT_EXEC = 0x00002000,
69593 + GR_AUDIT_FIND = 0x00004000,
69594 + GR_AUDIT_INHERIT= 0x00008000,
69595 + GR_AUDIT_SETID = 0x00010000,
69596 + GR_AUDIT_CREATE = 0x00020000,
69597 + GR_AUDIT_DELETE = 0x00040000,
69598 + GR_AUDIT_LINK = 0x00080000,
69599 + GR_PTRACERD = 0x00100000,
69600 + GR_NOPTRACE = 0x00200000,
69601 + GR_SUPPRESS = 0x00400000,
69602 + GR_NOLEARN = 0x00800000,
69603 + GR_INIT_TRANSFER= 0x01000000
69604 +};
69605 +
69606 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69607 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69608 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69609 +
69610 +/* ACL subject-only mode flags */
69611 +enum {
69612 + GR_KILL = 0x00000001,
69613 + GR_VIEW = 0x00000002,
69614 + GR_PROTECTED = 0x00000004,
69615 + GR_LEARN = 0x00000008,
69616 + GR_OVERRIDE = 0x00000010,
69617 + /* just a placeholder, this mode is only used in userspace */
69618 + GR_DUMMY = 0x00000020,
69619 + GR_PROTSHM = 0x00000040,
69620 + GR_KILLPROC = 0x00000080,
69621 + GR_KILLIPPROC = 0x00000100,
69622 + /* just a placeholder, this mode is only used in userspace */
69623 + GR_NOTROJAN = 0x00000200,
69624 + GR_PROTPROCFD = 0x00000400,
69625 + GR_PROCACCT = 0x00000800,
69626 + GR_RELAXPTRACE = 0x00001000,
69627 + //GR_NESTED = 0x00002000,
69628 + GR_INHERITLEARN = 0x00004000,
69629 + GR_PROCFIND = 0x00008000,
69630 + GR_POVERRIDE = 0x00010000,
69631 + GR_KERNELAUTH = 0x00020000,
69632 + GR_ATSECURE = 0x00040000,
69633 + GR_SHMEXEC = 0x00080000
69634 +};
69635 +
69636 +enum {
69637 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69638 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69639 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69640 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69641 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69642 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69643 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69644 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69645 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69646 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69647 +};
69648 +
69649 +enum {
69650 + GR_ID_USER = 0x01,
69651 + GR_ID_GROUP = 0x02,
69652 +};
69653 +
69654 +enum {
69655 + GR_ID_ALLOW = 0x01,
69656 + GR_ID_DENY = 0x02,
69657 +};
69658 +
69659 +#define GR_CRASH_RES 31
69660 +#define GR_UIDTABLE_MAX 500
69661 +
69662 +/* begin resource learning section */
69663 +enum {
69664 + GR_RLIM_CPU_BUMP = 60,
69665 + GR_RLIM_FSIZE_BUMP = 50000,
69666 + GR_RLIM_DATA_BUMP = 10000,
69667 + GR_RLIM_STACK_BUMP = 1000,
69668 + GR_RLIM_CORE_BUMP = 10000,
69669 + GR_RLIM_RSS_BUMP = 500000,
69670 + GR_RLIM_NPROC_BUMP = 1,
69671 + GR_RLIM_NOFILE_BUMP = 5,
69672 + GR_RLIM_MEMLOCK_BUMP = 50000,
69673 + GR_RLIM_AS_BUMP = 500000,
69674 + GR_RLIM_LOCKS_BUMP = 2,
69675 + GR_RLIM_SIGPENDING_BUMP = 5,
69676 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69677 + GR_RLIM_NICE_BUMP = 1,
69678 + GR_RLIM_RTPRIO_BUMP = 1,
69679 + GR_RLIM_RTTIME_BUMP = 1000000
69680 +};
69681 +
69682 +#endif
69683 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69684 new file mode 100644
69685 index 0000000..9bb6662
69686 --- /dev/null
69687 +++ b/include/linux/grinternal.h
69688 @@ -0,0 +1,215 @@
69689 +#ifndef __GRINTERNAL_H
69690 +#define __GRINTERNAL_H
69691 +
69692 +#ifdef CONFIG_GRKERNSEC
69693 +
69694 +#include <linux/fs.h>
69695 +#include <linux/mnt_namespace.h>
69696 +#include <linux/nsproxy.h>
69697 +#include <linux/gracl.h>
69698 +#include <linux/grdefs.h>
69699 +#include <linux/grmsg.h>
69700 +
69701 +void gr_add_learn_entry(const char *fmt, ...)
69702 + __attribute__ ((format (printf, 1, 2)));
69703 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69704 + const struct vfsmount *mnt);
69705 +__u32 gr_check_create(const struct dentry *new_dentry,
69706 + const struct dentry *parent,
69707 + const struct vfsmount *mnt, const __u32 mode);
69708 +int gr_check_protected_task(const struct task_struct *task);
69709 +__u32 to_gr_audit(const __u32 reqmode);
69710 +int gr_set_acls(const int type);
69711 +int gr_apply_subject_to_task(struct task_struct *task);
69712 +int gr_acl_is_enabled(void);
69713 +char gr_roletype_to_char(void);
69714 +
69715 +void gr_handle_alertkill(struct task_struct *task);
69716 +char *gr_to_filename(const struct dentry *dentry,
69717 + const struct vfsmount *mnt);
69718 +char *gr_to_filename1(const struct dentry *dentry,
69719 + const struct vfsmount *mnt);
69720 +char *gr_to_filename2(const struct dentry *dentry,
69721 + const struct vfsmount *mnt);
69722 +char *gr_to_filename3(const struct dentry *dentry,
69723 + const struct vfsmount *mnt);
69724 +
69725 +extern int grsec_enable_ptrace_readexec;
69726 +extern int grsec_enable_harden_ptrace;
69727 +extern int grsec_enable_link;
69728 +extern int grsec_enable_fifo;
69729 +extern int grsec_enable_execve;
69730 +extern int grsec_enable_shm;
69731 +extern int grsec_enable_execlog;
69732 +extern int grsec_enable_signal;
69733 +extern int grsec_enable_audit_ptrace;
69734 +extern int grsec_enable_forkfail;
69735 +extern int grsec_enable_time;
69736 +extern int grsec_enable_rofs;
69737 +extern int grsec_enable_chroot_shmat;
69738 +extern int grsec_enable_chroot_mount;
69739 +extern int grsec_enable_chroot_double;
69740 +extern int grsec_enable_chroot_pivot;
69741 +extern int grsec_enable_chroot_chdir;
69742 +extern int grsec_enable_chroot_chmod;
69743 +extern int grsec_enable_chroot_mknod;
69744 +extern int grsec_enable_chroot_fchdir;
69745 +extern int grsec_enable_chroot_nice;
69746 +extern int grsec_enable_chroot_execlog;
69747 +extern int grsec_enable_chroot_caps;
69748 +extern int grsec_enable_chroot_sysctl;
69749 +extern int grsec_enable_chroot_unix;
69750 +extern int grsec_enable_symlinkown;
69751 +extern kgid_t grsec_symlinkown_gid;
69752 +extern int grsec_enable_tpe;
69753 +extern kgid_t grsec_tpe_gid;
69754 +extern int grsec_enable_tpe_all;
69755 +extern int grsec_enable_tpe_invert;
69756 +extern int grsec_enable_socket_all;
69757 +extern kgid_t grsec_socket_all_gid;
69758 +extern int grsec_enable_socket_client;
69759 +extern kgid_t grsec_socket_client_gid;
69760 +extern int grsec_enable_socket_server;
69761 +extern kgid_t grsec_socket_server_gid;
69762 +extern kgid_t grsec_audit_gid;
69763 +extern int grsec_enable_group;
69764 +extern int grsec_enable_audit_textrel;
69765 +extern int grsec_enable_log_rwxmaps;
69766 +extern int grsec_enable_mount;
69767 +extern int grsec_enable_chdir;
69768 +extern int grsec_resource_logging;
69769 +extern int grsec_enable_blackhole;
69770 +extern int grsec_lastack_retries;
69771 +extern int grsec_enable_brute;
69772 +extern int grsec_lock;
69773 +
69774 +extern spinlock_t grsec_alert_lock;
69775 +extern unsigned long grsec_alert_wtime;
69776 +extern unsigned long grsec_alert_fyet;
69777 +
69778 +extern spinlock_t grsec_audit_lock;
69779 +
69780 +extern rwlock_t grsec_exec_file_lock;
69781 +
69782 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69783 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69784 + (tsk)->exec_file->f_vfsmnt) : "/")
69785 +
69786 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69787 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69788 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69789 +
69790 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69791 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69792 + (tsk)->exec_file->f_vfsmnt) : "/")
69793 +
69794 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69795 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69796 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69797 +
69798 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69799 +
69800 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69801 +
69802 +#define GR_CHROOT_CAPS {{ \
69803 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69804 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69805 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69806 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69807 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69808 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69809 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69810 +
69811 +#define security_learn(normal_msg,args...) \
69812 +({ \
69813 + read_lock(&grsec_exec_file_lock); \
69814 + gr_add_learn_entry(normal_msg "\n", ## args); \
69815 + read_unlock(&grsec_exec_file_lock); \
69816 +})
69817 +
69818 +enum {
69819 + GR_DO_AUDIT,
69820 + GR_DONT_AUDIT,
69821 + /* used for non-audit messages that we shouldn't kill the task on */
69822 + GR_DONT_AUDIT_GOOD
69823 +};
69824 +
69825 +enum {
69826 + GR_TTYSNIFF,
69827 + GR_RBAC,
69828 + GR_RBAC_STR,
69829 + GR_STR_RBAC,
69830 + GR_RBAC_MODE2,
69831 + GR_RBAC_MODE3,
69832 + GR_FILENAME,
69833 + GR_SYSCTL_HIDDEN,
69834 + GR_NOARGS,
69835 + GR_ONE_INT,
69836 + GR_ONE_INT_TWO_STR,
69837 + GR_ONE_STR,
69838 + GR_STR_INT,
69839 + GR_TWO_STR_INT,
69840 + GR_TWO_INT,
69841 + GR_TWO_U64,
69842 + GR_THREE_INT,
69843 + GR_FIVE_INT_TWO_STR,
69844 + GR_TWO_STR,
69845 + GR_THREE_STR,
69846 + GR_FOUR_STR,
69847 + GR_STR_FILENAME,
69848 + GR_FILENAME_STR,
69849 + GR_FILENAME_TWO_INT,
69850 + GR_FILENAME_TWO_INT_STR,
69851 + GR_TEXTREL,
69852 + GR_PTRACE,
69853 + GR_RESOURCE,
69854 + GR_CAP,
69855 + GR_SIG,
69856 + GR_SIG2,
69857 + GR_CRASH1,
69858 + GR_CRASH2,
69859 + GR_PSACCT,
69860 + GR_RWXMAP
69861 +};
69862 +
69863 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69864 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69865 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69866 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69867 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69868 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69869 +#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)
69870 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69871 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69872 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69873 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69874 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69875 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69876 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69877 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69878 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69879 +#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)
69880 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69881 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69882 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69883 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69884 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69885 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69886 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69887 +#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)
69888 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69889 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69890 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69891 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69892 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69893 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69894 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69895 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69896 +#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)
69897 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69898 +
69899 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69900 +
69901 +#endif
69902 +
69903 +#endif
69904 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69905 new file mode 100644
69906 index 0000000..2bd4c8d
69907 --- /dev/null
69908 +++ b/include/linux/grmsg.h
69909 @@ -0,0 +1,111 @@
69910 +#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"
69911 +#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"
69912 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69913 +#define GR_STOPMOD_MSG "denied modification of module state by "
69914 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69915 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69916 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69917 +#define GR_IOPL_MSG "denied use of iopl() by "
69918 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69919 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69920 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69921 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69922 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69923 +#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"
69924 +#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"
69925 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69926 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69927 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69928 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69929 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69930 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69931 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69932 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69933 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69934 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69935 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69936 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69937 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69938 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69939 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69940 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69941 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69942 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69943 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69944 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69945 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69946 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69947 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69948 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69949 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69950 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69951 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69952 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69953 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69954 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69955 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69956 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69957 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69958 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69959 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69960 +#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"
69961 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69962 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69963 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69964 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69965 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69966 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69967 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69968 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69969 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69970 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69971 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69972 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69973 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69974 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69975 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69976 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69977 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69978 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69979 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69980 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69981 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69982 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69983 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69984 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69985 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69986 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69987 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69988 +#define GR_TIME_MSG "time set by "
69989 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69990 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69991 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69992 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69993 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69994 +#define GR_BIND_MSG "denied bind() by "
69995 +#define GR_CONNECT_MSG "denied connect() by "
69996 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69997 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69998 +#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"
69999 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
70000 +#define GR_CAP_ACL_MSG "use of %s denied for "
70001 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
70002 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
70003 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
70004 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
70005 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
70006 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
70007 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
70008 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
70009 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
70010 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
70011 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
70012 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
70013 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
70014 +#define GR_VM86_MSG "denied use of vm86 by "
70015 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
70016 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
70017 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
70018 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
70019 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
70020 +#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 "
70021 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
70022 new file mode 100644
70023 index 0000000..8da63a4
70024 --- /dev/null
70025 +++ b/include/linux/grsecurity.h
70026 @@ -0,0 +1,242 @@
70027 +#ifndef GR_SECURITY_H
70028 +#define GR_SECURITY_H
70029 +#include <linux/fs.h>
70030 +#include <linux/fs_struct.h>
70031 +#include <linux/binfmts.h>
70032 +#include <linux/gracl.h>
70033 +
70034 +/* notify of brain-dead configs */
70035 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70036 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
70037 +#endif
70038 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
70039 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
70040 +#endif
70041 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
70042 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
70043 +#endif
70044 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
70045 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
70046 +#endif
70047 +
70048 +void gr_handle_brute_attach(unsigned long mm_flags);
70049 +void gr_handle_brute_check(void);
70050 +void gr_handle_kernel_exploit(void);
70051 +int gr_process_user_ban(void);
70052 +
70053 +char gr_roletype_to_char(void);
70054 +
70055 +int gr_acl_enable_at_secure(void);
70056 +
70057 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
70058 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
70059 +
70060 +void gr_del_task_from_ip_table(struct task_struct *p);
70061 +
70062 +int gr_pid_is_chrooted(struct task_struct *p);
70063 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
70064 +int gr_handle_chroot_nice(void);
70065 +int gr_handle_chroot_sysctl(const int op);
70066 +int gr_handle_chroot_setpriority(struct task_struct *p,
70067 + const int niceval);
70068 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
70069 +int gr_handle_chroot_chroot(const struct dentry *dentry,
70070 + const struct vfsmount *mnt);
70071 +void gr_handle_chroot_chdir(struct path *path);
70072 +int gr_handle_chroot_chmod(const struct dentry *dentry,
70073 + const struct vfsmount *mnt, const int mode);
70074 +int gr_handle_chroot_mknod(const struct dentry *dentry,
70075 + const struct vfsmount *mnt, const int mode);
70076 +int gr_handle_chroot_mount(const struct dentry *dentry,
70077 + const struct vfsmount *mnt,
70078 + const char *dev_name);
70079 +int gr_handle_chroot_pivot(void);
70080 +int gr_handle_chroot_unix(const pid_t pid);
70081 +
70082 +int gr_handle_rawio(const struct inode *inode);
70083 +
70084 +void gr_handle_ioperm(void);
70085 +void gr_handle_iopl(void);
70086 +
70087 +umode_t gr_acl_umask(void);
70088 +
70089 +int gr_tpe_allow(const struct file *file);
70090 +
70091 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
70092 +void gr_clear_chroot_entries(struct task_struct *task);
70093 +
70094 +void gr_log_forkfail(const int retval);
70095 +void gr_log_timechange(void);
70096 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
70097 +void gr_log_chdir(const struct dentry *dentry,
70098 + const struct vfsmount *mnt);
70099 +void gr_log_chroot_exec(const struct dentry *dentry,
70100 + const struct vfsmount *mnt);
70101 +void gr_log_remount(const char *devname, const int retval);
70102 +void gr_log_unmount(const char *devname, const int retval);
70103 +void gr_log_mount(const char *from, const char *to, const int retval);
70104 +void gr_log_textrel(struct vm_area_struct *vma);
70105 +void gr_log_rwxmmap(struct file *file);
70106 +void gr_log_rwxmprotect(struct file *file);
70107 +
70108 +int gr_handle_follow_link(const struct inode *parent,
70109 + const struct inode *inode,
70110 + const struct dentry *dentry,
70111 + const struct vfsmount *mnt);
70112 +int gr_handle_fifo(const struct dentry *dentry,
70113 + const struct vfsmount *mnt,
70114 + const struct dentry *dir, const int flag,
70115 + const int acc_mode);
70116 +int gr_handle_hardlink(const struct dentry *dentry,
70117 + const struct vfsmount *mnt,
70118 + struct inode *inode,
70119 + const int mode, const struct filename *to);
70120 +
70121 +int gr_is_capable(const int cap);
70122 +int gr_is_capable_nolog(const int cap);
70123 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
70124 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
70125 +
70126 +void gr_copy_label(struct task_struct *tsk);
70127 +void gr_handle_crash(struct task_struct *task, const int sig);
70128 +int gr_handle_signal(const struct task_struct *p, const int sig);
70129 +int gr_check_crash_uid(const kuid_t uid);
70130 +int gr_check_protected_task(const struct task_struct *task);
70131 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
70132 +int gr_acl_handle_mmap(const struct file *file,
70133 + const unsigned long prot);
70134 +int gr_acl_handle_mprotect(const struct file *file,
70135 + const unsigned long prot);
70136 +int gr_check_hidden_task(const struct task_struct *tsk);
70137 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
70138 + const struct vfsmount *mnt);
70139 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
70140 + const struct vfsmount *mnt);
70141 +__u32 gr_acl_handle_access(const struct dentry *dentry,
70142 + const struct vfsmount *mnt, const int fmode);
70143 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
70144 + const struct vfsmount *mnt, umode_t *mode);
70145 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
70146 + const struct vfsmount *mnt);
70147 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
70148 + const struct vfsmount *mnt);
70149 +int gr_handle_ptrace(struct task_struct *task, const long request);
70150 +int gr_handle_proc_ptrace(struct task_struct *task);
70151 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
70152 + const struct vfsmount *mnt);
70153 +int gr_check_crash_exec(const struct file *filp);
70154 +int gr_acl_is_enabled(void);
70155 +void gr_set_kernel_label(struct task_struct *task);
70156 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
70157 + const kgid_t gid);
70158 +int gr_set_proc_label(const struct dentry *dentry,
70159 + const struct vfsmount *mnt,
70160 + const int unsafe_flags);
70161 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
70162 + const struct vfsmount *mnt);
70163 +__u32 gr_acl_handle_open(const struct dentry *dentry,
70164 + const struct vfsmount *mnt, int acc_mode);
70165 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
70166 + const struct dentry *p_dentry,
70167 + const struct vfsmount *p_mnt,
70168 + int open_flags, int acc_mode, const int imode);
70169 +void gr_handle_create(const struct dentry *dentry,
70170 + const struct vfsmount *mnt);
70171 +void gr_handle_proc_create(const struct dentry *dentry,
70172 + const struct inode *inode);
70173 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
70174 + const struct dentry *parent_dentry,
70175 + const struct vfsmount *parent_mnt,
70176 + const int mode);
70177 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
70178 + const struct dentry *parent_dentry,
70179 + const struct vfsmount *parent_mnt);
70180 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
70181 + const struct vfsmount *mnt);
70182 +void gr_handle_delete(const ino_t ino, const dev_t dev);
70183 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
70184 + const struct vfsmount *mnt);
70185 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
70186 + const struct dentry *parent_dentry,
70187 + const struct vfsmount *parent_mnt,
70188 + const struct filename *from);
70189 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
70190 + const struct dentry *parent_dentry,
70191 + const struct vfsmount *parent_mnt,
70192 + const struct dentry *old_dentry,
70193 + const struct vfsmount *old_mnt, const struct filename *to);
70194 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
70195 +int gr_acl_handle_rename(struct dentry *new_dentry,
70196 + struct dentry *parent_dentry,
70197 + const struct vfsmount *parent_mnt,
70198 + struct dentry *old_dentry,
70199 + struct inode *old_parent_inode,
70200 + struct vfsmount *old_mnt, const struct filename *newname);
70201 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
70202 + struct dentry *old_dentry,
70203 + struct dentry *new_dentry,
70204 + struct vfsmount *mnt, const __u8 replace);
70205 +__u32 gr_check_link(const struct dentry *new_dentry,
70206 + const struct dentry *parent_dentry,
70207 + const struct vfsmount *parent_mnt,
70208 + const struct dentry *old_dentry,
70209 + const struct vfsmount *old_mnt);
70210 +int gr_acl_handle_filldir(const struct file *file, const char *name,
70211 + const unsigned int namelen, const ino_t ino);
70212 +
70213 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
70214 + const struct vfsmount *mnt);
70215 +void gr_acl_handle_exit(void);
70216 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
70217 +int gr_acl_handle_procpidmem(const struct task_struct *task);
70218 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
70219 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
70220 +void gr_audit_ptrace(struct task_struct *task);
70221 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
70222 +void gr_put_exec_file(struct task_struct *task);
70223 +
70224 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
70225 +
70226 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
70227 +extern void gr_learn_resource(const struct task_struct *task, const int res,
70228 + const unsigned long wanted, const int gt);
70229 +#else
70230 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
70231 + const unsigned long wanted, const int gt)
70232 +{
70233 +}
70234 +#endif
70235 +
70236 +#ifdef CONFIG_GRKERNSEC_RESLOG
70237 +extern void gr_log_resource(const struct task_struct *task, const int res,
70238 + const unsigned long wanted, const int gt);
70239 +#else
70240 +static inline void gr_log_resource(const struct task_struct *task, const int res,
70241 + const unsigned long wanted, const int gt)
70242 +{
70243 +}
70244 +#endif
70245 +
70246 +#ifdef CONFIG_GRKERNSEC
70247 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
70248 +void gr_handle_vm86(void);
70249 +void gr_handle_mem_readwrite(u64 from, u64 to);
70250 +
70251 +void gr_log_badprocpid(const char *entry);
70252 +
70253 +extern int grsec_enable_dmesg;
70254 +extern int grsec_disable_privio;
70255 +
70256 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
70257 +extern kgid_t grsec_proc_gid;
70258 +#endif
70259 +
70260 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70261 +extern int grsec_enable_chroot_findtask;
70262 +#endif
70263 +#ifdef CONFIG_GRKERNSEC_SETXID
70264 +extern int grsec_enable_setxid;
70265 +#endif
70266 +#endif
70267 +
70268 +#endif
70269 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
70270 new file mode 100644
70271 index 0000000..e7ffaaf
70272 --- /dev/null
70273 +++ b/include/linux/grsock.h
70274 @@ -0,0 +1,19 @@
70275 +#ifndef __GRSOCK_H
70276 +#define __GRSOCK_H
70277 +
70278 +extern void gr_attach_curr_ip(const struct sock *sk);
70279 +extern int gr_handle_sock_all(const int family, const int type,
70280 + const int protocol);
70281 +extern int gr_handle_sock_server(const struct sockaddr *sck);
70282 +extern int gr_handle_sock_server_other(const struct sock *sck);
70283 +extern int gr_handle_sock_client(const struct sockaddr *sck);
70284 +extern int gr_search_connect(struct socket * sock,
70285 + struct sockaddr_in * addr);
70286 +extern int gr_search_bind(struct socket * sock,
70287 + struct sockaddr_in * addr);
70288 +extern int gr_search_listen(struct socket * sock);
70289 +extern int gr_search_accept(struct socket * sock);
70290 +extern int gr_search_socket(const int domain, const int type,
70291 + const int protocol);
70292 +
70293 +#endif
70294 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
70295 index ef788b5..ac41b7b 100644
70296 --- a/include/linux/highmem.h
70297 +++ b/include/linux/highmem.h
70298 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
70299 kunmap_atomic(kaddr);
70300 }
70301
70302 +static inline void sanitize_highpage(struct page *page)
70303 +{
70304 + void *kaddr;
70305 + unsigned long flags;
70306 +
70307 + local_irq_save(flags);
70308 + kaddr = kmap_atomic(page);
70309 + clear_page(kaddr);
70310 + kunmap_atomic(kaddr);
70311 + local_irq_restore(flags);
70312 +}
70313 +
70314 static inline void zero_user_segments(struct page *page,
70315 unsigned start1, unsigned end1,
70316 unsigned start2, unsigned end2)
70317 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
70318 index 1c7b89a..7f52502 100644
70319 --- a/include/linux/hwmon-sysfs.h
70320 +++ b/include/linux/hwmon-sysfs.h
70321 @@ -25,7 +25,8 @@
70322 struct sensor_device_attribute{
70323 struct device_attribute dev_attr;
70324 int index;
70325 -};
70326 +} __do_const;
70327 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
70328 #define to_sensor_dev_attr(_dev_attr) \
70329 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
70330
70331 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
70332 struct device_attribute dev_attr;
70333 u8 index;
70334 u8 nr;
70335 -};
70336 +} __do_const;
70337 #define to_sensor_dev_attr_2(_dev_attr) \
70338 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
70339
70340 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
70341 index d0c4db7..61b3577 100644
70342 --- a/include/linux/i2c.h
70343 +++ b/include/linux/i2c.h
70344 @@ -369,6 +369,7 @@ struct i2c_algorithm {
70345 /* To determine what the adapter supports */
70346 u32 (*functionality) (struct i2c_adapter *);
70347 };
70348 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
70349
70350 /*
70351 * i2c_adapter is the structure used to identify a physical i2c bus along
70352 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
70353 index d23c3c2..eb63c81 100644
70354 --- a/include/linux/i2o.h
70355 +++ b/include/linux/i2o.h
70356 @@ -565,7 +565,7 @@ struct i2o_controller {
70357 struct i2o_device *exec; /* Executive */
70358 #if BITS_PER_LONG == 64
70359 spinlock_t context_list_lock; /* lock for context_list */
70360 - atomic_t context_list_counter; /* needed for unique contexts */
70361 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
70362 struct list_head context_list; /* list of context id's
70363 and pointers */
70364 #endif
70365 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
70366 index aff7ad8..3942bbd 100644
70367 --- a/include/linux/if_pppox.h
70368 +++ b/include/linux/if_pppox.h
70369 @@ -76,7 +76,7 @@ struct pppox_proto {
70370 int (*ioctl)(struct socket *sock, unsigned int cmd,
70371 unsigned long arg);
70372 struct module *owner;
70373 -};
70374 +} __do_const;
70375
70376 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
70377 extern void unregister_pppox_proto(int proto_num);
70378 diff --git a/include/linux/init.h b/include/linux/init.h
70379 index 10ed4f4..8e8490d 100644
70380 --- a/include/linux/init.h
70381 +++ b/include/linux/init.h
70382 @@ -39,9 +39,36 @@
70383 * Also note, that this data cannot be "const".
70384 */
70385
70386 +#ifdef MODULE
70387 +#define add_init_latent_entropy
70388 +#define add_devinit_latent_entropy
70389 +#define add_cpuinit_latent_entropy
70390 +#define add_meminit_latent_entropy
70391 +#else
70392 +#define add_init_latent_entropy __latent_entropy
70393 +
70394 +#ifdef CONFIG_HOTPLUG
70395 +#define add_devinit_latent_entropy
70396 +#else
70397 +#define add_devinit_latent_entropy __latent_entropy
70398 +#endif
70399 +
70400 +#ifdef CONFIG_HOTPLUG_CPU
70401 +#define add_cpuinit_latent_entropy
70402 +#else
70403 +#define add_cpuinit_latent_entropy __latent_entropy
70404 +#endif
70405 +
70406 +#ifdef CONFIG_MEMORY_HOTPLUG
70407 +#define add_meminit_latent_entropy
70408 +#else
70409 +#define add_meminit_latent_entropy __latent_entropy
70410 +#endif
70411 +#endif
70412 +
70413 /* These are for everybody (although not all archs will actually
70414 discard it in modules) */
70415 -#define __init __section(.init.text) __cold notrace
70416 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
70417 #define __initdata __section(.init.data)
70418 #define __initconst __constsection(.init.rodata)
70419 #define __exitdata __section(.exit.data)
70420 @@ -94,7 +121,7 @@
70421 #define __exit __section(.exit.text) __exitused __cold notrace
70422
70423 /* Used for HOTPLUG_CPU */
70424 -#define __cpuinit __section(.cpuinit.text) __cold notrace
70425 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
70426 #define __cpuinitdata __section(.cpuinit.data)
70427 #define __cpuinitconst __constsection(.cpuinit.rodata)
70428 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
70429 @@ -102,7 +129,7 @@
70430 #define __cpuexitconst __constsection(.cpuexit.rodata)
70431
70432 /* Used for MEMORY_HOTPLUG */
70433 -#define __meminit __section(.meminit.text) __cold notrace
70434 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
70435 #define __meminitdata __section(.meminit.data)
70436 #define __meminitconst __constsection(.meminit.rodata)
70437 #define __memexit __section(.memexit.text) __exitused __cold notrace
70438 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
70439 index 6d087c5..401cab8 100644
70440 --- a/include/linux/init_task.h
70441 +++ b/include/linux/init_task.h
70442 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
70443
70444 #define INIT_TASK_COMM "swapper"
70445
70446 +#ifdef CONFIG_X86
70447 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
70448 +#else
70449 +#define INIT_TASK_THREAD_INFO
70450 +#endif
70451 +
70452 /*
70453 * INIT_TASK is used to set up the first task table, touch at
70454 * your own risk!. Base=0, limit=0x1fffff (=2MB)
70455 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
70456 RCU_POINTER_INITIALIZER(cred, &init_cred), \
70457 .comm = INIT_TASK_COMM, \
70458 .thread = INIT_THREAD, \
70459 + INIT_TASK_THREAD_INFO \
70460 .fs = &init_fs, \
70461 .files = &init_files, \
70462 .signal = &init_signals, \
70463 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
70464 index 5fa5afe..ac55b25 100644
70465 --- a/include/linux/interrupt.h
70466 +++ b/include/linux/interrupt.h
70467 @@ -430,7 +430,7 @@ enum
70468 /* map softirq index to softirq name. update 'softirq_to_name' in
70469 * kernel/softirq.c when adding a new softirq.
70470 */
70471 -extern char *softirq_to_name[NR_SOFTIRQS];
70472 +extern const char * const softirq_to_name[NR_SOFTIRQS];
70473
70474 /* softirq mask and active fields moved to irq_cpustat_t in
70475 * asm/hardirq.h to get better cache usage. KAO
70476 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
70477
70478 struct softirq_action
70479 {
70480 - void (*action)(struct softirq_action *);
70481 -};
70482 + void (*action)(void);
70483 +} __no_const;
70484
70485 asmlinkage void do_softirq(void);
70486 asmlinkage void __do_softirq(void);
70487 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
70488 +extern void open_softirq(int nr, void (*action)(void));
70489 extern void softirq_init(void);
70490 extern void __raise_softirq_irqoff(unsigned int nr);
70491
70492 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
70493 index f3b99e1..9b73cee 100644
70494 --- a/include/linux/iommu.h
70495 +++ b/include/linux/iommu.h
70496 @@ -101,7 +101,7 @@ struct iommu_ops {
70497 int (*domain_set_attr)(struct iommu_domain *domain,
70498 enum iommu_attr attr, void *data);
70499 unsigned long pgsize_bitmap;
70500 -};
70501 +} __do_const;
70502
70503 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
70504 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
70505 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
70506 index 85ac9b9b..e5759ab 100644
70507 --- a/include/linux/ioport.h
70508 +++ b/include/linux/ioport.h
70509 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
70510 int adjust_resource(struct resource *res, resource_size_t start,
70511 resource_size_t size);
70512 resource_size_t resource_alignment(struct resource *res);
70513 -static inline resource_size_t resource_size(const struct resource *res)
70514 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
70515 {
70516 return res->end - res->start + 1;
70517 }
70518 diff --git a/include/linux/irq.h b/include/linux/irq.h
70519 index fdf2c4a..5332486 100644
70520 --- a/include/linux/irq.h
70521 +++ b/include/linux/irq.h
70522 @@ -328,7 +328,8 @@ struct irq_chip {
70523 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
70524
70525 unsigned long flags;
70526 -};
70527 +} __do_const;
70528 +typedef struct irq_chip __no_const irq_chip_no_const;
70529
70530 /*
70531 * irq_chip specific flags
70532 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
70533 index 6883e19..06992b1 100644
70534 --- a/include/linux/kallsyms.h
70535 +++ b/include/linux/kallsyms.h
70536 @@ -15,7 +15,8 @@
70537
70538 struct module;
70539
70540 -#ifdef CONFIG_KALLSYMS
70541 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
70542 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
70543 /* Lookup the address for a symbol. Returns 0 if not found. */
70544 unsigned long kallsyms_lookup_name(const char *name);
70545
70546 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
70547 /* Stupid that this does nothing, but I didn't create this mess. */
70548 #define __print_symbol(fmt, addr)
70549 #endif /*CONFIG_KALLSYMS*/
70550 +#else /* when included by kallsyms.c, vsnprintf.c, or
70551 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
70552 +extern void __print_symbol(const char *fmt, unsigned long address);
70553 +extern int sprint_backtrace(char *buffer, unsigned long address);
70554 +extern int sprint_symbol(char *buffer, unsigned long address);
70555 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
70556 +const char *kallsyms_lookup(unsigned long addr,
70557 + unsigned long *symbolsize,
70558 + unsigned long *offset,
70559 + char **modname, char *namebuf);
70560 +#endif
70561
70562 /* This macro allows us to keep printk typechecking */
70563 static __printf(1, 2)
70564 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
70565 index 518a53a..5e28358 100644
70566 --- a/include/linux/key-type.h
70567 +++ b/include/linux/key-type.h
70568 @@ -125,7 +125,7 @@ struct key_type {
70569 /* internal fields */
70570 struct list_head link; /* link in types list */
70571 struct lock_class_key lock_class; /* key->sem lock class */
70572 -};
70573 +} __do_const;
70574
70575 extern struct key_type key_type_keyring;
70576
70577 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
70578 index 4dff0c6..1ca9b72 100644
70579 --- a/include/linux/kgdb.h
70580 +++ b/include/linux/kgdb.h
70581 @@ -53,7 +53,7 @@ extern int kgdb_connected;
70582 extern int kgdb_io_module_registered;
70583
70584 extern atomic_t kgdb_setting_breakpoint;
70585 -extern atomic_t kgdb_cpu_doing_single_step;
70586 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70587
70588 extern struct task_struct *kgdb_usethread;
70589 extern struct task_struct *kgdb_contthread;
70590 @@ -255,7 +255,7 @@ struct kgdb_arch {
70591 void (*correct_hw_break)(void);
70592
70593 void (*enable_nmi)(bool on);
70594 -};
70595 +} __do_const;
70596
70597 /**
70598 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
70599 @@ -280,7 +280,7 @@ struct kgdb_io {
70600 void (*pre_exception) (void);
70601 void (*post_exception) (void);
70602 int is_console;
70603 -};
70604 +} __do_const;
70605
70606 extern struct kgdb_arch arch_kgdb_ops;
70607
70608 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70609 index 5398d58..5883a34 100644
70610 --- a/include/linux/kmod.h
70611 +++ b/include/linux/kmod.h
70612 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70613 * usually useless though. */
70614 extern __printf(2, 3)
70615 int __request_module(bool wait, const char *name, ...);
70616 +extern __printf(3, 4)
70617 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70618 #define request_module(mod...) __request_module(true, mod)
70619 #define request_module_nowait(mod...) __request_module(false, mod)
70620 #define try_then_request_module(x, mod...) \
70621 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70622 index 939b112..ed6ed51 100644
70623 --- a/include/linux/kobject.h
70624 +++ b/include/linux/kobject.h
70625 @@ -111,7 +111,7 @@ struct kobj_type {
70626 struct attribute **default_attrs;
70627 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70628 const void *(*namespace)(struct kobject *kobj);
70629 -};
70630 +} __do_const;
70631
70632 struct kobj_uevent_env {
70633 char *envp[UEVENT_NUM_ENVP];
70634 @@ -134,6 +134,7 @@ struct kobj_attribute {
70635 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70636 const char *buf, size_t count);
70637 };
70638 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70639
70640 extern const struct sysfs_ops kobj_sysfs_ops;
70641
70642 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70643 index f66b065..c2c29b4 100644
70644 --- a/include/linux/kobject_ns.h
70645 +++ b/include/linux/kobject_ns.h
70646 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70647 const void *(*netlink_ns)(struct sock *sk);
70648 const void *(*initial_ns)(void);
70649 void (*drop_ns)(void *);
70650 -};
70651 +} __do_const;
70652
70653 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70654 int kobj_ns_type_registered(enum kobj_ns_type type);
70655 diff --git a/include/linux/kref.h b/include/linux/kref.h
70656 index 4972e6e..de4d19b 100644
70657 --- a/include/linux/kref.h
70658 +++ b/include/linux/kref.h
70659 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
70660 static inline int kref_sub(struct kref *kref, unsigned int count,
70661 void (*release)(struct kref *kref))
70662 {
70663 - WARN_ON(release == NULL);
70664 + BUG_ON(release == NULL);
70665
70666 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70667 release(kref);
70668 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70669 index ffdf8b7..1f91d0e 100644
70670 --- a/include/linux/kvm_host.h
70671 +++ b/include/linux/kvm_host.h
70672 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
70673 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
70674 void vcpu_put(struct kvm_vcpu *vcpu);
70675
70676 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70677 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70678 struct module *module);
70679 void kvm_exit(void);
70680
70681 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70682 struct kvm_guest_debug *dbg);
70683 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70684
70685 -int kvm_arch_init(void *opaque);
70686 +int kvm_arch_init(const void *opaque);
70687 void kvm_arch_exit(void);
70688
70689 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70690 diff --git a/include/linux/libata.h b/include/linux/libata.h
70691 index 0621bca..24d6851 100644
70692 --- a/include/linux/libata.h
70693 +++ b/include/linux/libata.h
70694 @@ -916,7 +916,7 @@ struct ata_port_operations {
70695 * fields must be pointers.
70696 */
70697 const struct ata_port_operations *inherits;
70698 -};
70699 +} __do_const;
70700
70701 struct ata_port_info {
70702 unsigned long flags;
70703 diff --git a/include/linux/list.h b/include/linux/list.h
70704 index cc6d2aa..c10ee83 100644
70705 --- a/include/linux/list.h
70706 +++ b/include/linux/list.h
70707 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70708 extern void list_del(struct list_head *entry);
70709 #endif
70710
70711 +extern void __pax_list_add(struct list_head *new,
70712 + struct list_head *prev,
70713 + struct list_head *next);
70714 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70715 +{
70716 + __pax_list_add(new, head, head->next);
70717 +}
70718 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70719 +{
70720 + __pax_list_add(new, head->prev, head);
70721 +}
70722 +extern void pax_list_del(struct list_head *entry);
70723 +
70724 /**
70725 * list_replace - replace old entry by new one
70726 * @old : the element to be replaced
70727 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70728 INIT_LIST_HEAD(entry);
70729 }
70730
70731 +extern void pax_list_del_init(struct list_head *entry);
70732 +
70733 /**
70734 * list_move - delete from one list and add as another's head
70735 * @list: the entry to move
70736 diff --git a/include/linux/math64.h b/include/linux/math64.h
70737 index b8ba855..0148090 100644
70738 --- a/include/linux/math64.h
70739 +++ b/include/linux/math64.h
70740 @@ -14,7 +14,7 @@
70741 * This is commonly provided by 32bit archs to provide an optimized 64bit
70742 * divide.
70743 */
70744 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70745 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70746 {
70747 *remainder = dividend % divisor;
70748 return dividend / divisor;
70749 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70750 #define div64_long(x,y) div_s64((x),(y))
70751
70752 #ifndef div_u64_rem
70753 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70754 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70755 {
70756 *remainder = do_div(dividend, divisor);
70757 return dividend;
70758 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70759 * divide.
70760 */
70761 #ifndef div_u64
70762 -static inline u64 div_u64(u64 dividend, u32 divisor)
70763 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70764 {
70765 u32 remainder;
70766 return div_u64_rem(dividend, divisor, &remainder);
70767 diff --git a/include/linux/mm.h b/include/linux/mm.h
70768 index 9568b90..6cc79f9 100644
70769 --- a/include/linux/mm.h
70770 +++ b/include/linux/mm.h
70771 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
70772 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70773 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70774 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70775 +
70776 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70777 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70778 +#endif
70779 +
70780 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70781
70782 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70783 @@ -200,8 +205,8 @@ struct vm_operations_struct {
70784 /* called by access_process_vm when get_user_pages() fails, typically
70785 * for use by special VMAs that can switch between memory and hardware
70786 */
70787 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70788 - void *buf, int len, int write);
70789 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70790 + void *buf, size_t len, int write);
70791 #ifdef CONFIG_NUMA
70792 /*
70793 * set_policy() op must add a reference to any non-NULL @new mempolicy
70794 @@ -231,6 +236,7 @@ struct vm_operations_struct {
70795 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70796 unsigned long size, pgoff_t pgoff);
70797 };
70798 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70799
70800 struct mmu_gather;
70801 struct inode;
70802 @@ -995,8 +1001,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70803 unsigned long *pfn);
70804 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70805 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70806 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70807 - void *buf, int len, int write);
70808 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70809 + void *buf, size_t len, int write);
70810
70811 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70812 loff_t const holebegin, loff_t const holelen)
70813 @@ -1035,10 +1041,10 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70814 }
70815 #endif
70816
70817 -extern int make_pages_present(unsigned long addr, unsigned long end);
70818 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70819 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70820 - void *buf, int len, int write);
70821 +extern ssize_t make_pages_present(unsigned long addr, unsigned long end);
70822 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70823 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70824 + void *buf, size_t len, int write);
70825
70826 int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70827 unsigned long start, int len, unsigned int foll_flags,
70828 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
70829 int set_page_dirty_lock(struct page *page);
70830 int clear_page_dirty_for_io(struct page *page);
70831
70832 -/* Is the vma a continuation of the stack vma above it? */
70833 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70834 -{
70835 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70836 -}
70837 -
70838 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70839 - unsigned long addr)
70840 -{
70841 - return (vma->vm_flags & VM_GROWSDOWN) &&
70842 - (vma->vm_start == addr) &&
70843 - !vma_growsdown(vma->vm_prev, addr);
70844 -}
70845 -
70846 -/* Is the vma a continuation of the stack vma below it? */
70847 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70848 -{
70849 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70850 -}
70851 -
70852 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70853 - unsigned long addr)
70854 -{
70855 - return (vma->vm_flags & VM_GROWSUP) &&
70856 - (vma->vm_end == addr) &&
70857 - !vma_growsup(vma->vm_next, addr);
70858 -}
70859 -
70860 extern pid_t
70861 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70862
70863 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70864 }
70865 #endif
70866
70867 +#ifdef CONFIG_MMU
70868 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70869 +#else
70870 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70871 +{
70872 + return __pgprot(0);
70873 +}
70874 +#endif
70875 +
70876 int vma_wants_writenotify(struct vm_area_struct *vma);
70877
70878 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70879 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70880 {
70881 return 0;
70882 }
70883 +
70884 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70885 + unsigned long address)
70886 +{
70887 + return 0;
70888 +}
70889 #else
70890 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70891 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70892 #endif
70893
70894 #ifdef __PAGETABLE_PMD_FOLDED
70895 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70896 {
70897 return 0;
70898 }
70899 +
70900 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70901 + unsigned long address)
70902 +{
70903 + return 0;
70904 +}
70905 #else
70906 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70907 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70908 #endif
70909
70910 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70911 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70912 NULL: pud_offset(pgd, address);
70913 }
70914
70915 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70916 +{
70917 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70918 + NULL: pud_offset(pgd, address);
70919 +}
70920 +
70921 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70922 {
70923 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70924 NULL: pmd_offset(pud, address);
70925 }
70926 +
70927 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70928 +{
70929 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70930 + NULL: pmd_offset(pud, address);
70931 +}
70932 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70933
70934 #if USE_SPLIT_PTLOCKS
70935 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
70936 unsigned long, unsigned long,
70937 unsigned long, unsigned long);
70938 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70939 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70940
70941 /* These take the mm semaphore themselves */
70942 extern unsigned long vm_brk(unsigned long, unsigned long);
70943 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70944 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70945 struct vm_area_struct **pprev);
70946
70947 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70948 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70949 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70950 +
70951 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70952 NULL if none. Assume start_addr < end_addr. */
70953 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70954 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70955 return vma;
70956 }
70957
70958 -#ifdef CONFIG_MMU
70959 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70960 -#else
70961 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70962 -{
70963 - return __pgprot(0);
70964 -}
70965 -#endif
70966 -
70967 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70968 unsigned long change_prot_numa(struct vm_area_struct *vma,
70969 unsigned long start, unsigned long end);
70970 @@ -1651,6 +1660,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70971 static inline void vm_stat_account(struct mm_struct *mm,
70972 unsigned long flags, struct file *file, long pages)
70973 {
70974 +
70975 +#ifdef CONFIG_PAX_RANDMMAP
70976 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70977 +#endif
70978 +
70979 mm->total_vm += pages;
70980 }
70981 #endif /* CONFIG_PROC_FS */
70982 @@ -1723,7 +1737,7 @@ extern int unpoison_memory(unsigned long pfn);
70983 extern int sysctl_memory_failure_early_kill;
70984 extern int sysctl_memory_failure_recovery;
70985 extern void shake_page(struct page *p, int access);
70986 -extern atomic_long_t mce_bad_pages;
70987 +extern atomic_long_unchecked_t mce_bad_pages;
70988 extern int soft_offline_page(struct page *page, int flags);
70989
70990 extern void dump_page(struct page *page);
70991 @@ -1754,5 +1768,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70992 static inline bool page_is_guard(struct page *page) { return false; }
70993 #endif /* CONFIG_DEBUG_PAGEALLOC */
70994
70995 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70996 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70997 +#else
70998 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70999 +#endif
71000 +
71001 #endif /* __KERNEL__ */
71002 #endif /* _LINUX_MM_H */
71003 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
71004 index f8f5162..3aaf20f 100644
71005 --- a/include/linux/mm_types.h
71006 +++ b/include/linux/mm_types.h
71007 @@ -288,6 +288,8 @@ struct vm_area_struct {
71008 #ifdef CONFIG_NUMA
71009 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
71010 #endif
71011 +
71012 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
71013 };
71014
71015 struct core_thread {
71016 @@ -436,6 +438,24 @@ struct mm_struct {
71017 int first_nid;
71018 #endif
71019 struct uprobes_state uprobes_state;
71020 +
71021 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71022 + unsigned long pax_flags;
71023 +#endif
71024 +
71025 +#ifdef CONFIG_PAX_DLRESOLVE
71026 + unsigned long call_dl_resolve;
71027 +#endif
71028 +
71029 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
71030 + unsigned long call_syscall;
71031 +#endif
71032 +
71033 +#ifdef CONFIG_PAX_ASLR
71034 + unsigned long delta_mmap; /* randomized offset */
71035 + unsigned long delta_stack; /* randomized offset */
71036 +#endif
71037 +
71038 };
71039
71040 /* first nid will either be a valid NID or one of these values */
71041 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
71042 index c5d5278..f0b68c8 100644
71043 --- a/include/linux/mmiotrace.h
71044 +++ b/include/linux/mmiotrace.h
71045 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
71046 /* Called from ioremap.c */
71047 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
71048 void __iomem *addr);
71049 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
71050 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
71051
71052 /* For anyone to insert markers. Remember trailing newline. */
71053 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
71054 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
71055 {
71056 }
71057
71058 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
71059 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
71060 {
71061 }
71062
71063 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
71064 index 73b64a3..6562925 100644
71065 --- a/include/linux/mmzone.h
71066 +++ b/include/linux/mmzone.h
71067 @@ -412,7 +412,7 @@ struct zone {
71068 unsigned long flags; /* zone flags, see below */
71069
71070 /* Zone statistics */
71071 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71072 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
71073
71074 /*
71075 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
71076 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
71077 index fed3def..c933f99 100644
71078 --- a/include/linux/mod_devicetable.h
71079 +++ b/include/linux/mod_devicetable.h
71080 @@ -12,7 +12,7 @@
71081 typedef unsigned long kernel_ulong_t;
71082 #endif
71083
71084 -#define PCI_ANY_ID (~0)
71085 +#define PCI_ANY_ID ((__u16)~0)
71086
71087 struct pci_device_id {
71088 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
71089 @@ -139,7 +139,7 @@ struct usb_device_id {
71090 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
71091 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
71092
71093 -#define HID_ANY_ID (~0)
71094 +#define HID_ANY_ID (~0U)
71095 #define HID_BUS_ANY 0xffff
71096 #define HID_GROUP_ANY 0x0000
71097
71098 @@ -498,7 +498,7 @@ struct dmi_system_id {
71099 const char *ident;
71100 struct dmi_strmatch matches[4];
71101 void *driver_data;
71102 -};
71103 +} __do_const;
71104 /*
71105 * struct dmi_device_id appears during expansion of
71106 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
71107 diff --git a/include/linux/module.h b/include/linux/module.h
71108 index 1375ee3..ced8177 100644
71109 --- a/include/linux/module.h
71110 +++ b/include/linux/module.h
71111 @@ -17,9 +17,11 @@
71112 #include <linux/moduleparam.h>
71113 #include <linux/tracepoint.h>
71114 #include <linux/export.h>
71115 +#include <linux/fs.h>
71116
71117 #include <linux/percpu.h>
71118 #include <asm/module.h>
71119 +#include <asm/pgtable.h>
71120
71121 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
71122 #define MODULE_SIG_STRING "~Module signature appended~\n"
71123 @@ -54,12 +56,13 @@ struct module_attribute {
71124 int (*test)(struct module *);
71125 void (*free)(struct module *);
71126 };
71127 +typedef struct module_attribute __no_const module_attribute_no_const;
71128
71129 struct module_version_attribute {
71130 struct module_attribute mattr;
71131 const char *module_name;
71132 const char *version;
71133 -} __attribute__ ((__aligned__(sizeof(void *))));
71134 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
71135
71136 extern ssize_t __modver_version_show(struct module_attribute *,
71137 struct module_kobject *, char *);
71138 @@ -232,7 +235,7 @@ struct module
71139
71140 /* Sysfs stuff. */
71141 struct module_kobject mkobj;
71142 - struct module_attribute *modinfo_attrs;
71143 + module_attribute_no_const *modinfo_attrs;
71144 const char *version;
71145 const char *srcversion;
71146 struct kobject *holders_dir;
71147 @@ -281,19 +284,16 @@ struct module
71148 int (*init)(void);
71149
71150 /* If this is non-NULL, vfree after init() returns */
71151 - void *module_init;
71152 + void *module_init_rx, *module_init_rw;
71153
71154 /* Here is the actual code + data, vfree'd on unload. */
71155 - void *module_core;
71156 + void *module_core_rx, *module_core_rw;
71157
71158 /* Here are the sizes of the init and core sections */
71159 - unsigned int init_size, core_size;
71160 + unsigned int init_size_rw, core_size_rw;
71161
71162 /* The size of the executable code in each section. */
71163 - unsigned int init_text_size, core_text_size;
71164 -
71165 - /* Size of RO sections of the module (text+rodata) */
71166 - unsigned int init_ro_size, core_ro_size;
71167 + unsigned int init_size_rx, core_size_rx;
71168
71169 /* Arch-specific module values */
71170 struct mod_arch_specific arch;
71171 @@ -349,6 +349,10 @@ struct module
71172 #ifdef CONFIG_EVENT_TRACING
71173 struct ftrace_event_call **trace_events;
71174 unsigned int num_trace_events;
71175 + struct file_operations trace_id;
71176 + struct file_operations trace_enable;
71177 + struct file_operations trace_format;
71178 + struct file_operations trace_filter;
71179 #endif
71180 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
71181 unsigned int num_ftrace_callsites;
71182 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
71183 bool is_module_percpu_address(unsigned long addr);
71184 bool is_module_text_address(unsigned long addr);
71185
71186 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
71187 +{
71188 +
71189 +#ifdef CONFIG_PAX_KERNEXEC
71190 + if (ktla_ktva(addr) >= (unsigned long)start &&
71191 + ktla_ktva(addr) < (unsigned long)start + size)
71192 + return 1;
71193 +#endif
71194 +
71195 + return ((void *)addr >= start && (void *)addr < start + size);
71196 +}
71197 +
71198 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
71199 +{
71200 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
71201 +}
71202 +
71203 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
71204 +{
71205 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
71206 +}
71207 +
71208 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
71209 +{
71210 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
71211 +}
71212 +
71213 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
71214 +{
71215 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
71216 +}
71217 +
71218 static inline int within_module_core(unsigned long addr, struct module *mod)
71219 {
71220 - return (unsigned long)mod->module_core <= addr &&
71221 - addr < (unsigned long)mod->module_core + mod->core_size;
71222 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
71223 }
71224
71225 static inline int within_module_init(unsigned long addr, struct module *mod)
71226 {
71227 - return (unsigned long)mod->module_init <= addr &&
71228 - addr < (unsigned long)mod->module_init + mod->init_size;
71229 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
71230 }
71231
71232 /* Search for module by name: must hold module_mutex. */
71233 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
71234 index 560ca53..ef621ef 100644
71235 --- a/include/linux/moduleloader.h
71236 +++ b/include/linux/moduleloader.h
71237 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
71238 sections. Returns NULL on failure. */
71239 void *module_alloc(unsigned long size);
71240
71241 +#ifdef CONFIG_PAX_KERNEXEC
71242 +void *module_alloc_exec(unsigned long size);
71243 +#else
71244 +#define module_alloc_exec(x) module_alloc(x)
71245 +#endif
71246 +
71247 /* Free memory returned from module_alloc. */
71248 void module_free(struct module *mod, void *module_region);
71249
71250 +#ifdef CONFIG_PAX_KERNEXEC
71251 +void module_free_exec(struct module *mod, void *module_region);
71252 +#else
71253 +#define module_free_exec(x, y) module_free((x), (y))
71254 +#endif
71255 +
71256 /*
71257 * Apply the given relocation to the (simplified) ELF. Return -error
71258 * or 0.
71259 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
71260 unsigned int relsec,
71261 struct module *me)
71262 {
71263 +#ifdef CONFIG_MODULES
71264 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
71265 +#endif
71266 return -ENOEXEC;
71267 }
71268 #endif
71269 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
71270 unsigned int relsec,
71271 struct module *me)
71272 {
71273 +#ifdef CONFIG_MODULES
71274 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
71275 +#endif
71276 return -ENOEXEC;
71277 }
71278 #endif
71279 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
71280 index 137b419..fe663ec 100644
71281 --- a/include/linux/moduleparam.h
71282 +++ b/include/linux/moduleparam.h
71283 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
71284 * @len is usually just sizeof(string).
71285 */
71286 #define module_param_string(name, string, len, perm) \
71287 - static const struct kparam_string __param_string_##name \
71288 + static const struct kparam_string __param_string_##name __used \
71289 = { len, string }; \
71290 __module_param_call(MODULE_PARAM_PREFIX, name, \
71291 &param_ops_string, \
71292 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
71293 */
71294 #define module_param_array_named(name, array, type, nump, perm) \
71295 param_check_##type(name, &(array)[0]); \
71296 - static const struct kparam_array __param_arr_##name \
71297 + static const struct kparam_array __param_arr_##name __used \
71298 = { .max = ARRAY_SIZE(array), .num = nump, \
71299 .ops = &param_ops_##type, \
71300 .elemsize = sizeof(array[0]), .elem = array }; \
71301 diff --git a/include/linux/namei.h b/include/linux/namei.h
71302 index 5a5ff57..5ae5070 100644
71303 --- a/include/linux/namei.h
71304 +++ b/include/linux/namei.h
71305 @@ -19,7 +19,7 @@ struct nameidata {
71306 unsigned seq;
71307 int last_type;
71308 unsigned depth;
71309 - char *saved_names[MAX_NESTED_LINKS + 1];
71310 + const char *saved_names[MAX_NESTED_LINKS + 1];
71311 };
71312
71313 /*
71314 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
71315
71316 extern void nd_jump_link(struct nameidata *nd, struct path *path);
71317
71318 -static inline void nd_set_link(struct nameidata *nd, char *path)
71319 +static inline void nd_set_link(struct nameidata *nd, const char *path)
71320 {
71321 nd->saved_names[nd->depth] = path;
71322 }
71323
71324 -static inline char *nd_get_link(struct nameidata *nd)
71325 +static inline const char *nd_get_link(const struct nameidata *nd)
71326 {
71327 return nd->saved_names[nd->depth];
71328 }
71329 diff --git a/include/linux/net.h b/include/linux/net.h
71330 index aa16731..514b875 100644
71331 --- a/include/linux/net.h
71332 +++ b/include/linux/net.h
71333 @@ -183,7 +183,7 @@ struct net_proto_family {
71334 int (*create)(struct net *net, struct socket *sock,
71335 int protocol, int kern);
71336 struct module *owner;
71337 -};
71338 +} __do_const;
71339
71340 struct iovec;
71341 struct kvec;
71342 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
71343 index 9ef07d0..130a5d9 100644
71344 --- a/include/linux/netdevice.h
71345 +++ b/include/linux/netdevice.h
71346 @@ -1012,6 +1012,7 @@ struct net_device_ops {
71347 u32 pid, u32 seq,
71348 struct net_device *dev);
71349 };
71350 +typedef struct net_device_ops __no_const net_device_ops_no_const;
71351
71352 /*
71353 * The DEVICE structure.
71354 @@ -1078,7 +1079,7 @@ struct net_device {
71355 int iflink;
71356
71357 struct net_device_stats stats;
71358 - atomic_long_t rx_dropped; /* dropped packets by core network
71359 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
71360 * Do not use this in drivers.
71361 */
71362
71363 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
71364 index ee14284..bc65d63 100644
71365 --- a/include/linux/netfilter.h
71366 +++ b/include/linux/netfilter.h
71367 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
71368 #endif
71369 /* Use the module struct to lock set/get code in place */
71370 struct module *owner;
71371 -};
71372 +} __do_const;
71373
71374 /* Function to register/unregister hook points. */
71375 int nf_register_hook(struct nf_hook_ops *reg);
71376 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
71377 index 7958e84..ed74d7a 100644
71378 --- a/include/linux/netfilter/ipset/ip_set.h
71379 +++ b/include/linux/netfilter/ipset/ip_set.h
71380 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
71381 /* Return true if "b" set is the same as "a"
71382 * according to the create set parameters */
71383 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
71384 -};
71385 +} __do_const;
71386
71387 /* The core set type structure */
71388 struct ip_set_type {
71389 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
71390 index 4966dde..7d8ce06 100644
71391 --- a/include/linux/netfilter/nfnetlink.h
71392 +++ b/include/linux/netfilter/nfnetlink.h
71393 @@ -16,7 +16,7 @@ struct nfnl_callback {
71394 const struct nlattr * const cda[]);
71395 const struct nla_policy *policy; /* netlink attribute policy */
71396 const u_int16_t attr_count; /* number of nlattr's */
71397 -};
71398 +} __do_const;
71399
71400 struct nfnetlink_subsystem {
71401 const char *name;
71402 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
71403 new file mode 100644
71404 index 0000000..33f4af8
71405 --- /dev/null
71406 +++ b/include/linux/netfilter/xt_gradm.h
71407 @@ -0,0 +1,9 @@
71408 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
71409 +#define _LINUX_NETFILTER_XT_GRADM_H 1
71410 +
71411 +struct xt_gradm_mtinfo {
71412 + __u16 flags;
71413 + __u16 invflags;
71414 +};
71415 +
71416 +#endif
71417 diff --git a/include/linux/nls.h b/include/linux/nls.h
71418 index 5dc635f..35f5e11 100644
71419 --- a/include/linux/nls.h
71420 +++ b/include/linux/nls.h
71421 @@ -31,7 +31,7 @@ struct nls_table {
71422 const unsigned char *charset2upper;
71423 struct module *owner;
71424 struct nls_table *next;
71425 -};
71426 +} __do_const;
71427
71428 /* this value hold the maximum octet of charset */
71429 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
71430 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
71431 index d65746e..62e72c2 100644
71432 --- a/include/linux/notifier.h
71433 +++ b/include/linux/notifier.h
71434 @@ -51,7 +51,8 @@ struct notifier_block {
71435 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
71436 struct notifier_block __rcu *next;
71437 int priority;
71438 -};
71439 +} __do_const;
71440 +typedef struct notifier_block __no_const notifier_block_no_const;
71441
71442 struct atomic_notifier_head {
71443 spinlock_t lock;
71444 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
71445 index a4c5624..79d6d88 100644
71446 --- a/include/linux/oprofile.h
71447 +++ b/include/linux/oprofile.h
71448 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
71449 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
71450 char const * name, ulong * val);
71451
71452 -/** Create a file for read-only access to an atomic_t. */
71453 +/** Create a file for read-only access to an atomic_unchecked_t. */
71454 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
71455 - char const * name, atomic_t * val);
71456 + char const * name, atomic_unchecked_t * val);
71457
71458 /** create a directory */
71459 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
71460 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
71461 index 45fc162..01a4068 100644
71462 --- a/include/linux/pci_hotplug.h
71463 +++ b/include/linux/pci_hotplug.h
71464 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
71465 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
71466 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
71467 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
71468 -};
71469 +} __do_const;
71470 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
71471
71472 /**
71473 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
71474 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
71475 index a280650..2b67b91 100644
71476 --- a/include/linux/perf_event.h
71477 +++ b/include/linux/perf_event.h
71478 @@ -328,8 +328,8 @@ struct perf_event {
71479
71480 enum perf_event_active_state state;
71481 unsigned int attach_state;
71482 - local64_t count;
71483 - atomic64_t child_count;
71484 + local64_t count; /* PaX: fix it one day */
71485 + atomic64_unchecked_t child_count;
71486
71487 /*
71488 * These are the total time in nanoseconds that the event
71489 @@ -380,8 +380,8 @@ struct perf_event {
71490 * These accumulate total time (in nanoseconds) that children
71491 * events have been enabled and running, respectively.
71492 */
71493 - atomic64_t child_total_time_enabled;
71494 - atomic64_t child_total_time_running;
71495 + atomic64_unchecked_t child_total_time_enabled;
71496 + atomic64_unchecked_t child_total_time_running;
71497
71498 /*
71499 * Protect attach/detach and child_list:
71500 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
71501 */
71502 #define perf_cpu_notifier(fn) \
71503 do { \
71504 - static struct notifier_block fn##_nb __cpuinitdata = \
71505 + static struct notifier_block fn##_nb = \
71506 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
71507 unsigned long cpu = smp_processor_id(); \
71508 unsigned long flags; \
71509 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
71510 index ad1a427..6419649 100644
71511 --- a/include/linux/pipe_fs_i.h
71512 +++ b/include/linux/pipe_fs_i.h
71513 @@ -45,9 +45,9 @@ struct pipe_buffer {
71514 struct pipe_inode_info {
71515 wait_queue_head_t wait;
71516 unsigned int nrbufs, curbuf, buffers;
71517 - unsigned int readers;
71518 - unsigned int writers;
71519 - unsigned int waiting_writers;
71520 + atomic_t readers;
71521 + atomic_t writers;
71522 + atomic_t waiting_writers;
71523 unsigned int r_counter;
71524 unsigned int w_counter;
71525 struct page *tmp_page;
71526 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
71527 index 5f28cae..3d23723 100644
71528 --- a/include/linux/platform_data/usb-ehci-s5p.h
71529 +++ b/include/linux/platform_data/usb-ehci-s5p.h
71530 @@ -14,7 +14,7 @@
71531 struct s5p_ehci_platdata {
71532 int (*phy_init)(struct platform_device *pdev, int type);
71533 int (*phy_exit)(struct platform_device *pdev, int type);
71534 -};
71535 +} __no_const;
71536
71537 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
71538
71539 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
71540 index c256c59..8ea94c7 100644
71541 --- a/include/linux/platform_data/usb-exynos.h
71542 +++ b/include/linux/platform_data/usb-exynos.h
71543 @@ -14,7 +14,7 @@
71544 struct exynos4_ohci_platdata {
71545 int (*phy_init)(struct platform_device *pdev, int type);
71546 int (*phy_exit)(struct platform_device *pdev, int type);
71547 -};
71548 +} __no_const;
71549
71550 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
71551
71552 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
71553 index 7c1d252..c5c773e 100644
71554 --- a/include/linux/pm_domain.h
71555 +++ b/include/linux/pm_domain.h
71556 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
71557
71558 struct gpd_cpu_data {
71559 unsigned int saved_exit_latency;
71560 - struct cpuidle_state *idle_state;
71561 + cpuidle_state_no_const *idle_state;
71562 };
71563
71564 struct generic_pm_domain {
71565 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
71566 index f271860..6b3bec5 100644
71567 --- a/include/linux/pm_runtime.h
71568 +++ b/include/linux/pm_runtime.h
71569 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
71570
71571 static inline void pm_runtime_mark_last_busy(struct device *dev)
71572 {
71573 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
71574 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
71575 }
71576
71577 #else /* !CONFIG_PM_RUNTIME */
71578 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
71579 index 195aafc..49a7bc2 100644
71580 --- a/include/linux/pnp.h
71581 +++ b/include/linux/pnp.h
71582 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
71583 struct pnp_fixup {
71584 char id[7];
71585 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
71586 -};
71587 +} __do_const;
71588
71589 /* config parameters */
71590 #define PNP_CONFIG_NORMAL 0x0001
71591 diff --git a/include/linux/poison.h b/include/linux/poison.h
71592 index 2110a81..13a11bb 100644
71593 --- a/include/linux/poison.h
71594 +++ b/include/linux/poison.h
71595 @@ -19,8 +19,8 @@
71596 * under normal circumstances, used to verify that nobody uses
71597 * non-initialized list entries.
71598 */
71599 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
71600 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
71601 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
71602 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
71603
71604 /********** include/linux/timer.h **********/
71605 /*
71606 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71607 index c0f44c2..1572583 100644
71608 --- a/include/linux/power/smartreflex.h
71609 +++ b/include/linux/power/smartreflex.h
71610 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71611 int (*notify)(struct omap_sr *sr, u32 status);
71612 u8 notify_flags;
71613 u8 class_type;
71614 -};
71615 +} __do_const;
71616
71617 /**
71618 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71619 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71620 index 4ea1d37..80f4b33 100644
71621 --- a/include/linux/ppp-comp.h
71622 +++ b/include/linux/ppp-comp.h
71623 @@ -84,7 +84,7 @@ struct compressor {
71624 struct module *owner;
71625 /* Extra skb space needed by the compressor algorithm */
71626 unsigned int comp_extra;
71627 -};
71628 +} __do_const;
71629
71630 /*
71631 * The return value from decompress routine is the length of the
71632 diff --git a/include/linux/printk.h b/include/linux/printk.h
71633 index 9afc01e..92c32e8 100644
71634 --- a/include/linux/printk.h
71635 +++ b/include/linux/printk.h
71636 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
71637 extern int printk_needs_cpu(int cpu);
71638 extern void printk_tick(void);
71639
71640 +extern int kptr_restrict;
71641 +
71642 #ifdef CONFIG_PRINTK
71643 asmlinkage __printf(5, 0)
71644 int vprintk_emit(int facility, int level,
71645 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71646
71647 extern int printk_delay_msec;
71648 extern int dmesg_restrict;
71649 -extern int kptr_restrict;
71650
71651 void log_buf_kexec_setup(void);
71652 void __init setup_log_buf(int early);
71653 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71654 index 32676b3..e46f2c0 100644
71655 --- a/include/linux/proc_fs.h
71656 +++ b/include/linux/proc_fs.h
71657 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
71658 return proc_create_data(name, mode, parent, proc_fops, NULL);
71659 }
71660
71661 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71662 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71663 +{
71664 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71665 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71666 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71667 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71668 +#else
71669 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71670 +#endif
71671 +}
71672 +
71673 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
71674 umode_t mode, struct proc_dir_entry *base,
71675 read_proc_t *read_proc, void * data)
71676 @@ -268,7 +280,7 @@ struct proc_ns_operations {
71677 void (*put)(void *ns);
71678 int (*install)(struct nsproxy *nsproxy, void *ns);
71679 unsigned int (*inum)(void *ns);
71680 -};
71681 +} __do_const;
71682 extern const struct proc_ns_operations netns_operations;
71683 extern const struct proc_ns_operations utsns_operations;
71684 extern const struct proc_ns_operations ipcns_operations;
71685 diff --git a/include/linux/random.h b/include/linux/random.h
71686 index d984608..d6f0042 100644
71687 --- a/include/linux/random.h
71688 +++ b/include/linux/random.h
71689 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
71690 u32 prandom_u32_state(struct rnd_state *);
71691 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71692
71693 +static inline unsigned long pax_get_random_long(void)
71694 +{
71695 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71696 +}
71697 +
71698 /*
71699 * Handle minimum values for seeds
71700 */
71701 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71702 index c92dd28..08f4eab 100644
71703 --- a/include/linux/rculist.h
71704 +++ b/include/linux/rculist.h
71705 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71706 struct list_head *prev, struct list_head *next);
71707 #endif
71708
71709 +extern void __pax_list_add_rcu(struct list_head *new,
71710 + struct list_head *prev, struct list_head *next);
71711 +
71712 /**
71713 * list_add_rcu - add a new entry to rcu-protected list
71714 * @new: new entry to be added
71715 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71716 __list_add_rcu(new, head, head->next);
71717 }
71718
71719 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71720 +{
71721 + __pax_list_add_rcu(new, head, head->next);
71722 +}
71723 +
71724 /**
71725 * list_add_tail_rcu - add a new entry to rcu-protected list
71726 * @new: new entry to be added
71727 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71728 __list_add_rcu(new, head->prev, head);
71729 }
71730
71731 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71732 + struct list_head *head)
71733 +{
71734 + __pax_list_add_rcu(new, head->prev, head);
71735 +}
71736 +
71737 /**
71738 * list_del_rcu - deletes entry from list without re-initialization
71739 * @entry: the element to delete from the list.
71740 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71741 entry->prev = LIST_POISON2;
71742 }
71743
71744 +extern void pax_list_del_rcu(struct list_head *entry);
71745 +
71746 /**
71747 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71748 * @n: the element to delete from the hash list.
71749 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71750 index 23b3630..e1bc12b 100644
71751 --- a/include/linux/reboot.h
71752 +++ b/include/linux/reboot.h
71753 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71754 * Architecture-specific implementations of sys_reboot commands.
71755 */
71756
71757 -extern void machine_restart(char *cmd);
71758 -extern void machine_halt(void);
71759 -extern void machine_power_off(void);
71760 +extern void machine_restart(char *cmd) __noreturn;
71761 +extern void machine_halt(void) __noreturn;
71762 +extern void machine_power_off(void) __noreturn;
71763
71764 extern void machine_shutdown(void);
71765 struct pt_regs;
71766 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71767 */
71768
71769 extern void kernel_restart_prepare(char *cmd);
71770 -extern void kernel_restart(char *cmd);
71771 -extern void kernel_halt(void);
71772 -extern void kernel_power_off(void);
71773 +extern void kernel_restart(char *cmd) __noreturn;
71774 +extern void kernel_halt(void) __noreturn;
71775 +extern void kernel_power_off(void) __noreturn;
71776
71777 extern int C_A_D; /* for sysctl */
71778 void ctrl_alt_del(void);
71779 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71780 * Emergency restart, callable from an interrupt handler.
71781 */
71782
71783 -extern void emergency_restart(void);
71784 +extern void emergency_restart(void) __noreturn;
71785 #include <asm/emergency-restart.h>
71786
71787 #endif /* _LINUX_REBOOT_H */
71788 diff --git a/include/linux/regset.h b/include/linux/regset.h
71789 index 8e0c9fe..ac4d221 100644
71790 --- a/include/linux/regset.h
71791 +++ b/include/linux/regset.h
71792 @@ -161,7 +161,8 @@ struct user_regset {
71793 unsigned int align;
71794 unsigned int bias;
71795 unsigned int core_note_type;
71796 -};
71797 +} __do_const;
71798 +typedef struct user_regset __no_const user_regset_no_const;
71799
71800 /**
71801 * struct user_regset_view - available regsets
71802 diff --git a/include/linux/relay.h b/include/linux/relay.h
71803 index 91cacc3..b55ff74 100644
71804 --- a/include/linux/relay.h
71805 +++ b/include/linux/relay.h
71806 @@ -160,7 +160,7 @@ struct rchan_callbacks
71807 * The callback should return 0 if successful, negative if not.
71808 */
71809 int (*remove_buf_file)(struct dentry *dentry);
71810 -};
71811 +} __no_const;
71812
71813 /*
71814 * CONFIG_RELAY kernel API, kernel/relay.c
71815 diff --git a/include/linux/rio.h b/include/linux/rio.h
71816 index a3e7842..d973ca6 100644
71817 --- a/include/linux/rio.h
71818 +++ b/include/linux/rio.h
71819 @@ -339,7 +339,7 @@ struct rio_ops {
71820 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71821 u64 rstart, u32 size, u32 flags);
71822 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71823 -};
71824 +} __no_const;
71825
71826 #define RIO_RESOURCE_MEM 0x00000100
71827 #define RIO_RESOURCE_DOORBELL 0x00000200
71828 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71829 index c20635c..2f5def4 100644
71830 --- a/include/linux/rmap.h
71831 +++ b/include/linux/rmap.h
71832 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71833 void anon_vma_init(void); /* create anon_vma_cachep */
71834 int anon_vma_prepare(struct vm_area_struct *);
71835 void unlink_anon_vmas(struct vm_area_struct *);
71836 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71837 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71838 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71839 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71840
71841 static inline void anon_vma_merge(struct vm_area_struct *vma,
71842 struct vm_area_struct *next)
71843 diff --git a/include/linux/sched.h b/include/linux/sched.h
71844 index 7e49270..835d8d9 100644
71845 --- a/include/linux/sched.h
71846 +++ b/include/linux/sched.h
71847 @@ -61,6 +61,7 @@ struct bio_list;
71848 struct fs_struct;
71849 struct perf_event_context;
71850 struct blk_plug;
71851 +struct linux_binprm;
71852
71853 /*
71854 * List of flags we want to share for kernel threads,
71855 @@ -328,7 +329,7 @@ extern char __sched_text_start[], __sched_text_end[];
71856 extern int in_sched_functions(unsigned long addr);
71857
71858 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71859 -extern signed long schedule_timeout(signed long timeout);
71860 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71861 extern signed long schedule_timeout_interruptible(signed long timeout);
71862 extern signed long schedule_timeout_killable(signed long timeout);
71863 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71864 @@ -355,10 +356,23 @@ struct user_namespace;
71865 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71866
71867 extern int sysctl_max_map_count;
71868 +extern unsigned long sysctl_heap_stack_gap;
71869
71870 #include <linux/aio.h>
71871
71872 #ifdef CONFIG_MMU
71873 +
71874 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71875 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71876 +#else
71877 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71878 +{
71879 + return 0;
71880 +}
71881 +#endif
71882 +
71883 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71884 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71885 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71886 extern unsigned long
71887 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71888 @@ -640,6 +654,17 @@ struct signal_struct {
71889 #ifdef CONFIG_TASKSTATS
71890 struct taskstats *stats;
71891 #endif
71892 +
71893 +#ifdef CONFIG_GRKERNSEC
71894 + u32 curr_ip;
71895 + u32 saved_ip;
71896 + u32 gr_saddr;
71897 + u32 gr_daddr;
71898 + u16 gr_sport;
71899 + u16 gr_dport;
71900 + u8 used_accept:1;
71901 +#endif
71902 +
71903 #ifdef CONFIG_AUDIT
71904 unsigned audit_tty;
71905 struct tty_audit_buf *tty_audit_buf;
71906 @@ -718,6 +743,11 @@ struct user_struct {
71907 struct key *session_keyring; /* UID's default session keyring */
71908 #endif
71909
71910 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71911 + unsigned int banned;
71912 + unsigned long ban_expires;
71913 +#endif
71914 +
71915 /* Hash table maintenance information */
71916 struct hlist_node uidhash_node;
71917 kuid_t uid;
71918 @@ -1117,7 +1147,7 @@ struct sched_class {
71919 #ifdef CONFIG_FAIR_GROUP_SCHED
71920 void (*task_move_group) (struct task_struct *p, int on_rq);
71921 #endif
71922 -};
71923 +} __do_const;
71924
71925 struct load_weight {
71926 unsigned long weight, inv_weight;
71927 @@ -1361,8 +1391,8 @@ struct task_struct {
71928 struct list_head thread_group;
71929
71930 struct completion *vfork_done; /* for vfork() */
71931 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71932 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71933 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71934 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71935
71936 cputime_t utime, stime, utimescaled, stimescaled;
71937 cputime_t gtime;
71938 @@ -1378,11 +1408,6 @@ struct task_struct {
71939 struct task_cputime cputime_expires;
71940 struct list_head cpu_timers[3];
71941
71942 -/* process credentials */
71943 - const struct cred __rcu *real_cred; /* objective and real subjective task
71944 - * credentials (COW) */
71945 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71946 - * credentials (COW) */
71947 char comm[TASK_COMM_LEN]; /* executable name excluding path
71948 - access with [gs]et_task_comm (which lock
71949 it with task_lock())
71950 @@ -1399,6 +1424,10 @@ struct task_struct {
71951 #endif
71952 /* CPU-specific state of this task */
71953 struct thread_struct thread;
71954 +/* thread_info moved to task_struct */
71955 +#ifdef CONFIG_X86
71956 + struct thread_info tinfo;
71957 +#endif
71958 /* filesystem information */
71959 struct fs_struct *fs;
71960 /* open file information */
71961 @@ -1472,6 +1501,10 @@ struct task_struct {
71962 gfp_t lockdep_reclaim_gfp;
71963 #endif
71964
71965 +/* process credentials */
71966 + const struct cred __rcu *real_cred; /* objective and real subjective task
71967 + * credentials (COW) */
71968 +
71969 /* journalling filesystem info */
71970 void *journal_info;
71971
71972 @@ -1510,6 +1543,10 @@ struct task_struct {
71973 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71974 struct list_head cg_list;
71975 #endif
71976 +
71977 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71978 + * credentials (COW) */
71979 +
71980 #ifdef CONFIG_FUTEX
71981 struct robust_list_head __user *robust_list;
71982 #ifdef CONFIG_COMPAT
71983 @@ -1606,8 +1643,74 @@ struct task_struct {
71984 #ifdef CONFIG_UPROBES
71985 struct uprobe_task *utask;
71986 #endif
71987 +
71988 +#ifdef CONFIG_GRKERNSEC
71989 + /* grsecurity */
71990 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71991 + u64 exec_id;
71992 +#endif
71993 +#ifdef CONFIG_GRKERNSEC_SETXID
71994 + const struct cred *delayed_cred;
71995 +#endif
71996 + struct dentry *gr_chroot_dentry;
71997 + struct acl_subject_label *acl;
71998 + struct acl_role_label *role;
71999 + struct file *exec_file;
72000 + unsigned long brute_expires;
72001 + u16 acl_role_id;
72002 + /* is this the task that authenticated to the special role */
72003 + u8 acl_sp_role;
72004 + u8 is_writable;
72005 + u8 brute;
72006 + u8 gr_is_chrooted;
72007 +#endif
72008 +
72009 };
72010
72011 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
72012 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
72013 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
72014 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
72015 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
72016 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
72017 +
72018 +#ifdef CONFIG_PAX_SOFTMODE
72019 +extern int pax_softmode;
72020 +#endif
72021 +
72022 +extern int pax_check_flags(unsigned long *);
72023 +
72024 +/* if tsk != current then task_lock must be held on it */
72025 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
72026 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
72027 +{
72028 + if (likely(tsk->mm))
72029 + return tsk->mm->pax_flags;
72030 + else
72031 + return 0UL;
72032 +}
72033 +
72034 +/* if tsk != current then task_lock must be held on it */
72035 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
72036 +{
72037 + if (likely(tsk->mm)) {
72038 + tsk->mm->pax_flags = flags;
72039 + return 0;
72040 + }
72041 + return -EINVAL;
72042 +}
72043 +#endif
72044 +
72045 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
72046 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
72047 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
72048 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
72049 +#endif
72050 +
72051 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
72052 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
72053 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
72054 +
72055 /* Future-safe accessor for struct task_struct's cpus_allowed. */
72056 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
72057
72058 @@ -1697,7 +1800,7 @@ struct pid_namespace;
72059 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
72060 struct pid_namespace *ns);
72061
72062 -static inline pid_t task_pid_nr(struct task_struct *tsk)
72063 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
72064 {
72065 return tsk->pid;
72066 }
72067 @@ -2156,7 +2259,9 @@ void yield(void);
72068 extern struct exec_domain default_exec_domain;
72069
72070 union thread_union {
72071 +#ifndef CONFIG_X86
72072 struct thread_info thread_info;
72073 +#endif
72074 unsigned long stack[THREAD_SIZE/sizeof(long)];
72075 };
72076
72077 @@ -2189,6 +2294,7 @@ extern struct pid_namespace init_pid_ns;
72078 */
72079
72080 extern struct task_struct *find_task_by_vpid(pid_t nr);
72081 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
72082 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
72083 struct pid_namespace *ns);
72084
72085 @@ -2345,7 +2451,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
72086 extern void exit_itimers(struct signal_struct *);
72087 extern void flush_itimer_signals(void);
72088
72089 -extern void do_group_exit(int);
72090 +extern __noreturn void do_group_exit(int);
72091
72092 extern int allow_signal(int);
72093 extern int disallow_signal(int);
72094 @@ -2546,9 +2652,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
72095
72096 #endif
72097
72098 -static inline int object_is_on_stack(void *obj)
72099 +static inline int object_starts_on_stack(void *obj)
72100 {
72101 - void *stack = task_stack_page(current);
72102 + const void *stack = task_stack_page(current);
72103
72104 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
72105 }
72106 diff --git a/include/linux/security.h b/include/linux/security.h
72107 index eee7478..290f7ba 100644
72108 --- a/include/linux/security.h
72109 +++ b/include/linux/security.h
72110 @@ -26,6 +26,7 @@
72111 #include <linux/capability.h>
72112 #include <linux/slab.h>
72113 #include <linux/err.h>
72114 +#include <linux/grsecurity.h>
72115
72116 struct linux_binprm;
72117 struct cred;
72118 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
72119 index 68a04a3..866e6a1 100644
72120 --- a/include/linux/seq_file.h
72121 +++ b/include/linux/seq_file.h
72122 @@ -26,6 +26,9 @@ struct seq_file {
72123 struct mutex lock;
72124 const struct seq_operations *op;
72125 int poll_event;
72126 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
72127 + u64 exec_id;
72128 +#endif
72129 #ifdef CONFIG_USER_NS
72130 struct user_namespace *user_ns;
72131 #endif
72132 @@ -38,6 +41,7 @@ struct seq_operations {
72133 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
72134 int (*show) (struct seq_file *m, void *v);
72135 };
72136 +typedef struct seq_operations __no_const seq_operations_no_const;
72137
72138 #define SEQ_SKIP 1
72139
72140 diff --git a/include/linux/shm.h b/include/linux/shm.h
72141 index 429c199..4d42e38 100644
72142 --- a/include/linux/shm.h
72143 +++ b/include/linux/shm.h
72144 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
72145
72146 /* The task created the shm object. NULL if the task is dead. */
72147 struct task_struct *shm_creator;
72148 +#ifdef CONFIG_GRKERNSEC
72149 + time_t shm_createtime;
72150 + pid_t shm_lapid;
72151 +#endif
72152 };
72153
72154 /* shm_mode upper byte flags */
72155 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
72156 index 98399e2..7c74c41 100644
72157 --- a/include/linux/skbuff.h
72158 +++ b/include/linux/skbuff.h
72159 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
72160 extern struct sk_buff *__alloc_skb(unsigned int size,
72161 gfp_t priority, int flags, int node);
72162 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
72163 -static inline struct sk_buff *alloc_skb(unsigned int size,
72164 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
72165 gfp_t priority)
72166 {
72167 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
72168 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
72169 */
72170 static inline int skb_queue_empty(const struct sk_buff_head *list)
72171 {
72172 - return list->next == (struct sk_buff *)list;
72173 + return list->next == (const struct sk_buff *)list;
72174 }
72175
72176 /**
72177 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
72178 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
72179 const struct sk_buff *skb)
72180 {
72181 - return skb->next == (struct sk_buff *)list;
72182 + return skb->next == (const struct sk_buff *)list;
72183 }
72184
72185 /**
72186 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
72187 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
72188 const struct sk_buff *skb)
72189 {
72190 - return skb->prev == (struct sk_buff *)list;
72191 + return skb->prev == (const struct sk_buff *)list;
72192 }
72193
72194 /**
72195 @@ -1727,7 +1727,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
72196 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
72197 */
72198 #ifndef NET_SKB_PAD
72199 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
72200 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
72201 #endif
72202
72203 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
72204 @@ -2305,7 +2305,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
72205 int noblock, int *err);
72206 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
72207 struct poll_table_struct *wait);
72208 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
72209 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
72210 int offset, struct iovec *to,
72211 int size);
72212 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
72213 @@ -2595,6 +2595,9 @@ static inline void nf_reset(struct sk_buff *skb)
72214 nf_bridge_put(skb->nf_bridge);
72215 skb->nf_bridge = NULL;
72216 #endif
72217 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
72218 + skb->nf_trace = 0;
72219 +#endif
72220 }
72221
72222 /* Note: This doesn't put any conntrack and bridge info in dst. */
72223 diff --git a/include/linux/slab.h b/include/linux/slab.h
72224 index 5d168d7..720bff3 100644
72225 --- a/include/linux/slab.h
72226 +++ b/include/linux/slab.h
72227 @@ -12,13 +12,20 @@
72228 #include <linux/gfp.h>
72229 #include <linux/types.h>
72230 #include <linux/workqueue.h>
72231 -
72232 +#include <linux/err.h>
72233
72234 /*
72235 * Flags to pass to kmem_cache_create().
72236 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
72237 */
72238 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
72239 +
72240 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72241 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
72242 +#else
72243 +#define SLAB_USERCOPY 0x00000000UL
72244 +#endif
72245 +
72246 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
72247 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
72248 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
72249 @@ -89,10 +96,13 @@
72250 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
72251 * Both make kfree a no-op.
72252 */
72253 -#define ZERO_SIZE_PTR ((void *)16)
72254 +#define ZERO_SIZE_PTR \
72255 +({ \
72256 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
72257 + (void *)(-MAX_ERRNO-1L); \
72258 +})
72259
72260 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
72261 - (unsigned long)ZERO_SIZE_PTR)
72262 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
72263
72264 /*
72265 * Common fields provided in kmem_cache by all slab allocators
72266 @@ -112,7 +122,7 @@ struct kmem_cache {
72267 unsigned int align; /* Alignment as calculated */
72268 unsigned long flags; /* Active flags on the slab */
72269 const char *name; /* Slab name for sysfs */
72270 - int refcount; /* Use counter */
72271 + atomic_t refcount; /* Use counter */
72272 void (*ctor)(void *); /* Called on object slot creation */
72273 struct list_head list; /* List of all slab caches on the system */
72274 };
72275 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
72276 void kfree(const void *);
72277 void kzfree(const void *);
72278 size_t ksize(const void *);
72279 +const char *check_heap_object(const void *ptr, unsigned long n);
72280 +bool is_usercopy_object(const void *ptr);
72281
72282 /*
72283 * Allocator specific definitions. These are mainly used to establish optimized
72284 @@ -311,6 +323,7 @@ size_t ksize(const void *);
72285 * for general use, and so are not documented here. For a full list of
72286 * potential flags, always refer to linux/gfp.h.
72287 */
72288 +
72289 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
72290 {
72291 if (size != 0 && n > SIZE_MAX / size)
72292 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
72293 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
72294 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
72295 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
72296 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
72297 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
72298 #define kmalloc_track_caller(size, flags) \
72299 __kmalloc_track_caller(size, flags, _RET_IP_)
72300 #else
72301 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
72302 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
72303 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
72304 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
72305 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
72306 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
72307 #define kmalloc_node_track_caller(size, flags, node) \
72308 __kmalloc_node_track_caller(size, flags, node, \
72309 _RET_IP_)
72310 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
72311 index 8bb6e0e..8eb0dbe 100644
72312 --- a/include/linux/slab_def.h
72313 +++ b/include/linux/slab_def.h
72314 @@ -52,7 +52,7 @@ struct kmem_cache {
72315 /* 4) cache creation/removal */
72316 const char *name;
72317 struct list_head list;
72318 - int refcount;
72319 + atomic_t refcount;
72320 int object_size;
72321 int align;
72322
72323 @@ -68,10 +68,10 @@ struct kmem_cache {
72324 unsigned long node_allocs;
72325 unsigned long node_frees;
72326 unsigned long node_overflow;
72327 - atomic_t allochit;
72328 - atomic_t allocmiss;
72329 - atomic_t freehit;
72330 - atomic_t freemiss;
72331 + atomic_unchecked_t allochit;
72332 + atomic_unchecked_t allocmiss;
72333 + atomic_unchecked_t freehit;
72334 + atomic_unchecked_t freemiss;
72335
72336 /*
72337 * If debugging is enabled, then the allocator can add additional
72338 @@ -111,11 +111,16 @@ struct cache_sizes {
72339 #ifdef CONFIG_ZONE_DMA
72340 struct kmem_cache *cs_dmacachep;
72341 #endif
72342 +
72343 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72344 + struct kmem_cache *cs_usercopycachep;
72345 +#endif
72346 +
72347 };
72348 extern struct cache_sizes malloc_sizes[];
72349
72350 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72351 -void *__kmalloc(size_t size, gfp_t flags);
72352 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
72353
72354 #ifdef CONFIG_TRACING
72355 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
72356 @@ -152,6 +157,13 @@ found:
72357 cachep = malloc_sizes[i].cs_dmacachep;
72358 else
72359 #endif
72360 +
72361 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72362 + if (flags & GFP_USERCOPY)
72363 + cachep = malloc_sizes[i].cs_usercopycachep;
72364 + else
72365 +#endif
72366 +
72367 cachep = malloc_sizes[i].cs_cachep;
72368
72369 ret = kmem_cache_alloc_trace(cachep, flags, size);
72370 @@ -162,7 +174,7 @@ found:
72371 }
72372
72373 #ifdef CONFIG_NUMA
72374 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
72375 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72376 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72377
72378 #ifdef CONFIG_TRACING
72379 @@ -205,6 +217,13 @@ found:
72380 cachep = malloc_sizes[i].cs_dmacachep;
72381 else
72382 #endif
72383 +
72384 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72385 + if (flags & GFP_USERCOPY)
72386 + cachep = malloc_sizes[i].cs_usercopycachep;
72387 + else
72388 +#endif
72389 +
72390 cachep = malloc_sizes[i].cs_cachep;
72391
72392 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
72393 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
72394 index f28e14a..7831211 100644
72395 --- a/include/linux/slob_def.h
72396 +++ b/include/linux/slob_def.h
72397 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
72398 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
72399 }
72400
72401 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72402 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72403
72404 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72405 {
72406 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72407 return __kmalloc_node(size, flags, NUMA_NO_NODE);
72408 }
72409
72410 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
72411 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
72412 {
72413 return kmalloc(size, flags);
72414 }
72415 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
72416 index 9db4825..ed42fb5 100644
72417 --- a/include/linux/slub_def.h
72418 +++ b/include/linux/slub_def.h
72419 @@ -91,7 +91,7 @@ struct kmem_cache {
72420 struct kmem_cache_order_objects max;
72421 struct kmem_cache_order_objects min;
72422 gfp_t allocflags; /* gfp flags to use on each alloc */
72423 - int refcount; /* Refcount for slab cache destroy */
72424 + atomic_t refcount; /* Refcount for slab cache destroy */
72425 void (*ctor)(void *);
72426 int inuse; /* Offset to metadata */
72427 int align; /* Alignment */
72428 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
72429 * Sorry that the following has to be that ugly but some versions of GCC
72430 * have trouble with constant propagation and loops.
72431 */
72432 -static __always_inline int kmalloc_index(size_t size)
72433 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
72434 {
72435 if (!size)
72436 return 0;
72437 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
72438 }
72439
72440 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72441 -void *__kmalloc(size_t size, gfp_t flags);
72442 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
72443
72444 static __always_inline void *
72445 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
72446 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
72447 }
72448 #endif
72449
72450 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
72451 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
72452 {
72453 unsigned int order = get_order(size);
72454 return kmalloc_order_trace(size, flags, order);
72455 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72456 }
72457
72458 #ifdef CONFIG_NUMA
72459 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72460 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72461 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72462
72463 #ifdef CONFIG_TRACING
72464 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
72465 index e8d702e..0a56eb4 100644
72466 --- a/include/linux/sock_diag.h
72467 +++ b/include/linux/sock_diag.h
72468 @@ -10,7 +10,7 @@ struct sock;
72469 struct sock_diag_handler {
72470 __u8 family;
72471 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
72472 -};
72473 +} __do_const;
72474
72475 int sock_diag_register(const struct sock_diag_handler *h);
72476 void sock_diag_unregister(const struct sock_diag_handler *h);
72477 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
72478 index 680f9a3..f13aeb0 100644
72479 --- a/include/linux/sonet.h
72480 +++ b/include/linux/sonet.h
72481 @@ -7,7 +7,7 @@
72482 #include <uapi/linux/sonet.h>
72483
72484 struct k_sonet_stats {
72485 -#define __HANDLE_ITEM(i) atomic_t i
72486 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72487 __SONET_ITEMS
72488 #undef __HANDLE_ITEM
72489 };
72490 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
72491 index 34206b8..3db7f1c 100644
72492 --- a/include/linux/sunrpc/clnt.h
72493 +++ b/include/linux/sunrpc/clnt.h
72494 @@ -96,7 +96,7 @@ struct rpc_procinfo {
72495 unsigned int p_timer; /* Which RTT timer to use */
72496 u32 p_statidx; /* Which procedure to account */
72497 const char * p_name; /* name of procedure */
72498 -};
72499 +} __do_const;
72500
72501 #ifdef __KERNEL__
72502
72503 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
72504 {
72505 switch (sap->sa_family) {
72506 case AF_INET:
72507 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
72508 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
72509 case AF_INET6:
72510 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
72511 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
72512 }
72513 return 0;
72514 }
72515 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
72516 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
72517 const struct sockaddr *src)
72518 {
72519 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
72520 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
72521 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
72522
72523 dsin->sin_family = ssin->sin_family;
72524 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
72525 if (sa->sa_family != AF_INET6)
72526 return 0;
72527
72528 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
72529 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
72530 }
72531
72532 #endif /* __KERNEL__ */
72533 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
72534 index 676ddf5..4c519a1 100644
72535 --- a/include/linux/sunrpc/svc.h
72536 +++ b/include/linux/sunrpc/svc.h
72537 @@ -410,7 +410,7 @@ struct svc_procedure {
72538 unsigned int pc_count; /* call count */
72539 unsigned int pc_cachetype; /* cache info (NFS) */
72540 unsigned int pc_xdrressize; /* maximum size of XDR reply */
72541 -};
72542 +} __do_const;
72543
72544 /*
72545 * Function prototypes.
72546 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
72547 index 0b8e3e6..33e0a01 100644
72548 --- a/include/linux/sunrpc/svc_rdma.h
72549 +++ b/include/linux/sunrpc/svc_rdma.h
72550 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
72551 extern unsigned int svcrdma_max_requests;
72552 extern unsigned int svcrdma_max_req_size;
72553
72554 -extern atomic_t rdma_stat_recv;
72555 -extern atomic_t rdma_stat_read;
72556 -extern atomic_t rdma_stat_write;
72557 -extern atomic_t rdma_stat_sq_starve;
72558 -extern atomic_t rdma_stat_rq_starve;
72559 -extern atomic_t rdma_stat_rq_poll;
72560 -extern atomic_t rdma_stat_rq_prod;
72561 -extern atomic_t rdma_stat_sq_poll;
72562 -extern atomic_t rdma_stat_sq_prod;
72563 +extern atomic_unchecked_t rdma_stat_recv;
72564 +extern atomic_unchecked_t rdma_stat_read;
72565 +extern atomic_unchecked_t rdma_stat_write;
72566 +extern atomic_unchecked_t rdma_stat_sq_starve;
72567 +extern atomic_unchecked_t rdma_stat_rq_starve;
72568 +extern atomic_unchecked_t rdma_stat_rq_poll;
72569 +extern atomic_unchecked_t rdma_stat_rq_prod;
72570 +extern atomic_unchecked_t rdma_stat_sq_poll;
72571 +extern atomic_unchecked_t rdma_stat_sq_prod;
72572
72573 #define RPCRDMA_VERSION 1
72574
72575 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
72576 index dd74084a..7f509d5 100644
72577 --- a/include/linux/sunrpc/svcauth.h
72578 +++ b/include/linux/sunrpc/svcauth.h
72579 @@ -109,7 +109,7 @@ struct auth_ops {
72580 int (*release)(struct svc_rqst *rq);
72581 void (*domain_release)(struct auth_domain *);
72582 int (*set_client)(struct svc_rqst *rq);
72583 -};
72584 +} __do_const;
72585
72586 #define SVC_GARBAGE 1
72587 #define SVC_SYSERR 2
72588 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
72589 index 071d62c..4ccc7ac 100644
72590 --- a/include/linux/swiotlb.h
72591 +++ b/include/linux/swiotlb.h
72592 @@ -59,7 +59,8 @@ extern void
72593
72594 extern void
72595 swiotlb_free_coherent(struct device *hwdev, size_t size,
72596 - void *vaddr, dma_addr_t dma_handle);
72597 + void *vaddr, dma_addr_t dma_handle,
72598 + struct dma_attrs *attrs);
72599
72600 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
72601 unsigned long offset, size_t size,
72602 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
72603 index 45e2db2..1635156a 100644
72604 --- a/include/linux/syscalls.h
72605 +++ b/include/linux/syscalls.h
72606 @@ -615,7 +615,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72607 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72608 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72609 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72610 - struct sockaddr __user *, int);
72611 + struct sockaddr __user *, int) __intentional_overflow(0);
72612 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72613 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72614 unsigned int vlen, unsigned flags);
72615 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72616 index 27b3b0b..e093dd9 100644
72617 --- a/include/linux/syscore_ops.h
72618 +++ b/include/linux/syscore_ops.h
72619 @@ -16,7 +16,7 @@ struct syscore_ops {
72620 int (*suspend)(void);
72621 void (*resume)(void);
72622 void (*shutdown)(void);
72623 -};
72624 +} __do_const;
72625
72626 extern void register_syscore_ops(struct syscore_ops *ops);
72627 extern void unregister_syscore_ops(struct syscore_ops *ops);
72628 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72629 index 14a8ff2..af52bad 100644
72630 --- a/include/linux/sysctl.h
72631 +++ b/include/linux/sysctl.h
72632 @@ -34,13 +34,13 @@ struct ctl_table_root;
72633 struct ctl_table_header;
72634 struct ctl_dir;
72635
72636 -typedef struct ctl_table ctl_table;
72637 -
72638 typedef int proc_handler (struct ctl_table *ctl, int write,
72639 void __user *buffer, size_t *lenp, loff_t *ppos);
72640
72641 extern int proc_dostring(struct ctl_table *, int,
72642 void __user *, size_t *, loff_t *);
72643 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72644 + void __user *, size_t *, loff_t *);
72645 extern int proc_dointvec(struct ctl_table *, int,
72646 void __user *, size_t *, loff_t *);
72647 extern int proc_dointvec_minmax(struct ctl_table *, int,
72648 @@ -115,7 +115,9 @@ struct ctl_table
72649 struct ctl_table_poll *poll;
72650 void *extra1;
72651 void *extra2;
72652 -};
72653 +} __do_const;
72654 +typedef struct ctl_table __no_const ctl_table_no_const;
72655 +typedef struct ctl_table ctl_table;
72656
72657 struct ctl_node {
72658 struct rb_node node;
72659 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72660 index 381f06d..dc16cc7 100644
72661 --- a/include/linux/sysfs.h
72662 +++ b/include/linux/sysfs.h
72663 @@ -31,7 +31,8 @@ struct attribute {
72664 struct lock_class_key *key;
72665 struct lock_class_key skey;
72666 #endif
72667 -};
72668 +} __do_const;
72669 +typedef struct attribute __no_const attribute_no_const;
72670
72671 /**
72672 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72673 @@ -59,8 +60,8 @@ struct attribute_group {
72674 umode_t (*is_visible)(struct kobject *,
72675 struct attribute *, int);
72676 struct attribute **attrs;
72677 -};
72678 -
72679 +} __do_const;
72680 +typedef struct attribute_group __no_const attribute_group_no_const;
72681
72682
72683 /**
72684 @@ -107,7 +108,8 @@ struct bin_attribute {
72685 char *, loff_t, size_t);
72686 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72687 struct vm_area_struct *vma);
72688 -};
72689 +} __do_const;
72690 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72691
72692 /**
72693 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72694 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72695 index 7faf933..9b85a0c 100644
72696 --- a/include/linux/sysrq.h
72697 +++ b/include/linux/sysrq.h
72698 @@ -16,6 +16,7 @@
72699
72700 #include <linux/errno.h>
72701 #include <linux/types.h>
72702 +#include <linux/compiler.h>
72703
72704 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72705 #define SYSRQ_DEFAULT_ENABLE 1
72706 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72707 char *help_msg;
72708 char *action_msg;
72709 int enable_mask;
72710 -};
72711 +} __do_const;
72712
72713 #ifdef CONFIG_MAGIC_SYSRQ
72714
72715 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72716 index e7e0473..7989295 100644
72717 --- a/include/linux/thread_info.h
72718 +++ b/include/linux/thread_info.h
72719 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72720 #error "no set_restore_sigmask() provided and default one won't work"
72721 #endif
72722
72723 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72724 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72725 +{
72726 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72727 + if (!__builtin_constant_p(n))
72728 +#endif
72729 + __check_object_size(ptr, n, to_user);
72730 +}
72731 +
72732 #endif /* __KERNEL__ */
72733
72734 #endif /* _LINUX_THREAD_INFO_H */
72735 diff --git a/include/linux/tty.h b/include/linux/tty.h
72736 index 8db1b56..c16a040 100644
72737 --- a/include/linux/tty.h
72738 +++ b/include/linux/tty.h
72739 @@ -194,7 +194,7 @@ struct tty_port {
72740 const struct tty_port_operations *ops; /* Port operations */
72741 spinlock_t lock; /* Lock protecting tty field */
72742 int blocked_open; /* Waiting to open */
72743 - int count; /* Usage count */
72744 + atomic_t count; /* Usage count */
72745 wait_queue_head_t open_wait; /* Open waiters */
72746 wait_queue_head_t close_wait; /* Close waiters */
72747 wait_queue_head_t delta_msr_wait; /* Modem status change */
72748 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
72749 struct tty_struct *tty, struct file *filp);
72750 static inline int tty_port_users(struct tty_port *port)
72751 {
72752 - return port->count + port->blocked_open;
72753 + return atomic_read(&port->count) + port->blocked_open;
72754 }
72755
72756 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72757 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72758 index dd976cf..e272742 100644
72759 --- a/include/linux/tty_driver.h
72760 +++ b/include/linux/tty_driver.h
72761 @@ -284,7 +284,7 @@ struct tty_operations {
72762 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72763 #endif
72764 const struct file_operations *proc_fops;
72765 -};
72766 +} __do_const;
72767
72768 struct tty_driver {
72769 int magic; /* magic number for this structure */
72770 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72771 index fb79dd8d..07d4773 100644
72772 --- a/include/linux/tty_ldisc.h
72773 +++ b/include/linux/tty_ldisc.h
72774 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
72775
72776 struct module *owner;
72777
72778 - int refcount;
72779 + atomic_t refcount;
72780 };
72781
72782 struct tty_ldisc {
72783 diff --git a/include/linux/types.h b/include/linux/types.h
72784 index 4d118ba..c3ee9bf 100644
72785 --- a/include/linux/types.h
72786 +++ b/include/linux/types.h
72787 @@ -176,10 +176,26 @@ typedef struct {
72788 int counter;
72789 } atomic_t;
72790
72791 +#ifdef CONFIG_PAX_REFCOUNT
72792 +typedef struct {
72793 + int counter;
72794 +} atomic_unchecked_t;
72795 +#else
72796 +typedef atomic_t atomic_unchecked_t;
72797 +#endif
72798 +
72799 #ifdef CONFIG_64BIT
72800 typedef struct {
72801 long counter;
72802 } atomic64_t;
72803 +
72804 +#ifdef CONFIG_PAX_REFCOUNT
72805 +typedef struct {
72806 + long counter;
72807 +} atomic64_unchecked_t;
72808 +#else
72809 +typedef atomic64_t atomic64_unchecked_t;
72810 +#endif
72811 #endif
72812
72813 struct list_head {
72814 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72815 index 5ca0951..ab496a5 100644
72816 --- a/include/linux/uaccess.h
72817 +++ b/include/linux/uaccess.h
72818 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72819 long ret; \
72820 mm_segment_t old_fs = get_fs(); \
72821 \
72822 - set_fs(KERNEL_DS); \
72823 pagefault_disable(); \
72824 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72825 - pagefault_enable(); \
72826 + set_fs(KERNEL_DS); \
72827 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72828 set_fs(old_fs); \
72829 + pagefault_enable(); \
72830 ret; \
72831 })
72832
72833 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72834 index 8e522cbc..aa8572d 100644
72835 --- a/include/linux/uidgid.h
72836 +++ b/include/linux/uidgid.h
72837 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72838
72839 #endif /* CONFIG_USER_NS */
72840
72841 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72842 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72843 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72844 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72845 +
72846 #endif /* _LINUX_UIDGID_H */
72847 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72848 index 99c1b4d..562e6f3 100644
72849 --- a/include/linux/unaligned/access_ok.h
72850 +++ b/include/linux/unaligned/access_ok.h
72851 @@ -4,34 +4,34 @@
72852 #include <linux/kernel.h>
72853 #include <asm/byteorder.h>
72854
72855 -static inline u16 get_unaligned_le16(const void *p)
72856 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72857 {
72858 - return le16_to_cpup((__le16 *)p);
72859 + return le16_to_cpup((const __le16 *)p);
72860 }
72861
72862 -static inline u32 get_unaligned_le32(const void *p)
72863 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72864 {
72865 - return le32_to_cpup((__le32 *)p);
72866 + return le32_to_cpup((const __le32 *)p);
72867 }
72868
72869 -static inline u64 get_unaligned_le64(const void *p)
72870 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72871 {
72872 - return le64_to_cpup((__le64 *)p);
72873 + return le64_to_cpup((const __le64 *)p);
72874 }
72875
72876 -static inline u16 get_unaligned_be16(const void *p)
72877 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72878 {
72879 - return be16_to_cpup((__be16 *)p);
72880 + return be16_to_cpup((const __be16 *)p);
72881 }
72882
72883 -static inline u32 get_unaligned_be32(const void *p)
72884 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72885 {
72886 - return be32_to_cpup((__be32 *)p);
72887 + return be32_to_cpup((const __be32 *)p);
72888 }
72889
72890 -static inline u64 get_unaligned_be64(const void *p)
72891 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72892 {
72893 - return be64_to_cpup((__be64 *)p);
72894 + return be64_to_cpup((const __be64 *)p);
72895 }
72896
72897 static inline void put_unaligned_le16(u16 val, void *p)
72898 diff --git a/include/linux/usb.h b/include/linux/usb.h
72899 index 4d22d0f..8d0e8f8 100644
72900 --- a/include/linux/usb.h
72901 +++ b/include/linux/usb.h
72902 @@ -554,7 +554,7 @@ struct usb_device {
72903 int maxchild;
72904
72905 u32 quirks;
72906 - atomic_t urbnum;
72907 + atomic_unchecked_t urbnum;
72908
72909 unsigned long active_duration;
72910
72911 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72912
72913 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72914 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72915 - void *data, __u16 size, int timeout);
72916 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72917 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72918 void *data, int len, int *actual_length, int timeout);
72919 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72920 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72921 index c5d36c6..108f4f9 100644
72922 --- a/include/linux/usb/renesas_usbhs.h
72923 +++ b/include/linux/usb/renesas_usbhs.h
72924 @@ -39,7 +39,7 @@ enum {
72925 */
72926 struct renesas_usbhs_driver_callback {
72927 int (*notify_hotplug)(struct platform_device *pdev);
72928 -};
72929 +} __no_const;
72930
72931 /*
72932 * callback functions for platform
72933 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
72934 index 5209cfe..b6b215f 100644
72935 --- a/include/linux/user_namespace.h
72936 +++ b/include/linux/user_namespace.h
72937 @@ -21,7 +21,7 @@ struct user_namespace {
72938 struct uid_gid_map uid_map;
72939 struct uid_gid_map gid_map;
72940 struct uid_gid_map projid_map;
72941 - struct kref kref;
72942 + atomic_t count;
72943 struct user_namespace *parent;
72944 kuid_t owner;
72945 kgid_t group;
72946 @@ -37,18 +37,18 @@ extern struct user_namespace init_user_ns;
72947 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
72948 {
72949 if (ns)
72950 - kref_get(&ns->kref);
72951 + atomic_inc(&ns->count);
72952 return ns;
72953 }
72954
72955 extern int create_user_ns(struct cred *new);
72956 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
72957 -extern void free_user_ns(struct kref *kref);
72958 +extern void free_user_ns(struct user_namespace *ns);
72959
72960 static inline void put_user_ns(struct user_namespace *ns)
72961 {
72962 - if (ns)
72963 - kref_put(&ns->kref, free_user_ns);
72964 + if (ns && atomic_dec_and_test(&ns->count))
72965 + free_user_ns(ns);
72966 }
72967
72968 struct seq_operations;
72969 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72970 index 6f8fbcf..8259001 100644
72971 --- a/include/linux/vermagic.h
72972 +++ b/include/linux/vermagic.h
72973 @@ -25,9 +25,35 @@
72974 #define MODULE_ARCH_VERMAGIC ""
72975 #endif
72976
72977 +#ifdef CONFIG_PAX_REFCOUNT
72978 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72979 +#else
72980 +#define MODULE_PAX_REFCOUNT ""
72981 +#endif
72982 +
72983 +#ifdef CONSTIFY_PLUGIN
72984 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72985 +#else
72986 +#define MODULE_CONSTIFY_PLUGIN ""
72987 +#endif
72988 +
72989 +#ifdef STACKLEAK_PLUGIN
72990 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72991 +#else
72992 +#define MODULE_STACKLEAK_PLUGIN ""
72993 +#endif
72994 +
72995 +#ifdef CONFIG_GRKERNSEC
72996 +#define MODULE_GRSEC "GRSEC "
72997 +#else
72998 +#define MODULE_GRSEC ""
72999 +#endif
73000 +
73001 #define VERMAGIC_STRING \
73002 UTS_RELEASE " " \
73003 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
73004 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
73005 - MODULE_ARCH_VERMAGIC
73006 + MODULE_ARCH_VERMAGIC \
73007 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
73008 + MODULE_GRSEC
73009
73010 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
73011 index 6071e91..ca6a489 100644
73012 --- a/include/linux/vmalloc.h
73013 +++ b/include/linux/vmalloc.h
73014 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
73015 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
73016 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
73017 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
73018 +
73019 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
73020 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
73021 +#endif
73022 +
73023 /* bits [20..32] reserved for arch specific ioremap internals */
73024
73025 /*
73026 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
73027 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
73028 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
73029 unsigned long start, unsigned long end, gfp_t gfp_mask,
73030 - pgprot_t prot, int node, const void *caller);
73031 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
73032 extern void vfree(const void *addr);
73033
73034 extern void *vmap(struct page **pages, unsigned int count,
73035 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
73036 extern void free_vm_area(struct vm_struct *area);
73037
73038 /* for /dev/kmem */
73039 -extern long vread(char *buf, char *addr, unsigned long count);
73040 -extern long vwrite(char *buf, char *addr, unsigned long count);
73041 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
73042 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
73043
73044 /*
73045 * Internals. Dont't use..
73046 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
73047 index a13291f..af51fa3 100644
73048 --- a/include/linux/vmstat.h
73049 +++ b/include/linux/vmstat.h
73050 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
73051 /*
73052 * Zone based page accounting with per cpu differentials.
73053 */
73054 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
73055 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
73056
73057 static inline void zone_page_state_add(long x, struct zone *zone,
73058 enum zone_stat_item item)
73059 {
73060 - atomic_long_add(x, &zone->vm_stat[item]);
73061 - atomic_long_add(x, &vm_stat[item]);
73062 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
73063 + atomic_long_add_unchecked(x, &vm_stat[item]);
73064 }
73065
73066 static inline unsigned long global_page_state(enum zone_stat_item item)
73067 {
73068 - long x = atomic_long_read(&vm_stat[item]);
73069 + long x = atomic_long_read_unchecked(&vm_stat[item]);
73070 #ifdef CONFIG_SMP
73071 if (x < 0)
73072 x = 0;
73073 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
73074 static inline unsigned long zone_page_state(struct zone *zone,
73075 enum zone_stat_item item)
73076 {
73077 - long x = atomic_long_read(&zone->vm_stat[item]);
73078 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
73079 #ifdef CONFIG_SMP
73080 if (x < 0)
73081 x = 0;
73082 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
73083 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
73084 enum zone_stat_item item)
73085 {
73086 - long x = atomic_long_read(&zone->vm_stat[item]);
73087 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
73088
73089 #ifdef CONFIG_SMP
73090 int cpu;
73091 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
73092
73093 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
73094 {
73095 - atomic_long_inc(&zone->vm_stat[item]);
73096 - atomic_long_inc(&vm_stat[item]);
73097 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
73098 + atomic_long_inc_unchecked(&vm_stat[item]);
73099 }
73100
73101 static inline void __inc_zone_page_state(struct page *page,
73102 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
73103
73104 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
73105 {
73106 - atomic_long_dec(&zone->vm_stat[item]);
73107 - atomic_long_dec(&vm_stat[item]);
73108 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
73109 + atomic_long_dec_unchecked(&vm_stat[item]);
73110 }
73111
73112 static inline void __dec_zone_page_state(struct page *page,
73113 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
73114 index fdbafc6..b7ffd47 100644
73115 --- a/include/linux/xattr.h
73116 +++ b/include/linux/xattr.h
73117 @@ -28,7 +28,7 @@ struct xattr_handler {
73118 size_t size, int handler_flags);
73119 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
73120 size_t size, int flags, int handler_flags);
73121 -};
73122 +} __do_const;
73123
73124 struct xattr {
73125 char *name;
73126 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
73127 index 9c5a6b4..09c9438 100644
73128 --- a/include/linux/zlib.h
73129 +++ b/include/linux/zlib.h
73130 @@ -31,6 +31,7 @@
73131 #define _ZLIB_H
73132
73133 #include <linux/zconf.h>
73134 +#include <linux/compiler.h>
73135
73136 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
73137 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
73138 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
73139
73140 /* basic functions */
73141
73142 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
73143 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
73144 /*
73145 Returns the number of bytes that needs to be allocated for a per-
73146 stream workspace with the specified parameters. A pointer to this
73147 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
73148 index 95d1c91..6798cca 100644
73149 --- a/include/media/v4l2-dev.h
73150 +++ b/include/media/v4l2-dev.h
73151 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
73152 int (*mmap) (struct file *, struct vm_area_struct *);
73153 int (*open) (struct file *);
73154 int (*release) (struct file *);
73155 -};
73156 +} __do_const;
73157
73158 /*
73159 * Newer version of video_device, handled by videodev2.c
73160 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
73161 index 4118ad1..cb7e25f 100644
73162 --- a/include/media/v4l2-ioctl.h
73163 +++ b/include/media/v4l2-ioctl.h
73164 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
73165 bool valid_prio, int cmd, void *arg);
73166 };
73167
73168 -
73169 /* v4l debugging and diagnostics */
73170
73171 /* Debug bitmask flags to be used on V4L2 */
73172 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
73173 index adcbb20..62c2559 100644
73174 --- a/include/net/9p/transport.h
73175 +++ b/include/net/9p/transport.h
73176 @@ -57,7 +57,7 @@ struct p9_trans_module {
73177 int (*cancel) (struct p9_client *, struct p9_req_t *req);
73178 int (*zc_request)(struct p9_client *, struct p9_req_t *,
73179 char *, char *, int , int, int, int);
73180 -};
73181 +} __do_const;
73182
73183 void v9fs_register_trans(struct p9_trans_module *m);
73184 void v9fs_unregister_trans(struct p9_trans_module *m);
73185 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
73186 index 7588ef4..e62d35f 100644
73187 --- a/include/net/bluetooth/l2cap.h
73188 +++ b/include/net/bluetooth/l2cap.h
73189 @@ -552,7 +552,7 @@ struct l2cap_ops {
73190 void (*defer) (struct l2cap_chan *chan);
73191 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
73192 unsigned long len, int nb);
73193 -};
73194 +} __do_const;
73195
73196 struct l2cap_conn {
73197 struct hci_conn *hcon;
73198 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
73199 index 9e5425b..8136ffc 100644
73200 --- a/include/net/caif/cfctrl.h
73201 +++ b/include/net/caif/cfctrl.h
73202 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
73203 void (*radioset_rsp)(void);
73204 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
73205 struct cflayer *client_layer);
73206 -};
73207 +} __no_const;
73208
73209 /* Link Setup Parameters for CAIF-Links. */
73210 struct cfctrl_link_param {
73211 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
73212 struct cfctrl {
73213 struct cfsrvl serv;
73214 struct cfctrl_rsp res;
73215 - atomic_t req_seq_no;
73216 - atomic_t rsp_seq_no;
73217 + atomic_unchecked_t req_seq_no;
73218 + atomic_unchecked_t rsp_seq_no;
73219 struct list_head list;
73220 /* Protects from simultaneous access to first_req list */
73221 spinlock_t info_list_lock;
73222 diff --git a/include/net/flow.h b/include/net/flow.h
73223 index 628e11b..4c475df 100644
73224 --- a/include/net/flow.h
73225 +++ b/include/net/flow.h
73226 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
73227
73228 extern void flow_cache_flush(void);
73229 extern void flow_cache_flush_deferred(void);
73230 -extern atomic_t flow_cache_genid;
73231 +extern atomic_unchecked_t flow_cache_genid;
73232
73233 #endif
73234 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
73235 index bdfbe68..4402ebe 100644
73236 --- a/include/net/genetlink.h
73237 +++ b/include/net/genetlink.h
73238 @@ -118,7 +118,7 @@ struct genl_ops {
73239 struct netlink_callback *cb);
73240 int (*done)(struct netlink_callback *cb);
73241 struct list_head ops_list;
73242 -};
73243 +} __do_const;
73244
73245 extern int genl_register_family(struct genl_family *family);
73246 extern int genl_register_family_with_ops(struct genl_family *family,
73247 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
73248 index e5062c9..48a9a4b 100644
73249 --- a/include/net/gro_cells.h
73250 +++ b/include/net/gro_cells.h
73251 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
73252 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
73253
73254 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
73255 - atomic_long_inc(&dev->rx_dropped);
73256 + atomic_long_inc_unchecked(&dev->rx_dropped);
73257 kfree_skb(skb);
73258 return;
73259 }
73260 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
73261 int i;
73262
73263 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
73264 - gcells->cells = kcalloc(sizeof(struct gro_cell),
73265 - gcells->gro_cells_mask + 1,
73266 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
73267 + sizeof(struct gro_cell),
73268 GFP_KERNEL);
73269 if (!gcells->cells)
73270 return -ENOMEM;
73271 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
73272 index 1832927..ce39aea 100644
73273 --- a/include/net/inet_connection_sock.h
73274 +++ b/include/net/inet_connection_sock.h
73275 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
73276 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
73277 int (*bind_conflict)(const struct sock *sk,
73278 const struct inet_bind_bucket *tb, bool relax);
73279 -};
73280 +} __do_const;
73281
73282 /** inet_connection_sock - INET connection oriented sock
73283 *
73284 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
73285 index 53f464d..ba76aaa 100644
73286 --- a/include/net/inetpeer.h
73287 +++ b/include/net/inetpeer.h
73288 @@ -47,8 +47,8 @@ struct inet_peer {
73289 */
73290 union {
73291 struct {
73292 - atomic_t rid; /* Frag reception counter */
73293 - atomic_t ip_id_count; /* IP ID for the next packet */
73294 + atomic_unchecked_t rid; /* Frag reception counter */
73295 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
73296 };
73297 struct rcu_head rcu;
73298 struct inet_peer *gc_next;
73299 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
73300 more++;
73301 inet_peer_refcheck(p);
73302 do {
73303 - old = atomic_read(&p->ip_id_count);
73304 + old = atomic_read_unchecked(&p->ip_id_count);
73305 new = old + more;
73306 if (!new)
73307 new = 1;
73308 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
73309 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
73310 return new;
73311 }
73312
73313 diff --git a/include/net/ip.h b/include/net/ip.h
73314 index a68f838..74518ab 100644
73315 --- a/include/net/ip.h
73316 +++ b/include/net/ip.h
73317 @@ -202,7 +202,7 @@ extern struct local_ports {
73318 } sysctl_local_ports;
73319 extern void inet_get_local_port_range(int *low, int *high);
73320
73321 -extern unsigned long *sysctl_local_reserved_ports;
73322 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
73323 static inline int inet_is_reserved_local_port(int port)
73324 {
73325 return test_bit(port, sysctl_local_reserved_ports);
73326 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
73327 index e49db91..76a81de 100644
73328 --- a/include/net/ip_fib.h
73329 +++ b/include/net/ip_fib.h
73330 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
73331
73332 #define FIB_RES_SADDR(net, res) \
73333 ((FIB_RES_NH(res).nh_saddr_genid == \
73334 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
73335 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
73336 FIB_RES_NH(res).nh_saddr : \
73337 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
73338 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
73339 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
73340 index 68c69d5..bdab192 100644
73341 --- a/include/net/ip_vs.h
73342 +++ b/include/net/ip_vs.h
73343 @@ -599,7 +599,7 @@ struct ip_vs_conn {
73344 struct ip_vs_conn *control; /* Master control connection */
73345 atomic_t n_control; /* Number of controlled ones */
73346 struct ip_vs_dest *dest; /* real server */
73347 - atomic_t in_pkts; /* incoming packet counter */
73348 + atomic_unchecked_t in_pkts; /* incoming packet counter */
73349
73350 /* packet transmitter for different forwarding methods. If it
73351 mangles the packet, it must return NF_DROP or better NF_STOLEN,
73352 @@ -737,7 +737,7 @@ struct ip_vs_dest {
73353 __be16 port; /* port number of the server */
73354 union nf_inet_addr addr; /* IP address of the server */
73355 volatile unsigned int flags; /* dest status flags */
73356 - atomic_t conn_flags; /* flags to copy to conn */
73357 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
73358 atomic_t weight; /* server weight */
73359
73360 atomic_t refcnt; /* reference counter */
73361 @@ -980,11 +980,11 @@ struct netns_ipvs {
73362 /* ip_vs_lblc */
73363 int sysctl_lblc_expiration;
73364 struct ctl_table_header *lblc_ctl_header;
73365 - struct ctl_table *lblc_ctl_table;
73366 + ctl_table_no_const *lblc_ctl_table;
73367 /* ip_vs_lblcr */
73368 int sysctl_lblcr_expiration;
73369 struct ctl_table_header *lblcr_ctl_header;
73370 - struct ctl_table *lblcr_ctl_table;
73371 + ctl_table_no_const *lblcr_ctl_table;
73372 /* ip_vs_est */
73373 struct list_head est_list; /* estimator list */
73374 spinlock_t est_lock;
73375 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
73376 index 80ffde3..968b0f4 100644
73377 --- a/include/net/irda/ircomm_tty.h
73378 +++ b/include/net/irda/ircomm_tty.h
73379 @@ -35,6 +35,7 @@
73380 #include <linux/termios.h>
73381 #include <linux/timer.h>
73382 #include <linux/tty.h> /* struct tty_struct */
73383 +#include <asm/local.h>
73384
73385 #include <net/irda/irias_object.h>
73386 #include <net/irda/ircomm_core.h>
73387 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
73388 index cc7c197..9f2da2a 100644
73389 --- a/include/net/iucv/af_iucv.h
73390 +++ b/include/net/iucv/af_iucv.h
73391 @@ -141,7 +141,7 @@ struct iucv_sock {
73392 struct iucv_sock_list {
73393 struct hlist_head head;
73394 rwlock_t lock;
73395 - atomic_t autobind_name;
73396 + atomic_unchecked_t autobind_name;
73397 };
73398
73399 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
73400 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
73401 index df83f69..9b640b8 100644
73402 --- a/include/net/llc_c_ac.h
73403 +++ b/include/net/llc_c_ac.h
73404 @@ -87,7 +87,7 @@
73405 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
73406 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
73407
73408 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73409 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73410
73411 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
73412 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
73413 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
73414 index 6ca3113..f8026dd 100644
73415 --- a/include/net/llc_c_ev.h
73416 +++ b/include/net/llc_c_ev.h
73417 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
73418 return (struct llc_conn_state_ev *)skb->cb;
73419 }
73420
73421 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73422 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73423 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73424 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73425
73426 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
73427 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
73428 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
73429 index 0e79cfb..f46db31 100644
73430 --- a/include/net/llc_c_st.h
73431 +++ b/include/net/llc_c_st.h
73432 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
73433 u8 next_state;
73434 llc_conn_ev_qfyr_t *ev_qualifiers;
73435 llc_conn_action_t *ev_actions;
73436 -};
73437 +} __do_const;
73438
73439 struct llc_conn_state {
73440 u8 current_state;
73441 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
73442 index 37a3bbd..55a4241 100644
73443 --- a/include/net/llc_s_ac.h
73444 +++ b/include/net/llc_s_ac.h
73445 @@ -23,7 +23,7 @@
73446 #define SAP_ACT_TEST_IND 9
73447
73448 /* All action functions must look like this */
73449 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73450 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73451
73452 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
73453 struct sk_buff *skb);
73454 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
73455 index 567c681..cd73ac0 100644
73456 --- a/include/net/llc_s_st.h
73457 +++ b/include/net/llc_s_st.h
73458 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
73459 llc_sap_ev_t ev;
73460 u8 next_state;
73461 llc_sap_action_t *ev_actions;
73462 -};
73463 +} __do_const;
73464
73465 struct llc_sap_state {
73466 u8 curr_state;
73467 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
73468 index ee50c5e..1bc3b1a 100644
73469 --- a/include/net/mac80211.h
73470 +++ b/include/net/mac80211.h
73471 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
73472 void (*add_sta_debugfs)(void *priv, void *priv_sta,
73473 struct dentry *dir);
73474 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
73475 -};
73476 +} __do_const;
73477
73478 static inline int rate_supported(struct ieee80211_sta *sta,
73479 enum ieee80211_band band,
73480 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
73481 index 0dab173..1b76af0 100644
73482 --- a/include/net/neighbour.h
73483 +++ b/include/net/neighbour.h
73484 @@ -123,7 +123,7 @@ struct neigh_ops {
73485 void (*error_report)(struct neighbour *, struct sk_buff *);
73486 int (*output)(struct neighbour *, struct sk_buff *);
73487 int (*connected_output)(struct neighbour *, struct sk_buff *);
73488 -};
73489 +} __do_const;
73490
73491 struct pneigh_entry {
73492 struct pneigh_entry *next;
73493 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
73494 index de644bc..dfbcc4c 100644
73495 --- a/include/net/net_namespace.h
73496 +++ b/include/net/net_namespace.h
73497 @@ -115,7 +115,7 @@ struct net {
73498 #endif
73499 struct netns_ipvs *ipvs;
73500 struct sock *diag_nlsk;
73501 - atomic_t rt_genid;
73502 + atomic_unchecked_t rt_genid;
73503 };
73504
73505 /*
73506 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
73507 #define __net_init __init
73508 #define __net_exit __exit_refok
73509 #define __net_initdata __initdata
73510 +#ifdef CONSTIFY_PLUGIN
73511 #define __net_initconst __initconst
73512 +#else
73513 +#define __net_initconst __initdata
73514 +#endif
73515 #endif
73516
73517 struct pernet_operations {
73518 @@ -282,7 +286,7 @@ struct pernet_operations {
73519 void (*exit_batch)(struct list_head *net_exit_list);
73520 int *id;
73521 size_t size;
73522 -};
73523 +} __do_const;
73524
73525 /*
73526 * Use these carefully. If you implement a network device and it
73527 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
73528
73529 static inline int rt_genid(struct net *net)
73530 {
73531 - return atomic_read(&net->rt_genid);
73532 + return atomic_read_unchecked(&net->rt_genid);
73533 }
73534
73535 static inline void rt_genid_bump(struct net *net)
73536 {
73537 - atomic_inc(&net->rt_genid);
73538 + atomic_inc_unchecked(&net->rt_genid);
73539 }
73540
73541 #endif /* __NET_NET_NAMESPACE_H */
73542 diff --git a/include/net/netdma.h b/include/net/netdma.h
73543 index 8ba8ce2..99b7fff 100644
73544 --- a/include/net/netdma.h
73545 +++ b/include/net/netdma.h
73546 @@ -24,7 +24,7 @@
73547 #include <linux/dmaengine.h>
73548 #include <linux/skbuff.h>
73549
73550 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73551 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73552 struct sk_buff *skb, int offset, struct iovec *to,
73553 size_t len, struct dma_pinned_list *pinned_list);
73554
73555 diff --git a/include/net/netlink.h b/include/net/netlink.h
73556 index 9690b0f..87aded7 100644
73557 --- a/include/net/netlink.h
73558 +++ b/include/net/netlink.h
73559 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
73560 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
73561 {
73562 if (mark)
73563 - skb_trim(skb, (unsigned char *) mark - skb->data);
73564 + skb_trim(skb, (const unsigned char *) mark - skb->data);
73565 }
73566
73567 /**
73568 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
73569 index 923cb20..deae816 100644
73570 --- a/include/net/netns/conntrack.h
73571 +++ b/include/net/netns/conntrack.h
73572 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
73573 struct nf_proto_net {
73574 #ifdef CONFIG_SYSCTL
73575 struct ctl_table_header *ctl_table_header;
73576 - struct ctl_table *ctl_table;
73577 + ctl_table_no_const *ctl_table;
73578 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
73579 struct ctl_table_header *ctl_compat_header;
73580 - struct ctl_table *ctl_compat_table;
73581 + ctl_table_no_const *ctl_compat_table;
73582 #endif
73583 #endif
73584 unsigned int users;
73585 @@ -58,7 +58,7 @@ struct nf_ip_net {
73586 struct nf_icmp_net icmpv6;
73587 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
73588 struct ctl_table_header *ctl_table_header;
73589 - struct ctl_table *ctl_table;
73590 + ctl_table_no_const *ctl_table;
73591 #endif
73592 };
73593
73594 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
73595 index 2ae2b83..dbdc85e 100644
73596 --- a/include/net/netns/ipv4.h
73597 +++ b/include/net/netns/ipv4.h
73598 @@ -64,7 +64,7 @@ struct netns_ipv4 {
73599 kgid_t sysctl_ping_group_range[2];
73600 long sysctl_tcp_mem[3];
73601
73602 - atomic_t dev_addr_genid;
73603 + atomic_unchecked_t dev_addr_genid;
73604
73605 #ifdef CONFIG_IP_MROUTE
73606 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73607 diff --git a/include/net/protocol.h b/include/net/protocol.h
73608 index 047c047..b9dad15 100644
73609 --- a/include/net/protocol.h
73610 +++ b/include/net/protocol.h
73611 @@ -44,7 +44,7 @@ struct net_protocol {
73612 void (*err_handler)(struct sk_buff *skb, u32 info);
73613 unsigned int no_policy:1,
73614 netns_ok:1;
73615 -};
73616 +} __do_const;
73617
73618 #if IS_ENABLED(CONFIG_IPV6)
73619 struct inet6_protocol {
73620 @@ -57,7 +57,7 @@ struct inet6_protocol {
73621 u8 type, u8 code, int offset,
73622 __be32 info);
73623 unsigned int flags; /* INET6_PROTO_xxx */
73624 -};
73625 +} __do_const;
73626
73627 #define INET6_PROTO_NOPOLICY 0x1
73628 #define INET6_PROTO_FINAL 0x2
73629 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73630 index 5a15fab..d799ea7 100644
73631 --- a/include/net/rtnetlink.h
73632 +++ b/include/net/rtnetlink.h
73633 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73634 const struct net_device *dev);
73635 unsigned int (*get_num_tx_queues)(void);
73636 unsigned int (*get_num_rx_queues)(void);
73637 -};
73638 +} __do_const;
73639
73640 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73641 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73642 diff --git a/include/net/scm.h b/include/net/scm.h
73643 index 975cca0..b117081 100644
73644 --- a/include/net/scm.h
73645 +++ b/include/net/scm.h
73646 @@ -56,8 +56,8 @@ static __inline__ void scm_set_cred(struct scm_cookie *scm,
73647 scm->pid = get_pid(pid);
73648 scm->cred = cred ? get_cred(cred) : NULL;
73649 scm->creds.pid = pid_vnr(pid);
73650 - scm->creds.uid = cred ? cred->euid : INVALID_UID;
73651 - scm->creds.gid = cred ? cred->egid : INVALID_GID;
73652 + scm->creds.uid = cred ? cred->uid : INVALID_UID;
73653 + scm->creds.gid = cred ? cred->gid : INVALID_GID;
73654 }
73655
73656 static __inline__ void scm_destroy_cred(struct scm_cookie *scm)
73657 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73658 index 7fdf298..197e9f7 100644
73659 --- a/include/net/sctp/sctp.h
73660 +++ b/include/net/sctp/sctp.h
73661 @@ -330,9 +330,9 @@ do { \
73662
73663 #else /* SCTP_DEBUG */
73664
73665 -#define SCTP_DEBUG_PRINTK(whatever...)
73666 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73667 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73668 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73669 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73670 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73671 #define SCTP_ENABLE_DEBUG
73672 #define SCTP_DISABLE_DEBUG
73673 #define SCTP_ASSERT(expr, str, func)
73674 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73675 index 2a82d13..62a31c2 100644
73676 --- a/include/net/sctp/sm.h
73677 +++ b/include/net/sctp/sm.h
73678 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73679 typedef struct {
73680 sctp_state_fn_t *fn;
73681 const char *name;
73682 -} sctp_sm_table_entry_t;
73683 +} __do_const sctp_sm_table_entry_t;
73684
73685 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73686 * currently in use.
73687 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73688 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73689
73690 /* Extern declarations for major data structures. */
73691 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73692 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73693
73694
73695 /* Get the size of a DATA chunk payload. */
73696 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73697 index fdeb85a..1329d95 100644
73698 --- a/include/net/sctp/structs.h
73699 +++ b/include/net/sctp/structs.h
73700 @@ -517,7 +517,7 @@ struct sctp_pf {
73701 struct sctp_association *asoc);
73702 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73703 struct sctp_af *af;
73704 -};
73705 +} __do_const;
73706
73707
73708 /* Structure to track chunk fragments that have been acked, but peer
73709 diff --git a/include/net/sock.h b/include/net/sock.h
73710 index 25afaa0..8bb0070 100644
73711 --- a/include/net/sock.h
73712 +++ b/include/net/sock.h
73713 @@ -322,7 +322,7 @@ struct sock {
73714 #ifdef CONFIG_RPS
73715 __u32 sk_rxhash;
73716 #endif
73717 - atomic_t sk_drops;
73718 + atomic_unchecked_t sk_drops;
73719 int sk_rcvbuf;
73720
73721 struct sk_filter __rcu *sk_filter;
73722 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73723 }
73724
73725 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73726 - char __user *from, char *to,
73727 + char __user *from, unsigned char *to,
73728 int copy, int offset)
73729 {
73730 if (skb->ip_summed == CHECKSUM_NONE) {
73731 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73732 }
73733 }
73734
73735 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73736 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73737
73738 /**
73739 * sk_page_frag - return an appropriate page_frag
73740 diff --git a/include/net/tcp.h b/include/net/tcp.h
73741 index aed42c7..43890c6 100644
73742 --- a/include/net/tcp.h
73743 +++ b/include/net/tcp.h
73744 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73745 extern void tcp_xmit_retransmit_queue(struct sock *);
73746 extern void tcp_simple_retransmit(struct sock *);
73747 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73748 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73749 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73750
73751 extern void tcp_send_probe0(struct sock *);
73752 extern void tcp_send_partial(struct sock *);
73753 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
73754 struct inet6_skb_parm h6;
73755 #endif
73756 } header; /* For incoming frames */
73757 - __u32 seq; /* Starting sequence number */
73758 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73759 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73760 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73761 __u32 when; /* used to compute rtt's */
73762 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73763
73764 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
73765
73766 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73767 /* 1 byte hole */
73768 - __u32 ack_seq; /* Sequence number ACK'd */
73769 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73770 };
73771
73772 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73773 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73774 index 63445ed..d6fc34f 100644
73775 --- a/include/net/xfrm.h
73776 +++ b/include/net/xfrm.h
73777 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73778 struct net_device *dev,
73779 const struct flowi *fl);
73780 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73781 -};
73782 +} __do_const;
73783
73784 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73785 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73786 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73787 struct sk_buff *skb);
73788 int (*transport_finish)(struct sk_buff *skb,
73789 int async);
73790 -};
73791 +} __do_const;
73792
73793 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73794 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73795 @@ -423,7 +423,7 @@ struct xfrm_mode {
73796 struct module *owner;
73797 unsigned int encap;
73798 int flags;
73799 -};
73800 +} __do_const;
73801
73802 /* Flags for xfrm_mode. */
73803 enum {
73804 @@ -514,7 +514,7 @@ struct xfrm_policy {
73805 struct timer_list timer;
73806
73807 struct flow_cache_object flo;
73808 - atomic_t genid;
73809 + atomic_unchecked_t genid;
73810 u32 priority;
73811 u32 index;
73812 struct xfrm_mark mark;
73813 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73814 index 1a046b1..ee0bef0 100644
73815 --- a/include/rdma/iw_cm.h
73816 +++ b/include/rdma/iw_cm.h
73817 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73818 int backlog);
73819
73820 int (*destroy_listen)(struct iw_cm_id *cm_id);
73821 -};
73822 +} __no_const;
73823
73824 /**
73825 * iw_create_cm_id - Create an IW CM identifier.
73826 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73827 index 399162b..b337f1a 100644
73828 --- a/include/scsi/libfc.h
73829 +++ b/include/scsi/libfc.h
73830 @@ -762,6 +762,7 @@ struct libfc_function_template {
73831 */
73832 void (*disc_stop_final) (struct fc_lport *);
73833 };
73834 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73835
73836 /**
73837 * struct fc_disc - Discovery context
73838 @@ -866,7 +867,7 @@ struct fc_lport {
73839 struct fc_vport *vport;
73840
73841 /* Operational Information */
73842 - struct libfc_function_template tt;
73843 + libfc_function_template_no_const tt;
73844 u8 link_up;
73845 u8 qfull;
73846 enum fc_lport_state state;
73847 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73848 index e65c62e..aa2e5a2 100644
73849 --- a/include/scsi/scsi_device.h
73850 +++ b/include/scsi/scsi_device.h
73851 @@ -170,9 +170,9 @@ struct scsi_device {
73852 unsigned int max_device_blocked; /* what device_blocked counts down from */
73853 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73854
73855 - atomic_t iorequest_cnt;
73856 - atomic_t iodone_cnt;
73857 - atomic_t ioerr_cnt;
73858 + atomic_unchecked_t iorequest_cnt;
73859 + atomic_unchecked_t iodone_cnt;
73860 + atomic_unchecked_t ioerr_cnt;
73861
73862 struct device sdev_gendev,
73863 sdev_dev;
73864 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73865 index b797e8f..8e2c3aa 100644
73866 --- a/include/scsi/scsi_transport_fc.h
73867 +++ b/include/scsi/scsi_transport_fc.h
73868 @@ -751,7 +751,8 @@ struct fc_function_template {
73869 unsigned long show_host_system_hostname:1;
73870
73871 unsigned long disable_target_scan:1;
73872 -};
73873 +} __do_const;
73874 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73875
73876
73877 /**
73878 diff --git a/include/sound/soc.h b/include/sound/soc.h
73879 index bc56738..a4be132 100644
73880 --- a/include/sound/soc.h
73881 +++ b/include/sound/soc.h
73882 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73883 /* probe ordering - for components with runtime dependencies */
73884 int probe_order;
73885 int remove_order;
73886 -};
73887 +} __do_const;
73888
73889 /* SoC platform interface */
73890 struct snd_soc_platform_driver {
73891 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73892 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73893 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73894 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73895 -};
73896 +} __do_const;
73897
73898 struct snd_soc_platform {
73899 const char *name;
73900 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73901 index 663e34a..91b306a 100644
73902 --- a/include/target/target_core_base.h
73903 +++ b/include/target/target_core_base.h
73904 @@ -654,7 +654,7 @@ struct se_device {
73905 spinlock_t stats_lock;
73906 /* Active commands on this virtual SE device */
73907 atomic_t simple_cmds;
73908 - atomic_t dev_ordered_id;
73909 + atomic_unchecked_t dev_ordered_id;
73910 atomic_t dev_ordered_sync;
73911 atomic_t dev_qf_count;
73912 int export_count;
73913 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73914 new file mode 100644
73915 index 0000000..fb634b7
73916 --- /dev/null
73917 +++ b/include/trace/events/fs.h
73918 @@ -0,0 +1,53 @@
73919 +#undef TRACE_SYSTEM
73920 +#define TRACE_SYSTEM fs
73921 +
73922 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73923 +#define _TRACE_FS_H
73924 +
73925 +#include <linux/fs.h>
73926 +#include <linux/tracepoint.h>
73927 +
73928 +TRACE_EVENT(do_sys_open,
73929 +
73930 + TP_PROTO(const char *filename, int flags, int mode),
73931 +
73932 + TP_ARGS(filename, flags, mode),
73933 +
73934 + TP_STRUCT__entry(
73935 + __string( filename, filename )
73936 + __field( int, flags )
73937 + __field( int, mode )
73938 + ),
73939 +
73940 + TP_fast_assign(
73941 + __assign_str(filename, filename);
73942 + __entry->flags = flags;
73943 + __entry->mode = mode;
73944 + ),
73945 +
73946 + TP_printk("\"%s\" %x %o",
73947 + __get_str(filename), __entry->flags, __entry->mode)
73948 +);
73949 +
73950 +TRACE_EVENT(open_exec,
73951 +
73952 + TP_PROTO(const char *filename),
73953 +
73954 + TP_ARGS(filename),
73955 +
73956 + TP_STRUCT__entry(
73957 + __string( filename, filename )
73958 + ),
73959 +
73960 + TP_fast_assign(
73961 + __assign_str(filename, filename);
73962 + ),
73963 +
73964 + TP_printk("\"%s\"",
73965 + __get_str(filename))
73966 +);
73967 +
73968 +#endif /* _TRACE_FS_H */
73969 +
73970 +/* This part must be outside protection */
73971 +#include <trace/define_trace.h>
73972 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73973 index 1c09820..7f5ec79 100644
73974 --- a/include/trace/events/irq.h
73975 +++ b/include/trace/events/irq.h
73976 @@ -36,7 +36,7 @@ struct softirq_action;
73977 */
73978 TRACE_EVENT(irq_handler_entry,
73979
73980 - TP_PROTO(int irq, struct irqaction *action),
73981 + TP_PROTO(int irq, const struct irqaction *action),
73982
73983 TP_ARGS(irq, action),
73984
73985 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73986 */
73987 TRACE_EVENT(irq_handler_exit,
73988
73989 - TP_PROTO(int irq, struct irqaction *action, int ret),
73990 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73991
73992 TP_ARGS(irq, action, ret),
73993
73994 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73995 index 7caf44c..23c6f27 100644
73996 --- a/include/uapi/linux/a.out.h
73997 +++ b/include/uapi/linux/a.out.h
73998 @@ -39,6 +39,14 @@ enum machine_type {
73999 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
74000 };
74001
74002 +/* Constants for the N_FLAGS field */
74003 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
74004 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
74005 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
74006 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
74007 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
74008 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
74009 +
74010 #if !defined (N_MAGIC)
74011 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
74012 #endif
74013 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
74014 index d876736..ccce5c0 100644
74015 --- a/include/uapi/linux/byteorder/little_endian.h
74016 +++ b/include/uapi/linux/byteorder/little_endian.h
74017 @@ -42,51 +42,51 @@
74018
74019 static inline __le64 __cpu_to_le64p(const __u64 *p)
74020 {
74021 - return (__force __le64)*p;
74022 + return (__force const __le64)*p;
74023 }
74024 -static inline __u64 __le64_to_cpup(const __le64 *p)
74025 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
74026 {
74027 - return (__force __u64)*p;
74028 + return (__force const __u64)*p;
74029 }
74030 static inline __le32 __cpu_to_le32p(const __u32 *p)
74031 {
74032 - return (__force __le32)*p;
74033 + return (__force const __le32)*p;
74034 }
74035 static inline __u32 __le32_to_cpup(const __le32 *p)
74036 {
74037 - return (__force __u32)*p;
74038 + return (__force const __u32)*p;
74039 }
74040 static inline __le16 __cpu_to_le16p(const __u16 *p)
74041 {
74042 - return (__force __le16)*p;
74043 + return (__force const __le16)*p;
74044 }
74045 static inline __u16 __le16_to_cpup(const __le16 *p)
74046 {
74047 - return (__force __u16)*p;
74048 + return (__force const __u16)*p;
74049 }
74050 static inline __be64 __cpu_to_be64p(const __u64 *p)
74051 {
74052 - return (__force __be64)__swab64p(p);
74053 + return (__force const __be64)__swab64p(p);
74054 }
74055 static inline __u64 __be64_to_cpup(const __be64 *p)
74056 {
74057 - return __swab64p((__u64 *)p);
74058 + return __swab64p((const __u64 *)p);
74059 }
74060 static inline __be32 __cpu_to_be32p(const __u32 *p)
74061 {
74062 - return (__force __be32)__swab32p(p);
74063 + return (__force const __be32)__swab32p(p);
74064 }
74065 -static inline __u32 __be32_to_cpup(const __be32 *p)
74066 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
74067 {
74068 - return __swab32p((__u32 *)p);
74069 + return __swab32p((const __u32 *)p);
74070 }
74071 static inline __be16 __cpu_to_be16p(const __u16 *p)
74072 {
74073 - return (__force __be16)__swab16p(p);
74074 + return (__force const __be16)__swab16p(p);
74075 }
74076 static inline __u16 __be16_to_cpup(const __be16 *p)
74077 {
74078 - return __swab16p((__u16 *)p);
74079 + return __swab16p((const __u16 *)p);
74080 }
74081 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
74082 #define __le64_to_cpus(x) do { (void)(x); } while (0)
74083 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
74084 index 126a817..d522bd1 100644
74085 --- a/include/uapi/linux/elf.h
74086 +++ b/include/uapi/linux/elf.h
74087 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
74088 #define PT_GNU_EH_FRAME 0x6474e550
74089
74090 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
74091 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
74092 +
74093 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
74094 +
74095 +/* Constants for the e_flags field */
74096 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
74097 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
74098 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
74099 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
74100 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
74101 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
74102
74103 /*
74104 * Extended Numbering
74105 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
74106 #define DT_DEBUG 21
74107 #define DT_TEXTREL 22
74108 #define DT_JMPREL 23
74109 +#define DT_FLAGS 30
74110 + #define DF_TEXTREL 0x00000004
74111 #define DT_ENCODING 32
74112 #define OLD_DT_LOOS 0x60000000
74113 #define DT_LOOS 0x6000000d
74114 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
74115 #define PF_W 0x2
74116 #define PF_X 0x1
74117
74118 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
74119 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
74120 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
74121 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
74122 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
74123 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
74124 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
74125 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
74126 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
74127 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
74128 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
74129 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
74130 +
74131 typedef struct elf32_phdr{
74132 Elf32_Word p_type;
74133 Elf32_Off p_offset;
74134 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
74135 #define EI_OSABI 7
74136 #define EI_PAD 8
74137
74138 +#define EI_PAX 14
74139 +
74140 #define ELFMAG0 0x7f /* EI_MAG */
74141 #define ELFMAG1 'E'
74142 #define ELFMAG2 'L'
74143 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
74144 index aa169c4..6a2771d 100644
74145 --- a/include/uapi/linux/personality.h
74146 +++ b/include/uapi/linux/personality.h
74147 @@ -30,6 +30,7 @@ enum {
74148 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
74149 ADDR_NO_RANDOMIZE | \
74150 ADDR_COMPAT_LAYOUT | \
74151 + ADDR_LIMIT_3GB | \
74152 MMAP_PAGE_ZERO)
74153
74154 /*
74155 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
74156 index 7530e74..e714828 100644
74157 --- a/include/uapi/linux/screen_info.h
74158 +++ b/include/uapi/linux/screen_info.h
74159 @@ -43,7 +43,8 @@ struct screen_info {
74160 __u16 pages; /* 0x32 */
74161 __u16 vesa_attributes; /* 0x34 */
74162 __u32 capabilities; /* 0x36 */
74163 - __u8 _reserved[6]; /* 0x3a */
74164 + __u16 vesapm_size; /* 0x3a */
74165 + __u8 _reserved[4]; /* 0x3c */
74166 } __attribute__((packed));
74167
74168 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
74169 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
74170 index 0e011eb..82681b1 100644
74171 --- a/include/uapi/linux/swab.h
74172 +++ b/include/uapi/linux/swab.h
74173 @@ -43,7 +43,7 @@
74174 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
74175 */
74176
74177 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
74178 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
74179 {
74180 #ifdef __HAVE_BUILTIN_BSWAP16__
74181 return __builtin_bswap16(val);
74182 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
74183 #endif
74184 }
74185
74186 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
74187 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
74188 {
74189 #ifdef __HAVE_BUILTIN_BSWAP32__
74190 return __builtin_bswap32(val);
74191 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
74192 #endif
74193 }
74194
74195 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
74196 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
74197 {
74198 #ifdef __HAVE_BUILTIN_BSWAP64__
74199 return __builtin_bswap64(val);
74200 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
74201 index 6d67213..8dab561 100644
74202 --- a/include/uapi/linux/sysctl.h
74203 +++ b/include/uapi/linux/sysctl.h
74204 @@ -155,7 +155,11 @@ enum
74205 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
74206 };
74207
74208 -
74209 +#ifdef CONFIG_PAX_SOFTMODE
74210 +enum {
74211 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
74212 +};
74213 +#endif
74214
74215 /* CTL_VM names: */
74216 enum
74217 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
74218 index 26607bd..588b65f 100644
74219 --- a/include/uapi/linux/xattr.h
74220 +++ b/include/uapi/linux/xattr.h
74221 @@ -60,5 +60,9 @@
74222 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
74223 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
74224
74225 +/* User namespace */
74226 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
74227 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
74228 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
74229
74230 #endif /* _UAPI_LINUX_XATTR_H */
74231 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
74232 index f9466fa..f4e2b81 100644
74233 --- a/include/video/udlfb.h
74234 +++ b/include/video/udlfb.h
74235 @@ -53,10 +53,10 @@ struct dlfb_data {
74236 u32 pseudo_palette[256];
74237 int blank_mode; /*one of FB_BLANK_ */
74238 /* blit-only rendering path metrics, exposed through sysfs */
74239 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
74240 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
74241 - atomic_t bytes_sent; /* to usb, after compression including overhead */
74242 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
74243 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
74244 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
74245 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
74246 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
74247 };
74248
74249 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
74250 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
74251 index 0993a22..32ba2fe 100644
74252 --- a/include/video/uvesafb.h
74253 +++ b/include/video/uvesafb.h
74254 @@ -177,6 +177,7 @@ struct uvesafb_par {
74255 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
74256 u8 pmi_setpal; /* PMI for palette changes */
74257 u16 *pmi_base; /* protected mode interface location */
74258 + u8 *pmi_code; /* protected mode code location */
74259 void *pmi_start;
74260 void *pmi_pal;
74261 u8 *vbe_state_orig; /*
74262 diff --git a/init/Kconfig b/init/Kconfig
74263 index be8b7f5..1eeca9b 100644
74264 --- a/init/Kconfig
74265 +++ b/init/Kconfig
74266 @@ -990,6 +990,7 @@ endif # CGROUPS
74267
74268 config CHECKPOINT_RESTORE
74269 bool "Checkpoint/restore support" if EXPERT
74270 + depends on !GRKERNSEC
74271 default n
74272 help
74273 Enables additional kernel features in a sake of checkpoint/restore.
74274 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
74275
74276 config COMPAT_BRK
74277 bool "Disable heap randomization"
74278 - default y
74279 + default n
74280 help
74281 Randomizing heap placement makes heap exploits harder, but it
74282 also breaks ancient binaries (including anything libc5 based).
74283 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
74284 config STOP_MACHINE
74285 bool
74286 default y
74287 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
74288 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
74289 help
74290 Need stop_machine() primitive.
74291
74292 diff --git a/init/Makefile b/init/Makefile
74293 index 7bc47ee..6da2dc7 100644
74294 --- a/init/Makefile
74295 +++ b/init/Makefile
74296 @@ -2,6 +2,9 @@
74297 # Makefile for the linux kernel.
74298 #
74299
74300 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
74301 +asflags-y := $(GCC_PLUGINS_AFLAGS)
74302 +
74303 obj-y := main.o version.o mounts.o
74304 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
74305 obj-y += noinitramfs.o
74306 diff --git a/init/do_mounts.c b/init/do_mounts.c
74307 index 1d1b634..a1c810f 100644
74308 --- a/init/do_mounts.c
74309 +++ b/init/do_mounts.c
74310 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
74311 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
74312 {
74313 struct super_block *s;
74314 - int err = sys_mount(name, "/root", fs, flags, data);
74315 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
74316 if (err)
74317 return err;
74318
74319 - sys_chdir("/root");
74320 + sys_chdir((const char __force_user *)"/root");
74321 s = current->fs->pwd.dentry->d_sb;
74322 ROOT_DEV = s->s_dev;
74323 printk(KERN_INFO
74324 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
74325 va_start(args, fmt);
74326 vsprintf(buf, fmt, args);
74327 va_end(args);
74328 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
74329 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
74330 if (fd >= 0) {
74331 sys_ioctl(fd, FDEJECT, 0);
74332 sys_close(fd);
74333 }
74334 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
74335 - fd = sys_open("/dev/console", O_RDWR, 0);
74336 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
74337 if (fd >= 0) {
74338 sys_ioctl(fd, TCGETS, (long)&termios);
74339 termios.c_lflag &= ~ICANON;
74340 sys_ioctl(fd, TCSETSF, (long)&termios);
74341 - sys_read(fd, &c, 1);
74342 + sys_read(fd, (char __user *)&c, 1);
74343 termios.c_lflag |= ICANON;
74344 sys_ioctl(fd, TCSETSF, (long)&termios);
74345 sys_close(fd);
74346 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
74347 mount_root();
74348 out:
74349 devtmpfs_mount("dev");
74350 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
74351 - sys_chroot(".");
74352 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
74353 + sys_chroot((const char __force_user *)".");
74354 }
74355 diff --git a/init/do_mounts.h b/init/do_mounts.h
74356 index f5b978a..69dbfe8 100644
74357 --- a/init/do_mounts.h
74358 +++ b/init/do_mounts.h
74359 @@ -15,15 +15,15 @@ extern int root_mountflags;
74360
74361 static inline int create_dev(char *name, dev_t dev)
74362 {
74363 - sys_unlink(name);
74364 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
74365 + sys_unlink((char __force_user *)name);
74366 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
74367 }
74368
74369 #if BITS_PER_LONG == 32
74370 static inline u32 bstat(char *name)
74371 {
74372 struct stat64 stat;
74373 - if (sys_stat64(name, &stat) != 0)
74374 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
74375 return 0;
74376 if (!S_ISBLK(stat.st_mode))
74377 return 0;
74378 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
74379 static inline u32 bstat(char *name)
74380 {
74381 struct stat stat;
74382 - if (sys_newstat(name, &stat) != 0)
74383 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
74384 return 0;
74385 if (!S_ISBLK(stat.st_mode))
74386 return 0;
74387 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
74388 index f9acf71..1e19144 100644
74389 --- a/init/do_mounts_initrd.c
74390 +++ b/init/do_mounts_initrd.c
74391 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
74392 create_dev("/dev/root.old", Root_RAM0);
74393 /* mount initrd on rootfs' /root */
74394 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
74395 - sys_mkdir("/old", 0700);
74396 - sys_chdir("/old");
74397 + sys_mkdir((const char __force_user *)"/old", 0700);
74398 + sys_chdir((const char __force_user *)"/old");
74399
74400 /*
74401 * In case that a resume from disk is carried out by linuxrc or one of
74402 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
74403 current->flags &= ~PF_FREEZER_SKIP;
74404
74405 /* move initrd to rootfs' /old */
74406 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
74407 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
74408 /* switch root and cwd back to / of rootfs */
74409 - sys_chroot("..");
74410 + sys_chroot((const char __force_user *)"..");
74411
74412 if (new_decode_dev(real_root_dev) == Root_RAM0) {
74413 - sys_chdir("/old");
74414 + sys_chdir((const char __force_user *)"/old");
74415 return;
74416 }
74417
74418 - sys_chdir("/");
74419 + sys_chdir((const char __force_user *)"/");
74420 ROOT_DEV = new_decode_dev(real_root_dev);
74421 mount_root();
74422
74423 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
74424 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
74425 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
74426 if (!error)
74427 printk("okay\n");
74428 else {
74429 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
74430 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
74431 if (error == -ENOENT)
74432 printk("/initrd does not exist. Ignored.\n");
74433 else
74434 printk("failed\n");
74435 printk(KERN_NOTICE "Unmounting old root\n");
74436 - sys_umount("/old", MNT_DETACH);
74437 + sys_umount((char __force_user *)"/old", MNT_DETACH);
74438 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
74439 if (fd < 0) {
74440 error = fd;
74441 @@ -120,11 +120,11 @@ int __init initrd_load(void)
74442 * mounted in the normal path.
74443 */
74444 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
74445 - sys_unlink("/initrd.image");
74446 + sys_unlink((const char __force_user *)"/initrd.image");
74447 handle_initrd();
74448 return 1;
74449 }
74450 }
74451 - sys_unlink("/initrd.image");
74452 + sys_unlink((const char __force_user *)"/initrd.image");
74453 return 0;
74454 }
74455 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
74456 index 8cb6db5..d729f50 100644
74457 --- a/init/do_mounts_md.c
74458 +++ b/init/do_mounts_md.c
74459 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
74460 partitioned ? "_d" : "", minor,
74461 md_setup_args[ent].device_names);
74462
74463 - fd = sys_open(name, 0, 0);
74464 + fd = sys_open((char __force_user *)name, 0, 0);
74465 if (fd < 0) {
74466 printk(KERN_ERR "md: open failed - cannot start "
74467 "array %s\n", name);
74468 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
74469 * array without it
74470 */
74471 sys_close(fd);
74472 - fd = sys_open(name, 0, 0);
74473 + fd = sys_open((char __force_user *)name, 0, 0);
74474 sys_ioctl(fd, BLKRRPART, 0);
74475 }
74476 sys_close(fd);
74477 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
74478
74479 wait_for_device_probe();
74480
74481 - fd = sys_open("/dev/md0", 0, 0);
74482 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
74483 if (fd >= 0) {
74484 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
74485 sys_close(fd);
74486 diff --git a/init/init_task.c b/init/init_task.c
74487 index 8b2f399..f0797c9 100644
74488 --- a/init/init_task.c
74489 +++ b/init/init_task.c
74490 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
74491 * Initial thread structure. Alignment of this is handled by a special
74492 * linker map entry.
74493 */
74494 +#ifdef CONFIG_X86
74495 +union thread_union init_thread_union __init_task_data;
74496 +#else
74497 union thread_union init_thread_union __init_task_data =
74498 { INIT_THREAD_INFO(init_task) };
74499 +#endif
74500 diff --git a/init/initramfs.c b/init/initramfs.c
74501 index 84c6bf1..8899338 100644
74502 --- a/init/initramfs.c
74503 +++ b/init/initramfs.c
74504 @@ -84,7 +84,7 @@ static void __init free_hash(void)
74505 }
74506 }
74507
74508 -static long __init do_utime(char *filename, time_t mtime)
74509 +static long __init do_utime(char __force_user *filename, time_t mtime)
74510 {
74511 struct timespec t[2];
74512
74513 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
74514 struct dir_entry *de, *tmp;
74515 list_for_each_entry_safe(de, tmp, &dir_list, list) {
74516 list_del(&de->list);
74517 - do_utime(de->name, de->mtime);
74518 + do_utime((char __force_user *)de->name, de->mtime);
74519 kfree(de->name);
74520 kfree(de);
74521 }
74522 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
74523 if (nlink >= 2) {
74524 char *old = find_link(major, minor, ino, mode, collected);
74525 if (old)
74526 - return (sys_link(old, collected) < 0) ? -1 : 1;
74527 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
74528 }
74529 return 0;
74530 }
74531 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
74532 {
74533 struct stat st;
74534
74535 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
74536 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
74537 if (S_ISDIR(st.st_mode))
74538 - sys_rmdir(path);
74539 + sys_rmdir((char __force_user *)path);
74540 else
74541 - sys_unlink(path);
74542 + sys_unlink((char __force_user *)path);
74543 }
74544 }
74545
74546 @@ -315,7 +315,7 @@ static int __init do_name(void)
74547 int openflags = O_WRONLY|O_CREAT;
74548 if (ml != 1)
74549 openflags |= O_TRUNC;
74550 - wfd = sys_open(collected, openflags, mode);
74551 + wfd = sys_open((char __force_user *)collected, openflags, mode);
74552
74553 if (wfd >= 0) {
74554 sys_fchown(wfd, uid, gid);
74555 @@ -327,17 +327,17 @@ static int __init do_name(void)
74556 }
74557 }
74558 } else if (S_ISDIR(mode)) {
74559 - sys_mkdir(collected, mode);
74560 - sys_chown(collected, uid, gid);
74561 - sys_chmod(collected, mode);
74562 + sys_mkdir((char __force_user *)collected, mode);
74563 + sys_chown((char __force_user *)collected, uid, gid);
74564 + sys_chmod((char __force_user *)collected, mode);
74565 dir_add(collected, mtime);
74566 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
74567 S_ISFIFO(mode) || S_ISSOCK(mode)) {
74568 if (maybe_link() == 0) {
74569 - sys_mknod(collected, mode, rdev);
74570 - sys_chown(collected, uid, gid);
74571 - sys_chmod(collected, mode);
74572 - do_utime(collected, mtime);
74573 + sys_mknod((char __force_user *)collected, mode, rdev);
74574 + sys_chown((char __force_user *)collected, uid, gid);
74575 + sys_chmod((char __force_user *)collected, mode);
74576 + do_utime((char __force_user *)collected, mtime);
74577 }
74578 }
74579 return 0;
74580 @@ -346,15 +346,15 @@ static int __init do_name(void)
74581 static int __init do_copy(void)
74582 {
74583 if (count >= body_len) {
74584 - sys_write(wfd, victim, body_len);
74585 + sys_write(wfd, (char __force_user *)victim, body_len);
74586 sys_close(wfd);
74587 - do_utime(vcollected, mtime);
74588 + do_utime((char __force_user *)vcollected, mtime);
74589 kfree(vcollected);
74590 eat(body_len);
74591 state = SkipIt;
74592 return 0;
74593 } else {
74594 - sys_write(wfd, victim, count);
74595 + sys_write(wfd, (char __force_user *)victim, count);
74596 body_len -= count;
74597 eat(count);
74598 return 1;
74599 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
74600 {
74601 collected[N_ALIGN(name_len) + body_len] = '\0';
74602 clean_path(collected, 0);
74603 - sys_symlink(collected + N_ALIGN(name_len), collected);
74604 - sys_lchown(collected, uid, gid);
74605 - do_utime(collected, mtime);
74606 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
74607 + sys_lchown((char __force_user *)collected, uid, gid);
74608 + do_utime((char __force_user *)collected, mtime);
74609 state = SkipIt;
74610 next_state = Reset;
74611 return 0;
74612 diff --git a/init/main.c b/init/main.c
74613 index cee4b5c..360e10a 100644
74614 --- a/init/main.c
74615 +++ b/init/main.c
74616 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
74617 extern void tc_init(void);
74618 #endif
74619
74620 +extern void grsecurity_init(void);
74621 +
74622 /*
74623 * Debug helper: via this flag we know that we are in 'early bootup code'
74624 * where only the boot processor is running with IRQ disabled. This means
74625 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
74626
74627 __setup("reset_devices", set_reset_devices);
74628
74629 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74630 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74631 +static int __init setup_grsec_proc_gid(char *str)
74632 +{
74633 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74634 + return 1;
74635 +}
74636 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74637 +#endif
74638 +
74639 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74640 +extern char pax_enter_kernel_user[];
74641 +extern char pax_exit_kernel_user[];
74642 +extern pgdval_t clone_pgd_mask;
74643 +#endif
74644 +
74645 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74646 +static int __init setup_pax_nouderef(char *str)
74647 +{
74648 +#ifdef CONFIG_X86_32
74649 + unsigned int cpu;
74650 + struct desc_struct *gdt;
74651 +
74652 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74653 + gdt = get_cpu_gdt_table(cpu);
74654 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74655 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74656 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74657 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74658 + }
74659 + loadsegment(ds, __KERNEL_DS);
74660 + loadsegment(es, __KERNEL_DS);
74661 + loadsegment(ss, __KERNEL_DS);
74662 +#else
74663 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74664 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74665 + clone_pgd_mask = ~(pgdval_t)0UL;
74666 +#endif
74667 +
74668 + return 0;
74669 +}
74670 +early_param("pax_nouderef", setup_pax_nouderef);
74671 +#endif
74672 +
74673 +#ifdef CONFIG_PAX_SOFTMODE
74674 +int pax_softmode;
74675 +
74676 +static int __init setup_pax_softmode(char *str)
74677 +{
74678 + get_option(&str, &pax_softmode);
74679 + return 1;
74680 +}
74681 +__setup("pax_softmode=", setup_pax_softmode);
74682 +#endif
74683 +
74684 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74685 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74686 static const char *panic_later, *panic_param;
74687 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
74688 {
74689 int count = preempt_count();
74690 int ret;
74691 + const char *msg1 = "", *msg2 = "";
74692
74693 if (initcall_debug)
74694 ret = do_one_initcall_debug(fn);
74695 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
74696 sprintf(msgbuf, "error code %d ", ret);
74697
74698 if (preempt_count() != count) {
74699 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
74700 + msg1 = " preemption imbalance";
74701 preempt_count() = count;
74702 }
74703 if (irqs_disabled()) {
74704 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74705 + msg2 = " disabled interrupts";
74706 local_irq_enable();
74707 }
74708 - if (msgbuf[0]) {
74709 - printk("initcall %pF returned with %s\n", fn, msgbuf);
74710 + if (msgbuf[0] || *msg1 || *msg2) {
74711 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
74712 }
74713
74714 return ret;
74715 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
74716 level, level,
74717 &repair_env_string);
74718
74719 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74720 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74721 do_one_initcall(*fn);
74722 +
74723 +#ifdef LATENT_ENTROPY_PLUGIN
74724 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74725 +#endif
74726 +
74727 + }
74728 }
74729
74730 static void __init do_initcalls(void)
74731 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
74732 {
74733 initcall_t *fn;
74734
74735 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74736 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74737 do_one_initcall(*fn);
74738 +
74739 +#ifdef LATENT_ENTROPY_PLUGIN
74740 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74741 +#endif
74742 +
74743 + }
74744 }
74745
74746 static int run_init_process(const char *init_filename)
74747 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
74748 do_basic_setup();
74749
74750 /* Open the /dev/console on the rootfs, this should never fail */
74751 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74752 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74753 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74754
74755 (void) sys_dup(0);
74756 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
74757 if (!ramdisk_execute_command)
74758 ramdisk_execute_command = "/init";
74759
74760 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74761 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74762 ramdisk_execute_command = NULL;
74763 prepare_namespace();
74764 }
74765
74766 + grsecurity_init();
74767 +
74768 /*
74769 * Ok, we have completed the initial bootup, and
74770 * we're essentially up and running. Get rid of the
74771 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74772 index 130dfec..cc88451 100644
74773 --- a/ipc/ipc_sysctl.c
74774 +++ b/ipc/ipc_sysctl.c
74775 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74776 static int proc_ipc_dointvec(ctl_table *table, int write,
74777 void __user *buffer, size_t *lenp, loff_t *ppos)
74778 {
74779 - struct ctl_table ipc_table;
74780 + ctl_table_no_const ipc_table;
74781
74782 memcpy(&ipc_table, table, sizeof(ipc_table));
74783 ipc_table.data = get_ipc(table);
74784 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74785 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74786 void __user *buffer, size_t *lenp, loff_t *ppos)
74787 {
74788 - struct ctl_table ipc_table;
74789 + ctl_table_no_const ipc_table;
74790
74791 memcpy(&ipc_table, table, sizeof(ipc_table));
74792 ipc_table.data = get_ipc(table);
74793 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74794 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74795 void __user *buffer, size_t *lenp, loff_t *ppos)
74796 {
74797 - struct ctl_table ipc_table;
74798 + ctl_table_no_const ipc_table;
74799 size_t lenp_bef = *lenp;
74800 int rc;
74801
74802 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74803 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74804 void __user *buffer, size_t *lenp, loff_t *ppos)
74805 {
74806 - struct ctl_table ipc_table;
74807 + ctl_table_no_const ipc_table;
74808 memcpy(&ipc_table, table, sizeof(ipc_table));
74809 ipc_table.data = get_ipc(table);
74810
74811 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74812 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74813 void __user *buffer, size_t *lenp, loff_t *ppos)
74814 {
74815 - struct ctl_table ipc_table;
74816 + ctl_table_no_const ipc_table;
74817 size_t lenp_bef = *lenp;
74818 int oldval;
74819 int rc;
74820 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74821 index 383d638..943fdbb 100644
74822 --- a/ipc/mq_sysctl.c
74823 +++ b/ipc/mq_sysctl.c
74824 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74825 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74826 void __user *buffer, size_t *lenp, loff_t *ppos)
74827 {
74828 - struct ctl_table mq_table;
74829 + ctl_table_no_const mq_table;
74830 memcpy(&mq_table, table, sizeof(mq_table));
74831 mq_table.data = get_mq(table);
74832
74833 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74834 index f3f40dc..ffe5a3a 100644
74835 --- a/ipc/mqueue.c
74836 +++ b/ipc/mqueue.c
74837 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74838 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74839 info->attr.mq_msgsize);
74840
74841 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74842 spin_lock(&mq_lock);
74843 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74844 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74845 diff --git a/ipc/msg.c b/ipc/msg.c
74846 index fede1d0..9778e0f8 100644
74847 --- a/ipc/msg.c
74848 +++ b/ipc/msg.c
74849 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74850 return security_msg_queue_associate(msq, msgflg);
74851 }
74852
74853 +static struct ipc_ops msg_ops = {
74854 + .getnew = newque,
74855 + .associate = msg_security,
74856 + .more_checks = NULL
74857 +};
74858 +
74859 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74860 {
74861 struct ipc_namespace *ns;
74862 - struct ipc_ops msg_ops;
74863 struct ipc_params msg_params;
74864
74865 ns = current->nsproxy->ipc_ns;
74866
74867 - msg_ops.getnew = newque;
74868 - msg_ops.associate = msg_security;
74869 - msg_ops.more_checks = NULL;
74870 -
74871 msg_params.key = key;
74872 msg_params.flg = msgflg;
74873
74874 diff --git a/ipc/sem.c b/ipc/sem.c
74875 index 58d31f1..cce7a55 100644
74876 --- a/ipc/sem.c
74877 +++ b/ipc/sem.c
74878 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74879 return 0;
74880 }
74881
74882 +static struct ipc_ops sem_ops = {
74883 + .getnew = newary,
74884 + .associate = sem_security,
74885 + .more_checks = sem_more_checks
74886 +};
74887 +
74888 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74889 {
74890 struct ipc_namespace *ns;
74891 - struct ipc_ops sem_ops;
74892 struct ipc_params sem_params;
74893
74894 ns = current->nsproxy->ipc_ns;
74895 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74896 if (nsems < 0 || nsems > ns->sc_semmsl)
74897 return -EINVAL;
74898
74899 - sem_ops.getnew = newary;
74900 - sem_ops.associate = sem_security;
74901 - sem_ops.more_checks = sem_more_checks;
74902 -
74903 sem_params.key = key;
74904 sem_params.flg = semflg;
74905 sem_params.u.nsems = nsems;
74906 diff --git a/ipc/shm.c b/ipc/shm.c
74907 index 4fa6d8f..55cff14 100644
74908 --- a/ipc/shm.c
74909 +++ b/ipc/shm.c
74910 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74911 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74912 #endif
74913
74914 +#ifdef CONFIG_GRKERNSEC
74915 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74916 + const time_t shm_createtime, const kuid_t cuid,
74917 + const int shmid);
74918 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74919 + const time_t shm_createtime);
74920 +#endif
74921 +
74922 void shm_init_ns(struct ipc_namespace *ns)
74923 {
74924 ns->shm_ctlmax = SHMMAX;
74925 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74926 shp->shm_lprid = 0;
74927 shp->shm_atim = shp->shm_dtim = 0;
74928 shp->shm_ctim = get_seconds();
74929 +#ifdef CONFIG_GRKERNSEC
74930 + {
74931 + struct timespec timeval;
74932 + do_posix_clock_monotonic_gettime(&timeval);
74933 +
74934 + shp->shm_createtime = timeval.tv_sec;
74935 + }
74936 +#endif
74937 shp->shm_segsz = size;
74938 shp->shm_nattch = 0;
74939 shp->shm_file = file;
74940 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74941 return 0;
74942 }
74943
74944 +static struct ipc_ops shm_ops = {
74945 + .getnew = newseg,
74946 + .associate = shm_security,
74947 + .more_checks = shm_more_checks
74948 +};
74949 +
74950 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74951 {
74952 struct ipc_namespace *ns;
74953 - struct ipc_ops shm_ops;
74954 struct ipc_params shm_params;
74955
74956 ns = current->nsproxy->ipc_ns;
74957
74958 - shm_ops.getnew = newseg;
74959 - shm_ops.associate = shm_security;
74960 - shm_ops.more_checks = shm_more_checks;
74961 -
74962 shm_params.key = key;
74963 shm_params.flg = shmflg;
74964 shm_params.u.size = size;
74965 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74966 f_mode = FMODE_READ | FMODE_WRITE;
74967 }
74968 if (shmflg & SHM_EXEC) {
74969 +
74970 +#ifdef CONFIG_PAX_MPROTECT
74971 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74972 + goto out;
74973 +#endif
74974 +
74975 prot |= PROT_EXEC;
74976 acc_mode |= S_IXUGO;
74977 }
74978 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74979 if (err)
74980 goto out_unlock;
74981
74982 +#ifdef CONFIG_GRKERNSEC
74983 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74984 + shp->shm_perm.cuid, shmid) ||
74985 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74986 + err = -EACCES;
74987 + goto out_unlock;
74988 + }
74989 +#endif
74990 +
74991 path = shp->shm_file->f_path;
74992 path_get(&path);
74993 shp->shm_nattch++;
74994 +#ifdef CONFIG_GRKERNSEC
74995 + shp->shm_lapid = current->pid;
74996 +#endif
74997 size = i_size_read(path.dentry->d_inode);
74998 shm_unlock(shp);
74999
75000 diff --git a/kernel/acct.c b/kernel/acct.c
75001 index 051e071..15e0920 100644
75002 --- a/kernel/acct.c
75003 +++ b/kernel/acct.c
75004 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
75005 */
75006 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
75007 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
75008 - file->f_op->write(file, (char *)&ac,
75009 + file->f_op->write(file, (char __force_user *)&ac,
75010 sizeof(acct_t), &file->f_pos);
75011 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
75012 set_fs(fs);
75013 diff --git a/kernel/audit.c b/kernel/audit.c
75014 index d596e53..dbef3c3 100644
75015 --- a/kernel/audit.c
75016 +++ b/kernel/audit.c
75017 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
75018 3) suppressed due to audit_rate_limit
75019 4) suppressed due to audit_backlog_limit
75020 */
75021 -static atomic_t audit_lost = ATOMIC_INIT(0);
75022 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
75023
75024 /* The netlink socket. */
75025 static struct sock *audit_sock;
75026 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
75027 unsigned long now;
75028 int print;
75029
75030 - atomic_inc(&audit_lost);
75031 + atomic_inc_unchecked(&audit_lost);
75032
75033 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
75034
75035 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
75036 printk(KERN_WARNING
75037 "audit: audit_lost=%d audit_rate_limit=%d "
75038 "audit_backlog_limit=%d\n",
75039 - atomic_read(&audit_lost),
75040 + atomic_read_unchecked(&audit_lost),
75041 audit_rate_limit,
75042 audit_backlog_limit);
75043 audit_panic(message);
75044 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
75045 status_set.pid = audit_pid;
75046 status_set.rate_limit = audit_rate_limit;
75047 status_set.backlog_limit = audit_backlog_limit;
75048 - status_set.lost = atomic_read(&audit_lost);
75049 + status_set.lost = atomic_read_unchecked(&audit_lost);
75050 status_set.backlog = skb_queue_len(&audit_skb_queue);
75051 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
75052 &status_set, sizeof(status_set));
75053 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
75054 index a371f85..da826c1 100644
75055 --- a/kernel/auditsc.c
75056 +++ b/kernel/auditsc.c
75057 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
75058 }
75059
75060 /* global counter which is incremented every time something logs in */
75061 -static atomic_t session_id = ATOMIC_INIT(0);
75062 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
75063
75064 /**
75065 * audit_set_loginuid - set current task's audit_context loginuid
75066 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
75067 return -EPERM;
75068 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
75069
75070 - sessionid = atomic_inc_return(&session_id);
75071 + sessionid = atomic_inc_return_unchecked(&session_id);
75072 if (context && context->in_syscall) {
75073 struct audit_buffer *ab;
75074
75075 diff --git a/kernel/capability.c b/kernel/capability.c
75076 index f6c2ce5..982c0f9 100644
75077 --- a/kernel/capability.c
75078 +++ b/kernel/capability.c
75079 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
75080 * before modification is attempted and the application
75081 * fails.
75082 */
75083 + if (tocopy > ARRAY_SIZE(kdata))
75084 + return -EFAULT;
75085 +
75086 if (copy_to_user(dataptr, kdata, tocopy
75087 * sizeof(struct __user_cap_data_struct))) {
75088 return -EFAULT;
75089 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
75090 int ret;
75091
75092 rcu_read_lock();
75093 - ret = security_capable(__task_cred(t), ns, cap);
75094 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
75095 + gr_task_is_capable(t, __task_cred(t), cap);
75096 rcu_read_unlock();
75097
75098 - return (ret == 0);
75099 + return ret;
75100 }
75101
75102 /**
75103 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
75104 int ret;
75105
75106 rcu_read_lock();
75107 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
75108 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
75109 rcu_read_unlock();
75110
75111 - return (ret == 0);
75112 + return ret;
75113 }
75114
75115 /**
75116 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
75117 BUG();
75118 }
75119
75120 - if (security_capable(current_cred(), ns, cap) == 0) {
75121 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
75122 current->flags |= PF_SUPERPRIV;
75123 return true;
75124 }
75125 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
75126 }
75127 EXPORT_SYMBOL(ns_capable);
75128
75129 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
75130 +{
75131 + if (unlikely(!cap_valid(cap))) {
75132 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
75133 + BUG();
75134 + }
75135 +
75136 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
75137 + current->flags |= PF_SUPERPRIV;
75138 + return true;
75139 + }
75140 + return false;
75141 +}
75142 +EXPORT_SYMBOL(ns_capable_nolog);
75143 +
75144 /**
75145 * file_ns_capable - Determine if the file's opener had a capability in effect
75146 * @file: The file we want to check
75147 @@ -432,6 +451,12 @@ bool capable(int cap)
75148 }
75149 EXPORT_SYMBOL(capable);
75150
75151 +bool capable_nolog(int cap)
75152 +{
75153 + return ns_capable_nolog(&init_user_ns, cap);
75154 +}
75155 +EXPORT_SYMBOL(capable_nolog);
75156 +
75157 /**
75158 * nsown_capable - Check superior capability to one's own user_ns
75159 * @cap: The capability in question
75160 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
75161
75162 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
75163 }
75164 +
75165 +bool inode_capable_nolog(const struct inode *inode, int cap)
75166 +{
75167 + struct user_namespace *ns = current_user_ns();
75168 +
75169 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
75170 +}
75171 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
75172 index 1e23664..570a83d 100644
75173 --- a/kernel/cgroup.c
75174 +++ b/kernel/cgroup.c
75175 @@ -5543,7 +5543,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
75176 struct css_set *cg = link->cg;
75177 struct task_struct *task;
75178 int count = 0;
75179 - seq_printf(seq, "css_set %p\n", cg);
75180 + seq_printf(seq, "css_set %pK\n", cg);
75181 list_for_each_entry(task, &cg->tasks, cg_list) {
75182 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
75183 seq_puts(seq, " ...\n");
75184 diff --git a/kernel/compat.c b/kernel/compat.c
75185 index 36700e9..73d770c 100644
75186 --- a/kernel/compat.c
75187 +++ b/kernel/compat.c
75188 @@ -13,6 +13,7 @@
75189
75190 #include <linux/linkage.h>
75191 #include <linux/compat.h>
75192 +#include <linux/module.h>
75193 #include <linux/errno.h>
75194 #include <linux/time.h>
75195 #include <linux/signal.h>
75196 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
75197 mm_segment_t oldfs;
75198 long ret;
75199
75200 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
75201 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
75202 oldfs = get_fs();
75203 set_fs(KERNEL_DS);
75204 ret = hrtimer_nanosleep_restart(restart);
75205 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
75206 oldfs = get_fs();
75207 set_fs(KERNEL_DS);
75208 ret = hrtimer_nanosleep(&tu,
75209 - rmtp ? (struct timespec __user *)&rmt : NULL,
75210 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
75211 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
75212 set_fs(oldfs);
75213
75214 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
75215 mm_segment_t old_fs = get_fs();
75216
75217 set_fs(KERNEL_DS);
75218 - ret = sys_sigpending((old_sigset_t __user *) &s);
75219 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
75220 set_fs(old_fs);
75221 if (ret == 0)
75222 ret = put_user(s, set);
75223 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
75224 mm_segment_t old_fs = get_fs();
75225
75226 set_fs(KERNEL_DS);
75227 - ret = sys_old_getrlimit(resource, &r);
75228 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
75229 set_fs(old_fs);
75230
75231 if (!ret) {
75232 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
75233 mm_segment_t old_fs = get_fs();
75234
75235 set_fs(KERNEL_DS);
75236 - ret = sys_getrusage(who, (struct rusage __user *) &r);
75237 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
75238 set_fs(old_fs);
75239
75240 if (ret)
75241 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
75242 set_fs (KERNEL_DS);
75243 ret = sys_wait4(pid,
75244 (stat_addr ?
75245 - (unsigned int __user *) &status : NULL),
75246 - options, (struct rusage __user *) &r);
75247 + (unsigned int __force_user *) &status : NULL),
75248 + options, (struct rusage __force_user *) &r);
75249 set_fs (old_fs);
75250
75251 if (ret > 0) {
75252 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
75253 memset(&info, 0, sizeof(info));
75254
75255 set_fs(KERNEL_DS);
75256 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
75257 - uru ? (struct rusage __user *)&ru : NULL);
75258 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
75259 + uru ? (struct rusage __force_user *)&ru : NULL);
75260 set_fs(old_fs);
75261
75262 if ((ret < 0) || (info.si_signo == 0))
75263 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
75264 oldfs = get_fs();
75265 set_fs(KERNEL_DS);
75266 err = sys_timer_settime(timer_id, flags,
75267 - (struct itimerspec __user *) &newts,
75268 - (struct itimerspec __user *) &oldts);
75269 + (struct itimerspec __force_user *) &newts,
75270 + (struct itimerspec __force_user *) &oldts);
75271 set_fs(oldfs);
75272 if (!err && old && put_compat_itimerspec(old, &oldts))
75273 return -EFAULT;
75274 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
75275 oldfs = get_fs();
75276 set_fs(KERNEL_DS);
75277 err = sys_timer_gettime(timer_id,
75278 - (struct itimerspec __user *) &ts);
75279 + (struct itimerspec __force_user *) &ts);
75280 set_fs(oldfs);
75281 if (!err && put_compat_itimerspec(setting, &ts))
75282 return -EFAULT;
75283 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
75284 oldfs = get_fs();
75285 set_fs(KERNEL_DS);
75286 err = sys_clock_settime(which_clock,
75287 - (struct timespec __user *) &ts);
75288 + (struct timespec __force_user *) &ts);
75289 set_fs(oldfs);
75290 return err;
75291 }
75292 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
75293 oldfs = get_fs();
75294 set_fs(KERNEL_DS);
75295 err = sys_clock_gettime(which_clock,
75296 - (struct timespec __user *) &ts);
75297 + (struct timespec __force_user *) &ts);
75298 set_fs(oldfs);
75299 if (!err && put_compat_timespec(&ts, tp))
75300 return -EFAULT;
75301 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
75302
75303 oldfs = get_fs();
75304 set_fs(KERNEL_DS);
75305 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
75306 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
75307 set_fs(oldfs);
75308
75309 err = compat_put_timex(utp, &txc);
75310 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
75311 oldfs = get_fs();
75312 set_fs(KERNEL_DS);
75313 err = sys_clock_getres(which_clock,
75314 - (struct timespec __user *) &ts);
75315 + (struct timespec __force_user *) &ts);
75316 set_fs(oldfs);
75317 if (!err && tp && put_compat_timespec(&ts, tp))
75318 return -EFAULT;
75319 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
75320 long err;
75321 mm_segment_t oldfs;
75322 struct timespec tu;
75323 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
75324 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
75325
75326 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
75327 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
75328 oldfs = get_fs();
75329 set_fs(KERNEL_DS);
75330 err = clock_nanosleep_restart(restart);
75331 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
75332 oldfs = get_fs();
75333 set_fs(KERNEL_DS);
75334 err = sys_clock_nanosleep(which_clock, flags,
75335 - (struct timespec __user *) &in,
75336 - (struct timespec __user *) &out);
75337 + (struct timespec __force_user *) &in,
75338 + (struct timespec __force_user *) &out);
75339 set_fs(oldfs);
75340
75341 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
75342 diff --git a/kernel/configs.c b/kernel/configs.c
75343 index 42e8fa0..9e7406b 100644
75344 --- a/kernel/configs.c
75345 +++ b/kernel/configs.c
75346 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
75347 struct proc_dir_entry *entry;
75348
75349 /* create the current config file */
75350 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
75351 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
75352 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
75353 + &ikconfig_file_ops);
75354 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75355 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
75356 + &ikconfig_file_ops);
75357 +#endif
75358 +#else
75359 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
75360 &ikconfig_file_ops);
75361 +#endif
75362 +
75363 if (!entry)
75364 return -ENOMEM;
75365
75366 diff --git a/kernel/cred.c b/kernel/cred.c
75367 index e0573a4..3874e41 100644
75368 --- a/kernel/cred.c
75369 +++ b/kernel/cred.c
75370 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
75371 validate_creds(cred);
75372 alter_cred_subscribers(cred, -1);
75373 put_cred(cred);
75374 +
75375 +#ifdef CONFIG_GRKERNSEC_SETXID
75376 + cred = (struct cred *) tsk->delayed_cred;
75377 + if (cred != NULL) {
75378 + tsk->delayed_cred = NULL;
75379 + validate_creds(cred);
75380 + alter_cred_subscribers(cred, -1);
75381 + put_cred(cred);
75382 + }
75383 +#endif
75384 }
75385
75386 /**
75387 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
75388 * Always returns 0 thus allowing this function to be tail-called at the end
75389 * of, say, sys_setgid().
75390 */
75391 -int commit_creds(struct cred *new)
75392 +static int __commit_creds(struct cred *new)
75393 {
75394 struct task_struct *task = current;
75395 const struct cred *old = task->real_cred;
75396 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
75397
75398 get_cred(new); /* we will require a ref for the subj creds too */
75399
75400 + gr_set_role_label(task, new->uid, new->gid);
75401 +
75402 /* dumpability changes */
75403 if (!uid_eq(old->euid, new->euid) ||
75404 !gid_eq(old->egid, new->egid) ||
75405 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
75406 put_cred(old);
75407 return 0;
75408 }
75409 +#ifdef CONFIG_GRKERNSEC_SETXID
75410 +extern int set_user(struct cred *new);
75411 +
75412 +void gr_delayed_cred_worker(void)
75413 +{
75414 + const struct cred *new = current->delayed_cred;
75415 + struct cred *ncred;
75416 +
75417 + current->delayed_cred = NULL;
75418 +
75419 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
75420 + // from doing get_cred on it when queueing this
75421 + put_cred(new);
75422 + return;
75423 + } else if (new == NULL)
75424 + return;
75425 +
75426 + ncred = prepare_creds();
75427 + if (!ncred)
75428 + goto die;
75429 + // uids
75430 + ncred->uid = new->uid;
75431 + ncred->euid = new->euid;
75432 + ncred->suid = new->suid;
75433 + ncred->fsuid = new->fsuid;
75434 + // gids
75435 + ncred->gid = new->gid;
75436 + ncred->egid = new->egid;
75437 + ncred->sgid = new->sgid;
75438 + ncred->fsgid = new->fsgid;
75439 + // groups
75440 + if (set_groups(ncred, new->group_info) < 0) {
75441 + abort_creds(ncred);
75442 + goto die;
75443 + }
75444 + // caps
75445 + ncred->securebits = new->securebits;
75446 + ncred->cap_inheritable = new->cap_inheritable;
75447 + ncred->cap_permitted = new->cap_permitted;
75448 + ncred->cap_effective = new->cap_effective;
75449 + ncred->cap_bset = new->cap_bset;
75450 +
75451 + if (set_user(ncred)) {
75452 + abort_creds(ncred);
75453 + goto die;
75454 + }
75455 +
75456 + // from doing get_cred on it when queueing this
75457 + put_cred(new);
75458 +
75459 + __commit_creds(ncred);
75460 + return;
75461 +die:
75462 + // from doing get_cred on it when queueing this
75463 + put_cred(new);
75464 + do_group_exit(SIGKILL);
75465 +}
75466 +#endif
75467 +
75468 +int commit_creds(struct cred *new)
75469 +{
75470 +#ifdef CONFIG_GRKERNSEC_SETXID
75471 + int ret;
75472 + int schedule_it = 0;
75473 + struct task_struct *t;
75474 +
75475 + /* we won't get called with tasklist_lock held for writing
75476 + and interrupts disabled as the cred struct in that case is
75477 + init_cred
75478 + */
75479 + if (grsec_enable_setxid && !current_is_single_threaded() &&
75480 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
75481 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
75482 + schedule_it = 1;
75483 + }
75484 + ret = __commit_creds(new);
75485 + if (schedule_it) {
75486 + rcu_read_lock();
75487 + read_lock(&tasklist_lock);
75488 + for (t = next_thread(current); t != current;
75489 + t = next_thread(t)) {
75490 + if (t->delayed_cred == NULL) {
75491 + t->delayed_cred = get_cred(new);
75492 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
75493 + set_tsk_need_resched(t);
75494 + }
75495 + }
75496 + read_unlock(&tasklist_lock);
75497 + rcu_read_unlock();
75498 + }
75499 + return ret;
75500 +#else
75501 + return __commit_creds(new);
75502 +#endif
75503 +}
75504 +
75505 EXPORT_SYMBOL(commit_creds);
75506
75507 /**
75508 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
75509 index 9a61738..c5c8f3a 100644
75510 --- a/kernel/debug/debug_core.c
75511 +++ b/kernel/debug/debug_core.c
75512 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
75513 */
75514 static atomic_t masters_in_kgdb;
75515 static atomic_t slaves_in_kgdb;
75516 -static atomic_t kgdb_break_tasklet_var;
75517 +static atomic_unchecked_t kgdb_break_tasklet_var;
75518 atomic_t kgdb_setting_breakpoint;
75519
75520 struct task_struct *kgdb_usethread;
75521 @@ -132,7 +132,7 @@ int kgdb_single_step;
75522 static pid_t kgdb_sstep_pid;
75523
75524 /* to keep track of the CPU which is doing the single stepping*/
75525 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75526 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75527
75528 /*
75529 * If you are debugging a problem where roundup (the collection of
75530 @@ -540,7 +540,7 @@ return_normal:
75531 * kernel will only try for the value of sstep_tries before
75532 * giving up and continuing on.
75533 */
75534 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
75535 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
75536 (kgdb_info[cpu].task &&
75537 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
75538 atomic_set(&kgdb_active, -1);
75539 @@ -634,8 +634,8 @@ cpu_master_loop:
75540 }
75541
75542 kgdb_restore:
75543 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
75544 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
75545 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
75546 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
75547 if (kgdb_info[sstep_cpu].task)
75548 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
75549 else
75550 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
75551 static void kgdb_tasklet_bpt(unsigned long ing)
75552 {
75553 kgdb_breakpoint();
75554 - atomic_set(&kgdb_break_tasklet_var, 0);
75555 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
75556 }
75557
75558 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
75559
75560 void kgdb_schedule_breakpoint(void)
75561 {
75562 - if (atomic_read(&kgdb_break_tasklet_var) ||
75563 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
75564 atomic_read(&kgdb_active) != -1 ||
75565 atomic_read(&kgdb_setting_breakpoint))
75566 return;
75567 - atomic_inc(&kgdb_break_tasklet_var);
75568 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
75569 tasklet_schedule(&kgdb_tasklet_breakpoint);
75570 }
75571 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
75572 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
75573 index 8875254..7cf4928 100644
75574 --- a/kernel/debug/kdb/kdb_main.c
75575 +++ b/kernel/debug/kdb/kdb_main.c
75576 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
75577 continue;
75578
75579 kdb_printf("%-20s%8u 0x%p ", mod->name,
75580 - mod->core_size, (void *)mod);
75581 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
75582 #ifdef CONFIG_MODULE_UNLOAD
75583 kdb_printf("%4ld ", module_refcount(mod));
75584 #endif
75585 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
75586 kdb_printf(" (Loading)");
75587 else
75588 kdb_printf(" (Live)");
75589 - kdb_printf(" 0x%p", mod->module_core);
75590 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
75591
75592 #ifdef CONFIG_MODULE_UNLOAD
75593 {
75594 diff --git a/kernel/events/core.c b/kernel/events/core.c
75595 index 0600d3b..742ab1b 100644
75596 --- a/kernel/events/core.c
75597 +++ b/kernel/events/core.c
75598 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
75599 return 0;
75600 }
75601
75602 -static atomic64_t perf_event_id;
75603 +static atomic64_unchecked_t perf_event_id;
75604
75605 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
75606 enum event_type_t event_type);
75607 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
75608
75609 static inline u64 perf_event_count(struct perf_event *event)
75610 {
75611 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75612 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75613 }
75614
75615 static u64 perf_event_read(struct perf_event *event)
75616 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75617 mutex_lock(&event->child_mutex);
75618 total += perf_event_read(event);
75619 *enabled += event->total_time_enabled +
75620 - atomic64_read(&event->child_total_time_enabled);
75621 + atomic64_read_unchecked(&event->child_total_time_enabled);
75622 *running += event->total_time_running +
75623 - atomic64_read(&event->child_total_time_running);
75624 + atomic64_read_unchecked(&event->child_total_time_running);
75625
75626 list_for_each_entry(child, &event->child_list, child_list) {
75627 total += perf_event_read(child);
75628 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
75629 userpg->offset -= local64_read(&event->hw.prev_count);
75630
75631 userpg->time_enabled = enabled +
75632 - atomic64_read(&event->child_total_time_enabled);
75633 + atomic64_read_unchecked(&event->child_total_time_enabled);
75634
75635 userpg->time_running = running +
75636 - atomic64_read(&event->child_total_time_running);
75637 + atomic64_read_unchecked(&event->child_total_time_running);
75638
75639 arch_perf_update_userpage(userpg, now);
75640
75641 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75642 values[n++] = perf_event_count(event);
75643 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75644 values[n++] = enabled +
75645 - atomic64_read(&event->child_total_time_enabled);
75646 + atomic64_read_unchecked(&event->child_total_time_enabled);
75647 }
75648 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75649 values[n++] = running +
75650 - atomic64_read(&event->child_total_time_running);
75651 + atomic64_read_unchecked(&event->child_total_time_running);
75652 }
75653 if (read_format & PERF_FORMAT_ID)
75654 values[n++] = primary_event_id(event);
75655 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75656 * need to add enough zero bytes after the string to handle
75657 * the 64bit alignment we do later.
75658 */
75659 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75660 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75661 if (!buf) {
75662 name = strncpy(tmp, "//enomem", sizeof(tmp));
75663 goto got_name;
75664 }
75665 - name = d_path(&file->f_path, buf, PATH_MAX);
75666 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75667 if (IS_ERR(name)) {
75668 name = strncpy(tmp, "//toolong", sizeof(tmp));
75669 goto got_name;
75670 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75671 event->parent = parent_event;
75672
75673 event->ns = get_pid_ns(task_active_pid_ns(current));
75674 - event->id = atomic64_inc_return(&perf_event_id);
75675 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75676
75677 event->state = PERF_EVENT_STATE_INACTIVE;
75678
75679 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
75680 /*
75681 * Add back the child's count to the parent's count:
75682 */
75683 - atomic64_add(child_val, &parent_event->child_count);
75684 - atomic64_add(child_event->total_time_enabled,
75685 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75686 + atomic64_add_unchecked(child_event->total_time_enabled,
75687 &parent_event->child_total_time_enabled);
75688 - atomic64_add(child_event->total_time_running,
75689 + atomic64_add_unchecked(child_event->total_time_running,
75690 &parent_event->child_total_time_running);
75691
75692 /*
75693 diff --git a/kernel/exit.c b/kernel/exit.c
75694 index b4df219..f13c02d 100644
75695 --- a/kernel/exit.c
75696 +++ b/kernel/exit.c
75697 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
75698 struct task_struct *leader;
75699 int zap_leader;
75700 repeat:
75701 +#ifdef CONFIG_NET
75702 + gr_del_task_from_ip_table(p);
75703 +#endif
75704 +
75705 /* don't need to get the RCU readlock here - the process is dead and
75706 * can't be modifying its own credentials. But shut RCU-lockdep up */
75707 rcu_read_lock();
75708 @@ -338,7 +342,7 @@ int allow_signal(int sig)
75709 * know it'll be handled, so that they don't get converted to
75710 * SIGKILL or just silently dropped.
75711 */
75712 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75713 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75714 recalc_sigpending();
75715 spin_unlock_irq(&current->sighand->siglock);
75716 return 0;
75717 @@ -708,6 +712,8 @@ void do_exit(long code)
75718 struct task_struct *tsk = current;
75719 int group_dead;
75720
75721 + set_fs(USER_DS);
75722 +
75723 profile_task_exit(tsk);
75724
75725 WARN_ON(blk_needs_flush_plug(tsk));
75726 @@ -724,7 +730,6 @@ void do_exit(long code)
75727 * mm_release()->clear_child_tid() from writing to a user-controlled
75728 * kernel address.
75729 */
75730 - set_fs(USER_DS);
75731
75732 ptrace_event(PTRACE_EVENT_EXIT, code);
75733
75734 @@ -783,6 +788,9 @@ void do_exit(long code)
75735 tsk->exit_code = code;
75736 taskstats_exit(tsk, group_dead);
75737
75738 + gr_acl_handle_psacct(tsk, code);
75739 + gr_acl_handle_exit();
75740 +
75741 exit_mm(tsk);
75742
75743 if (group_dead)
75744 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75745 * Take down every thread in the group. This is called by fatal signals
75746 * as well as by sys_exit_group (below).
75747 */
75748 -void
75749 +__noreturn void
75750 do_group_exit(int exit_code)
75751 {
75752 struct signal_struct *sig = current->signal;
75753 diff --git a/kernel/fork.c b/kernel/fork.c
75754 index 5630e52..0cee608 100644
75755 --- a/kernel/fork.c
75756 +++ b/kernel/fork.c
75757 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75758 *stackend = STACK_END_MAGIC; /* for overflow detection */
75759
75760 #ifdef CONFIG_CC_STACKPROTECTOR
75761 - tsk->stack_canary = get_random_int();
75762 + tsk->stack_canary = pax_get_random_long();
75763 #endif
75764
75765 /*
75766 @@ -344,13 +344,81 @@ free_tsk:
75767 }
75768
75769 #ifdef CONFIG_MMU
75770 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75771 +{
75772 + struct vm_area_struct *tmp;
75773 + unsigned long charge;
75774 + struct mempolicy *pol;
75775 + struct file *file;
75776 +
75777 + charge = 0;
75778 + if (mpnt->vm_flags & VM_ACCOUNT) {
75779 + unsigned long len = vma_pages(mpnt);
75780 +
75781 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75782 + goto fail_nomem;
75783 + charge = len;
75784 + }
75785 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75786 + if (!tmp)
75787 + goto fail_nomem;
75788 + *tmp = *mpnt;
75789 + tmp->vm_mm = mm;
75790 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75791 + pol = mpol_dup(vma_policy(mpnt));
75792 + if (IS_ERR(pol))
75793 + goto fail_nomem_policy;
75794 + vma_set_policy(tmp, pol);
75795 + if (anon_vma_fork(tmp, mpnt))
75796 + goto fail_nomem_anon_vma_fork;
75797 + tmp->vm_flags &= ~VM_LOCKED;
75798 + tmp->vm_next = tmp->vm_prev = NULL;
75799 + tmp->vm_mirror = NULL;
75800 + file = tmp->vm_file;
75801 + if (file) {
75802 + struct inode *inode = file->f_path.dentry->d_inode;
75803 + struct address_space *mapping = file->f_mapping;
75804 +
75805 + get_file(file);
75806 + if (tmp->vm_flags & VM_DENYWRITE)
75807 + atomic_dec(&inode->i_writecount);
75808 + mutex_lock(&mapping->i_mmap_mutex);
75809 + if (tmp->vm_flags & VM_SHARED)
75810 + mapping->i_mmap_writable++;
75811 + flush_dcache_mmap_lock(mapping);
75812 + /* insert tmp into the share list, just after mpnt */
75813 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75814 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75815 + else
75816 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75817 + flush_dcache_mmap_unlock(mapping);
75818 + mutex_unlock(&mapping->i_mmap_mutex);
75819 + }
75820 +
75821 + /*
75822 + * Clear hugetlb-related page reserves for children. This only
75823 + * affects MAP_PRIVATE mappings. Faults generated by the child
75824 + * are not guaranteed to succeed, even if read-only
75825 + */
75826 + if (is_vm_hugetlb_page(tmp))
75827 + reset_vma_resv_huge_pages(tmp);
75828 +
75829 + return tmp;
75830 +
75831 +fail_nomem_anon_vma_fork:
75832 + mpol_put(pol);
75833 +fail_nomem_policy:
75834 + kmem_cache_free(vm_area_cachep, tmp);
75835 +fail_nomem:
75836 + vm_unacct_memory(charge);
75837 + return NULL;
75838 +}
75839 +
75840 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75841 {
75842 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75843 struct rb_node **rb_link, *rb_parent;
75844 int retval;
75845 - unsigned long charge;
75846 - struct mempolicy *pol;
75847
75848 uprobe_start_dup_mmap();
75849 down_write(&oldmm->mmap_sem);
75850 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75851 mm->locked_vm = 0;
75852 mm->mmap = NULL;
75853 mm->mmap_cache = NULL;
75854 - mm->free_area_cache = oldmm->mmap_base;
75855 - mm->cached_hole_size = ~0UL;
75856 + mm->free_area_cache = oldmm->free_area_cache;
75857 + mm->cached_hole_size = oldmm->cached_hole_size;
75858 mm->map_count = 0;
75859 cpumask_clear(mm_cpumask(mm));
75860 mm->mm_rb = RB_ROOT;
75861 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75862
75863 prev = NULL;
75864 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75865 - struct file *file;
75866 -
75867 if (mpnt->vm_flags & VM_DONTCOPY) {
75868 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75869 -vma_pages(mpnt));
75870 continue;
75871 }
75872 - charge = 0;
75873 - if (mpnt->vm_flags & VM_ACCOUNT) {
75874 - unsigned long len = vma_pages(mpnt);
75875 -
75876 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75877 - goto fail_nomem;
75878 - charge = len;
75879 - }
75880 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75881 - if (!tmp)
75882 - goto fail_nomem;
75883 - *tmp = *mpnt;
75884 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75885 - pol = mpol_dup(vma_policy(mpnt));
75886 - retval = PTR_ERR(pol);
75887 - if (IS_ERR(pol))
75888 - goto fail_nomem_policy;
75889 - vma_set_policy(tmp, pol);
75890 - tmp->vm_mm = mm;
75891 - if (anon_vma_fork(tmp, mpnt))
75892 - goto fail_nomem_anon_vma_fork;
75893 - tmp->vm_flags &= ~VM_LOCKED;
75894 - tmp->vm_next = tmp->vm_prev = NULL;
75895 - file = tmp->vm_file;
75896 - if (file) {
75897 - struct inode *inode = file->f_path.dentry->d_inode;
75898 - struct address_space *mapping = file->f_mapping;
75899 -
75900 - get_file(file);
75901 - if (tmp->vm_flags & VM_DENYWRITE)
75902 - atomic_dec(&inode->i_writecount);
75903 - mutex_lock(&mapping->i_mmap_mutex);
75904 - if (tmp->vm_flags & VM_SHARED)
75905 - mapping->i_mmap_writable++;
75906 - flush_dcache_mmap_lock(mapping);
75907 - /* insert tmp into the share list, just after mpnt */
75908 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75909 - vma_nonlinear_insert(tmp,
75910 - &mapping->i_mmap_nonlinear);
75911 - else
75912 - vma_interval_tree_insert_after(tmp, mpnt,
75913 - &mapping->i_mmap);
75914 - flush_dcache_mmap_unlock(mapping);
75915 - mutex_unlock(&mapping->i_mmap_mutex);
75916 + tmp = dup_vma(mm, oldmm, mpnt);
75917 + if (!tmp) {
75918 + retval = -ENOMEM;
75919 + goto out;
75920 }
75921
75922 /*
75923 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75924 if (retval)
75925 goto out;
75926 }
75927 +
75928 +#ifdef CONFIG_PAX_SEGMEXEC
75929 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75930 + struct vm_area_struct *mpnt_m;
75931 +
75932 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75933 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75934 +
75935 + if (!mpnt->vm_mirror)
75936 + continue;
75937 +
75938 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75939 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75940 + mpnt->vm_mirror = mpnt_m;
75941 + } else {
75942 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75943 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75944 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75945 + mpnt->vm_mirror->vm_mirror = mpnt;
75946 + }
75947 + }
75948 + BUG_ON(mpnt_m);
75949 + }
75950 +#endif
75951 +
75952 /* a new mm has just been created */
75953 arch_dup_mmap(oldmm, mm);
75954 retval = 0;
75955 @@ -472,14 +523,6 @@ out:
75956 up_write(&oldmm->mmap_sem);
75957 uprobe_end_dup_mmap();
75958 return retval;
75959 -fail_nomem_anon_vma_fork:
75960 - mpol_put(pol);
75961 -fail_nomem_policy:
75962 - kmem_cache_free(vm_area_cachep, tmp);
75963 -fail_nomem:
75964 - retval = -ENOMEM;
75965 - vm_unacct_memory(charge);
75966 - goto out;
75967 }
75968
75969 static inline int mm_alloc_pgd(struct mm_struct *mm)
75970 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75971 return ERR_PTR(err);
75972
75973 mm = get_task_mm(task);
75974 - if (mm && mm != current->mm &&
75975 - !ptrace_may_access(task, mode)) {
75976 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75977 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75978 mmput(mm);
75979 mm = ERR_PTR(-EACCES);
75980 }
75981 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75982 spin_unlock(&fs->lock);
75983 return -EAGAIN;
75984 }
75985 - fs->users++;
75986 + atomic_inc(&fs->users);
75987 spin_unlock(&fs->lock);
75988 return 0;
75989 }
75990 tsk->fs = copy_fs_struct(fs);
75991 if (!tsk->fs)
75992 return -ENOMEM;
75993 + /* Carry through gr_chroot_dentry and is_chrooted instead
75994 + of recomputing it here. Already copied when the task struct
75995 + is duplicated. This allows pivot_root to not be treated as
75996 + a chroot
75997 + */
75998 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75999 +
76000 return 0;
76001 }
76002
76003 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
76004 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
76005 #endif
76006 retval = -EAGAIN;
76007 +
76008 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
76009 +
76010 if (atomic_read(&p->real_cred->user->processes) >=
76011 task_rlimit(p, RLIMIT_NPROC)) {
76012 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
76013 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
76014 goto bad_fork_free_pid;
76015 }
76016
76017 + /* synchronizes with gr_set_acls()
76018 + we need to call this past the point of no return for fork()
76019 + */
76020 + gr_copy_label(p);
76021 +
76022 if (clone_flags & CLONE_THREAD) {
76023 current->signal->nr_threads++;
76024 atomic_inc(&current->signal->live);
76025 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
76026 bad_fork_free:
76027 free_task(p);
76028 fork_out:
76029 + gr_log_forkfail(retval);
76030 +
76031 return ERR_PTR(retval);
76032 }
76033
76034 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
76035 return -EINVAL;
76036 }
76037
76038 +#ifdef CONFIG_GRKERNSEC
76039 + if (clone_flags & CLONE_NEWUSER) {
76040 + /*
76041 + * This doesn't really inspire confidence:
76042 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
76043 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
76044 + * Increases kernel attack surface in areas developers
76045 + * previously cared little about ("low importance due
76046 + * to requiring "root" capability")
76047 + * To be removed when this code receives *proper* review
76048 + */
76049 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
76050 + !capable(CAP_SETGID))
76051 + return -EPERM;
76052 + }
76053 +#endif
76054 +
76055 /*
76056 * Determine whether and which event to report to ptracer. When
76057 * called from kernel_thread or CLONE_UNTRACED is explicitly
76058 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
76059 if (clone_flags & CLONE_PARENT_SETTID)
76060 put_user(nr, parent_tidptr);
76061
76062 + gr_handle_brute_check();
76063 +
76064 if (clone_flags & CLONE_VFORK) {
76065 p->vfork_done = &vfork;
76066 init_completion(&vfork);
76067 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
76068 return 0;
76069
76070 /* don't need lock here; in the worst case we'll do useless copy */
76071 - if (fs->users == 1)
76072 + if (atomic_read(&fs->users) == 1)
76073 return 0;
76074
76075 *new_fsp = copy_fs_struct(fs);
76076 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
76077 fs = current->fs;
76078 spin_lock(&fs->lock);
76079 current->fs = new_fs;
76080 - if (--fs->users)
76081 + gr_set_chroot_entries(current, &current->fs->root);
76082 + if (atomic_dec_return(&fs->users))
76083 new_fs = NULL;
76084 else
76085 new_fs = fs;
76086 diff --git a/kernel/futex.c b/kernel/futex.c
76087 index 8879430..31696f1 100644
76088 --- a/kernel/futex.c
76089 +++ b/kernel/futex.c
76090 @@ -54,6 +54,7 @@
76091 #include <linux/mount.h>
76092 #include <linux/pagemap.h>
76093 #include <linux/syscalls.h>
76094 +#include <linux/ptrace.h>
76095 #include <linux/signal.h>
76096 #include <linux/export.h>
76097 #include <linux/magic.h>
76098 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
76099 struct page *page, *page_head;
76100 int err, ro = 0;
76101
76102 +#ifdef CONFIG_PAX_SEGMEXEC
76103 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
76104 + return -EFAULT;
76105 +#endif
76106 +
76107 /*
76108 * The futex address must be "naturally" aligned.
76109 */
76110 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
76111 {
76112 u32 curval;
76113 int i;
76114 + mm_segment_t oldfs;
76115
76116 /*
76117 * This will fail and we want it. Some arch implementations do
76118 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
76119 * implementation, the non-functional ones will return
76120 * -ENOSYS.
76121 */
76122 + oldfs = get_fs();
76123 + set_fs(USER_DS);
76124 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
76125 futex_cmpxchg_enabled = 1;
76126 + set_fs(oldfs);
76127
76128 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
76129 plist_head_init(&futex_queues[i].chain);
76130 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
76131 index a9642d5..51eb98c 100644
76132 --- a/kernel/futex_compat.c
76133 +++ b/kernel/futex_compat.c
76134 @@ -31,7 +31,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
76135 return 0;
76136 }
76137
76138 -static void __user *futex_uaddr(struct robust_list __user *entry,
76139 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
76140 compat_long_t futex_offset)
76141 {
76142 compat_uptr_t base = ptr_to_compat(entry);
76143 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
76144 index 9b22d03..6295b62 100644
76145 --- a/kernel/gcov/base.c
76146 +++ b/kernel/gcov/base.c
76147 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
76148 }
76149
76150 #ifdef CONFIG_MODULES
76151 -static inline int within(void *addr, void *start, unsigned long size)
76152 -{
76153 - return ((addr >= start) && (addr < start + size));
76154 -}
76155 -
76156 /* Update list and generate events when modules are unloaded. */
76157 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
76158 void *data)
76159 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
76160 prev = NULL;
76161 /* Remove entries located in module from linked list. */
76162 for (info = gcov_info_head; info; info = info->next) {
76163 - if (within(info, mod->module_core, mod->core_size)) {
76164 + if (within_module_core_rw((unsigned long)info, mod)) {
76165 if (prev)
76166 prev->next = info->next;
76167 else
76168 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
76169 index e4cee8d..f31f503 100644
76170 --- a/kernel/hrtimer.c
76171 +++ b/kernel/hrtimer.c
76172 @@ -1408,7 +1408,7 @@ void hrtimer_peek_ahead_timers(void)
76173 local_irq_restore(flags);
76174 }
76175
76176 -static void run_hrtimer_softirq(struct softirq_action *h)
76177 +static void run_hrtimer_softirq(void)
76178 {
76179 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
76180
76181 @@ -1750,7 +1750,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
76182 return NOTIFY_OK;
76183 }
76184
76185 -static struct notifier_block __cpuinitdata hrtimers_nb = {
76186 +static struct notifier_block hrtimers_nb = {
76187 .notifier_call = hrtimer_cpu_notify,
76188 };
76189
76190 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
76191 index 60f48fa..7f3a770 100644
76192 --- a/kernel/jump_label.c
76193 +++ b/kernel/jump_label.c
76194 @@ -13,6 +13,7 @@
76195 #include <linux/sort.h>
76196 #include <linux/err.h>
76197 #include <linux/static_key.h>
76198 +#include <linux/mm.h>
76199
76200 #ifdef HAVE_JUMP_LABEL
76201
76202 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
76203
76204 size = (((unsigned long)stop - (unsigned long)start)
76205 / sizeof(struct jump_entry));
76206 + pax_open_kernel();
76207 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
76208 + pax_close_kernel();
76209 }
76210
76211 static void jump_label_update(struct static_key *key, int enable);
76212 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
76213 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
76214 struct jump_entry *iter;
76215
76216 + pax_open_kernel();
76217 for (iter = iter_start; iter < iter_stop; iter++) {
76218 if (within_module_init(iter->code, mod))
76219 iter->code = 0;
76220 }
76221 + pax_close_kernel();
76222 }
76223
76224 static int
76225 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
76226 index 2169fee..706ccca 100644
76227 --- a/kernel/kallsyms.c
76228 +++ b/kernel/kallsyms.c
76229 @@ -11,6 +11,9 @@
76230 * Changed the compression method from stem compression to "table lookup"
76231 * compression (see scripts/kallsyms.c for a more complete description)
76232 */
76233 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76234 +#define __INCLUDED_BY_HIDESYM 1
76235 +#endif
76236 #include <linux/kallsyms.h>
76237 #include <linux/module.h>
76238 #include <linux/init.h>
76239 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
76240
76241 static inline int is_kernel_inittext(unsigned long addr)
76242 {
76243 + if (system_state != SYSTEM_BOOTING)
76244 + return 0;
76245 +
76246 if (addr >= (unsigned long)_sinittext
76247 && addr <= (unsigned long)_einittext)
76248 return 1;
76249 return 0;
76250 }
76251
76252 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76253 +#ifdef CONFIG_MODULES
76254 +static inline int is_module_text(unsigned long addr)
76255 +{
76256 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
76257 + return 1;
76258 +
76259 + addr = ktla_ktva(addr);
76260 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
76261 +}
76262 +#else
76263 +static inline int is_module_text(unsigned long addr)
76264 +{
76265 + return 0;
76266 +}
76267 +#endif
76268 +#endif
76269 +
76270 static inline int is_kernel_text(unsigned long addr)
76271 {
76272 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
76273 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
76274
76275 static inline int is_kernel(unsigned long addr)
76276 {
76277 +
76278 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76279 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
76280 + return 1;
76281 +
76282 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
76283 +#else
76284 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
76285 +#endif
76286 +
76287 return 1;
76288 return in_gate_area_no_mm(addr);
76289 }
76290
76291 static int is_ksym_addr(unsigned long addr)
76292 {
76293 +
76294 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76295 + if (is_module_text(addr))
76296 + return 0;
76297 +#endif
76298 +
76299 if (all_var)
76300 return is_kernel(addr);
76301
76302 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
76303
76304 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
76305 {
76306 - iter->name[0] = '\0';
76307 iter->nameoff = get_symbol_offset(new_pos);
76308 iter->pos = new_pos;
76309 }
76310 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
76311 {
76312 struct kallsym_iter *iter = m->private;
76313
76314 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76315 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
76316 + return 0;
76317 +#endif
76318 +
76319 /* Some debugging symbols have no name. Ignore them. */
76320 if (!iter->name[0])
76321 return 0;
76322 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
76323 */
76324 type = iter->exported ? toupper(iter->type) :
76325 tolower(iter->type);
76326 +
76327 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
76328 type, iter->name, iter->module_name);
76329 } else
76330 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
76331 struct kallsym_iter *iter;
76332 int ret;
76333
76334 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
76335 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
76336 if (!iter)
76337 return -ENOMEM;
76338 reset_iter(iter, 0);
76339 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
76340 index e30ac0f..3528cac 100644
76341 --- a/kernel/kcmp.c
76342 +++ b/kernel/kcmp.c
76343 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
76344 struct task_struct *task1, *task2;
76345 int ret;
76346
76347 +#ifdef CONFIG_GRKERNSEC
76348 + return -ENOSYS;
76349 +#endif
76350 +
76351 rcu_read_lock();
76352
76353 /*
76354 diff --git a/kernel/kexec.c b/kernel/kexec.c
76355 index 5e4bd78..00c5b91 100644
76356 --- a/kernel/kexec.c
76357 +++ b/kernel/kexec.c
76358 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
76359 unsigned long flags)
76360 {
76361 struct compat_kexec_segment in;
76362 - struct kexec_segment out, __user *ksegments;
76363 + struct kexec_segment out;
76364 + struct kexec_segment __user *ksegments;
76365 unsigned long i, result;
76366
76367 /* Don't allow clients that don't understand the native
76368 diff --git a/kernel/kmod.c b/kernel/kmod.c
76369 index 0023a87..9c0c068 100644
76370 --- a/kernel/kmod.c
76371 +++ b/kernel/kmod.c
76372 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
76373 kfree(info->argv);
76374 }
76375
76376 -static int call_modprobe(char *module_name, int wait)
76377 +static int call_modprobe(char *module_name, char *module_param, int wait)
76378 {
76379 static char *envp[] = {
76380 "HOME=/",
76381 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
76382 NULL
76383 };
76384
76385 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
76386 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
76387 if (!argv)
76388 goto out;
76389
76390 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
76391 argv[1] = "-q";
76392 argv[2] = "--";
76393 argv[3] = module_name; /* check free_modprobe_argv() */
76394 - argv[4] = NULL;
76395 + argv[4] = module_param;
76396 + argv[5] = NULL;
76397
76398 return call_usermodehelper_fns(modprobe_path, argv, envp,
76399 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
76400 @@ -120,9 +121,8 @@ out:
76401 * If module auto-loading support is disabled then this function
76402 * becomes a no-operation.
76403 */
76404 -int __request_module(bool wait, const char *fmt, ...)
76405 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
76406 {
76407 - va_list args;
76408 char module_name[MODULE_NAME_LEN];
76409 unsigned int max_modprobes;
76410 int ret;
76411 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
76412 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
76413 static int kmod_loop_msg;
76414
76415 - va_start(args, fmt);
76416 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
76417 - va_end(args);
76418 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
76419 if (ret >= MODULE_NAME_LEN)
76420 return -ENAMETOOLONG;
76421
76422 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
76423 if (ret)
76424 return ret;
76425
76426 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76427 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76428 + /* hack to workaround consolekit/udisks stupidity */
76429 + read_lock(&tasklist_lock);
76430 + if (!strcmp(current->comm, "mount") &&
76431 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
76432 + read_unlock(&tasklist_lock);
76433 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
76434 + return -EPERM;
76435 + }
76436 + read_unlock(&tasklist_lock);
76437 + }
76438 +#endif
76439 +
76440 /* If modprobe needs a service that is in a module, we get a recursive
76441 * loop. Limit the number of running kmod threads to max_threads/2 or
76442 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
76443 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
76444
76445 trace_module_request(module_name, wait, _RET_IP_);
76446
76447 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76448 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76449
76450 atomic_dec(&kmod_concurrent);
76451 return ret;
76452 }
76453 +
76454 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
76455 +{
76456 + va_list args;
76457 + int ret;
76458 +
76459 + va_start(args, fmt);
76460 + ret = ____request_module(wait, module_param, fmt, args);
76461 + va_end(args);
76462 +
76463 + return ret;
76464 +}
76465 +
76466 +int __request_module(bool wait, const char *fmt, ...)
76467 +{
76468 + va_list args;
76469 + int ret;
76470 +
76471 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76472 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76473 + char module_param[MODULE_NAME_LEN];
76474 +
76475 + memset(module_param, 0, sizeof(module_param));
76476 +
76477 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
76478 +
76479 + va_start(args, fmt);
76480 + ret = ____request_module(wait, module_param, fmt, args);
76481 + va_end(args);
76482 +
76483 + return ret;
76484 + }
76485 +#endif
76486 +
76487 + va_start(args, fmt);
76488 + ret = ____request_module(wait, NULL, fmt, args);
76489 + va_end(args);
76490 +
76491 + return ret;
76492 +}
76493 +
76494 EXPORT_SYMBOL(__request_module);
76495 #endif /* CONFIG_MODULES */
76496
76497 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
76498 *
76499 * Thus the __user pointer cast is valid here.
76500 */
76501 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
76502 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
76503
76504 /*
76505 * If ret is 0, either ____call_usermodehelper failed and the
76506 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
76507 static int proc_cap_handler(struct ctl_table *table, int write,
76508 void __user *buffer, size_t *lenp, loff_t *ppos)
76509 {
76510 - struct ctl_table t;
76511 + ctl_table_no_const t;
76512 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
76513 kernel_cap_t new_cap;
76514 int err, i;
76515 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
76516 index 098f396..fe85ff1 100644
76517 --- a/kernel/kprobes.c
76518 +++ b/kernel/kprobes.c
76519 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
76520 * kernel image and loaded module images reside. This is required
76521 * so x86_64 can correctly handle the %rip-relative fixups.
76522 */
76523 - kip->insns = module_alloc(PAGE_SIZE);
76524 + kip->insns = module_alloc_exec(PAGE_SIZE);
76525 if (!kip->insns) {
76526 kfree(kip);
76527 return NULL;
76528 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
76529 */
76530 if (!list_is_singular(&kip->list)) {
76531 list_del(&kip->list);
76532 - module_free(NULL, kip->insns);
76533 + module_free_exec(NULL, kip->insns);
76534 kfree(kip);
76535 }
76536 return 1;
76537 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
76538 {
76539 int i, err = 0;
76540 unsigned long offset = 0, size = 0;
76541 - char *modname, namebuf[128];
76542 + char *modname, namebuf[KSYM_NAME_LEN];
76543 const char *symbol_name;
76544 void *addr;
76545 struct kprobe_blackpoint *kb;
76546 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
76547 kprobe_type = "k";
76548
76549 if (sym)
76550 - seq_printf(pi, "%p %s %s+0x%x %s ",
76551 + seq_printf(pi, "%pK %s %s+0x%x %s ",
76552 p->addr, kprobe_type, sym, offset,
76553 (modname ? modname : " "));
76554 else
76555 - seq_printf(pi, "%p %s %p ",
76556 + seq_printf(pi, "%pK %s %pK ",
76557 p->addr, kprobe_type, p->addr);
76558
76559 if (!pp)
76560 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
76561 const char *sym = NULL;
76562 unsigned int i = *(loff_t *) v;
76563 unsigned long offset = 0;
76564 - char *modname, namebuf[128];
76565 + char *modname, namebuf[KSYM_NAME_LEN];
76566
76567 head = &kprobe_table[i];
76568 preempt_disable();
76569 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
76570 index 6ada93c..dce7d5d 100644
76571 --- a/kernel/ksysfs.c
76572 +++ b/kernel/ksysfs.c
76573 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
76574 {
76575 if (count+1 > UEVENT_HELPER_PATH_LEN)
76576 return -ENOENT;
76577 + if (!capable(CAP_SYS_ADMIN))
76578 + return -EPERM;
76579 memcpy(uevent_helper, buf, count);
76580 uevent_helper[count] = '\0';
76581 if (count && uevent_helper[count-1] == '\n')
76582 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
76583 return count;
76584 }
76585
76586 -static struct bin_attribute notes_attr = {
76587 +static bin_attribute_no_const notes_attr __read_only = {
76588 .attr = {
76589 .name = "notes",
76590 .mode = S_IRUGO,
76591 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
76592 index 7981e5b..7f2105c 100644
76593 --- a/kernel/lockdep.c
76594 +++ b/kernel/lockdep.c
76595 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
76596 end = (unsigned long) &_end,
76597 addr = (unsigned long) obj;
76598
76599 +#ifdef CONFIG_PAX_KERNEXEC
76600 + start = ktla_ktva(start);
76601 +#endif
76602 +
76603 /*
76604 * static variable?
76605 */
76606 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
76607 if (!static_obj(lock->key)) {
76608 debug_locks_off();
76609 printk("INFO: trying to register non-static key.\n");
76610 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76611 printk("the code is fine but needs lockdep annotation.\n");
76612 printk("turning off the locking correctness validator.\n");
76613 dump_stack();
76614 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76615 if (!class)
76616 return 0;
76617 }
76618 - atomic_inc((atomic_t *)&class->ops);
76619 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76620 if (very_verbose(class)) {
76621 printk("\nacquire class [%p] %s", class->key, class->name);
76622 if (class->name_version > 1)
76623 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76624 index b2c71c5..7b88d63 100644
76625 --- a/kernel/lockdep_proc.c
76626 +++ b/kernel/lockdep_proc.c
76627 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76628 return 0;
76629 }
76630
76631 - seq_printf(m, "%p", class->key);
76632 + seq_printf(m, "%pK", class->key);
76633 #ifdef CONFIG_DEBUG_LOCKDEP
76634 seq_printf(m, " OPS:%8ld", class->ops);
76635 #endif
76636 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76637
76638 list_for_each_entry(entry, &class->locks_after, entry) {
76639 if (entry->distance == 1) {
76640 - seq_printf(m, " -> [%p] ", entry->class->key);
76641 + seq_printf(m, " -> [%pK] ", entry->class->key);
76642 print_name(m, entry->class);
76643 seq_puts(m, "\n");
76644 }
76645 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76646 if (!class->key)
76647 continue;
76648
76649 - seq_printf(m, "[%p] ", class->key);
76650 + seq_printf(m, "[%pK] ", class->key);
76651 print_name(m, class);
76652 seq_puts(m, "\n");
76653 }
76654 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76655 if (!i)
76656 seq_line(m, '-', 40-namelen, namelen);
76657
76658 - snprintf(ip, sizeof(ip), "[<%p>]",
76659 + snprintf(ip, sizeof(ip), "[<%pK>]",
76660 (void *)class->contention_point[i]);
76661 seq_printf(m, "%40s %14lu %29s %pS\n",
76662 name, stats->contention_point[i],
76663 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76664 if (!i)
76665 seq_line(m, '-', 40-namelen, namelen);
76666
76667 - snprintf(ip, sizeof(ip), "[<%p>]",
76668 + snprintf(ip, sizeof(ip), "[<%pK>]",
76669 (void *)class->contending_point[i]);
76670 seq_printf(m, "%40s %14lu %29s %pS\n",
76671 name, stats->contending_point[i],
76672 diff --git a/kernel/module.c b/kernel/module.c
76673 index eab0827..f488603 100644
76674 --- a/kernel/module.c
76675 +++ b/kernel/module.c
76676 @@ -61,6 +61,7 @@
76677 #include <linux/pfn.h>
76678 #include <linux/bsearch.h>
76679 #include <linux/fips.h>
76680 +#include <linux/grsecurity.h>
76681 #include <uapi/linux/module.h>
76682 #include "module-internal.h"
76683
76684 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76685
76686 /* Bounds of module allocation, for speeding __module_address.
76687 * Protected by module_mutex. */
76688 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76689 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76690 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76691
76692 int register_module_notifier(struct notifier_block * nb)
76693 {
76694 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76695 return true;
76696
76697 list_for_each_entry_rcu(mod, &modules, list) {
76698 - struct symsearch arr[] = {
76699 + struct symsearch modarr[] = {
76700 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76701 NOT_GPL_ONLY, false },
76702 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76703 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76704 if (mod->state == MODULE_STATE_UNFORMED)
76705 continue;
76706
76707 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76708 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76709 return true;
76710 }
76711 return false;
76712 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76713 static int percpu_modalloc(struct module *mod,
76714 unsigned long size, unsigned long align)
76715 {
76716 - if (align > PAGE_SIZE) {
76717 + if (align-1 >= PAGE_SIZE) {
76718 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76719 mod->name, align, PAGE_SIZE);
76720 align = PAGE_SIZE;
76721 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
76722 static ssize_t show_coresize(struct module_attribute *mattr,
76723 struct module_kobject *mk, char *buffer)
76724 {
76725 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76726 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76727 }
76728
76729 static struct module_attribute modinfo_coresize =
76730 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
76731 static ssize_t show_initsize(struct module_attribute *mattr,
76732 struct module_kobject *mk, char *buffer)
76733 {
76734 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76735 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76736 }
76737
76738 static struct module_attribute modinfo_initsize =
76739 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
76740 */
76741 #ifdef CONFIG_SYSFS
76742
76743 -#ifdef CONFIG_KALLSYMS
76744 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76745 static inline bool sect_empty(const Elf_Shdr *sect)
76746 {
76747 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76748 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76749 {
76750 unsigned int notes, loaded, i;
76751 struct module_notes_attrs *notes_attrs;
76752 - struct bin_attribute *nattr;
76753 + bin_attribute_no_const *nattr;
76754
76755 /* failed to create section attributes, so can't create notes */
76756 if (!mod->sect_attrs)
76757 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
76758 static int module_add_modinfo_attrs(struct module *mod)
76759 {
76760 struct module_attribute *attr;
76761 - struct module_attribute *temp_attr;
76762 + module_attribute_no_const *temp_attr;
76763 int error = 0;
76764 int i;
76765
76766 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
76767
76768 static void unset_module_core_ro_nx(struct module *mod)
76769 {
76770 - set_page_attributes(mod->module_core + mod->core_text_size,
76771 - mod->module_core + mod->core_size,
76772 + set_page_attributes(mod->module_core_rw,
76773 + mod->module_core_rw + mod->core_size_rw,
76774 set_memory_x);
76775 - set_page_attributes(mod->module_core,
76776 - mod->module_core + mod->core_ro_size,
76777 + set_page_attributes(mod->module_core_rx,
76778 + mod->module_core_rx + mod->core_size_rx,
76779 set_memory_rw);
76780 }
76781
76782 static void unset_module_init_ro_nx(struct module *mod)
76783 {
76784 - set_page_attributes(mod->module_init + mod->init_text_size,
76785 - mod->module_init + mod->init_size,
76786 + set_page_attributes(mod->module_init_rw,
76787 + mod->module_init_rw + mod->init_size_rw,
76788 set_memory_x);
76789 - set_page_attributes(mod->module_init,
76790 - mod->module_init + mod->init_ro_size,
76791 + set_page_attributes(mod->module_init_rx,
76792 + mod->module_init_rx + mod->init_size_rx,
76793 set_memory_rw);
76794 }
76795
76796 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
76797 list_for_each_entry_rcu(mod, &modules, list) {
76798 if (mod->state == MODULE_STATE_UNFORMED)
76799 continue;
76800 - if ((mod->module_core) && (mod->core_text_size)) {
76801 - set_page_attributes(mod->module_core,
76802 - mod->module_core + mod->core_text_size,
76803 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76804 + set_page_attributes(mod->module_core_rx,
76805 + mod->module_core_rx + mod->core_size_rx,
76806 set_memory_rw);
76807 }
76808 - if ((mod->module_init) && (mod->init_text_size)) {
76809 - set_page_attributes(mod->module_init,
76810 - mod->module_init + mod->init_text_size,
76811 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76812 + set_page_attributes(mod->module_init_rx,
76813 + mod->module_init_rx + mod->init_size_rx,
76814 set_memory_rw);
76815 }
76816 }
76817 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
76818 list_for_each_entry_rcu(mod, &modules, list) {
76819 if (mod->state == MODULE_STATE_UNFORMED)
76820 continue;
76821 - if ((mod->module_core) && (mod->core_text_size)) {
76822 - set_page_attributes(mod->module_core,
76823 - mod->module_core + mod->core_text_size,
76824 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76825 + set_page_attributes(mod->module_core_rx,
76826 + mod->module_core_rx + mod->core_size_rx,
76827 set_memory_ro);
76828 }
76829 - if ((mod->module_init) && (mod->init_text_size)) {
76830 - set_page_attributes(mod->module_init,
76831 - mod->module_init + mod->init_text_size,
76832 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76833 + set_page_attributes(mod->module_init_rx,
76834 + mod->module_init_rx + mod->init_size_rx,
76835 set_memory_ro);
76836 }
76837 }
76838 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
76839
76840 /* This may be NULL, but that's OK */
76841 unset_module_init_ro_nx(mod);
76842 - module_free(mod, mod->module_init);
76843 + module_free(mod, mod->module_init_rw);
76844 + module_free_exec(mod, mod->module_init_rx);
76845 kfree(mod->args);
76846 percpu_modfree(mod);
76847
76848 /* Free lock-classes: */
76849 - lockdep_free_key_range(mod->module_core, mod->core_size);
76850 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76851 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76852
76853 /* Finally, free the core (containing the module structure) */
76854 unset_module_core_ro_nx(mod);
76855 - module_free(mod, mod->module_core);
76856 + module_free_exec(mod, mod->module_core_rx);
76857 + module_free(mod, mod->module_core_rw);
76858
76859 #ifdef CONFIG_MPU
76860 update_protections(current->mm);
76861 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76862 int ret = 0;
76863 const struct kernel_symbol *ksym;
76864
76865 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76866 + int is_fs_load = 0;
76867 + int register_filesystem_found = 0;
76868 + char *p;
76869 +
76870 + p = strstr(mod->args, "grsec_modharden_fs");
76871 + if (p) {
76872 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76873 + /* copy \0 as well */
76874 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76875 + is_fs_load = 1;
76876 + }
76877 +#endif
76878 +
76879 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76880 const char *name = info->strtab + sym[i].st_name;
76881
76882 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76883 + /* it's a real shame this will never get ripped and copied
76884 + upstream! ;(
76885 + */
76886 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76887 + register_filesystem_found = 1;
76888 +#endif
76889 +
76890 switch (sym[i].st_shndx) {
76891 case SHN_COMMON:
76892 /* We compiled with -fno-common. These are not
76893 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76894 ksym = resolve_symbol_wait(mod, info, name);
76895 /* Ok if resolved. */
76896 if (ksym && !IS_ERR(ksym)) {
76897 + pax_open_kernel();
76898 sym[i].st_value = ksym->value;
76899 + pax_close_kernel();
76900 break;
76901 }
76902
76903 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76904 secbase = (unsigned long)mod_percpu(mod);
76905 else
76906 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76907 + pax_open_kernel();
76908 sym[i].st_value += secbase;
76909 + pax_close_kernel();
76910 break;
76911 }
76912 }
76913
76914 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76915 + if (is_fs_load && !register_filesystem_found) {
76916 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76917 + ret = -EPERM;
76918 + }
76919 +#endif
76920 +
76921 return ret;
76922 }
76923
76924 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76925 || s->sh_entsize != ~0UL
76926 || strstarts(sname, ".init"))
76927 continue;
76928 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76929 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76930 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76931 + else
76932 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76933 pr_debug("\t%s\n", sname);
76934 }
76935 - switch (m) {
76936 - case 0: /* executable */
76937 - mod->core_size = debug_align(mod->core_size);
76938 - mod->core_text_size = mod->core_size;
76939 - break;
76940 - case 1: /* RO: text and ro-data */
76941 - mod->core_size = debug_align(mod->core_size);
76942 - mod->core_ro_size = mod->core_size;
76943 - break;
76944 - case 3: /* whole core */
76945 - mod->core_size = debug_align(mod->core_size);
76946 - break;
76947 - }
76948 }
76949
76950 pr_debug("Init section allocation order:\n");
76951 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76952 || s->sh_entsize != ~0UL
76953 || !strstarts(sname, ".init"))
76954 continue;
76955 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76956 - | INIT_OFFSET_MASK);
76957 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76958 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76959 + else
76960 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76961 + s->sh_entsize |= INIT_OFFSET_MASK;
76962 pr_debug("\t%s\n", sname);
76963 }
76964 - switch (m) {
76965 - case 0: /* executable */
76966 - mod->init_size = debug_align(mod->init_size);
76967 - mod->init_text_size = mod->init_size;
76968 - break;
76969 - case 1: /* RO: text and ro-data */
76970 - mod->init_size = debug_align(mod->init_size);
76971 - mod->init_ro_size = mod->init_size;
76972 - break;
76973 - case 3: /* whole init */
76974 - mod->init_size = debug_align(mod->init_size);
76975 - break;
76976 - }
76977 }
76978 }
76979
76980 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76981
76982 /* Put symbol section at end of init part of module. */
76983 symsect->sh_flags |= SHF_ALLOC;
76984 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76985 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76986 info->index.sym) | INIT_OFFSET_MASK;
76987 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76988
76989 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76990 }
76991
76992 /* Append room for core symbols at end of core part. */
76993 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76994 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76995 - mod->core_size += strtab_size;
76996 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76997 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76998 + mod->core_size_rx += strtab_size;
76999
77000 /* Put string table section at end of init part of module. */
77001 strsect->sh_flags |= SHF_ALLOC;
77002 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
77003 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
77004 info->index.str) | INIT_OFFSET_MASK;
77005 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
77006 }
77007 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
77008 /* Make sure we get permanent strtab: don't use info->strtab. */
77009 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
77010
77011 + pax_open_kernel();
77012 +
77013 /* Set types up while we still have access to sections. */
77014 for (i = 0; i < mod->num_symtab; i++)
77015 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
77016
77017 - mod->core_symtab = dst = mod->module_core + info->symoffs;
77018 - mod->core_strtab = s = mod->module_core + info->stroffs;
77019 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
77020 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
77021 src = mod->symtab;
77022 for (ndst = i = 0; i < mod->num_symtab; i++) {
77023 if (i == 0 ||
77024 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
77025 }
77026 }
77027 mod->core_num_syms = ndst;
77028 +
77029 + pax_close_kernel();
77030 }
77031 #else
77032 static inline void layout_symtab(struct module *mod, struct load_info *info)
77033 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
77034 return vmalloc_exec(size);
77035 }
77036
77037 -static void *module_alloc_update_bounds(unsigned long size)
77038 +static void *module_alloc_update_bounds_rw(unsigned long size)
77039 {
77040 void *ret = module_alloc(size);
77041
77042 if (ret) {
77043 mutex_lock(&module_mutex);
77044 /* Update module bounds. */
77045 - if ((unsigned long)ret < module_addr_min)
77046 - module_addr_min = (unsigned long)ret;
77047 - if ((unsigned long)ret + size > module_addr_max)
77048 - module_addr_max = (unsigned long)ret + size;
77049 + if ((unsigned long)ret < module_addr_min_rw)
77050 + module_addr_min_rw = (unsigned long)ret;
77051 + if ((unsigned long)ret + size > module_addr_max_rw)
77052 + module_addr_max_rw = (unsigned long)ret + size;
77053 + mutex_unlock(&module_mutex);
77054 + }
77055 + return ret;
77056 +}
77057 +
77058 +static void *module_alloc_update_bounds_rx(unsigned long size)
77059 +{
77060 + void *ret = module_alloc_exec(size);
77061 +
77062 + if (ret) {
77063 + mutex_lock(&module_mutex);
77064 + /* Update module bounds. */
77065 + if ((unsigned long)ret < module_addr_min_rx)
77066 + module_addr_min_rx = (unsigned long)ret;
77067 + if ((unsigned long)ret + size > module_addr_max_rx)
77068 + module_addr_max_rx = (unsigned long)ret + size;
77069 mutex_unlock(&module_mutex);
77070 }
77071 return ret;
77072 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
77073 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
77074 {
77075 const char *modmagic = get_modinfo(info, "vermagic");
77076 + const char *license = get_modinfo(info, "license");
77077 int err;
77078
77079 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
77080 + if (!license || !license_is_gpl_compatible(license))
77081 + return -ENOEXEC;
77082 +#endif
77083 +
77084 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
77085 modmagic = NULL;
77086
77087 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
77088 }
77089
77090 /* Set up license info based on the info section */
77091 - set_license(mod, get_modinfo(info, "license"));
77092 + set_license(mod, license);
77093
77094 return 0;
77095 }
77096 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
77097 void *ptr;
77098
77099 /* Do the allocs. */
77100 - ptr = module_alloc_update_bounds(mod->core_size);
77101 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
77102 /*
77103 * The pointer to this block is stored in the module structure
77104 * which is inside the block. Just mark it as not being a
77105 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
77106 if (!ptr)
77107 return -ENOMEM;
77108
77109 - memset(ptr, 0, mod->core_size);
77110 - mod->module_core = ptr;
77111 + memset(ptr, 0, mod->core_size_rw);
77112 + mod->module_core_rw = ptr;
77113
77114 - if (mod->init_size) {
77115 - ptr = module_alloc_update_bounds(mod->init_size);
77116 + if (mod->init_size_rw) {
77117 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
77118 /*
77119 * The pointer to this block is stored in the module structure
77120 * which is inside the block. This block doesn't need to be
77121 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
77122 */
77123 kmemleak_ignore(ptr);
77124 if (!ptr) {
77125 - module_free(mod, mod->module_core);
77126 + module_free(mod, mod->module_core_rw);
77127 return -ENOMEM;
77128 }
77129 - memset(ptr, 0, mod->init_size);
77130 - mod->module_init = ptr;
77131 + memset(ptr, 0, mod->init_size_rw);
77132 + mod->module_init_rw = ptr;
77133 } else
77134 - mod->module_init = NULL;
77135 + mod->module_init_rw = NULL;
77136 +
77137 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
77138 + kmemleak_not_leak(ptr);
77139 + if (!ptr) {
77140 + if (mod->module_init_rw)
77141 + module_free(mod, mod->module_init_rw);
77142 + module_free(mod, mod->module_core_rw);
77143 + return -ENOMEM;
77144 + }
77145 +
77146 + pax_open_kernel();
77147 + memset(ptr, 0, mod->core_size_rx);
77148 + pax_close_kernel();
77149 + mod->module_core_rx = ptr;
77150 +
77151 + if (mod->init_size_rx) {
77152 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
77153 + kmemleak_ignore(ptr);
77154 + if (!ptr && mod->init_size_rx) {
77155 + module_free_exec(mod, mod->module_core_rx);
77156 + if (mod->module_init_rw)
77157 + module_free(mod, mod->module_init_rw);
77158 + module_free(mod, mod->module_core_rw);
77159 + return -ENOMEM;
77160 + }
77161 +
77162 + pax_open_kernel();
77163 + memset(ptr, 0, mod->init_size_rx);
77164 + pax_close_kernel();
77165 + mod->module_init_rx = ptr;
77166 + } else
77167 + mod->module_init_rx = NULL;
77168
77169 /* Transfer each section which specifies SHF_ALLOC */
77170 pr_debug("final section addresses:\n");
77171 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
77172 if (!(shdr->sh_flags & SHF_ALLOC))
77173 continue;
77174
77175 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
77176 - dest = mod->module_init
77177 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77178 - else
77179 - dest = mod->module_core + shdr->sh_entsize;
77180 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
77181 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
77182 + dest = mod->module_init_rw
77183 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77184 + else
77185 + dest = mod->module_init_rx
77186 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
77187 + } else {
77188 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
77189 + dest = mod->module_core_rw + shdr->sh_entsize;
77190 + else
77191 + dest = mod->module_core_rx + shdr->sh_entsize;
77192 + }
77193 +
77194 + if (shdr->sh_type != SHT_NOBITS) {
77195 +
77196 +#ifdef CONFIG_PAX_KERNEXEC
77197 +#ifdef CONFIG_X86_64
77198 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
77199 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
77200 +#endif
77201 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
77202 + pax_open_kernel();
77203 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
77204 + pax_close_kernel();
77205 + } else
77206 +#endif
77207
77208 - if (shdr->sh_type != SHT_NOBITS)
77209 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
77210 + }
77211 /* Update sh_addr to point to copy in image. */
77212 - shdr->sh_addr = (unsigned long)dest;
77213 +
77214 +#ifdef CONFIG_PAX_KERNEXEC
77215 + if (shdr->sh_flags & SHF_EXECINSTR)
77216 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
77217 + else
77218 +#endif
77219 +
77220 + shdr->sh_addr = (unsigned long)dest;
77221 pr_debug("\t0x%lx %s\n",
77222 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
77223 }
77224 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
77225 * Do it before processing of module parameters, so the module
77226 * can provide parameter accessor functions of its own.
77227 */
77228 - if (mod->module_init)
77229 - flush_icache_range((unsigned long)mod->module_init,
77230 - (unsigned long)mod->module_init
77231 - + mod->init_size);
77232 - flush_icache_range((unsigned long)mod->module_core,
77233 - (unsigned long)mod->module_core + mod->core_size);
77234 + if (mod->module_init_rx)
77235 + flush_icache_range((unsigned long)mod->module_init_rx,
77236 + (unsigned long)mod->module_init_rx
77237 + + mod->init_size_rx);
77238 + flush_icache_range((unsigned long)mod->module_core_rx,
77239 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
77240
77241 set_fs(old_fs);
77242 }
77243 @@ -2983,8 +3088,10 @@ out:
77244 static void module_deallocate(struct module *mod, struct load_info *info)
77245 {
77246 percpu_modfree(mod);
77247 - module_free(mod, mod->module_init);
77248 - module_free(mod, mod->module_core);
77249 + module_free_exec(mod, mod->module_init_rx);
77250 + module_free_exec(mod, mod->module_core_rx);
77251 + module_free(mod, mod->module_init_rw);
77252 + module_free(mod, mod->module_core_rw);
77253 }
77254
77255 int __weak module_finalize(const Elf_Ehdr *hdr,
77256 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
77257 static int post_relocation(struct module *mod, const struct load_info *info)
77258 {
77259 /* Sort exception table now relocations are done. */
77260 + pax_open_kernel();
77261 sort_extable(mod->extable, mod->extable + mod->num_exentries);
77262 + pax_close_kernel();
77263
77264 /* Copy relocated percpu area over. */
77265 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
77266 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
77267 MODULE_STATE_COMING, mod);
77268
77269 /* Set RO and NX regions for core */
77270 - set_section_ro_nx(mod->module_core,
77271 - mod->core_text_size,
77272 - mod->core_ro_size,
77273 - mod->core_size);
77274 + set_section_ro_nx(mod->module_core_rx,
77275 + mod->core_size_rx,
77276 + mod->core_size_rx,
77277 + mod->core_size_rx);
77278
77279 /* Set RO and NX regions for init */
77280 - set_section_ro_nx(mod->module_init,
77281 - mod->init_text_size,
77282 - mod->init_ro_size,
77283 - mod->init_size);
77284 + set_section_ro_nx(mod->module_init_rx,
77285 + mod->init_size_rx,
77286 + mod->init_size_rx,
77287 + mod->init_size_rx);
77288
77289 do_mod_ctors(mod);
77290 /* Start the module */
77291 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
77292 mod->strtab = mod->core_strtab;
77293 #endif
77294 unset_module_init_ro_nx(mod);
77295 - module_free(mod, mod->module_init);
77296 - mod->module_init = NULL;
77297 - mod->init_size = 0;
77298 - mod->init_ro_size = 0;
77299 - mod->init_text_size = 0;
77300 + module_free(mod, mod->module_init_rw);
77301 + module_free_exec(mod, mod->module_init_rx);
77302 + mod->module_init_rw = NULL;
77303 + mod->module_init_rx = NULL;
77304 + mod->init_size_rw = 0;
77305 + mod->init_size_rx = 0;
77306 mutex_unlock(&module_mutex);
77307 wake_up_all(&module_wq);
77308
77309 @@ -3209,9 +3319,38 @@ again:
77310 if (err)
77311 goto free_unload;
77312
77313 + /* Now copy in args */
77314 + mod->args = strndup_user(uargs, ~0UL >> 1);
77315 + if (IS_ERR(mod->args)) {
77316 + err = PTR_ERR(mod->args);
77317 + goto free_unload;
77318 + }
77319 +
77320 /* Set up MODINFO_ATTR fields */
77321 setup_modinfo(mod, info);
77322
77323 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77324 + {
77325 + char *p, *p2;
77326 +
77327 + if (strstr(mod->args, "grsec_modharden_netdev")) {
77328 + 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);
77329 + err = -EPERM;
77330 + goto free_modinfo;
77331 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
77332 + p += sizeof("grsec_modharden_normal") - 1;
77333 + p2 = strstr(p, "_");
77334 + if (p2) {
77335 + *p2 = '\0';
77336 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
77337 + *p2 = '_';
77338 + }
77339 + err = -EPERM;
77340 + goto free_modinfo;
77341 + }
77342 + }
77343 +#endif
77344 +
77345 /* Fix up syms, so that st_value is a pointer to location. */
77346 err = simplify_symbols(mod, info);
77347 if (err < 0)
77348 @@ -3227,13 +3366,6 @@ again:
77349
77350 flush_module_icache(mod);
77351
77352 - /* Now copy in args */
77353 - mod->args = strndup_user(uargs, ~0UL >> 1);
77354 - if (IS_ERR(mod->args)) {
77355 - err = PTR_ERR(mod->args);
77356 - goto free_arch_cleanup;
77357 - }
77358 -
77359 dynamic_debug_setup(info->debug, info->num_debug);
77360
77361 mutex_lock(&module_mutex);
77362 @@ -3278,11 +3410,10 @@ again:
77363 mutex_unlock(&module_mutex);
77364 dynamic_debug_remove(info->debug);
77365 synchronize_sched();
77366 - kfree(mod->args);
77367 - free_arch_cleanup:
77368 module_arch_cleanup(mod);
77369 free_modinfo:
77370 free_modinfo(mod);
77371 + kfree(mod->args);
77372 free_unload:
77373 module_unload_free(mod);
77374 unlink_mod:
77375 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
77376 unsigned long nextval;
77377
77378 /* At worse, next value is at end of module */
77379 - if (within_module_init(addr, mod))
77380 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
77381 + if (within_module_init_rx(addr, mod))
77382 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
77383 + else if (within_module_init_rw(addr, mod))
77384 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
77385 + else if (within_module_core_rx(addr, mod))
77386 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
77387 + else if (within_module_core_rw(addr, mod))
77388 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
77389 else
77390 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
77391 + return NULL;
77392
77393 /* Scan for closest preceding symbol, and next symbol. (ELF
77394 starts real symbols at 1). */
77395 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
77396 return 0;
77397
77398 seq_printf(m, "%s %u",
77399 - mod->name, mod->init_size + mod->core_size);
77400 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
77401 print_unload_info(m, mod);
77402
77403 /* Informative for users. */
77404 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
77405 mod->state == MODULE_STATE_COMING ? "Loading":
77406 "Live");
77407 /* Used by oprofile and other similar tools. */
77408 - seq_printf(m, " 0x%pK", mod->module_core);
77409 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
77410
77411 /* Taints info */
77412 if (mod->taints)
77413 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
77414
77415 static int __init proc_modules_init(void)
77416 {
77417 +#ifndef CONFIG_GRKERNSEC_HIDESYM
77418 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77419 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77420 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77421 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
77422 +#else
77423 proc_create("modules", 0, NULL, &proc_modules_operations);
77424 +#endif
77425 +#else
77426 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77427 +#endif
77428 return 0;
77429 }
77430 module_init(proc_modules_init);
77431 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
77432 {
77433 struct module *mod;
77434
77435 - if (addr < module_addr_min || addr > module_addr_max)
77436 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
77437 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
77438 return NULL;
77439
77440 list_for_each_entry_rcu(mod, &modules, list) {
77441 if (mod->state == MODULE_STATE_UNFORMED)
77442 continue;
77443 - if (within_module_core(addr, mod)
77444 - || within_module_init(addr, mod))
77445 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
77446 return mod;
77447 }
77448 return NULL;
77449 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
77450 */
77451 struct module *__module_text_address(unsigned long addr)
77452 {
77453 - struct module *mod = __module_address(addr);
77454 + struct module *mod;
77455 +
77456 +#ifdef CONFIG_X86_32
77457 + addr = ktla_ktva(addr);
77458 +#endif
77459 +
77460 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
77461 + return NULL;
77462 +
77463 + mod = __module_address(addr);
77464 +
77465 if (mod) {
77466 /* Make sure it's within the text section. */
77467 - if (!within(addr, mod->module_init, mod->init_text_size)
77468 - && !within(addr, mod->module_core, mod->core_text_size))
77469 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
77470 mod = NULL;
77471 }
77472 return mod;
77473 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
77474 index 7e3443f..b2a1e6b 100644
77475 --- a/kernel/mutex-debug.c
77476 +++ b/kernel/mutex-debug.c
77477 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
77478 }
77479
77480 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77481 - struct thread_info *ti)
77482 + struct task_struct *task)
77483 {
77484 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
77485
77486 /* Mark the current thread as blocked on the lock: */
77487 - ti->task->blocked_on = waiter;
77488 + task->blocked_on = waiter;
77489 }
77490
77491 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77492 - struct thread_info *ti)
77493 + struct task_struct *task)
77494 {
77495 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
77496 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
77497 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
77498 - ti->task->blocked_on = NULL;
77499 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
77500 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
77501 + task->blocked_on = NULL;
77502
77503 list_del_init(&waiter->list);
77504 waiter->task = NULL;
77505 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
77506 index 0799fd3..d06ae3b 100644
77507 --- a/kernel/mutex-debug.h
77508 +++ b/kernel/mutex-debug.h
77509 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
77510 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
77511 extern void debug_mutex_add_waiter(struct mutex *lock,
77512 struct mutex_waiter *waiter,
77513 - struct thread_info *ti);
77514 + struct task_struct *task);
77515 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77516 - struct thread_info *ti);
77517 + struct task_struct *task);
77518 extern void debug_mutex_unlock(struct mutex *lock);
77519 extern void debug_mutex_init(struct mutex *lock, const char *name,
77520 struct lock_class_key *key);
77521 diff --git a/kernel/mutex.c b/kernel/mutex.c
77522 index a307cc9..27fd2e9 100644
77523 --- a/kernel/mutex.c
77524 +++ b/kernel/mutex.c
77525 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77526 spin_lock_mutex(&lock->wait_lock, flags);
77527
77528 debug_mutex_lock_common(lock, &waiter);
77529 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
77530 + debug_mutex_add_waiter(lock, &waiter, task);
77531
77532 /* add waiting tasks to the end of the waitqueue (FIFO): */
77533 list_add_tail(&waiter.list, &lock->wait_list);
77534 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77535 * TASK_UNINTERRUPTIBLE case.)
77536 */
77537 if (unlikely(signal_pending_state(state, task))) {
77538 - mutex_remove_waiter(lock, &waiter,
77539 - task_thread_info(task));
77540 + mutex_remove_waiter(lock, &waiter, task);
77541 mutex_release(&lock->dep_map, 1, ip);
77542 spin_unlock_mutex(&lock->wait_lock, flags);
77543
77544 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77545 done:
77546 lock_acquired(&lock->dep_map, ip);
77547 /* got the lock - rejoice! */
77548 - mutex_remove_waiter(lock, &waiter, current_thread_info());
77549 + mutex_remove_waiter(lock, &waiter, task);
77550 mutex_set_owner(lock);
77551
77552 /* set it to 0 if there are no waiters left: */
77553 diff --git a/kernel/notifier.c b/kernel/notifier.c
77554 index 2d5cc4c..d9ea600 100644
77555 --- a/kernel/notifier.c
77556 +++ b/kernel/notifier.c
77557 @@ -5,6 +5,7 @@
77558 #include <linux/rcupdate.h>
77559 #include <linux/vmalloc.h>
77560 #include <linux/reboot.h>
77561 +#include <linux/mm.h>
77562
77563 /*
77564 * Notifier list for kernel code which wants to be called
77565 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
77566 while ((*nl) != NULL) {
77567 if (n->priority > (*nl)->priority)
77568 break;
77569 - nl = &((*nl)->next);
77570 + nl = (struct notifier_block **)&((*nl)->next);
77571 }
77572 - n->next = *nl;
77573 + pax_open_kernel();
77574 + *(const void **)&n->next = *nl;
77575 rcu_assign_pointer(*nl, n);
77576 + pax_close_kernel();
77577 return 0;
77578 }
77579
77580 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
77581 return 0;
77582 if (n->priority > (*nl)->priority)
77583 break;
77584 - nl = &((*nl)->next);
77585 + nl = (struct notifier_block **)&((*nl)->next);
77586 }
77587 - n->next = *nl;
77588 + pax_open_kernel();
77589 + *(const void **)&n->next = *nl;
77590 rcu_assign_pointer(*nl, n);
77591 + pax_close_kernel();
77592 return 0;
77593 }
77594
77595 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
77596 {
77597 while ((*nl) != NULL) {
77598 if ((*nl) == n) {
77599 + pax_open_kernel();
77600 rcu_assign_pointer(*nl, n->next);
77601 + pax_close_kernel();
77602 return 0;
77603 }
77604 - nl = &((*nl)->next);
77605 + nl = (struct notifier_block **)&((*nl)->next);
77606 }
77607 return -ENOENT;
77608 }
77609 diff --git a/kernel/panic.c b/kernel/panic.c
77610 index e1b2822..5edc1d9 100644
77611 --- a/kernel/panic.c
77612 +++ b/kernel/panic.c
77613 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77614 const char *board;
77615
77616 printk(KERN_WARNING "------------[ cut here ]------------\n");
77617 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77618 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77619 board = dmi_get_system_info(DMI_PRODUCT_NAME);
77620 if (board)
77621 printk(KERN_WARNING "Hardware name: %s\n", board);
77622 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77623 */
77624 void __stack_chk_fail(void)
77625 {
77626 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77627 + dump_stack();
77628 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77629 __builtin_return_address(0));
77630 }
77631 EXPORT_SYMBOL(__stack_chk_fail);
77632 diff --git a/kernel/pid.c b/kernel/pid.c
77633 index f2c6a68..4922d97 100644
77634 --- a/kernel/pid.c
77635 +++ b/kernel/pid.c
77636 @@ -33,6 +33,7 @@
77637 #include <linux/rculist.h>
77638 #include <linux/bootmem.h>
77639 #include <linux/hash.h>
77640 +#include <linux/security.h>
77641 #include <linux/pid_namespace.h>
77642 #include <linux/init_task.h>
77643 #include <linux/syscalls.h>
77644 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77645
77646 int pid_max = PID_MAX_DEFAULT;
77647
77648 -#define RESERVED_PIDS 300
77649 +#define RESERVED_PIDS 500
77650
77651 int pid_max_min = RESERVED_PIDS + 1;
77652 int pid_max_max = PID_MAX_LIMIT;
77653 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
77654 */
77655 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77656 {
77657 + struct task_struct *task;
77658 +
77659 rcu_lockdep_assert(rcu_read_lock_held(),
77660 "find_task_by_pid_ns() needs rcu_read_lock()"
77661 " protection");
77662 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77663 +
77664 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77665 +
77666 + if (gr_pid_is_chrooted(task))
77667 + return NULL;
77668 +
77669 + return task;
77670 }
77671
77672 struct task_struct *find_task_by_vpid(pid_t vnr)
77673 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77674 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77675 }
77676
77677 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77678 +{
77679 + rcu_lockdep_assert(rcu_read_lock_held(),
77680 + "find_task_by_pid_ns() needs rcu_read_lock()"
77681 + " protection");
77682 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77683 +}
77684 +
77685 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77686 {
77687 struct pid *pid;
77688 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77689 index bea15bd..789f3d0 100644
77690 --- a/kernel/pid_namespace.c
77691 +++ b/kernel/pid_namespace.c
77692 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77693 void __user *buffer, size_t *lenp, loff_t *ppos)
77694 {
77695 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77696 - struct ctl_table tmp = *table;
77697 + ctl_table_no_const tmp = *table;
77698
77699 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77700 return -EPERM;
77701 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77702 index 942ca27..111e609 100644
77703 --- a/kernel/posix-cpu-timers.c
77704 +++ b/kernel/posix-cpu-timers.c
77705 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
77706
77707 static __init int init_posix_cpu_timers(void)
77708 {
77709 - struct k_clock process = {
77710 + static struct k_clock process = {
77711 .clock_getres = process_cpu_clock_getres,
77712 .clock_get = process_cpu_clock_get,
77713 .timer_create = process_cpu_timer_create,
77714 .nsleep = process_cpu_nsleep,
77715 .nsleep_restart = process_cpu_nsleep_restart,
77716 };
77717 - struct k_clock thread = {
77718 + static struct k_clock thread = {
77719 .clock_getres = thread_cpu_clock_getres,
77720 .clock_get = thread_cpu_clock_get,
77721 .timer_create = thread_cpu_timer_create,
77722 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77723 index e885be1..380fe76 100644
77724 --- a/kernel/posix-timers.c
77725 +++ b/kernel/posix-timers.c
77726 @@ -43,6 +43,7 @@
77727 #include <linux/idr.h>
77728 #include <linux/posix-clock.h>
77729 #include <linux/posix-timers.h>
77730 +#include <linux/grsecurity.h>
77731 #include <linux/syscalls.h>
77732 #include <linux/wait.h>
77733 #include <linux/workqueue.h>
77734 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77735 * which we beg off on and pass to do_sys_settimeofday().
77736 */
77737
77738 -static struct k_clock posix_clocks[MAX_CLOCKS];
77739 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77740
77741 /*
77742 * These ones are defined below.
77743 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77744 */
77745 static __init int init_posix_timers(void)
77746 {
77747 - struct k_clock clock_realtime = {
77748 + static struct k_clock clock_realtime = {
77749 .clock_getres = hrtimer_get_res,
77750 .clock_get = posix_clock_realtime_get,
77751 .clock_set = posix_clock_realtime_set,
77752 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
77753 .timer_get = common_timer_get,
77754 .timer_del = common_timer_del,
77755 };
77756 - struct k_clock clock_monotonic = {
77757 + static struct k_clock clock_monotonic = {
77758 .clock_getres = hrtimer_get_res,
77759 .clock_get = posix_ktime_get_ts,
77760 .nsleep = common_nsleep,
77761 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77762 .timer_get = common_timer_get,
77763 .timer_del = common_timer_del,
77764 };
77765 - struct k_clock clock_monotonic_raw = {
77766 + static struct k_clock clock_monotonic_raw = {
77767 .clock_getres = hrtimer_get_res,
77768 .clock_get = posix_get_monotonic_raw,
77769 };
77770 - struct k_clock clock_realtime_coarse = {
77771 + static struct k_clock clock_realtime_coarse = {
77772 .clock_getres = posix_get_coarse_res,
77773 .clock_get = posix_get_realtime_coarse,
77774 };
77775 - struct k_clock clock_monotonic_coarse = {
77776 + static struct k_clock clock_monotonic_coarse = {
77777 .clock_getres = posix_get_coarse_res,
77778 .clock_get = posix_get_monotonic_coarse,
77779 };
77780 - struct k_clock clock_boottime = {
77781 + static struct k_clock clock_boottime = {
77782 .clock_getres = hrtimer_get_res,
77783 .clock_get = posix_get_boottime,
77784 .nsleep = common_nsleep,
77785 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77786 return;
77787 }
77788
77789 - posix_clocks[clock_id] = *new_clock;
77790 + posix_clocks[clock_id] = new_clock;
77791 }
77792 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77793
77794 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77795 return (id & CLOCKFD_MASK) == CLOCKFD ?
77796 &clock_posix_dynamic : &clock_posix_cpu;
77797
77798 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77799 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77800 return NULL;
77801 - return &posix_clocks[id];
77802 + return posix_clocks[id];
77803 }
77804
77805 static int common_timer_create(struct k_itimer *new_timer)
77806 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77807 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77808 return -EFAULT;
77809
77810 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77811 + have their clock_set fptr set to a nosettime dummy function
77812 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77813 + call common_clock_set, which calls do_sys_settimeofday, which
77814 + we hook
77815 + */
77816 +
77817 return kc->clock_set(which_clock, &new_tp);
77818 }
77819
77820 diff --git a/kernel/power/process.c b/kernel/power/process.c
77821 index d5a258b..4271191 100644
77822 --- a/kernel/power/process.c
77823 +++ b/kernel/power/process.c
77824 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77825 u64 elapsed_csecs64;
77826 unsigned int elapsed_csecs;
77827 bool wakeup = false;
77828 + bool timedout = false;
77829
77830 do_gettimeofday(&start);
77831
77832 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77833
77834 while (true) {
77835 todo = 0;
77836 + if (time_after(jiffies, end_time))
77837 + timedout = true;
77838 read_lock(&tasklist_lock);
77839 do_each_thread(g, p) {
77840 if (p == current || !freeze_task(p))
77841 continue;
77842
77843 - if (!freezer_should_skip(p))
77844 + if (!freezer_should_skip(p)) {
77845 todo++;
77846 + if (timedout) {
77847 + printk(KERN_ERR "Task refusing to freeze:\n");
77848 + sched_show_task(p);
77849 + }
77850 + }
77851 } while_each_thread(g, p);
77852 read_unlock(&tasklist_lock);
77853
77854 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77855 todo += wq_busy;
77856 }
77857
77858 - if (!todo || time_after(jiffies, end_time))
77859 + if (!todo || timedout)
77860 break;
77861
77862 if (pm_wakeup_pending()) {
77863 diff --git a/kernel/printk.c b/kernel/printk.c
77864 index 267ce78..2487112 100644
77865 --- a/kernel/printk.c
77866 +++ b/kernel/printk.c
77867 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
77868 return ret;
77869 }
77870
77871 +static int check_syslog_permissions(int type, bool from_file);
77872 +
77873 static int devkmsg_open(struct inode *inode, struct file *file)
77874 {
77875 struct devkmsg_user *user;
77876 int err;
77877
77878 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
77879 + if (err)
77880 + return err;
77881 +
77882 /* write-only does not need any file context */
77883 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
77884 return 0;
77885 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
77886 if (dmesg_restrict)
77887 return 1;
77888 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
77889 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77890 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77891 }
77892
77893 static int check_syslog_permissions(int type, bool from_file)
77894 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
77895 if (from_file && type != SYSLOG_ACTION_OPEN)
77896 return 0;
77897
77898 +#ifdef CONFIG_GRKERNSEC_DMESG
77899 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77900 + return -EPERM;
77901 +#endif
77902 +
77903 if (syslog_action_restricted(type)) {
77904 if (capable(CAP_SYSLOG))
77905 return 0;
77906 diff --git a/kernel/profile.c b/kernel/profile.c
77907 index 1f39181..86093471 100644
77908 --- a/kernel/profile.c
77909 +++ b/kernel/profile.c
77910 @@ -40,7 +40,7 @@ struct profile_hit {
77911 /* Oprofile timer tick hook */
77912 static int (*timer_hook)(struct pt_regs *) __read_mostly;
77913
77914 -static atomic_t *prof_buffer;
77915 +static atomic_unchecked_t *prof_buffer;
77916 static unsigned long prof_len, prof_shift;
77917
77918 int prof_on __read_mostly;
77919 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
77920 hits[i].pc = 0;
77921 continue;
77922 }
77923 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77924 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77925 hits[i].hits = hits[i].pc = 0;
77926 }
77927 }
77928 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77929 * Add the current hit(s) and flush the write-queue out
77930 * to the global buffer:
77931 */
77932 - atomic_add(nr_hits, &prof_buffer[pc]);
77933 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77934 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77935 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77936 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77937 hits[i].pc = hits[i].hits = 0;
77938 }
77939 out:
77940 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77941 {
77942 unsigned long pc;
77943 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77944 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77945 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77946 }
77947 #endif /* !CONFIG_SMP */
77948
77949 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77950 return -EFAULT;
77951 buf++; p++; count--; read++;
77952 }
77953 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77954 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77955 if (copy_to_user(buf, (void *)pnt, count))
77956 return -EFAULT;
77957 read += count;
77958 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77959 }
77960 #endif
77961 profile_discard_flip_buffers();
77962 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77963 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77964 return count;
77965 }
77966
77967 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77968 index 6cbeaae..cfe7ff0 100644
77969 --- a/kernel/ptrace.c
77970 +++ b/kernel/ptrace.c
77971 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77972 if (seize)
77973 flags |= PT_SEIZED;
77974 rcu_read_lock();
77975 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77976 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77977 flags |= PT_PTRACE_CAP;
77978 rcu_read_unlock();
77979 task->ptrace = flags;
77980 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77981 break;
77982 return -EIO;
77983 }
77984 - if (copy_to_user(dst, buf, retval))
77985 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77986 return -EFAULT;
77987 copied += retval;
77988 src += retval;
77989 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
77990 bool seized = child->ptrace & PT_SEIZED;
77991 int ret = -EIO;
77992 siginfo_t siginfo, *si;
77993 - void __user *datavp = (void __user *) data;
77994 + void __user *datavp = (__force void __user *) data;
77995 unsigned long __user *datalp = datavp;
77996 unsigned long flags;
77997
77998 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77999 goto out;
78000 }
78001
78002 + if (gr_handle_ptrace(child, request)) {
78003 + ret = -EPERM;
78004 + goto out_put_task_struct;
78005 + }
78006 +
78007 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
78008 ret = ptrace_attach(child, request, addr, data);
78009 /*
78010 * Some architectures need to do book-keeping after
78011 * a ptrace attach.
78012 */
78013 - if (!ret)
78014 + if (!ret) {
78015 arch_ptrace_attach(child);
78016 + gr_audit_ptrace(child);
78017 + }
78018 goto out_put_task_struct;
78019 }
78020
78021 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
78022 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
78023 if (copied != sizeof(tmp))
78024 return -EIO;
78025 - return put_user(tmp, (unsigned long __user *)data);
78026 + return put_user(tmp, (__force unsigned long __user *)data);
78027 }
78028
78029 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
78030 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
78031 }
78032
78033 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
78034 - compat_long_t addr, compat_long_t data)
78035 + compat_ulong_t addr, compat_ulong_t data)
78036 {
78037 struct task_struct *child;
78038 long ret;
78039 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
78040 goto out;
78041 }
78042
78043 + if (gr_handle_ptrace(child, request)) {
78044 + ret = -EPERM;
78045 + goto out_put_task_struct;
78046 + }
78047 +
78048 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
78049 ret = ptrace_attach(child, request, addr, data);
78050 /*
78051 * Some architectures need to do book-keeping after
78052 * a ptrace attach.
78053 */
78054 - if (!ret)
78055 + if (!ret) {
78056 arch_ptrace_attach(child);
78057 + gr_audit_ptrace(child);
78058 + }
78059 goto out_put_task_struct;
78060 }
78061
78062 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
78063 index e7dce58..ad0d7b7 100644
78064 --- a/kernel/rcutiny.c
78065 +++ b/kernel/rcutiny.c
78066 @@ -46,7 +46,7 @@
78067 struct rcu_ctrlblk;
78068 static void invoke_rcu_callbacks(void);
78069 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
78070 -static void rcu_process_callbacks(struct softirq_action *unused);
78071 +static void rcu_process_callbacks(void);
78072 static void __call_rcu(struct rcu_head *head,
78073 void (*func)(struct rcu_head *rcu),
78074 struct rcu_ctrlblk *rcp);
78075 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
78076 rcu_is_callbacks_kthread()));
78077 }
78078
78079 -static void rcu_process_callbacks(struct softirq_action *unused)
78080 +static void rcu_process_callbacks(void)
78081 {
78082 __rcu_process_callbacks(&rcu_sched_ctrlblk);
78083 __rcu_process_callbacks(&rcu_bh_ctrlblk);
78084 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
78085 index f85016a..91cb03b 100644
78086 --- a/kernel/rcutiny_plugin.h
78087 +++ b/kernel/rcutiny_plugin.h
78088 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
78089 have_rcu_kthread_work = morework;
78090 local_irq_restore(flags);
78091 if (work)
78092 - rcu_process_callbacks(NULL);
78093 + rcu_process_callbacks();
78094 schedule_timeout_interruptible(1); /* Leave CPU for others. */
78095 }
78096
78097 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
78098 index 31dea01..ad91ffb 100644
78099 --- a/kernel/rcutorture.c
78100 +++ b/kernel/rcutorture.c
78101 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
78102 { 0 };
78103 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
78104 { 0 };
78105 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
78106 -static atomic_t n_rcu_torture_alloc;
78107 -static atomic_t n_rcu_torture_alloc_fail;
78108 -static atomic_t n_rcu_torture_free;
78109 -static atomic_t n_rcu_torture_mberror;
78110 -static atomic_t n_rcu_torture_error;
78111 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
78112 +static atomic_unchecked_t n_rcu_torture_alloc;
78113 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
78114 +static atomic_unchecked_t n_rcu_torture_free;
78115 +static atomic_unchecked_t n_rcu_torture_mberror;
78116 +static atomic_unchecked_t n_rcu_torture_error;
78117 static long n_rcu_torture_barrier_error;
78118 static long n_rcu_torture_boost_ktrerror;
78119 static long n_rcu_torture_boost_rterror;
78120 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
78121
78122 spin_lock_bh(&rcu_torture_lock);
78123 if (list_empty(&rcu_torture_freelist)) {
78124 - atomic_inc(&n_rcu_torture_alloc_fail);
78125 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
78126 spin_unlock_bh(&rcu_torture_lock);
78127 return NULL;
78128 }
78129 - atomic_inc(&n_rcu_torture_alloc);
78130 + atomic_inc_unchecked(&n_rcu_torture_alloc);
78131 p = rcu_torture_freelist.next;
78132 list_del_init(p);
78133 spin_unlock_bh(&rcu_torture_lock);
78134 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
78135 static void
78136 rcu_torture_free(struct rcu_torture *p)
78137 {
78138 - atomic_inc(&n_rcu_torture_free);
78139 + atomic_inc_unchecked(&n_rcu_torture_free);
78140 spin_lock_bh(&rcu_torture_lock);
78141 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
78142 spin_unlock_bh(&rcu_torture_lock);
78143 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
78144 i = rp->rtort_pipe_count;
78145 if (i > RCU_TORTURE_PIPE_LEN)
78146 i = RCU_TORTURE_PIPE_LEN;
78147 - atomic_inc(&rcu_torture_wcount[i]);
78148 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78149 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
78150 rp->rtort_mbtest = 0;
78151 rcu_torture_free(rp);
78152 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
78153 i = rp->rtort_pipe_count;
78154 if (i > RCU_TORTURE_PIPE_LEN)
78155 i = RCU_TORTURE_PIPE_LEN;
78156 - atomic_inc(&rcu_torture_wcount[i]);
78157 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78158 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
78159 rp->rtort_mbtest = 0;
78160 list_del(&rp->rtort_free);
78161 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
78162 i = old_rp->rtort_pipe_count;
78163 if (i > RCU_TORTURE_PIPE_LEN)
78164 i = RCU_TORTURE_PIPE_LEN;
78165 - atomic_inc(&rcu_torture_wcount[i]);
78166 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
78167 old_rp->rtort_pipe_count++;
78168 cur_ops->deferred_free(old_rp);
78169 }
78170 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
78171 }
78172 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
78173 if (p->rtort_mbtest == 0)
78174 - atomic_inc(&n_rcu_torture_mberror);
78175 + atomic_inc_unchecked(&n_rcu_torture_mberror);
78176 spin_lock(&rand_lock);
78177 cur_ops->read_delay(&rand);
78178 n_rcu_torture_timers++;
78179 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
78180 }
78181 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
78182 if (p->rtort_mbtest == 0)
78183 - atomic_inc(&n_rcu_torture_mberror);
78184 + atomic_inc_unchecked(&n_rcu_torture_mberror);
78185 cur_ops->read_delay(&rand);
78186 preempt_disable();
78187 pipe_count = p->rtort_pipe_count;
78188 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
78189 rcu_torture_current,
78190 rcu_torture_current_version,
78191 list_empty(&rcu_torture_freelist),
78192 - atomic_read(&n_rcu_torture_alloc),
78193 - atomic_read(&n_rcu_torture_alloc_fail),
78194 - atomic_read(&n_rcu_torture_free));
78195 + atomic_read_unchecked(&n_rcu_torture_alloc),
78196 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
78197 + atomic_read_unchecked(&n_rcu_torture_free));
78198 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
78199 - atomic_read(&n_rcu_torture_mberror),
78200 + atomic_read_unchecked(&n_rcu_torture_mberror),
78201 n_rcu_torture_boost_ktrerror,
78202 n_rcu_torture_boost_rterror);
78203 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
78204 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
78205 n_barrier_attempts,
78206 n_rcu_torture_barrier_error);
78207 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
78208 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
78209 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
78210 n_rcu_torture_barrier_error != 0 ||
78211 n_rcu_torture_boost_ktrerror != 0 ||
78212 n_rcu_torture_boost_rterror != 0 ||
78213 n_rcu_torture_boost_failure != 0 ||
78214 i > 1) {
78215 cnt += sprintf(&page[cnt], "!!! ");
78216 - atomic_inc(&n_rcu_torture_error);
78217 + atomic_inc_unchecked(&n_rcu_torture_error);
78218 WARN_ON_ONCE(1);
78219 }
78220 cnt += sprintf(&page[cnt], "Reader Pipe: ");
78221 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
78222 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
78223 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78224 cnt += sprintf(&page[cnt], " %d",
78225 - atomic_read(&rcu_torture_wcount[i]));
78226 + atomic_read_unchecked(&rcu_torture_wcount[i]));
78227 }
78228 cnt += sprintf(&page[cnt], "\n");
78229 if (cur_ops->stats)
78230 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
78231
78232 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
78233
78234 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78235 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78236 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
78237 else if (n_online_successes != n_online_attempts ||
78238 n_offline_successes != n_offline_attempts)
78239 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
78240
78241 rcu_torture_current = NULL;
78242 rcu_torture_current_version = 0;
78243 - atomic_set(&n_rcu_torture_alloc, 0);
78244 - atomic_set(&n_rcu_torture_alloc_fail, 0);
78245 - atomic_set(&n_rcu_torture_free, 0);
78246 - atomic_set(&n_rcu_torture_mberror, 0);
78247 - atomic_set(&n_rcu_torture_error, 0);
78248 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
78249 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
78250 + atomic_set_unchecked(&n_rcu_torture_free, 0);
78251 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
78252 + atomic_set_unchecked(&n_rcu_torture_error, 0);
78253 n_rcu_torture_barrier_error = 0;
78254 n_rcu_torture_boost_ktrerror = 0;
78255 n_rcu_torture_boost_rterror = 0;
78256 n_rcu_torture_boost_failure = 0;
78257 n_rcu_torture_boosts = 0;
78258 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
78259 - atomic_set(&rcu_torture_wcount[i], 0);
78260 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
78261 for_each_possible_cpu(cpu) {
78262 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78263 per_cpu(rcu_torture_count, cpu)[i] = 0;
78264 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
78265 index e441b77..dd54f17 100644
78266 --- a/kernel/rcutree.c
78267 +++ b/kernel/rcutree.c
78268 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
78269 rcu_prepare_for_idle(smp_processor_id());
78270 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78271 smp_mb__before_atomic_inc(); /* See above. */
78272 - atomic_inc(&rdtp->dynticks);
78273 + atomic_inc_unchecked(&rdtp->dynticks);
78274 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
78275 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78276 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78277
78278 /*
78279 * It is illegal to enter an extended quiescent state while
78280 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
78281 int user)
78282 {
78283 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
78284 - atomic_inc(&rdtp->dynticks);
78285 + atomic_inc_unchecked(&rdtp->dynticks);
78286 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78287 smp_mb__after_atomic_inc(); /* See above. */
78288 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78289 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78290 rcu_cleanup_after_idle(smp_processor_id());
78291 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
78292 if (!user && !is_idle_task(current)) {
78293 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
78294 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
78295
78296 if (rdtp->dynticks_nmi_nesting == 0 &&
78297 - (atomic_read(&rdtp->dynticks) & 0x1))
78298 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
78299 return;
78300 rdtp->dynticks_nmi_nesting++;
78301 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
78302 - atomic_inc(&rdtp->dynticks);
78303 + atomic_inc_unchecked(&rdtp->dynticks);
78304 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78305 smp_mb__after_atomic_inc(); /* See above. */
78306 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78307 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78308 }
78309
78310 /**
78311 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
78312 return;
78313 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78314 smp_mb__before_atomic_inc(); /* See above. */
78315 - atomic_inc(&rdtp->dynticks);
78316 + atomic_inc_unchecked(&rdtp->dynticks);
78317 smp_mb__after_atomic_inc(); /* Force delay to next write. */
78318 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78319 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78320 }
78321
78322 /**
78323 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
78324 int ret;
78325
78326 preempt_disable();
78327 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
78328 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
78329 preempt_enable();
78330 return ret;
78331 }
78332 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
78333 */
78334 static int dyntick_save_progress_counter(struct rcu_data *rdp)
78335 {
78336 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
78337 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
78338 return (rdp->dynticks_snap & 0x1) == 0;
78339 }
78340
78341 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
78342 unsigned int curr;
78343 unsigned int snap;
78344
78345 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
78346 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
78347 snap = (unsigned int)rdp->dynticks_snap;
78348
78349 /*
78350 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
78351 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
78352 */
78353 if (till_stall_check < 3) {
78354 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
78355 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
78356 till_stall_check = 3;
78357 } else if (till_stall_check > 300) {
78358 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
78359 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
78360 till_stall_check = 300;
78361 }
78362 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
78363 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
78364 rsp->qlen += rdp->qlen;
78365 rdp->n_cbs_orphaned += rdp->qlen;
78366 rdp->qlen_lazy = 0;
78367 - ACCESS_ONCE(rdp->qlen) = 0;
78368 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78369 }
78370
78371 /*
78372 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
78373 }
78374 smp_mb(); /* List handling before counting for rcu_barrier(). */
78375 rdp->qlen_lazy -= count_lazy;
78376 - ACCESS_ONCE(rdp->qlen) -= count;
78377 + ACCESS_ONCE_RW(rdp->qlen) -= count;
78378 rdp->n_cbs_invoked += count;
78379
78380 /* Reinstate batch limit if we have worked down the excess. */
78381 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
78382 /*
78383 * Do RCU core processing for the current CPU.
78384 */
78385 -static void rcu_process_callbacks(struct softirq_action *unused)
78386 +static void rcu_process_callbacks(void)
78387 {
78388 struct rcu_state *rsp;
78389
78390 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
78391 local_irq_restore(flags);
78392 return;
78393 }
78394 - ACCESS_ONCE(rdp->qlen)++;
78395 + ACCESS_ONCE_RW(rdp->qlen)++;
78396 if (lazy)
78397 rdp->qlen_lazy++;
78398 else
78399 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
78400 * counter wrap on a 32-bit system. Quite a few more CPUs would of
78401 * course be required on a 64-bit system.
78402 */
78403 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
78404 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
78405 (ulong)atomic_long_read(&rsp->expedited_done) +
78406 ULONG_MAX / 8)) {
78407 synchronize_sched();
78408 - atomic_long_inc(&rsp->expedited_wrap);
78409 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
78410 return;
78411 }
78412
78413 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
78414 * Take a ticket. Note that atomic_inc_return() implies a
78415 * full memory barrier.
78416 */
78417 - snap = atomic_long_inc_return(&rsp->expedited_start);
78418 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
78419 firstsnap = snap;
78420 get_online_cpus();
78421 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
78422 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
78423 synchronize_sched_expedited_cpu_stop,
78424 NULL) == -EAGAIN) {
78425 put_online_cpus();
78426 - atomic_long_inc(&rsp->expedited_tryfail);
78427 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
78428
78429 /* Check to see if someone else did our work for us. */
78430 s = atomic_long_read(&rsp->expedited_done);
78431 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78432 /* ensure test happens before caller kfree */
78433 smp_mb__before_atomic_inc(); /* ^^^ */
78434 - atomic_long_inc(&rsp->expedited_workdone1);
78435 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
78436 return;
78437 }
78438
78439 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
78440 udelay(trycount * num_online_cpus());
78441 } else {
78442 wait_rcu_gp(call_rcu_sched);
78443 - atomic_long_inc(&rsp->expedited_normal);
78444 + atomic_long_inc_unchecked(&rsp->expedited_normal);
78445 return;
78446 }
78447
78448 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
78449 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78450 /* ensure test happens before caller kfree */
78451 smp_mb__before_atomic_inc(); /* ^^^ */
78452 - atomic_long_inc(&rsp->expedited_workdone2);
78453 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
78454 return;
78455 }
78456
78457 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
78458 * period works for us.
78459 */
78460 get_online_cpus();
78461 - snap = atomic_long_read(&rsp->expedited_start);
78462 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
78463 smp_mb(); /* ensure read is before try_stop_cpus(). */
78464 }
78465 - atomic_long_inc(&rsp->expedited_stoppedcpus);
78466 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
78467
78468 /*
78469 * Everyone up to our most recent fetch is covered by our grace
78470 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
78471 * than we did already did their update.
78472 */
78473 do {
78474 - atomic_long_inc(&rsp->expedited_done_tries);
78475 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
78476 s = atomic_long_read(&rsp->expedited_done);
78477 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
78478 /* ensure test happens before caller kfree */
78479 smp_mb__before_atomic_inc(); /* ^^^ */
78480 - atomic_long_inc(&rsp->expedited_done_lost);
78481 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
78482 break;
78483 }
78484 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
78485 - atomic_long_inc(&rsp->expedited_done_exit);
78486 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
78487
78488 put_online_cpus();
78489 }
78490 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78491 * ACCESS_ONCE() to prevent the compiler from speculating
78492 * the increment to precede the early-exit check.
78493 */
78494 - ACCESS_ONCE(rsp->n_barrier_done)++;
78495 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78496 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
78497 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
78498 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
78499 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78500
78501 /* Increment ->n_barrier_done to prevent duplicate work. */
78502 smp_mb(); /* Keep increment after above mechanism. */
78503 - ACCESS_ONCE(rsp->n_barrier_done)++;
78504 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78505 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
78506 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
78507 smp_mb(); /* Keep increment before caller's subsequent code. */
78508 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
78509 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
78510 init_callback_list(rdp);
78511 rdp->qlen_lazy = 0;
78512 - ACCESS_ONCE(rdp->qlen) = 0;
78513 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78514 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
78515 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
78516 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
78517 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
78518 #ifdef CONFIG_RCU_USER_QS
78519 WARN_ON_ONCE(rdp->dynticks->in_user);
78520 #endif
78521 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
78522 rdp->blimit = blimit;
78523 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
78524 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
78525 - atomic_set(&rdp->dynticks->dynticks,
78526 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
78527 + atomic_set_unchecked(&rdp->dynticks->dynticks,
78528 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
78529 rcu_prepare_for_idle_init(cpu);
78530 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
78531
78532 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
78533 index 4b69291..704c92e 100644
78534 --- a/kernel/rcutree.h
78535 +++ b/kernel/rcutree.h
78536 @@ -86,7 +86,7 @@ struct rcu_dynticks {
78537 long long dynticks_nesting; /* Track irq/process nesting level. */
78538 /* Process level is worth LLONG_MAX/2. */
78539 int dynticks_nmi_nesting; /* Track NMI nesting level. */
78540 - atomic_t dynticks; /* Even value for idle, else odd. */
78541 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
78542 #ifdef CONFIG_RCU_FAST_NO_HZ
78543 int dyntick_drain; /* Prepare-for-idle state variable. */
78544 unsigned long dyntick_holdoff;
78545 @@ -423,17 +423,17 @@ struct rcu_state {
78546 /* _rcu_barrier(). */
78547 /* End of fields guarded by barrier_mutex. */
78548
78549 - atomic_long_t expedited_start; /* Starting ticket. */
78550 - atomic_long_t expedited_done; /* Done ticket. */
78551 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
78552 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
78553 - atomic_long_t expedited_workdone1; /* # done by others #1. */
78554 - atomic_long_t expedited_workdone2; /* # done by others #2. */
78555 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
78556 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
78557 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
78558 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
78559 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
78560 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
78561 + atomic_long_t expedited_done; /* Done ticket. */
78562 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
78563 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
78564 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
78565 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
78566 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
78567 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
78568 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
78569 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
78570 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
78571
78572 unsigned long jiffies_force_qs; /* Time at which to invoke */
78573 /* force_quiescent_state(). */
78574 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
78575 index c1cc7e1..f62e436 100644
78576 --- a/kernel/rcutree_plugin.h
78577 +++ b/kernel/rcutree_plugin.h
78578 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
78579
78580 /* Clean up and exit. */
78581 smp_mb(); /* ensure expedited GP seen before counter increment. */
78582 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
78583 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
78584 unlock_mb_ret:
78585 mutex_unlock(&sync_rcu_preempt_exp_mutex);
78586 mb_ret:
78587 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
78588 free_cpumask_var(cm);
78589 }
78590
78591 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
78592 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
78593 .store = &rcu_cpu_kthread_task,
78594 .thread_should_run = rcu_cpu_kthread_should_run,
78595 .thread_fn = rcu_cpu_kthread,
78596 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
78597 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
78598 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
78599 cpu, ticks_value, ticks_title,
78600 - atomic_read(&rdtp->dynticks) & 0xfff,
78601 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
78602 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
78603 fast_no_hz);
78604 }
78605 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
78606
78607 /* Enqueue the callback on the nocb list and update counts. */
78608 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78609 - ACCESS_ONCE(*old_rhpp) = rhp;
78610 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78611 atomic_long_add(rhcount, &rdp->nocb_q_count);
78612 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78613
78614 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
78615 * Extract queued callbacks, update counts, and wait
78616 * for a grace period to elapse.
78617 */
78618 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78619 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78620 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78621 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78622 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78623 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78624 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78625 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78626 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78627 wait_rcu_gp(rdp->rsp->call_remote);
78628
78629 /* Each pass through the following loop invokes a callback. */
78630 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
78631 list = next;
78632 }
78633 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78634 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78635 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78636 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78637 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78638 rdp->n_nocbs_invoked += c;
78639 }
78640 return 0;
78641 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78642 rdp = per_cpu_ptr(rsp->rda, cpu);
78643 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
78644 BUG_ON(IS_ERR(t));
78645 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78646 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78647 }
78648 }
78649
78650 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78651 index 0d095dc..1985b19 100644
78652 --- a/kernel/rcutree_trace.c
78653 +++ b/kernel/rcutree_trace.c
78654 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78655 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78656 rdp->passed_quiesce, rdp->qs_pending);
78657 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78658 - atomic_read(&rdp->dynticks->dynticks),
78659 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78660 rdp->dynticks->dynticks_nesting,
78661 rdp->dynticks->dynticks_nmi_nesting,
78662 rdp->dynticks_fqs);
78663 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78664 struct rcu_state *rsp = (struct rcu_state *)m->private;
78665
78666 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",
78667 - atomic_long_read(&rsp->expedited_start),
78668 + atomic_long_read_unchecked(&rsp->expedited_start),
78669 atomic_long_read(&rsp->expedited_done),
78670 - atomic_long_read(&rsp->expedited_wrap),
78671 - atomic_long_read(&rsp->expedited_tryfail),
78672 - atomic_long_read(&rsp->expedited_workdone1),
78673 - atomic_long_read(&rsp->expedited_workdone2),
78674 - atomic_long_read(&rsp->expedited_normal),
78675 - atomic_long_read(&rsp->expedited_stoppedcpus),
78676 - atomic_long_read(&rsp->expedited_done_tries),
78677 - atomic_long_read(&rsp->expedited_done_lost),
78678 - atomic_long_read(&rsp->expedited_done_exit));
78679 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78680 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78681 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78682 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78683 + atomic_long_read_unchecked(&rsp->expedited_normal),
78684 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78685 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78686 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78687 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78688 return 0;
78689 }
78690
78691 diff --git a/kernel/resource.c b/kernel/resource.c
78692 index 73f35d4..4684fc4 100644
78693 --- a/kernel/resource.c
78694 +++ b/kernel/resource.c
78695 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78696
78697 static int __init ioresources_init(void)
78698 {
78699 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78700 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78701 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78702 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78703 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78704 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78705 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78706 +#endif
78707 +#else
78708 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78709 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78710 +#endif
78711 return 0;
78712 }
78713 __initcall(ioresources_init);
78714 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78715 index 98ec494..4241d6d 100644
78716 --- a/kernel/rtmutex-tester.c
78717 +++ b/kernel/rtmutex-tester.c
78718 @@ -20,7 +20,7 @@
78719 #define MAX_RT_TEST_MUTEXES 8
78720
78721 static spinlock_t rttest_lock;
78722 -static atomic_t rttest_event;
78723 +static atomic_unchecked_t rttest_event;
78724
78725 struct test_thread_data {
78726 int opcode;
78727 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78728
78729 case RTTEST_LOCKCONT:
78730 td->mutexes[td->opdata] = 1;
78731 - td->event = atomic_add_return(1, &rttest_event);
78732 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78733 return 0;
78734
78735 case RTTEST_RESET:
78736 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78737 return 0;
78738
78739 case RTTEST_RESETEVENT:
78740 - atomic_set(&rttest_event, 0);
78741 + atomic_set_unchecked(&rttest_event, 0);
78742 return 0;
78743
78744 default:
78745 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78746 return ret;
78747
78748 td->mutexes[id] = 1;
78749 - td->event = atomic_add_return(1, &rttest_event);
78750 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78751 rt_mutex_lock(&mutexes[id]);
78752 - td->event = atomic_add_return(1, &rttest_event);
78753 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78754 td->mutexes[id] = 4;
78755 return 0;
78756
78757 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78758 return ret;
78759
78760 td->mutexes[id] = 1;
78761 - td->event = atomic_add_return(1, &rttest_event);
78762 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78763 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78764 - td->event = atomic_add_return(1, &rttest_event);
78765 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78766 td->mutexes[id] = ret ? 0 : 4;
78767 return ret ? -EINTR : 0;
78768
78769 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78770 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78771 return ret;
78772
78773 - td->event = atomic_add_return(1, &rttest_event);
78774 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78775 rt_mutex_unlock(&mutexes[id]);
78776 - td->event = atomic_add_return(1, &rttest_event);
78777 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78778 td->mutexes[id] = 0;
78779 return 0;
78780
78781 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78782 break;
78783
78784 td->mutexes[dat] = 2;
78785 - td->event = atomic_add_return(1, &rttest_event);
78786 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78787 break;
78788
78789 default:
78790 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78791 return;
78792
78793 td->mutexes[dat] = 3;
78794 - td->event = atomic_add_return(1, &rttest_event);
78795 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78796 break;
78797
78798 case RTTEST_LOCKNOWAIT:
78799 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78800 return;
78801
78802 td->mutexes[dat] = 1;
78803 - td->event = atomic_add_return(1, &rttest_event);
78804 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78805 return;
78806
78807 default:
78808 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78809 index 0984a21..939f183 100644
78810 --- a/kernel/sched/auto_group.c
78811 +++ b/kernel/sched/auto_group.c
78812 @@ -11,7 +11,7 @@
78813
78814 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78815 static struct autogroup autogroup_default;
78816 -static atomic_t autogroup_seq_nr;
78817 +static atomic_unchecked_t autogroup_seq_nr;
78818
78819 void __init autogroup_init(struct task_struct *init_task)
78820 {
78821 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
78822
78823 kref_init(&ag->kref);
78824 init_rwsem(&ag->lock);
78825 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78826 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78827 ag->tg = tg;
78828 #ifdef CONFIG_RT_GROUP_SCHED
78829 /*
78830 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78831 index 5e2f7c3..4002d41 100644
78832 --- a/kernel/sched/core.c
78833 +++ b/kernel/sched/core.c
78834 @@ -3369,7 +3369,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78835 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78836 * positive (at least 1, or number of jiffies left till timeout) if completed.
78837 */
78838 -long __sched
78839 +long __sched __intentional_overflow(-1)
78840 wait_for_completion_interruptible_timeout(struct completion *x,
78841 unsigned long timeout)
78842 {
78843 @@ -3386,7 +3386,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78844 *
78845 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78846 */
78847 -int __sched wait_for_completion_killable(struct completion *x)
78848 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78849 {
78850 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78851 if (t == -ERESTARTSYS)
78852 @@ -3407,7 +3407,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78853 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78854 * positive (at least 1, or number of jiffies left till timeout) if completed.
78855 */
78856 -long __sched
78857 +long __sched __intentional_overflow(-1)
78858 wait_for_completion_killable_timeout(struct completion *x,
78859 unsigned long timeout)
78860 {
78861 @@ -3633,6 +3633,8 @@ int can_nice(const struct task_struct *p, const int nice)
78862 /* convert nice value [19,-20] to rlimit style value [1,40] */
78863 int nice_rlim = 20 - nice;
78864
78865 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78866 +
78867 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78868 capable(CAP_SYS_NICE));
78869 }
78870 @@ -3666,7 +3668,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78871 if (nice > 19)
78872 nice = 19;
78873
78874 - if (increment < 0 && !can_nice(current, nice))
78875 + if (increment < 0 && (!can_nice(current, nice) ||
78876 + gr_handle_chroot_nice()))
78877 return -EPERM;
78878
78879 retval = security_task_setnice(current, nice);
78880 @@ -3820,6 +3823,7 @@ recheck:
78881 unsigned long rlim_rtprio =
78882 task_rlimit(p, RLIMIT_RTPRIO);
78883
78884 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78885 /* can't set/change the rt policy */
78886 if (policy != p->policy && !rlim_rtprio)
78887 return -EPERM;
78888 @@ -4903,7 +4907,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78889
78890 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78891
78892 -static struct ctl_table sd_ctl_dir[] = {
78893 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78894 {
78895 .procname = "sched_domain",
78896 .mode = 0555,
78897 @@ -4920,17 +4924,17 @@ static struct ctl_table sd_ctl_root[] = {
78898 {}
78899 };
78900
78901 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78902 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78903 {
78904 - struct ctl_table *entry =
78905 + ctl_table_no_const *entry =
78906 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78907
78908 return entry;
78909 }
78910
78911 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78912 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78913 {
78914 - struct ctl_table *entry;
78915 + ctl_table_no_const *entry;
78916
78917 /*
78918 * In the intermediate directories, both the child directory and
78919 @@ -4938,22 +4942,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78920 * will always be set. In the lowest directory the names are
78921 * static strings and all have proc handlers.
78922 */
78923 - for (entry = *tablep; entry->mode; entry++) {
78924 - if (entry->child)
78925 - sd_free_ctl_entry(&entry->child);
78926 + for (entry = tablep; entry->mode; entry++) {
78927 + if (entry->child) {
78928 + sd_free_ctl_entry(entry->child);
78929 + pax_open_kernel();
78930 + entry->child = NULL;
78931 + pax_close_kernel();
78932 + }
78933 if (entry->proc_handler == NULL)
78934 kfree(entry->procname);
78935 }
78936
78937 - kfree(*tablep);
78938 - *tablep = NULL;
78939 + kfree(tablep);
78940 }
78941
78942 static int min_load_idx = 0;
78943 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78944
78945 static void
78946 -set_table_entry(struct ctl_table *entry,
78947 +set_table_entry(ctl_table_no_const *entry,
78948 const char *procname, void *data, int maxlen,
78949 umode_t mode, proc_handler *proc_handler,
78950 bool load_idx)
78951 @@ -4973,7 +4980,7 @@ set_table_entry(struct ctl_table *entry,
78952 static struct ctl_table *
78953 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78954 {
78955 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78956 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78957
78958 if (table == NULL)
78959 return NULL;
78960 @@ -5008,9 +5015,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78961 return table;
78962 }
78963
78964 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78965 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78966 {
78967 - struct ctl_table *entry, *table;
78968 + ctl_table_no_const *entry, *table;
78969 struct sched_domain *sd;
78970 int domain_num = 0, i;
78971 char buf[32];
78972 @@ -5037,11 +5044,13 @@ static struct ctl_table_header *sd_sysctl_header;
78973 static void register_sched_domain_sysctl(void)
78974 {
78975 int i, cpu_num = num_possible_cpus();
78976 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78977 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78978 char buf[32];
78979
78980 WARN_ON(sd_ctl_dir[0].child);
78981 + pax_open_kernel();
78982 sd_ctl_dir[0].child = entry;
78983 + pax_close_kernel();
78984
78985 if (entry == NULL)
78986 return;
78987 @@ -5064,8 +5073,12 @@ static void unregister_sched_domain_sysctl(void)
78988 if (sd_sysctl_header)
78989 unregister_sysctl_table(sd_sysctl_header);
78990 sd_sysctl_header = NULL;
78991 - if (sd_ctl_dir[0].child)
78992 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78993 + if (sd_ctl_dir[0].child) {
78994 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78995 + pax_open_kernel();
78996 + sd_ctl_dir[0].child = NULL;
78997 + pax_close_kernel();
78998 + }
78999 }
79000 #else
79001 static void register_sched_domain_sysctl(void)
79002 @@ -5164,7 +5177,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
79003 * happens before everything else. This has to be lower priority than
79004 * the notifier in the perf_event subsystem, though.
79005 */
79006 -static struct notifier_block __cpuinitdata migration_notifier = {
79007 +static struct notifier_block migration_notifier = {
79008 .notifier_call = migration_call,
79009 .priority = CPU_PRI_MIGRATION,
79010 };
79011 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
79012 index 81fa536..6ccf96a 100644
79013 --- a/kernel/sched/fair.c
79014 +++ b/kernel/sched/fair.c
79015 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
79016
79017 static void reset_ptenuma_scan(struct task_struct *p)
79018 {
79019 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
79020 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
79021 p->mm->numa_scan_offset = 0;
79022 }
79023
79024 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
79025 */
79026 static int select_idle_sibling(struct task_struct *p, int target)
79027 {
79028 - int cpu = smp_processor_id();
79029 - int prev_cpu = task_cpu(p);
79030 struct sched_domain *sd;
79031 struct sched_group *sg;
79032 - int i;
79033 + int i = task_cpu(p);
79034
79035 - /*
79036 - * If the task is going to be woken-up on this cpu and if it is
79037 - * already idle, then it is the right target.
79038 - */
79039 - if (target == cpu && idle_cpu(cpu))
79040 - return cpu;
79041 + if (idle_cpu(target))
79042 + return target;
79043
79044 /*
79045 - * If the task is going to be woken-up on the cpu where it previously
79046 - * ran and if it is currently idle, then it the right target.
79047 + * If the prevous cpu is cache affine and idle, don't be stupid.
79048 */
79049 - if (target == prev_cpu && idle_cpu(prev_cpu))
79050 - return prev_cpu;
79051 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
79052 + return i;
79053
79054 /*
79055 * Otherwise, iterate the domains and find an elegible idle cpu.
79056 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
79057 goto next;
79058
79059 for_each_cpu(i, sched_group_cpus(sg)) {
79060 - if (!idle_cpu(i))
79061 + if (i == target || !idle_cpu(i))
79062 goto next;
79063 }
79064
79065 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
79066 * run_rebalance_domains is triggered when needed from the scheduler tick.
79067 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
79068 */
79069 -static void run_rebalance_domains(struct softirq_action *h)
79070 +static void run_rebalance_domains(void)
79071 {
79072 int this_cpu = smp_processor_id();
79073 struct rq *this_rq = cpu_rq(this_cpu);
79074 diff --git a/kernel/signal.c b/kernel/signal.c
79075 index 50e425c..92c8f65 100644
79076 --- a/kernel/signal.c
79077 +++ b/kernel/signal.c
79078 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
79079
79080 int print_fatal_signals __read_mostly;
79081
79082 -static void __user *sig_handler(struct task_struct *t, int sig)
79083 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
79084 {
79085 return t->sighand->action[sig - 1].sa.sa_handler;
79086 }
79087
79088 -static int sig_handler_ignored(void __user *handler, int sig)
79089 +static int sig_handler_ignored(__sighandler_t handler, int sig)
79090 {
79091 /* Is it explicitly or implicitly ignored? */
79092 return handler == SIG_IGN ||
79093 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
79094
79095 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
79096 {
79097 - void __user *handler;
79098 + __sighandler_t handler;
79099
79100 handler = sig_handler(t, sig);
79101
79102 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
79103 atomic_inc(&user->sigpending);
79104 rcu_read_unlock();
79105
79106 + if (!override_rlimit)
79107 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
79108 +
79109 if (override_rlimit ||
79110 atomic_read(&user->sigpending) <=
79111 task_rlimit(t, RLIMIT_SIGPENDING)) {
79112 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
79113
79114 int unhandled_signal(struct task_struct *tsk, int sig)
79115 {
79116 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
79117 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
79118 if (is_global_init(tsk))
79119 return 1;
79120 if (handler != SIG_IGN && handler != SIG_DFL)
79121 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
79122 }
79123 }
79124
79125 + /* allow glibc communication via tgkill to other threads in our
79126 + thread group */
79127 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
79128 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
79129 + && gr_handle_signal(t, sig))
79130 + return -EPERM;
79131 +
79132 return security_task_kill(t, info, sig, 0);
79133 }
79134
79135 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
79136 return send_signal(sig, info, p, 1);
79137 }
79138
79139 -static int
79140 +int
79141 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79142 {
79143 return send_signal(sig, info, t, 0);
79144 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79145 unsigned long int flags;
79146 int ret, blocked, ignored;
79147 struct k_sigaction *action;
79148 + int is_unhandled = 0;
79149
79150 spin_lock_irqsave(&t->sighand->siglock, flags);
79151 action = &t->sighand->action[sig-1];
79152 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
79153 }
79154 if (action->sa.sa_handler == SIG_DFL)
79155 t->signal->flags &= ~SIGNAL_UNKILLABLE;
79156 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
79157 + is_unhandled = 1;
79158 ret = specific_send_sig_info(sig, info, t);
79159 spin_unlock_irqrestore(&t->sighand->siglock, flags);
79160
79161 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
79162 + normal operation */
79163 + if (is_unhandled) {
79164 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
79165 + gr_handle_crash(t, sig);
79166 + }
79167 +
79168 return ret;
79169 }
79170
79171 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
79172 ret = check_kill_permission(sig, info, p);
79173 rcu_read_unlock();
79174
79175 - if (!ret && sig)
79176 + if (!ret && sig) {
79177 ret = do_send_sig_info(sig, info, p, true);
79178 + if (!ret)
79179 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
79180 + }
79181
79182 return ret;
79183 }
79184 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
79185 int error = -ESRCH;
79186
79187 rcu_read_lock();
79188 - p = find_task_by_vpid(pid);
79189 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
79190 + /* allow glibc communication via tgkill to other threads in our
79191 + thread group */
79192 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
79193 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
79194 + p = find_task_by_vpid_unrestricted(pid);
79195 + else
79196 +#endif
79197 + p = find_task_by_vpid(pid);
79198 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
79199 error = check_kill_permission(sig, info, p);
79200 /*
79201 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
79202 }
79203 seg = get_fs();
79204 set_fs(KERNEL_DS);
79205 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
79206 - (stack_t __force __user *) &uoss,
79207 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
79208 + (stack_t __force_user *) &uoss,
79209 compat_user_stack_pointer());
79210 set_fs(seg);
79211 if (ret >= 0 && uoss_ptr) {
79212 diff --git a/kernel/smp.c b/kernel/smp.c
79213 index 69f38bd..77bbf12 100644
79214 --- a/kernel/smp.c
79215 +++ b/kernel/smp.c
79216 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
79217 return NOTIFY_OK;
79218 }
79219
79220 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
79221 +static struct notifier_block hotplug_cfd_notifier = {
79222 .notifier_call = hotplug_cfd,
79223 };
79224
79225 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
79226 index d6c5fc0..530560c 100644
79227 --- a/kernel/smpboot.c
79228 +++ b/kernel/smpboot.c
79229 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
79230 }
79231 smpboot_unpark_thread(plug_thread, cpu);
79232 }
79233 - list_add(&plug_thread->list, &hotplug_threads);
79234 + pax_list_add(&plug_thread->list, &hotplug_threads);
79235 out:
79236 mutex_unlock(&smpboot_threads_lock);
79237 return ret;
79238 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
79239 {
79240 get_online_cpus();
79241 mutex_lock(&smpboot_threads_lock);
79242 - list_del(&plug_thread->list);
79243 + pax_list_del(&plug_thread->list);
79244 smpboot_destroy_threads(plug_thread);
79245 mutex_unlock(&smpboot_threads_lock);
79246 put_online_cpus();
79247 diff --git a/kernel/softirq.c b/kernel/softirq.c
79248 index ed567ba..e71dabf 100644
79249 --- a/kernel/softirq.c
79250 +++ b/kernel/softirq.c
79251 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
79252 EXPORT_SYMBOL(irq_stat);
79253 #endif
79254
79255 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
79256 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
79257
79258 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
79259
79260 -char *softirq_to_name[NR_SOFTIRQS] = {
79261 +const char * const softirq_to_name[NR_SOFTIRQS] = {
79262 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
79263 "TASKLET", "SCHED", "HRTIMER", "RCU"
79264 };
79265 @@ -244,7 +244,7 @@ restart:
79266 kstat_incr_softirqs_this_cpu(vec_nr);
79267
79268 trace_softirq_entry(vec_nr);
79269 - h->action(h);
79270 + h->action();
79271 trace_softirq_exit(vec_nr);
79272 if (unlikely(prev_count != preempt_count())) {
79273 printk(KERN_ERR "huh, entered softirq %u %s %p"
79274 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
79275 or_softirq_pending(1UL << nr);
79276 }
79277
79278 -void open_softirq(int nr, void (*action)(struct softirq_action *))
79279 +void __init open_softirq(int nr, void (*action)(void))
79280 {
79281 softirq_vec[nr].action = action;
79282 }
79283 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
79284
79285 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
79286
79287 -static void tasklet_action(struct softirq_action *a)
79288 +static void tasklet_action(void)
79289 {
79290 struct tasklet_struct *list;
79291
79292 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
79293 }
79294 }
79295
79296 -static void tasklet_hi_action(struct softirq_action *a)
79297 +static void tasklet_hi_action(void)
79298 {
79299 struct tasklet_struct *list;
79300
79301 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
79302 return NOTIFY_OK;
79303 }
79304
79305 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
79306 +static struct notifier_block remote_softirq_cpu_notifier = {
79307 .notifier_call = remote_softirq_cpu_notify,
79308 };
79309
79310 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
79311 return NOTIFY_OK;
79312 }
79313
79314 -static struct notifier_block __cpuinitdata cpu_nfb = {
79315 +static struct notifier_block cpu_nfb = {
79316 .notifier_call = cpu_callback
79317 };
79318
79319 -static struct smp_hotplug_thread softirq_threads = {
79320 +static struct smp_hotplug_thread softirq_threads __read_only = {
79321 .store = &ksoftirqd,
79322 .thread_should_run = ksoftirqd_should_run,
79323 .thread_fn = run_ksoftirqd,
79324 diff --git a/kernel/srcu.c b/kernel/srcu.c
79325 index 2b85982..d52ab26 100644
79326 --- a/kernel/srcu.c
79327 +++ b/kernel/srcu.c
79328 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
79329 preempt_disable();
79330 idx = rcu_dereference_index_check(sp->completed,
79331 rcu_read_lock_sched_held()) & 0x1;
79332 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
79333 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
79334 smp_mb(); /* B */ /* Avoid leaking the critical section. */
79335 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
79336 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
79337 preempt_enable();
79338 return idx;
79339 }
79340 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
79341 {
79342 preempt_disable();
79343 smp_mb(); /* C */ /* Avoid leaking the critical section. */
79344 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
79345 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
79346 preempt_enable();
79347 }
79348 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
79349 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
79350 index 2f194e9..2c05ea9 100644
79351 --- a/kernel/stop_machine.c
79352 +++ b/kernel/stop_machine.c
79353 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
79354 * cpu notifiers. It currently shares the same priority as sched
79355 * migration_notifier.
79356 */
79357 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
79358 +static struct notifier_block cpu_stop_cpu_notifier = {
79359 .notifier_call = cpu_stop_cpu_callback,
79360 .priority = 10,
79361 };
79362 diff --git a/kernel/sys.c b/kernel/sys.c
79363 index 47f1d1b..04c769e 100644
79364 --- a/kernel/sys.c
79365 +++ b/kernel/sys.c
79366 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
79367 error = -EACCES;
79368 goto out;
79369 }
79370 +
79371 + if (gr_handle_chroot_setpriority(p, niceval)) {
79372 + error = -EACCES;
79373 + goto out;
79374 + }
79375 +
79376 no_nice = security_task_setnice(p, niceval);
79377 if (no_nice) {
79378 error = no_nice;
79379 @@ -596,6 +602,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
79380 goto error;
79381 }
79382
79383 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
79384 + goto error;
79385 +
79386 if (rgid != (gid_t) -1 ||
79387 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
79388 new->sgid = new->egid;
79389 @@ -631,6 +640,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
79390 old = current_cred();
79391
79392 retval = -EPERM;
79393 +
79394 + if (gr_check_group_change(kgid, kgid, kgid))
79395 + goto error;
79396 +
79397 if (nsown_capable(CAP_SETGID))
79398 new->gid = new->egid = new->sgid = new->fsgid = kgid;
79399 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
79400 @@ -648,7 +661,7 @@ error:
79401 /*
79402 * change the user struct in a credentials set to match the new UID
79403 */
79404 -static int set_user(struct cred *new)
79405 +int set_user(struct cred *new)
79406 {
79407 struct user_struct *new_user;
79408
79409 @@ -728,6 +741,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
79410 goto error;
79411 }
79412
79413 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
79414 + goto error;
79415 +
79416 if (!uid_eq(new->uid, old->uid)) {
79417 retval = set_user(new);
79418 if (retval < 0)
79419 @@ -778,6 +794,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
79420 old = current_cred();
79421
79422 retval = -EPERM;
79423 +
79424 + if (gr_check_crash_uid(kuid))
79425 + goto error;
79426 + if (gr_check_user_change(kuid, kuid, kuid))
79427 + goto error;
79428 +
79429 if (nsown_capable(CAP_SETUID)) {
79430 new->suid = new->uid = kuid;
79431 if (!uid_eq(kuid, old->uid)) {
79432 @@ -847,6 +869,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
79433 goto error;
79434 }
79435
79436 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
79437 + goto error;
79438 +
79439 if (ruid != (uid_t) -1) {
79440 new->uid = kruid;
79441 if (!uid_eq(kruid, old->uid)) {
79442 @@ -929,6 +954,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
79443 goto error;
79444 }
79445
79446 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
79447 + goto error;
79448 +
79449 if (rgid != (gid_t) -1)
79450 new->gid = krgid;
79451 if (egid != (gid_t) -1)
79452 @@ -990,12 +1018,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
79453 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
79454 nsown_capable(CAP_SETUID)) {
79455 if (!uid_eq(kuid, old->fsuid)) {
79456 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
79457 + goto error;
79458 +
79459 new->fsuid = kuid;
79460 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
79461 goto change_okay;
79462 }
79463 }
79464
79465 +error:
79466 abort_creds(new);
79467 return old_fsuid;
79468
79469 @@ -1028,12 +1060,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
79470 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
79471 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
79472 nsown_capable(CAP_SETGID)) {
79473 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
79474 + goto error;
79475 +
79476 if (!gid_eq(kgid, old->fsgid)) {
79477 new->fsgid = kgid;
79478 goto change_okay;
79479 }
79480 }
79481
79482 +error:
79483 abort_creds(new);
79484 return old_fsgid;
79485
79486 @@ -1341,19 +1377,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
79487 return -EFAULT;
79488
79489 down_read(&uts_sem);
79490 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
79491 + error = __copy_to_user(name->sysname, &utsname()->sysname,
79492 __OLD_UTS_LEN);
79493 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
79494 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
79495 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
79496 __OLD_UTS_LEN);
79497 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
79498 - error |= __copy_to_user(&name->release, &utsname()->release,
79499 + error |= __copy_to_user(name->release, &utsname()->release,
79500 __OLD_UTS_LEN);
79501 error |= __put_user(0, name->release + __OLD_UTS_LEN);
79502 - error |= __copy_to_user(&name->version, &utsname()->version,
79503 + error |= __copy_to_user(name->version, &utsname()->version,
79504 __OLD_UTS_LEN);
79505 error |= __put_user(0, name->version + __OLD_UTS_LEN);
79506 - error |= __copy_to_user(&name->machine, &utsname()->machine,
79507 + error |= __copy_to_user(name->machine, &utsname()->machine,
79508 __OLD_UTS_LEN);
79509 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
79510 up_read(&uts_sem);
79511 @@ -2027,7 +2063,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
79512 error = get_dumpable(me->mm);
79513 break;
79514 case PR_SET_DUMPABLE:
79515 - if (arg2 < 0 || arg2 > 1) {
79516 + if (arg2 > 1) {
79517 error = -EINVAL;
79518 break;
79519 }
79520 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
79521 index c88878d..e4fa5d1 100644
79522 --- a/kernel/sysctl.c
79523 +++ b/kernel/sysctl.c
79524 @@ -92,7 +92,6 @@
79525
79526
79527 #if defined(CONFIG_SYSCTL)
79528 -
79529 /* External variables not in a header file. */
79530 extern int sysctl_overcommit_memory;
79531 extern int sysctl_overcommit_ratio;
79532 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
79533 void __user *buffer, size_t *lenp, loff_t *ppos);
79534 #endif
79535
79536 -#ifdef CONFIG_PRINTK
79537 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79538 void __user *buffer, size_t *lenp, loff_t *ppos);
79539 -#endif
79540
79541 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
79542 void __user *buffer, size_t *lenp, loff_t *ppos);
79543 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
79544
79545 #endif
79546
79547 +extern struct ctl_table grsecurity_table[];
79548 +
79549 static struct ctl_table kern_table[];
79550 static struct ctl_table vm_table[];
79551 static struct ctl_table fs_table[];
79552 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
79553 int sysctl_legacy_va_layout;
79554 #endif
79555
79556 +#ifdef CONFIG_PAX_SOFTMODE
79557 +static ctl_table pax_table[] = {
79558 + {
79559 + .procname = "softmode",
79560 + .data = &pax_softmode,
79561 + .maxlen = sizeof(unsigned int),
79562 + .mode = 0600,
79563 + .proc_handler = &proc_dointvec,
79564 + },
79565 +
79566 + { }
79567 +};
79568 +#endif
79569 +
79570 /* The default sysctl tables: */
79571
79572 static struct ctl_table sysctl_base_table[] = {
79573 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
79574 #endif
79575
79576 static struct ctl_table kern_table[] = {
79577 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
79578 + {
79579 + .procname = "grsecurity",
79580 + .mode = 0500,
79581 + .child = grsecurity_table,
79582 + },
79583 +#endif
79584 +
79585 +#ifdef CONFIG_PAX_SOFTMODE
79586 + {
79587 + .procname = "pax",
79588 + .mode = 0500,
79589 + .child = pax_table,
79590 + },
79591 +#endif
79592 +
79593 {
79594 .procname = "sched_child_runs_first",
79595 .data = &sysctl_sched_child_runs_first,
79596 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
79597 .data = &modprobe_path,
79598 .maxlen = KMOD_PATH_LEN,
79599 .mode = 0644,
79600 - .proc_handler = proc_dostring,
79601 + .proc_handler = proc_dostring_modpriv,
79602 },
79603 {
79604 .procname = "modules_disabled",
79605 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
79606 .extra1 = &zero,
79607 .extra2 = &one,
79608 },
79609 +#endif
79610 {
79611 .procname = "kptr_restrict",
79612 .data = &kptr_restrict,
79613 .maxlen = sizeof(int),
79614 .mode = 0644,
79615 .proc_handler = proc_dointvec_minmax_sysadmin,
79616 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79617 + .extra1 = &two,
79618 +#else
79619 .extra1 = &zero,
79620 +#endif
79621 .extra2 = &two,
79622 },
79623 -#endif
79624 {
79625 .procname = "ngroups_max",
79626 .data = &ngroups_max,
79627 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
79628 .proc_handler = proc_dointvec_minmax,
79629 .extra1 = &zero,
79630 },
79631 + {
79632 + .procname = "heap_stack_gap",
79633 + .data = &sysctl_heap_stack_gap,
79634 + .maxlen = sizeof(sysctl_heap_stack_gap),
79635 + .mode = 0644,
79636 + .proc_handler = proc_doulongvec_minmax,
79637 + },
79638 #else
79639 {
79640 .procname = "nr_trim_pages",
79641 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
79642 buffer, lenp, ppos);
79643 }
79644
79645 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79646 + void __user *buffer, size_t *lenp, loff_t *ppos)
79647 +{
79648 + if (write && !capable(CAP_SYS_MODULE))
79649 + return -EPERM;
79650 +
79651 + return _proc_do_string(table->data, table->maxlen, write,
79652 + buffer, lenp, ppos);
79653 +}
79654 +
79655 static size_t proc_skip_spaces(char **buf)
79656 {
79657 size_t ret;
79658 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79659 len = strlen(tmp);
79660 if (len > *size)
79661 len = *size;
79662 + if (len > sizeof(tmp))
79663 + len = sizeof(tmp);
79664 if (copy_to_user(*buf, tmp, len))
79665 return -EFAULT;
79666 *size -= len;
79667 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79668 static int proc_taint(struct ctl_table *table, int write,
79669 void __user *buffer, size_t *lenp, loff_t *ppos)
79670 {
79671 - struct ctl_table t;
79672 + ctl_table_no_const t;
79673 unsigned long tmptaint = get_taint();
79674 int err;
79675
79676 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
79677 return err;
79678 }
79679
79680 -#ifdef CONFIG_PRINTK
79681 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79682 void __user *buffer, size_t *lenp, loff_t *ppos)
79683 {
79684 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79685
79686 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79687 }
79688 -#endif
79689
79690 struct do_proc_dointvec_minmax_conv_param {
79691 int *min;
79692 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79693 *i = val;
79694 } else {
79695 val = convdiv * (*i) / convmul;
79696 - if (!first)
79697 + if (!first) {
79698 err = proc_put_char(&buffer, &left, '\t');
79699 + if (err)
79700 + break;
79701 + }
79702 err = proc_put_long(&buffer, &left, val, false);
79703 if (err)
79704 break;
79705 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
79706 return -ENOSYS;
79707 }
79708
79709 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79710 + void __user *buffer, size_t *lenp, loff_t *ppos)
79711 +{
79712 + return -ENOSYS;
79713 +}
79714 +
79715 int proc_dointvec(struct ctl_table *table, int write,
79716 void __user *buffer, size_t *lenp, loff_t *ppos)
79717 {
79718 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79719 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79720 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79721 EXPORT_SYMBOL(proc_dostring);
79722 +EXPORT_SYMBOL(proc_dostring_modpriv);
79723 EXPORT_SYMBOL(proc_doulongvec_minmax);
79724 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79725 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
79726 index 0ddf3a0..a199f50 100644
79727 --- a/kernel/sysctl_binary.c
79728 +++ b/kernel/sysctl_binary.c
79729 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
79730 int i;
79731
79732 set_fs(KERNEL_DS);
79733 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79734 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79735 set_fs(old_fs);
79736 if (result < 0)
79737 goto out_kfree;
79738 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
79739 }
79740
79741 set_fs(KERNEL_DS);
79742 - result = vfs_write(file, buffer, str - buffer, &pos);
79743 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79744 set_fs(old_fs);
79745 if (result < 0)
79746 goto out_kfree;
79747 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
79748 int i;
79749
79750 set_fs(KERNEL_DS);
79751 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79752 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79753 set_fs(old_fs);
79754 if (result < 0)
79755 goto out_kfree;
79756 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
79757 }
79758
79759 set_fs(KERNEL_DS);
79760 - result = vfs_write(file, buffer, str - buffer, &pos);
79761 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79762 set_fs(old_fs);
79763 if (result < 0)
79764 goto out_kfree;
79765 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
79766 int i;
79767
79768 set_fs(KERNEL_DS);
79769 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79770 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79771 set_fs(old_fs);
79772 if (result < 0)
79773 goto out;
79774 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79775 __le16 dnaddr;
79776
79777 set_fs(KERNEL_DS);
79778 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79779 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79780 set_fs(old_fs);
79781 if (result < 0)
79782 goto out;
79783 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79784 le16_to_cpu(dnaddr) & 0x3ff);
79785
79786 set_fs(KERNEL_DS);
79787 - result = vfs_write(file, buf, len, &pos);
79788 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
79789 set_fs(old_fs);
79790 if (result < 0)
79791 goto out;
79792 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79793 index 145bb4d..b2aa969 100644
79794 --- a/kernel/taskstats.c
79795 +++ b/kernel/taskstats.c
79796 @@ -28,9 +28,12 @@
79797 #include <linux/fs.h>
79798 #include <linux/file.h>
79799 #include <linux/pid_namespace.h>
79800 +#include <linux/grsecurity.h>
79801 #include <net/genetlink.h>
79802 #include <linux/atomic.h>
79803
79804 +extern int gr_is_taskstats_denied(int pid);
79805 +
79806 /*
79807 * Maximum length of a cpumask that can be specified in
79808 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79809 @@ -570,6 +573,9 @@ err:
79810
79811 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79812 {
79813 + if (gr_is_taskstats_denied(current->pid))
79814 + return -EACCES;
79815 +
79816 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79817 return cmd_attr_register_cpumask(info);
79818 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79819 diff --git a/kernel/time.c b/kernel/time.c
79820 index d226c6a..2f0d217 100644
79821 --- a/kernel/time.c
79822 +++ b/kernel/time.c
79823 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79824 return error;
79825
79826 if (tz) {
79827 + /* we log in do_settimeofday called below, so don't log twice
79828 + */
79829 + if (!tv)
79830 + gr_log_timechange();
79831 +
79832 sys_tz = *tz;
79833 update_vsyscall_tz();
79834 if (firsttime) {
79835 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79836 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79837 * value to a scaled second value.
79838 */
79839 -unsigned long
79840 +unsigned long __intentional_overflow(-1)
79841 timespec_to_jiffies(const struct timespec *value)
79842 {
79843 unsigned long sec = value->tv_sec;
79844 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79845 index f11d83b..d016d91 100644
79846 --- a/kernel/time/alarmtimer.c
79847 +++ b/kernel/time/alarmtimer.c
79848 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79849 struct platform_device *pdev;
79850 int error = 0;
79851 int i;
79852 - struct k_clock alarm_clock = {
79853 + static struct k_clock alarm_clock = {
79854 .clock_getres = alarm_clock_getres,
79855 .clock_get = alarm_clock_get,
79856 .timer_create = alarm_timer_create,
79857 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79858 index a13987a..36cd791 100644
79859 --- a/kernel/time/tick-broadcast.c
79860 +++ b/kernel/time/tick-broadcast.c
79861 @@ -116,7 +116,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79862 * then clear the broadcast bit.
79863 */
79864 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79865 - int cpu = smp_processor_id();
79866 + cpu = smp_processor_id();
79867
79868 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79869 tick_broadcast_clear_oneshot(cpu);
79870 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79871 index cbc6acb..3a77191 100644
79872 --- a/kernel/time/timekeeping.c
79873 +++ b/kernel/time/timekeeping.c
79874 @@ -15,6 +15,7 @@
79875 #include <linux/init.h>
79876 #include <linux/mm.h>
79877 #include <linux/sched.h>
79878 +#include <linux/grsecurity.h>
79879 #include <linux/syscore_ops.h>
79880 #include <linux/clocksource.h>
79881 #include <linux/jiffies.h>
79882 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
79883 if (!timespec_valid_strict(tv))
79884 return -EINVAL;
79885
79886 + gr_log_timechange();
79887 +
79888 write_seqlock_irqsave(&tk->lock, flags);
79889
79890 timekeeping_forward_now(tk);
79891 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79892 index af5a7e9..715611a 100644
79893 --- a/kernel/time/timer_list.c
79894 +++ b/kernel/time/timer_list.c
79895 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79896
79897 static void print_name_offset(struct seq_file *m, void *sym)
79898 {
79899 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79900 + SEQ_printf(m, "<%p>", NULL);
79901 +#else
79902 char symname[KSYM_NAME_LEN];
79903
79904 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79905 SEQ_printf(m, "<%pK>", sym);
79906 else
79907 SEQ_printf(m, "%s", symname);
79908 +#endif
79909 }
79910
79911 static void
79912 @@ -112,7 +116,11 @@ next_one:
79913 static void
79914 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79915 {
79916 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79917 + SEQ_printf(m, " .base: %p\n", NULL);
79918 +#else
79919 SEQ_printf(m, " .base: %pK\n", base);
79920 +#endif
79921 SEQ_printf(m, " .index: %d\n",
79922 base->index);
79923 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79924 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79925 {
79926 struct proc_dir_entry *pe;
79927
79928 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79929 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79930 +#else
79931 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79932 +#endif
79933 if (!pe)
79934 return -ENOMEM;
79935 return 0;
79936 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79937 index 0b537f2..40d6c20 100644
79938 --- a/kernel/time/timer_stats.c
79939 +++ b/kernel/time/timer_stats.c
79940 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79941 static unsigned long nr_entries;
79942 static struct entry entries[MAX_ENTRIES];
79943
79944 -static atomic_t overflow_count;
79945 +static atomic_unchecked_t overflow_count;
79946
79947 /*
79948 * The entries are in a hash-table, for fast lookup:
79949 @@ -140,7 +140,7 @@ static void reset_entries(void)
79950 nr_entries = 0;
79951 memset(entries, 0, sizeof(entries));
79952 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79953 - atomic_set(&overflow_count, 0);
79954 + atomic_set_unchecked(&overflow_count, 0);
79955 }
79956
79957 static struct entry *alloc_entry(void)
79958 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79959 if (likely(entry))
79960 entry->count++;
79961 else
79962 - atomic_inc(&overflow_count);
79963 + atomic_inc_unchecked(&overflow_count);
79964
79965 out_unlock:
79966 raw_spin_unlock_irqrestore(lock, flags);
79967 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79968
79969 static void print_name_offset(struct seq_file *m, unsigned long addr)
79970 {
79971 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79972 + seq_printf(m, "<%p>", NULL);
79973 +#else
79974 char symname[KSYM_NAME_LEN];
79975
79976 if (lookup_symbol_name(addr, symname) < 0)
79977 - seq_printf(m, "<%p>", (void *)addr);
79978 + seq_printf(m, "<%pK>", (void *)addr);
79979 else
79980 seq_printf(m, "%s", symname);
79981 +#endif
79982 }
79983
79984 static int tstats_show(struct seq_file *m, void *v)
79985 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79986
79987 seq_puts(m, "Timer Stats Version: v0.2\n");
79988 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79989 - if (atomic_read(&overflow_count))
79990 + if (atomic_read_unchecked(&overflow_count))
79991 seq_printf(m, "Overflow: %d entries\n",
79992 - atomic_read(&overflow_count));
79993 + atomic_read_unchecked(&overflow_count));
79994
79995 for (i = 0; i < nr_entries; i++) {
79996 entry = entries + i;
79997 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79998 {
79999 struct proc_dir_entry *pe;
80000
80001 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
80002 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
80003 +#else
80004 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
80005 +#endif
80006 if (!pe)
80007 return -ENOMEM;
80008 return 0;
80009 diff --git a/kernel/timer.c b/kernel/timer.c
80010 index 367d008..5dee98f 100644
80011 --- a/kernel/timer.c
80012 +++ b/kernel/timer.c
80013 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
80014 /*
80015 * This function runs timers and the timer-tq in bottom half context.
80016 */
80017 -static void run_timer_softirq(struct softirq_action *h)
80018 +static void run_timer_softirq(void)
80019 {
80020 struct tvec_base *base = __this_cpu_read(tvec_bases);
80021
80022 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
80023 *
80024 * In all cases the return value is guaranteed to be non-negative.
80025 */
80026 -signed long __sched schedule_timeout(signed long timeout)
80027 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
80028 {
80029 struct timer_list timer;
80030 unsigned long expire;
80031 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
80032 return NOTIFY_OK;
80033 }
80034
80035 -static struct notifier_block __cpuinitdata timers_nb = {
80036 +static struct notifier_block timers_nb = {
80037 .notifier_call = timer_cpu_notify,
80038 };
80039
80040 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
80041 index c0bd030..62a1927 100644
80042 --- a/kernel/trace/blktrace.c
80043 +++ b/kernel/trace/blktrace.c
80044 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
80045 struct blk_trace *bt = filp->private_data;
80046 char buf[16];
80047
80048 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
80049 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
80050
80051 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
80052 }
80053 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
80054 return 1;
80055
80056 bt = buf->chan->private_data;
80057 - atomic_inc(&bt->dropped);
80058 + atomic_inc_unchecked(&bt->dropped);
80059 return 0;
80060 }
80061
80062 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
80063
80064 bt->dir = dir;
80065 bt->dev = dev;
80066 - atomic_set(&bt->dropped, 0);
80067 + atomic_set_unchecked(&bt->dropped, 0);
80068
80069 ret = -EIO;
80070 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
80071 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
80072 index 35cc3a8..2a47da3 100644
80073 --- a/kernel/trace/ftrace.c
80074 +++ b/kernel/trace/ftrace.c
80075 @@ -1886,12 +1886,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
80076 if (unlikely(ftrace_disabled))
80077 return 0;
80078
80079 + ret = ftrace_arch_code_modify_prepare();
80080 + FTRACE_WARN_ON(ret);
80081 + if (ret)
80082 + return 0;
80083 +
80084 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
80085 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
80086 if (ret) {
80087 ftrace_bug(ret, ip);
80088 - return 0;
80089 }
80090 - return 1;
80091 + return ret ? 0 : 1;
80092 }
80093
80094 /*
80095 @@ -2964,7 +2969,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
80096
80097 int
80098 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
80099 - void *data)
80100 + void *data)
80101 {
80102 struct ftrace_func_probe *entry;
80103 struct ftrace_page *pg;
80104 @@ -3831,8 +3836,10 @@ static int ftrace_process_locs(struct module *mod,
80105 if (!count)
80106 return 0;
80107
80108 + pax_open_kernel();
80109 sort(start, count, sizeof(*start),
80110 ftrace_cmp_ips, ftrace_swap_ips);
80111 + pax_close_kernel();
80112
80113 start_pg = ftrace_allocate_pages(count);
80114 if (!start_pg)
80115 @@ -4554,8 +4561,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
80116 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
80117
80118 static int ftrace_graph_active;
80119 -static struct notifier_block ftrace_suspend_notifier;
80120 -
80121 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
80122 {
80123 return 0;
80124 @@ -4699,6 +4704,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
80125 return NOTIFY_DONE;
80126 }
80127
80128 +static struct notifier_block ftrace_suspend_notifier = {
80129 + .notifier_call = ftrace_suspend_notifier_call
80130 +};
80131 +
80132 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
80133 trace_func_graph_ent_t entryfunc)
80134 {
80135 @@ -4712,7 +4721,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
80136 goto out;
80137 }
80138
80139 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
80140 register_pm_notifier(&ftrace_suspend_notifier);
80141
80142 ftrace_graph_active++;
80143 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
80144 index ce8514f..8233573 100644
80145 --- a/kernel/trace/ring_buffer.c
80146 +++ b/kernel/trace/ring_buffer.c
80147 @@ -346,9 +346,9 @@ struct buffer_data_page {
80148 */
80149 struct buffer_page {
80150 struct list_head list; /* list of buffer pages */
80151 - local_t write; /* index for next write */
80152 + local_unchecked_t write; /* index for next write */
80153 unsigned read; /* index for next read */
80154 - local_t entries; /* entries on this page */
80155 + local_unchecked_t entries; /* entries on this page */
80156 unsigned long real_end; /* real end of data */
80157 struct buffer_data_page *page; /* Actual data page */
80158 };
80159 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
80160 unsigned long last_overrun;
80161 local_t entries_bytes;
80162 local_t entries;
80163 - local_t overrun;
80164 - local_t commit_overrun;
80165 + local_unchecked_t overrun;
80166 + local_unchecked_t commit_overrun;
80167 local_t dropped_events;
80168 local_t committing;
80169 local_t commits;
80170 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
80171 *
80172 * We add a counter to the write field to denote this.
80173 */
80174 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
80175 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
80176 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
80177 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
80178
80179 /*
80180 * Just make sure we have seen our old_write and synchronize
80181 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
80182 * cmpxchg to only update if an interrupt did not already
80183 * do it for us. If the cmpxchg fails, we don't care.
80184 */
80185 - (void)local_cmpxchg(&next_page->write, old_write, val);
80186 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
80187 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
80188 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
80189
80190 /*
80191 * No need to worry about races with clearing out the commit.
80192 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
80193
80194 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
80195 {
80196 - return local_read(&bpage->entries) & RB_WRITE_MASK;
80197 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
80198 }
80199
80200 static inline unsigned long rb_page_write(struct buffer_page *bpage)
80201 {
80202 - return local_read(&bpage->write) & RB_WRITE_MASK;
80203 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
80204 }
80205
80206 static int
80207 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
80208 * bytes consumed in ring buffer from here.
80209 * Increment overrun to account for the lost events.
80210 */
80211 - local_add(page_entries, &cpu_buffer->overrun);
80212 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
80213 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
80214 }
80215
80216 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
80217 * it is our responsibility to update
80218 * the counters.
80219 */
80220 - local_add(entries, &cpu_buffer->overrun);
80221 + local_add_unchecked(entries, &cpu_buffer->overrun);
80222 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
80223
80224 /*
80225 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80226 if (tail == BUF_PAGE_SIZE)
80227 tail_page->real_end = 0;
80228
80229 - local_sub(length, &tail_page->write);
80230 + local_sub_unchecked(length, &tail_page->write);
80231 return;
80232 }
80233
80234 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80235 rb_event_set_padding(event);
80236
80237 /* Set the write back to the previous setting */
80238 - local_sub(length, &tail_page->write);
80239 + local_sub_unchecked(length, &tail_page->write);
80240 return;
80241 }
80242
80243 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
80244
80245 /* Set write to end of buffer */
80246 length = (tail + length) - BUF_PAGE_SIZE;
80247 - local_sub(length, &tail_page->write);
80248 + local_sub_unchecked(length, &tail_page->write);
80249 }
80250
80251 /*
80252 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
80253 * about it.
80254 */
80255 if (unlikely(next_page == commit_page)) {
80256 - local_inc(&cpu_buffer->commit_overrun);
80257 + local_inc_unchecked(&cpu_buffer->commit_overrun);
80258 goto out_reset;
80259 }
80260
80261 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
80262 cpu_buffer->tail_page) &&
80263 (cpu_buffer->commit_page ==
80264 cpu_buffer->reader_page))) {
80265 - local_inc(&cpu_buffer->commit_overrun);
80266 + local_inc_unchecked(&cpu_buffer->commit_overrun);
80267 goto out_reset;
80268 }
80269 }
80270 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80271 length += RB_LEN_TIME_EXTEND;
80272
80273 tail_page = cpu_buffer->tail_page;
80274 - write = local_add_return(length, &tail_page->write);
80275 + write = local_add_return_unchecked(length, &tail_page->write);
80276
80277 /* set write to only the index of the write */
80278 write &= RB_WRITE_MASK;
80279 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80280 kmemcheck_annotate_bitfield(event, bitfield);
80281 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
80282
80283 - local_inc(&tail_page->entries);
80284 + local_inc_unchecked(&tail_page->entries);
80285
80286 /*
80287 * If this is the first commit on the page, then update
80288 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80289
80290 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
80291 unsigned long write_mask =
80292 - local_read(&bpage->write) & ~RB_WRITE_MASK;
80293 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
80294 unsigned long event_length = rb_event_length(event);
80295 /*
80296 * This is on the tail page. It is possible that
80297 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80298 */
80299 old_index += write_mask;
80300 new_index += write_mask;
80301 - index = local_cmpxchg(&bpage->write, old_index, new_index);
80302 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
80303 if (index == old_index) {
80304 /* update counters */
80305 local_sub(event_length, &cpu_buffer->entries_bytes);
80306 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80307
80308 /* Do the likely case first */
80309 if (likely(bpage->page == (void *)addr)) {
80310 - local_dec(&bpage->entries);
80311 + local_dec_unchecked(&bpage->entries);
80312 return;
80313 }
80314
80315 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80316 start = bpage;
80317 do {
80318 if (bpage->page == (void *)addr) {
80319 - local_dec(&bpage->entries);
80320 + local_dec_unchecked(&bpage->entries);
80321 return;
80322 }
80323 rb_inc_page(cpu_buffer, &bpage);
80324 @@ -2926,7 +2926,7 @@ static inline unsigned long
80325 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
80326 {
80327 return local_read(&cpu_buffer->entries) -
80328 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
80329 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
80330 }
80331
80332 /**
80333 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
80334 return 0;
80335
80336 cpu_buffer = buffer->buffers[cpu];
80337 - ret = local_read(&cpu_buffer->overrun);
80338 + ret = local_read_unchecked(&cpu_buffer->overrun);
80339
80340 return ret;
80341 }
80342 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
80343 return 0;
80344
80345 cpu_buffer = buffer->buffers[cpu];
80346 - ret = local_read(&cpu_buffer->commit_overrun);
80347 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
80348
80349 return ret;
80350 }
80351 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
80352 /* if you care about this being correct, lock the buffer */
80353 for_each_buffer_cpu(buffer, cpu) {
80354 cpu_buffer = buffer->buffers[cpu];
80355 - overruns += local_read(&cpu_buffer->overrun);
80356 + overruns += local_read_unchecked(&cpu_buffer->overrun);
80357 }
80358
80359 return overruns;
80360 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80361 /*
80362 * Reset the reader page to size zero.
80363 */
80364 - local_set(&cpu_buffer->reader_page->write, 0);
80365 - local_set(&cpu_buffer->reader_page->entries, 0);
80366 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
80367 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
80368 local_set(&cpu_buffer->reader_page->page->commit, 0);
80369 cpu_buffer->reader_page->real_end = 0;
80370
80371 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80372 * want to compare with the last_overrun.
80373 */
80374 smp_mb();
80375 - overwrite = local_read(&(cpu_buffer->overrun));
80376 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
80377
80378 /*
80379 * Here's the tricky part.
80380 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
80381
80382 cpu_buffer->head_page
80383 = list_entry(cpu_buffer->pages, struct buffer_page, list);
80384 - local_set(&cpu_buffer->head_page->write, 0);
80385 - local_set(&cpu_buffer->head_page->entries, 0);
80386 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
80387 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
80388 local_set(&cpu_buffer->head_page->page->commit, 0);
80389
80390 cpu_buffer->head_page->read = 0;
80391 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
80392
80393 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
80394 INIT_LIST_HEAD(&cpu_buffer->new_pages);
80395 - local_set(&cpu_buffer->reader_page->write, 0);
80396 - local_set(&cpu_buffer->reader_page->entries, 0);
80397 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
80398 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
80399 local_set(&cpu_buffer->reader_page->page->commit, 0);
80400 cpu_buffer->reader_page->read = 0;
80401
80402 local_set(&cpu_buffer->entries_bytes, 0);
80403 - local_set(&cpu_buffer->overrun, 0);
80404 - local_set(&cpu_buffer->commit_overrun, 0);
80405 + local_set_unchecked(&cpu_buffer->overrun, 0);
80406 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
80407 local_set(&cpu_buffer->dropped_events, 0);
80408 local_set(&cpu_buffer->entries, 0);
80409 local_set(&cpu_buffer->committing, 0);
80410 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
80411 rb_init_page(bpage);
80412 bpage = reader->page;
80413 reader->page = *data_page;
80414 - local_set(&reader->write, 0);
80415 - local_set(&reader->entries, 0);
80416 + local_set_unchecked(&reader->write, 0);
80417 + local_set_unchecked(&reader->entries, 0);
80418 reader->read = 0;
80419 *data_page = bpage;
80420
80421 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
80422 index fe1d581..43a0f38 100644
80423 --- a/kernel/trace/trace.c
80424 +++ b/kernel/trace/trace.c
80425 @@ -4494,10 +4494,9 @@ static const struct file_operations tracing_dyn_info_fops = {
80426 };
80427 #endif
80428
80429 -static struct dentry *d_tracer;
80430 -
80431 struct dentry *tracing_init_dentry(void)
80432 {
80433 + static struct dentry *d_tracer;
80434 static int once;
80435
80436 if (d_tracer)
80437 @@ -4517,10 +4516,9 @@ struct dentry *tracing_init_dentry(void)
80438 return d_tracer;
80439 }
80440
80441 -static struct dentry *d_percpu;
80442 -
80443 struct dentry *tracing_dentry_percpu(void)
80444 {
80445 + static struct dentry *d_percpu;
80446 static int once;
80447 struct dentry *d_tracer;
80448
80449 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
80450 index 880073d..42db7c3 100644
80451 --- a/kernel/trace/trace_events.c
80452 +++ b/kernel/trace/trace_events.c
80453 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
80454 struct ftrace_module_file_ops {
80455 struct list_head list;
80456 struct module *mod;
80457 - struct file_operations id;
80458 - struct file_operations enable;
80459 - struct file_operations format;
80460 - struct file_operations filter;
80461 };
80462
80463 static struct ftrace_module_file_ops *
80464 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
80465
80466 file_ops->mod = mod;
80467
80468 - file_ops->id = ftrace_event_id_fops;
80469 - file_ops->id.owner = mod;
80470 -
80471 - file_ops->enable = ftrace_enable_fops;
80472 - file_ops->enable.owner = mod;
80473 -
80474 - file_ops->filter = ftrace_event_filter_fops;
80475 - file_ops->filter.owner = mod;
80476 -
80477 - file_ops->format = ftrace_event_format_fops;
80478 - file_ops->format.owner = mod;
80479 + pax_open_kernel();
80480 + mod->trace_id.owner = mod;
80481 + mod->trace_enable.owner = mod;
80482 + mod->trace_filter.owner = mod;
80483 + mod->trace_format.owner = mod;
80484 + pax_close_kernel();
80485
80486 list_add(&file_ops->list, &ftrace_module_file_list);
80487
80488 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
80489
80490 for_each_event(call, start, end) {
80491 __trace_add_event_call(*call, mod,
80492 - &file_ops->id, &file_ops->enable,
80493 - &file_ops->filter, &file_ops->format);
80494 + &mod->trace_id, &mod->trace_enable,
80495 + &mod->trace_filter, &mod->trace_format);
80496 }
80497 }
80498
80499 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
80500 index fd3c8aa..5f324a6 100644
80501 --- a/kernel/trace/trace_mmiotrace.c
80502 +++ b/kernel/trace/trace_mmiotrace.c
80503 @@ -24,7 +24,7 @@ struct header_iter {
80504 static struct trace_array *mmio_trace_array;
80505 static bool overrun_detected;
80506 static unsigned long prev_overruns;
80507 -static atomic_t dropped_count;
80508 +static atomic_unchecked_t dropped_count;
80509
80510 static void mmio_reset_data(struct trace_array *tr)
80511 {
80512 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
80513
80514 static unsigned long count_overruns(struct trace_iterator *iter)
80515 {
80516 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
80517 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
80518 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
80519
80520 if (over > prev_overruns)
80521 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
80522 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
80523 sizeof(*entry), 0, pc);
80524 if (!event) {
80525 - atomic_inc(&dropped_count);
80526 + atomic_inc_unchecked(&dropped_count);
80527 return;
80528 }
80529 entry = ring_buffer_event_data(event);
80530 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
80531 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
80532 sizeof(*entry), 0, pc);
80533 if (!event) {
80534 - atomic_inc(&dropped_count);
80535 + atomic_inc_unchecked(&dropped_count);
80536 return;
80537 }
80538 entry = ring_buffer_event_data(event);
80539 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
80540 index 194d796..76edb8f 100644
80541 --- a/kernel/trace/trace_output.c
80542 +++ b/kernel/trace/trace_output.c
80543 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
80544
80545 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
80546 if (!IS_ERR(p)) {
80547 - p = mangle_path(s->buffer + s->len, p, "\n");
80548 + p = mangle_path(s->buffer + s->len, p, "\n\\");
80549 if (p) {
80550 s->len = p - s->buffer;
80551 return 1;
80552 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
80553 goto out;
80554 }
80555
80556 + pax_open_kernel();
80557 if (event->funcs->trace == NULL)
80558 - event->funcs->trace = trace_nop_print;
80559 + *(void **)&event->funcs->trace = trace_nop_print;
80560 if (event->funcs->raw == NULL)
80561 - event->funcs->raw = trace_nop_print;
80562 + *(void **)&event->funcs->raw = trace_nop_print;
80563 if (event->funcs->hex == NULL)
80564 - event->funcs->hex = trace_nop_print;
80565 + *(void **)&event->funcs->hex = trace_nop_print;
80566 if (event->funcs->binary == NULL)
80567 - event->funcs->binary = trace_nop_print;
80568 + *(void **)&event->funcs->binary = trace_nop_print;
80569 + pax_close_kernel();
80570
80571 key = event->type & (EVENT_HASHSIZE - 1);
80572
80573 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
80574 index 83a8b5b..0bf39a9 100644
80575 --- a/kernel/trace/trace_stack.c
80576 +++ b/kernel/trace/trace_stack.c
80577 @@ -52,7 +52,7 @@ static inline void check_stack(void)
80578 return;
80579
80580 /* we do not handle interrupt stacks yet */
80581 - if (!object_is_on_stack(&this_size))
80582 + if (!object_starts_on_stack(&this_size))
80583 return;
80584
80585 local_irq_save(flags);
80586 diff --git a/kernel/user.c b/kernel/user.c
80587 index 7f6ff2b..1ac8f18 100644
80588 --- a/kernel/user.c
80589 +++ b/kernel/user.c
80590 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
80591 .count = 4294967295U,
80592 },
80593 },
80594 - .kref = {
80595 - .refcount = ATOMIC_INIT(3),
80596 - },
80597 + .count = ATOMIC_INIT(3),
80598 .owner = GLOBAL_ROOT_UID,
80599 .group = GLOBAL_ROOT_GID,
80600 .proc_inum = PROC_USER_INIT_INO,
80601 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
80602 index f359dc7..ddc606a 100644
80603 --- a/kernel/user_namespace.c
80604 +++ b/kernel/user_namespace.c
80605 @@ -89,7 +89,7 @@ int create_user_ns(struct cred *new)
80606 return ret;
80607 }
80608
80609 - kref_init(&ns->kref);
80610 + atomic_set(&ns->count, 1);
80611 /* Leave the new->user_ns reference with the new user namespace. */
80612 ns->parent = parent_ns;
80613 ns->owner = owner;
80614 @@ -117,15 +117,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
80615 return create_user_ns(cred);
80616 }
80617
80618 -void free_user_ns(struct kref *kref)
80619 +void free_user_ns(struct user_namespace *ns)
80620 {
80621 - struct user_namespace *parent, *ns =
80622 - container_of(kref, struct user_namespace, kref);
80623 + struct user_namespace *parent;
80624
80625 - parent = ns->parent;
80626 - proc_free_inum(ns->proc_inum);
80627 - kmem_cache_free(user_ns_cachep, ns);
80628 - put_user_ns(parent);
80629 + do {
80630 + parent = ns->parent;
80631 + proc_free_inum(ns->proc_inum);
80632 + kmem_cache_free(user_ns_cachep, ns);
80633 + ns = parent;
80634 + } while (atomic_dec_and_test(&parent->count));
80635 }
80636 EXPORT_SYMBOL(free_user_ns);
80637
80638 @@ -819,7 +820,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80639 if (atomic_read(&current->mm->mm_users) > 1)
80640 return -EINVAL;
80641
80642 - if (current->fs->users != 1)
80643 + if (atomic_read(&current->fs->users) != 1)
80644 return -EINVAL;
80645
80646 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80647 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80648 index 63da38c..639904e 100644
80649 --- a/kernel/utsname_sysctl.c
80650 +++ b/kernel/utsname_sysctl.c
80651 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80652 static int proc_do_uts_string(ctl_table *table, int write,
80653 void __user *buffer, size_t *lenp, loff_t *ppos)
80654 {
80655 - struct ctl_table uts_table;
80656 + ctl_table_no_const uts_table;
80657 int r;
80658 memcpy(&uts_table, table, sizeof(uts_table));
80659 uts_table.data = get_uts(table, write);
80660 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80661 index 75a2ab3..5961da7 100644
80662 --- a/kernel/watchdog.c
80663 +++ b/kernel/watchdog.c
80664 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80665 }
80666 #endif /* CONFIG_SYSCTL */
80667
80668 -static struct smp_hotplug_thread watchdog_threads = {
80669 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80670 .store = &softlockup_watchdog,
80671 .thread_should_run = watchdog_should_run,
80672 .thread_fn = watchdog,
80673 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80674 index 67604e5..fe94fb1 100644
80675 --- a/lib/Kconfig.debug
80676 +++ b/lib/Kconfig.debug
80677 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
80678
80679 config DEBUG_LOCK_ALLOC
80680 bool "Lock debugging: detect incorrect freeing of live locks"
80681 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80682 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80683 select DEBUG_SPINLOCK
80684 select DEBUG_MUTEXES
80685 select LOCKDEP
80686 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
80687
80688 config PROVE_LOCKING
80689 bool "Lock debugging: prove locking correctness"
80690 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80691 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80692 select LOCKDEP
80693 select DEBUG_SPINLOCK
80694 select DEBUG_MUTEXES
80695 @@ -670,7 +670,7 @@ config LOCKDEP
80696
80697 config LOCK_STAT
80698 bool "Lock usage statistics"
80699 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80700 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80701 select LOCKDEP
80702 select DEBUG_SPINLOCK
80703 select DEBUG_MUTEXES
80704 @@ -1278,6 +1278,7 @@ config LATENCYTOP
80705 depends on DEBUG_KERNEL
80706 depends on STACKTRACE_SUPPORT
80707 depends on PROC_FS
80708 + depends on !GRKERNSEC_HIDESYM
80709 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80710 select KALLSYMS
80711 select KALLSYMS_ALL
80712 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
80713
80714 config PROVIDE_OHCI1394_DMA_INIT
80715 bool "Remote debugging over FireWire early on boot"
80716 - depends on PCI && X86
80717 + depends on PCI && X86 && !GRKERNSEC
80718 help
80719 If you want to debug problems which hang or crash the kernel early
80720 on boot and the crashing machine has a FireWire port, you can use
80721 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80722
80723 config FIREWIRE_OHCI_REMOTE_DMA
80724 bool "Remote debugging over FireWire with firewire-ohci"
80725 - depends on FIREWIRE_OHCI
80726 + depends on FIREWIRE_OHCI && !GRKERNSEC
80727 help
80728 This option lets you use the FireWire bus for remote debugging
80729 with help of the firewire-ohci driver. It enables unfiltered
80730 diff --git a/lib/Makefile b/lib/Makefile
80731 index 02ed6c0..bd243da 100644
80732 --- a/lib/Makefile
80733 +++ b/lib/Makefile
80734 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80735
80736 obj-$(CONFIG_BTREE) += btree.o
80737 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80738 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80739 +obj-y += list_debug.o
80740 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80741
80742 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80743 diff --git a/lib/bitmap.c b/lib/bitmap.c
80744 index 06f7e4f..f3cf2b0 100644
80745 --- a/lib/bitmap.c
80746 +++ b/lib/bitmap.c
80747 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80748 {
80749 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80750 u32 chunk;
80751 - const char __user __force *ubuf = (const char __user __force *)buf;
80752 + const char __user *ubuf = (const char __force_user *)buf;
80753
80754 bitmap_zero(maskp, nmaskbits);
80755
80756 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80757 {
80758 if (!access_ok(VERIFY_READ, ubuf, ulen))
80759 return -EFAULT;
80760 - return __bitmap_parse((const char __force *)ubuf,
80761 + return __bitmap_parse((const char __force_kernel *)ubuf,
80762 ulen, 1, maskp, nmaskbits);
80763
80764 }
80765 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80766 {
80767 unsigned a, b;
80768 int c, old_c, totaldigits;
80769 - const char __user __force *ubuf = (const char __user __force *)buf;
80770 + const char __user *ubuf = (const char __force_user *)buf;
80771 int exp_digit, in_range;
80772
80773 totaldigits = c = 0;
80774 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80775 {
80776 if (!access_ok(VERIFY_READ, ubuf, ulen))
80777 return -EFAULT;
80778 - return __bitmap_parselist((const char __force *)ubuf,
80779 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80780 ulen, 1, maskp, nmaskbits);
80781 }
80782 EXPORT_SYMBOL(bitmap_parselist_user);
80783 diff --git a/lib/bug.c b/lib/bug.c
80784 index d0cdf14..4d07bd2 100644
80785 --- a/lib/bug.c
80786 +++ b/lib/bug.c
80787 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80788 return BUG_TRAP_TYPE_NONE;
80789
80790 bug = find_bug(bugaddr);
80791 + if (!bug)
80792 + return BUG_TRAP_TYPE_NONE;
80793
80794 file = NULL;
80795 line = 0;
80796 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80797 index d11808c..dc2d6f8 100644
80798 --- a/lib/debugobjects.c
80799 +++ b/lib/debugobjects.c
80800 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80801 if (limit > 4)
80802 return;
80803
80804 - is_on_stack = object_is_on_stack(addr);
80805 + is_on_stack = object_starts_on_stack(addr);
80806 if (is_on_stack == onstack)
80807 return;
80808
80809 diff --git a/lib/devres.c b/lib/devres.c
80810 index 80b9c76..9e32279 100644
80811 --- a/lib/devres.c
80812 +++ b/lib/devres.c
80813 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80814 void devm_iounmap(struct device *dev, void __iomem *addr)
80815 {
80816 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80817 - (void *)addr));
80818 + (void __force *)addr));
80819 iounmap(addr);
80820 }
80821 EXPORT_SYMBOL(devm_iounmap);
80822 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80823 {
80824 ioport_unmap(addr);
80825 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80826 - devm_ioport_map_match, (void *)addr));
80827 + devm_ioport_map_match, (void __force *)addr));
80828 }
80829 EXPORT_SYMBOL(devm_ioport_unmap);
80830
80831 diff --git a/lib/div64.c b/lib/div64.c
80832 index a163b6c..9618fa5 100644
80833 --- a/lib/div64.c
80834 +++ b/lib/div64.c
80835 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80836 EXPORT_SYMBOL(__div64_32);
80837
80838 #ifndef div_s64_rem
80839 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80840 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80841 {
80842 u64 quotient;
80843
80844 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80845 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80846 */
80847 #ifndef div64_u64
80848 -u64 div64_u64(u64 dividend, u64 divisor)
80849 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80850 {
80851 u32 high = divisor >> 32;
80852 u64 quot;
80853 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80854 index 5e396ac..58d5de1 100644
80855 --- a/lib/dma-debug.c
80856 +++ b/lib/dma-debug.c
80857 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80858
80859 void dma_debug_add_bus(struct bus_type *bus)
80860 {
80861 - struct notifier_block *nb;
80862 + notifier_block_no_const *nb;
80863
80864 if (global_disable)
80865 return;
80866 @@ -942,7 +942,7 @@ out:
80867
80868 static void check_for_stack(struct device *dev, void *addr)
80869 {
80870 - if (object_is_on_stack(addr))
80871 + if (object_starts_on_stack(addr))
80872 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80873 "stack [addr=%p]\n", addr);
80874 }
80875 diff --git a/lib/inflate.c b/lib/inflate.c
80876 index 013a761..c28f3fc 100644
80877 --- a/lib/inflate.c
80878 +++ b/lib/inflate.c
80879 @@ -269,7 +269,7 @@ static void free(void *where)
80880 malloc_ptr = free_mem_ptr;
80881 }
80882 #else
80883 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80884 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80885 #define free(a) kfree(a)
80886 #endif
80887
80888 diff --git a/lib/ioremap.c b/lib/ioremap.c
80889 index 0c9216c..863bd89 100644
80890 --- a/lib/ioremap.c
80891 +++ b/lib/ioremap.c
80892 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80893 unsigned long next;
80894
80895 phys_addr -= addr;
80896 - pmd = pmd_alloc(&init_mm, pud, addr);
80897 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80898 if (!pmd)
80899 return -ENOMEM;
80900 do {
80901 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80902 unsigned long next;
80903
80904 phys_addr -= addr;
80905 - pud = pud_alloc(&init_mm, pgd, addr);
80906 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80907 if (!pud)
80908 return -ENOMEM;
80909 do {
80910 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80911 index bd2bea9..6b3c95e 100644
80912 --- a/lib/is_single_threaded.c
80913 +++ b/lib/is_single_threaded.c
80914 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80915 struct task_struct *p, *t;
80916 bool ret;
80917
80918 + if (!mm)
80919 + return true;
80920 +
80921 if (atomic_read(&task->signal->live) != 1)
80922 return false;
80923
80924 diff --git a/lib/kobject.c b/lib/kobject.c
80925 index a654866..a4fd13d 100644
80926 --- a/lib/kobject.c
80927 +++ b/lib/kobject.c
80928 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80929
80930
80931 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80932 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80933 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80934
80935 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80936 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80937 {
80938 enum kobj_ns_type type = ops->type;
80939 int error;
80940 diff --git a/lib/list_debug.c b/lib/list_debug.c
80941 index c24c2f7..06e070b 100644
80942 --- a/lib/list_debug.c
80943 +++ b/lib/list_debug.c
80944 @@ -11,7 +11,9 @@
80945 #include <linux/bug.h>
80946 #include <linux/kernel.h>
80947 #include <linux/rculist.h>
80948 +#include <linux/mm.h>
80949
80950 +#ifdef CONFIG_DEBUG_LIST
80951 /*
80952 * Insert a new entry between two known consecutive entries.
80953 *
80954 @@ -19,21 +21,32 @@
80955 * the prev/next entries already!
80956 */
80957
80958 -void __list_add(struct list_head *new,
80959 - struct list_head *prev,
80960 - struct list_head *next)
80961 +static bool __list_add_debug(struct list_head *new,
80962 + struct list_head *prev,
80963 + struct list_head *next)
80964 {
80965 - WARN(next->prev != prev,
80966 + if (WARN(next->prev != prev,
80967 "list_add corruption. next->prev should be "
80968 "prev (%p), but was %p. (next=%p).\n",
80969 - prev, next->prev, next);
80970 - WARN(prev->next != next,
80971 + prev, next->prev, next) ||
80972 + WARN(prev->next != next,
80973 "list_add corruption. prev->next should be "
80974 "next (%p), but was %p. (prev=%p).\n",
80975 - next, prev->next, prev);
80976 - WARN(new == prev || new == next,
80977 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80978 - new, prev, next);
80979 + next, prev->next, prev) ||
80980 + WARN(new == prev || new == next,
80981 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80982 + new, prev, next))
80983 + return false;
80984 + return true;
80985 +}
80986 +
80987 +void __list_add(struct list_head *new,
80988 + struct list_head *prev,
80989 + struct list_head *next)
80990 +{
80991 + if (!__list_add_debug(new, prev, next))
80992 + return;
80993 +
80994 next->prev = new;
80995 new->next = next;
80996 new->prev = prev;
80997 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80998 }
80999 EXPORT_SYMBOL(__list_add);
81000
81001 -void __list_del_entry(struct list_head *entry)
81002 +static bool __list_del_entry_debug(struct list_head *entry)
81003 {
81004 struct list_head *prev, *next;
81005
81006 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
81007 WARN(next->prev != entry,
81008 "list_del corruption. next->prev should be %p, "
81009 "but was %p\n", entry, next->prev))
81010 + return false;
81011 + return true;
81012 +}
81013 +
81014 +void __list_del_entry(struct list_head *entry)
81015 +{
81016 + if (!__list_del_entry_debug(entry))
81017 return;
81018
81019 - __list_del(prev, next);
81020 + __list_del(entry->prev, entry->next);
81021 }
81022 EXPORT_SYMBOL(__list_del_entry);
81023
81024 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
81025 void __list_add_rcu(struct list_head *new,
81026 struct list_head *prev, struct list_head *next)
81027 {
81028 - WARN(next->prev != prev,
81029 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
81030 - prev, next->prev, next);
81031 - WARN(prev->next != next,
81032 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
81033 - next, prev->next, prev);
81034 + if (!__list_add_debug(new, prev, next))
81035 + return;
81036 +
81037 new->next = next;
81038 new->prev = prev;
81039 rcu_assign_pointer(list_next_rcu(prev), new);
81040 next->prev = new;
81041 }
81042 EXPORT_SYMBOL(__list_add_rcu);
81043 +#endif
81044 +
81045 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
81046 +{
81047 +#ifdef CONFIG_DEBUG_LIST
81048 + if (!__list_add_debug(new, prev, next))
81049 + return;
81050 +#endif
81051 +
81052 + pax_open_kernel();
81053 + next->prev = new;
81054 + new->next = next;
81055 + new->prev = prev;
81056 + prev->next = new;
81057 + pax_close_kernel();
81058 +}
81059 +EXPORT_SYMBOL(__pax_list_add);
81060 +
81061 +void pax_list_del(struct list_head *entry)
81062 +{
81063 +#ifdef CONFIG_DEBUG_LIST
81064 + if (!__list_del_entry_debug(entry))
81065 + return;
81066 +#endif
81067 +
81068 + pax_open_kernel();
81069 + __list_del(entry->prev, entry->next);
81070 + entry->next = LIST_POISON1;
81071 + entry->prev = LIST_POISON2;
81072 + pax_close_kernel();
81073 +}
81074 +EXPORT_SYMBOL(pax_list_del);
81075 +
81076 +void pax_list_del_init(struct list_head *entry)
81077 +{
81078 + pax_open_kernel();
81079 + __list_del(entry->prev, entry->next);
81080 + INIT_LIST_HEAD(entry);
81081 + pax_close_kernel();
81082 +}
81083 +EXPORT_SYMBOL(pax_list_del_init);
81084 +
81085 +void __pax_list_add_rcu(struct list_head *new,
81086 + struct list_head *prev, struct list_head *next)
81087 +{
81088 +#ifdef CONFIG_DEBUG_LIST
81089 + if (!__list_add_debug(new, prev, next))
81090 + return;
81091 +#endif
81092 +
81093 + pax_open_kernel();
81094 + new->next = next;
81095 + new->prev = prev;
81096 + rcu_assign_pointer(list_next_rcu(prev), new);
81097 + next->prev = new;
81098 + pax_close_kernel();
81099 +}
81100 +EXPORT_SYMBOL(__pax_list_add_rcu);
81101 +
81102 +void pax_list_del_rcu(struct list_head *entry)
81103 +{
81104 +#ifdef CONFIG_DEBUG_LIST
81105 + if (!__list_del_entry_debug(entry))
81106 + return;
81107 +#endif
81108 +
81109 + pax_open_kernel();
81110 + __list_del(entry->prev, entry->next);
81111 + entry->next = LIST_POISON1;
81112 + entry->prev = LIST_POISON2;
81113 + pax_close_kernel();
81114 +}
81115 +EXPORT_SYMBOL(pax_list_del_rcu);
81116 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
81117 index e796429..6e38f9f 100644
81118 --- a/lib/radix-tree.c
81119 +++ b/lib/radix-tree.c
81120 @@ -92,7 +92,7 @@ struct radix_tree_preload {
81121 int nr;
81122 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
81123 };
81124 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
81125 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
81126
81127 static inline void *ptr_to_indirect(void *ptr)
81128 {
81129 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
81130 index bb2b201..46abaf9 100644
81131 --- a/lib/strncpy_from_user.c
81132 +++ b/lib/strncpy_from_user.c
81133 @@ -21,7 +21,7 @@
81134 */
81135 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
81136 {
81137 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81138 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81139 long res = 0;
81140
81141 /*
81142 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
81143 index a28df52..3d55877 100644
81144 --- a/lib/strnlen_user.c
81145 +++ b/lib/strnlen_user.c
81146 @@ -26,7 +26,7 @@
81147 */
81148 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
81149 {
81150 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81151 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
81152 long align, res = 0;
81153 unsigned long c;
81154
81155 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
81156 index 196b069..358f342 100644
81157 --- a/lib/swiotlb.c
81158 +++ b/lib/swiotlb.c
81159 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
81160
81161 void
81162 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
81163 - dma_addr_t dev_addr)
81164 + dma_addr_t dev_addr, struct dma_attrs *attrs)
81165 {
81166 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
81167
81168 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
81169 index fab33a9..3b5fe68 100644
81170 --- a/lib/vsprintf.c
81171 +++ b/lib/vsprintf.c
81172 @@ -16,6 +16,9 @@
81173 * - scnprintf and vscnprintf
81174 */
81175
81176 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81177 +#define __INCLUDED_BY_HIDESYM 1
81178 +#endif
81179 #include <stdarg.h>
81180 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
81181 #include <linux/types.h>
81182 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
81183 char sym[KSYM_SYMBOL_LEN];
81184 if (ext == 'B')
81185 sprint_backtrace(sym, value);
81186 - else if (ext != 'f' && ext != 's')
81187 + else if (ext != 'f' && ext != 's' && ext != 'a')
81188 sprint_symbol(sym, value);
81189 else
81190 sprint_symbol_no_offset(sym, value);
81191 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
81192 return number(buf, end, *(const netdev_features_t *)addr, spec);
81193 }
81194
81195 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81196 +int kptr_restrict __read_mostly = 2;
81197 +#else
81198 int kptr_restrict __read_mostly;
81199 +#endif
81200
81201 /*
81202 * Show a '%p' thing. A kernel extension is that the '%p' is followed
81203 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
81204 * - 'S' For symbolic direct pointers with offset
81205 * - 's' For symbolic direct pointers without offset
81206 * - 'B' For backtraced symbolic direct pointers with offset
81207 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
81208 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
81209 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
81210 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
81211 * - 'M' For a 6-byte MAC address, it prints the address in the
81212 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81213
81214 if (!ptr && *fmt != 'K') {
81215 /*
81216 - * Print (null) with the same width as a pointer so it makes
81217 + * Print (nil) with the same width as a pointer so it makes
81218 * tabular output look nice.
81219 */
81220 if (spec.field_width == -1)
81221 spec.field_width = default_width;
81222 - return string(buf, end, "(null)", spec);
81223 + return string(buf, end, "(nil)", spec);
81224 }
81225
81226 switch (*fmt) {
81227 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81228 /* Fallthrough */
81229 case 'S':
81230 case 's':
81231 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81232 + break;
81233 +#else
81234 + return symbol_string(buf, end, ptr, spec, *fmt);
81235 +#endif
81236 + case 'A':
81237 + case 'a':
81238 case 'B':
81239 return symbol_string(buf, end, ptr, spec, *fmt);
81240 case 'R':
81241 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81242 va_end(va);
81243 return buf;
81244 }
81245 + case 'P':
81246 + break;
81247 case 'K':
81248 /*
81249 * %pK cannot be used in IRQ context because its test
81250 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
81251 }
81252 break;
81253 }
81254 +
81255 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81256 + /* 'P' = approved pointers to copy to userland,
81257 + as in the /proc/kallsyms case, as we make it display nothing
81258 + for non-root users, and the real contents for root users
81259 + Also ignore 'K' pointers, since we force their NULLing for non-root users
81260 + above
81261 + */
81262 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
81263 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
81264 + dump_stack();
81265 + ptr = NULL;
81266 + }
81267 +#endif
81268 +
81269 spec.flags |= SMALL;
81270 if (spec.field_width == -1) {
81271 spec.field_width = default_width;
81272 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
81273 typeof(type) value; \
81274 if (sizeof(type) == 8) { \
81275 args = PTR_ALIGN(args, sizeof(u32)); \
81276 - *(u32 *)&value = *(u32 *)args; \
81277 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
81278 + *(u32 *)&value = *(const u32 *)args; \
81279 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
81280 } else { \
81281 args = PTR_ALIGN(args, sizeof(type)); \
81282 - value = *(typeof(type) *)args; \
81283 + value = *(const typeof(type) *)args; \
81284 } \
81285 args += sizeof(type); \
81286 value; \
81287 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
81288 case FORMAT_TYPE_STR: {
81289 const char *str_arg = args;
81290 args += strlen(str_arg) + 1;
81291 - str = string(str, end, (char *)str_arg, spec);
81292 + str = string(str, end, str_arg, spec);
81293 break;
81294 }
81295
81296 diff --git a/localversion-grsec b/localversion-grsec
81297 new file mode 100644
81298 index 0000000..7cd6065
81299 --- /dev/null
81300 +++ b/localversion-grsec
81301 @@ -0,0 +1 @@
81302 +-grsec
81303 diff --git a/mm/Kconfig b/mm/Kconfig
81304 index 278e3ab..87c384d 100644
81305 --- a/mm/Kconfig
81306 +++ b/mm/Kconfig
81307 @@ -286,10 +286,10 @@ config KSM
81308 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
81309
81310 config DEFAULT_MMAP_MIN_ADDR
81311 - int "Low address space to protect from user allocation"
81312 + int "Low address space to protect from user allocation"
81313 depends on MMU
81314 - default 4096
81315 - help
81316 + default 65536
81317 + help
81318 This is the portion of low virtual memory which should be protected
81319 from userspace allocation. Keeping a user from writing to low pages
81320 can help reduce the impact of kernel NULL pointer bugs.
81321 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
81322
81323 config HWPOISON_INJECT
81324 tristate "HWPoison pages injector"
81325 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
81326 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
81327 select PROC_PAGE_MONITOR
81328
81329 config NOMMU_INITIAL_TRIM_EXCESS
81330 diff --git a/mm/filemap.c b/mm/filemap.c
81331 index 83efee7..3f99381 100644
81332 --- a/mm/filemap.c
81333 +++ b/mm/filemap.c
81334 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
81335 struct address_space *mapping = file->f_mapping;
81336
81337 if (!mapping->a_ops->readpage)
81338 - return -ENOEXEC;
81339 + return -ENODEV;
81340 file_accessed(file);
81341 vma->vm_ops = &generic_file_vm_ops;
81342 return 0;
81343 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
81344 *pos = i_size_read(inode);
81345
81346 if (limit != RLIM_INFINITY) {
81347 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
81348 if (*pos >= limit) {
81349 send_sig(SIGXFSZ, current, 0);
81350 return -EFBIG;
81351 diff --git a/mm/fremap.c b/mm/fremap.c
81352 index a0aaf0e..20325c3 100644
81353 --- a/mm/fremap.c
81354 +++ b/mm/fremap.c
81355 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
81356 retry:
81357 vma = find_vma(mm, start);
81358
81359 +#ifdef CONFIG_PAX_SEGMEXEC
81360 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
81361 + goto out;
81362 +#endif
81363 +
81364 /*
81365 * Make sure the vma is shared, that it supports prefaulting,
81366 * and that the remapped range is valid and fully within
81367 diff --git a/mm/highmem.c b/mm/highmem.c
81368 index b32b70c..e512eb0 100644
81369 --- a/mm/highmem.c
81370 +++ b/mm/highmem.c
81371 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
81372 * So no dangers, even with speculative execution.
81373 */
81374 page = pte_page(pkmap_page_table[i]);
81375 + pax_open_kernel();
81376 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
81377 -
81378 + pax_close_kernel();
81379 set_page_address(page, NULL);
81380 need_flush = 1;
81381 }
81382 @@ -198,9 +199,11 @@ start:
81383 }
81384 }
81385 vaddr = PKMAP_ADDR(last_pkmap_nr);
81386 +
81387 + pax_open_kernel();
81388 set_pte_at(&init_mm, vaddr,
81389 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
81390 -
81391 + pax_close_kernel();
81392 pkmap_count[last_pkmap_nr] = 1;
81393 set_page_address(page, (void *)vaddr);
81394
81395 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
81396 index 88eb939..0bd9e7d 100644
81397 --- a/mm/hugetlb.c
81398 +++ b/mm/hugetlb.c
81399 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
81400 struct hstate *h = &default_hstate;
81401 unsigned long tmp;
81402 int ret;
81403 + ctl_table_no_const hugetlb_table;
81404
81405 tmp = h->max_huge_pages;
81406
81407 if (write && h->order >= MAX_ORDER)
81408 return -EINVAL;
81409
81410 - table->data = &tmp;
81411 - table->maxlen = sizeof(unsigned long);
81412 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
81413 + hugetlb_table = *table;
81414 + hugetlb_table.data = &tmp;
81415 + hugetlb_table.maxlen = sizeof(unsigned long);
81416 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
81417 if (ret)
81418 goto out;
81419
81420 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
81421 struct hstate *h = &default_hstate;
81422 unsigned long tmp;
81423 int ret;
81424 + ctl_table_no_const hugetlb_table;
81425
81426 tmp = h->nr_overcommit_huge_pages;
81427
81428 if (write && h->order >= MAX_ORDER)
81429 return -EINVAL;
81430
81431 - table->data = &tmp;
81432 - table->maxlen = sizeof(unsigned long);
81433 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
81434 + hugetlb_table = *table;
81435 + hugetlb_table.data = &tmp;
81436 + hugetlb_table.maxlen = sizeof(unsigned long);
81437 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
81438 if (ret)
81439 goto out;
81440
81441 @@ -2515,6 +2519,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
81442 return 1;
81443 }
81444
81445 +#ifdef CONFIG_PAX_SEGMEXEC
81446 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
81447 +{
81448 + struct mm_struct *mm = vma->vm_mm;
81449 + struct vm_area_struct *vma_m;
81450 + unsigned long address_m;
81451 + pte_t *ptep_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 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
81460 + get_page(page_m);
81461 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
81462 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
81463 +}
81464 +#endif
81465 +
81466 /*
81467 * Hugetlb_cow() should be called with page lock of the original hugepage held.
81468 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
81469 @@ -2633,6 +2658,11 @@ retry_avoidcopy:
81470 make_huge_pte(vma, new_page, 1));
81471 page_remove_rmap(old_page);
81472 hugepage_add_new_anon_rmap(new_page, vma, address);
81473 +
81474 +#ifdef CONFIG_PAX_SEGMEXEC
81475 + pax_mirror_huge_pte(vma, address, new_page);
81476 +#endif
81477 +
81478 /* Make the old page be freed below */
81479 new_page = old_page;
81480 }
81481 @@ -2792,6 +2822,10 @@ retry:
81482 && (vma->vm_flags & VM_SHARED)));
81483 set_huge_pte_at(mm, address, ptep, new_pte);
81484
81485 +#ifdef CONFIG_PAX_SEGMEXEC
81486 + pax_mirror_huge_pte(vma, address, page);
81487 +#endif
81488 +
81489 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
81490 /* Optimization, do the COW without a second fault */
81491 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
81492 @@ -2821,6 +2855,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81493 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
81494 struct hstate *h = hstate_vma(vma);
81495
81496 +#ifdef CONFIG_PAX_SEGMEXEC
81497 + struct vm_area_struct *vma_m;
81498 +#endif
81499 +
81500 address &= huge_page_mask(h);
81501
81502 ptep = huge_pte_offset(mm, address);
81503 @@ -2834,6 +2872,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81504 VM_FAULT_SET_HINDEX(hstate_index(h));
81505 }
81506
81507 +#ifdef CONFIG_PAX_SEGMEXEC
81508 + vma_m = pax_find_mirror_vma(vma);
81509 + if (vma_m) {
81510 + unsigned long address_m;
81511 +
81512 + if (vma->vm_start > vma_m->vm_start) {
81513 + address_m = address;
81514 + address -= SEGMEXEC_TASK_SIZE;
81515 + vma = vma_m;
81516 + h = hstate_vma(vma);
81517 + } else
81518 + address_m = address + SEGMEXEC_TASK_SIZE;
81519 +
81520 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
81521 + return VM_FAULT_OOM;
81522 + address_m &= HPAGE_MASK;
81523 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
81524 + }
81525 +#endif
81526 +
81527 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
81528 if (!ptep)
81529 return VM_FAULT_OOM;
81530 diff --git a/mm/internal.h b/mm/internal.h
81531 index 9ba2110..eaf0674 100644
81532 --- a/mm/internal.h
81533 +++ b/mm/internal.h
81534 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
81535 * in mm/page_alloc.c
81536 */
81537 extern void __free_pages_bootmem(struct page *page, unsigned int order);
81538 +extern void free_compound_page(struct page *page);
81539 extern void prep_compound_page(struct page *page, unsigned long order);
81540 #ifdef CONFIG_MEMORY_FAILURE
81541 extern bool is_free_buddy_page(struct page *page);
81542 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
81543 index 752a705..6c3102e 100644
81544 --- a/mm/kmemleak.c
81545 +++ b/mm/kmemleak.c
81546 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
81547
81548 for (i = 0; i < object->trace_len; i++) {
81549 void *ptr = (void *)object->trace[i];
81550 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
81551 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
81552 }
81553 }
81554
81555 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
81556 return -ENOMEM;
81557 }
81558
81559 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
81560 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
81561 &kmemleak_fops);
81562 if (!dentry)
81563 pr_warning("Failed to create the debugfs kmemleak file\n");
81564 diff --git a/mm/maccess.c b/mm/maccess.c
81565 index d53adf9..03a24bf 100644
81566 --- a/mm/maccess.c
81567 +++ b/mm/maccess.c
81568 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
81569 set_fs(KERNEL_DS);
81570 pagefault_disable();
81571 ret = __copy_from_user_inatomic(dst,
81572 - (__force const void __user *)src, size);
81573 + (const void __force_user *)src, size);
81574 pagefault_enable();
81575 set_fs(old_fs);
81576
81577 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
81578
81579 set_fs(KERNEL_DS);
81580 pagefault_disable();
81581 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81582 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81583 pagefault_enable();
81584 set_fs(old_fs);
81585
81586 diff --git a/mm/madvise.c b/mm/madvise.c
81587 index 03dfa5c..b032917 100644
81588 --- a/mm/madvise.c
81589 +++ b/mm/madvise.c
81590 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81591 pgoff_t pgoff;
81592 unsigned long new_flags = vma->vm_flags;
81593
81594 +#ifdef CONFIG_PAX_SEGMEXEC
81595 + struct vm_area_struct *vma_m;
81596 +#endif
81597 +
81598 switch (behavior) {
81599 case MADV_NORMAL:
81600 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81601 @@ -123,6 +127,13 @@ success:
81602 /*
81603 * vm_flags is protected by the mmap_sem held in write mode.
81604 */
81605 +
81606 +#ifdef CONFIG_PAX_SEGMEXEC
81607 + vma_m = pax_find_mirror_vma(vma);
81608 + if (vma_m)
81609 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81610 +#endif
81611 +
81612 vma->vm_flags = new_flags;
81613
81614 out:
81615 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81616 struct vm_area_struct ** prev,
81617 unsigned long start, unsigned long end)
81618 {
81619 +
81620 +#ifdef CONFIG_PAX_SEGMEXEC
81621 + struct vm_area_struct *vma_m;
81622 +#endif
81623 +
81624 *prev = vma;
81625 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81626 return -EINVAL;
81627 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81628 zap_page_range(vma, start, end - start, &details);
81629 } else
81630 zap_page_range(vma, start, end - start, NULL);
81631 +
81632 +#ifdef CONFIG_PAX_SEGMEXEC
81633 + vma_m = pax_find_mirror_vma(vma);
81634 + if (vma_m) {
81635 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81636 + struct zap_details details = {
81637 + .nonlinear_vma = vma_m,
81638 + .last_index = ULONG_MAX,
81639 + };
81640 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81641 + } else
81642 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81643 + }
81644 +#endif
81645 +
81646 return 0;
81647 }
81648
81649 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81650 if (end < start)
81651 goto out;
81652
81653 +#ifdef CONFIG_PAX_SEGMEXEC
81654 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81655 + if (end > SEGMEXEC_TASK_SIZE)
81656 + goto out;
81657 + } else
81658 +#endif
81659 +
81660 + if (end > TASK_SIZE)
81661 + goto out;
81662 +
81663 error = 0;
81664 if (end == start)
81665 goto out;
81666 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81667 index c6e4dd3..1f41988 100644
81668 --- a/mm/memory-failure.c
81669 +++ b/mm/memory-failure.c
81670 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81671
81672 int sysctl_memory_failure_recovery __read_mostly = 1;
81673
81674 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81675 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81676
81677 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81678
81679 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81680 pfn, t->comm, t->pid);
81681 si.si_signo = SIGBUS;
81682 si.si_errno = 0;
81683 - si.si_addr = (void *)addr;
81684 + si.si_addr = (void __user *)addr;
81685 #ifdef __ARCH_SI_TRAPNO
81686 si.si_trapno = trapno;
81687 #endif
81688 @@ -760,7 +760,7 @@ static struct page_state {
81689 unsigned long res;
81690 char *msg;
81691 int (*action)(struct page *p, unsigned long pfn);
81692 -} error_states[] = {
81693 +} __do_const error_states[] = {
81694 { reserved, reserved, "reserved kernel", me_kernel },
81695 /*
81696 * free pages are specially detected outside this table:
81697 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81698 }
81699
81700 nr_pages = 1 << compound_trans_order(hpage);
81701 - atomic_long_add(nr_pages, &mce_bad_pages);
81702 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
81703
81704 /*
81705 * We need/can do nothing about count=0 pages.
81706 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81707 if (!PageHWPoison(hpage)
81708 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81709 || (p != hpage && TestSetPageHWPoison(hpage))) {
81710 - atomic_long_sub(nr_pages, &mce_bad_pages);
81711 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81712 return 0;
81713 }
81714 set_page_hwpoison_huge_page(hpage);
81715 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81716 }
81717 if (hwpoison_filter(p)) {
81718 if (TestClearPageHWPoison(p))
81719 - atomic_long_sub(nr_pages, &mce_bad_pages);
81720 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81721 unlock_page(hpage);
81722 put_page(hpage);
81723 return 0;
81724 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
81725 return 0;
81726 }
81727 if (TestClearPageHWPoison(p))
81728 - atomic_long_sub(nr_pages, &mce_bad_pages);
81729 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81730 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81731 return 0;
81732 }
81733 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
81734 */
81735 if (TestClearPageHWPoison(page)) {
81736 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81737 - atomic_long_sub(nr_pages, &mce_bad_pages);
81738 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81739 freeit = 1;
81740 if (PageHuge(page))
81741 clear_page_hwpoison_huge_page(page);
81742 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81743 }
81744 done:
81745 if (!PageHWPoison(hpage))
81746 - atomic_long_add(1 << compound_trans_order(hpage),
81747 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81748 &mce_bad_pages);
81749 set_page_hwpoison_huge_page(hpage);
81750 dequeue_hwpoisoned_huge_page(hpage);
81751 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
81752 return ret;
81753
81754 done:
81755 - atomic_long_add(1, &mce_bad_pages);
81756 + atomic_long_add_unchecked(1, &mce_bad_pages);
81757 SetPageHWPoison(page);
81758 /* keep elevated page count for bad page */
81759 return ret;
81760 diff --git a/mm/memory.c b/mm/memory.c
81761 index 32a495a..8042dce 100644
81762 --- a/mm/memory.c
81763 +++ b/mm/memory.c
81764 @@ -434,6 +434,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81765 free_pte_range(tlb, pmd, addr);
81766 } while (pmd++, addr = next, addr != end);
81767
81768 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81769 start &= PUD_MASK;
81770 if (start < floor)
81771 return;
81772 @@ -448,6 +449,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81773 pmd = pmd_offset(pud, start);
81774 pud_clear(pud);
81775 pmd_free_tlb(tlb, pmd, start);
81776 +#endif
81777 +
81778 }
81779
81780 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81781 @@ -467,6 +470,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81782 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81783 } while (pud++, addr = next, addr != end);
81784
81785 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81786 start &= PGDIR_MASK;
81787 if (start < floor)
81788 return;
81789 @@ -481,6 +485,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81790 pud = pud_offset(pgd, start);
81791 pgd_clear(pgd);
81792 pud_free_tlb(tlb, pud, start);
81793 +#endif
81794 +
81795 }
81796
81797 /*
81798 @@ -1619,12 +1625,6 @@ no_page_table:
81799 return page;
81800 }
81801
81802 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81803 -{
81804 - return stack_guard_page_start(vma, addr) ||
81805 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81806 -}
81807 -
81808 /**
81809 * __get_user_pages() - pin user pages in memory
81810 * @tsk: task_struct of target task
81811 @@ -1710,10 +1710,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81812
81813 i = 0;
81814
81815 - do {
81816 + while (nr_pages) {
81817 struct vm_area_struct *vma;
81818
81819 - vma = find_extend_vma(mm, start);
81820 + vma = find_vma(mm, start);
81821 if (!vma && in_gate_area(mm, start)) {
81822 unsigned long pg = start & PAGE_MASK;
81823 pgd_t *pgd;
81824 @@ -1761,7 +1761,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81825 goto next_page;
81826 }
81827
81828 - if (!vma ||
81829 + if (!vma || start < vma->vm_start ||
81830 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81831 !(vm_flags & vma->vm_flags))
81832 return i ? : -EFAULT;
81833 @@ -1788,11 +1788,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81834 int ret;
81835 unsigned int fault_flags = 0;
81836
81837 - /* For mlock, just skip the stack guard page. */
81838 - if (foll_flags & FOLL_MLOCK) {
81839 - if (stack_guard_page(vma, start))
81840 - goto next_page;
81841 - }
81842 if (foll_flags & FOLL_WRITE)
81843 fault_flags |= FAULT_FLAG_WRITE;
81844 if (nonblocking)
81845 @@ -1866,7 +1861,7 @@ next_page:
81846 start += PAGE_SIZE;
81847 nr_pages--;
81848 } while (nr_pages && start < vma->vm_end);
81849 - } while (nr_pages);
81850 + }
81851 return i;
81852 }
81853 EXPORT_SYMBOL(__get_user_pages);
81854 @@ -2073,6 +2068,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81855 page_add_file_rmap(page);
81856 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81857
81858 +#ifdef CONFIG_PAX_SEGMEXEC
81859 + pax_mirror_file_pte(vma, addr, page, ptl);
81860 +#endif
81861 +
81862 retval = 0;
81863 pte_unmap_unlock(pte, ptl);
81864 return retval;
81865 @@ -2117,9 +2116,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81866 if (!page_count(page))
81867 return -EINVAL;
81868 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81869 +
81870 +#ifdef CONFIG_PAX_SEGMEXEC
81871 + struct vm_area_struct *vma_m;
81872 +#endif
81873 +
81874 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81875 BUG_ON(vma->vm_flags & VM_PFNMAP);
81876 vma->vm_flags |= VM_MIXEDMAP;
81877 +
81878 +#ifdef CONFIG_PAX_SEGMEXEC
81879 + vma_m = pax_find_mirror_vma(vma);
81880 + if (vma_m)
81881 + vma_m->vm_flags |= VM_MIXEDMAP;
81882 +#endif
81883 +
81884 }
81885 return insert_page(vma, addr, page, vma->vm_page_prot);
81886 }
81887 @@ -2202,6 +2213,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81888 unsigned long pfn)
81889 {
81890 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81891 + BUG_ON(vma->vm_mirror);
81892
81893 if (addr < vma->vm_start || addr >= vma->vm_end)
81894 return -EFAULT;
81895 @@ -2449,7 +2461,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81896
81897 BUG_ON(pud_huge(*pud));
81898
81899 - pmd = pmd_alloc(mm, pud, addr);
81900 + pmd = (mm == &init_mm) ?
81901 + pmd_alloc_kernel(mm, pud, addr) :
81902 + pmd_alloc(mm, pud, addr);
81903 if (!pmd)
81904 return -ENOMEM;
81905 do {
81906 @@ -2469,7 +2483,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81907 unsigned long next;
81908 int err;
81909
81910 - pud = pud_alloc(mm, pgd, addr);
81911 + pud = (mm == &init_mm) ?
81912 + pud_alloc_kernel(mm, pgd, addr) :
81913 + pud_alloc(mm, pgd, addr);
81914 if (!pud)
81915 return -ENOMEM;
81916 do {
81917 @@ -2557,6 +2573,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81918 copy_user_highpage(dst, src, va, vma);
81919 }
81920
81921 +#ifdef CONFIG_PAX_SEGMEXEC
81922 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81923 +{
81924 + struct mm_struct *mm = vma->vm_mm;
81925 + spinlock_t *ptl;
81926 + pte_t *pte, entry;
81927 +
81928 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81929 + entry = *pte;
81930 + if (!pte_present(entry)) {
81931 + if (!pte_none(entry)) {
81932 + BUG_ON(pte_file(entry));
81933 + free_swap_and_cache(pte_to_swp_entry(entry));
81934 + pte_clear_not_present_full(mm, address, pte, 0);
81935 + }
81936 + } else {
81937 + struct page *page;
81938 +
81939 + flush_cache_page(vma, address, pte_pfn(entry));
81940 + entry = ptep_clear_flush(vma, address, pte);
81941 + BUG_ON(pte_dirty(entry));
81942 + page = vm_normal_page(vma, address, entry);
81943 + if (page) {
81944 + update_hiwater_rss(mm);
81945 + if (PageAnon(page))
81946 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81947 + else
81948 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81949 + page_remove_rmap(page);
81950 + page_cache_release(page);
81951 + }
81952 + }
81953 + pte_unmap_unlock(pte, ptl);
81954 +}
81955 +
81956 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81957 + *
81958 + * the ptl of the lower mapped page is held on entry and is not released on exit
81959 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81960 + */
81961 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81962 +{
81963 + struct mm_struct *mm = vma->vm_mm;
81964 + unsigned long address_m;
81965 + spinlock_t *ptl_m;
81966 + struct vm_area_struct *vma_m;
81967 + pmd_t *pmd_m;
81968 + pte_t *pte_m, entry_m;
81969 +
81970 + BUG_ON(!page_m || !PageAnon(page_m));
81971 +
81972 + vma_m = pax_find_mirror_vma(vma);
81973 + if (!vma_m)
81974 + return;
81975 +
81976 + BUG_ON(!PageLocked(page_m));
81977 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81978 + address_m = address + SEGMEXEC_TASK_SIZE;
81979 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81980 + pte_m = pte_offset_map(pmd_m, address_m);
81981 + ptl_m = pte_lockptr(mm, pmd_m);
81982 + if (ptl != ptl_m) {
81983 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81984 + if (!pte_none(*pte_m))
81985 + goto out;
81986 + }
81987 +
81988 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81989 + page_cache_get(page_m);
81990 + page_add_anon_rmap(page_m, vma_m, address_m);
81991 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81992 + set_pte_at(mm, address_m, pte_m, entry_m);
81993 + update_mmu_cache(vma_m, address_m, entry_m);
81994 +out:
81995 + if (ptl != ptl_m)
81996 + spin_unlock(ptl_m);
81997 + pte_unmap(pte_m);
81998 + unlock_page(page_m);
81999 +}
82000 +
82001 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
82002 +{
82003 + struct mm_struct *mm = vma->vm_mm;
82004 + unsigned long address_m;
82005 + spinlock_t *ptl_m;
82006 + struct vm_area_struct *vma_m;
82007 + pmd_t *pmd_m;
82008 + pte_t *pte_m, entry_m;
82009 +
82010 + BUG_ON(!page_m || PageAnon(page_m));
82011 +
82012 + vma_m = pax_find_mirror_vma(vma);
82013 + if (!vma_m)
82014 + return;
82015 +
82016 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
82017 + address_m = address + SEGMEXEC_TASK_SIZE;
82018 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
82019 + pte_m = pte_offset_map(pmd_m, address_m);
82020 + ptl_m = pte_lockptr(mm, pmd_m);
82021 + if (ptl != ptl_m) {
82022 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
82023 + if (!pte_none(*pte_m))
82024 + goto out;
82025 + }
82026 +
82027 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
82028 + page_cache_get(page_m);
82029 + page_add_file_rmap(page_m);
82030 + inc_mm_counter_fast(mm, MM_FILEPAGES);
82031 + set_pte_at(mm, address_m, pte_m, entry_m);
82032 + update_mmu_cache(vma_m, address_m, entry_m);
82033 +out:
82034 + if (ptl != ptl_m)
82035 + spin_unlock(ptl_m);
82036 + pte_unmap(pte_m);
82037 +}
82038 +
82039 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
82040 +{
82041 + struct mm_struct *mm = vma->vm_mm;
82042 + unsigned long address_m;
82043 + spinlock_t *ptl_m;
82044 + struct vm_area_struct *vma_m;
82045 + pmd_t *pmd_m;
82046 + pte_t *pte_m, entry_m;
82047 +
82048 + vma_m = pax_find_mirror_vma(vma);
82049 + if (!vma_m)
82050 + return;
82051 +
82052 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
82053 + address_m = address + SEGMEXEC_TASK_SIZE;
82054 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
82055 + pte_m = pte_offset_map(pmd_m, address_m);
82056 + ptl_m = pte_lockptr(mm, pmd_m);
82057 + if (ptl != ptl_m) {
82058 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
82059 + if (!pte_none(*pte_m))
82060 + goto out;
82061 + }
82062 +
82063 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
82064 + set_pte_at(mm, address_m, pte_m, entry_m);
82065 +out:
82066 + if (ptl != ptl_m)
82067 + spin_unlock(ptl_m);
82068 + pte_unmap(pte_m);
82069 +}
82070 +
82071 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
82072 +{
82073 + struct page *page_m;
82074 + pte_t entry;
82075 +
82076 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
82077 + goto out;
82078 +
82079 + entry = *pte;
82080 + page_m = vm_normal_page(vma, address, entry);
82081 + if (!page_m)
82082 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
82083 + else if (PageAnon(page_m)) {
82084 + if (pax_find_mirror_vma(vma)) {
82085 + pte_unmap_unlock(pte, ptl);
82086 + lock_page(page_m);
82087 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
82088 + if (pte_same(entry, *pte))
82089 + pax_mirror_anon_pte(vma, address, page_m, ptl);
82090 + else
82091 + unlock_page(page_m);
82092 + }
82093 + } else
82094 + pax_mirror_file_pte(vma, address, page_m, ptl);
82095 +
82096 +out:
82097 + pte_unmap_unlock(pte, ptl);
82098 +}
82099 +#endif
82100 +
82101 /*
82102 * This routine handles present pages, when users try to write
82103 * to a shared page. It is done by copying the page to a new address
82104 @@ -2773,6 +2969,12 @@ gotten:
82105 */
82106 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
82107 if (likely(pte_same(*page_table, orig_pte))) {
82108 +
82109 +#ifdef CONFIG_PAX_SEGMEXEC
82110 + if (pax_find_mirror_vma(vma))
82111 + BUG_ON(!trylock_page(new_page));
82112 +#endif
82113 +
82114 if (old_page) {
82115 if (!PageAnon(old_page)) {
82116 dec_mm_counter_fast(mm, MM_FILEPAGES);
82117 @@ -2824,6 +3026,10 @@ gotten:
82118 page_remove_rmap(old_page);
82119 }
82120
82121 +#ifdef CONFIG_PAX_SEGMEXEC
82122 + pax_mirror_anon_pte(vma, address, new_page, ptl);
82123 +#endif
82124 +
82125 /* Free the old page.. */
82126 new_page = old_page;
82127 ret |= VM_FAULT_WRITE;
82128 @@ -3099,6 +3305,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
82129 swap_free(entry);
82130 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
82131 try_to_free_swap(page);
82132 +
82133 +#ifdef CONFIG_PAX_SEGMEXEC
82134 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
82135 +#endif
82136 +
82137 unlock_page(page);
82138 if (swapcache) {
82139 /*
82140 @@ -3122,6 +3333,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
82141
82142 /* No need to invalidate - it was non-present before */
82143 update_mmu_cache(vma, address, page_table);
82144 +
82145 +#ifdef CONFIG_PAX_SEGMEXEC
82146 + pax_mirror_anon_pte(vma, address, page, ptl);
82147 +#endif
82148 +
82149 unlock:
82150 pte_unmap_unlock(page_table, ptl);
82151 out:
82152 @@ -3141,40 +3357,6 @@ out_release:
82153 }
82154
82155 /*
82156 - * This is like a special single-page "expand_{down|up}wards()",
82157 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
82158 - * doesn't hit another vma.
82159 - */
82160 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
82161 -{
82162 - address &= PAGE_MASK;
82163 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
82164 - struct vm_area_struct *prev = vma->vm_prev;
82165 -
82166 - /*
82167 - * Is there a mapping abutting this one below?
82168 - *
82169 - * That's only ok if it's the same stack mapping
82170 - * that has gotten split..
82171 - */
82172 - if (prev && prev->vm_end == address)
82173 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
82174 -
82175 - expand_downwards(vma, address - PAGE_SIZE);
82176 - }
82177 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
82178 - struct vm_area_struct *next = vma->vm_next;
82179 -
82180 - /* As VM_GROWSDOWN but s/below/above/ */
82181 - if (next && next->vm_start == address + PAGE_SIZE)
82182 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
82183 -
82184 - expand_upwards(vma, address + PAGE_SIZE);
82185 - }
82186 - return 0;
82187 -}
82188 -
82189 -/*
82190 * We enter with non-exclusive mmap_sem (to exclude vma changes,
82191 * but allow concurrent faults), and pte mapped but not yet locked.
82192 * We return with mmap_sem still held, but pte unmapped and unlocked.
82193 @@ -3183,27 +3365,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
82194 unsigned long address, pte_t *page_table, pmd_t *pmd,
82195 unsigned int flags)
82196 {
82197 - struct page *page;
82198 + struct page *page = NULL;
82199 spinlock_t *ptl;
82200 pte_t entry;
82201
82202 - pte_unmap(page_table);
82203 -
82204 - /* Check if we need to add a guard page to the stack */
82205 - if (check_stack_guard_page(vma, address) < 0)
82206 - return VM_FAULT_SIGBUS;
82207 -
82208 - /* Use the zero-page for reads */
82209 if (!(flags & FAULT_FLAG_WRITE)) {
82210 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
82211 vma->vm_page_prot));
82212 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
82213 + ptl = pte_lockptr(mm, pmd);
82214 + spin_lock(ptl);
82215 if (!pte_none(*page_table))
82216 goto unlock;
82217 goto setpte;
82218 }
82219
82220 /* Allocate our own private page. */
82221 + pte_unmap(page_table);
82222 +
82223 if (unlikely(anon_vma_prepare(vma)))
82224 goto oom;
82225 page = alloc_zeroed_user_highpage_movable(vma, address);
82226 @@ -3222,6 +3400,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
82227 if (!pte_none(*page_table))
82228 goto release;
82229
82230 +#ifdef CONFIG_PAX_SEGMEXEC
82231 + if (pax_find_mirror_vma(vma))
82232 + BUG_ON(!trylock_page(page));
82233 +#endif
82234 +
82235 inc_mm_counter_fast(mm, MM_ANONPAGES);
82236 page_add_new_anon_rmap(page, vma, address);
82237 setpte:
82238 @@ -3229,6 +3412,12 @@ setpte:
82239
82240 /* No need to invalidate - it was non-present before */
82241 update_mmu_cache(vma, address, page_table);
82242 +
82243 +#ifdef CONFIG_PAX_SEGMEXEC
82244 + if (page)
82245 + pax_mirror_anon_pte(vma, address, page, ptl);
82246 +#endif
82247 +
82248 unlock:
82249 pte_unmap_unlock(page_table, ptl);
82250 return 0;
82251 @@ -3372,6 +3561,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82252 */
82253 /* Only go through if we didn't race with anybody else... */
82254 if (likely(pte_same(*page_table, orig_pte))) {
82255 +
82256 +#ifdef CONFIG_PAX_SEGMEXEC
82257 + if (anon && pax_find_mirror_vma(vma))
82258 + BUG_ON(!trylock_page(page));
82259 +#endif
82260 +
82261 flush_icache_page(vma, page);
82262 entry = mk_pte(page, vma->vm_page_prot);
82263 if (flags & FAULT_FLAG_WRITE)
82264 @@ -3391,6 +3586,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82265
82266 /* no need to invalidate: a not-present page won't be cached */
82267 update_mmu_cache(vma, address, page_table);
82268 +
82269 +#ifdef CONFIG_PAX_SEGMEXEC
82270 + if (anon)
82271 + pax_mirror_anon_pte(vma, address, page, ptl);
82272 + else
82273 + pax_mirror_file_pte(vma, address, page, ptl);
82274 +#endif
82275 +
82276 } else {
82277 if (cow_page)
82278 mem_cgroup_uncharge_page(cow_page);
82279 @@ -3712,6 +3915,12 @@ int handle_pte_fault(struct mm_struct *mm,
82280 if (flags & FAULT_FLAG_WRITE)
82281 flush_tlb_fix_spurious_fault(vma, address);
82282 }
82283 +
82284 +#ifdef CONFIG_PAX_SEGMEXEC
82285 + pax_mirror_pte(vma, address, pte, pmd, ptl);
82286 + return 0;
82287 +#endif
82288 +
82289 unlock:
82290 pte_unmap_unlock(pte, ptl);
82291 return 0;
82292 @@ -3728,6 +3937,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82293 pmd_t *pmd;
82294 pte_t *pte;
82295
82296 +#ifdef CONFIG_PAX_SEGMEXEC
82297 + struct vm_area_struct *vma_m;
82298 +#endif
82299 +
82300 __set_current_state(TASK_RUNNING);
82301
82302 count_vm_event(PGFAULT);
82303 @@ -3739,6 +3952,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82304 if (unlikely(is_vm_hugetlb_page(vma)))
82305 return hugetlb_fault(mm, vma, address, flags);
82306
82307 +#ifdef CONFIG_PAX_SEGMEXEC
82308 + vma_m = pax_find_mirror_vma(vma);
82309 + if (vma_m) {
82310 + unsigned long address_m;
82311 + pgd_t *pgd_m;
82312 + pud_t *pud_m;
82313 + pmd_t *pmd_m;
82314 +
82315 + if (vma->vm_start > vma_m->vm_start) {
82316 + address_m = address;
82317 + address -= SEGMEXEC_TASK_SIZE;
82318 + vma = vma_m;
82319 + } else
82320 + address_m = address + SEGMEXEC_TASK_SIZE;
82321 +
82322 + pgd_m = pgd_offset(mm, address_m);
82323 + pud_m = pud_alloc(mm, pgd_m, address_m);
82324 + if (!pud_m)
82325 + return VM_FAULT_OOM;
82326 + pmd_m = pmd_alloc(mm, pud_m, address_m);
82327 + if (!pmd_m)
82328 + return VM_FAULT_OOM;
82329 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
82330 + return VM_FAULT_OOM;
82331 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
82332 + }
82333 +#endif
82334 +
82335 retry:
82336 pgd = pgd_offset(mm, address);
82337 pud = pud_alloc(mm, pgd, address);
82338 @@ -3837,6 +4078,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
82339 spin_unlock(&mm->page_table_lock);
82340 return 0;
82341 }
82342 +
82343 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
82344 +{
82345 + pud_t *new = pud_alloc_one(mm, address);
82346 + if (!new)
82347 + return -ENOMEM;
82348 +
82349 + smp_wmb(); /* See comment in __pte_alloc */
82350 +
82351 + spin_lock(&mm->page_table_lock);
82352 + if (pgd_present(*pgd)) /* Another has populated it */
82353 + pud_free(mm, new);
82354 + else
82355 + pgd_populate_kernel(mm, pgd, new);
82356 + spin_unlock(&mm->page_table_lock);
82357 + return 0;
82358 +}
82359 #endif /* __PAGETABLE_PUD_FOLDED */
82360
82361 #ifndef __PAGETABLE_PMD_FOLDED
82362 @@ -3867,11 +4125,35 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
82363 spin_unlock(&mm->page_table_lock);
82364 return 0;
82365 }
82366 +
82367 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
82368 +{
82369 + pmd_t *new = pmd_alloc_one(mm, address);
82370 + if (!new)
82371 + return -ENOMEM;
82372 +
82373 + smp_wmb(); /* See comment in __pte_alloc */
82374 +
82375 + spin_lock(&mm->page_table_lock);
82376 +#ifndef __ARCH_HAS_4LEVEL_HACK
82377 + if (pud_present(*pud)) /* Another has populated it */
82378 + pmd_free(mm, new);
82379 + else
82380 + pud_populate_kernel(mm, pud, new);
82381 +#else
82382 + if (pgd_present(*pud)) /* Another has populated it */
82383 + pmd_free(mm, new);
82384 + else
82385 + pgd_populate_kernel(mm, pud, new);
82386 +#endif /* __ARCH_HAS_4LEVEL_HACK */
82387 + spin_unlock(&mm->page_table_lock);
82388 + return 0;
82389 +}
82390 #endif /* __PAGETABLE_PMD_FOLDED */
82391
82392 -int make_pages_present(unsigned long addr, unsigned long end)
82393 +ssize_t make_pages_present(unsigned long addr, unsigned long end)
82394 {
82395 - int ret, len, write;
82396 + ssize_t ret, len, write;
82397 struct vm_area_struct * vma;
82398
82399 vma = find_vma(current->mm, addr);
82400 @@ -3904,7 +4186,7 @@ static int __init gate_vma_init(void)
82401 gate_vma.vm_start = FIXADDR_USER_START;
82402 gate_vma.vm_end = FIXADDR_USER_END;
82403 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
82404 - gate_vma.vm_page_prot = __P101;
82405 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
82406
82407 return 0;
82408 }
82409 @@ -4038,8 +4320,8 @@ out:
82410 return ret;
82411 }
82412
82413 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82414 - void *buf, int len, int write)
82415 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82416 + void *buf, size_t len, int write)
82417 {
82418 resource_size_t phys_addr;
82419 unsigned long prot = 0;
82420 @@ -4064,8 +4346,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82421 * Access another process' address space as given in mm. If non-NULL, use the
82422 * given task for page fault accounting.
82423 */
82424 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82425 - unsigned long addr, void *buf, int len, int write)
82426 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82427 + unsigned long addr, void *buf, size_t len, int write)
82428 {
82429 struct vm_area_struct *vma;
82430 void *old_buf = buf;
82431 @@ -4073,7 +4355,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82432 down_read(&mm->mmap_sem);
82433 /* ignore errors, just check how much was successfully transferred */
82434 while (len) {
82435 - int bytes, ret, offset;
82436 + ssize_t bytes, ret, offset;
82437 void *maddr;
82438 struct page *page = NULL;
82439
82440 @@ -4132,8 +4414,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82441 *
82442 * The caller must hold a reference on @mm.
82443 */
82444 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82445 - void *buf, int len, int write)
82446 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
82447 + void *buf, size_t len, int write)
82448 {
82449 return __access_remote_vm(NULL, mm, addr, buf, len, write);
82450 }
82451 @@ -4143,11 +4425,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82452 * Source/target buffer must be kernel space,
82453 * Do not walk the page table directly, use get_user_pages
82454 */
82455 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
82456 - void *buf, int len, int write)
82457 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
82458 + void *buf, size_t len, int write)
82459 {
82460 struct mm_struct *mm;
82461 - int ret;
82462 + ssize_t ret;
82463
82464 mm = get_task_mm(tsk);
82465 if (!mm)
82466 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
82467 index 3df6d12..a11056a 100644
82468 --- a/mm/mempolicy.c
82469 +++ b/mm/mempolicy.c
82470 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82471 unsigned long vmstart;
82472 unsigned long vmend;
82473
82474 +#ifdef CONFIG_PAX_SEGMEXEC
82475 + struct vm_area_struct *vma_m;
82476 +#endif
82477 +
82478 vma = find_vma(mm, start);
82479 if (!vma || vma->vm_start > start)
82480 return -EFAULT;
82481 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82482 if (err)
82483 goto out;
82484 }
82485 +
82486 err = vma_replace_policy(vma, new_pol);
82487 if (err)
82488 goto out;
82489 +
82490 +#ifdef CONFIG_PAX_SEGMEXEC
82491 + vma_m = pax_find_mirror_vma(vma);
82492 + if (vma_m) {
82493 + err = vma_replace_policy(vma_m, new_pol);
82494 + if (err)
82495 + goto out;
82496 + }
82497 +#endif
82498 +
82499 }
82500
82501 out:
82502 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
82503
82504 if (end < start)
82505 return -EINVAL;
82506 +
82507 +#ifdef CONFIG_PAX_SEGMEXEC
82508 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82509 + if (end > SEGMEXEC_TASK_SIZE)
82510 + return -EINVAL;
82511 + } else
82512 +#endif
82513 +
82514 + if (end > TASK_SIZE)
82515 + return -EINVAL;
82516 +
82517 if (end == start)
82518 return 0;
82519
82520 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82521 */
82522 tcred = __task_cred(task);
82523 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82524 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82525 - !capable(CAP_SYS_NICE)) {
82526 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82527 rcu_read_unlock();
82528 err = -EPERM;
82529 goto out_put;
82530 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82531 goto out;
82532 }
82533
82534 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82535 + if (mm != current->mm &&
82536 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
82537 + mmput(mm);
82538 + err = -EPERM;
82539 + goto out;
82540 + }
82541 +#endif
82542 +
82543 err = do_migrate_pages(mm, old, new,
82544 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
82545
82546 diff --git a/mm/migrate.c b/mm/migrate.c
82547 index 2fd8b4a..d70358f 100644
82548 --- a/mm/migrate.c
82549 +++ b/mm/migrate.c
82550 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
82551 */
82552 tcred = __task_cred(task);
82553 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82554 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82555 - !capable(CAP_SYS_NICE)) {
82556 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82557 rcu_read_unlock();
82558 err = -EPERM;
82559 goto out;
82560 diff --git a/mm/mlock.c b/mm/mlock.c
82561 index c9bd528..da8d069 100644
82562 --- a/mm/mlock.c
82563 +++ b/mm/mlock.c
82564 @@ -13,6 +13,7 @@
82565 #include <linux/pagemap.h>
82566 #include <linux/mempolicy.h>
82567 #include <linux/syscalls.h>
82568 +#include <linux/security.h>
82569 #include <linux/sched.h>
82570 #include <linux/export.h>
82571 #include <linux/rmap.h>
82572 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82573 {
82574 unsigned long nstart, end, tmp;
82575 struct vm_area_struct * vma, * prev;
82576 - int error;
82577 + int error = 0;
82578
82579 VM_BUG_ON(start & ~PAGE_MASK);
82580 VM_BUG_ON(len != PAGE_ALIGN(len));
82581 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82582 return -EINVAL;
82583 if (end == start)
82584 return 0;
82585 + if (end > TASK_SIZE)
82586 + return -EINVAL;
82587 +
82588 vma = find_vma(current->mm, start);
82589 if (!vma || vma->vm_start > start)
82590 return -ENOMEM;
82591 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82592 for (nstart = start ; ; ) {
82593 vm_flags_t newflags;
82594
82595 +#ifdef CONFIG_PAX_SEGMEXEC
82596 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82597 + break;
82598 +#endif
82599 +
82600 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82601
82602 newflags = vma->vm_flags | VM_LOCKED;
82603 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82604 lock_limit >>= PAGE_SHIFT;
82605
82606 /* check against resource limits */
82607 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82608 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82609 error = do_mlock(start, len, 1);
82610 up_write(&current->mm->mmap_sem);
82611 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
82612 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82613 vm_flags_t newflags;
82614
82615 +#ifdef CONFIG_PAX_SEGMEXEC
82616 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82617 + break;
82618 +#endif
82619 +
82620 + BUG_ON(vma->vm_end > TASK_SIZE);
82621 newflags = vma->vm_flags | VM_LOCKED;
82622 if (!(flags & MCL_CURRENT))
82623 newflags &= ~VM_LOCKED;
82624 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82625 lock_limit >>= PAGE_SHIFT;
82626
82627 ret = -ENOMEM;
82628 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82629 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82630 capable(CAP_IPC_LOCK))
82631 ret = do_mlockall(flags);
82632 diff --git a/mm/mmap.c b/mm/mmap.c
82633 index 90db251..04240d1 100644
82634 --- a/mm/mmap.c
82635 +++ b/mm/mmap.c
82636 @@ -32,6 +32,7 @@
82637 #include <linux/khugepaged.h>
82638 #include <linux/uprobes.h>
82639 #include <linux/rbtree_augmented.h>
82640 +#include <linux/random.h>
82641
82642 #include <asm/uaccess.h>
82643 #include <asm/cacheflush.h>
82644 @@ -48,6 +49,16 @@
82645 #define arch_rebalance_pgtables(addr, len) (addr)
82646 #endif
82647
82648 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82649 +{
82650 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82651 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82652 + up_read(&mm->mmap_sem);
82653 + BUG();
82654 + }
82655 +#endif
82656 +}
82657 +
82658 static void unmap_region(struct mm_struct *mm,
82659 struct vm_area_struct *vma, struct vm_area_struct *prev,
82660 unsigned long start, unsigned long end);
82661 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
82662 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82663 *
82664 */
82665 -pgprot_t protection_map[16] = {
82666 +pgprot_t protection_map[16] __read_only = {
82667 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82668 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82669 };
82670
82671 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82672 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82673 {
82674 - return __pgprot(pgprot_val(protection_map[vm_flags &
82675 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82676 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82677 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82678 +
82679 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82680 + if (!(__supported_pte_mask & _PAGE_NX) &&
82681 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82682 + (vm_flags & (VM_READ | VM_WRITE)))
82683 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82684 +#endif
82685 +
82686 + return prot;
82687 }
82688 EXPORT_SYMBOL(vm_get_page_prot);
82689
82690 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
82691 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82692 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82693 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82694 /*
82695 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82696 * other variables. It can be updated by several CPUs frequently.
82697 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82698 struct vm_area_struct *next = vma->vm_next;
82699
82700 might_sleep();
82701 + BUG_ON(vma->vm_mirror);
82702 if (vma->vm_ops && vma->vm_ops->close)
82703 vma->vm_ops->close(vma);
82704 if (vma->vm_file)
82705 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82706 * not page aligned -Ram Gupta
82707 */
82708 rlim = rlimit(RLIMIT_DATA);
82709 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82710 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82711 (mm->end_data - mm->start_data) > rlim)
82712 goto out;
82713 @@ -888,6 +911,12 @@ static int
82714 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82715 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82716 {
82717 +
82718 +#ifdef CONFIG_PAX_SEGMEXEC
82719 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82720 + return 0;
82721 +#endif
82722 +
82723 if (is_mergeable_vma(vma, file, vm_flags) &&
82724 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82725 if (vma->vm_pgoff == vm_pgoff)
82726 @@ -907,6 +936,12 @@ static int
82727 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82728 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82729 {
82730 +
82731 +#ifdef CONFIG_PAX_SEGMEXEC
82732 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82733 + return 0;
82734 +#endif
82735 +
82736 if (is_mergeable_vma(vma, file, vm_flags) &&
82737 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82738 pgoff_t vm_pglen;
82739 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82740 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82741 struct vm_area_struct *prev, unsigned long addr,
82742 unsigned long end, unsigned long vm_flags,
82743 - struct anon_vma *anon_vma, struct file *file,
82744 + struct anon_vma *anon_vma, struct file *file,
82745 pgoff_t pgoff, struct mempolicy *policy)
82746 {
82747 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82748 struct vm_area_struct *area, *next;
82749 int err;
82750
82751 +#ifdef CONFIG_PAX_SEGMEXEC
82752 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82753 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82754 +
82755 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82756 +#endif
82757 +
82758 /*
82759 * We later require that vma->vm_flags == vm_flags,
82760 * so this tests vma->vm_flags & VM_SPECIAL, too.
82761 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82762 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82763 next = next->vm_next;
82764
82765 +#ifdef CONFIG_PAX_SEGMEXEC
82766 + if (prev)
82767 + prev_m = pax_find_mirror_vma(prev);
82768 + if (area)
82769 + area_m = pax_find_mirror_vma(area);
82770 + if (next)
82771 + next_m = pax_find_mirror_vma(next);
82772 +#endif
82773 +
82774 /*
82775 * Can it merge with the predecessor?
82776 */
82777 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82778 /* cases 1, 6 */
82779 err = vma_adjust(prev, prev->vm_start,
82780 next->vm_end, prev->vm_pgoff, NULL);
82781 - } else /* cases 2, 5, 7 */
82782 +
82783 +#ifdef CONFIG_PAX_SEGMEXEC
82784 + if (!err && prev_m)
82785 + err = vma_adjust(prev_m, prev_m->vm_start,
82786 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82787 +#endif
82788 +
82789 + } else { /* cases 2, 5, 7 */
82790 err = vma_adjust(prev, prev->vm_start,
82791 end, prev->vm_pgoff, NULL);
82792 +
82793 +#ifdef CONFIG_PAX_SEGMEXEC
82794 + if (!err && prev_m)
82795 + err = vma_adjust(prev_m, prev_m->vm_start,
82796 + end_m, prev_m->vm_pgoff, NULL);
82797 +#endif
82798 +
82799 + }
82800 if (err)
82801 return NULL;
82802 khugepaged_enter_vma_merge(prev);
82803 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82804 mpol_equal(policy, vma_policy(next)) &&
82805 can_vma_merge_before(next, vm_flags,
82806 anon_vma, file, pgoff+pglen)) {
82807 - if (prev && addr < prev->vm_end) /* case 4 */
82808 + if (prev && addr < prev->vm_end) { /* case 4 */
82809 err = vma_adjust(prev, prev->vm_start,
82810 addr, prev->vm_pgoff, NULL);
82811 - else /* cases 3, 8 */
82812 +
82813 +#ifdef CONFIG_PAX_SEGMEXEC
82814 + if (!err && prev_m)
82815 + err = vma_adjust(prev_m, prev_m->vm_start,
82816 + addr_m, prev_m->vm_pgoff, NULL);
82817 +#endif
82818 +
82819 + } else { /* cases 3, 8 */
82820 err = vma_adjust(area, addr, next->vm_end,
82821 next->vm_pgoff - pglen, NULL);
82822 +
82823 +#ifdef CONFIG_PAX_SEGMEXEC
82824 + if (!err && area_m)
82825 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82826 + next_m->vm_pgoff - pglen, NULL);
82827 +#endif
82828 +
82829 + }
82830 if (err)
82831 return NULL;
82832 khugepaged_enter_vma_merge(area);
82833 @@ -1120,8 +1201,10 @@ none:
82834 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82835 struct file *file, long pages)
82836 {
82837 - const unsigned long stack_flags
82838 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82839 +
82840 +#ifdef CONFIG_PAX_RANDMMAP
82841 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82842 +#endif
82843
82844 mm->total_vm += pages;
82845
82846 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82847 mm->shared_vm += pages;
82848 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82849 mm->exec_vm += pages;
82850 - } else if (flags & stack_flags)
82851 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82852 mm->stack_vm += pages;
82853 }
82854 #endif /* CONFIG_PROC_FS */
82855 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82856 * (the exception is when the underlying filesystem is noexec
82857 * mounted, in which case we dont add PROT_EXEC.)
82858 */
82859 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82860 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82861 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82862 prot |= PROT_EXEC;
82863
82864 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82865 /* Obtain the address to map to. we verify (or select) it and ensure
82866 * that it represents a valid section of the address space.
82867 */
82868 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82869 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82870 if (addr & ~PAGE_MASK)
82871 return addr;
82872
82873 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82874 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82875 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82876
82877 +#ifdef CONFIG_PAX_MPROTECT
82878 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82879 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82880 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82881 + gr_log_rwxmmap(file);
82882 +
82883 +#ifdef CONFIG_PAX_EMUPLT
82884 + vm_flags &= ~VM_EXEC;
82885 +#else
82886 + return -EPERM;
82887 +#endif
82888 +
82889 + }
82890 +
82891 + if (!(vm_flags & VM_EXEC))
82892 + vm_flags &= ~VM_MAYEXEC;
82893 +#else
82894 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82895 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82896 +#endif
82897 + else
82898 + vm_flags &= ~VM_MAYWRITE;
82899 + }
82900 +#endif
82901 +
82902 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82903 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82904 + vm_flags &= ~VM_PAGEEXEC;
82905 +#endif
82906 +
82907 if (flags & MAP_LOCKED)
82908 if (!can_do_mlock())
82909 return -EPERM;
82910 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82911 locked += mm->locked_vm;
82912 lock_limit = rlimit(RLIMIT_MEMLOCK);
82913 lock_limit >>= PAGE_SHIFT;
82914 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82915 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82916 return -EAGAIN;
82917 }
82918 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82919 }
82920 }
82921
82922 + if (!gr_acl_handle_mmap(file, prot))
82923 + return -EACCES;
82924 +
82925 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
82926 }
82927
82928 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82929 vm_flags_t vm_flags = vma->vm_flags;
82930
82931 /* If it was private or non-writable, the write bit is already clear */
82932 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82933 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82934 return 0;
82935
82936 /* The backer wishes to know when pages are first written to? */
82937 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82938 unsigned long charged = 0;
82939 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
82940
82941 +#ifdef CONFIG_PAX_SEGMEXEC
82942 + struct vm_area_struct *vma_m = NULL;
82943 +#endif
82944 +
82945 + /*
82946 + * mm->mmap_sem is required to protect against another thread
82947 + * changing the mappings in case we sleep.
82948 + */
82949 + verify_mm_writelocked(mm);
82950 +
82951 /* Clear old maps */
82952 error = -ENOMEM;
82953 -munmap_back:
82954 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82955 if (do_munmap(mm, addr, len))
82956 return -ENOMEM;
82957 - goto munmap_back;
82958 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82959 }
82960
82961 /* Check against address space limit. */
82962 +
82963 +#ifdef CONFIG_PAX_RANDMMAP
82964 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82965 +#endif
82966 +
82967 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82968 return -ENOMEM;
82969
82970 @@ -1460,6 +1591,16 @@ munmap_back:
82971 goto unacct_error;
82972 }
82973
82974 +#ifdef CONFIG_PAX_SEGMEXEC
82975 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82976 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82977 + if (!vma_m) {
82978 + error = -ENOMEM;
82979 + goto free_vma;
82980 + }
82981 + }
82982 +#endif
82983 +
82984 vma->vm_mm = mm;
82985 vma->vm_start = addr;
82986 vma->vm_end = addr + len;
82987 @@ -1484,6 +1625,13 @@ munmap_back:
82988 if (error)
82989 goto unmap_and_free_vma;
82990
82991 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82992 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82993 + vma->vm_flags |= VM_PAGEEXEC;
82994 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82995 + }
82996 +#endif
82997 +
82998 /* Can addr have changed??
82999 *
83000 * Answer: Yes, several device drivers can do it in their
83001 @@ -1522,6 +1670,11 @@ munmap_back:
83002 vma_link(mm, vma, prev, rb_link, rb_parent);
83003 file = vma->vm_file;
83004
83005 +#ifdef CONFIG_PAX_SEGMEXEC
83006 + if (vma_m)
83007 + BUG_ON(pax_mirror_vma(vma_m, vma));
83008 +#endif
83009 +
83010 /* Once vma denies write, undo our temporary denial count */
83011 if (correct_wcount)
83012 atomic_inc(&inode->i_writecount);
83013 @@ -1529,6 +1682,7 @@ out:
83014 perf_event_mmap(vma);
83015
83016 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
83017 + track_exec_limit(mm, addr, addr + len, vm_flags);
83018 if (vm_flags & VM_LOCKED) {
83019 if (!mlock_vma_pages_range(vma, addr, addr + len))
83020 mm->locked_vm += (len >> PAGE_SHIFT);
83021 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
83022 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
83023 charged = 0;
83024 free_vma:
83025 +
83026 +#ifdef CONFIG_PAX_SEGMEXEC
83027 + if (vma_m)
83028 + kmem_cache_free(vm_area_cachep, vma_m);
83029 +#endif
83030 +
83031 kmem_cache_free(vm_area_cachep, vma);
83032 unacct_error:
83033 if (charged)
83034 @@ -1557,6 +1717,62 @@ unacct_error:
83035 return error;
83036 }
83037
83038 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
83039 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
83040 +{
83041 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
83042 + return (random32() & 0xFF) << PAGE_SHIFT;
83043 +
83044 + return 0;
83045 +}
83046 +#endif
83047 +
83048 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
83049 +{
83050 + if (!vma) {
83051 +#ifdef CONFIG_STACK_GROWSUP
83052 + if (addr > sysctl_heap_stack_gap)
83053 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
83054 + else
83055 + vma = find_vma(current->mm, 0);
83056 + if (vma && (vma->vm_flags & VM_GROWSUP))
83057 + return false;
83058 +#endif
83059 + return true;
83060 + }
83061 +
83062 + if (addr + len > vma->vm_start)
83063 + return false;
83064 +
83065 + if (vma->vm_flags & VM_GROWSDOWN)
83066 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
83067 +#ifdef CONFIG_STACK_GROWSUP
83068 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
83069 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
83070 +#endif
83071 + else if (offset)
83072 + return offset <= vma->vm_start - addr - len;
83073 +
83074 + return true;
83075 +}
83076 +
83077 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
83078 +{
83079 + if (vma->vm_start < len)
83080 + return -ENOMEM;
83081 +
83082 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
83083 + if (offset <= vma->vm_start - len)
83084 + return vma->vm_start - len - offset;
83085 + else
83086 + return -ENOMEM;
83087 + }
83088 +
83089 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
83090 + return vma->vm_start - len - sysctl_heap_stack_gap;
83091 + return -ENOMEM;
83092 +}
83093 +
83094 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
83095 {
83096 /*
83097 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83098 struct mm_struct *mm = current->mm;
83099 struct vm_area_struct *vma;
83100 struct vm_unmapped_area_info info;
83101 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
83102
83103 if (len > TASK_SIZE)
83104 return -ENOMEM;
83105 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83106 if (flags & MAP_FIXED)
83107 return addr;
83108
83109 +#ifdef CONFIG_PAX_RANDMMAP
83110 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
83111 +#endif
83112 +
83113 if (addr) {
83114 addr = PAGE_ALIGN(addr);
83115 vma = find_vma(mm, addr);
83116 - if (TASK_SIZE - len >= addr &&
83117 - (!vma || addr + len <= vma->vm_start))
83118 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
83119 return addr;
83120 }
83121
83122 info.flags = 0;
83123 info.length = len;
83124 info.low_limit = TASK_UNMAPPED_BASE;
83125 +
83126 +#ifdef CONFIG_PAX_RANDMMAP
83127 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83128 + info.low_limit += mm->delta_mmap;
83129 +#endif
83130 +
83131 info.high_limit = TASK_SIZE;
83132 info.align_mask = 0;
83133 return vm_unmapped_area(&info);
83134 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
83135
83136 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
83137 {
83138 +
83139 +#ifdef CONFIG_PAX_SEGMEXEC
83140 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83141 + return;
83142 +#endif
83143 +
83144 /*
83145 * Is this a new hole at the lowest possible address?
83146 */
83147 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
83148 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
83149 mm->free_area_cache = addr;
83150 }
83151
83152 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83153 struct mm_struct *mm = current->mm;
83154 unsigned long addr = addr0;
83155 struct vm_unmapped_area_info info;
83156 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
83157
83158 /* requested length too big for entire address space */
83159 if (len > TASK_SIZE)
83160 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83161 if (flags & MAP_FIXED)
83162 return addr;
83163
83164 +#ifdef CONFIG_PAX_RANDMMAP
83165 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
83166 +#endif
83167 +
83168 /* requesting a specific address */
83169 if (addr) {
83170 addr = PAGE_ALIGN(addr);
83171 vma = find_vma(mm, addr);
83172 - if (TASK_SIZE - len >= addr &&
83173 - (!vma || addr + len <= vma->vm_start))
83174 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
83175 return addr;
83176 }
83177
83178 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83179 VM_BUG_ON(addr != -ENOMEM);
83180 info.flags = 0;
83181 info.low_limit = TASK_UNMAPPED_BASE;
83182 +
83183 +#ifdef CONFIG_PAX_RANDMMAP
83184 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83185 + info.low_limit += mm->delta_mmap;
83186 +#endif
83187 +
83188 info.high_limit = TASK_SIZE;
83189 addr = vm_unmapped_area(&info);
83190 }
83191 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83192
83193 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83194 {
83195 +
83196 +#ifdef CONFIG_PAX_SEGMEXEC
83197 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83198 + return;
83199 +#endif
83200 +
83201 /*
83202 * Is this a new hole at the highest possible address?
83203 */
83204 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83205 mm->free_area_cache = addr;
83206
83207 /* dont allow allocations above current base */
83208 - if (mm->free_area_cache > mm->mmap_base)
83209 + if (mm->free_area_cache > mm->mmap_base) {
83210 mm->free_area_cache = mm->mmap_base;
83211 + mm->cached_hole_size = ~0UL;
83212 + }
83213 }
83214
83215 unsigned long
83216 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
83217 return vma;
83218 }
83219
83220 +#ifdef CONFIG_PAX_SEGMEXEC
83221 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
83222 +{
83223 + struct vm_area_struct *vma_m;
83224 +
83225 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
83226 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
83227 + BUG_ON(vma->vm_mirror);
83228 + return NULL;
83229 + }
83230 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
83231 + vma_m = vma->vm_mirror;
83232 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
83233 + BUG_ON(vma->vm_file != vma_m->vm_file);
83234 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
83235 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
83236 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
83237 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
83238 + return vma_m;
83239 +}
83240 +#endif
83241 +
83242 /*
83243 * Verify that the stack growth is acceptable and
83244 * update accounting. This is shared with both the
83245 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83246 return -ENOMEM;
83247
83248 /* Stack limit test */
83249 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
83250 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
83251 return -ENOMEM;
83252
83253 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83254 locked = mm->locked_vm + grow;
83255 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
83256 limit >>= PAGE_SHIFT;
83257 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
83258 if (locked > limit && !capable(CAP_IPC_LOCK))
83259 return -ENOMEM;
83260 }
83261 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83262 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
83263 * vma is the last one with address > vma->vm_end. Have to extend vma.
83264 */
83265 +#ifndef CONFIG_IA64
83266 +static
83267 +#endif
83268 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
83269 {
83270 int error;
83271 + bool locknext;
83272
83273 if (!(vma->vm_flags & VM_GROWSUP))
83274 return -EFAULT;
83275
83276 + /* Also guard against wrapping around to address 0. */
83277 + if (address < PAGE_ALIGN(address+1))
83278 + address = PAGE_ALIGN(address+1);
83279 + else
83280 + return -ENOMEM;
83281 +
83282 /*
83283 * We must make sure the anon_vma is allocated
83284 * so that the anon_vma locking is not a noop.
83285 */
83286 if (unlikely(anon_vma_prepare(vma)))
83287 return -ENOMEM;
83288 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
83289 + if (locknext && anon_vma_prepare(vma->vm_next))
83290 + return -ENOMEM;
83291 vma_lock_anon_vma(vma);
83292 + if (locknext)
83293 + vma_lock_anon_vma(vma->vm_next);
83294
83295 /*
83296 * vma->vm_start/vm_end cannot change under us because the caller
83297 * is required to hold the mmap_sem in read mode. We need the
83298 - * anon_vma lock to serialize against concurrent expand_stacks.
83299 - * Also guard against wrapping around to address 0.
83300 + * anon_vma locks to serialize against concurrent expand_stacks
83301 + * and expand_upwards.
83302 */
83303 - if (address < PAGE_ALIGN(address+4))
83304 - address = PAGE_ALIGN(address+4);
83305 - else {
83306 - vma_unlock_anon_vma(vma);
83307 - return -ENOMEM;
83308 - }
83309 error = 0;
83310
83311 /* Somebody else might have raced and expanded it already */
83312 - if (address > vma->vm_end) {
83313 + 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)
83314 + error = -ENOMEM;
83315 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
83316 unsigned long size, grow;
83317
83318 size = address - vma->vm_start;
83319 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
83320 }
83321 }
83322 }
83323 + if (locknext)
83324 + vma_unlock_anon_vma(vma->vm_next);
83325 vma_unlock_anon_vma(vma);
83326 khugepaged_enter_vma_merge(vma);
83327 validate_mm(vma->vm_mm);
83328 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
83329 unsigned long address)
83330 {
83331 int error;
83332 + bool lockprev = false;
83333 + struct vm_area_struct *prev;
83334
83335 /*
83336 * We must make sure the anon_vma is allocated
83337 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
83338 if (error)
83339 return error;
83340
83341 + prev = vma->vm_prev;
83342 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
83343 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
83344 +#endif
83345 + if (lockprev && anon_vma_prepare(prev))
83346 + return -ENOMEM;
83347 + if (lockprev)
83348 + vma_lock_anon_vma(prev);
83349 +
83350 vma_lock_anon_vma(vma);
83351
83352 /*
83353 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
83354 */
83355
83356 /* Somebody else might have raced and expanded it already */
83357 - if (address < vma->vm_start) {
83358 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
83359 + error = -ENOMEM;
83360 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
83361 unsigned long size, grow;
83362
83363 +#ifdef CONFIG_PAX_SEGMEXEC
83364 + struct vm_area_struct *vma_m;
83365 +
83366 + vma_m = pax_find_mirror_vma(vma);
83367 +#endif
83368 +
83369 size = vma->vm_end - address;
83370 grow = (vma->vm_start - address) >> PAGE_SHIFT;
83371
83372 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
83373 vma->vm_pgoff -= grow;
83374 anon_vma_interval_tree_post_update_vma(vma);
83375 vma_gap_update(vma);
83376 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
83377 +
83378 +#ifdef CONFIG_PAX_SEGMEXEC
83379 + if (vma_m) {
83380 + anon_vma_interval_tree_pre_update_vma(vma_m);
83381 + vma_m->vm_start -= grow << PAGE_SHIFT;
83382 + vma_m->vm_pgoff -= grow;
83383 + anon_vma_interval_tree_post_update_vma(vma_m);
83384 + vma_gap_update(vma_m);
83385 + }
83386 +#endif
83387 +
83388 spin_unlock(&vma->vm_mm->page_table_lock);
83389
83390 perf_event_mmap(vma);
83391 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
83392 do {
83393 long nrpages = vma_pages(vma);
83394
83395 +#ifdef CONFIG_PAX_SEGMEXEC
83396 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
83397 + vma = remove_vma(vma);
83398 + continue;
83399 + }
83400 +#endif
83401 +
83402 if (vma->vm_flags & VM_ACCOUNT)
83403 nr_accounted += nrpages;
83404 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
83405 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
83406 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
83407 vma->vm_prev = NULL;
83408 do {
83409 +
83410 +#ifdef CONFIG_PAX_SEGMEXEC
83411 + if (vma->vm_mirror) {
83412 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
83413 + vma->vm_mirror->vm_mirror = NULL;
83414 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
83415 + vma->vm_mirror = NULL;
83416 + }
83417 +#endif
83418 +
83419 vma_rb_erase(vma, &mm->mm_rb);
83420 mm->map_count--;
83421 tail_vma = vma;
83422 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83423 struct vm_area_struct *new;
83424 int err = -ENOMEM;
83425
83426 +#ifdef CONFIG_PAX_SEGMEXEC
83427 + struct vm_area_struct *vma_m, *new_m = NULL;
83428 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
83429 +#endif
83430 +
83431 if (is_vm_hugetlb_page(vma) && (addr &
83432 ~(huge_page_mask(hstate_vma(vma)))))
83433 return -EINVAL;
83434
83435 +#ifdef CONFIG_PAX_SEGMEXEC
83436 + vma_m = pax_find_mirror_vma(vma);
83437 +#endif
83438 +
83439 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83440 if (!new)
83441 goto out_err;
83442
83443 +#ifdef CONFIG_PAX_SEGMEXEC
83444 + if (vma_m) {
83445 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83446 + if (!new_m) {
83447 + kmem_cache_free(vm_area_cachep, new);
83448 + goto out_err;
83449 + }
83450 + }
83451 +#endif
83452 +
83453 /* most fields are the same, copy all, and then fixup */
83454 *new = *vma;
83455
83456 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83457 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
83458 }
83459
83460 +#ifdef CONFIG_PAX_SEGMEXEC
83461 + if (vma_m) {
83462 + *new_m = *vma_m;
83463 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
83464 + new_m->vm_mirror = new;
83465 + new->vm_mirror = new_m;
83466 +
83467 + if (new_below)
83468 + new_m->vm_end = addr_m;
83469 + else {
83470 + new_m->vm_start = addr_m;
83471 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
83472 + }
83473 + }
83474 +#endif
83475 +
83476 pol = mpol_dup(vma_policy(vma));
83477 if (IS_ERR(pol)) {
83478 err = PTR_ERR(pol);
83479 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83480 else
83481 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
83482
83483 +#ifdef CONFIG_PAX_SEGMEXEC
83484 + if (!err && vma_m) {
83485 + if (anon_vma_clone(new_m, vma_m))
83486 + goto out_free_mpol;
83487 +
83488 + mpol_get(pol);
83489 + vma_set_policy(new_m, pol);
83490 +
83491 + if (new_m->vm_file)
83492 + get_file(new_m->vm_file);
83493 +
83494 + if (new_m->vm_ops && new_m->vm_ops->open)
83495 + new_m->vm_ops->open(new_m);
83496 +
83497 + if (new_below)
83498 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
83499 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
83500 + else
83501 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
83502 +
83503 + if (err) {
83504 + if (new_m->vm_ops && new_m->vm_ops->close)
83505 + new_m->vm_ops->close(new_m);
83506 + if (new_m->vm_file)
83507 + fput(new_m->vm_file);
83508 + mpol_put(pol);
83509 + }
83510 + }
83511 +#endif
83512 +
83513 /* Success. */
83514 if (!err)
83515 return 0;
83516 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83517 new->vm_ops->close(new);
83518 if (new->vm_file)
83519 fput(new->vm_file);
83520 - unlink_anon_vmas(new);
83521 out_free_mpol:
83522 mpol_put(pol);
83523 out_free_vma:
83524 +
83525 +#ifdef CONFIG_PAX_SEGMEXEC
83526 + if (new_m) {
83527 + unlink_anon_vmas(new_m);
83528 + kmem_cache_free(vm_area_cachep, new_m);
83529 + }
83530 +#endif
83531 +
83532 + unlink_anon_vmas(new);
83533 kmem_cache_free(vm_area_cachep, new);
83534 out_err:
83535 return err;
83536 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83537 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83538 unsigned long addr, int new_below)
83539 {
83540 +
83541 +#ifdef CONFIG_PAX_SEGMEXEC
83542 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83543 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
83544 + if (mm->map_count >= sysctl_max_map_count-1)
83545 + return -ENOMEM;
83546 + } else
83547 +#endif
83548 +
83549 if (mm->map_count >= sysctl_max_map_count)
83550 return -ENOMEM;
83551
83552 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83553 * work. This now handles partial unmappings.
83554 * Jeremy Fitzhardinge <jeremy@goop.org>
83555 */
83556 +#ifdef CONFIG_PAX_SEGMEXEC
83557 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83558 {
83559 + int ret = __do_munmap(mm, start, len);
83560 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
83561 + return ret;
83562 +
83563 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
83564 +}
83565 +
83566 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83567 +#else
83568 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83569 +#endif
83570 +{
83571 unsigned long end;
83572 struct vm_area_struct *vma, *prev, *last;
83573
83574 + /*
83575 + * mm->mmap_sem is required to protect against another thread
83576 + * changing the mappings in case we sleep.
83577 + */
83578 + verify_mm_writelocked(mm);
83579 +
83580 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83581 return -EINVAL;
83582
83583 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83584 /* Fix up all other VM information */
83585 remove_vma_list(mm, vma);
83586
83587 + track_exec_limit(mm, start, end, 0UL);
83588 +
83589 return 0;
83590 }
83591
83592 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
83593 int ret;
83594 struct mm_struct *mm = current->mm;
83595
83596 +
83597 +#ifdef CONFIG_PAX_SEGMEXEC
83598 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83599 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83600 + return -EINVAL;
83601 +#endif
83602 +
83603 down_write(&mm->mmap_sem);
83604 ret = do_munmap(mm, start, len);
83605 up_write(&mm->mmap_sem);
83606 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83607 return vm_munmap(addr, len);
83608 }
83609
83610 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83611 -{
83612 -#ifdef CONFIG_DEBUG_VM
83613 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83614 - WARN_ON(1);
83615 - up_read(&mm->mmap_sem);
83616 - }
83617 -#endif
83618 -}
83619 -
83620 /*
83621 * this is really a simplified "do_mmap". it only handles
83622 * anonymous maps. eventually we may be able to do some
83623 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83624 struct rb_node ** rb_link, * rb_parent;
83625 pgoff_t pgoff = addr >> PAGE_SHIFT;
83626 int error;
83627 + unsigned long charged;
83628
83629 len = PAGE_ALIGN(len);
83630 if (!len)
83631 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83632
83633 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83634
83635 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83636 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83637 + flags &= ~VM_EXEC;
83638 +
83639 +#ifdef CONFIG_PAX_MPROTECT
83640 + if (mm->pax_flags & MF_PAX_MPROTECT)
83641 + flags &= ~VM_MAYEXEC;
83642 +#endif
83643 +
83644 + }
83645 +#endif
83646 +
83647 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83648 if (error & ~PAGE_MASK)
83649 return error;
83650
83651 + charged = len >> PAGE_SHIFT;
83652 +
83653 /*
83654 * mlock MCL_FUTURE?
83655 */
83656 if (mm->def_flags & VM_LOCKED) {
83657 unsigned long locked, lock_limit;
83658 - locked = len >> PAGE_SHIFT;
83659 + locked = charged;
83660 locked += mm->locked_vm;
83661 lock_limit = rlimit(RLIMIT_MEMLOCK);
83662 lock_limit >>= PAGE_SHIFT;
83663 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83664 /*
83665 * Clear old maps. this also does some error checking for us
83666 */
83667 - munmap_back:
83668 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83669 if (do_munmap(mm, addr, len))
83670 return -ENOMEM;
83671 - goto munmap_back;
83672 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83673 }
83674
83675 /* Check against address space limits *after* clearing old maps... */
83676 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83677 + if (!may_expand_vm(mm, charged))
83678 return -ENOMEM;
83679
83680 if (mm->map_count > sysctl_max_map_count)
83681 return -ENOMEM;
83682
83683 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83684 + if (security_vm_enough_memory_mm(mm, charged))
83685 return -ENOMEM;
83686
83687 /* Can we just expand an old private anonymous mapping? */
83688 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83689 */
83690 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83691 if (!vma) {
83692 - vm_unacct_memory(len >> PAGE_SHIFT);
83693 + vm_unacct_memory(charged);
83694 return -ENOMEM;
83695 }
83696
83697 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83698 vma_link(mm, vma, prev, rb_link, rb_parent);
83699 out:
83700 perf_event_mmap(vma);
83701 - mm->total_vm += len >> PAGE_SHIFT;
83702 + mm->total_vm += charged;
83703 if (flags & VM_LOCKED) {
83704 if (!mlock_vma_pages_range(vma, addr, addr + len))
83705 - mm->locked_vm += (len >> PAGE_SHIFT);
83706 + mm->locked_vm += charged;
83707 }
83708 + track_exec_limit(mm, addr, addr + len, flags);
83709 return addr;
83710 }
83711
83712 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
83713 while (vma) {
83714 if (vma->vm_flags & VM_ACCOUNT)
83715 nr_accounted += vma_pages(vma);
83716 + vma->vm_mirror = NULL;
83717 vma = remove_vma(vma);
83718 }
83719 vm_unacct_memory(nr_accounted);
83720 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83721 struct vm_area_struct *prev;
83722 struct rb_node **rb_link, *rb_parent;
83723
83724 +#ifdef CONFIG_PAX_SEGMEXEC
83725 + struct vm_area_struct *vma_m = NULL;
83726 +#endif
83727 +
83728 + if (security_mmap_addr(vma->vm_start))
83729 + return -EPERM;
83730 +
83731 /*
83732 * The vm_pgoff of a purely anonymous vma should be irrelevant
83733 * until its first write fault, when page's anon_vma and index
83734 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83735 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83736 return -ENOMEM;
83737
83738 +#ifdef CONFIG_PAX_SEGMEXEC
83739 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83740 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83741 + if (!vma_m)
83742 + return -ENOMEM;
83743 + }
83744 +#endif
83745 +
83746 vma_link(mm, vma, prev, rb_link, rb_parent);
83747 +
83748 +#ifdef CONFIG_PAX_SEGMEXEC
83749 + if (vma_m)
83750 + BUG_ON(pax_mirror_vma(vma_m, vma));
83751 +#endif
83752 +
83753 return 0;
83754 }
83755
83756 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83757 struct mempolicy *pol;
83758 bool faulted_in_anon_vma = true;
83759
83760 + BUG_ON(vma->vm_mirror);
83761 +
83762 /*
83763 * If anonymous vma has not yet been faulted, update new pgoff
83764 * to match new location, to increase its chance of merging.
83765 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83766 return NULL;
83767 }
83768
83769 +#ifdef CONFIG_PAX_SEGMEXEC
83770 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83771 +{
83772 + struct vm_area_struct *prev_m;
83773 + struct rb_node **rb_link_m, *rb_parent_m;
83774 + struct mempolicy *pol_m;
83775 +
83776 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83777 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83778 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83779 + *vma_m = *vma;
83780 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83781 + if (anon_vma_clone(vma_m, vma))
83782 + return -ENOMEM;
83783 + pol_m = vma_policy(vma_m);
83784 + mpol_get(pol_m);
83785 + vma_set_policy(vma_m, pol_m);
83786 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83787 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83788 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83789 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83790 + if (vma_m->vm_file)
83791 + get_file(vma_m->vm_file);
83792 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83793 + vma_m->vm_ops->open(vma_m);
83794 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83795 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83796 + vma_m->vm_mirror = vma;
83797 + vma->vm_mirror = vma_m;
83798 + return 0;
83799 +}
83800 +#endif
83801 +
83802 /*
83803 * Return true if the calling process may expand its vm space by the passed
83804 * number of pages
83805 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83806
83807 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83808
83809 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83810 if (cur + npages > lim)
83811 return 0;
83812 return 1;
83813 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
83814 vma->vm_start = addr;
83815 vma->vm_end = addr + len;
83816
83817 +#ifdef CONFIG_PAX_MPROTECT
83818 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83819 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83820 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83821 + return -EPERM;
83822 + if (!(vm_flags & VM_EXEC))
83823 + vm_flags &= ~VM_MAYEXEC;
83824 +#else
83825 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83826 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83827 +#endif
83828 + else
83829 + vm_flags &= ~VM_MAYWRITE;
83830 + }
83831 +#endif
83832 +
83833 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83834 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83835
83836 diff --git a/mm/mprotect.c b/mm/mprotect.c
83837 index 94722a4..9837984 100644
83838 --- a/mm/mprotect.c
83839 +++ b/mm/mprotect.c
83840 @@ -23,10 +23,17 @@
83841 #include <linux/mmu_notifier.h>
83842 #include <linux/migrate.h>
83843 #include <linux/perf_event.h>
83844 +
83845 +#ifdef CONFIG_PAX_MPROTECT
83846 +#include <linux/elf.h>
83847 +#include <linux/binfmts.h>
83848 +#endif
83849 +
83850 #include <asm/uaccess.h>
83851 #include <asm/pgtable.h>
83852 #include <asm/cacheflush.h>
83853 #include <asm/tlbflush.h>
83854 +#include <asm/mmu_context.h>
83855
83856 #ifndef pgprot_modify
83857 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83858 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83859 return pages;
83860 }
83861
83862 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83863 +/* called while holding the mmap semaphor for writing except stack expansion */
83864 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83865 +{
83866 + unsigned long oldlimit, newlimit = 0UL;
83867 +
83868 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83869 + return;
83870 +
83871 + spin_lock(&mm->page_table_lock);
83872 + oldlimit = mm->context.user_cs_limit;
83873 + if ((prot & VM_EXEC) && oldlimit < end)
83874 + /* USER_CS limit moved up */
83875 + newlimit = end;
83876 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83877 + /* USER_CS limit moved down */
83878 + newlimit = start;
83879 +
83880 + if (newlimit) {
83881 + mm->context.user_cs_limit = newlimit;
83882 +
83883 +#ifdef CONFIG_SMP
83884 + wmb();
83885 + cpus_clear(mm->context.cpu_user_cs_mask);
83886 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83887 +#endif
83888 +
83889 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83890 + }
83891 + spin_unlock(&mm->page_table_lock);
83892 + if (newlimit == end) {
83893 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83894 +
83895 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83896 + if (is_vm_hugetlb_page(vma))
83897 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83898 + else
83899 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83900 + }
83901 +}
83902 +#endif
83903 +
83904 int
83905 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83906 unsigned long start, unsigned long end, unsigned long newflags)
83907 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83908 int error;
83909 int dirty_accountable = 0;
83910
83911 +#ifdef CONFIG_PAX_SEGMEXEC
83912 + struct vm_area_struct *vma_m = NULL;
83913 + unsigned long start_m, end_m;
83914 +
83915 + start_m = start + SEGMEXEC_TASK_SIZE;
83916 + end_m = end + SEGMEXEC_TASK_SIZE;
83917 +#endif
83918 +
83919 if (newflags == oldflags) {
83920 *pprev = vma;
83921 return 0;
83922 }
83923
83924 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83925 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83926 +
83927 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83928 + return -ENOMEM;
83929 +
83930 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83931 + return -ENOMEM;
83932 + }
83933 +
83934 /*
83935 * If we make a private mapping writable we increase our commit;
83936 * but (without finer accounting) cannot reduce our commit if we
83937 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83938 }
83939 }
83940
83941 +#ifdef CONFIG_PAX_SEGMEXEC
83942 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83943 + if (start != vma->vm_start) {
83944 + error = split_vma(mm, vma, start, 1);
83945 + if (error)
83946 + goto fail;
83947 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83948 + *pprev = (*pprev)->vm_next;
83949 + }
83950 +
83951 + if (end != vma->vm_end) {
83952 + error = split_vma(mm, vma, end, 0);
83953 + if (error)
83954 + goto fail;
83955 + }
83956 +
83957 + if (pax_find_mirror_vma(vma)) {
83958 + error = __do_munmap(mm, start_m, end_m - start_m);
83959 + if (error)
83960 + goto fail;
83961 + } else {
83962 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83963 + if (!vma_m) {
83964 + error = -ENOMEM;
83965 + goto fail;
83966 + }
83967 + vma->vm_flags = newflags;
83968 + error = pax_mirror_vma(vma_m, vma);
83969 + if (error) {
83970 + vma->vm_flags = oldflags;
83971 + goto fail;
83972 + }
83973 + }
83974 + }
83975 +#endif
83976 +
83977 /*
83978 * First try to merge with previous and/or next vma.
83979 */
83980 @@ -296,9 +399,21 @@ success:
83981 * vm_flags and vm_page_prot are protected by the mmap_sem
83982 * held in write mode.
83983 */
83984 +
83985 +#ifdef CONFIG_PAX_SEGMEXEC
83986 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83987 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83988 +#endif
83989 +
83990 vma->vm_flags = newflags;
83991 +
83992 +#ifdef CONFIG_PAX_MPROTECT
83993 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83994 + mm->binfmt->handle_mprotect(vma, newflags);
83995 +#endif
83996 +
83997 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83998 - vm_get_page_prot(newflags));
83999 + vm_get_page_prot(vma->vm_flags));
84000
84001 if (vma_wants_writenotify(vma)) {
84002 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
84003 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84004 end = start + len;
84005 if (end <= start)
84006 return -ENOMEM;
84007 +
84008 +#ifdef CONFIG_PAX_SEGMEXEC
84009 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
84010 + if (end > SEGMEXEC_TASK_SIZE)
84011 + return -EINVAL;
84012 + } else
84013 +#endif
84014 +
84015 + if (end > TASK_SIZE)
84016 + return -EINVAL;
84017 +
84018 if (!arch_validate_prot(prot))
84019 return -EINVAL;
84020
84021 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84022 /*
84023 * Does the application expect PROT_READ to imply PROT_EXEC:
84024 */
84025 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
84026 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
84027 prot |= PROT_EXEC;
84028
84029 vm_flags = calc_vm_prot_bits(prot);
84030 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84031 if (start > vma->vm_start)
84032 prev = vma;
84033
84034 +#ifdef CONFIG_PAX_MPROTECT
84035 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
84036 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
84037 +#endif
84038 +
84039 for (nstart = start ; ; ) {
84040 unsigned long newflags;
84041
84042 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84043
84044 /* newflags >> 4 shift VM_MAY% in place of VM_% */
84045 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
84046 + if (prot & (PROT_WRITE | PROT_EXEC))
84047 + gr_log_rwxmprotect(vma->vm_file);
84048 +
84049 + error = -EACCES;
84050 + goto out;
84051 + }
84052 +
84053 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
84054 error = -EACCES;
84055 goto out;
84056 }
84057 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
84058 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
84059 if (error)
84060 goto out;
84061 +
84062 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
84063 +
84064 nstart = tmp;
84065
84066 if (nstart < prev->vm_end)
84067 diff --git a/mm/mremap.c b/mm/mremap.c
84068 index e1031e1..1f2a0a1 100644
84069 --- a/mm/mremap.c
84070 +++ b/mm/mremap.c
84071 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
84072 continue;
84073 pte = ptep_get_and_clear(mm, old_addr, old_pte);
84074 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
84075 +
84076 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
84077 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
84078 + pte = pte_exprotect(pte);
84079 +#endif
84080 +
84081 set_pte_at(mm, new_addr, new_pte, pte);
84082 }
84083
84084 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
84085 if (is_vm_hugetlb_page(vma))
84086 goto Einval;
84087
84088 +#ifdef CONFIG_PAX_SEGMEXEC
84089 + if (pax_find_mirror_vma(vma))
84090 + goto Einval;
84091 +#endif
84092 +
84093 /* We can't remap across vm area boundaries */
84094 if (old_len > vma->vm_end - addr)
84095 goto Efault;
84096 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
84097 unsigned long ret = -EINVAL;
84098 unsigned long charged = 0;
84099 unsigned long map_flags;
84100 + unsigned long pax_task_size = TASK_SIZE;
84101
84102 if (new_addr & ~PAGE_MASK)
84103 goto out;
84104
84105 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
84106 +#ifdef CONFIG_PAX_SEGMEXEC
84107 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
84108 + pax_task_size = SEGMEXEC_TASK_SIZE;
84109 +#endif
84110 +
84111 + pax_task_size -= PAGE_SIZE;
84112 +
84113 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
84114 goto out;
84115
84116 /* Check if the location we're moving into overlaps the
84117 * old location at all, and fail if it does.
84118 */
84119 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
84120 - goto out;
84121 -
84122 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
84123 + if (addr + old_len > new_addr && new_addr + new_len > addr)
84124 goto out;
84125
84126 ret = do_munmap(mm, new_addr, new_len);
84127 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84128 struct vm_area_struct *vma;
84129 unsigned long ret = -EINVAL;
84130 unsigned long charged = 0;
84131 + unsigned long pax_task_size = TASK_SIZE;
84132
84133 down_write(&current->mm->mmap_sem);
84134
84135 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84136 if (!new_len)
84137 goto out;
84138
84139 +#ifdef CONFIG_PAX_SEGMEXEC
84140 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
84141 + pax_task_size = SEGMEXEC_TASK_SIZE;
84142 +#endif
84143 +
84144 + pax_task_size -= PAGE_SIZE;
84145 +
84146 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
84147 + old_len > pax_task_size || addr > pax_task_size-old_len)
84148 + goto out;
84149 +
84150 if (flags & MREMAP_FIXED) {
84151 if (flags & MREMAP_MAYMOVE)
84152 ret = mremap_to(addr, old_len, new_addr, new_len);
84153 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84154 addr + new_len);
84155 }
84156 ret = addr;
84157 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
84158 goto out;
84159 }
84160 }
84161 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
84162 goto out;
84163 }
84164
84165 + map_flags = vma->vm_flags;
84166 ret = move_vma(vma, addr, old_len, new_len, new_addr);
84167 + if (!(ret & ~PAGE_MASK)) {
84168 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
84169 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
84170 + }
84171 }
84172 out:
84173 if (ret & ~PAGE_MASK)
84174 diff --git a/mm/nommu.c b/mm/nommu.c
84175 index bbe1f3f..b2601ea 100644
84176 --- a/mm/nommu.c
84177 +++ b/mm/nommu.c
84178 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
84179 int sysctl_overcommit_ratio = 50; /* default is 50% */
84180 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
84181 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
84182 -int heap_stack_gap = 0;
84183
84184 atomic_long_t mmap_pages_allocated;
84185
84186 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
84187 EXPORT_SYMBOL(find_vma);
84188
84189 /*
84190 - * find a VMA
84191 - * - we don't extend stack VMAs under NOMMU conditions
84192 - */
84193 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
84194 -{
84195 - return find_vma(mm, addr);
84196 -}
84197 -
84198 -/*
84199 * expand a stack to a given address
84200 * - not supported under NOMMU conditions
84201 */
84202 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
84203
84204 /* most fields are the same, copy all, and then fixup */
84205 *new = *vma;
84206 + INIT_LIST_HEAD(&new->anon_vma_chain);
84207 *region = *vma->vm_region;
84208 new->vm_region = region;
84209
84210 @@ -1975,8 +1966,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
84211 }
84212 EXPORT_SYMBOL(generic_file_remap_pages);
84213
84214 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84215 - unsigned long addr, void *buf, int len, int write)
84216 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84217 + unsigned long addr, void *buf, size_t len, int write)
84218 {
84219 struct vm_area_struct *vma;
84220
84221 @@ -2017,8 +2008,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84222 *
84223 * The caller must hold a reference on @mm.
84224 */
84225 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84226 - void *buf, int len, int write)
84227 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
84228 + void *buf, size_t len, int write)
84229 {
84230 return __access_remote_vm(NULL, mm, addr, buf, len, write);
84231 }
84232 @@ -2027,7 +2018,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84233 * Access another process' address space.
84234 * - source/target buffer must be kernel space
84235 */
84236 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
84237 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
84238 {
84239 struct mm_struct *mm;
84240
84241 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
84242 index 0713bfb..b95bb87 100644
84243 --- a/mm/page-writeback.c
84244 +++ b/mm/page-writeback.c
84245 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
84246 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
84247 * - the bdi dirty thresh drops quickly due to change of JBOD workload
84248 */
84249 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
84250 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
84251 unsigned long thresh,
84252 unsigned long bg_thresh,
84253 unsigned long dirty,
84254 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
84255 }
84256 }
84257
84258 -static struct notifier_block __cpuinitdata ratelimit_nb = {
84259 +static struct notifier_block ratelimit_nb = {
84260 .notifier_call = ratelimit_handler,
84261 .next = NULL,
84262 };
84263 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
84264 index 6a83cd3..3ab04ef 100644
84265 --- a/mm/page_alloc.c
84266 +++ b/mm/page_alloc.c
84267 @@ -58,6 +58,7 @@
84268 #include <linux/prefetch.h>
84269 #include <linux/migrate.h>
84270 #include <linux/page-debug-flags.h>
84271 +#include <linux/random.h>
84272
84273 #include <asm/tlbflush.h>
84274 #include <asm/div64.h>
84275 @@ -338,7 +339,7 @@ out:
84276 * This usage means that zero-order pages may not be compound.
84277 */
84278
84279 -static void free_compound_page(struct page *page)
84280 +void free_compound_page(struct page *page)
84281 {
84282 __free_pages_ok(page, compound_order(page));
84283 }
84284 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
84285 int i;
84286 int bad = 0;
84287
84288 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
84289 + unsigned long index = 1UL << order;
84290 +#endif
84291 +
84292 trace_mm_page_free(page, order);
84293 kmemcheck_free_shadow(page, order);
84294
84295 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
84296 debug_check_no_obj_freed(page_address(page),
84297 PAGE_SIZE << order);
84298 }
84299 +
84300 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
84301 + for (; index; --index)
84302 + sanitize_highpage(page + index - 1);
84303 +#endif
84304 +
84305 arch_free_page(page, order);
84306 kernel_map_pages(page, 1 << order, 0);
84307
84308 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
84309 local_irq_restore(flags);
84310 }
84311
84312 +#ifdef CONFIG_PAX_LATENT_ENTROPY
84313 +bool __meminitdata extra_latent_entropy;
84314 +
84315 +static int __init setup_pax_extra_latent_entropy(char *str)
84316 +{
84317 + extra_latent_entropy = true;
84318 + return 0;
84319 +}
84320 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
84321 +
84322 +volatile u64 latent_entropy;
84323 +#endif
84324 +
84325 /*
84326 * Read access to zone->managed_pages is safe because it's unsigned long,
84327 * but we still need to serialize writers. Currently all callers of
84328 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
84329 set_page_count(p, 0);
84330 }
84331
84332 +#ifdef CONFIG_PAX_LATENT_ENTROPY
84333 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
84334 + u64 hash = 0;
84335 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
84336 + const u64 *data = lowmem_page_address(page);
84337 +
84338 + for (index = 0; index < end; index++)
84339 + hash ^= hash + data[index];
84340 + latent_entropy ^= hash;
84341 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
84342 + }
84343 +#endif
84344 +
84345 page_zone(page)->managed_pages += 1 << order;
84346 set_page_refcounted(page);
84347 __free_pages(page, order);
84348 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
84349 arch_alloc_page(page, order);
84350 kernel_map_pages(page, 1 << order, 1);
84351
84352 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
84353 if (gfp_flags & __GFP_ZERO)
84354 prep_zero_page(page, order, gfp_flags);
84355 +#endif
84356
84357 if (order && (gfp_flags & __GFP_COMP))
84358 prep_compound_page(page, order);
84359 @@ -3752,7 +3791,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
84360 unsigned long pfn;
84361
84362 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
84363 +#ifdef CONFIG_X86_32
84364 + /* boot failures in VMware 8 on 32bit vanilla since
84365 + this change */
84366 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
84367 +#else
84368 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
84369 +#endif
84370 return 1;
84371 }
84372 return 0;
84373 diff --git a/mm/percpu.c b/mm/percpu.c
84374 index 8c8e08f..73a5cda 100644
84375 --- a/mm/percpu.c
84376 +++ b/mm/percpu.c
84377 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
84378 static unsigned int pcpu_high_unit_cpu __read_mostly;
84379
84380 /* the address of the first chunk which starts with the kernel static area */
84381 -void *pcpu_base_addr __read_mostly;
84382 +void *pcpu_base_addr __read_only;
84383 EXPORT_SYMBOL_GPL(pcpu_base_addr);
84384
84385 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
84386 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
84387 index fd26d04..0cea1b0 100644
84388 --- a/mm/process_vm_access.c
84389 +++ b/mm/process_vm_access.c
84390 @@ -13,6 +13,7 @@
84391 #include <linux/uio.h>
84392 #include <linux/sched.h>
84393 #include <linux/highmem.h>
84394 +#include <linux/security.h>
84395 #include <linux/ptrace.h>
84396 #include <linux/slab.h>
84397 #include <linux/syscalls.h>
84398 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84399 size_t iov_l_curr_offset = 0;
84400 ssize_t iov_len;
84401
84402 + return -ENOSYS; // PaX: until properly audited
84403 +
84404 /*
84405 * Work out how many pages of struct pages we're going to need
84406 * when eventually calling get_user_pages
84407 */
84408 for (i = 0; i < riovcnt; i++) {
84409 iov_len = rvec[i].iov_len;
84410 - if (iov_len > 0) {
84411 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
84412 - + iov_len)
84413 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
84414 - / PAGE_SIZE + 1;
84415 - nr_pages = max(nr_pages, nr_pages_iov);
84416 - }
84417 + if (iov_len <= 0)
84418 + continue;
84419 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
84420 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
84421 + nr_pages = max(nr_pages, nr_pages_iov);
84422 }
84423
84424 if (nr_pages == 0)
84425 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84426 goto free_proc_pages;
84427 }
84428
84429 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
84430 + rc = -EPERM;
84431 + goto put_task_struct;
84432 + }
84433 +
84434 mm = mm_access(task, PTRACE_MODE_ATTACH);
84435 if (!mm || IS_ERR(mm)) {
84436 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
84437 diff --git a/mm/rmap.c b/mm/rmap.c
84438 index 2c78f8c..9e9c624 100644
84439 --- a/mm/rmap.c
84440 +++ b/mm/rmap.c
84441 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84442 struct anon_vma *anon_vma = vma->anon_vma;
84443 struct anon_vma_chain *avc;
84444
84445 +#ifdef CONFIG_PAX_SEGMEXEC
84446 + struct anon_vma_chain *avc_m = NULL;
84447 +#endif
84448 +
84449 might_sleep();
84450 if (unlikely(!anon_vma)) {
84451 struct mm_struct *mm = vma->vm_mm;
84452 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84453 if (!avc)
84454 goto out_enomem;
84455
84456 +#ifdef CONFIG_PAX_SEGMEXEC
84457 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
84458 + if (!avc_m)
84459 + goto out_enomem_free_avc;
84460 +#endif
84461 +
84462 anon_vma = find_mergeable_anon_vma(vma);
84463 allocated = NULL;
84464 if (!anon_vma) {
84465 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84466 /* page_table_lock to protect against threads */
84467 spin_lock(&mm->page_table_lock);
84468 if (likely(!vma->anon_vma)) {
84469 +
84470 +#ifdef CONFIG_PAX_SEGMEXEC
84471 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
84472 +
84473 + if (vma_m) {
84474 + BUG_ON(vma_m->anon_vma);
84475 + vma_m->anon_vma = anon_vma;
84476 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
84477 + avc_m = NULL;
84478 + }
84479 +#endif
84480 +
84481 vma->anon_vma = anon_vma;
84482 anon_vma_chain_link(vma, avc, anon_vma);
84483 allocated = NULL;
84484 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84485
84486 if (unlikely(allocated))
84487 put_anon_vma(allocated);
84488 +
84489 +#ifdef CONFIG_PAX_SEGMEXEC
84490 + if (unlikely(avc_m))
84491 + anon_vma_chain_free(avc_m);
84492 +#endif
84493 +
84494 if (unlikely(avc))
84495 anon_vma_chain_free(avc);
84496 }
84497 return 0;
84498
84499 out_enomem_free_avc:
84500 +
84501 +#ifdef CONFIG_PAX_SEGMEXEC
84502 + if (avc_m)
84503 + anon_vma_chain_free(avc_m);
84504 +#endif
84505 +
84506 anon_vma_chain_free(avc);
84507 out_enomem:
84508 return -ENOMEM;
84509 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
84510 * Attach the anon_vmas from src to dst.
84511 * Returns 0 on success, -ENOMEM on failure.
84512 */
84513 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84514 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
84515 {
84516 struct anon_vma_chain *avc, *pavc;
84517 struct anon_vma *root = NULL;
84518 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84519 * the corresponding VMA in the parent process is attached to.
84520 * Returns 0 on success, non-zero on failure.
84521 */
84522 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
84523 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
84524 {
84525 struct anon_vma_chain *avc;
84526 struct anon_vma *anon_vma;
84527 diff --git a/mm/shmem.c b/mm/shmem.c
84528 index efd0b3a..994b702 100644
84529 --- a/mm/shmem.c
84530 +++ b/mm/shmem.c
84531 @@ -31,7 +31,7 @@
84532 #include <linux/export.h>
84533 #include <linux/swap.h>
84534
84535 -static struct vfsmount *shm_mnt;
84536 +struct vfsmount *shm_mnt;
84537
84538 #ifdef CONFIG_SHMEM
84539 /*
84540 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
84541 #define BOGO_DIRENT_SIZE 20
84542
84543 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
84544 -#define SHORT_SYMLINK_LEN 128
84545 +#define SHORT_SYMLINK_LEN 64
84546
84547 /*
84548 * shmem_fallocate and shmem_writepage communicate via inode->i_private
84549 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
84550 static int shmem_xattr_validate(const char *name)
84551 {
84552 struct { const char *prefix; size_t len; } arr[] = {
84553 +
84554 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84555 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
84556 +#endif
84557 +
84558 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
84559 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
84560 };
84561 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
84562 if (err)
84563 return err;
84564
84565 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84566 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
84567 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
84568 + return -EOPNOTSUPP;
84569 + if (size > 8)
84570 + return -EINVAL;
84571 + }
84572 +#endif
84573 +
84574 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84575 }
84576
84577 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84578 int err = -ENOMEM;
84579
84580 /* Round up to L1_CACHE_BYTES to resist false sharing */
84581 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84582 - L1_CACHE_BYTES), GFP_KERNEL);
84583 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84584 if (!sbinfo)
84585 return -ENOMEM;
84586
84587 diff --git a/mm/slab.c b/mm/slab.c
84588 index e7667a3..a48e73b 100644
84589 --- a/mm/slab.c
84590 +++ b/mm/slab.c
84591 @@ -306,7 +306,7 @@ struct kmem_list3 {
84592 * Need this for bootstrapping a per node allocator.
84593 */
84594 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
84595 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
84596 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
84597 #define CACHE_CACHE 0
84598 #define SIZE_AC MAX_NUMNODES
84599 #define SIZE_L3 (2 * MAX_NUMNODES)
84600 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
84601 if ((x)->max_freeable < i) \
84602 (x)->max_freeable = i; \
84603 } while (0)
84604 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84605 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84606 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84607 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84608 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84609 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84610 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84611 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84612 #else
84613 #define STATS_INC_ACTIVE(x) do { } while (0)
84614 #define STATS_DEC_ACTIVE(x) do { } while (0)
84615 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84616 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84617 */
84618 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84619 - const struct slab *slab, void *obj)
84620 + const struct slab *slab, const void *obj)
84621 {
84622 u32 offset = (obj - slab->s_mem);
84623 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84624 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
84625 struct cache_names {
84626 char *name;
84627 char *name_dma;
84628 + char *name_usercopy;
84629 };
84630
84631 static struct cache_names __initdata cache_names[] = {
84632 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
84633 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
84634 #include <linux/kmalloc_sizes.h>
84635 - {NULL,}
84636 + {NULL}
84637 #undef CACHE
84638 };
84639
84640 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
84641 if (unlikely(gfpflags & GFP_DMA))
84642 return csizep->cs_dmacachep;
84643 #endif
84644 +
84645 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84646 + if (unlikely(gfpflags & GFP_USERCOPY))
84647 + return csizep->cs_usercopycachep;
84648 +#endif
84649 +
84650 return csizep->cs_cachep;
84651 }
84652
84653 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84654 return notifier_from_errno(err);
84655 }
84656
84657 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84658 +static struct notifier_block cpucache_notifier = {
84659 &cpuup_callback, NULL, 0
84660 };
84661
84662 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
84663 */
84664
84665 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
84666 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
84667 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84668
84669 if (INDEX_AC != INDEX_L3)
84670 sizes[INDEX_L3].cs_cachep =
84671 create_kmalloc_cache(names[INDEX_L3].name,
84672 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
84673 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84674
84675 slab_early_init = 0;
84676
84677 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
84678 */
84679 if (!sizes->cs_cachep)
84680 sizes->cs_cachep = create_kmalloc_cache(names->name,
84681 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
84682 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84683
84684 #ifdef CONFIG_ZONE_DMA
84685 sizes->cs_dmacachep = create_kmalloc_cache(
84686 names->name_dma, sizes->cs_size,
84687 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84688 #endif
84689 +
84690 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84691 + sizes->cs_usercopycachep = create_kmalloc_cache(
84692 + names->name_usercopy, sizes->cs_size,
84693 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84694 +#endif
84695 +
84696 sizes++;
84697 names++;
84698 }
84699 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84700
84701 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84702 return;
84703 + VM_BUG_ON(!virt_addr_valid(objp));
84704 local_irq_save(flags);
84705 kfree_debugcheck(objp);
84706 c = virt_to_cache(objp);
84707 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84708 }
84709 /* cpu stats */
84710 {
84711 - unsigned long allochit = atomic_read(&cachep->allochit);
84712 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84713 - unsigned long freehit = atomic_read(&cachep->freehit);
84714 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84715 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84716 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84717 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84718 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84719
84720 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84721 allochit, allocmiss, freehit, freemiss);
84722 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84723 static int __init slab_proc_init(void)
84724 {
84725 #ifdef CONFIG_DEBUG_SLAB_LEAK
84726 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84727 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84728 #endif
84729 return 0;
84730 }
84731 module_init(slab_proc_init);
84732 #endif
84733
84734 +bool is_usercopy_object(const void *ptr)
84735 +{
84736 + struct page *page;
84737 + struct kmem_cache *cachep;
84738 +
84739 + if (ZERO_OR_NULL_PTR(ptr))
84740 + return false;
84741 +
84742 + if (!slab_is_available())
84743 + return false;
84744 +
84745 + if (!virt_addr_valid(ptr))
84746 + return false;
84747 +
84748 + page = virt_to_head_page(ptr);
84749 +
84750 + if (!PageSlab(page))
84751 + return false;
84752 +
84753 + cachep = page->slab_cache;
84754 + return cachep->flags & SLAB_USERCOPY;
84755 +}
84756 +
84757 +#ifdef CONFIG_PAX_USERCOPY
84758 +const char *check_heap_object(const void *ptr, unsigned long n)
84759 +{
84760 + struct page *page;
84761 + struct kmem_cache *cachep;
84762 + struct slab *slabp;
84763 + unsigned int objnr;
84764 + unsigned long offset;
84765 +
84766 + if (ZERO_OR_NULL_PTR(ptr))
84767 + return "<null>";
84768 +
84769 + if (!virt_addr_valid(ptr))
84770 + return NULL;
84771 +
84772 + page = virt_to_head_page(ptr);
84773 +
84774 + if (!PageSlab(page))
84775 + return NULL;
84776 +
84777 + cachep = page->slab_cache;
84778 + if (!(cachep->flags & SLAB_USERCOPY))
84779 + return cachep->name;
84780 +
84781 + slabp = page->slab_page;
84782 + objnr = obj_to_index(cachep, slabp, ptr);
84783 + BUG_ON(objnr >= cachep->num);
84784 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84785 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84786 + return NULL;
84787 +
84788 + return cachep->name;
84789 +}
84790 +#endif
84791 +
84792 /**
84793 * ksize - get the actual amount of memory allocated for a given object
84794 * @objp: Pointer to the object
84795 diff --git a/mm/slab.h b/mm/slab.h
84796 index 34a98d6..73633d1 100644
84797 --- a/mm/slab.h
84798 +++ b/mm/slab.h
84799 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84800
84801 /* Legal flag mask for kmem_cache_create(), for various configurations */
84802 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84803 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84804 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84805
84806 #if defined(CONFIG_DEBUG_SLAB)
84807 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84808 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84809 return s;
84810
84811 page = virt_to_head_page(x);
84812 +
84813 + BUG_ON(!PageSlab(page));
84814 +
84815 cachep = page->slab_cache;
84816 if (slab_equal_or_root(cachep, s))
84817 return cachep;
84818 diff --git a/mm/slab_common.c b/mm/slab_common.c
84819 index 3f3cd97..93b0236 100644
84820 --- a/mm/slab_common.c
84821 +++ b/mm/slab_common.c
84822 @@ -22,7 +22,7 @@
84823
84824 #include "slab.h"
84825
84826 -enum slab_state slab_state;
84827 +enum slab_state slab_state __read_only;
84828 LIST_HEAD(slab_caches);
84829 DEFINE_MUTEX(slab_mutex);
84830 struct kmem_cache *kmem_cache;
84831 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84832
84833 err = __kmem_cache_create(s, flags);
84834 if (!err) {
84835 - s->refcount = 1;
84836 + atomic_set(&s->refcount, 1);
84837 list_add(&s->list, &slab_caches);
84838 memcg_cache_list_add(memcg, s);
84839 } else {
84840 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84841
84842 get_online_cpus();
84843 mutex_lock(&slab_mutex);
84844 - s->refcount--;
84845 - if (!s->refcount) {
84846 + if (atomic_dec_and_test(&s->refcount)) {
84847 list_del(&s->list);
84848
84849 if (!__kmem_cache_shutdown(s)) {
84850 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84851 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84852 name, size, err);
84853
84854 - s->refcount = -1; /* Exempt from merging for now */
84855 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84856 }
84857
84858 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84859 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84860
84861 create_boot_cache(s, name, size, flags);
84862 list_add(&s->list, &slab_caches);
84863 - s->refcount = 1;
84864 + atomic_set(&s->refcount, 1);
84865 return s;
84866 }
84867
84868 diff --git a/mm/slob.c b/mm/slob.c
84869 index a99fdf7..6ee34ec 100644
84870 --- a/mm/slob.c
84871 +++ b/mm/slob.c
84872 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84873 /*
84874 * Return the size of a slob block.
84875 */
84876 -static slobidx_t slob_units(slob_t *s)
84877 +static slobidx_t slob_units(const slob_t *s)
84878 {
84879 if (s->units > 0)
84880 return s->units;
84881 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84882 /*
84883 * Return the next free slob block pointer after this one.
84884 */
84885 -static slob_t *slob_next(slob_t *s)
84886 +static slob_t *slob_next(const slob_t *s)
84887 {
84888 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84889 slobidx_t next;
84890 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84891 /*
84892 * Returns true if s is the last free block in its page.
84893 */
84894 -static int slob_last(slob_t *s)
84895 +static int slob_last(const slob_t *s)
84896 {
84897 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84898 }
84899
84900 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84901 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84902 {
84903 - void *page;
84904 + struct page *page;
84905
84906 #ifdef CONFIG_NUMA
84907 if (node != NUMA_NO_NODE)
84908 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84909 if (!page)
84910 return NULL;
84911
84912 - return page_address(page);
84913 + __SetPageSlab(page);
84914 + return page;
84915 }
84916
84917 -static void slob_free_pages(void *b, int order)
84918 +static void slob_free_pages(struct page *sp, int order)
84919 {
84920 if (current->reclaim_state)
84921 current->reclaim_state->reclaimed_slab += 1 << order;
84922 - free_pages((unsigned long)b, order);
84923 + __ClearPageSlab(sp);
84924 + reset_page_mapcount(sp);
84925 + sp->private = 0;
84926 + __free_pages(sp, order);
84927 }
84928
84929 /*
84930 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84931
84932 /* Not enough space: must allocate a new page */
84933 if (!b) {
84934 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84935 - if (!b)
84936 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84937 + if (!sp)
84938 return NULL;
84939 - sp = virt_to_page(b);
84940 - __SetPageSlab(sp);
84941 + b = page_address(sp);
84942
84943 spin_lock_irqsave(&slob_lock, flags);
84944 sp->units = SLOB_UNITS(PAGE_SIZE);
84945 sp->freelist = b;
84946 + sp->private = 0;
84947 INIT_LIST_HEAD(&sp->list);
84948 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84949 set_slob_page_free(sp, slob_list);
84950 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84951 if (slob_page_free(sp))
84952 clear_slob_page_free(sp);
84953 spin_unlock_irqrestore(&slob_lock, flags);
84954 - __ClearPageSlab(sp);
84955 - reset_page_mapcount(sp);
84956 - slob_free_pages(b, 0);
84957 + slob_free_pages(sp, 0);
84958 return;
84959 }
84960
84961 @@ -424,11 +426,10 @@ out:
84962 */
84963
84964 static __always_inline void *
84965 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84966 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84967 {
84968 - unsigned int *m;
84969 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84970 - void *ret;
84971 + slob_t *m;
84972 + void *ret = NULL;
84973
84974 gfp &= gfp_allowed_mask;
84975
84976 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84977
84978 if (!m)
84979 return NULL;
84980 - *m = size;
84981 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84982 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84983 + m[0].units = size;
84984 + m[1].units = align;
84985 ret = (void *)m + align;
84986
84987 trace_kmalloc_node(caller, ret,
84988 size, size + align, gfp, node);
84989 } else {
84990 unsigned int order = get_order(size);
84991 + struct page *page;
84992
84993 if (likely(order))
84994 gfp |= __GFP_COMP;
84995 - ret = slob_new_pages(gfp, order, node);
84996 + page = slob_new_pages(gfp, order, node);
84997 + if (page) {
84998 + ret = page_address(page);
84999 + page->private = size;
85000 + }
85001
85002 trace_kmalloc_node(caller, ret,
85003 size, PAGE_SIZE << order, gfp, node);
85004 }
85005
85006 - kmemleak_alloc(ret, size, 1, gfp);
85007 + return ret;
85008 +}
85009 +
85010 +static __always_inline void *
85011 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
85012 +{
85013 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85014 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
85015 +
85016 + if (!ZERO_OR_NULL_PTR(ret))
85017 + kmemleak_alloc(ret, size, 1, gfp);
85018 return ret;
85019 }
85020
85021 @@ -493,34 +512,112 @@ void kfree(const void *block)
85022 return;
85023 kmemleak_free(block);
85024
85025 + VM_BUG_ON(!virt_addr_valid(block));
85026 sp = virt_to_page(block);
85027 - if (PageSlab(sp)) {
85028 + VM_BUG_ON(!PageSlab(sp));
85029 + if (!sp->private) {
85030 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85031 - unsigned int *m = (unsigned int *)(block - align);
85032 - slob_free(m, *m + align);
85033 - } else
85034 + slob_t *m = (slob_t *)(block - align);
85035 + slob_free(m, m[0].units + align);
85036 + } else {
85037 + __ClearPageSlab(sp);
85038 + reset_page_mapcount(sp);
85039 + sp->private = 0;
85040 __free_pages(sp, compound_order(sp));
85041 + }
85042 }
85043 EXPORT_SYMBOL(kfree);
85044
85045 +bool is_usercopy_object(const void *ptr)
85046 +{
85047 + if (!slab_is_available())
85048 + return false;
85049 +
85050 + // PAX: TODO
85051 +
85052 + return false;
85053 +}
85054 +
85055 +#ifdef CONFIG_PAX_USERCOPY
85056 +const char *check_heap_object(const void *ptr, unsigned long n)
85057 +{
85058 + struct page *page;
85059 + const slob_t *free;
85060 + const void *base;
85061 + unsigned long flags;
85062 +
85063 + if (ZERO_OR_NULL_PTR(ptr))
85064 + return "<null>";
85065 +
85066 + if (!virt_addr_valid(ptr))
85067 + return NULL;
85068 +
85069 + page = virt_to_head_page(ptr);
85070 + if (!PageSlab(page))
85071 + return NULL;
85072 +
85073 + if (page->private) {
85074 + base = page;
85075 + if (base <= ptr && n <= page->private - (ptr - base))
85076 + return NULL;
85077 + return "<slob>";
85078 + }
85079 +
85080 + /* some tricky double walking to find the chunk */
85081 + spin_lock_irqsave(&slob_lock, flags);
85082 + base = (void *)((unsigned long)ptr & PAGE_MASK);
85083 + free = page->freelist;
85084 +
85085 + while (!slob_last(free) && (void *)free <= ptr) {
85086 + base = free + slob_units(free);
85087 + free = slob_next(free);
85088 + }
85089 +
85090 + while (base < (void *)free) {
85091 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
85092 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
85093 + int offset;
85094 +
85095 + if (ptr < base + align)
85096 + break;
85097 +
85098 + offset = ptr - base - align;
85099 + if (offset >= m) {
85100 + base += size;
85101 + continue;
85102 + }
85103 +
85104 + if (n > m - offset)
85105 + break;
85106 +
85107 + spin_unlock_irqrestore(&slob_lock, flags);
85108 + return NULL;
85109 + }
85110 +
85111 + spin_unlock_irqrestore(&slob_lock, flags);
85112 + return "<slob>";
85113 +}
85114 +#endif
85115 +
85116 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
85117 size_t ksize(const void *block)
85118 {
85119 struct page *sp;
85120 int align;
85121 - unsigned int *m;
85122 + slob_t *m;
85123
85124 BUG_ON(!block);
85125 if (unlikely(block == ZERO_SIZE_PTR))
85126 return 0;
85127
85128 sp = virt_to_page(block);
85129 - if (unlikely(!PageSlab(sp)))
85130 - return PAGE_SIZE << compound_order(sp);
85131 + VM_BUG_ON(!PageSlab(sp));
85132 + if (sp->private)
85133 + return sp->private;
85134
85135 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
85136 - m = (unsigned int *)(block - align);
85137 - return SLOB_UNITS(*m) * SLOB_UNIT;
85138 + m = (slob_t *)(block - align);
85139 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
85140 }
85141 EXPORT_SYMBOL(ksize);
85142
85143 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
85144
85145 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
85146 {
85147 - void *b;
85148 + void *b = NULL;
85149
85150 flags &= gfp_allowed_mask;
85151
85152 lockdep_trace_alloc(flags);
85153
85154 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85155 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
85156 +#else
85157 if (c->size < PAGE_SIZE) {
85158 b = slob_alloc(c->size, flags, c->align, node);
85159 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
85160 SLOB_UNITS(c->size) * SLOB_UNIT,
85161 flags, node);
85162 } else {
85163 - b = slob_new_pages(flags, get_order(c->size), node);
85164 + struct page *sp;
85165 +
85166 + sp = slob_new_pages(flags, get_order(c->size), node);
85167 + if (sp) {
85168 + b = page_address(sp);
85169 + sp->private = c->size;
85170 + }
85171 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
85172 PAGE_SIZE << get_order(c->size),
85173 flags, node);
85174 }
85175 +#endif
85176
85177 if (c->ctor)
85178 c->ctor(b);
85179 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
85180
85181 static void __kmem_cache_free(void *b, int size)
85182 {
85183 - if (size < PAGE_SIZE)
85184 + struct page *sp;
85185 +
85186 + sp = virt_to_page(b);
85187 + BUG_ON(!PageSlab(sp));
85188 + if (!sp->private)
85189 slob_free(b, size);
85190 else
85191 - slob_free_pages(b, get_order(size));
85192 + slob_free_pages(sp, get_order(size));
85193 }
85194
85195 static void kmem_rcu_free(struct rcu_head *head)
85196 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
85197
85198 void kmem_cache_free(struct kmem_cache *c, void *b)
85199 {
85200 + int size = c->size;
85201 +
85202 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85203 + if (size + c->align < PAGE_SIZE) {
85204 + size += c->align;
85205 + b -= c->align;
85206 + }
85207 +#endif
85208 +
85209 kmemleak_free_recursive(b, c->flags);
85210 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
85211 struct slob_rcu *slob_rcu;
85212 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
85213 - slob_rcu->size = c->size;
85214 + slob_rcu = b + (size - sizeof(struct slob_rcu));
85215 + slob_rcu->size = size;
85216 call_rcu(&slob_rcu->head, kmem_rcu_free);
85217 } else {
85218 - __kmem_cache_free(b, c->size);
85219 + __kmem_cache_free(b, size);
85220 }
85221
85222 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85223 + trace_kfree(_RET_IP_, b);
85224 +#else
85225 trace_kmem_cache_free(_RET_IP_, b);
85226 +#endif
85227 +
85228 }
85229 EXPORT_SYMBOL(kmem_cache_free);
85230
85231 diff --git a/mm/slub.c b/mm/slub.c
85232 index ba2ca53..991c4f7 100644
85233 --- a/mm/slub.c
85234 +++ b/mm/slub.c
85235 @@ -197,7 +197,7 @@ struct track {
85236
85237 enum track_item { TRACK_ALLOC, TRACK_FREE };
85238
85239 -#ifdef CONFIG_SYSFS
85240 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85241 static int sysfs_slab_add(struct kmem_cache *);
85242 static int sysfs_slab_alias(struct kmem_cache *, const char *);
85243 static void sysfs_slab_remove(struct kmem_cache *);
85244 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
85245 if (!t->addr)
85246 return;
85247
85248 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
85249 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
85250 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
85251 #ifdef CONFIG_STACKTRACE
85252 {
85253 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
85254 * Merge control. If this is set then no merging of slab caches will occur.
85255 * (Could be removed. This was introduced to pacify the merge skeptics.)
85256 */
85257 -static int slub_nomerge;
85258 +static int slub_nomerge = 1;
85259
85260 /*
85261 * Calculate the order of allocation given an slab object size.
85262 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
85263 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
85264 #endif
85265
85266 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85267 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
85268 +#endif
85269 +
85270 static int __init setup_slub_min_order(char *str)
85271 {
85272 get_option(&str, &slub_min_order);
85273 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
85274 return kmalloc_dma_caches[index];
85275
85276 #endif
85277 +
85278 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85279 + if (flags & SLAB_USERCOPY)
85280 + return kmalloc_usercopy_caches[index];
85281 +
85282 +#endif
85283 +
85284 return kmalloc_caches[index];
85285 }
85286
85287 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
85288 EXPORT_SYMBOL(__kmalloc_node);
85289 #endif
85290
85291 +bool is_usercopy_object(const void *ptr)
85292 +{
85293 + struct page *page;
85294 + struct kmem_cache *s;
85295 +
85296 + if (ZERO_OR_NULL_PTR(ptr))
85297 + return false;
85298 +
85299 + if (!slab_is_available())
85300 + return false;
85301 +
85302 + if (!virt_addr_valid(ptr))
85303 + return false;
85304 +
85305 + page = virt_to_head_page(ptr);
85306 +
85307 + if (!PageSlab(page))
85308 + return false;
85309 +
85310 + s = page->slab_cache;
85311 + return s->flags & SLAB_USERCOPY;
85312 +}
85313 +
85314 +#ifdef CONFIG_PAX_USERCOPY
85315 +const char *check_heap_object(const void *ptr, unsigned long n)
85316 +{
85317 + struct page *page;
85318 + struct kmem_cache *s;
85319 + unsigned long offset;
85320 +
85321 + if (ZERO_OR_NULL_PTR(ptr))
85322 + return "<null>";
85323 +
85324 + if (!virt_addr_valid(ptr))
85325 + return NULL;
85326 +
85327 + page = virt_to_head_page(ptr);
85328 +
85329 + if (!PageSlab(page))
85330 + return NULL;
85331 +
85332 + s = page->slab_cache;
85333 + if (!(s->flags & SLAB_USERCOPY))
85334 + return s->name;
85335 +
85336 + offset = (ptr - page_address(page)) % s->size;
85337 + if (offset <= s->object_size && n <= s->object_size - offset)
85338 + return NULL;
85339 +
85340 + return s->name;
85341 +}
85342 +#endif
85343 +
85344 size_t ksize(const void *object)
85345 {
85346 struct page *page;
85347 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
85348 if (unlikely(ZERO_OR_NULL_PTR(x)))
85349 return;
85350
85351 + VM_BUG_ON(!virt_addr_valid(x));
85352 page = virt_to_head_page(x);
85353 if (unlikely(!PageSlab(page))) {
85354 BUG_ON(!PageCompound(page));
85355 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
85356
85357 /* Caches that are not of the two-to-the-power-of size */
85358 if (KMALLOC_MIN_SIZE <= 32) {
85359 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
85360 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
85361 caches++;
85362 }
85363
85364 if (KMALLOC_MIN_SIZE <= 64) {
85365 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
85366 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
85367 caches++;
85368 }
85369
85370 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
85371 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
85372 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
85373 caches++;
85374 }
85375
85376 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
85377 }
85378 }
85379 #endif
85380 +
85381 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85382 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
85383 + struct kmem_cache *s = kmalloc_caches[i];
85384 +
85385 + if (s && s->size) {
85386 + char *name = kasprintf(GFP_NOWAIT,
85387 + "usercopy-kmalloc-%d", s->object_size);
85388 +
85389 + BUG_ON(!name);
85390 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
85391 + s->object_size, SLAB_USERCOPY);
85392 + }
85393 + }
85394 +#endif
85395 +
85396 printk(KERN_INFO
85397 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
85398 " CPUs=%d, Nodes=%d\n",
85399 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
85400 /*
85401 * We may have set a slab to be unmergeable during bootstrap.
85402 */
85403 - if (s->refcount < 0)
85404 + if (atomic_read(&s->refcount) < 0)
85405 return 1;
85406
85407 return 0;
85408 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85409
85410 s = find_mergeable(memcg, size, align, flags, name, ctor);
85411 if (s) {
85412 - s->refcount++;
85413 + atomic_inc(&s->refcount);
85414 /*
85415 * Adjust the object sizes so that we clear
85416 * the complete object on kzalloc.
85417 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85418 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
85419
85420 if (sysfs_slab_alias(s, name)) {
85421 - s->refcount--;
85422 + atomic_dec(&s->refcount);
85423 s = NULL;
85424 }
85425 }
85426 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
85427 return NOTIFY_OK;
85428 }
85429
85430 -static struct notifier_block __cpuinitdata slab_notifier = {
85431 +static struct notifier_block slab_notifier = {
85432 .notifier_call = slab_cpuup_callback
85433 };
85434
85435 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
85436 }
85437 #endif
85438
85439 -#ifdef CONFIG_SYSFS
85440 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85441 static int count_inuse(struct page *page)
85442 {
85443 return page->inuse;
85444 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
85445 validate_slab_cache(kmalloc_caches[9]);
85446 }
85447 #else
85448 -#ifdef CONFIG_SYSFS
85449 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85450 static void resiliency_test(void) {};
85451 #endif
85452 #endif
85453
85454 -#ifdef CONFIG_SYSFS
85455 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85456 enum slab_stat_type {
85457 SL_ALL, /* All slabs */
85458 SL_PARTIAL, /* Only partially allocated slabs */
85459 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
85460
85461 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
85462 {
85463 - return sprintf(buf, "%d\n", s->refcount - 1);
85464 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
85465 }
85466 SLAB_ATTR_RO(aliases);
85467
85468 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
85469 return name;
85470 }
85471
85472 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85473 static int sysfs_slab_add(struct kmem_cache *s)
85474 {
85475 int err;
85476 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
85477 kobject_del(&s->kobj);
85478 kobject_put(&s->kobj);
85479 }
85480 +#endif
85481
85482 /*
85483 * Need to buffer aliases during bootup until sysfs becomes
85484 @@ -5336,6 +5419,7 @@ struct saved_alias {
85485
85486 static struct saved_alias *alias_list;
85487
85488 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85489 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85490 {
85491 struct saved_alias *al;
85492 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85493 alias_list = al;
85494 return 0;
85495 }
85496 +#endif
85497
85498 static int __init slab_sysfs_init(void)
85499 {
85500 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
85501 index 1b7e22a..3fcd4f3 100644
85502 --- a/mm/sparse-vmemmap.c
85503 +++ b/mm/sparse-vmemmap.c
85504 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
85505 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85506 if (!p)
85507 return NULL;
85508 - pud_populate(&init_mm, pud, p);
85509 + pud_populate_kernel(&init_mm, pud, p);
85510 }
85511 return pud;
85512 }
85513 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
85514 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85515 if (!p)
85516 return NULL;
85517 - pgd_populate(&init_mm, pgd, p);
85518 + pgd_populate_kernel(&init_mm, pgd, p);
85519 }
85520 return pgd;
85521 }
85522 diff --git a/mm/sparse.c b/mm/sparse.c
85523 index 6b5fb76..db0c190 100644
85524 --- a/mm/sparse.c
85525 +++ b/mm/sparse.c
85526 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
85527
85528 for (i = 0; i < PAGES_PER_SECTION; i++) {
85529 if (PageHWPoison(&memmap[i])) {
85530 - atomic_long_sub(1, &mce_bad_pages);
85531 + atomic_long_sub_unchecked(1, &mce_bad_pages);
85532 ClearPageHWPoison(&memmap[i]);
85533 }
85534 }
85535 diff --git a/mm/swap.c b/mm/swap.c
85536 index 6310dc2..3662b3f 100644
85537 --- a/mm/swap.c
85538 +++ b/mm/swap.c
85539 @@ -30,6 +30,7 @@
85540 #include <linux/backing-dev.h>
85541 #include <linux/memcontrol.h>
85542 #include <linux/gfp.h>
85543 +#include <linux/hugetlb.h>
85544
85545 #include "internal.h"
85546
85547 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
85548
85549 __page_cache_release(page);
85550 dtor = get_compound_page_dtor(page);
85551 + if (!PageHuge(page))
85552 + BUG_ON(dtor != free_compound_page);
85553 (*dtor)(page);
85554 }
85555
85556 diff --git a/mm/swapfile.c b/mm/swapfile.c
85557 index e97a0e5..b50e796 100644
85558 --- a/mm/swapfile.c
85559 +++ b/mm/swapfile.c
85560 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
85561
85562 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
85563 /* Activity counter to indicate that a swapon or swapoff has occurred */
85564 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
85565 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
85566
85567 static inline unsigned char swap_count(unsigned char ent)
85568 {
85569 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
85570 }
85571 filp_close(swap_file, NULL);
85572 err = 0;
85573 - atomic_inc(&proc_poll_event);
85574 + atomic_inc_unchecked(&proc_poll_event);
85575 wake_up_interruptible(&proc_poll_wait);
85576
85577 out_dput:
85578 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85579
85580 poll_wait(file, &proc_poll_wait, wait);
85581
85582 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85583 - seq->poll_event = atomic_read(&proc_poll_event);
85584 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85585 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85586 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85587 }
85588
85589 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85590 return ret;
85591
85592 seq = file->private_data;
85593 - seq->poll_event = atomic_read(&proc_poll_event);
85594 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85595 return 0;
85596 }
85597
85598 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85599 (frontswap_map) ? "FS" : "");
85600
85601 mutex_unlock(&swapon_mutex);
85602 - atomic_inc(&proc_poll_event);
85603 + atomic_inc_unchecked(&proc_poll_event);
85604 wake_up_interruptible(&proc_poll_wait);
85605
85606 if (S_ISREG(inode->i_mode))
85607 diff --git a/mm/util.c b/mm/util.c
85608 index c55e26b..3f913a9 100644
85609 --- a/mm/util.c
85610 +++ b/mm/util.c
85611 @@ -292,6 +292,12 @@ done:
85612 void arch_pick_mmap_layout(struct mm_struct *mm)
85613 {
85614 mm->mmap_base = TASK_UNMAPPED_BASE;
85615 +
85616 +#ifdef CONFIG_PAX_RANDMMAP
85617 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85618 + mm->mmap_base += mm->delta_mmap;
85619 +#endif
85620 +
85621 mm->get_unmapped_area = arch_get_unmapped_area;
85622 mm->unmap_area = arch_unmap_area;
85623 }
85624 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85625 index 5123a16..f234a48 100644
85626 --- a/mm/vmalloc.c
85627 +++ b/mm/vmalloc.c
85628 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85629
85630 pte = pte_offset_kernel(pmd, addr);
85631 do {
85632 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85633 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85634 +
85635 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85636 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85637 + BUG_ON(!pte_exec(*pte));
85638 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85639 + continue;
85640 + }
85641 +#endif
85642 +
85643 + {
85644 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85645 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85646 + }
85647 } while (pte++, addr += PAGE_SIZE, addr != end);
85648 }
85649
85650 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85651 pte = pte_alloc_kernel(pmd, addr);
85652 if (!pte)
85653 return -ENOMEM;
85654 +
85655 + pax_open_kernel();
85656 do {
85657 struct page *page = pages[*nr];
85658
85659 - if (WARN_ON(!pte_none(*pte)))
85660 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85661 + if (pgprot_val(prot) & _PAGE_NX)
85662 +#endif
85663 +
85664 + if (!pte_none(*pte)) {
85665 + pax_close_kernel();
85666 + WARN_ON(1);
85667 return -EBUSY;
85668 - if (WARN_ON(!page))
85669 + }
85670 + if (!page) {
85671 + pax_close_kernel();
85672 + WARN_ON(1);
85673 return -ENOMEM;
85674 + }
85675 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85676 (*nr)++;
85677 } while (pte++, addr += PAGE_SIZE, addr != end);
85678 + pax_close_kernel();
85679 return 0;
85680 }
85681
85682 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85683 pmd_t *pmd;
85684 unsigned long next;
85685
85686 - pmd = pmd_alloc(&init_mm, pud, addr);
85687 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85688 if (!pmd)
85689 return -ENOMEM;
85690 do {
85691 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85692 pud_t *pud;
85693 unsigned long next;
85694
85695 - pud = pud_alloc(&init_mm, pgd, addr);
85696 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85697 if (!pud)
85698 return -ENOMEM;
85699 do {
85700 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
85701 * and fall back on vmalloc() if that fails. Others
85702 * just put it in the vmalloc space.
85703 */
85704 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
85705 +#ifdef CONFIG_MODULES
85706 +#ifdef MODULES_VADDR
85707 unsigned long addr = (unsigned long)x;
85708 if (addr >= MODULES_VADDR && addr < MODULES_END)
85709 return 1;
85710 #endif
85711 +
85712 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85713 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85714 + return 1;
85715 +#endif
85716 +
85717 +#endif
85718 +
85719 return is_vmalloc_addr(x);
85720 }
85721
85722 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85723
85724 if (!pgd_none(*pgd)) {
85725 pud_t *pud = pud_offset(pgd, addr);
85726 +#ifdef CONFIG_X86
85727 + if (!pud_large(*pud))
85728 +#endif
85729 if (!pud_none(*pud)) {
85730 pmd_t *pmd = pmd_offset(pud, addr);
85731 +#ifdef CONFIG_X86
85732 + if (!pmd_large(*pmd))
85733 +#endif
85734 if (!pmd_none(*pmd)) {
85735 pte_t *ptep, pte;
85736
85737 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
85738 * Allocate a region of KVA of the specified size and alignment, within the
85739 * vstart and vend.
85740 */
85741 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85742 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85743 unsigned long align,
85744 unsigned long vstart, unsigned long vend,
85745 int node, gfp_t gfp_mask)
85746 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85747 struct vm_struct *area;
85748
85749 BUG_ON(in_interrupt());
85750 +
85751 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85752 + if (flags & VM_KERNEXEC) {
85753 + if (start != VMALLOC_START || end != VMALLOC_END)
85754 + return NULL;
85755 + start = (unsigned long)MODULES_EXEC_VADDR;
85756 + end = (unsigned long)MODULES_EXEC_END;
85757 + }
85758 +#endif
85759 +
85760 if (flags & VM_IOREMAP) {
85761 int bit = fls(size);
85762
85763 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
85764 if (count > totalram_pages)
85765 return NULL;
85766
85767 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85768 + if (!(pgprot_val(prot) & _PAGE_NX))
85769 + flags |= VM_KERNEXEC;
85770 +#endif
85771 +
85772 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85773 __builtin_return_address(0));
85774 if (!area)
85775 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85776 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85777 goto fail;
85778
85779 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85780 + if (!(pgprot_val(prot) & _PAGE_NX))
85781 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85782 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85783 + else
85784 +#endif
85785 +
85786 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85787 start, end, node, gfp_mask, caller);
85788 if (!area)
85789 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
85790 * For tight control over page level allocator and protection flags
85791 * use __vmalloc() instead.
85792 */
85793 -
85794 void *vmalloc_exec(unsigned long size)
85795 {
85796 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85797 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85798 -1, __builtin_return_address(0));
85799 }
85800
85801 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85802 unsigned long uaddr = vma->vm_start;
85803 unsigned long usize = vma->vm_end - vma->vm_start;
85804
85805 + BUG_ON(vma->vm_mirror);
85806 +
85807 if ((PAGE_SIZE-1) & (unsigned long)addr)
85808 return -EINVAL;
85809
85810 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
85811 v->addr, v->addr + v->size, v->size);
85812
85813 if (v->caller)
85814 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85815 + seq_printf(m, " %pK", v->caller);
85816 +#else
85817 seq_printf(m, " %pS", v->caller);
85818 +#endif
85819
85820 if (v->nr_pages)
85821 seq_printf(m, " pages=%d", v->nr_pages);
85822 diff --git a/mm/vmstat.c b/mm/vmstat.c
85823 index 9800306..76b4b27 100644
85824 --- a/mm/vmstat.c
85825 +++ b/mm/vmstat.c
85826 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85827 *
85828 * vm_stat contains the global counters
85829 */
85830 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85831 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85832 EXPORT_SYMBOL(vm_stat);
85833
85834 #ifdef CONFIG_SMP
85835 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85836 v = p->vm_stat_diff[i];
85837 p->vm_stat_diff[i] = 0;
85838 local_irq_restore(flags);
85839 - atomic_long_add(v, &zone->vm_stat[i]);
85840 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85841 global_diff[i] += v;
85842 #ifdef CONFIG_NUMA
85843 /* 3 seconds idle till flush */
85844 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85845
85846 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85847 if (global_diff[i])
85848 - atomic_long_add(global_diff[i], &vm_stat[i]);
85849 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85850 }
85851
85852 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85853 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85854 if (pset->vm_stat_diff[i]) {
85855 int v = pset->vm_stat_diff[i];
85856 pset->vm_stat_diff[i] = 0;
85857 - atomic_long_add(v, &zone->vm_stat[i]);
85858 - atomic_long_add(v, &vm_stat[i]);
85859 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85860 + atomic_long_add_unchecked(v, &vm_stat[i]);
85861 }
85862 }
85863 #endif
85864 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85865 return NOTIFY_OK;
85866 }
85867
85868 -static struct notifier_block __cpuinitdata vmstat_notifier =
85869 +static struct notifier_block vmstat_notifier =
85870 { &vmstat_cpuup_callback, NULL, 0 };
85871 #endif
85872
85873 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
85874 start_cpu_timer(cpu);
85875 #endif
85876 #ifdef CONFIG_PROC_FS
85877 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85878 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85879 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85880 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85881 + {
85882 + mode_t gr_mode = S_IRUGO;
85883 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85884 + gr_mode = S_IRUSR;
85885 +#endif
85886 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85887 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85888 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85889 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85890 +#else
85891 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85892 +#endif
85893 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85894 + }
85895 #endif
85896 return 0;
85897 }
85898 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85899 index acc74ad..be02639 100644
85900 --- a/net/8021q/vlan.c
85901 +++ b/net/8021q/vlan.c
85902 @@ -108,6 +108,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85903 if (vlan_id)
85904 vlan_vid_del(real_dev, vlan_id);
85905
85906 + /* Take it out of our own structures, but be sure to interlock with
85907 + * HW accelerating devices or SW vlan input packet processing if
85908 + * VLAN is not 0 (leave it there for 802.1p).
85909 + */
85910 + if (vlan_id)
85911 + vlan_vid_del(real_dev, vlan_id);
85912 +
85913 /* Get rid of the vlan's reference to real_dev */
85914 dev_put(real_dev);
85915 }
85916 @@ -485,7 +492,7 @@ out:
85917 return NOTIFY_DONE;
85918 }
85919
85920 -static struct notifier_block vlan_notifier_block __read_mostly = {
85921 +static struct notifier_block vlan_notifier_block = {
85922 .notifier_call = vlan_device_event,
85923 };
85924
85925 @@ -560,8 +567,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85926 err = -EPERM;
85927 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85928 break;
85929 - if ((args.u.name_type >= 0) &&
85930 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85931 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85932 struct vlan_net *vn;
85933
85934 vn = net_generic(net, vlan_net_id);
85935 diff --git a/net/9p/mod.c b/net/9p/mod.c
85936 index 6ab36ae..6f1841b 100644
85937 --- a/net/9p/mod.c
85938 +++ b/net/9p/mod.c
85939 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85940 void v9fs_register_trans(struct p9_trans_module *m)
85941 {
85942 spin_lock(&v9fs_trans_lock);
85943 - list_add_tail(&m->list, &v9fs_trans_list);
85944 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85945 spin_unlock(&v9fs_trans_lock);
85946 }
85947 EXPORT_SYMBOL(v9fs_register_trans);
85948 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85949 void v9fs_unregister_trans(struct p9_trans_module *m)
85950 {
85951 spin_lock(&v9fs_trans_lock);
85952 - list_del_init(&m->list);
85953 + pax_list_del_init((struct list_head *)&m->list);
85954 spin_unlock(&v9fs_trans_lock);
85955 }
85956 EXPORT_SYMBOL(v9fs_unregister_trans);
85957 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85958 index 02efb25..41541a9 100644
85959 --- a/net/9p/trans_fd.c
85960 +++ b/net/9p/trans_fd.c
85961 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85962 oldfs = get_fs();
85963 set_fs(get_ds());
85964 /* The cast to a user pointer is valid due to the set_fs() */
85965 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85966 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85967 set_fs(oldfs);
85968
85969 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85970 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85971 index 876fbe8..8bbea9f 100644
85972 --- a/net/atm/atm_misc.c
85973 +++ b/net/atm/atm_misc.c
85974 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85975 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85976 return 1;
85977 atm_return(vcc, truesize);
85978 - atomic_inc(&vcc->stats->rx_drop);
85979 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85980 return 0;
85981 }
85982 EXPORT_SYMBOL(atm_charge);
85983 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85984 }
85985 }
85986 atm_return(vcc, guess);
85987 - atomic_inc(&vcc->stats->rx_drop);
85988 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85989 return NULL;
85990 }
85991 EXPORT_SYMBOL(atm_alloc_charge);
85992 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85993
85994 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85995 {
85996 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85997 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85998 __SONET_ITEMS
85999 #undef __HANDLE_ITEM
86000 }
86001 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
86002
86003 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
86004 {
86005 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
86006 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
86007 __SONET_ITEMS
86008 #undef __HANDLE_ITEM
86009 }
86010 diff --git a/net/atm/lec.h b/net/atm/lec.h
86011 index a86aff9..3a0d6f6 100644
86012 --- a/net/atm/lec.h
86013 +++ b/net/atm/lec.h
86014 @@ -48,7 +48,7 @@ struct lane2_ops {
86015 const u8 *tlvs, u32 sizeoftlvs);
86016 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
86017 const u8 *tlvs, u32 sizeoftlvs);
86018 -};
86019 +} __no_const;
86020
86021 /*
86022 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
86023 diff --git a/net/atm/proc.c b/net/atm/proc.c
86024 index 0d020de..011c7bb 100644
86025 --- a/net/atm/proc.c
86026 +++ b/net/atm/proc.c
86027 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
86028 const struct k_atm_aal_stats *stats)
86029 {
86030 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
86031 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
86032 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
86033 - atomic_read(&stats->rx_drop));
86034 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
86035 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
86036 + atomic_read_unchecked(&stats->rx_drop));
86037 }
86038
86039 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
86040 diff --git a/net/atm/resources.c b/net/atm/resources.c
86041 index 0447d5d..3cf4728 100644
86042 --- a/net/atm/resources.c
86043 +++ b/net/atm/resources.c
86044 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
86045 static void copy_aal_stats(struct k_atm_aal_stats *from,
86046 struct atm_aal_stats *to)
86047 {
86048 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
86049 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
86050 __AAL_STAT_ITEMS
86051 #undef __HANDLE_ITEM
86052 }
86053 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
86054 static void subtract_aal_stats(struct k_atm_aal_stats *from,
86055 struct atm_aal_stats *to)
86056 {
86057 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
86058 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
86059 __AAL_STAT_ITEMS
86060 #undef __HANDLE_ITEM
86061 }
86062 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
86063 index d5744b7..506bae3 100644
86064 --- a/net/ax25/sysctl_net_ax25.c
86065 +++ b/net/ax25/sysctl_net_ax25.c
86066 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
86067 {
86068 char path[sizeof("net/ax25/") + IFNAMSIZ];
86069 int k;
86070 - struct ctl_table *table;
86071 + ctl_table_no_const *table;
86072
86073 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
86074 if (!table)
86075 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
86076 index 1ee94d0..14beea2 100644
86077 --- a/net/batman-adv/bat_iv_ogm.c
86078 +++ b/net/batman-adv/bat_iv_ogm.c
86079 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
86080
86081 /* randomize initial seqno to avoid collision */
86082 get_random_bytes(&random_seqno, sizeof(random_seqno));
86083 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
86084 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
86085
86086 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
86087 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
86088 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
86089 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
86090
86091 /* change sequence number to network order */
86092 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
86093 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
86094 batadv_ogm_packet->seqno = htonl(seqno);
86095 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
86096 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
86097
86098 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
86099 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
86100 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
86101 return;
86102
86103 /* could be changed by schedule_own_packet() */
86104 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
86105 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
86106
86107 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
86108 has_directlink_flag = 1;
86109 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
86110 index f1d37cd..4190879 100644
86111 --- a/net/batman-adv/hard-interface.c
86112 +++ b/net/batman-adv/hard-interface.c
86113 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
86114 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
86115 dev_add_pack(&hard_iface->batman_adv_ptype);
86116
86117 - atomic_set(&hard_iface->frag_seqno, 1);
86118 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
86119 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
86120 hard_iface->net_dev->name);
86121
86122 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
86123 /* This can't be called via a bat_priv callback because
86124 * we have no bat_priv yet.
86125 */
86126 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
86127 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
86128 hard_iface->bat_iv.ogm_buff = NULL;
86129
86130 return hard_iface;
86131 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
86132 index 6b548fd..fc32c8d 100644
86133 --- a/net/batman-adv/soft-interface.c
86134 +++ b/net/batman-adv/soft-interface.c
86135 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
86136 primary_if->net_dev->dev_addr, ETH_ALEN);
86137
86138 /* set broadcast sequence number */
86139 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
86140 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
86141 bcast_packet->seqno = htonl(seqno);
86142
86143 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
86144 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
86145 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
86146
86147 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
86148 - atomic_set(&bat_priv->bcast_seqno, 1);
86149 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
86150 atomic_set(&bat_priv->tt.vn, 0);
86151 atomic_set(&bat_priv->tt.local_changes, 0);
86152 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
86153 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
86154 index ae9ac9a..11e0fe7 100644
86155 --- a/net/batman-adv/types.h
86156 +++ b/net/batman-adv/types.h
86157 @@ -48,7 +48,7 @@
86158 struct batadv_hard_iface_bat_iv {
86159 unsigned char *ogm_buff;
86160 int ogm_buff_len;
86161 - atomic_t ogm_seqno;
86162 + atomic_unchecked_t ogm_seqno;
86163 };
86164
86165 struct batadv_hard_iface {
86166 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
86167 int16_t if_num;
86168 char if_status;
86169 struct net_device *net_dev;
86170 - atomic_t frag_seqno;
86171 + atomic_unchecked_t frag_seqno;
86172 struct kobject *hardif_obj;
86173 atomic_t refcount;
86174 struct packet_type batman_adv_ptype;
86175 @@ -284,7 +284,7 @@ struct batadv_priv {
86176 atomic_t orig_interval; /* uint */
86177 atomic_t hop_penalty; /* uint */
86178 atomic_t log_level; /* uint */
86179 - atomic_t bcast_seqno;
86180 + atomic_unchecked_t bcast_seqno;
86181 atomic_t bcast_queue_left;
86182 atomic_t batman_queue_left;
86183 char num_ifaces;
86184 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
86185 index 10aff49..ea8e021 100644
86186 --- a/net/batman-adv/unicast.c
86187 +++ b/net/batman-adv/unicast.c
86188 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
86189 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
86190 frag2->flags = large_tail;
86191
86192 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
86193 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
86194 frag1->seqno = htons(seqno - 1);
86195 frag2->seqno = htons(seqno);
86196
86197 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
86198 index 07f0739..3c42e34 100644
86199 --- a/net/bluetooth/hci_sock.c
86200 +++ b/net/bluetooth/hci_sock.c
86201 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
86202 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
86203 }
86204
86205 - len = min_t(unsigned int, len, sizeof(uf));
86206 + len = min((size_t)len, sizeof(uf));
86207 if (copy_from_user(&uf, optval, len)) {
86208 err = -EFAULT;
86209 break;
86210 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
86211 index 22e6583..426e2f3 100644
86212 --- a/net/bluetooth/l2cap_core.c
86213 +++ b/net/bluetooth/l2cap_core.c
86214 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
86215 break;
86216
86217 case L2CAP_CONF_RFC:
86218 - if (olen == sizeof(rfc))
86219 - memcpy(&rfc, (void *)val, olen);
86220 + if (olen != sizeof(rfc))
86221 + break;
86222 +
86223 + memcpy(&rfc, (void *)val, olen);
86224
86225 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
86226 rfc.mode != chan->mode)
86227 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
86228 index 1bcfb84..dad9f98 100644
86229 --- a/net/bluetooth/l2cap_sock.c
86230 +++ b/net/bluetooth/l2cap_sock.c
86231 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
86232 struct sock *sk = sock->sk;
86233 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
86234 struct l2cap_options opts;
86235 - int len, err = 0;
86236 + int err = 0;
86237 + size_t len = optlen;
86238 u32 opt;
86239
86240 BT_DBG("sk %p", sk);
86241 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
86242 opts.max_tx = chan->max_tx;
86243 opts.txwin_size = chan->tx_win;
86244
86245 - len = min_t(unsigned int, sizeof(opts), optlen);
86246 + len = min(sizeof(opts), len);
86247 if (copy_from_user((char *) &opts, optval, len)) {
86248 err = -EFAULT;
86249 break;
86250 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86251 struct bt_security sec;
86252 struct bt_power pwr;
86253 struct l2cap_conn *conn;
86254 - int len, err = 0;
86255 + int err = 0;
86256 + size_t len = optlen;
86257 u32 opt;
86258
86259 BT_DBG("sk %p", sk);
86260 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86261
86262 sec.level = BT_SECURITY_LOW;
86263
86264 - len = min_t(unsigned int, sizeof(sec), optlen);
86265 + len = min(sizeof(sec), len);
86266 if (copy_from_user((char *) &sec, optval, len)) {
86267 err = -EFAULT;
86268 break;
86269 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86270
86271 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
86272
86273 - len = min_t(unsigned int, sizeof(pwr), optlen);
86274 + len = min(sizeof(pwr), len);
86275 if (copy_from_user((char *) &pwr, optval, len)) {
86276 err = -EFAULT;
86277 break;
86278 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
86279 index ce3f665..2c7d08f 100644
86280 --- a/net/bluetooth/rfcomm/sock.c
86281 +++ b/net/bluetooth/rfcomm/sock.c
86282 @@ -667,7 +667,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
86283 struct sock *sk = sock->sk;
86284 struct bt_security sec;
86285 int err = 0;
86286 - size_t len;
86287 + size_t len = optlen;
86288 u32 opt;
86289
86290 BT_DBG("sk %p", sk);
86291 @@ -689,7 +689,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
86292
86293 sec.level = BT_SECURITY_LOW;
86294
86295 - len = min_t(unsigned int, sizeof(sec), optlen);
86296 + len = min(sizeof(sec), len);
86297 if (copy_from_user((char *) &sec, optval, len)) {
86298 err = -EFAULT;
86299 break;
86300 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
86301 index bd6fd0f..6492cba 100644
86302 --- a/net/bluetooth/rfcomm/tty.c
86303 +++ b/net/bluetooth/rfcomm/tty.c
86304 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
86305 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
86306
86307 spin_lock_irqsave(&dev->port.lock, flags);
86308 - if (dev->port.count > 0) {
86309 + if (atomic_read(&dev->port.count) > 0) {
86310 spin_unlock_irqrestore(&dev->port.lock, flags);
86311 return;
86312 }
86313 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
86314 return -ENODEV;
86315
86316 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
86317 - dev->channel, dev->port.count);
86318 + dev->channel, atomic_read(&dev->port.count));
86319
86320 spin_lock_irqsave(&dev->port.lock, flags);
86321 - if (++dev->port.count > 1) {
86322 + if (atomic_inc_return(&dev->port.count) > 1) {
86323 spin_unlock_irqrestore(&dev->port.lock, flags);
86324 return 0;
86325 }
86326 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
86327 return;
86328
86329 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
86330 - dev->port.count);
86331 + atomic_read(&dev->port.count));
86332
86333 spin_lock_irqsave(&dev->port.lock, flags);
86334 - if (!--dev->port.count) {
86335 + if (!atomic_dec_return(&dev->port.count)) {
86336 spin_unlock_irqrestore(&dev->port.lock, flags);
86337 if (dev->tty_dev->parent)
86338 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
86339 diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
86340 index d9576e6..85f4f4e 100644
86341 --- a/net/bridge/br_fdb.c
86342 +++ b/net/bridge/br_fdb.c
86343 @@ -386,7 +386,7 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
86344 return 0;
86345 br_warn(br, "adding interface %s with same address "
86346 "as a received packet\n",
86347 - source->dev->name);
86348 + source ? source->dev->name : br->dev->name);
86349 fdb_delete(br, fdb);
86350 }
86351
86352 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
86353 index 5fe2ff3..121d696 100644
86354 --- a/net/bridge/netfilter/ebtables.c
86355 +++ b/net/bridge/netfilter/ebtables.c
86356 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86357 tmp.valid_hooks = t->table->valid_hooks;
86358 }
86359 mutex_unlock(&ebt_mutex);
86360 - if (copy_to_user(user, &tmp, *len) != 0){
86361 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
86362 BUGPRINT("c2u Didn't work\n");
86363 ret = -EFAULT;
86364 break;
86365 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86366 goto out;
86367 tmp.valid_hooks = t->valid_hooks;
86368
86369 - if (copy_to_user(user, &tmp, *len) != 0) {
86370 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86371 ret = -EFAULT;
86372 break;
86373 }
86374 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86375 tmp.entries_size = t->table->entries_size;
86376 tmp.valid_hooks = t->table->valid_hooks;
86377
86378 - if (copy_to_user(user, &tmp, *len) != 0) {
86379 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86380 ret = -EFAULT;
86381 break;
86382 }
86383 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
86384 index a376ec1..1fbd6be 100644
86385 --- a/net/caif/cfctrl.c
86386 +++ b/net/caif/cfctrl.c
86387 @@ -10,6 +10,7 @@
86388 #include <linux/spinlock.h>
86389 #include <linux/slab.h>
86390 #include <linux/pkt_sched.h>
86391 +#include <linux/sched.h>
86392 #include <net/caif/caif_layer.h>
86393 #include <net/caif/cfpkt.h>
86394 #include <net/caif/cfctrl.h>
86395 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
86396 memset(&dev_info, 0, sizeof(dev_info));
86397 dev_info.id = 0xff;
86398 cfsrvl_init(&this->serv, 0, &dev_info, false);
86399 - atomic_set(&this->req_seq_no, 1);
86400 - atomic_set(&this->rsp_seq_no, 1);
86401 + atomic_set_unchecked(&this->req_seq_no, 1);
86402 + atomic_set_unchecked(&this->rsp_seq_no, 1);
86403 this->serv.layer.receive = cfctrl_recv;
86404 sprintf(this->serv.layer.name, "ctrl");
86405 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
86406 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
86407 struct cfctrl_request_info *req)
86408 {
86409 spin_lock_bh(&ctrl->info_list_lock);
86410 - atomic_inc(&ctrl->req_seq_no);
86411 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
86412 + atomic_inc_unchecked(&ctrl->req_seq_no);
86413 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
86414 list_add_tail(&req->list, &ctrl->list);
86415 spin_unlock_bh(&ctrl->info_list_lock);
86416 }
86417 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
86418 if (p != first)
86419 pr_warn("Requests are not received in order\n");
86420
86421 - atomic_set(&ctrl->rsp_seq_no,
86422 + atomic_set_unchecked(&ctrl->rsp_seq_no,
86423 p->sequence_no);
86424 list_del(&p->list);
86425 goto out;
86426 diff --git a/net/can/af_can.c b/net/can/af_can.c
86427 index ddac1ee..3ee0a78 100644
86428 --- a/net/can/af_can.c
86429 +++ b/net/can/af_can.c
86430 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
86431 };
86432
86433 /* notifier block for netdevice event */
86434 -static struct notifier_block can_netdev_notifier __read_mostly = {
86435 +static struct notifier_block can_netdev_notifier = {
86436 .notifier_call = can_notifier,
86437 };
86438
86439 diff --git a/net/can/gw.c b/net/can/gw.c
86440 index 28e7bdc..d42c4cd 100644
86441 --- a/net/can/gw.c
86442 +++ b/net/can/gw.c
86443 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
86444 MODULE_ALIAS("can-gw");
86445
86446 static HLIST_HEAD(cgw_list);
86447 -static struct notifier_block notifier;
86448
86449 static struct kmem_cache *cgw_cache __read_mostly;
86450
86451 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
86452 return err;
86453 }
86454
86455 +static struct notifier_block notifier = {
86456 + .notifier_call = cgw_notifier
86457 +};
86458 +
86459 static __init int cgw_module_init(void)
86460 {
86461 printk(banner);
86462 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
86463 return -ENOMEM;
86464
86465 /* set notifier */
86466 - notifier.notifier_call = cgw_notifier;
86467 register_netdevice_notifier(&notifier);
86468
86469 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
86470 diff --git a/net/compat.c b/net/compat.c
86471 index 79ae884..17c5c09 100644
86472 --- a/net/compat.c
86473 +++ b/net/compat.c
86474 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
86475 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
86476 __get_user(kmsg->msg_flags, &umsg->msg_flags))
86477 return -EFAULT;
86478 - kmsg->msg_name = compat_ptr(tmp1);
86479 - kmsg->msg_iov = compat_ptr(tmp2);
86480 - kmsg->msg_control = compat_ptr(tmp3);
86481 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
86482 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
86483 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
86484 return 0;
86485 }
86486
86487 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86488
86489 if (kern_msg->msg_namelen) {
86490 if (mode == VERIFY_READ) {
86491 - int err = move_addr_to_kernel(kern_msg->msg_name,
86492 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
86493 kern_msg->msg_namelen,
86494 kern_address);
86495 if (err < 0)
86496 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86497 kern_msg->msg_name = NULL;
86498
86499 tot_len = iov_from_user_compat_to_kern(kern_iov,
86500 - (struct compat_iovec __user *)kern_msg->msg_iov,
86501 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
86502 kern_msg->msg_iovlen);
86503 if (tot_len >= 0)
86504 kern_msg->msg_iov = kern_iov;
86505 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86506
86507 #define CMSG_COMPAT_FIRSTHDR(msg) \
86508 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
86509 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
86510 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
86511 (struct compat_cmsghdr __user *)NULL)
86512
86513 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
86514 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
86515 (ucmlen) <= (unsigned long) \
86516 ((mhdr)->msg_controllen - \
86517 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
86518 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
86519
86520 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
86521 struct compat_cmsghdr __user *cmsg, int cmsg_len)
86522 {
86523 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
86524 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
86525 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
86526 msg->msg_controllen)
86527 return NULL;
86528 return (struct compat_cmsghdr __user *)ptr;
86529 @@ -219,7 +219,7 @@ Efault:
86530
86531 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
86532 {
86533 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86534 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86535 struct compat_cmsghdr cmhdr;
86536 struct compat_timeval ctv;
86537 struct compat_timespec cts[3];
86538 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
86539
86540 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
86541 {
86542 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86543 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86544 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
86545 int fdnum = scm->fp->count;
86546 struct file **fp = scm->fp->fp;
86547 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
86548 return -EFAULT;
86549 old_fs = get_fs();
86550 set_fs(KERNEL_DS);
86551 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
86552 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
86553 set_fs(old_fs);
86554
86555 return err;
86556 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
86557 len = sizeof(ktime);
86558 old_fs = get_fs();
86559 set_fs(KERNEL_DS);
86560 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
86561 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
86562 set_fs(old_fs);
86563
86564 if (!err) {
86565 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86566 case MCAST_JOIN_GROUP:
86567 case MCAST_LEAVE_GROUP:
86568 {
86569 - struct compat_group_req __user *gr32 = (void *)optval;
86570 + struct compat_group_req __user *gr32 = (void __user *)optval;
86571 struct group_req __user *kgr =
86572 compat_alloc_user_space(sizeof(struct group_req));
86573 u32 interface;
86574 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86575 case MCAST_BLOCK_SOURCE:
86576 case MCAST_UNBLOCK_SOURCE:
86577 {
86578 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86579 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86580 struct group_source_req __user *kgsr = compat_alloc_user_space(
86581 sizeof(struct group_source_req));
86582 u32 interface;
86583 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86584 }
86585 case MCAST_MSFILTER:
86586 {
86587 - struct compat_group_filter __user *gf32 = (void *)optval;
86588 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86589 struct group_filter __user *kgf;
86590 u32 interface, fmode, numsrc;
86591
86592 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86593 char __user *optval, int __user *optlen,
86594 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86595 {
86596 - struct compat_group_filter __user *gf32 = (void *)optval;
86597 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86598 struct group_filter __user *kgf;
86599 int __user *koptlen;
86600 u32 interface, fmode, numsrc;
86601 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86602
86603 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86604 return -EINVAL;
86605 - if (copy_from_user(a, args, nas[call]))
86606 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86607 return -EFAULT;
86608 a0 = a[0];
86609 a1 = a[1];
86610 diff --git a/net/core/datagram.c b/net/core/datagram.c
86611 index 368f9c3..f82d4a3 100644
86612 --- a/net/core/datagram.c
86613 +++ b/net/core/datagram.c
86614 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86615 }
86616
86617 kfree_skb(skb);
86618 - atomic_inc(&sk->sk_drops);
86619 + atomic_inc_unchecked(&sk->sk_drops);
86620 sk_mem_reclaim_partial(sk);
86621
86622 return err;
86623 diff --git a/net/core/dev.c b/net/core/dev.c
86624 index 5d9c43d..b471558 100644
86625 --- a/net/core/dev.c
86626 +++ b/net/core/dev.c
86627 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
86628 if (no_module && capable(CAP_NET_ADMIN))
86629 no_module = request_module("netdev-%s", name);
86630 if (no_module && capable(CAP_SYS_MODULE)) {
86631 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86632 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86633 +#else
86634 if (!request_module("%s", name))
86635 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86636 name);
86637 +#endif
86638 }
86639 }
86640 EXPORT_SYMBOL(dev_load);
86641 @@ -1714,7 +1718,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86642 {
86643 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86644 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86645 - atomic_long_inc(&dev->rx_dropped);
86646 + atomic_long_inc_unchecked(&dev->rx_dropped);
86647 kfree_skb(skb);
86648 return NET_RX_DROP;
86649 }
86650 @@ -1724,7 +1728,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86651 nf_reset(skb);
86652
86653 if (unlikely(!is_skb_forwardable(dev, skb))) {
86654 - atomic_long_inc(&dev->rx_dropped);
86655 + atomic_long_inc_unchecked(&dev->rx_dropped);
86656 kfree_skb(skb);
86657 return NET_RX_DROP;
86658 }
86659 @@ -2179,7 +2183,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86660
86661 struct dev_gso_cb {
86662 void (*destructor)(struct sk_buff *skb);
86663 -};
86664 +} __no_const;
86665
86666 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86667
86668 @@ -3052,7 +3056,7 @@ enqueue:
86669
86670 local_irq_restore(flags);
86671
86672 - atomic_long_inc(&skb->dev->rx_dropped);
86673 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86674 kfree_skb(skb);
86675 return NET_RX_DROP;
86676 }
86677 @@ -3124,7 +3128,7 @@ int netif_rx_ni(struct sk_buff *skb)
86678 }
86679 EXPORT_SYMBOL(netif_rx_ni);
86680
86681 -static void net_tx_action(struct softirq_action *h)
86682 +static void net_tx_action(void)
86683 {
86684 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86685
86686 @@ -3462,7 +3466,7 @@ ncls:
86687 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86688 } else {
86689 drop:
86690 - atomic_long_inc(&skb->dev->rx_dropped);
86691 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86692 kfree_skb(skb);
86693 /* Jamal, now you will not able to escape explaining
86694 * me how you were going to use this. :-)
86695 @@ -4045,7 +4049,7 @@ void netif_napi_del(struct napi_struct *napi)
86696 }
86697 EXPORT_SYMBOL(netif_napi_del);
86698
86699 -static void net_rx_action(struct softirq_action *h)
86700 +static void net_rx_action(void)
86701 {
86702 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86703 unsigned long time_limit = jiffies + 2;
86704 @@ -4529,8 +4533,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86705 else
86706 seq_printf(seq, "%04x", ntohs(pt->type));
86707
86708 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86709 + seq_printf(seq, " %-8s %p\n",
86710 + pt->dev ? pt->dev->name : "", NULL);
86711 +#else
86712 seq_printf(seq, " %-8s %pF\n",
86713 pt->dev ? pt->dev->name : "", pt->func);
86714 +#endif
86715 }
86716
86717 return 0;
86718 @@ -6102,7 +6111,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86719 } else {
86720 netdev_stats_to_stats64(storage, &dev->stats);
86721 }
86722 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86723 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86724 return storage;
86725 }
86726 EXPORT_SYMBOL(dev_get_stats);
86727 diff --git a/net/core/flow.c b/net/core/flow.c
86728 index 3bad824..2071a55 100644
86729 --- a/net/core/flow.c
86730 +++ b/net/core/flow.c
86731 @@ -61,7 +61,7 @@ struct flow_cache {
86732 struct timer_list rnd_timer;
86733 };
86734
86735 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86736 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86737 EXPORT_SYMBOL(flow_cache_genid);
86738 static struct flow_cache flow_cache_global;
86739 static struct kmem_cache *flow_cachep __read_mostly;
86740 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86741
86742 static int flow_entry_valid(struct flow_cache_entry *fle)
86743 {
86744 - if (atomic_read(&flow_cache_genid) != fle->genid)
86745 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86746 return 0;
86747 if (fle->object && !fle->object->ops->check(fle->object))
86748 return 0;
86749 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86750 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86751 fcp->hash_count++;
86752 }
86753 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86754 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86755 flo = fle->object;
86756 if (!flo)
86757 goto ret_object;
86758 @@ -280,7 +280,7 @@ nocache:
86759 }
86760 flo = resolver(net, key, family, dir, flo, ctx);
86761 if (fle) {
86762 - fle->genid = atomic_read(&flow_cache_genid);
86763 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86764 if (!IS_ERR(flo))
86765 fle->object = flo;
86766 else
86767 diff --git a/net/core/iovec.c b/net/core/iovec.c
86768 index 7e7aeb0..2a998cb 100644
86769 --- a/net/core/iovec.c
86770 +++ b/net/core/iovec.c
86771 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86772 if (m->msg_namelen) {
86773 if (mode == VERIFY_READ) {
86774 void __user *namep;
86775 - namep = (void __user __force *) m->msg_name;
86776 + namep = (void __force_user *) m->msg_name;
86777 err = move_addr_to_kernel(namep, m->msg_namelen,
86778 address);
86779 if (err < 0)
86780 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86781 }
86782
86783 size = m->msg_iovlen * sizeof(struct iovec);
86784 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86785 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86786 return -EFAULT;
86787
86788 m->msg_iov = iov;
86789 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86790 index c815f28..e6403f2 100644
86791 --- a/net/core/neighbour.c
86792 +++ b/net/core/neighbour.c
86793 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86794 size_t *lenp, loff_t *ppos)
86795 {
86796 int size, ret;
86797 - ctl_table tmp = *ctl;
86798 + ctl_table_no_const tmp = *ctl;
86799
86800 tmp.extra1 = &zero;
86801 tmp.extra2 = &unres_qlen_max;
86802 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86803 index 28c5f5a..7edf2e2 100644
86804 --- a/net/core/net-sysfs.c
86805 +++ b/net/core/net-sysfs.c
86806 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86807 }
86808 EXPORT_SYMBOL(netdev_class_remove_file);
86809
86810 -int netdev_kobject_init(void)
86811 +int __init netdev_kobject_init(void)
86812 {
86813 kobj_ns_type_register(&net_ns_type_operations);
86814 return class_register(&net_class);
86815 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86816 index 8acce01..2e306bb 100644
86817 --- a/net/core/net_namespace.c
86818 +++ b/net/core/net_namespace.c
86819 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86820 int error;
86821 LIST_HEAD(net_exit_list);
86822
86823 - list_add_tail(&ops->list, list);
86824 + pax_list_add_tail((struct list_head *)&ops->list, list);
86825 if (ops->init || (ops->id && ops->size)) {
86826 for_each_net(net) {
86827 error = ops_init(ops, net);
86828 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86829
86830 out_undo:
86831 /* If I have an error cleanup all namespaces I initialized */
86832 - list_del(&ops->list);
86833 + pax_list_del((struct list_head *)&ops->list);
86834 ops_exit_list(ops, &net_exit_list);
86835 ops_free_list(ops, &net_exit_list);
86836 return error;
86837 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86838 struct net *net;
86839 LIST_HEAD(net_exit_list);
86840
86841 - list_del(&ops->list);
86842 + pax_list_del((struct list_head *)&ops->list);
86843 for_each_net(net)
86844 list_add_tail(&net->exit_list, &net_exit_list);
86845 ops_exit_list(ops, &net_exit_list);
86846 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86847 mutex_lock(&net_mutex);
86848 error = register_pernet_operations(&pernet_list, ops);
86849 if (!error && (first_device == &pernet_list))
86850 - first_device = &ops->list;
86851 + first_device = (struct list_head *)&ops->list;
86852 mutex_unlock(&net_mutex);
86853 return error;
86854 }
86855 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86856 index 6212ec9..5ee16b2 100644
86857 --- a/net/core/rtnetlink.c
86858 +++ b/net/core/rtnetlink.c
86859 @@ -58,7 +58,7 @@ struct rtnl_link {
86860 rtnl_doit_func doit;
86861 rtnl_dumpit_func dumpit;
86862 rtnl_calcit_func calcit;
86863 -};
86864 +} __no_const;
86865
86866 static DEFINE_MUTEX(rtnl_mutex);
86867
86868 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86869 if (rtnl_link_ops_get(ops->kind))
86870 return -EEXIST;
86871
86872 - if (!ops->dellink)
86873 - ops->dellink = unregister_netdevice_queue;
86874 + if (!ops->dellink) {
86875 + pax_open_kernel();
86876 + *(void **)&ops->dellink = unregister_netdevice_queue;
86877 + pax_close_kernel();
86878 + }
86879
86880 - list_add_tail(&ops->list, &link_ops);
86881 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86882 return 0;
86883 }
86884 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86885 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86886 for_each_net(net) {
86887 __rtnl_kill_links(net, ops);
86888 }
86889 - list_del(&ops->list);
86890 + pax_list_del((struct list_head *)&ops->list);
86891 }
86892 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86893
86894 @@ -1068,7 +1071,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
86895 rcu_read_lock();
86896 cb->seq = net->dev_base_seq;
86897
86898 - if (nlmsg_parse(cb->nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
86899 + if (nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
86900 ifla_policy) >= 0) {
86901
86902 if (tb[IFLA_EXT_MASK])
86903 @@ -1924,7 +1927,7 @@ static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
86904 u32 ext_filter_mask = 0;
86905 u16 min_ifinfo_dump_size = 0;
86906
86907 - if (nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
86908 + if (nlmsg_parse(nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
86909 ifla_policy) >= 0) {
86910 if (tb[IFLA_EXT_MASK])
86911 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
86912 diff --git a/net/core/scm.c b/net/core/scm.c
86913 index 2dc6cda..2159524 100644
86914 --- a/net/core/scm.c
86915 +++ b/net/core/scm.c
86916 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86917 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86918 {
86919 struct cmsghdr __user *cm
86920 - = (__force struct cmsghdr __user *)msg->msg_control;
86921 + = (struct cmsghdr __force_user *)msg->msg_control;
86922 struct cmsghdr cmhdr;
86923 int cmlen = CMSG_LEN(len);
86924 int err;
86925 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86926 err = -EFAULT;
86927 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86928 goto out;
86929 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86930 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86931 goto out;
86932 cmlen = CMSG_SPACE(len);
86933 if (msg->msg_controllen < cmlen)
86934 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86935 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86936 {
86937 struct cmsghdr __user *cm
86938 - = (__force struct cmsghdr __user*)msg->msg_control;
86939 + = (struct cmsghdr __force_user *)msg->msg_control;
86940
86941 int fdmax = 0;
86942 int fdnum = scm->fp->count;
86943 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86944 if (fdnum < fdmax)
86945 fdmax = fdnum;
86946
86947 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86948 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86949 i++, cmfptr++)
86950 {
86951 struct socket *sock;
86952 diff --git a/net/core/sock.c b/net/core/sock.c
86953 index bc131d4..029e378 100644
86954 --- a/net/core/sock.c
86955 +++ b/net/core/sock.c
86956 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86957 struct sk_buff_head *list = &sk->sk_receive_queue;
86958
86959 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86960 - atomic_inc(&sk->sk_drops);
86961 + atomic_inc_unchecked(&sk->sk_drops);
86962 trace_sock_rcvqueue_full(sk, skb);
86963 return -ENOMEM;
86964 }
86965 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86966 return err;
86967
86968 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86969 - atomic_inc(&sk->sk_drops);
86970 + atomic_inc_unchecked(&sk->sk_drops);
86971 return -ENOBUFS;
86972 }
86973
86974 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86975 skb_dst_force(skb);
86976
86977 spin_lock_irqsave(&list->lock, flags);
86978 - skb->dropcount = atomic_read(&sk->sk_drops);
86979 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86980 __skb_queue_tail(list, skb);
86981 spin_unlock_irqrestore(&list->lock, flags);
86982
86983 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86984 skb->dev = NULL;
86985
86986 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86987 - atomic_inc(&sk->sk_drops);
86988 + atomic_inc_unchecked(&sk->sk_drops);
86989 goto discard_and_relse;
86990 }
86991 if (nested)
86992 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86993 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86994 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86995 bh_unlock_sock(sk);
86996 - atomic_inc(&sk->sk_drops);
86997 + atomic_inc_unchecked(&sk->sk_drops);
86998 goto discard_and_relse;
86999 }
87000
87001 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87002 struct timeval tm;
87003 } v;
87004
87005 - int lv = sizeof(int);
87006 - int len;
87007 + unsigned int lv = sizeof(int);
87008 + unsigned int len;
87009
87010 if (get_user(len, optlen))
87011 return -EFAULT;
87012 - if (len < 0)
87013 + if (len > INT_MAX)
87014 return -EINVAL;
87015
87016 memset(&v, 0, sizeof(v));
87017 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87018
87019 case SO_PEERNAME:
87020 {
87021 - char address[128];
87022 + char address[_K_SS_MAXSIZE];
87023
87024 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
87025 return -ENOTCONN;
87026 - if (lv < len)
87027 + if (lv < len || sizeof address < len)
87028 return -EINVAL;
87029 if (copy_to_user(optval, address, len))
87030 return -EFAULT;
87031 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
87032
87033 if (len > lv)
87034 len = lv;
87035 - if (copy_to_user(optval, &v, len))
87036 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
87037 return -EFAULT;
87038 lenout:
87039 if (put_user(len, optlen))
87040 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
87041 */
87042 smp_wmb();
87043 atomic_set(&sk->sk_refcnt, 1);
87044 - atomic_set(&sk->sk_drops, 0);
87045 + atomic_set_unchecked(&sk->sk_drops, 0);
87046 }
87047 EXPORT_SYMBOL(sock_init_data);
87048
87049 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
87050 index 750f44f..922399c 100644
87051 --- a/net/core/sock_diag.c
87052 +++ b/net/core/sock_diag.c
87053 @@ -9,26 +9,33 @@
87054 #include <linux/inet_diag.h>
87055 #include <linux/sock_diag.h>
87056
87057 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
87058 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
87059 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
87060 static DEFINE_MUTEX(sock_diag_table_mutex);
87061
87062 int sock_diag_check_cookie(void *sk, __u32 *cookie)
87063 {
87064 +#ifndef CONFIG_GRKERNSEC_HIDESYM
87065 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
87066 cookie[1] != INET_DIAG_NOCOOKIE) &&
87067 ((u32)(unsigned long)sk != cookie[0] ||
87068 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
87069 return -ESTALE;
87070 else
87071 +#endif
87072 return 0;
87073 }
87074 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
87075
87076 void sock_diag_save_cookie(void *sk, __u32 *cookie)
87077 {
87078 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87079 + cookie[0] = 0;
87080 + cookie[1] = 0;
87081 +#else
87082 cookie[0] = (u32)(unsigned long)sk;
87083 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
87084 +#endif
87085 }
87086 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
87087
87088 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
87089 mutex_lock(&sock_diag_table_mutex);
87090 if (sock_diag_handlers[hndl->family])
87091 err = -EBUSY;
87092 - else
87093 + else {
87094 + pax_open_kernel();
87095 sock_diag_handlers[hndl->family] = hndl;
87096 + pax_close_kernel();
87097 + }
87098 mutex_unlock(&sock_diag_table_mutex);
87099
87100 return err;
87101 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
87102
87103 mutex_lock(&sock_diag_table_mutex);
87104 BUG_ON(sock_diag_handlers[family] != hnld);
87105 + pax_open_kernel();
87106 sock_diag_handlers[family] = NULL;
87107 + pax_close_kernel();
87108 mutex_unlock(&sock_diag_table_mutex);
87109 }
87110 EXPORT_SYMBOL_GPL(sock_diag_unregister);
87111
87112 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
87113 -{
87114 - if (sock_diag_handlers[family] == NULL)
87115 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
87116 - NETLINK_SOCK_DIAG, family);
87117 -
87118 - mutex_lock(&sock_diag_table_mutex);
87119 - return sock_diag_handlers[family];
87120 -}
87121 -
87122 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
87123 -{
87124 - mutex_unlock(&sock_diag_table_mutex);
87125 -}
87126 -
87127 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
87128 {
87129 int err;
87130 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
87131 if (req->sdiag_family >= AF_MAX)
87132 return -EINVAL;
87133
87134 - hndl = sock_diag_lock_handler(req->sdiag_family);
87135 + if (sock_diag_handlers[req->sdiag_family] == NULL)
87136 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
87137 + NETLINK_SOCK_DIAG, req->sdiag_family);
87138 +
87139 + mutex_lock(&sock_diag_table_mutex);
87140 + hndl = sock_diag_handlers[req->sdiag_family];
87141 if (hndl == NULL)
87142 err = -ENOENT;
87143 else
87144 err = hndl->dump(skb, nlh);
87145 - sock_diag_unlock_handler(hndl);
87146 + mutex_unlock(&sock_diag_table_mutex);
87147
87148 return err;
87149 }
87150 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
87151 index d1b0804..98cf5f7 100644
87152 --- a/net/core/sysctl_net_core.c
87153 +++ b/net/core/sysctl_net_core.c
87154 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
87155 {
87156 unsigned int orig_size, size;
87157 int ret, i;
87158 - ctl_table tmp = {
87159 + ctl_table_no_const tmp = {
87160 .data = &size,
87161 .maxlen = sizeof(size),
87162 .mode = table->mode
87163 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
87164
87165 static __net_init int sysctl_core_net_init(struct net *net)
87166 {
87167 - struct ctl_table *tbl;
87168 + ctl_table_no_const *tbl = NULL;
87169
87170 net->core.sysctl_somaxconn = SOMAXCONN;
87171
87172 - tbl = netns_core_table;
87173 if (!net_eq(net, &init_net)) {
87174 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
87175 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
87176 if (tbl == NULL)
87177 goto err_dup;
87178
87179 @@ -221,17 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
87180 if (net->user_ns != &init_user_ns) {
87181 tbl[0].procname = NULL;
87182 }
87183 - }
87184 -
87185 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
87186 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
87187 + } else
87188 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
87189 if (net->core.sysctl_hdr == NULL)
87190 goto err_reg;
87191
87192 return 0;
87193
87194 err_reg:
87195 - if (tbl != netns_core_table)
87196 - kfree(tbl);
87197 + kfree(tbl);
87198 err_dup:
87199 return -ENOMEM;
87200 }
87201 @@ -246,7 +244,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
87202 kfree(tbl);
87203 }
87204
87205 -static __net_initdata struct pernet_operations sysctl_core_ops = {
87206 +static __net_initconst struct pernet_operations sysctl_core_ops = {
87207 .init = sysctl_core_net_init,
87208 .exit = sysctl_core_net_exit,
87209 };
87210 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
87211 index 307c322..78a4c6f 100644
87212 --- a/net/decnet/af_decnet.c
87213 +++ b/net/decnet/af_decnet.c
87214 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
87215 .sysctl_rmem = sysctl_decnet_rmem,
87216 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
87217 .obj_size = sizeof(struct dn_sock),
87218 + .slab_flags = SLAB_USERCOPY,
87219 };
87220
87221 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
87222 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
87223 index a55eecc..dd8428c 100644
87224 --- a/net/decnet/sysctl_net_decnet.c
87225 +++ b/net/decnet/sysctl_net_decnet.c
87226 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
87227
87228 if (len > *lenp) len = *lenp;
87229
87230 - if (copy_to_user(buffer, addr, len))
87231 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
87232 return -EFAULT;
87233
87234 *lenp = len;
87235 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
87236
87237 if (len > *lenp) len = *lenp;
87238
87239 - if (copy_to_user(buffer, devname, len))
87240 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
87241 return -EFAULT;
87242
87243 *lenp = len;
87244 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
87245 index fcf104e..95552d4 100644
87246 --- a/net/ipv4/af_inet.c
87247 +++ b/net/ipv4/af_inet.c
87248 @@ -1717,13 +1717,9 @@ static int __init inet_init(void)
87249
87250 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
87251
87252 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
87253 - if (!sysctl_local_reserved_ports)
87254 - goto out;
87255 -
87256 rc = proto_register(&tcp_prot, 1);
87257 if (rc)
87258 - goto out_free_reserved_ports;
87259 + goto out;
87260
87261 rc = proto_register(&udp_prot, 1);
87262 if (rc)
87263 @@ -1832,8 +1828,6 @@ out_unregister_udp_proto:
87264 proto_unregister(&udp_prot);
87265 out_unregister_tcp_proto:
87266 proto_unregister(&tcp_prot);
87267 -out_free_reserved_ports:
87268 - kfree(sysctl_local_reserved_ports);
87269 goto out;
87270 }
87271
87272 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
87273 index a69b4e4..dbccba5 100644
87274 --- a/net/ipv4/ah4.c
87275 +++ b/net/ipv4/ah4.c
87276 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
87277 return;
87278
87279 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87280 - atomic_inc(&flow_cache_genid);
87281 + atomic_inc_unchecked(&flow_cache_genid);
87282 rt_genid_bump(net);
87283
87284 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
87285 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
87286 index a8e4f26..25e5f40 100644
87287 --- a/net/ipv4/devinet.c
87288 +++ b/net/ipv4/devinet.c
87289 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
87290 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
87291 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
87292
87293 -static struct devinet_sysctl_table {
87294 +static const struct devinet_sysctl_table {
87295 struct ctl_table_header *sysctl_header;
87296 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
87297 } devinet_sysctl = {
87298 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
87299 int err;
87300 struct ipv4_devconf *all, *dflt;
87301 #ifdef CONFIG_SYSCTL
87302 - struct ctl_table *tbl = ctl_forward_entry;
87303 + ctl_table_no_const *tbl = NULL;
87304 struct ctl_table_header *forw_hdr;
87305 #endif
87306
87307 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
87308 goto err_alloc_dflt;
87309
87310 #ifdef CONFIG_SYSCTL
87311 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
87312 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
87313 if (tbl == NULL)
87314 goto err_alloc_ctl;
87315
87316 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
87317 goto err_reg_dflt;
87318
87319 err = -ENOMEM;
87320 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
87321 + if (!net_eq(net, &init_net))
87322 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
87323 + else
87324 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
87325 if (forw_hdr == NULL)
87326 goto err_reg_ctl;
87327 net->ipv4.forw_hdr = forw_hdr;
87328 @@ -1935,8 +1938,7 @@ err_reg_ctl:
87329 err_reg_dflt:
87330 __devinet_sysctl_unregister(all);
87331 err_reg_all:
87332 - if (tbl != ctl_forward_entry)
87333 - kfree(tbl);
87334 + kfree(tbl);
87335 err_alloc_ctl:
87336 #endif
87337 if (dflt != &ipv4_devconf_dflt)
87338 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
87339 index 3b4f0cd..a6ba66e 100644
87340 --- a/net/ipv4/esp4.c
87341 +++ b/net/ipv4/esp4.c
87342 @@ -139,8 +139,6 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
87343
87344 /* skb is pure payload to encrypt */
87345
87346 - err = -ENOMEM;
87347 -
87348 esp = x->data;
87349 aead = esp->aead;
87350 alen = crypto_aead_authsize(aead);
87351 @@ -176,8 +174,10 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
87352 }
87353
87354 tmp = esp_alloc_tmp(aead, nfrags + sglists, seqhilen);
87355 - if (!tmp)
87356 + if (!tmp) {
87357 + err = -ENOMEM;
87358 goto error;
87359 + }
87360
87361 seqhi = esp_tmp_seqhi(tmp);
87362 iv = esp_tmp_iv(aead, tmp, seqhilen);
87363 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
87364 return;
87365
87366 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87367 - atomic_inc(&flow_cache_genid);
87368 + atomic_inc_unchecked(&flow_cache_genid);
87369 rt_genid_bump(net);
87370
87371 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
87372 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
87373 index 5cd75e2..f57ef39 100644
87374 --- a/net/ipv4/fib_frontend.c
87375 +++ b/net/ipv4/fib_frontend.c
87376 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
87377 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87378 fib_sync_up(dev);
87379 #endif
87380 - atomic_inc(&net->ipv4.dev_addr_genid);
87381 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87382 rt_cache_flush(dev_net(dev));
87383 break;
87384 case NETDEV_DOWN:
87385 fib_del_ifaddr(ifa, NULL);
87386 - atomic_inc(&net->ipv4.dev_addr_genid);
87387 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87388 if (ifa->ifa_dev->ifa_list == NULL) {
87389 /* Last address was deleted from this interface.
87390 * Disable IP.
87391 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
87392 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87393 fib_sync_up(dev);
87394 #endif
87395 - atomic_inc(&net->ipv4.dev_addr_genid);
87396 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87397 rt_cache_flush(net);
87398 break;
87399 case NETDEV_DOWN:
87400 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
87401 index 4797a80..2bd54e9 100644
87402 --- a/net/ipv4/fib_semantics.c
87403 +++ b/net/ipv4/fib_semantics.c
87404 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
87405 nh->nh_saddr = inet_select_addr(nh->nh_dev,
87406 nh->nh_gw,
87407 nh->nh_parent->fib_scope);
87408 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
87409 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
87410
87411 return nh->nh_saddr;
87412 }
87413 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
87414 index d0670f0..744ac80 100644
87415 --- a/net/ipv4/inet_connection_sock.c
87416 +++ b/net/ipv4/inet_connection_sock.c
87417 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
87418 .range = { 32768, 61000 },
87419 };
87420
87421 -unsigned long *sysctl_local_reserved_ports;
87422 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
87423 EXPORT_SYMBOL(sysctl_local_reserved_ports);
87424
87425 void inet_get_local_port_range(int *low, int *high)
87426 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
87427 index fa3ae81..0dbe6b8 100644
87428 --- a/net/ipv4/inet_hashtables.c
87429 +++ b/net/ipv4/inet_hashtables.c
87430 @@ -18,12 +18,15 @@
87431 #include <linux/sched.h>
87432 #include <linux/slab.h>
87433 #include <linux/wait.h>
87434 +#include <linux/security.h>
87435
87436 #include <net/inet_connection_sock.h>
87437 #include <net/inet_hashtables.h>
87438 #include <net/secure_seq.h>
87439 #include <net/ip.h>
87440
87441 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
87442 +
87443 /*
87444 * Allocate and initialize a new local port bind bucket.
87445 * The bindhash mutex for snum's hash chain must be held here.
87446 @@ -540,6 +543,8 @@ ok:
87447 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
87448 spin_unlock(&head->lock);
87449
87450 + gr_update_task_in_ip_table(current, inet_sk(sk));
87451 +
87452 if (tw) {
87453 inet_twsk_deschedule(tw, death_row);
87454 while (twrefcnt) {
87455 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
87456 index 000e3d2..5472da3 100644
87457 --- a/net/ipv4/inetpeer.c
87458 +++ b/net/ipv4/inetpeer.c
87459 @@ -503,8 +503,8 @@ relookup:
87460 if (p) {
87461 p->daddr = *daddr;
87462 atomic_set(&p->refcnt, 1);
87463 - atomic_set(&p->rid, 0);
87464 - atomic_set(&p->ip_id_count,
87465 + atomic_set_unchecked(&p->rid, 0);
87466 + atomic_set_unchecked(&p->ip_id_count,
87467 (daddr->family == AF_INET) ?
87468 secure_ip_id(daddr->addr.a4) :
87469 secure_ipv6_id(daddr->addr.a6));
87470 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
87471 index a8fc332..4ca4ca65 100644
87472 --- a/net/ipv4/ip_fragment.c
87473 +++ b/net/ipv4/ip_fragment.c
87474 @@ -319,7 +319,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
87475 return 0;
87476
87477 start = qp->rid;
87478 - end = atomic_inc_return(&peer->rid);
87479 + end = atomic_inc_return_unchecked(&peer->rid);
87480 qp->rid = end;
87481
87482 rc = qp->q.fragments && (end - start) > max;
87483 @@ -786,12 +786,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
87484
87485 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87486 {
87487 - struct ctl_table *table;
87488 + ctl_table_no_const *table = NULL;
87489 struct ctl_table_header *hdr;
87490
87491 - table = ip4_frags_ns_ctl_table;
87492 if (!net_eq(net, &init_net)) {
87493 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87494 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87495 if (table == NULL)
87496 goto err_alloc;
87497
87498 @@ -802,9 +801,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87499 /* Don't export sysctls to unprivileged users */
87500 if (net->user_ns != &init_user_ns)
87501 table[0].procname = NULL;
87502 - }
87503 + hdr = register_net_sysctl(net, "net/ipv4", table);
87504 + } else
87505 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
87506
87507 - hdr = register_net_sysctl(net, "net/ipv4", table);
87508 if (hdr == NULL)
87509 goto err_reg;
87510
87511 @@ -812,8 +812,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87512 return 0;
87513
87514 err_reg:
87515 - if (!net_eq(net, &init_net))
87516 - kfree(table);
87517 + kfree(table);
87518 err_alloc:
87519 return -ENOMEM;
87520 }
87521 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
87522 index a85062b..2958a9b 100644
87523 --- a/net/ipv4/ip_gre.c
87524 +++ b/net/ipv4/ip_gre.c
87525 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
87526 module_param(log_ecn_error, bool, 0644);
87527 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87528
87529 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
87530 +static struct rtnl_link_ops ipgre_link_ops;
87531 static int ipgre_tunnel_init(struct net_device *dev);
87532 static void ipgre_tunnel_setup(struct net_device *dev);
87533 static int ipgre_tunnel_bind_dev(struct net_device *dev);
87534 @@ -1753,7 +1753,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
87535 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
87536 };
87537
87538 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87539 +static struct rtnl_link_ops ipgre_link_ops = {
87540 .kind = "gre",
87541 .maxtype = IFLA_GRE_MAX,
87542 .policy = ipgre_policy,
87543 @@ -1766,7 +1766,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87544 .fill_info = ipgre_fill_info,
87545 };
87546
87547 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
87548 +static struct rtnl_link_ops ipgre_tap_ops = {
87549 .kind = "gretap",
87550 .maxtype = IFLA_GRE_MAX,
87551 .policy = ipgre_policy,
87552 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
87553 index d9c4f11..02b82dbc 100644
87554 --- a/net/ipv4/ip_sockglue.c
87555 +++ b/net/ipv4/ip_sockglue.c
87556 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87557 len = min_t(unsigned int, len, opt->optlen);
87558 if (put_user(len, optlen))
87559 return -EFAULT;
87560 - if (copy_to_user(optval, opt->__data, len))
87561 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
87562 + copy_to_user(optval, opt->__data, len))
87563 return -EFAULT;
87564 return 0;
87565 }
87566 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87567 if (sk->sk_type != SOCK_STREAM)
87568 return -ENOPROTOOPT;
87569
87570 - msg.msg_control = optval;
87571 + msg.msg_control = (void __force_kernel *)optval;
87572 msg.msg_controllen = len;
87573 msg.msg_flags = flags;
87574
87575 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
87576 index c3a4233..1412161 100644
87577 --- a/net/ipv4/ip_vti.c
87578 +++ b/net/ipv4/ip_vti.c
87579 @@ -47,7 +47,7 @@
87580 #define HASH_SIZE 16
87581 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
87582
87583 -static struct rtnl_link_ops vti_link_ops __read_mostly;
87584 +static struct rtnl_link_ops vti_link_ops;
87585
87586 static int vti_net_id __read_mostly;
87587 struct vti_net {
87588 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
87589 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
87590 };
87591
87592 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
87593 +static struct rtnl_link_ops vti_link_ops = {
87594 .kind = "vti",
87595 .maxtype = IFLA_VTI_MAX,
87596 .policy = vti_policy,
87597 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87598 index 9a46dae..5f793a0 100644
87599 --- a/net/ipv4/ipcomp.c
87600 +++ b/net/ipv4/ipcomp.c
87601 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87602 return;
87603
87604 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87605 - atomic_inc(&flow_cache_genid);
87606 + atomic_inc_unchecked(&flow_cache_genid);
87607 rt_genid_bump(net);
87608
87609 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87610 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87611 index a2e50ae..e152b7c 100644
87612 --- a/net/ipv4/ipconfig.c
87613 +++ b/net/ipv4/ipconfig.c
87614 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87615
87616 mm_segment_t oldfs = get_fs();
87617 set_fs(get_ds());
87618 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87619 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87620 set_fs(oldfs);
87621 return res;
87622 }
87623 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87624
87625 mm_segment_t oldfs = get_fs();
87626 set_fs(get_ds());
87627 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87628 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87629 set_fs(oldfs);
87630 return res;
87631 }
87632 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87633
87634 mm_segment_t oldfs = get_fs();
87635 set_fs(get_ds());
87636 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87637 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87638 set_fs(oldfs);
87639 return res;
87640 }
87641 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87642 index 191fc24..1b3b804 100644
87643 --- a/net/ipv4/ipip.c
87644 +++ b/net/ipv4/ipip.c
87645 @@ -138,7 +138,7 @@ struct ipip_net {
87646 static int ipip_tunnel_init(struct net_device *dev);
87647 static void ipip_tunnel_setup(struct net_device *dev);
87648 static void ipip_dev_free(struct net_device *dev);
87649 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87650 +static struct rtnl_link_ops ipip_link_ops;
87651
87652 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
87653 struct rtnl_link_stats64 *tot)
87654 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87655 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87656 };
87657
87658 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87659 +static struct rtnl_link_ops ipip_link_ops = {
87660 .kind = "ipip",
87661 .maxtype = IFLA_IPTUN_MAX,
87662 .policy = ipip_policy,
87663 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87664 index 3ea4127..849297b 100644
87665 --- a/net/ipv4/netfilter/arp_tables.c
87666 +++ b/net/ipv4/netfilter/arp_tables.c
87667 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
87668 #endif
87669
87670 static int get_info(struct net *net, void __user *user,
87671 - const int *len, int compat)
87672 + int len, int compat)
87673 {
87674 char name[XT_TABLE_MAXNAMELEN];
87675 struct xt_table *t;
87676 int ret;
87677
87678 - if (*len != sizeof(struct arpt_getinfo)) {
87679 - duprintf("length %u != %Zu\n", *len,
87680 + if (len != sizeof(struct arpt_getinfo)) {
87681 + duprintf("length %u != %Zu\n", len,
87682 sizeof(struct arpt_getinfo));
87683 return -EINVAL;
87684 }
87685 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
87686 info.size = private->size;
87687 strcpy(info.name, name);
87688
87689 - if (copy_to_user(user, &info, *len) != 0)
87690 + if (copy_to_user(user, &info, len) != 0)
87691 ret = -EFAULT;
87692 else
87693 ret = 0;
87694 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87695
87696 switch (cmd) {
87697 case ARPT_SO_GET_INFO:
87698 - ret = get_info(sock_net(sk), user, len, 1);
87699 + ret = get_info(sock_net(sk), user, *len, 1);
87700 break;
87701 case ARPT_SO_GET_ENTRIES:
87702 ret = compat_get_entries(sock_net(sk), user, len);
87703 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87704
87705 switch (cmd) {
87706 case ARPT_SO_GET_INFO:
87707 - ret = get_info(sock_net(sk), user, len, 0);
87708 + ret = get_info(sock_net(sk), user, *len, 0);
87709 break;
87710
87711 case ARPT_SO_GET_ENTRIES:
87712 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87713 index 17c5e06..1b91206 100644
87714 --- a/net/ipv4/netfilter/ip_tables.c
87715 +++ b/net/ipv4/netfilter/ip_tables.c
87716 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87717 #endif
87718
87719 static int get_info(struct net *net, void __user *user,
87720 - const int *len, int compat)
87721 + int len, int compat)
87722 {
87723 char name[XT_TABLE_MAXNAMELEN];
87724 struct xt_table *t;
87725 int ret;
87726
87727 - if (*len != sizeof(struct ipt_getinfo)) {
87728 - duprintf("length %u != %zu\n", *len,
87729 + if (len != sizeof(struct ipt_getinfo)) {
87730 + duprintf("length %u != %zu\n", len,
87731 sizeof(struct ipt_getinfo));
87732 return -EINVAL;
87733 }
87734 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87735 info.size = private->size;
87736 strcpy(info.name, name);
87737
87738 - if (copy_to_user(user, &info, *len) != 0)
87739 + if (copy_to_user(user, &info, len) != 0)
87740 ret = -EFAULT;
87741 else
87742 ret = 0;
87743 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87744
87745 switch (cmd) {
87746 case IPT_SO_GET_INFO:
87747 - ret = get_info(sock_net(sk), user, len, 1);
87748 + ret = get_info(sock_net(sk), user, *len, 1);
87749 break;
87750 case IPT_SO_GET_ENTRIES:
87751 ret = compat_get_entries(sock_net(sk), user, len);
87752 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87753
87754 switch (cmd) {
87755 case IPT_SO_GET_INFO:
87756 - ret = get_info(sock_net(sk), user, len, 0);
87757 + ret = get_info(sock_net(sk), user, *len, 0);
87758 break;
87759
87760 case IPT_SO_GET_ENTRIES:
87761 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87762 index dc454cc..5bb917f 100644
87763 --- a/net/ipv4/ping.c
87764 +++ b/net/ipv4/ping.c
87765 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87766 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87767 0, sock_i_ino(sp),
87768 atomic_read(&sp->sk_refcnt), sp,
87769 - atomic_read(&sp->sk_drops), len);
87770 + atomic_read_unchecked(&sp->sk_drops), len);
87771 }
87772
87773 static int ping_seq_show(struct seq_file *seq, void *v)
87774 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87775 index 6f08991..55867ad 100644
87776 --- a/net/ipv4/raw.c
87777 +++ b/net/ipv4/raw.c
87778 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87779 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87780 {
87781 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87782 - atomic_inc(&sk->sk_drops);
87783 + atomic_inc_unchecked(&sk->sk_drops);
87784 kfree_skb(skb);
87785 return NET_RX_DROP;
87786 }
87787 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
87788
87789 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87790 {
87791 + struct icmp_filter filter;
87792 +
87793 if (optlen > sizeof(struct icmp_filter))
87794 optlen = sizeof(struct icmp_filter);
87795 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87796 + if (copy_from_user(&filter, optval, optlen))
87797 return -EFAULT;
87798 + raw_sk(sk)->filter = filter;
87799 return 0;
87800 }
87801
87802 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87803 {
87804 int len, ret = -EFAULT;
87805 + struct icmp_filter filter;
87806
87807 if (get_user(len, optlen))
87808 goto out;
87809 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87810 if (len > sizeof(struct icmp_filter))
87811 len = sizeof(struct icmp_filter);
87812 ret = -EFAULT;
87813 - if (put_user(len, optlen) ||
87814 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87815 + filter = raw_sk(sk)->filter;
87816 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87817 goto out;
87818 ret = 0;
87819 out: return ret;
87820 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87821 0, 0L, 0,
87822 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87823 0, sock_i_ino(sp),
87824 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87825 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87826 }
87827
87828 static int raw_seq_show(struct seq_file *seq, void *v)
87829 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87830 index a0fcc47..32e2c89 100644
87831 --- a/net/ipv4/route.c
87832 +++ b/net/ipv4/route.c
87833 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87834 .maxlen = sizeof(int),
87835 .mode = 0200,
87836 .proc_handler = ipv4_sysctl_rtcache_flush,
87837 + .extra1 = &init_net,
87838 },
87839 { },
87840 };
87841
87842 static __net_init int sysctl_route_net_init(struct net *net)
87843 {
87844 - struct ctl_table *tbl;
87845 + ctl_table_no_const *tbl = NULL;
87846
87847 - tbl = ipv4_route_flush_table;
87848 if (!net_eq(net, &init_net)) {
87849 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87850 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87851 if (tbl == NULL)
87852 goto err_dup;
87853
87854 /* Don't export sysctls to unprivileged users */
87855 if (net->user_ns != &init_user_ns)
87856 tbl[0].procname = NULL;
87857 - }
87858 - tbl[0].extra1 = net;
87859 + tbl[0].extra1 = net;
87860 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87861 + } else
87862 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87863
87864 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87865 if (net->ipv4.route_hdr == NULL)
87866 goto err_reg;
87867 return 0;
87868
87869 err_reg:
87870 - if (tbl != ipv4_route_flush_table)
87871 - kfree(tbl);
87872 + kfree(tbl);
87873 err_dup:
87874 return -ENOMEM;
87875 }
87876 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87877
87878 static __net_init int rt_genid_init(struct net *net)
87879 {
87880 - atomic_set(&net->rt_genid, 0);
87881 + atomic_set_unchecked(&net->rt_genid, 0);
87882 get_random_bytes(&net->ipv4.dev_addr_genid,
87883 sizeof(net->ipv4.dev_addr_genid));
87884 return 0;
87885 diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
87886 index b236ef04..f962f19 100644
87887 --- a/net/ipv4/syncookies.c
87888 +++ b/net/ipv4/syncookies.c
87889 @@ -348,8 +348,8 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,
87890 * hasn't changed since we received the original syn, but I see
87891 * no easy way to do this.
87892 */
87893 - flowi4_init_output(&fl4, 0, sk->sk_mark, RT_CONN_FLAGS(sk),
87894 - RT_SCOPE_UNIVERSE, IPPROTO_TCP,
87895 + flowi4_init_output(&fl4, sk->sk_bound_dev_if, sk->sk_mark,
87896 + RT_CONN_FLAGS(sk), RT_SCOPE_UNIVERSE, IPPROTO_TCP,
87897 inet_sk_flowi_flags(sk),
87898 (opt && opt->srr) ? opt->faddr : ireq->rmt_addr,
87899 ireq->loc_addr, th->source, th->dest);
87900 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87901 index d84400b..62e066e 100644
87902 --- a/net/ipv4/sysctl_net_ipv4.c
87903 +++ b/net/ipv4/sysctl_net_ipv4.c
87904 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87905 {
87906 int ret;
87907 int range[2];
87908 - ctl_table tmp = {
87909 + ctl_table_no_const tmp = {
87910 .data = &range,
87911 .maxlen = sizeof(range),
87912 .mode = table->mode,
87913 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87914 int ret;
87915 gid_t urange[2];
87916 kgid_t low, high;
87917 - ctl_table tmp = {
87918 + ctl_table_no_const tmp = {
87919 .data = &urange,
87920 .maxlen = sizeof(urange),
87921 .mode = table->mode,
87922 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87923 void __user *buffer, size_t *lenp, loff_t *ppos)
87924 {
87925 char val[TCP_CA_NAME_MAX];
87926 - ctl_table tbl = {
87927 + ctl_table_no_const tbl = {
87928 .data = val,
87929 .maxlen = TCP_CA_NAME_MAX,
87930 };
87931 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87932 void __user *buffer, size_t *lenp,
87933 loff_t *ppos)
87934 {
87935 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87936 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87937 int ret;
87938
87939 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87940 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87941 void __user *buffer, size_t *lenp,
87942 loff_t *ppos)
87943 {
87944 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87945 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87946 int ret;
87947
87948 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87949 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87950 struct mem_cgroup *memcg;
87951 #endif
87952
87953 - ctl_table tmp = {
87954 + ctl_table_no_const tmp = {
87955 .data = &vec,
87956 .maxlen = sizeof(vec),
87957 .mode = ctl->mode,
87958 };
87959
87960 if (!write) {
87961 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87962 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87963 + ctl_table_no_const tcp_mem = *ctl;
87964 +
87965 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87966 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87967 }
87968
87969 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87970 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87971 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87972 size_t *lenp, loff_t *ppos)
87973 {
87974 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87975 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87976 struct tcp_fastopen_context *ctxt;
87977 int ret;
87978 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87979 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
87980 },
87981 {
87982 .procname = "ip_local_reserved_ports",
87983 - .data = NULL, /* initialized in sysctl_ipv4_init */
87984 + .data = sysctl_local_reserved_ports,
87985 .maxlen = 65536,
87986 .mode = 0644,
87987 .proc_handler = proc_do_large_bitmap,
87988 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
87989
87990 static __net_init int ipv4_sysctl_init_net(struct net *net)
87991 {
87992 - struct ctl_table *table;
87993 + ctl_table_no_const *table = NULL;
87994
87995 - table = ipv4_net_table;
87996 if (!net_eq(net, &init_net)) {
87997 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87998 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87999 if (table == NULL)
88000 goto err_alloc;
88001
88002 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
88003
88004 tcp_init_mem(net);
88005
88006 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
88007 + if (!net_eq(net, &init_net))
88008 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
88009 + else
88010 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
88011 if (net->ipv4.ipv4_hdr == NULL)
88012 goto err_reg;
88013
88014 return 0;
88015
88016 err_reg:
88017 - if (!net_eq(net, &init_net))
88018 - kfree(table);
88019 + kfree(table);
88020 err_alloc:
88021 return -ENOMEM;
88022 }
88023 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
88024 static __init int sysctl_ipv4_init(void)
88025 {
88026 struct ctl_table_header *hdr;
88027 - struct ctl_table *i;
88028 -
88029 - for (i = ipv4_table; i->procname; i++) {
88030 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
88031 - i->data = sysctl_local_reserved_ports;
88032 - break;
88033 - }
88034 - }
88035 - if (!i->procname)
88036 - return -EINVAL;
88037
88038 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
88039 if (hdr == NULL)
88040 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
88041 index 9841a71..ef60409 100644
88042 --- a/net/ipv4/tcp_input.c
88043 +++ b/net/ipv4/tcp_input.c
88044 @@ -4730,7 +4730,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
88045 * simplifies code)
88046 */
88047 static void
88048 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
88049 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
88050 struct sk_buff *head, struct sk_buff *tail,
88051 u32 start, u32 end)
88052 {
88053 @@ -5847,6 +5847,7 @@ discard:
88054 tcp_paws_reject(&tp->rx_opt, 0))
88055 goto discard_and_undo;
88056
88057 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
88058 if (th->syn) {
88059 /* We see SYN without ACK. It is attempt of
88060 * simultaneous connect with crossed SYNs.
88061 @@ -5897,6 +5898,7 @@ discard:
88062 goto discard;
88063 #endif
88064 }
88065 +#endif
88066 /* "fifth, if neither of the SYN or RST bits is set then
88067 * drop the segment and return."
88068 */
88069 @@ -5941,7 +5943,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
88070 goto discard;
88071
88072 if (th->syn) {
88073 - if (th->fin)
88074 + if (th->fin || th->urg || th->psh)
88075 goto discard;
88076 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
88077 return 1;
88078 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
88079 index d9130a9..00328ff 100644
88080 --- a/net/ipv4/tcp_ipv4.c
88081 +++ b/net/ipv4/tcp_ipv4.c
88082 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
88083 EXPORT_SYMBOL(sysctl_tcp_low_latency);
88084
88085
88086 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88087 +extern int grsec_enable_blackhole;
88088 +#endif
88089 +
88090 #ifdef CONFIG_TCP_MD5SIG
88091 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
88092 __be32 daddr, __be32 saddr, const struct tcphdr *th);
88093 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
88094 return 0;
88095
88096 reset:
88097 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88098 + if (!grsec_enable_blackhole)
88099 +#endif
88100 tcp_v4_send_reset(rsk, skb);
88101 discard:
88102 kfree_skb(skb);
88103 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
88104 TCP_SKB_CB(skb)->sacked = 0;
88105
88106 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88107 - if (!sk)
88108 + if (!sk) {
88109 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88110 + ret = 1;
88111 +#endif
88112 goto no_tcp_socket;
88113 -
88114 + }
88115 process:
88116 - if (sk->sk_state == TCP_TIME_WAIT)
88117 + if (sk->sk_state == TCP_TIME_WAIT) {
88118 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88119 + ret = 2;
88120 +#endif
88121 goto do_time_wait;
88122 + }
88123
88124 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
88125 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88126 @@ -2050,6 +2064,10 @@ no_tcp_socket:
88127 bad_packet:
88128 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88129 } else {
88130 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88131 + if (!grsec_enable_blackhole || (ret == 1 &&
88132 + (skb->dev->flags & IFF_LOOPBACK)))
88133 +#endif
88134 tcp_v4_send_reset(NULL, skb);
88135 }
88136
88137 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
88138 index f35f2df..ccb5ca6 100644
88139 --- a/net/ipv4/tcp_minisocks.c
88140 +++ b/net/ipv4/tcp_minisocks.c
88141 @@ -27,6 +27,10 @@
88142 #include <net/inet_common.h>
88143 #include <net/xfrm.h>
88144
88145 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88146 +extern int grsec_enable_blackhole;
88147 +#endif
88148 +
88149 int sysctl_tcp_syncookies __read_mostly = 1;
88150 EXPORT_SYMBOL(sysctl_tcp_syncookies);
88151
88152 @@ -742,7 +746,10 @@ embryonic_reset:
88153 * avoid becoming vulnerable to outside attack aiming at
88154 * resetting legit local connections.
88155 */
88156 - req->rsk_ops->send_reset(sk, skb);
88157 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88158 + if (!grsec_enable_blackhole)
88159 +#endif
88160 + req->rsk_ops->send_reset(sk, skb);
88161 } else if (fastopen) { /* received a valid RST pkt */
88162 reqsk_fastopen_remove(sk, req, true);
88163 tcp_reset(sk);
88164 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
88165 index 17d659e..a9f50ee 100644
88166 --- a/net/ipv4/tcp_output.c
88167 +++ b/net/ipv4/tcp_output.c
88168 @@ -2388,8 +2388,12 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
88169 */
88170 TCP_SKB_CB(skb)->when = tcp_time_stamp;
88171
88172 - /* make sure skb->data is aligned on arches that require it */
88173 - if (unlikely(NET_IP_ALIGN && ((unsigned long)skb->data & 3))) {
88174 + /* make sure skb->data is aligned on arches that require it
88175 + * and check if ack-trimming & collapsing extended the headroom
88176 + * beyond what csum_start can cover.
88177 + */
88178 + if (unlikely((NET_IP_ALIGN && ((unsigned long)skb->data & 3)) ||
88179 + skb_headroom(skb) >= 0xFFFF)) {
88180 struct sk_buff *nskb = __pskb_copy(skb, MAX_TCP_HEADER,
88181 GFP_ATOMIC);
88182 return nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) :
88183 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
88184 index 4526fe6..1a34e43 100644
88185 --- a/net/ipv4/tcp_probe.c
88186 +++ b/net/ipv4/tcp_probe.c
88187 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
88188 if (cnt + width >= len)
88189 break;
88190
88191 - if (copy_to_user(buf + cnt, tbuf, width))
88192 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
88193 return -EFAULT;
88194 cnt += width;
88195 }
88196 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
88197 index b78aac3..e18230b 100644
88198 --- a/net/ipv4/tcp_timer.c
88199 +++ b/net/ipv4/tcp_timer.c
88200 @@ -22,6 +22,10 @@
88201 #include <linux/gfp.h>
88202 #include <net/tcp.h>
88203
88204 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88205 +extern int grsec_lastack_retries;
88206 +#endif
88207 +
88208 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
88209 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
88210 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
88211 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
88212 }
88213 }
88214
88215 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88216 + if ((sk->sk_state == TCP_LAST_ACK) &&
88217 + (grsec_lastack_retries > 0) &&
88218 + (grsec_lastack_retries < retry_until))
88219 + retry_until = grsec_lastack_retries;
88220 +#endif
88221 +
88222 if (retransmits_timed_out(sk, retry_until,
88223 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
88224 /* Has it gone just too far? */
88225 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
88226 index 1f4d405..3524677 100644
88227 --- a/net/ipv4/udp.c
88228 +++ b/net/ipv4/udp.c
88229 @@ -87,6 +87,7 @@
88230 #include <linux/types.h>
88231 #include <linux/fcntl.h>
88232 #include <linux/module.h>
88233 +#include <linux/security.h>
88234 #include <linux/socket.h>
88235 #include <linux/sockios.h>
88236 #include <linux/igmp.h>
88237 @@ -111,6 +112,10 @@
88238 #include <trace/events/skb.h>
88239 #include "udp_impl.h"
88240
88241 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88242 +extern int grsec_enable_blackhole;
88243 +#endif
88244 +
88245 struct udp_table udp_table __read_mostly;
88246 EXPORT_SYMBOL(udp_table);
88247
88248 @@ -569,6 +574,9 @@ found:
88249 return s;
88250 }
88251
88252 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
88253 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
88254 +
88255 /*
88256 * This routine is called by the ICMP module when it gets some
88257 * sort of error condition. If err < 0 then the socket should
88258 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
88259 dport = usin->sin_port;
88260 if (dport == 0)
88261 return -EINVAL;
88262 +
88263 + err = gr_search_udp_sendmsg(sk, usin);
88264 + if (err)
88265 + return err;
88266 } else {
88267 if (sk->sk_state != TCP_ESTABLISHED)
88268 return -EDESTADDRREQ;
88269 +
88270 + err = gr_search_udp_sendmsg(sk, NULL);
88271 + if (err)
88272 + return err;
88273 +
88274 daddr = inet->inet_daddr;
88275 dport = inet->inet_dport;
88276 /* Open fast path for connected socket.
88277 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
88278 udp_lib_checksum_complete(skb)) {
88279 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88280 IS_UDPLITE(sk));
88281 - atomic_inc(&sk->sk_drops);
88282 + atomic_inc_unchecked(&sk->sk_drops);
88283 __skb_unlink(skb, rcvq);
88284 __skb_queue_tail(&list_kill, skb);
88285 }
88286 @@ -1194,6 +1211,10 @@ try_again:
88287 if (!skb)
88288 goto out;
88289
88290 + err = gr_search_udp_recvmsg(sk, skb);
88291 + if (err)
88292 + goto out_free;
88293 +
88294 ulen = skb->len - sizeof(struct udphdr);
88295 copied = len;
88296 if (copied > ulen)
88297 @@ -1227,7 +1248,7 @@ try_again:
88298 if (unlikely(err)) {
88299 trace_kfree_skb(skb, udp_recvmsg);
88300 if (!peeked) {
88301 - atomic_inc(&sk->sk_drops);
88302 + atomic_inc_unchecked(&sk->sk_drops);
88303 UDP_INC_STATS_USER(sock_net(sk),
88304 UDP_MIB_INERRORS, is_udplite);
88305 }
88306 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88307
88308 drop:
88309 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88310 - atomic_inc(&sk->sk_drops);
88311 + atomic_inc_unchecked(&sk->sk_drops);
88312 kfree_skb(skb);
88313 return -1;
88314 }
88315 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88316 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88317
88318 if (!skb1) {
88319 - atomic_inc(&sk->sk_drops);
88320 + atomic_inc_unchecked(&sk->sk_drops);
88321 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88322 IS_UDPLITE(sk));
88323 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88324 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88325 goto csum_error;
88326
88327 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88328 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88329 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88330 +#endif
88331 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
88332
88333 /*
88334 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
88335 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
88336 0, sock_i_ino(sp),
88337 atomic_read(&sp->sk_refcnt), sp,
88338 - atomic_read(&sp->sk_drops), len);
88339 + atomic_read_unchecked(&sp->sk_drops), len);
88340 }
88341
88342 int udp4_seq_show(struct seq_file *seq, void *v)
88343 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
88344 index a36d17e..96d099f 100644
88345 --- a/net/ipv6/addrconf.c
88346 +++ b/net/ipv6/addrconf.c
88347 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
88348 p.iph.ihl = 5;
88349 p.iph.protocol = IPPROTO_IPV6;
88350 p.iph.ttl = 64;
88351 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
88352 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
88353
88354 if (ops->ndo_do_ioctl) {
88355 mm_segment_t oldfs = get_fs();
88356 @@ -4388,7 +4388,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
88357 int *valp = ctl->data;
88358 int val = *valp;
88359 loff_t pos = *ppos;
88360 - ctl_table lctl;
88361 + ctl_table_no_const lctl;
88362 int ret;
88363
88364 /*
88365 @@ -4470,7 +4470,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
88366 int *valp = ctl->data;
88367 int val = *valp;
88368 loff_t pos = *ppos;
88369 - ctl_table lctl;
88370 + ctl_table_no_const lctl;
88371 int ret;
88372
88373 /*
88374 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
88375 index fff5bdd..15194fb 100644
88376 --- a/net/ipv6/icmp.c
88377 +++ b/net/ipv6/icmp.c
88378 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
88379
88380 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
88381 {
88382 - struct ctl_table *table;
88383 + ctl_table_no_const *table;
88384
88385 table = kmemdup(ipv6_icmp_table_template,
88386 sizeof(ipv6_icmp_table_template),
88387 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
88388 index 131dd09..f7ed64f 100644
88389 --- a/net/ipv6/ip6_gre.c
88390 +++ b/net/ipv6/ip6_gre.c
88391 @@ -73,7 +73,7 @@ struct ip6gre_net {
88392 struct net_device *fb_tunnel_dev;
88393 };
88394
88395 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
88396 +static struct rtnl_link_ops ip6gre_link_ops;
88397 static int ip6gre_tunnel_init(struct net_device *dev);
88398 static void ip6gre_tunnel_setup(struct net_device *dev);
88399 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
88400 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
88401 }
88402
88403
88404 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
88405 +static struct inet6_protocol ip6gre_protocol = {
88406 .handler = ip6gre_rcv,
88407 .err_handler = ip6gre_err,
88408 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
88409 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
88410 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
88411 };
88412
88413 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88414 +static struct rtnl_link_ops ip6gre_link_ops = {
88415 .kind = "ip6gre",
88416 .maxtype = IFLA_GRE_MAX,
88417 .policy = ip6gre_policy,
88418 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88419 .fill_info = ip6gre_fill_info,
88420 };
88421
88422 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
88423 +static struct rtnl_link_ops ip6gre_tap_ops = {
88424 .kind = "ip6gretap",
88425 .maxtype = IFLA_GRE_MAX,
88426 .policy = ip6gre_policy,
88427 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
88428 index a14f28b..b4b8956 100644
88429 --- a/net/ipv6/ip6_tunnel.c
88430 +++ b/net/ipv6/ip6_tunnel.c
88431 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
88432
88433 static int ip6_tnl_dev_init(struct net_device *dev);
88434 static void ip6_tnl_dev_setup(struct net_device *dev);
88435 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
88436 +static struct rtnl_link_ops ip6_link_ops;
88437
88438 static int ip6_tnl_net_id __read_mostly;
88439 struct ip6_tnl_net {
88440 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
88441 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
88442 };
88443
88444 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
88445 +static struct rtnl_link_ops ip6_link_ops = {
88446 .kind = "ip6tnl",
88447 .maxtype = IFLA_IPTUN_MAX,
88448 .policy = ip6_tnl_policy,
88449 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
88450 index d1e2e8e..51c19ae 100644
88451 --- a/net/ipv6/ipv6_sockglue.c
88452 +++ b/net/ipv6/ipv6_sockglue.c
88453 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
88454 if (sk->sk_type != SOCK_STREAM)
88455 return -ENOPROTOOPT;
88456
88457 - msg.msg_control = optval;
88458 + msg.msg_control = (void __force_kernel *)optval;
88459 msg.msg_controllen = len;
88460 msg.msg_flags = flags;
88461
88462 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
88463 index 125a90d..2a11f36 100644
88464 --- a/net/ipv6/netfilter/ip6_tables.c
88465 +++ b/net/ipv6/netfilter/ip6_tables.c
88466 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
88467 #endif
88468
88469 static int get_info(struct net *net, void __user *user,
88470 - const int *len, int compat)
88471 + int len, int compat)
88472 {
88473 char name[XT_TABLE_MAXNAMELEN];
88474 struct xt_table *t;
88475 int ret;
88476
88477 - if (*len != sizeof(struct ip6t_getinfo)) {
88478 - duprintf("length %u != %zu\n", *len,
88479 + if (len != sizeof(struct ip6t_getinfo)) {
88480 + duprintf("length %u != %zu\n", len,
88481 sizeof(struct ip6t_getinfo));
88482 return -EINVAL;
88483 }
88484 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
88485 info.size = private->size;
88486 strcpy(info.name, name);
88487
88488 - if (copy_to_user(user, &info, *len) != 0)
88489 + if (copy_to_user(user, &info, len) != 0)
88490 ret = -EFAULT;
88491 else
88492 ret = 0;
88493 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88494
88495 switch (cmd) {
88496 case IP6T_SO_GET_INFO:
88497 - ret = get_info(sock_net(sk), user, len, 1);
88498 + ret = get_info(sock_net(sk), user, *len, 1);
88499 break;
88500 case IP6T_SO_GET_ENTRIES:
88501 ret = compat_get_entries(sock_net(sk), user, len);
88502 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88503
88504 switch (cmd) {
88505 case IP6T_SO_GET_INFO:
88506 - ret = get_info(sock_net(sk), user, len, 0);
88507 + ret = get_info(sock_net(sk), user, *len, 0);
88508 break;
88509
88510 case IP6T_SO_GET_ENTRIES:
88511 diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
88512 index 83acc14..0ea43c7 100644
88513 --- a/net/ipv6/netfilter/ip6t_NPT.c
88514 +++ b/net/ipv6/netfilter/ip6t_NPT.c
88515 @@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
88516 if (pfx_len - i >= 32)
88517 mask = 0;
88518 else
88519 - mask = htonl(~((1 << (pfx_len - i)) - 1));
88520 + mask = htonl((1 << (i - pfx_len + 32)) - 1);
88521
88522 idx = i / 32;
88523 addr->s6_addr32[idx] &= mask;
88524 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
88525 index 2f3a018..8bca195 100644
88526 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
88527 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
88528 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
88529
88530 static int nf_ct_frag6_sysctl_register(struct net *net)
88531 {
88532 - struct ctl_table *table;
88533 + ctl_table_no_const *table = NULL;
88534 struct ctl_table_header *hdr;
88535
88536 - table = nf_ct_frag6_sysctl_table;
88537 if (!net_eq(net, &init_net)) {
88538 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
88539 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
88540 GFP_KERNEL);
88541 if (table == NULL)
88542 goto err_alloc;
88543 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88544 table[0].data = &net->ipv6.frags.high_thresh;
88545 table[1].data = &net->ipv6.frags.low_thresh;
88546 table[2].data = &net->ipv6.frags.timeout;
88547 - }
88548 -
88549 - hdr = register_net_sysctl(net, "net/netfilter", table);
88550 + hdr = register_net_sysctl(net, "net/netfilter", table);
88551 + } else
88552 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
88553 if (hdr == NULL)
88554 goto err_reg;
88555
88556 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88557 return 0;
88558
88559 err_reg:
88560 - if (!net_eq(net, &init_net))
88561 - kfree(table);
88562 + kfree(table);
88563 err_alloc:
88564 return -ENOMEM;
88565 }
88566 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
88567 index 70fa814..d70c28c 100644
88568 --- a/net/ipv6/raw.c
88569 +++ b/net/ipv6/raw.c
88570 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
88571 {
88572 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
88573 skb_checksum_complete(skb)) {
88574 - atomic_inc(&sk->sk_drops);
88575 + atomic_inc_unchecked(&sk->sk_drops);
88576 kfree_skb(skb);
88577 return NET_RX_DROP;
88578 }
88579 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88580 struct raw6_sock *rp = raw6_sk(sk);
88581
88582 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
88583 - atomic_inc(&sk->sk_drops);
88584 + atomic_inc_unchecked(&sk->sk_drops);
88585 kfree_skb(skb);
88586 return NET_RX_DROP;
88587 }
88588 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88589
88590 if (inet->hdrincl) {
88591 if (skb_checksum_complete(skb)) {
88592 - atomic_inc(&sk->sk_drops);
88593 + atomic_inc_unchecked(&sk->sk_drops);
88594 kfree_skb(skb);
88595 return NET_RX_DROP;
88596 }
88597 @@ -604,7 +604,7 @@ out:
88598 return err;
88599 }
88600
88601 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
88602 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
88603 struct flowi6 *fl6, struct dst_entry **dstp,
88604 unsigned int flags)
88605 {
88606 @@ -916,12 +916,15 @@ do_confirm:
88607 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
88608 char __user *optval, int optlen)
88609 {
88610 + struct icmp6_filter filter;
88611 +
88612 switch (optname) {
88613 case ICMPV6_FILTER:
88614 if (optlen > sizeof(struct icmp6_filter))
88615 optlen = sizeof(struct icmp6_filter);
88616 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
88617 + if (copy_from_user(&filter, optval, optlen))
88618 return -EFAULT;
88619 + raw6_sk(sk)->filter = filter;
88620 return 0;
88621 default:
88622 return -ENOPROTOOPT;
88623 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88624 char __user *optval, int __user *optlen)
88625 {
88626 int len;
88627 + struct icmp6_filter filter;
88628
88629 switch (optname) {
88630 case ICMPV6_FILTER:
88631 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88632 len = sizeof(struct icmp6_filter);
88633 if (put_user(len, optlen))
88634 return -EFAULT;
88635 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88636 + filter = raw6_sk(sk)->filter;
88637 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88638 return -EFAULT;
88639 return 0;
88640 default:
88641 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88642 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88643 0,
88644 sock_i_ino(sp),
88645 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88646 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88647 }
88648
88649 static int raw6_seq_show(struct seq_file *seq, void *v)
88650 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88651 index d9ba8a2..f3f9e14 100644
88652 --- a/net/ipv6/reassembly.c
88653 +++ b/net/ipv6/reassembly.c
88654 @@ -608,12 +608,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88655
88656 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88657 {
88658 - struct ctl_table *table;
88659 + ctl_table_no_const *table = NULL;
88660 struct ctl_table_header *hdr;
88661
88662 - table = ip6_frags_ns_ctl_table;
88663 if (!net_eq(net, &init_net)) {
88664 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88665 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88666 if (table == NULL)
88667 goto err_alloc;
88668
88669 @@ -624,9 +623,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88670 /* Don't export sysctls to unprivileged users */
88671 if (net->user_ns != &init_user_ns)
88672 table[0].procname = NULL;
88673 - }
88674 + hdr = register_net_sysctl(net, "net/ipv6", table);
88675 + } else
88676 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88677
88678 - hdr = register_net_sysctl(net, "net/ipv6", table);
88679 if (hdr == NULL)
88680 goto err_reg;
88681
88682 @@ -634,8 +634,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88683 return 0;
88684
88685 err_reg:
88686 - if (!net_eq(net, &init_net))
88687 - kfree(table);
88688 + kfree(table);
88689 err_alloc:
88690 return -ENOMEM;
88691 }
88692 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88693 index 5845613..3af8fc7 100644
88694 --- a/net/ipv6/route.c
88695 +++ b/net/ipv6/route.c
88696 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
88697
88698 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88699 {
88700 - struct ctl_table *table;
88701 + ctl_table_no_const *table;
88702
88703 table = kmemdup(ipv6_route_table_template,
88704 sizeof(ipv6_route_table_template),
88705 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88706 index cfba99b..20ca511 100644
88707 --- a/net/ipv6/sit.c
88708 +++ b/net/ipv6/sit.c
88709 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88710 static int ipip6_tunnel_init(struct net_device *dev);
88711 static void ipip6_tunnel_setup(struct net_device *dev);
88712 static void ipip6_dev_free(struct net_device *dev);
88713 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88714 +static struct rtnl_link_ops sit_link_ops;
88715
88716 static int sit_net_id __read_mostly;
88717 struct sit_net {
88718 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88719 #endif
88720 };
88721
88722 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88723 +static struct rtnl_link_ops sit_link_ops = {
88724 .kind = "sit",
88725 .maxtype = IFLA_IPTUN_MAX,
88726 .policy = ipip6_policy,
88727 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88728 index e85c48b..b8268d3 100644
88729 --- a/net/ipv6/sysctl_net_ipv6.c
88730 +++ b/net/ipv6/sysctl_net_ipv6.c
88731 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88732
88733 static int __net_init ipv6_sysctl_net_init(struct net *net)
88734 {
88735 - struct ctl_table *ipv6_table;
88736 + ctl_table_no_const *ipv6_table;
88737 struct ctl_table *ipv6_route_table;
88738 struct ctl_table *ipv6_icmp_table;
88739 int err;
88740 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88741 index 8d19346..f122ba5 100644
88742 --- a/net/ipv6/tcp_ipv6.c
88743 +++ b/net/ipv6/tcp_ipv6.c
88744 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88745 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88746 }
88747
88748 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88749 +extern int grsec_enable_blackhole;
88750 +#endif
88751 +
88752 static void tcp_v6_hash(struct sock *sk)
88753 {
88754 if (sk->sk_state != TCP_CLOSE) {
88755 @@ -386,6 +390,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
88756
88757 if (dst)
88758 dst->ops->redirect(dst, sk, skb);
88759 + goto out;
88760 }
88761
88762 if (type == ICMPV6_PKT_TOOBIG) {
88763 @@ -1440,6 +1445,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88764 return 0;
88765
88766 reset:
88767 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88768 + if (!grsec_enable_blackhole)
88769 +#endif
88770 tcp_v6_send_reset(sk, skb);
88771 discard:
88772 if (opt_skb)
88773 @@ -1521,12 +1529,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88774 TCP_SKB_CB(skb)->sacked = 0;
88775
88776 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88777 - if (!sk)
88778 + if (!sk) {
88779 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88780 + ret = 1;
88781 +#endif
88782 goto no_tcp_socket;
88783 + }
88784
88785 process:
88786 - if (sk->sk_state == TCP_TIME_WAIT)
88787 + if (sk->sk_state == TCP_TIME_WAIT) {
88788 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88789 + ret = 2;
88790 +#endif
88791 goto do_time_wait;
88792 + }
88793
88794 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88795 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88796 @@ -1575,6 +1591,10 @@ no_tcp_socket:
88797 bad_packet:
88798 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88799 } else {
88800 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88801 + if (!grsec_enable_blackhole || (ret == 1 &&
88802 + (skb->dev->flags & IFF_LOOPBACK)))
88803 +#endif
88804 tcp_v6_send_reset(NULL, skb);
88805 }
88806
88807 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88808 index fb08329..2d6919e 100644
88809 --- a/net/ipv6/udp.c
88810 +++ b/net/ipv6/udp.c
88811 @@ -51,6 +51,10 @@
88812 #include <trace/events/skb.h>
88813 #include "udp_impl.h"
88814
88815 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88816 +extern int grsec_enable_blackhole;
88817 +#endif
88818 +
88819 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88820 {
88821 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88822 @@ -395,7 +399,7 @@ try_again:
88823 if (unlikely(err)) {
88824 trace_kfree_skb(skb, udpv6_recvmsg);
88825 if (!peeked) {
88826 - atomic_inc(&sk->sk_drops);
88827 + atomic_inc_unchecked(&sk->sk_drops);
88828 if (is_udp4)
88829 UDP_INC_STATS_USER(sock_net(sk),
88830 UDP_MIB_INERRORS,
88831 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88832 return rc;
88833 drop:
88834 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88835 - atomic_inc(&sk->sk_drops);
88836 + atomic_inc_unchecked(&sk->sk_drops);
88837 kfree_skb(skb);
88838 return -1;
88839 }
88840 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88841 if (likely(skb1 == NULL))
88842 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88843 if (!skb1) {
88844 - atomic_inc(&sk->sk_drops);
88845 + atomic_inc_unchecked(&sk->sk_drops);
88846 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88847 IS_UDPLITE(sk));
88848 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88849 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88850 goto discard;
88851
88852 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88853 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88854 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88855 +#endif
88856 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88857
88858 kfree_skb(skb);
88859 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88860 0,
88861 sock_i_ino(sp),
88862 atomic_read(&sp->sk_refcnt), sp,
88863 - atomic_read(&sp->sk_drops));
88864 + atomic_read_unchecked(&sp->sk_drops));
88865 }
88866
88867 int udp6_seq_show(struct seq_file *seq, void *v)
88868 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88869 index a68c88c..d55b0c5 100644
88870 --- a/net/irda/ircomm/ircomm_tty.c
88871 +++ b/net/irda/ircomm/ircomm_tty.c
88872 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88873 add_wait_queue(&port->open_wait, &wait);
88874
88875 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88876 - __FILE__, __LINE__, tty->driver->name, port->count);
88877 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88878
88879 spin_lock_irqsave(&port->lock, flags);
88880 if (!tty_hung_up_p(filp)) {
88881 extra_count = 1;
88882 - port->count--;
88883 + atomic_dec(&port->count);
88884 }
88885 spin_unlock_irqrestore(&port->lock, flags);
88886 port->blocked_open++;
88887 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88888 }
88889
88890 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88891 - __FILE__, __LINE__, tty->driver->name, port->count);
88892 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88893
88894 schedule();
88895 }
88896 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88897 if (extra_count) {
88898 /* ++ is not atomic, so this should be protected - Jean II */
88899 spin_lock_irqsave(&port->lock, flags);
88900 - port->count++;
88901 + atomic_inc(&port->count);
88902 spin_unlock_irqrestore(&port->lock, flags);
88903 }
88904 port->blocked_open--;
88905
88906 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88907 - __FILE__, __LINE__, tty->driver->name, port->count);
88908 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88909
88910 if (!retval)
88911 port->flags |= ASYNC_NORMAL_ACTIVE;
88912 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88913
88914 /* ++ is not atomic, so this should be protected - Jean II */
88915 spin_lock_irqsave(&self->port.lock, flags);
88916 - self->port.count++;
88917 + atomic_inc(&self->port.count);
88918 spin_unlock_irqrestore(&self->port.lock, flags);
88919 tty_port_tty_set(&self->port, tty);
88920
88921 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88922 - self->line, self->port.count);
88923 + self->line, atomic_read(&self->port.count));
88924
88925 /* Not really used by us, but lets do it anyway */
88926 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88927 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88928 tty_kref_put(port->tty);
88929 }
88930 port->tty = NULL;
88931 - port->count = 0;
88932 + atomic_set(&port->count, 0);
88933 spin_unlock_irqrestore(&port->lock, flags);
88934
88935 wake_up_interruptible(&port->open_wait);
88936 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88937 seq_putc(m, '\n');
88938
88939 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88940 - seq_printf(m, "Open count: %d\n", self->port.count);
88941 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88942 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88943 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88944
88945 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
88946 index e71e85b..29340a9 100644
88947 --- a/net/irda/iriap.c
88948 +++ b/net/irda/iriap.c
88949 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
88950 /* case CS_ISO_8859_9: */
88951 /* case CS_UNICODE: */
88952 default:
88953 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
88954 - __func__, ias_charset_types[charset]);
88955 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
88956 + __func__, charset,
88957 + charset < ARRAY_SIZE(ias_charset_types) ?
88958 + ias_charset_types[charset] :
88959 + "(unknown)");
88960
88961 /* Aborting, close connection! */
88962 iriap_disconnect_request(self);
88963 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88964 index cd6f7a9..e63fe89 100644
88965 --- a/net/iucv/af_iucv.c
88966 +++ b/net/iucv/af_iucv.c
88967 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
88968
88969 write_lock_bh(&iucv_sk_list.lock);
88970
88971 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88972 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88973 while (__iucv_get_sock_by_name(name)) {
88974 sprintf(name, "%08x",
88975 - atomic_inc_return(&iucv_sk_list.autobind_name));
88976 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88977 }
88978
88979 write_unlock_bh(&iucv_sk_list.lock);
88980 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88981 index df08250..02021fe 100644
88982 --- a/net/iucv/iucv.c
88983 +++ b/net/iucv/iucv.c
88984 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88985 return NOTIFY_OK;
88986 }
88987
88988 -static struct notifier_block __refdata iucv_cpu_notifier = {
88989 +static struct notifier_block iucv_cpu_notifier = {
88990 .notifier_call = iucv_cpu_notify,
88991 };
88992
88993 diff --git a/net/key/af_key.c b/net/key/af_key.c
88994 index 5b426a6..970032b 100644
88995 --- a/net/key/af_key.c
88996 +++ b/net/key/af_key.c
88997 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88998 static u32 get_acqseq(void)
88999 {
89000 u32 res;
89001 - static atomic_t acqseq;
89002 + static atomic_unchecked_t acqseq;
89003
89004 do {
89005 - res = atomic_inc_return(&acqseq);
89006 + res = atomic_inc_return_unchecked(&acqseq);
89007 } while (!res);
89008 return res;
89009 }
89010 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
89011 index 49c48c6..9e72ff4 100644
89012 --- a/net/mac80211/cfg.c
89013 +++ b/net/mac80211/cfg.c
89014 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
89015 ret = ieee80211_vif_use_channel(sdata, chandef,
89016 IEEE80211_CHANCTX_EXCLUSIVE);
89017 }
89018 - } else if (local->open_count == local->monitors) {
89019 + } else if (local_read(&local->open_count) == local->monitors) {
89020 local->_oper_channel = chandef->chan;
89021 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
89022 ieee80211_hw_config(local, 0);
89023 @@ -2718,7 +2718,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
89024 else
89025 local->probe_req_reg--;
89026
89027 - if (!local->open_count)
89028 + if (!local_read(&local->open_count))
89029 break;
89030
89031 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
89032 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
89033 index 55d8f89..bec0c2b 100644
89034 --- a/net/mac80211/ieee80211_i.h
89035 +++ b/net/mac80211/ieee80211_i.h
89036 @@ -28,6 +28,7 @@
89037 #include <net/ieee80211_radiotap.h>
89038 #include <net/cfg80211.h>
89039 #include <net/mac80211.h>
89040 +#include <asm/local.h>
89041 #include "key.h"
89042 #include "sta_info.h"
89043 #include "debug.h"
89044 @@ -910,7 +911,7 @@ struct ieee80211_local {
89045 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
89046 spinlock_t queue_stop_reason_lock;
89047
89048 - int open_count;
89049 + local_t open_count;
89050 int monitors, cooked_mntrs;
89051 /* number of interfaces with corresponding FIF_ flags */
89052 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
89053 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
89054 index 8be854e..ad72a69 100644
89055 --- a/net/mac80211/iface.c
89056 +++ b/net/mac80211/iface.c
89057 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89058 break;
89059 }
89060
89061 - if (local->open_count == 0) {
89062 + if (local_read(&local->open_count) == 0) {
89063 res = drv_start(local);
89064 if (res)
89065 goto err_del_bss;
89066 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89067 break;
89068 }
89069
89070 - if (local->monitors == 0 && local->open_count == 0) {
89071 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
89072 res = ieee80211_add_virtual_monitor(local);
89073 if (res)
89074 goto err_stop;
89075 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89076 mutex_unlock(&local->mtx);
89077
89078 if (coming_up)
89079 - local->open_count++;
89080 + local_inc(&local->open_count);
89081
89082 if (hw_reconf_flags)
89083 ieee80211_hw_config(local, hw_reconf_flags);
89084 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
89085 err_del_interface:
89086 drv_remove_interface(local, sdata);
89087 err_stop:
89088 - if (!local->open_count)
89089 + if (!local_read(&local->open_count))
89090 drv_stop(local);
89091 err_del_bss:
89092 sdata->bss = NULL;
89093 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89094 }
89095
89096 if (going_down)
89097 - local->open_count--;
89098 + local_dec(&local->open_count);
89099
89100 switch (sdata->vif.type) {
89101 case NL80211_IFTYPE_AP_VLAN:
89102 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89103
89104 ieee80211_recalc_ps(local, -1);
89105
89106 - if (local->open_count == 0) {
89107 + if (local_read(&local->open_count) == 0) {
89108 if (local->ops->napi_poll)
89109 napi_disable(&local->napi);
89110 ieee80211_clear_tx_pending(local);
89111 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
89112 }
89113 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
89114
89115 - if (local->monitors == local->open_count && local->monitors > 0)
89116 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
89117 ieee80211_add_virtual_monitor(local);
89118 }
89119
89120 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
89121 index 1b087ff..bf600e9 100644
89122 --- a/net/mac80211/main.c
89123 +++ b/net/mac80211/main.c
89124 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
89125 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
89126 IEEE80211_CONF_CHANGE_POWER);
89127
89128 - if (changed && local->open_count) {
89129 + if (changed && local_read(&local->open_count)) {
89130 ret = drv_config(local, changed);
89131 /*
89132 * Goal:
89133 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
89134 index 79a48f3..5e185c9 100644
89135 --- a/net/mac80211/pm.c
89136 +++ b/net/mac80211/pm.c
89137 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
89138 struct sta_info *sta;
89139 struct ieee80211_chanctx *ctx;
89140
89141 - if (!local->open_count)
89142 + if (!local_read(&local->open_count))
89143 goto suspend;
89144
89145 ieee80211_scan_cancel(local);
89146 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
89147 cancel_work_sync(&local->dynamic_ps_enable_work);
89148 del_timer_sync(&local->dynamic_ps_timer);
89149
89150 - local->wowlan = wowlan && local->open_count;
89151 + local->wowlan = wowlan && local_read(&local->open_count);
89152 if (local->wowlan) {
89153 int err = drv_suspend(local, wowlan);
89154 if (err < 0) {
89155 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
89156 mutex_unlock(&local->chanctx_mtx);
89157
89158 /* stop hardware - this must stop RX */
89159 - if (local->open_count)
89160 + if (local_read(&local->open_count))
89161 ieee80211_stop_device(local);
89162
89163 suspend:
89164 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
89165 index dd88381..eef4dd6 100644
89166 --- a/net/mac80211/rate.c
89167 +++ b/net/mac80211/rate.c
89168 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
89169
89170 ASSERT_RTNL();
89171
89172 - if (local->open_count)
89173 + if (local_read(&local->open_count))
89174 return -EBUSY;
89175
89176 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
89177 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
89178 index c97a065..ff61928 100644
89179 --- a/net/mac80211/rc80211_pid_debugfs.c
89180 +++ b/net/mac80211/rc80211_pid_debugfs.c
89181 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
89182
89183 spin_unlock_irqrestore(&events->lock, status);
89184
89185 - if (copy_to_user(buf, pb, p))
89186 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
89187 return -EFAULT;
89188
89189 return p;
89190 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
89191 index f11e8c5..08d0013 100644
89192 --- a/net/mac80211/util.c
89193 +++ b/net/mac80211/util.c
89194 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
89195 }
89196 #endif
89197 /* everything else happens only if HW was up & running */
89198 - if (!local->open_count)
89199 + if (!local_read(&local->open_count))
89200 goto wake_up;
89201
89202 /*
89203 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
89204 index 49e96df..63a51c3 100644
89205 --- a/net/netfilter/Kconfig
89206 +++ b/net/netfilter/Kconfig
89207 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
89208
89209 To compile it as a module, choose M here. If unsure, say N.
89210
89211 +config NETFILTER_XT_MATCH_GRADM
89212 + tristate '"gradm" match support'
89213 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
89214 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
89215 + ---help---
89216 + The gradm match allows to match on grsecurity RBAC being enabled.
89217 + It is useful when iptables rules are applied early on bootup to
89218 + prevent connections to the machine (except from a trusted host)
89219 + while the RBAC system is disabled.
89220 +
89221 config NETFILTER_XT_MATCH_HASHLIMIT
89222 tristate '"hashlimit" match support'
89223 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
89224 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
89225 index 3259697..54d5393 100644
89226 --- a/net/netfilter/Makefile
89227 +++ b/net/netfilter/Makefile
89228 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
89229 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
89230 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
89231 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
89232 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
89233 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
89234 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
89235 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
89236 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
89237 index 6d6d8f2..a676749 100644
89238 --- a/net/netfilter/ipset/ip_set_core.c
89239 +++ b/net/netfilter/ipset/ip_set_core.c
89240 @@ -1800,7 +1800,7 @@ done:
89241 return ret;
89242 }
89243
89244 -static struct nf_sockopt_ops so_set __read_mostly = {
89245 +static struct nf_sockopt_ops so_set = {
89246 .pf = PF_INET,
89247 .get_optmin = SO_IP_SET,
89248 .get_optmax = SO_IP_SET + 1,
89249 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
89250 index 30e764a..c3b6a9d 100644
89251 --- a/net/netfilter/ipvs/ip_vs_conn.c
89252 +++ b/net/netfilter/ipvs/ip_vs_conn.c
89253 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
89254 /* Increase the refcnt counter of the dest */
89255 atomic_inc(&dest->refcnt);
89256
89257 - conn_flags = atomic_read(&dest->conn_flags);
89258 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
89259 if (cp->protocol != IPPROTO_UDP)
89260 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
89261 flags = cp->flags;
89262 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
89263 atomic_set(&cp->refcnt, 1);
89264
89265 atomic_set(&cp->n_control, 0);
89266 - atomic_set(&cp->in_pkts, 0);
89267 + atomic_set_unchecked(&cp->in_pkts, 0);
89268
89269 atomic_inc(&ipvs->conn_count);
89270 if (flags & IP_VS_CONN_F_NO_CPORT)
89271 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
89272
89273 /* Don't drop the entry if its number of incoming packets is not
89274 located in [0, 8] */
89275 - i = atomic_read(&cp->in_pkts);
89276 + i = atomic_read_unchecked(&cp->in_pkts);
89277 if (i > 8 || i < 0) return 0;
89278
89279 if (!todrop_rate[i]) return 0;
89280 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
89281 index 47edf5a..235b07d 100644
89282 --- a/net/netfilter/ipvs/ip_vs_core.c
89283 +++ b/net/netfilter/ipvs/ip_vs_core.c
89284 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
89285 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
89286 /* do not touch skb anymore */
89287
89288 - atomic_inc(&cp->in_pkts);
89289 + atomic_inc_unchecked(&cp->in_pkts);
89290 ip_vs_conn_put(cp);
89291 return ret;
89292 }
89293 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
89294 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
89295 pkts = sysctl_sync_threshold(ipvs);
89296 else
89297 - pkts = atomic_add_return(1, &cp->in_pkts);
89298 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89299
89300 if (ipvs->sync_state & IP_VS_STATE_MASTER)
89301 ip_vs_sync_conn(net, cp, pkts);
89302 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
89303 index ec664cb..7f34a77 100644
89304 --- a/net/netfilter/ipvs/ip_vs_ctl.c
89305 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
89306 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
89307 ip_vs_rs_hash(ipvs, dest);
89308 write_unlock_bh(&ipvs->rs_lock);
89309 }
89310 - atomic_set(&dest->conn_flags, conn_flags);
89311 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
89312
89313 /* bind the service */
89314 if (!dest->svc) {
89315 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
89316 * align with netns init in ip_vs_control_net_init()
89317 */
89318
89319 -static struct ctl_table vs_vars[] = {
89320 +static ctl_table_no_const vs_vars[] __read_only = {
89321 {
89322 .procname = "amemthresh",
89323 .maxlen = sizeof(int),
89324 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89325 " %-7s %-6d %-10d %-10d\n",
89326 &dest->addr.in6,
89327 ntohs(dest->port),
89328 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89329 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89330 atomic_read(&dest->weight),
89331 atomic_read(&dest->activeconns),
89332 atomic_read(&dest->inactconns));
89333 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89334 "%-7s %-6d %-10d %-10d\n",
89335 ntohl(dest->addr.ip),
89336 ntohs(dest->port),
89337 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89338 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89339 atomic_read(&dest->weight),
89340 atomic_read(&dest->activeconns),
89341 atomic_read(&dest->inactconns));
89342 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
89343
89344 entry.addr = dest->addr.ip;
89345 entry.port = dest->port;
89346 - entry.conn_flags = atomic_read(&dest->conn_flags);
89347 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
89348 entry.weight = atomic_read(&dest->weight);
89349 entry.u_threshold = dest->u_threshold;
89350 entry.l_threshold = dest->l_threshold;
89351 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
89352 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
89353 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
89354 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
89355 - (atomic_read(&dest->conn_flags) &
89356 + (atomic_read_unchecked(&dest->conn_flags) &
89357 IP_VS_CONN_F_FWD_MASK)) ||
89358 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
89359 atomic_read(&dest->weight)) ||
89360 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
89361 {
89362 int idx;
89363 struct netns_ipvs *ipvs = net_ipvs(net);
89364 - struct ctl_table *tbl;
89365 + ctl_table_no_const *tbl;
89366
89367 atomic_set(&ipvs->dropentry, 0);
89368 spin_lock_init(&ipvs->dropentry_lock);
89369 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
89370 index fdd89b9..bd96aa9 100644
89371 --- a/net/netfilter/ipvs/ip_vs_lblc.c
89372 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
89373 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
89374 * IPVS LBLC sysctl table
89375 */
89376 #ifdef CONFIG_SYSCTL
89377 -static ctl_table vs_vars_table[] = {
89378 +static ctl_table_no_const vs_vars_table[] __read_only = {
89379 {
89380 .procname = "lblc_expiration",
89381 .data = NULL,
89382 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
89383 index c03b6a3..8ce3681 100644
89384 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
89385 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
89386 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
89387 * IPVS LBLCR sysctl table
89388 */
89389
89390 -static ctl_table vs_vars_table[] = {
89391 +static ctl_table_no_const vs_vars_table[] __read_only = {
89392 {
89393 .procname = "lblcr_expiration",
89394 .data = NULL,
89395 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
89396 index 44fd10c..2a163b3 100644
89397 --- a/net/netfilter/ipvs/ip_vs_sync.c
89398 +++ b/net/netfilter/ipvs/ip_vs_sync.c
89399 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
89400 cp = cp->control;
89401 if (cp) {
89402 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89403 - pkts = atomic_add_return(1, &cp->in_pkts);
89404 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89405 else
89406 pkts = sysctl_sync_threshold(ipvs);
89407 ip_vs_sync_conn(net, cp->control, pkts);
89408 @@ -758,7 +758,7 @@ control:
89409 if (!cp)
89410 return;
89411 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89412 - pkts = atomic_add_return(1, &cp->in_pkts);
89413 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89414 else
89415 pkts = sysctl_sync_threshold(ipvs);
89416 goto sloop;
89417 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
89418
89419 if (opt)
89420 memcpy(&cp->in_seq, opt, sizeof(*opt));
89421 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89422 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89423 cp->state = state;
89424 cp->old_state = cp->state;
89425 /*
89426 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
89427 index ee6b7a9..f9a89f6 100644
89428 --- a/net/netfilter/ipvs/ip_vs_xmit.c
89429 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
89430 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
89431 else
89432 rc = NF_ACCEPT;
89433 /* do not touch skb anymore */
89434 - atomic_inc(&cp->in_pkts);
89435 + atomic_inc_unchecked(&cp->in_pkts);
89436 goto out;
89437 }
89438
89439 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
89440 else
89441 rc = NF_ACCEPT;
89442 /* do not touch skb anymore */
89443 - atomic_inc(&cp->in_pkts);
89444 + atomic_inc_unchecked(&cp->in_pkts);
89445 goto out;
89446 }
89447
89448 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
89449 index 7df424e..a527b02 100644
89450 --- a/net/netfilter/nf_conntrack_acct.c
89451 +++ b/net/netfilter/nf_conntrack_acct.c
89452 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
89453 #ifdef CONFIG_SYSCTL
89454 static int nf_conntrack_acct_init_sysctl(struct net *net)
89455 {
89456 - struct ctl_table *table;
89457 + ctl_table_no_const *table;
89458
89459 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
89460 GFP_KERNEL);
89461 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
89462 index e4a0c4f..c263f28 100644
89463 --- a/net/netfilter/nf_conntrack_core.c
89464 +++ b/net/netfilter/nf_conntrack_core.c
89465 @@ -1529,6 +1529,10 @@ err_extend:
89466 #define DYING_NULLS_VAL ((1<<30)+1)
89467 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
89468
89469 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89470 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
89471 +#endif
89472 +
89473 static int nf_conntrack_init_net(struct net *net)
89474 {
89475 int ret;
89476 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
89477 goto err_stat;
89478 }
89479
89480 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89481 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
89482 +#else
89483 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
89484 +#endif
89485 if (!net->ct.slabname) {
89486 ret = -ENOMEM;
89487 goto err_slabname;
89488 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
89489 index faa978f..1afb18f 100644
89490 --- a/net/netfilter/nf_conntrack_ecache.c
89491 +++ b/net/netfilter/nf_conntrack_ecache.c
89492 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
89493 #ifdef CONFIG_SYSCTL
89494 static int nf_conntrack_event_init_sysctl(struct net *net)
89495 {
89496 - struct ctl_table *table;
89497 + ctl_table_no_const *table;
89498
89499 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
89500 GFP_KERNEL);
89501 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
89502 index 884f2b3..d53b33a 100644
89503 --- a/net/netfilter/nf_conntrack_helper.c
89504 +++ b/net/netfilter/nf_conntrack_helper.c
89505 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
89506
89507 static int nf_conntrack_helper_init_sysctl(struct net *net)
89508 {
89509 - struct ctl_table *table;
89510 + ctl_table_no_const *table;
89511
89512 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
89513 GFP_KERNEL);
89514 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
89515 index 51e928d..72a413a 100644
89516 --- a/net/netfilter/nf_conntrack_proto.c
89517 +++ b/net/netfilter/nf_conntrack_proto.c
89518 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
89519
89520 static void
89521 nf_ct_unregister_sysctl(struct ctl_table_header **header,
89522 - struct ctl_table **table,
89523 + ctl_table_no_const **table,
89524 unsigned int users)
89525 {
89526 if (users > 0)
89527 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
89528 index e7185c6..4ad6c9c 100644
89529 --- a/net/netfilter/nf_conntrack_standalone.c
89530 +++ b/net/netfilter/nf_conntrack_standalone.c
89531 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
89532
89533 static int nf_conntrack_standalone_init_sysctl(struct net *net)
89534 {
89535 - struct ctl_table *table;
89536 + ctl_table_no_const *table;
89537
89538 if (net_eq(net, &init_net)) {
89539 nf_ct_netfilter_header =
89540 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
89541 index 7ea8026..bc9512d 100644
89542 --- a/net/netfilter/nf_conntrack_timestamp.c
89543 +++ b/net/netfilter/nf_conntrack_timestamp.c
89544 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
89545 #ifdef CONFIG_SYSCTL
89546 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
89547 {
89548 - struct ctl_table *table;
89549 + ctl_table_no_const *table;
89550
89551 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
89552 GFP_KERNEL);
89553 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
89554 index 9e31269..bc4c1b7 100644
89555 --- a/net/netfilter/nf_log.c
89556 +++ b/net/netfilter/nf_log.c
89557 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
89558
89559 #ifdef CONFIG_SYSCTL
89560 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
89561 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
89562 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
89563 static struct ctl_table_header *nf_log_dir_header;
89564
89565 static int nf_log_proc_dostring(ctl_table *table, int write,
89566 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
89567 rcu_assign_pointer(nf_loggers[tindex], logger);
89568 mutex_unlock(&nf_log_mutex);
89569 } else {
89570 + ctl_table_no_const nf_log_table = *table;
89571 +
89572 mutex_lock(&nf_log_mutex);
89573 logger = rcu_dereference_protected(nf_loggers[tindex],
89574 lockdep_is_held(&nf_log_mutex));
89575 if (!logger)
89576 - table->data = "NONE";
89577 + nf_log_table.data = "NONE";
89578 else
89579 - table->data = logger->name;
89580 - r = proc_dostring(table, write, buffer, lenp, ppos);
89581 + nf_log_table.data = logger->name;
89582 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
89583 mutex_unlock(&nf_log_mutex);
89584 }
89585
89586 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
89587 index f042ae5..30ea486 100644
89588 --- a/net/netfilter/nf_sockopt.c
89589 +++ b/net/netfilter/nf_sockopt.c
89590 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
89591 }
89592 }
89593
89594 - list_add(&reg->list, &nf_sockopts);
89595 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
89596 out:
89597 mutex_unlock(&nf_sockopt_mutex);
89598 return ret;
89599 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
89600 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
89601 {
89602 mutex_lock(&nf_sockopt_mutex);
89603 - list_del(&reg->list);
89604 + pax_list_del((struct list_head *)&reg->list);
89605 mutex_unlock(&nf_sockopt_mutex);
89606 }
89607 EXPORT_SYMBOL(nf_unregister_sockopt);
89608 diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
89609 index 589d686..dc3fd5d 100644
89610 --- a/net/netfilter/nfnetlink_acct.c
89611 +++ b/net/netfilter/nfnetlink_acct.c
89612 @@ -49,6 +49,8 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
89613 return -EINVAL;
89614
89615 acct_name = nla_data(tb[NFACCT_NAME]);
89616 + if (strlen(acct_name) == 0)
89617 + return -EINVAL;
89618
89619 list_for_each_entry(nfacct, &nfnl_acct_list, head) {
89620 if (strncmp(nfacct->name, acct_name, NFACCT_NAME_MAX) != 0)
89621 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
89622 index 92fd8ec..3f6ea4b 100644
89623 --- a/net/netfilter/nfnetlink_log.c
89624 +++ b/net/netfilter/nfnetlink_log.c
89625 @@ -72,7 +72,7 @@ struct nfulnl_instance {
89626 };
89627
89628 static DEFINE_SPINLOCK(instances_lock);
89629 -static atomic_t global_seq;
89630 +static atomic_unchecked_t global_seq;
89631
89632 #define INSTANCE_BUCKETS 16
89633 static struct hlist_head instance_table[INSTANCE_BUCKETS];
89634 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
89635 /* global sequence number */
89636 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89637 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89638 - htonl(atomic_inc_return(&global_seq))))
89639 + htonl(atomic_inc_return_unchecked(&global_seq))))
89640 goto nla_put_failure;
89641
89642 if (data_len) {
89643 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
89644 index 3158d87..39006c9 100644
89645 --- a/net/netfilter/nfnetlink_queue_core.c
89646 +++ b/net/netfilter/nfnetlink_queue_core.c
89647 @@ -1064,8 +1064,10 @@ static int __init nfnetlink_queue_init(void)
89648
89649 #ifdef CONFIG_PROC_FS
89650 if (!proc_create("nfnetlink_queue", 0440,
89651 - proc_net_netfilter, &nfqnl_file_ops))
89652 + proc_net_netfilter, &nfqnl_file_ops)) {
89653 + status = -ENOMEM;
89654 goto cleanup_subsys;
89655 + }
89656 #endif
89657
89658 register_netdevice_notifier(&nfqnl_dev_notifier);
89659 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89660 new file mode 100644
89661 index 0000000..c566332
89662 --- /dev/null
89663 +++ b/net/netfilter/xt_gradm.c
89664 @@ -0,0 +1,51 @@
89665 +/*
89666 + * gradm match for netfilter
89667 + * Copyright © Zbigniew Krzystolik, 2010
89668 + *
89669 + * This program is free software; you can redistribute it and/or modify
89670 + * it under the terms of the GNU General Public License; either version
89671 + * 2 or 3 as published by the Free Software Foundation.
89672 + */
89673 +#include <linux/module.h>
89674 +#include <linux/moduleparam.h>
89675 +#include <linux/skbuff.h>
89676 +#include <linux/netfilter/x_tables.h>
89677 +#include <linux/grsecurity.h>
89678 +#include <linux/netfilter/xt_gradm.h>
89679 +
89680 +static bool
89681 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89682 +{
89683 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89684 + bool retval = false;
89685 + if (gr_acl_is_enabled())
89686 + retval = true;
89687 + return retval ^ info->invflags;
89688 +}
89689 +
89690 +static struct xt_match gradm_mt_reg __read_mostly = {
89691 + .name = "gradm",
89692 + .revision = 0,
89693 + .family = NFPROTO_UNSPEC,
89694 + .match = gradm_mt,
89695 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89696 + .me = THIS_MODULE,
89697 +};
89698 +
89699 +static int __init gradm_mt_init(void)
89700 +{
89701 + return xt_register_match(&gradm_mt_reg);
89702 +}
89703 +
89704 +static void __exit gradm_mt_exit(void)
89705 +{
89706 + xt_unregister_match(&gradm_mt_reg);
89707 +}
89708 +
89709 +module_init(gradm_mt_init);
89710 +module_exit(gradm_mt_exit);
89711 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89712 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89713 +MODULE_LICENSE("GPL");
89714 +MODULE_ALIAS("ipt_gradm");
89715 +MODULE_ALIAS("ip6t_gradm");
89716 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89717 index 4fe4fb4..87a89e5 100644
89718 --- a/net/netfilter/xt_statistic.c
89719 +++ b/net/netfilter/xt_statistic.c
89720 @@ -19,7 +19,7 @@
89721 #include <linux/module.h>
89722
89723 struct xt_statistic_priv {
89724 - atomic_t count;
89725 + atomic_unchecked_t count;
89726 } ____cacheline_aligned_in_smp;
89727
89728 MODULE_LICENSE("GPL");
89729 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89730 break;
89731 case XT_STATISTIC_MODE_NTH:
89732 do {
89733 - oval = atomic_read(&info->master->count);
89734 + oval = atomic_read_unchecked(&info->master->count);
89735 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89736 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89737 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89738 if (nval == 0)
89739 ret = !ret;
89740 break;
89741 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89742 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89743 if (info->master == NULL)
89744 return -ENOMEM;
89745 - atomic_set(&info->master->count, info->u.nth.count);
89746 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89747
89748 return 0;
89749 }
89750 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89751 index c0353d5..fcb0270 100644
89752 --- a/net/netlink/af_netlink.c
89753 +++ b/net/netlink/af_netlink.c
89754 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
89755 sk->sk_error_report(sk);
89756 }
89757 }
89758 - atomic_inc(&sk->sk_drops);
89759 + atomic_inc_unchecked(&sk->sk_drops);
89760 }
89761
89762 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89763 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89764 sk_wmem_alloc_get(s),
89765 nlk->cb,
89766 atomic_read(&s->sk_refcnt),
89767 - atomic_read(&s->sk_drops),
89768 + atomic_read_unchecked(&s->sk_drops),
89769 sock_i_ino(s)
89770 );
89771
89772 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89773 index 5a55be3..7630745 100644
89774 --- a/net/netlink/genetlink.c
89775 +++ b/net/netlink/genetlink.c
89776 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89777 goto errout;
89778 }
89779
89780 + pax_open_kernel();
89781 if (ops->dumpit)
89782 - ops->flags |= GENL_CMD_CAP_DUMP;
89783 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89784 if (ops->doit)
89785 - ops->flags |= GENL_CMD_CAP_DO;
89786 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89787 if (ops->policy)
89788 - ops->flags |= GENL_CMD_CAP_HASPOL;
89789 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89790 + pax_close_kernel();
89791
89792 genl_lock();
89793 - list_add_tail(&ops->ops_list, &family->ops_list);
89794 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89795 genl_unlock();
89796
89797 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89798 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89799 err = 0;
89800 errout:
89801 return err;
89802 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89803 genl_lock();
89804 list_for_each_entry(rc, &family->ops_list, ops_list) {
89805 if (rc == ops) {
89806 - list_del(&ops->ops_list);
89807 + pax_list_del((struct list_head *)&ops->ops_list);
89808 genl_unlock();
89809 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89810 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89811 return 0;
89812 }
89813 }
89814 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89815 index 7261eb8..44e8ac6 100644
89816 --- a/net/netrom/af_netrom.c
89817 +++ b/net/netrom/af_netrom.c
89818 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89819 struct sock *sk = sock->sk;
89820 struct nr_sock *nr = nr_sk(sk);
89821
89822 + memset(sax, 0, sizeof(*sax));
89823 lock_sock(sk);
89824 if (peer != 0) {
89825 if (sk->sk_state != TCP_ESTABLISHED) {
89826 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89827 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89828 } else {
89829 sax->fsa_ax25.sax25_family = AF_NETROM;
89830 - sax->fsa_ax25.sax25_ndigis = 0;
89831 sax->fsa_ax25.sax25_call = nr->source_addr;
89832 *uaddr_len = sizeof(struct sockaddr_ax25);
89833 }
89834 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89835 index c111bd0..7788ff7 100644
89836 --- a/net/packet/af_packet.c
89837 +++ b/net/packet/af_packet.c
89838 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89839
89840 spin_lock(&sk->sk_receive_queue.lock);
89841 po->stats.tp_packets++;
89842 - skb->dropcount = atomic_read(&sk->sk_drops);
89843 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89844 __skb_queue_tail(&sk->sk_receive_queue, skb);
89845 spin_unlock(&sk->sk_receive_queue.lock);
89846 sk->sk_data_ready(sk, skb->len);
89847 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89848 drop_n_acct:
89849 spin_lock(&sk->sk_receive_queue.lock);
89850 po->stats.tp_drops++;
89851 - atomic_inc(&sk->sk_drops);
89852 + atomic_inc_unchecked(&sk->sk_drops);
89853 spin_unlock(&sk->sk_receive_queue.lock);
89854
89855 drop_n_restore:
89856 @@ -2565,6 +2565,7 @@ out:
89857
89858 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89859 {
89860 + struct sock_extended_err ee;
89861 struct sock_exterr_skb *serr;
89862 struct sk_buff *skb, *skb2;
89863 int copied, err;
89864 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89865 sock_recv_timestamp(msg, sk, skb);
89866
89867 serr = SKB_EXT_ERR(skb);
89868 + ee = serr->ee;
89869 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89870 - sizeof(serr->ee), &serr->ee);
89871 + sizeof ee, &ee);
89872
89873 msg->msg_flags |= MSG_ERRQUEUE;
89874 err = copied;
89875 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89876 case PACKET_HDRLEN:
89877 if (len > sizeof(int))
89878 len = sizeof(int);
89879 - if (copy_from_user(&val, optval, len))
89880 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89881 return -EFAULT;
89882 switch (val) {
89883 case TPACKET_V1:
89884 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89885 len = lv;
89886 if (put_user(len, optlen))
89887 return -EFAULT;
89888 - if (copy_to_user(optval, data, len))
89889 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89890 return -EFAULT;
89891 return 0;
89892 }
89893 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89894 index 5a940db..f0b9c12 100644
89895 --- a/net/phonet/af_phonet.c
89896 +++ b/net/phonet/af_phonet.c
89897 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
89898 {
89899 struct phonet_protocol *pp;
89900
89901 - if (protocol >= PHONET_NPROTO)
89902 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89903 return NULL;
89904
89905 rcu_read_lock();
89906 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89907 {
89908 int err = 0;
89909
89910 - if (protocol >= PHONET_NPROTO)
89911 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89912 return -EINVAL;
89913
89914 err = proto_register(pp->prot, 1);
89915 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89916 index 576f22c..bc7a71b 100644
89917 --- a/net/phonet/pep.c
89918 +++ b/net/phonet/pep.c
89919 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89920
89921 case PNS_PEP_CTRL_REQ:
89922 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89923 - atomic_inc(&sk->sk_drops);
89924 + atomic_inc_unchecked(&sk->sk_drops);
89925 break;
89926 }
89927 __skb_pull(skb, 4);
89928 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89929 }
89930
89931 if (pn->rx_credits == 0) {
89932 - atomic_inc(&sk->sk_drops);
89933 + atomic_inc_unchecked(&sk->sk_drops);
89934 err = -ENOBUFS;
89935 break;
89936 }
89937 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89938 }
89939
89940 if (pn->rx_credits == 0) {
89941 - atomic_inc(&sk->sk_drops);
89942 + atomic_inc_unchecked(&sk->sk_drops);
89943 err = NET_RX_DROP;
89944 break;
89945 }
89946 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89947 index b7e9827..c264c85 100644
89948 --- a/net/phonet/socket.c
89949 +++ b/net/phonet/socket.c
89950 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89951 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89952 sock_i_ino(sk),
89953 atomic_read(&sk->sk_refcnt), sk,
89954 - atomic_read(&sk->sk_drops), &len);
89955 + atomic_read_unchecked(&sk->sk_drops), &len);
89956 }
89957 seq_printf(seq, "%*s\n", 127 - len, "");
89958 return 0;
89959 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89960 index d6bbbbd..61561e4 100644
89961 --- a/net/phonet/sysctl.c
89962 +++ b/net/phonet/sysctl.c
89963 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89964 {
89965 int ret;
89966 int range[2] = {local_port_range[0], local_port_range[1]};
89967 - ctl_table tmp = {
89968 + ctl_table_no_const tmp = {
89969 .data = &range,
89970 .maxlen = sizeof(range),
89971 .mode = table->mode,
89972 diff --git a/net/rds/cong.c b/net/rds/cong.c
89973 index e5b65ac..f3b6fb7 100644
89974 --- a/net/rds/cong.c
89975 +++ b/net/rds/cong.c
89976 @@ -78,7 +78,7 @@
89977 * finds that the saved generation number is smaller than the global generation
89978 * number, it wakes up the process.
89979 */
89980 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89981 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89982
89983 /*
89984 * Congestion monitoring
89985 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89986 rdsdebug("waking map %p for %pI4\n",
89987 map, &map->m_addr);
89988 rds_stats_inc(s_cong_update_received);
89989 - atomic_inc(&rds_cong_generation);
89990 + atomic_inc_unchecked(&rds_cong_generation);
89991 if (waitqueue_active(&map->m_waitq))
89992 wake_up(&map->m_waitq);
89993 if (waitqueue_active(&rds_poll_waitq))
89994 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89995
89996 int rds_cong_updated_since(unsigned long *recent)
89997 {
89998 - unsigned long gen = atomic_read(&rds_cong_generation);
89999 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
90000
90001 if (likely(*recent == gen))
90002 return 0;
90003 diff --git a/net/rds/ib.h b/net/rds/ib.h
90004 index 7280ab8..e04f4ea 100644
90005 --- a/net/rds/ib.h
90006 +++ b/net/rds/ib.h
90007 @@ -128,7 +128,7 @@ struct rds_ib_connection {
90008 /* sending acks */
90009 unsigned long i_ack_flags;
90010 #ifdef KERNEL_HAS_ATOMIC64
90011 - atomic64_t i_ack_next; /* next ACK to send */
90012 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
90013 #else
90014 spinlock_t i_ack_lock; /* protect i_ack_next */
90015 u64 i_ack_next; /* next ACK to send */
90016 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
90017 index 31b74f5..dc1fbfa 100644
90018 --- a/net/rds/ib_cm.c
90019 +++ b/net/rds/ib_cm.c
90020 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
90021 /* Clear the ACK state */
90022 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
90023 #ifdef KERNEL_HAS_ATOMIC64
90024 - atomic64_set(&ic->i_ack_next, 0);
90025 + atomic64_set_unchecked(&ic->i_ack_next, 0);
90026 #else
90027 ic->i_ack_next = 0;
90028 #endif
90029 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
90030 index 8eb9501..0c386ff 100644
90031 --- a/net/rds/ib_recv.c
90032 +++ b/net/rds/ib_recv.c
90033 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
90034 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
90035 int ack_required)
90036 {
90037 - atomic64_set(&ic->i_ack_next, seq);
90038 + atomic64_set_unchecked(&ic->i_ack_next, seq);
90039 if (ack_required) {
90040 smp_mb__before_clear_bit();
90041 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90042 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
90043 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90044 smp_mb__after_clear_bit();
90045
90046 - return atomic64_read(&ic->i_ack_next);
90047 + return atomic64_read_unchecked(&ic->i_ack_next);
90048 }
90049 #endif
90050
90051 diff --git a/net/rds/iw.h b/net/rds/iw.h
90052 index 04ce3b1..48119a6 100644
90053 --- a/net/rds/iw.h
90054 +++ b/net/rds/iw.h
90055 @@ -134,7 +134,7 @@ struct rds_iw_connection {
90056 /* sending acks */
90057 unsigned long i_ack_flags;
90058 #ifdef KERNEL_HAS_ATOMIC64
90059 - atomic64_t i_ack_next; /* next ACK to send */
90060 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
90061 #else
90062 spinlock_t i_ack_lock; /* protect i_ack_next */
90063 u64 i_ack_next; /* next ACK to send */
90064 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
90065 index a91e1db..cf3053f 100644
90066 --- a/net/rds/iw_cm.c
90067 +++ b/net/rds/iw_cm.c
90068 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
90069 /* Clear the ACK state */
90070 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
90071 #ifdef KERNEL_HAS_ATOMIC64
90072 - atomic64_set(&ic->i_ack_next, 0);
90073 + atomic64_set_unchecked(&ic->i_ack_next, 0);
90074 #else
90075 ic->i_ack_next = 0;
90076 #endif
90077 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
90078 index 4503335..db566b4 100644
90079 --- a/net/rds/iw_recv.c
90080 +++ b/net/rds/iw_recv.c
90081 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
90082 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
90083 int ack_required)
90084 {
90085 - atomic64_set(&ic->i_ack_next, seq);
90086 + atomic64_set_unchecked(&ic->i_ack_next, seq);
90087 if (ack_required) {
90088 smp_mb__before_clear_bit();
90089 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90090 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
90091 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
90092 smp_mb__after_clear_bit();
90093
90094 - return atomic64_read(&ic->i_ack_next);
90095 + return atomic64_read_unchecked(&ic->i_ack_next);
90096 }
90097 #endif
90098
90099 diff --git a/net/rds/rds.h b/net/rds/rds.h
90100 index ec1d731..90a3a8d 100644
90101 --- a/net/rds/rds.h
90102 +++ b/net/rds/rds.h
90103 @@ -449,7 +449,7 @@ struct rds_transport {
90104 void (*sync_mr)(void *trans_private, int direction);
90105 void (*free_mr)(void *trans_private, int invalidate);
90106 void (*flush_mrs)(void);
90107 -};
90108 +} __do_const;
90109
90110 struct rds_sock {
90111 struct sock rs_sk;
90112 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
90113 index edac9ef..16bcb98 100644
90114 --- a/net/rds/tcp.c
90115 +++ b/net/rds/tcp.c
90116 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
90117 int val = 1;
90118
90119 set_fs(KERNEL_DS);
90120 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
90121 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
90122 sizeof(val));
90123 set_fs(oldfs);
90124 }
90125 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
90126 index 81cf5a4..b5826ff 100644
90127 --- a/net/rds/tcp_send.c
90128 +++ b/net/rds/tcp_send.c
90129 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
90130
90131 oldfs = get_fs();
90132 set_fs(KERNEL_DS);
90133 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
90134 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
90135 sizeof(val));
90136 set_fs(oldfs);
90137 }
90138 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
90139 index 05996d0..5a1dfe0 100644
90140 --- a/net/rxrpc/af_rxrpc.c
90141 +++ b/net/rxrpc/af_rxrpc.c
90142 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
90143 __be32 rxrpc_epoch;
90144
90145 /* current debugging ID */
90146 -atomic_t rxrpc_debug_id;
90147 +atomic_unchecked_t rxrpc_debug_id;
90148
90149 /* count of skbs currently in use */
90150 atomic_t rxrpc_n_skbs;
90151 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
90152 index e4d9cbc..b229649 100644
90153 --- a/net/rxrpc/ar-ack.c
90154 +++ b/net/rxrpc/ar-ack.c
90155 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
90156
90157 _enter("{%d,%d,%d,%d},",
90158 call->acks_hard, call->acks_unacked,
90159 - atomic_read(&call->sequence),
90160 + atomic_read_unchecked(&call->sequence),
90161 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
90162
90163 stop = 0;
90164 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
90165
90166 /* each Tx packet has a new serial number */
90167 sp->hdr.serial =
90168 - htonl(atomic_inc_return(&call->conn->serial));
90169 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
90170
90171 hdr = (struct rxrpc_header *) txb->head;
90172 hdr->serial = sp->hdr.serial;
90173 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
90174 */
90175 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
90176 {
90177 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
90178 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
90179 }
90180
90181 /*
90182 @@ -629,7 +629,7 @@ process_further:
90183
90184 latest = ntohl(sp->hdr.serial);
90185 hard = ntohl(ack.firstPacket);
90186 - tx = atomic_read(&call->sequence);
90187 + tx = atomic_read_unchecked(&call->sequence);
90188
90189 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
90190 latest,
90191 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
90192 goto maybe_reschedule;
90193
90194 send_ACK_with_skew:
90195 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
90196 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
90197 ntohl(ack.serial));
90198 send_ACK:
90199 mtu = call->conn->trans->peer->if_mtu;
90200 @@ -1173,7 +1173,7 @@ send_ACK:
90201 ackinfo.rxMTU = htonl(5692);
90202 ackinfo.jumbo_max = htonl(4);
90203
90204 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
90205 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
90206 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
90207 ntohl(hdr.serial),
90208 ntohs(ack.maxSkew),
90209 @@ -1191,7 +1191,7 @@ send_ACK:
90210 send_message:
90211 _debug("send message");
90212
90213 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
90214 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
90215 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
90216 send_message_2:
90217
90218 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
90219 index a3bbb36..3341fb9 100644
90220 --- a/net/rxrpc/ar-call.c
90221 +++ b/net/rxrpc/ar-call.c
90222 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
90223 spin_lock_init(&call->lock);
90224 rwlock_init(&call->state_lock);
90225 atomic_set(&call->usage, 1);
90226 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
90227 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90228 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
90229
90230 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
90231 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
90232 index 4106ca9..a338d7a 100644
90233 --- a/net/rxrpc/ar-connection.c
90234 +++ b/net/rxrpc/ar-connection.c
90235 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
90236 rwlock_init(&conn->lock);
90237 spin_lock_init(&conn->state_lock);
90238 atomic_set(&conn->usage, 1);
90239 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
90240 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90241 conn->avail_calls = RXRPC_MAXCALLS;
90242 conn->size_align = 4;
90243 conn->header_size = sizeof(struct rxrpc_header);
90244 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
90245 index e7ed43a..6afa140 100644
90246 --- a/net/rxrpc/ar-connevent.c
90247 +++ b/net/rxrpc/ar-connevent.c
90248 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
90249
90250 len = iov[0].iov_len + iov[1].iov_len;
90251
90252 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90253 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90254 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
90255
90256 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90257 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
90258 index 529572f..c758ca7 100644
90259 --- a/net/rxrpc/ar-input.c
90260 +++ b/net/rxrpc/ar-input.c
90261 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
90262 /* track the latest serial number on this connection for ACK packet
90263 * information */
90264 serial = ntohl(sp->hdr.serial);
90265 - hi_serial = atomic_read(&call->conn->hi_serial);
90266 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
90267 while (serial > hi_serial)
90268 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
90269 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
90270 serial);
90271
90272 /* request ACK generation for any ACK or DATA packet that requests
90273 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
90274 index a693aca..81e7293 100644
90275 --- a/net/rxrpc/ar-internal.h
90276 +++ b/net/rxrpc/ar-internal.h
90277 @@ -272,8 +272,8 @@ struct rxrpc_connection {
90278 int error; /* error code for local abort */
90279 int debug_id; /* debug ID for printks */
90280 unsigned int call_counter; /* call ID counter */
90281 - atomic_t serial; /* packet serial number counter */
90282 - atomic_t hi_serial; /* highest serial number received */
90283 + atomic_unchecked_t serial; /* packet serial number counter */
90284 + atomic_unchecked_t hi_serial; /* highest serial number received */
90285 u8 avail_calls; /* number of calls available */
90286 u8 size_align; /* data size alignment (for security) */
90287 u8 header_size; /* rxrpc + security header size */
90288 @@ -346,7 +346,7 @@ struct rxrpc_call {
90289 spinlock_t lock;
90290 rwlock_t state_lock; /* lock for state transition */
90291 atomic_t usage;
90292 - atomic_t sequence; /* Tx data packet sequence counter */
90293 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
90294 u32 abort_code; /* local/remote abort code */
90295 enum { /* current state of call */
90296 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
90297 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
90298 */
90299 extern atomic_t rxrpc_n_skbs;
90300 extern __be32 rxrpc_epoch;
90301 -extern atomic_t rxrpc_debug_id;
90302 +extern atomic_unchecked_t rxrpc_debug_id;
90303 extern struct workqueue_struct *rxrpc_workqueue;
90304
90305 /*
90306 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
90307 index 87f7135..74d3703 100644
90308 --- a/net/rxrpc/ar-local.c
90309 +++ b/net/rxrpc/ar-local.c
90310 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
90311 spin_lock_init(&local->lock);
90312 rwlock_init(&local->services_lock);
90313 atomic_set(&local->usage, 1);
90314 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
90315 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90316 memcpy(&local->srx, srx, sizeof(*srx));
90317 }
90318
90319 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
90320 index e1ac183..b43e10e 100644
90321 --- a/net/rxrpc/ar-output.c
90322 +++ b/net/rxrpc/ar-output.c
90323 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
90324 sp->hdr.cid = call->cid;
90325 sp->hdr.callNumber = call->call_id;
90326 sp->hdr.seq =
90327 - htonl(atomic_inc_return(&call->sequence));
90328 + htonl(atomic_inc_return_unchecked(&call->sequence));
90329 sp->hdr.serial =
90330 - htonl(atomic_inc_return(&conn->serial));
90331 + htonl(atomic_inc_return_unchecked(&conn->serial));
90332 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
90333 sp->hdr.userStatus = 0;
90334 sp->hdr.securityIndex = conn->security_ix;
90335 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
90336 index bebaa43..2644591 100644
90337 --- a/net/rxrpc/ar-peer.c
90338 +++ b/net/rxrpc/ar-peer.c
90339 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
90340 INIT_LIST_HEAD(&peer->error_targets);
90341 spin_lock_init(&peer->lock);
90342 atomic_set(&peer->usage, 1);
90343 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
90344 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90345 memcpy(&peer->srx, srx, sizeof(*srx));
90346
90347 rxrpc_assess_MTU_size(peer);
90348 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
90349 index 38047f7..9f48511 100644
90350 --- a/net/rxrpc/ar-proc.c
90351 +++ b/net/rxrpc/ar-proc.c
90352 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
90353 atomic_read(&conn->usage),
90354 rxrpc_conn_states[conn->state],
90355 key_serial(conn->key),
90356 - atomic_read(&conn->serial),
90357 - atomic_read(&conn->hi_serial));
90358 + atomic_read_unchecked(&conn->serial),
90359 + atomic_read_unchecked(&conn->hi_serial));
90360
90361 return 0;
90362 }
90363 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
90364 index 92df566..87ec1bf 100644
90365 --- a/net/rxrpc/ar-transport.c
90366 +++ b/net/rxrpc/ar-transport.c
90367 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
90368 spin_lock_init(&trans->client_lock);
90369 rwlock_init(&trans->conn_lock);
90370 atomic_set(&trans->usage, 1);
90371 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
90372 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90373
90374 if (peer->srx.transport.family == AF_INET) {
90375 switch (peer->srx.transport_type) {
90376 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
90377 index f226709..0e735a8 100644
90378 --- a/net/rxrpc/rxkad.c
90379 +++ b/net/rxrpc/rxkad.c
90380 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
90381
90382 len = iov[0].iov_len + iov[1].iov_len;
90383
90384 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90385 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90386 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
90387
90388 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90389 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
90390
90391 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
90392
90393 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
90394 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90395 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
90396
90397 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
90398 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
90399 index 391a245..296b3d7 100644
90400 --- a/net/sctp/ipv6.c
90401 +++ b/net/sctp/ipv6.c
90402 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
90403 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
90404 };
90405
90406 -static struct sctp_af sctp_af_inet6 = {
90407 +static struct sctp_af sctp_af_inet6 __read_only = {
90408 .sa_family = AF_INET6,
90409 .sctp_xmit = sctp_v6_xmit,
90410 .setsockopt = ipv6_setsockopt,
90411 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
90412 #endif
90413 };
90414
90415 -static struct sctp_pf sctp_pf_inet6 = {
90416 +static struct sctp_pf sctp_pf_inet6 __read_only = {
90417 .event_msgname = sctp_inet6_event_msgname,
90418 .skb_msgname = sctp_inet6_skb_msgname,
90419 .af_supported = sctp_inet6_af_supported,
90420 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
90421
90422 void sctp_v6_pf_exit(void)
90423 {
90424 - list_del(&sctp_af_inet6.list);
90425 + pax_list_del(&sctp_af_inet6.list);
90426 }
90427
90428 /* Initialize IPv6 support and register with socket layer. */
90429 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
90430 index 8c19e97..16264b8 100644
90431 --- a/net/sctp/proc.c
90432 +++ b/net/sctp/proc.c
90433 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
90434 seq_printf(seq,
90435 "%8pK %8pK %-3d %-3d %-2d %-4d "
90436 "%4d %8d %8d %7d %5lu %-5d %5d ",
90437 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
90438 + assoc, sk,
90439 + sctp_sk(sk)->type, sk->sk_state,
90440 assoc->state, hash,
90441 assoc->assoc_id,
90442 assoc->sndbuf_used,
90443 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
90444 index f898b1c..a2d0fe8 100644
90445 --- a/net/sctp/protocol.c
90446 +++ b/net/sctp/protocol.c
90447 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
90448 return 0;
90449 }
90450
90451 + pax_open_kernel();
90452 INIT_LIST_HEAD(&af->list);
90453 - list_add_tail(&af->list, &sctp_address_families);
90454 + pax_close_kernel();
90455 + pax_list_add_tail(&af->list, &sctp_address_families);
90456 return 1;
90457 }
90458
90459 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
90460
90461 static struct sctp_af sctp_af_inet;
90462
90463 -static struct sctp_pf sctp_pf_inet = {
90464 +static struct sctp_pf sctp_pf_inet __read_only = {
90465 .event_msgname = sctp_inet_event_msgname,
90466 .skb_msgname = sctp_inet_skb_msgname,
90467 .af_supported = sctp_inet_af_supported,
90468 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
90469 };
90470
90471 /* IPv4 address related functions. */
90472 -static struct sctp_af sctp_af_inet = {
90473 +static struct sctp_af sctp_af_inet __read_only = {
90474 .sa_family = AF_INET,
90475 .sctp_xmit = sctp_v4_xmit,
90476 .setsockopt = ip_setsockopt,
90477 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
90478
90479 static void sctp_v4_pf_exit(void)
90480 {
90481 - list_del(&sctp_af_inet.list);
90482 + pax_list_del(&sctp_af_inet.list);
90483 }
90484
90485 static int sctp_v4_protosw_init(void)
90486 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
90487 index c957775..6d4593a 100644
90488 --- a/net/sctp/sm_sideeffect.c
90489 +++ b/net/sctp/sm_sideeffect.c
90490 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
90491 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
90492 }
90493
90494 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90495 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90496 NULL,
90497 sctp_generate_t1_cookie_event,
90498 sctp_generate_t1_init_event,
90499 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
90500 index 9ef5c73..1e9a9a9 100644
90501 --- a/net/sctp/socket.c
90502 +++ b/net/sctp/socket.c
90503 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
90504 {
90505 struct sctp_association *asoc;
90506 struct sctp_ulpevent *event;
90507 + struct sctp_event_subscribe subscribe;
90508
90509 if (optlen > sizeof(struct sctp_event_subscribe))
90510 return -EINVAL;
90511 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
90512 + if (copy_from_user(&subscribe, optval, optlen))
90513 return -EFAULT;
90514 + sctp_sk(sk)->subscribe = subscribe;
90515
90516 /*
90517 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
90518 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
90519 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90520 int __user *optlen)
90521 {
90522 + struct sctp_event_subscribe subscribe;
90523 +
90524 if (len <= 0)
90525 return -EINVAL;
90526 if (len > sizeof(struct sctp_event_subscribe))
90527 len = sizeof(struct sctp_event_subscribe);
90528 if (put_user(len, optlen))
90529 return -EFAULT;
90530 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
90531 + subscribe = sctp_sk(sk)->subscribe;
90532 + if (copy_to_user(optval, &subscribe, len))
90533 return -EFAULT;
90534 return 0;
90535 }
90536 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90537 */
90538 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
90539 {
90540 + __u32 autoclose;
90541 +
90542 /* Applicable to UDP-style socket only */
90543 if (sctp_style(sk, TCP))
90544 return -EOPNOTSUPP;
90545 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
90546 len = sizeof(int);
90547 if (put_user(len, optlen))
90548 return -EFAULT;
90549 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
90550 + autoclose = sctp_sk(sk)->autoclose;
90551 + if (copy_to_user(optval, &autoclose, sizeof(int)))
90552 return -EFAULT;
90553 return 0;
90554 }
90555 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
90556 */
90557 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
90558 {
90559 + struct sctp_initmsg initmsg;
90560 +
90561 if (len < sizeof(struct sctp_initmsg))
90562 return -EINVAL;
90563 len = sizeof(struct sctp_initmsg);
90564 if (put_user(len, optlen))
90565 return -EFAULT;
90566 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
90567 + initmsg = sctp_sk(sk)->initmsg;
90568 + if (copy_to_user(optval, &initmsg, len))
90569 return -EFAULT;
90570 return 0;
90571 }
90572 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
90573 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
90574 if (space_left < addrlen)
90575 return -ENOMEM;
90576 + if (addrlen > sizeof(temp) || addrlen < 0)
90577 + return -EFAULT;
90578 if (copy_to_user(to, &temp, addrlen))
90579 return -EFAULT;
90580 to += addrlen;
90581 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
90582 index 442ad4e..825ea94 100644
90583 --- a/net/sctp/ssnmap.c
90584 +++ b/net/sctp/ssnmap.c
90585 @@ -41,8 +41,6 @@
90586 #include <net/sctp/sctp.h>
90587 #include <net/sctp/sm.h>
90588
90589 -#define MAX_KMALLOC_SIZE 131072
90590 -
90591 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
90592 __u16 out);
90593
90594 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
90595 int size;
90596
90597 size = sctp_ssnmap_size(in, out);
90598 - if (size <= MAX_KMALLOC_SIZE)
90599 + if (size <= KMALLOC_MAX_SIZE)
90600 retval = kmalloc(size, gfp);
90601 else
90602 retval = (struct sctp_ssnmap *)
90603 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
90604 return retval;
90605
90606 fail_map:
90607 - if (size <= MAX_KMALLOC_SIZE)
90608 + if (size <= KMALLOC_MAX_SIZE)
90609 kfree(retval);
90610 else
90611 free_pages((unsigned long)retval, get_order(size));
90612 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
90613 int size;
90614
90615 size = sctp_ssnmap_size(map->in.len, map->out.len);
90616 - if (size <= MAX_KMALLOC_SIZE)
90617 + if (size <= KMALLOC_MAX_SIZE)
90618 kfree(map);
90619 else
90620 free_pages((unsigned long)map, get_order(size));
90621 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
90622 index bf3c6e8..376d8d0 100644
90623 --- a/net/sctp/sysctl.c
90624 +++ b/net/sctp/sysctl.c
90625 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90626 {
90627 struct net *net = current->nsproxy->net_ns;
90628 char tmp[8];
90629 - ctl_table tbl;
90630 + ctl_table_no_const tbl;
90631 int ret;
90632 int changed = 0;
90633 char *none = "none";
90634 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90635
90636 int sctp_sysctl_net_register(struct net *net)
90637 {
90638 - struct ctl_table *table;
90639 + ctl_table_no_const *table;
90640 int i;
90641
90642 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90643 diff --git a/net/socket.c b/net/socket.c
90644 index 2ca51c7..ee5feb5 100644
90645 --- a/net/socket.c
90646 +++ b/net/socket.c
90647 @@ -89,6 +89,7 @@
90648 #include <linux/magic.h>
90649 #include <linux/slab.h>
90650 #include <linux/xattr.h>
90651 +#include <linux/in.h>
90652
90653 #include <asm/uaccess.h>
90654 #include <asm/unistd.h>
90655 @@ -106,6 +107,8 @@
90656 #include <linux/sockios.h>
90657 #include <linux/atalk.h>
90658
90659 +#include <linux/grsock.h>
90660 +
90661 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90662 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90663 unsigned long nr_segs, loff_t pos);
90664 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90665 &sockfs_dentry_operations, SOCKFS_MAGIC);
90666 }
90667
90668 -static struct vfsmount *sock_mnt __read_mostly;
90669 +struct vfsmount *sock_mnt __read_mostly;
90670
90671 static struct file_system_type sock_fs_type = {
90672 .name = "sockfs",
90673 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90674 return -EAFNOSUPPORT;
90675 if (type < 0 || type >= SOCK_MAX)
90676 return -EINVAL;
90677 + if (protocol < 0)
90678 + return -EINVAL;
90679
90680 /* Compatibility.
90681
90682 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90683 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90684 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90685
90686 + if(!gr_search_socket(family, type, protocol)) {
90687 + retval = -EACCES;
90688 + goto out;
90689 + }
90690 +
90691 + if (gr_handle_sock_all(family, type, protocol)) {
90692 + retval = -EACCES;
90693 + goto out;
90694 + }
90695 +
90696 retval = sock_create(family, type, protocol, &sock);
90697 if (retval < 0)
90698 goto out;
90699 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90700 if (sock) {
90701 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90702 if (err >= 0) {
90703 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90704 + err = -EACCES;
90705 + goto error;
90706 + }
90707 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90708 + if (err)
90709 + goto error;
90710 +
90711 err = security_socket_bind(sock,
90712 (struct sockaddr *)&address,
90713 addrlen);
90714 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90715 (struct sockaddr *)
90716 &address, addrlen);
90717 }
90718 +error:
90719 fput_light(sock->file, fput_needed);
90720 }
90721 return err;
90722 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90723 if ((unsigned int)backlog > somaxconn)
90724 backlog = somaxconn;
90725
90726 + if (gr_handle_sock_server_other(sock->sk)) {
90727 + err = -EPERM;
90728 + goto error;
90729 + }
90730 +
90731 + err = gr_search_listen(sock);
90732 + if (err)
90733 + goto error;
90734 +
90735 err = security_socket_listen(sock, backlog);
90736 if (!err)
90737 err = sock->ops->listen(sock, backlog);
90738
90739 +error:
90740 fput_light(sock->file, fput_needed);
90741 }
90742 return err;
90743 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90744 newsock->type = sock->type;
90745 newsock->ops = sock->ops;
90746
90747 + if (gr_handle_sock_server_other(sock->sk)) {
90748 + err = -EPERM;
90749 + sock_release(newsock);
90750 + goto out_put;
90751 + }
90752 +
90753 + err = gr_search_accept(sock);
90754 + if (err) {
90755 + sock_release(newsock);
90756 + goto out_put;
90757 + }
90758 +
90759 /*
90760 * We don't need try_module_get here, as the listening socket (sock)
90761 * has the protocol module (sock->ops->owner) held.
90762 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90763 fd_install(newfd, newfile);
90764 err = newfd;
90765
90766 + gr_attach_curr_ip(newsock->sk);
90767 +
90768 out_put:
90769 fput_light(sock->file, fput_needed);
90770 out:
90771 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90772 int, addrlen)
90773 {
90774 struct socket *sock;
90775 + struct sockaddr *sck;
90776 struct sockaddr_storage address;
90777 int err, fput_needed;
90778
90779 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90780 if (err < 0)
90781 goto out_put;
90782
90783 + sck = (struct sockaddr *)&address;
90784 +
90785 + if (gr_handle_sock_client(sck)) {
90786 + err = -EACCES;
90787 + goto out_put;
90788 + }
90789 +
90790 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90791 + if (err)
90792 + goto out_put;
90793 +
90794 err =
90795 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90796 if (err)
90797 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90798 * the protocol.
90799 */
90800
90801 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90802 +
90803 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90804 unsigned int, flags, struct sockaddr __user *, addr,
90805 int, addr_len)
90806 @@ -1840,7 +1902,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90807 struct socket *sock;
90808 struct iovec iov;
90809 struct msghdr msg;
90810 - struct sockaddr_storage address;
90811 + struct sockaddr_storage address = { };
90812 int err, err2;
90813 int fput_needed;
90814
90815 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90816 * checking falls down on this.
90817 */
90818 if (copy_from_user(ctl_buf,
90819 - (void __user __force *)msg_sys->msg_control,
90820 + (void __force_user *)msg_sys->msg_control,
90821 ctl_len))
90822 goto out_freectl;
90823 msg_sys->msg_control = ctl_buf;
90824 @@ -2187,7 +2249,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90825 int err, total_len, len;
90826
90827 /* kernel mode address */
90828 - struct sockaddr_storage addr;
90829 + struct sockaddr_storage addr = { };
90830
90831 /* user mode address pointers */
90832 struct sockaddr __user *uaddr;
90833 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90834 * kernel msghdr to use the kernel address space)
90835 */
90836
90837 - uaddr = (__force void __user *)msg_sys->msg_name;
90838 + uaddr = (void __force_user *)msg_sys->msg_name;
90839 uaddr_len = COMPAT_NAMELEN(msg);
90840 if (MSG_CMSG_COMPAT & flags) {
90841 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90842 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90843 }
90844
90845 ifr = compat_alloc_user_space(buf_size);
90846 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
90847 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
90848
90849 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
90850 return -EFAULT;
90851 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90852 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
90853
90854 if (copy_in_user(rxnfc, compat_rxnfc,
90855 - (void *)(&rxnfc->fs.m_ext + 1) -
90856 - (void *)rxnfc) ||
90857 + (void __user *)(&rxnfc->fs.m_ext + 1) -
90858 + (void __user *)rxnfc) ||
90859 copy_in_user(&rxnfc->fs.ring_cookie,
90860 &compat_rxnfc->fs.ring_cookie,
90861 - (void *)(&rxnfc->fs.location + 1) -
90862 - (void *)&rxnfc->fs.ring_cookie) ||
90863 + (void __user *)(&rxnfc->fs.location + 1) -
90864 + (void __user *)&rxnfc->fs.ring_cookie) ||
90865 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
90866 sizeof(rxnfc->rule_cnt)))
90867 return -EFAULT;
90868 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90869
90870 if (convert_out) {
90871 if (copy_in_user(compat_rxnfc, rxnfc,
90872 - (const void *)(&rxnfc->fs.m_ext + 1) -
90873 - (const void *)rxnfc) ||
90874 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
90875 + (const void __user *)rxnfc) ||
90876 copy_in_user(&compat_rxnfc->fs.ring_cookie,
90877 &rxnfc->fs.ring_cookie,
90878 - (const void *)(&rxnfc->fs.location + 1) -
90879 - (const void *)&rxnfc->fs.ring_cookie) ||
90880 + (const void __user *)(&rxnfc->fs.location + 1) -
90881 + (const void __user *)&rxnfc->fs.ring_cookie) ||
90882 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
90883 sizeof(rxnfc->rule_cnt)))
90884 return -EFAULT;
90885 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90886 old_fs = get_fs();
90887 set_fs(KERNEL_DS);
90888 err = dev_ioctl(net, cmd,
90889 - (struct ifreq __user __force *) &kifr);
90890 + (struct ifreq __force_user *) &kifr);
90891 set_fs(old_fs);
90892
90893 return err;
90894 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90895
90896 old_fs = get_fs();
90897 set_fs(KERNEL_DS);
90898 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90899 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90900 set_fs(old_fs);
90901
90902 if (cmd == SIOCGIFMAP && !err) {
90903 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90904 ret |= __get_user(rtdev, &(ur4->rt_dev));
90905 if (rtdev) {
90906 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90907 - r4.rt_dev = (char __user __force *)devname;
90908 + r4.rt_dev = (char __force_user *)devname;
90909 devname[15] = 0;
90910 } else
90911 r4.rt_dev = NULL;
90912 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90913 int __user *uoptlen;
90914 int err;
90915
90916 - uoptval = (char __user __force *) optval;
90917 - uoptlen = (int __user __force *) optlen;
90918 + uoptval = (char __force_user *) optval;
90919 + uoptlen = (int __force_user *) optlen;
90920
90921 set_fs(KERNEL_DS);
90922 if (level == SOL_SOCKET)
90923 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90924 char __user *uoptval;
90925 int err;
90926
90927 - uoptval = (char __user __force *) optval;
90928 + uoptval = (char __force_user *) optval;
90929
90930 set_fs(KERNEL_DS);
90931 if (level == SOL_SOCKET)
90932 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90933 index 716aa41..75e88ea 100644
90934 --- a/net/sunrpc/clnt.c
90935 +++ b/net/sunrpc/clnt.c
90936 @@ -303,10 +303,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
90937 err = rpciod_up();
90938 if (err)
90939 goto out_no_rpciod;
90940 +
90941 err = -EINVAL;
90942 - if (!xprt)
90943 - goto out_no_xprt;
90944 -
90945 if (args->version >= program->nrvers)
90946 goto out_err;
90947 version = program->version[args->version];
90948 @@ -381,10 +379,9 @@ out_no_principal:
90949 out_no_stats:
90950 kfree(clnt);
90951 out_err:
90952 - xprt_put(xprt);
90953 -out_no_xprt:
90954 rpciod_down();
90955 out_no_rpciod:
90956 + xprt_put(xprt);
90957 return ERR_PTR(err);
90958 }
90959
90960 @@ -1270,7 +1267,9 @@ call_start(struct rpc_task *task)
90961 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90962
90963 /* Increment call count */
90964 - task->tk_msg.rpc_proc->p_count++;
90965 + pax_open_kernel();
90966 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90967 + pax_close_kernel();
90968 clnt->cl_stats->rpccnt++;
90969 task->tk_action = call_reserve;
90970 }
90971 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90972 index f8529fc..ce8c643 100644
90973 --- a/net/sunrpc/sched.c
90974 +++ b/net/sunrpc/sched.c
90975 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90976 #ifdef RPC_DEBUG
90977 static void rpc_task_set_debuginfo(struct rpc_task *task)
90978 {
90979 - static atomic_t rpc_pid;
90980 + static atomic_unchecked_t rpc_pid;
90981
90982 - task->tk_pid = atomic_inc_return(&rpc_pid);
90983 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90984 }
90985 #else
90986 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90987 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90988 index 2d34b6b..e2d584d 100644
90989 --- a/net/sunrpc/svc.c
90990 +++ b/net/sunrpc/svc.c
90991 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90992 svc_putnl(resv, RPC_SUCCESS);
90993
90994 /* Bump per-procedure stats counter */
90995 - procp->pc_count++;
90996 + pax_open_kernel();
90997 + (*(unsigned int *)&procp->pc_count)++;
90998 + pax_close_kernel();
90999
91000 /* Initialize storage for argp and resp */
91001 memset(rqstp->rq_argp, 0, procp->pc_argsize);
91002 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
91003 index 8343737..677025e 100644
91004 --- a/net/sunrpc/xprtrdma/svc_rdma.c
91005 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
91006 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
91007 static unsigned int min_max_inline = 4096;
91008 static unsigned int max_max_inline = 65536;
91009
91010 -atomic_t rdma_stat_recv;
91011 -atomic_t rdma_stat_read;
91012 -atomic_t rdma_stat_write;
91013 -atomic_t rdma_stat_sq_starve;
91014 -atomic_t rdma_stat_rq_starve;
91015 -atomic_t rdma_stat_rq_poll;
91016 -atomic_t rdma_stat_rq_prod;
91017 -atomic_t rdma_stat_sq_poll;
91018 -atomic_t rdma_stat_sq_prod;
91019 +atomic_unchecked_t rdma_stat_recv;
91020 +atomic_unchecked_t rdma_stat_read;
91021 +atomic_unchecked_t rdma_stat_write;
91022 +atomic_unchecked_t rdma_stat_sq_starve;
91023 +atomic_unchecked_t rdma_stat_rq_starve;
91024 +atomic_unchecked_t rdma_stat_rq_poll;
91025 +atomic_unchecked_t rdma_stat_rq_prod;
91026 +atomic_unchecked_t rdma_stat_sq_poll;
91027 +atomic_unchecked_t rdma_stat_sq_prod;
91028
91029 /* Temporary NFS request map and context caches */
91030 struct kmem_cache *svc_rdma_map_cachep;
91031 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
91032 len -= *ppos;
91033 if (len > *lenp)
91034 len = *lenp;
91035 - if (len && copy_to_user(buffer, str_buf, len))
91036 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
91037 return -EFAULT;
91038 *lenp = len;
91039 *ppos += len;
91040 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
91041 {
91042 .procname = "rdma_stat_read",
91043 .data = &rdma_stat_read,
91044 - .maxlen = sizeof(atomic_t),
91045 + .maxlen = sizeof(atomic_unchecked_t),
91046 .mode = 0644,
91047 .proc_handler = read_reset_stat,
91048 },
91049 {
91050 .procname = "rdma_stat_recv",
91051 .data = &rdma_stat_recv,
91052 - .maxlen = sizeof(atomic_t),
91053 + .maxlen = sizeof(atomic_unchecked_t),
91054 .mode = 0644,
91055 .proc_handler = read_reset_stat,
91056 },
91057 {
91058 .procname = "rdma_stat_write",
91059 .data = &rdma_stat_write,
91060 - .maxlen = sizeof(atomic_t),
91061 + .maxlen = sizeof(atomic_unchecked_t),
91062 .mode = 0644,
91063 .proc_handler = read_reset_stat,
91064 },
91065 {
91066 .procname = "rdma_stat_sq_starve",
91067 .data = &rdma_stat_sq_starve,
91068 - .maxlen = sizeof(atomic_t),
91069 + .maxlen = sizeof(atomic_unchecked_t),
91070 .mode = 0644,
91071 .proc_handler = read_reset_stat,
91072 },
91073 {
91074 .procname = "rdma_stat_rq_starve",
91075 .data = &rdma_stat_rq_starve,
91076 - .maxlen = sizeof(atomic_t),
91077 + .maxlen = sizeof(atomic_unchecked_t),
91078 .mode = 0644,
91079 .proc_handler = read_reset_stat,
91080 },
91081 {
91082 .procname = "rdma_stat_rq_poll",
91083 .data = &rdma_stat_rq_poll,
91084 - .maxlen = sizeof(atomic_t),
91085 + .maxlen = sizeof(atomic_unchecked_t),
91086 .mode = 0644,
91087 .proc_handler = read_reset_stat,
91088 },
91089 {
91090 .procname = "rdma_stat_rq_prod",
91091 .data = &rdma_stat_rq_prod,
91092 - .maxlen = sizeof(atomic_t),
91093 + .maxlen = sizeof(atomic_unchecked_t),
91094 .mode = 0644,
91095 .proc_handler = read_reset_stat,
91096 },
91097 {
91098 .procname = "rdma_stat_sq_poll",
91099 .data = &rdma_stat_sq_poll,
91100 - .maxlen = sizeof(atomic_t),
91101 + .maxlen = sizeof(atomic_unchecked_t),
91102 .mode = 0644,
91103 .proc_handler = read_reset_stat,
91104 },
91105 {
91106 .procname = "rdma_stat_sq_prod",
91107 .data = &rdma_stat_sq_prod,
91108 - .maxlen = sizeof(atomic_t),
91109 + .maxlen = sizeof(atomic_unchecked_t),
91110 .mode = 0644,
91111 .proc_handler = read_reset_stat,
91112 },
91113 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91114 index 0ce7552..d074459 100644
91115 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91116 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
91117 @@ -501,7 +501,7 @@ next_sge:
91118 svc_rdma_put_context(ctxt, 0);
91119 goto out;
91120 }
91121 - atomic_inc(&rdma_stat_read);
91122 + atomic_inc_unchecked(&rdma_stat_read);
91123
91124 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
91125 chl_map->ch[ch_no].count -= read_wr.num_sge;
91126 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91127 dto_q);
91128 list_del_init(&ctxt->dto_q);
91129 } else {
91130 - atomic_inc(&rdma_stat_rq_starve);
91131 + atomic_inc_unchecked(&rdma_stat_rq_starve);
91132 clear_bit(XPT_DATA, &xprt->xpt_flags);
91133 ctxt = NULL;
91134 }
91135 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
91136 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
91137 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
91138 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
91139 - atomic_inc(&rdma_stat_recv);
91140 + atomic_inc_unchecked(&rdma_stat_recv);
91141
91142 /* Build up the XDR from the receive buffers. */
91143 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
91144 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91145 index c1d124d..acfc59e 100644
91146 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91147 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
91148 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
91149 write_wr.wr.rdma.remote_addr = to;
91150
91151 /* Post It */
91152 - atomic_inc(&rdma_stat_write);
91153 + atomic_inc_unchecked(&rdma_stat_write);
91154 if (svc_rdma_send(xprt, &write_wr))
91155 goto err;
91156 return 0;
91157 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
91158 index 62e4f9b..dd3f2d7 100644
91159 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
91160 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
91161 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
91162 return;
91163
91164 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
91165 - atomic_inc(&rdma_stat_rq_poll);
91166 + atomic_inc_unchecked(&rdma_stat_rq_poll);
91167
91168 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
91169 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
91170 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
91171 }
91172
91173 if (ctxt)
91174 - atomic_inc(&rdma_stat_rq_prod);
91175 + atomic_inc_unchecked(&rdma_stat_rq_prod);
91176
91177 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
91178 /*
91179 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
91180 return;
91181
91182 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
91183 - atomic_inc(&rdma_stat_sq_poll);
91184 + atomic_inc_unchecked(&rdma_stat_sq_poll);
91185 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
91186 if (wc.status != IB_WC_SUCCESS)
91187 /* Close the transport */
91188 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
91189 }
91190
91191 if (ctxt)
91192 - atomic_inc(&rdma_stat_sq_prod);
91193 + atomic_inc_unchecked(&rdma_stat_sq_prod);
91194 }
91195
91196 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
91197 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
91198 spin_lock_bh(&xprt->sc_lock);
91199 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
91200 spin_unlock_bh(&xprt->sc_lock);
91201 - atomic_inc(&rdma_stat_sq_starve);
91202 + atomic_inc_unchecked(&rdma_stat_sq_starve);
91203
91204 /* See if we can opportunistically reap SQ WR to make room */
91205 sq_cq_reap(xprt);
91206 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
91207 index 9bc6db0..47ac8c0 100644
91208 --- a/net/sysctl_net.c
91209 +++ b/net/sysctl_net.c
91210 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
91211 kgid_t root_gid = make_kgid(net->user_ns, 0);
91212
91213 /* Allow network administrator to have same access as root. */
91214 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
91215 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
91216 uid_eq(root_uid, current_uid())) {
91217 int mode = (table->mode >> 6) & 7;
91218 return (mode << 6) | (mode << 3) | mode;
91219 diff --git a/net/tipc/link.c b/net/tipc/link.c
91220 index daa6080..02d357f 100644
91221 --- a/net/tipc/link.c
91222 +++ b/net/tipc/link.c
91223 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
91224 struct tipc_msg fragm_hdr;
91225 struct sk_buff *buf, *buf_chain, *prev;
91226 u32 fragm_crs, fragm_rest, hsz, sect_rest;
91227 - const unchar *sect_crs;
91228 + const unchar __user *sect_crs;
91229 int curr_sect;
91230 u32 fragm_no;
91231
91232 @@ -1242,7 +1242,7 @@ again:
91233
91234 if (!sect_rest) {
91235 sect_rest = msg_sect[++curr_sect].iov_len;
91236 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
91237 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
91238 }
91239
91240 if (sect_rest < fragm_rest)
91241 @@ -1261,7 +1261,7 @@ error:
91242 }
91243 } else
91244 skb_copy_to_linear_data_offset(buf, fragm_crs,
91245 - sect_crs, sz);
91246 + (const void __force_kernel *)sect_crs, sz);
91247 sect_crs += sz;
91248 sect_rest -= sz;
91249 fragm_crs += sz;
91250 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
91251 index f2db8a8..9245aa4 100644
91252 --- a/net/tipc/msg.c
91253 +++ b/net/tipc/msg.c
91254 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
91255 msg_sect[cnt].iov_len);
91256 else
91257 skb_copy_to_linear_data_offset(*buf, pos,
91258 - msg_sect[cnt].iov_base,
91259 + (const void __force_kernel *)msg_sect[cnt].iov_base,
91260 msg_sect[cnt].iov_len);
91261 pos += msg_sect[cnt].iov_len;
91262 }
91263 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
91264 index 6b42d47..2ac24d5 100644
91265 --- a/net/tipc/subscr.c
91266 +++ b/net/tipc/subscr.c
91267 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
91268 {
91269 struct iovec msg_sect;
91270
91271 - msg_sect.iov_base = (void *)&sub->evt;
91272 + msg_sect.iov_base = (void __force_user *)&sub->evt;
91273 msg_sect.iov_len = sizeof(struct tipc_event);
91274
91275 sub->evt.event = htohl(event, sub->swap);
91276 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
91277 index b45eb65..bb4b223 100644
91278 --- a/net/unix/af_unix.c
91279 +++ b/net/unix/af_unix.c
91280 @@ -785,6 +785,12 @@ static struct sock *unix_find_other(struct net *net,
91281 err = -ECONNREFUSED;
91282 if (!S_ISSOCK(inode->i_mode))
91283 goto put_fail;
91284 +
91285 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
91286 + err = -EACCES;
91287 + goto put_fail;
91288 + }
91289 +
91290 u = unix_find_socket_byinode(inode);
91291 if (!u)
91292 goto put_fail;
91293 @@ -805,6 +811,13 @@ static struct sock *unix_find_other(struct net *net,
91294 if (u) {
91295 struct dentry *dentry;
91296 dentry = unix_sk(u)->path.dentry;
91297 +
91298 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
91299 + err = -EPERM;
91300 + sock_put(u);
91301 + goto fail;
91302 + }
91303 +
91304 if (dentry)
91305 touch_atime(&unix_sk(u)->path);
91306 } else
91307 @@ -838,12 +851,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
91308 */
91309 err = security_path_mknod(&path, dentry, mode, 0);
91310 if (!err) {
91311 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
91312 + err = -EACCES;
91313 + goto out;
91314 + }
91315 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
91316 if (!err) {
91317 res->mnt = mntget(path.mnt);
91318 res->dentry = dget(dentry);
91319 + gr_handle_create(dentry, path.mnt);
91320 }
91321 }
91322 +out:
91323 done_path_create(&path, dentry);
91324 return err;
91325 }
91326 @@ -1995,7 +2014,7 @@ again:
91327 if ((UNIXCB(skb).pid != siocb->scm->pid) ||
91328 (UNIXCB(skb).cred != siocb->scm->cred))
91329 break;
91330 - } else {
91331 + } else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
91332 /* Copy credentials */
91333 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
91334 check_creds = 1;
91335 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91336 seq_puts(seq, "Num RefCount Protocol Flags Type St "
91337 "Inode Path\n");
91338 else {
91339 - struct sock *s = v;
91340 + struct sock *s = v, *peer;
91341 struct unix_sock *u = unix_sk(s);
91342 unix_state_lock(s);
91343 + peer = unix_peer(s);
91344 + unix_state_unlock(s);
91345 +
91346 + unix_state_double_lock(s, peer);
91347
91348 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
91349 s,
91350 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91351 }
91352 for ( ; i < len; i++)
91353 seq_putc(seq, u->addr->name->sun_path[i]);
91354 - }
91355 - unix_state_unlock(s);
91356 + } else if (peer)
91357 + seq_printf(seq, " P%lu", sock_i_ino(peer));
91358 +
91359 + unix_state_double_unlock(s, peer);
91360 seq_putc(seq, '\n');
91361 }
91362
91363 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
91364 index 8800604..0526440 100644
91365 --- a/net/unix/sysctl_net_unix.c
91366 +++ b/net/unix/sysctl_net_unix.c
91367 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
91368
91369 int __net_init unix_sysctl_register(struct net *net)
91370 {
91371 - struct ctl_table *table;
91372 + ctl_table_no_const *table;
91373
91374 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
91375 if (table == NULL)
91376 diff --git a/net/wireless/trace.h b/net/wireless/trace.h
91377 index 2134576..5d71a5a 100644
91378 --- a/net/wireless/trace.h
91379 +++ b/net/wireless/trace.h
91380 @@ -27,7 +27,8 @@
91381 #define WIPHY_PR_ARG __entry->wiphy_name
91382
91383 #define WDEV_ENTRY __field(u32, id)
91384 -#define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0)
91385 +#define WDEV_ASSIGN (__entry->id) = (!IS_ERR_OR_NULL(wdev) \
91386 + ? wdev->identifier : 0)
91387 #define WDEV_PR_FMT "wdev(%u)"
91388 #define WDEV_PR_ARG (__entry->id)
91389
91390 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
91391 index c8717c1..08539f5 100644
91392 --- a/net/wireless/wext-core.c
91393 +++ b/net/wireless/wext-core.c
91394 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91395 */
91396
91397 /* Support for very large requests */
91398 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
91399 - (user_length > descr->max_tokens)) {
91400 + if (user_length > descr->max_tokens) {
91401 /* Allow userspace to GET more than max so
91402 * we can support any size GET requests.
91403 * There is still a limit : -ENOMEM.
91404 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91405 }
91406 }
91407
91408 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
91409 - /*
91410 - * If this is a GET, but not NOMAX, it means that the extra
91411 - * data is not bounded by userspace, but by max_tokens. Thus
91412 - * set the length to max_tokens. This matches the extra data
91413 - * allocation.
91414 - * The driver should fill it with the number of tokens it
91415 - * provided, and it may check iwp->length rather than having
91416 - * knowledge of max_tokens. If the driver doesn't change the
91417 - * iwp->length, this ioctl just copies back max_token tokens
91418 - * filled with zeroes. Hopefully the driver isn't claiming
91419 - * them to be valid data.
91420 - */
91421 - iwp->length = descr->max_tokens;
91422 - }
91423 -
91424 err = handler(dev, info, (union iwreq_data *) iwp, extra);
91425
91426 iwp->length += essid_compat;
91427 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
91428 index 07c5857..fde4018 100644
91429 --- a/net/xfrm/xfrm_policy.c
91430 +++ b/net/xfrm/xfrm_policy.c
91431 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
91432 {
91433 policy->walk.dead = 1;
91434
91435 - atomic_inc(&policy->genid);
91436 + atomic_inc_unchecked(&policy->genid);
91437
91438 if (del_timer(&policy->timer))
91439 xfrm_pol_put(policy);
91440 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
91441 hlist_add_head(&policy->bydst, chain);
91442 xfrm_pol_hold(policy);
91443 net->xfrm.policy_count[dir]++;
91444 - atomic_inc(&flow_cache_genid);
91445 + atomic_inc_unchecked(&flow_cache_genid);
91446 rt_genid_bump(net);
91447 if (delpol)
91448 __xfrm_policy_unlink(delpol, dir);
91449 @@ -1550,7 +1550,7 @@ free_dst:
91450 goto out;
91451 }
91452
91453 -static int inline
91454 +static inline int
91455 xfrm_dst_alloc_copy(void **target, const void *src, int size)
91456 {
91457 if (!*target) {
91458 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
91459 return 0;
91460 }
91461
91462 -static int inline
91463 +static inline int
91464 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91465 {
91466 #ifdef CONFIG_XFRM_SUB_POLICY
91467 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91468 #endif
91469 }
91470
91471 -static int inline
91472 +static inline int
91473 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
91474 {
91475 #ifdef CONFIG_XFRM_SUB_POLICY
91476 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
91477
91478 xdst->num_pols = num_pols;
91479 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
91480 - xdst->policy_genid = atomic_read(&pols[0]->genid);
91481 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
91482
91483 return xdst;
91484 }
91485 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
91486 if (xdst->xfrm_genid != dst->xfrm->genid)
91487 return 0;
91488 if (xdst->num_pols > 0 &&
91489 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
91490 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
91491 return 0;
91492
91493 mtu = dst_mtu(dst->child);
91494 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
91495 dst_ops->link_failure = xfrm_link_failure;
91496 if (likely(dst_ops->neigh_lookup == NULL))
91497 dst_ops->neigh_lookup = xfrm_neigh_lookup;
91498 - if (likely(afinfo->garbage_collect == NULL))
91499 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91500 + if (likely(afinfo->garbage_collect == NULL)) {
91501 + pax_open_kernel();
91502 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91503 + pax_close_kernel();
91504 + }
91505 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
91506 }
91507 spin_unlock(&xfrm_policy_afinfo_lock);
91508 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
91509 dst_ops->check = NULL;
91510 dst_ops->negative_advice = NULL;
91511 dst_ops->link_failure = NULL;
91512 - afinfo->garbage_collect = NULL;
91513 + pax_open_kernel();
91514 + *(void **)&afinfo->garbage_collect = NULL;
91515 + pax_close_kernel();
91516 }
91517 return err;
91518 }
91519 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
91520 sizeof(pol->xfrm_vec[i].saddr));
91521 pol->xfrm_vec[i].encap_family = mp->new_family;
91522 /* flush bundles */
91523 - atomic_inc(&pol->genid);
91524 + atomic_inc_unchecked(&pol->genid);
91525 }
91526 }
91527
91528 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
91529 index 3459692..e7cdb1a 100644
91530 --- a/net/xfrm/xfrm_state.c
91531 +++ b/net/xfrm/xfrm_state.c
91532 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
91533
91534 if (unlikely(afinfo == NULL))
91535 return -EAFNOSUPPORT;
91536 - typemap = afinfo->type_map;
91537 + typemap = (const struct xfrm_type **)afinfo->type_map;
91538
91539 - if (likely(typemap[type->proto] == NULL))
91540 + if (likely(typemap[type->proto] == NULL)) {
91541 + pax_open_kernel();
91542 typemap[type->proto] = type;
91543 - else
91544 + pax_close_kernel();
91545 + } else
91546 err = -EEXIST;
91547 xfrm_state_unlock_afinfo(afinfo);
91548 return err;
91549 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
91550
91551 if (unlikely(afinfo == NULL))
91552 return -EAFNOSUPPORT;
91553 - typemap = afinfo->type_map;
91554 + typemap = (const struct xfrm_type **)afinfo->type_map;
91555
91556 if (unlikely(typemap[type->proto] != type))
91557 err = -ENOENT;
91558 - else
91559 + else {
91560 + pax_open_kernel();
91561 typemap[type->proto] = NULL;
91562 + pax_close_kernel();
91563 + }
91564 xfrm_state_unlock_afinfo(afinfo);
91565 return err;
91566 }
91567 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
91568 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
91569 {
91570 struct xfrm_state_afinfo *afinfo;
91571 - const struct xfrm_type **typemap;
91572 const struct xfrm_type *type;
91573 int modload_attempted = 0;
91574
91575 @@ -235,9 +239,8 @@ retry:
91576 afinfo = xfrm_state_get_afinfo(family);
91577 if (unlikely(afinfo == NULL))
91578 return NULL;
91579 - typemap = afinfo->type_map;
91580
91581 - type = typemap[proto];
91582 + type = afinfo->type_map[proto];
91583 if (unlikely(type && !try_module_get(type->owner)))
91584 type = NULL;
91585 if (!type && !modload_attempted) {
91586 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91587 return -EAFNOSUPPORT;
91588
91589 err = -EEXIST;
91590 - modemap = afinfo->mode_map;
91591 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91592 if (modemap[mode->encap])
91593 goto out;
91594
91595 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91596 if (!try_module_get(afinfo->owner))
91597 goto out;
91598
91599 - mode->afinfo = afinfo;
91600 + pax_open_kernel();
91601 + *(const void **)&mode->afinfo = afinfo;
91602 modemap[mode->encap] = mode;
91603 + pax_close_kernel();
91604 err = 0;
91605
91606 out:
91607 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
91608 return -EAFNOSUPPORT;
91609
91610 err = -ENOENT;
91611 - modemap = afinfo->mode_map;
91612 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91613 if (likely(modemap[mode->encap] == mode)) {
91614 + pax_open_kernel();
91615 modemap[mode->encap] = NULL;
91616 + pax_close_kernel();
91617 module_put(mode->afinfo->owner);
91618 err = 0;
91619 }
91620 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
91621 index 05a6e3d..6716ec9 100644
91622 --- a/net/xfrm/xfrm_sysctl.c
91623 +++ b/net/xfrm/xfrm_sysctl.c
91624 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
91625
91626 int __net_init xfrm_sysctl_init(struct net *net)
91627 {
91628 - struct ctl_table *table;
91629 + ctl_table_no_const *table;
91630
91631 __xfrm_sysctl_init(net);
91632
91633 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
91634 index 0e801c3..5c8ad3b 100644
91635 --- a/scripts/Makefile.build
91636 +++ b/scripts/Makefile.build
91637 @@ -111,7 +111,7 @@ endif
91638 endif
91639
91640 # Do not include host rules unless needed
91641 -ifneq ($(hostprogs-y)$(hostprogs-m),)
91642 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
91643 include scripts/Makefile.host
91644 endif
91645
91646 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
91647 index 686cb0d..9d653bf 100644
91648 --- a/scripts/Makefile.clean
91649 +++ b/scripts/Makefile.clean
91650 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91651 __clean-files := $(extra-y) $(always) \
91652 $(targets) $(clean-files) \
91653 $(host-progs) \
91654 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91655 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91656 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91657
91658 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91659
91660 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91661 index 1ac414f..38575f7 100644
91662 --- a/scripts/Makefile.host
91663 +++ b/scripts/Makefile.host
91664 @@ -31,6 +31,8 @@
91665 # Note: Shared libraries consisting of C++ files are not supported
91666
91667 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91668 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91669 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91670
91671 # C code
91672 # Executables compiled from a single .c file
91673 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91674 # Shared libaries (only .c supported)
91675 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91676 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91677 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91678 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91679 # Remove .so files from "xxx-objs"
91680 host-cobjs := $(filter-out %.so,$(host-cobjs))
91681 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91682
91683 -#Object (.o) files used by the shared libaries
91684 +# Object (.o) files used by the shared libaries
91685 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91686 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91687
91688 # output directory for programs/.o files
91689 # hostprogs-y := tools/build may have been specified. Retrieve directory
91690 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91691 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91692 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91693 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91694 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91695 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91696 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91697 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91698
91699 obj-dirs += $(host-objdirs)
91700 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91701 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91702 $(call if_changed_dep,host-cshobjs)
91703
91704 +# Compile .c file, create position independent .o file
91705 +# host-cxxshobjs -> .o
91706 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91707 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91708 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91709 + $(call if_changed_dep,host-cxxshobjs)
91710 +
91711 # Link a shared library, based on position independent .o files
91712 # *.o -> .so shared library (host-cshlib)
91713 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91714 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91715 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91716 $(call if_changed,host-cshlib)
91717
91718 +# Link a shared library, based on position independent .o files
91719 +# *.o -> .so shared library (host-cxxshlib)
91720 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91721 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91722 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91723 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91724 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91725 + $(call if_changed,host-cxxshlib)
91726 +
91727 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91728 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91729 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91730
91731 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91732 index cb1f50c..cef2a7c 100644
91733 --- a/scripts/basic/fixdep.c
91734 +++ b/scripts/basic/fixdep.c
91735 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91736 /*
91737 * Lookup a value in the configuration string.
91738 */
91739 -static int is_defined_config(const char *name, int len, unsigned int hash)
91740 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91741 {
91742 struct item *aux;
91743
91744 @@ -211,10 +211,10 @@ static void clear_config(void)
91745 /*
91746 * Record the use of a CONFIG_* word.
91747 */
91748 -static void use_config(const char *m, int slen)
91749 +static void use_config(const char *m, unsigned int slen)
91750 {
91751 unsigned int hash = strhash(m, slen);
91752 - int c, i;
91753 + unsigned int c, i;
91754
91755 if (is_defined_config(m, slen, hash))
91756 return;
91757 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91758
91759 static void parse_config_file(const char *map, size_t len)
91760 {
91761 - const int *end = (const int *) (map + len);
91762 + const unsigned int *end = (const unsigned int *) (map + len);
91763 /* start at +1, so that p can never be < map */
91764 - const int *m = (const int *) map + 1;
91765 + const unsigned int *m = (const unsigned int *) map + 1;
91766 const char *p, *q;
91767
91768 for (; m < end; m++) {
91769 @@ -406,7 +406,7 @@ static void print_deps(void)
91770 static void traps(void)
91771 {
91772 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91773 - int *p = (int *)test;
91774 + unsigned int *p = (unsigned int *)test;
91775
91776 if (*p != INT_CONF) {
91777 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
91778 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91779 new file mode 100644
91780 index 0000000..5e0222d
91781 --- /dev/null
91782 +++ b/scripts/gcc-plugin.sh
91783 @@ -0,0 +1,17 @@
91784 +#!/bin/bash
91785 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91786 +#include "gcc-plugin.h"
91787 +#include "tree.h"
91788 +#include "tm.h"
91789 +#include "rtl.h"
91790 +#ifdef ENABLE_BUILD_WITH_CXX
91791 +#warning $2
91792 +#else
91793 +#warning $1
91794 +#endif
91795 +EOF`
91796 +if [ $? -eq 0 ]
91797 +then
91798 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91799 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91800 +fi
91801 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91802 index 581ca99..a6ff02e 100644
91803 --- a/scripts/headers_install.pl
91804 +++ b/scripts/headers_install.pl
91805 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91806 $line =~ s/([\s(])__user\s/$1/g;
91807 $line =~ s/([\s(])__force\s/$1/g;
91808 $line =~ s/([\s(])__iomem\s/$1/g;
91809 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91810 $line =~ s/\s__attribute_const__\s/ /g;
91811 $line =~ s/\s__attribute_const__$//g;
91812 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91813 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91814 index b3d907e..a4782ab 100644
91815 --- a/scripts/link-vmlinux.sh
91816 +++ b/scripts/link-vmlinux.sh
91817 @@ -152,7 +152,7 @@ else
91818 fi;
91819
91820 # final build of init/
91821 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91822 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91823
91824 kallsymso=""
91825 kallsyms_vmlinux=""
91826 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91827 index df4fc23..0ea719d 100644
91828 --- a/scripts/mod/file2alias.c
91829 +++ b/scripts/mod/file2alias.c
91830 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
91831 unsigned long size, unsigned long id_size,
91832 void *symval)
91833 {
91834 - int i;
91835 + unsigned int i;
91836
91837 if (size % id_size || size < id_size) {
91838 if (cross_build != 0)
91839 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
91840 /* USB is special because the bcdDevice can be matched against a numeric range */
91841 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91842 static void do_usb_entry(struct usb_device_id *id,
91843 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91844 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91845 unsigned char range_lo, unsigned char range_hi,
91846 unsigned char max, struct module *mod)
91847 {
91848 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
91849 {
91850 unsigned int devlo, devhi;
91851 unsigned char chi, clo, max;
91852 - int ndigits;
91853 + unsigned int ndigits;
91854
91855 id->match_flags = TO_NATIVE(id->match_flags);
91856 id->idVendor = TO_NATIVE(id->idVendor);
91857 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91858 for (i = 0; i < count; i++) {
91859 const char *id = (char *)devs[i].id;
91860 char acpi_id[sizeof(devs[0].id)];
91861 - int j;
91862 + unsigned int j;
91863
91864 buf_printf(&mod->dev_table_buf,
91865 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91866 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91867
91868 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91869 const char *id = (char *)card->devs[j].id;
91870 - int i2, j2;
91871 + unsigned int i2, j2;
91872 int dup = 0;
91873
91874 if (!id[0])
91875 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91876 /* add an individual alias for every device entry */
91877 if (!dup) {
91878 char acpi_id[sizeof(card->devs[0].id)];
91879 - int k;
91880 + unsigned int k;
91881
91882 buf_printf(&mod->dev_table_buf,
91883 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91884 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91885 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
91886 char *alias)
91887 {
91888 - int i, j;
91889 + unsigned int i, j;
91890
91891 sprintf(alias, "dmi*");
91892
91893 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91894 index ff36c50..7ab4fa9 100644
91895 --- a/scripts/mod/modpost.c
91896 +++ b/scripts/mod/modpost.c
91897 @@ -929,6 +929,7 @@ enum mismatch {
91898 ANY_INIT_TO_ANY_EXIT,
91899 ANY_EXIT_TO_ANY_INIT,
91900 EXPORT_TO_INIT_EXIT,
91901 + DATA_TO_TEXT
91902 };
91903
91904 struct sectioncheck {
91905 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
91906 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91907 .mismatch = EXPORT_TO_INIT_EXIT,
91908 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91909 +},
91910 +/* Do not reference code from writable data */
91911 +{
91912 + .fromsec = { DATA_SECTIONS, NULL },
91913 + .tosec = { TEXT_SECTIONS, NULL },
91914 + .mismatch = DATA_TO_TEXT
91915 }
91916 };
91917
91918 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91919 continue;
91920 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91921 continue;
91922 - if (sym->st_value == addr)
91923 - return sym;
91924 /* Find a symbol nearby - addr are maybe negative */
91925 d = sym->st_value - addr;
91926 + if (d == 0)
91927 + return sym;
91928 if (d < 0)
91929 d = addr - sym->st_value;
91930 if (d < distance) {
91931 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
91932 tosym, prl_to, prl_to, tosym);
91933 free(prl_to);
91934 break;
91935 + case DATA_TO_TEXT:
91936 +#if 0
91937 + fprintf(stderr,
91938 + "The %s %s:%s references\n"
91939 + "the %s %s:%s%s\n",
91940 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91941 +#endif
91942 + break;
91943 }
91944 fprintf(stderr, "\n");
91945 }
91946 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91947 static void check_sec_ref(struct module *mod, const char *modname,
91948 struct elf_info *elf)
91949 {
91950 - int i;
91951 + unsigned int i;
91952 Elf_Shdr *sechdrs = elf->sechdrs;
91953
91954 /* Walk through all sections */
91955 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91956 va_end(ap);
91957 }
91958
91959 -void buf_write(struct buffer *buf, const char *s, int len)
91960 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91961 {
91962 if (buf->size - buf->pos < len) {
91963 buf->size += len + SZ;
91964 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91965 if (fstat(fileno(file), &st) < 0)
91966 goto close_write;
91967
91968 - if (st.st_size != b->pos)
91969 + if (st.st_size != (off_t)b->pos)
91970 goto close_write;
91971
91972 tmp = NOFAIL(malloc(b->pos));
91973 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91974 index 51207e4..f7d603d 100644
91975 --- a/scripts/mod/modpost.h
91976 +++ b/scripts/mod/modpost.h
91977 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91978
91979 struct buffer {
91980 char *p;
91981 - int pos;
91982 - int size;
91983 + unsigned int pos;
91984 + unsigned int size;
91985 };
91986
91987 void __attribute__((format(printf, 2, 3)))
91988 buf_printf(struct buffer *buf, const char *fmt, ...);
91989
91990 void
91991 -buf_write(struct buffer *buf, const char *s, int len);
91992 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91993
91994 struct module {
91995 struct module *next;
91996 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91997 index 9dfcd6d..099068e 100644
91998 --- a/scripts/mod/sumversion.c
91999 +++ b/scripts/mod/sumversion.c
92000 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
92001 goto out;
92002 }
92003
92004 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
92005 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
92006 warn("writing sum in %s failed: %s\n",
92007 filename, strerror(errno));
92008 goto out;
92009 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
92010 index acb8650..b8c5f02 100644
92011 --- a/scripts/package/builddeb
92012 +++ b/scripts/package/builddeb
92013 @@ -246,6 +246,7 @@ fi
92014 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
92015 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
92016 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
92017 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
92018 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
92019 mkdir -p "$destdir"
92020 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
92021 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
92022 index 68bb4ef..2f419e1 100644
92023 --- a/scripts/pnmtologo.c
92024 +++ b/scripts/pnmtologo.c
92025 @@ -244,14 +244,14 @@ static void write_header(void)
92026 fprintf(out, " * Linux logo %s\n", logoname);
92027 fputs(" */\n\n", out);
92028 fputs("#include <linux/linux_logo.h>\n\n", out);
92029 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
92030 + fprintf(out, "static unsigned char %s_data[] = {\n",
92031 logoname);
92032 }
92033
92034 static void write_footer(void)
92035 {
92036 fputs("\n};\n\n", out);
92037 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
92038 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
92039 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
92040 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
92041 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
92042 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
92043 fputs("\n};\n\n", out);
92044
92045 /* write logo clut */
92046 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
92047 + fprintf(out, "static unsigned char %s_clut[] = {\n",
92048 logoname);
92049 write_hex_cnt = 0;
92050 for (i = 0; i < logo_clutsize; i++) {
92051 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
92052 index e4fd45b..2eeb5c4 100644
92053 --- a/scripts/sortextable.h
92054 +++ b/scripts/sortextable.h
92055 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
92056 const char *secstrtab;
92057 const char *strtab;
92058 char *extab_image;
92059 - int extab_index = 0;
92060 - int i;
92061 - int idx;
92062 + unsigned int extab_index = 0;
92063 + unsigned int i;
92064 + unsigned int idx;
92065
92066 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
92067 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
92068 diff --git a/security/Kconfig b/security/Kconfig
92069 index e9c6ac7..4cb4ecc 100644
92070 --- a/security/Kconfig
92071 +++ b/security/Kconfig
92072 @@ -4,6 +4,943 @@
92073
92074 menu "Security options"
92075
92076 +menu "Grsecurity"
92077 +
92078 + config ARCH_TRACK_EXEC_LIMIT
92079 + bool
92080 +
92081 + config PAX_KERNEXEC_PLUGIN
92082 + bool
92083 +
92084 + config PAX_PER_CPU_PGD
92085 + bool
92086 +
92087 + config TASK_SIZE_MAX_SHIFT
92088 + int
92089 + depends on X86_64
92090 + default 47 if !PAX_PER_CPU_PGD
92091 + default 42 if PAX_PER_CPU_PGD
92092 +
92093 + config PAX_ENABLE_PAE
92094 + bool
92095 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
92096 +
92097 + config PAX_USERCOPY_SLABS
92098 + bool
92099 +
92100 +config GRKERNSEC
92101 + bool "Grsecurity"
92102 + select CRYPTO
92103 + select CRYPTO_SHA256
92104 + select PROC_FS
92105 + select STOP_MACHINE
92106 + help
92107 + If you say Y here, you will be able to configure many features
92108 + that will enhance the security of your system. It is highly
92109 + recommended that you say Y here and read through the help
92110 + for each option so that you fully understand the features and
92111 + can evaluate their usefulness for your machine.
92112 +
92113 +choice
92114 + prompt "Configuration Method"
92115 + depends on GRKERNSEC
92116 + default GRKERNSEC_CONFIG_CUSTOM
92117 + help
92118 +
92119 +config GRKERNSEC_CONFIG_AUTO
92120 + bool "Automatic"
92121 + help
92122 + If you choose this configuration method, you'll be able to answer a small
92123 + number of simple questions about how you plan to use this kernel.
92124 + The settings of grsecurity and PaX will be automatically configured for
92125 + the highest commonly-used settings within the provided constraints.
92126 +
92127 + If you require additional configuration, custom changes can still be made
92128 + from the "custom configuration" menu.
92129 +
92130 +config GRKERNSEC_CONFIG_CUSTOM
92131 + bool "Custom"
92132 + help
92133 + If you choose this configuration method, you'll be able to configure all
92134 + grsecurity and PaX settings manually. Via this method, no options are
92135 + automatically enabled.
92136 +
92137 +endchoice
92138 +
92139 +choice
92140 + prompt "Usage Type"
92141 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92142 + default GRKERNSEC_CONFIG_SERVER
92143 + help
92144 +
92145 +config GRKERNSEC_CONFIG_SERVER
92146 + bool "Server"
92147 + help
92148 + Choose this option if you plan to use this kernel on a server.
92149 +
92150 +config GRKERNSEC_CONFIG_DESKTOP
92151 + bool "Desktop"
92152 + help
92153 + Choose this option if you plan to use this kernel on a desktop.
92154 +
92155 +endchoice
92156 +
92157 +choice
92158 + prompt "Virtualization Type"
92159 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
92160 + default GRKERNSEC_CONFIG_VIRT_NONE
92161 + help
92162 +
92163 +config GRKERNSEC_CONFIG_VIRT_NONE
92164 + bool "None"
92165 + help
92166 + Choose this option if this kernel will be run on bare metal.
92167 +
92168 +config GRKERNSEC_CONFIG_VIRT_GUEST
92169 + bool "Guest"
92170 + help
92171 + Choose this option if this kernel will be run as a VM guest.
92172 +
92173 +config GRKERNSEC_CONFIG_VIRT_HOST
92174 + bool "Host"
92175 + help
92176 + Choose this option if this kernel will be run as a VM host.
92177 +
92178 +endchoice
92179 +
92180 +choice
92181 + prompt "Virtualization Hardware"
92182 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
92183 + help
92184 +
92185 +config GRKERNSEC_CONFIG_VIRT_EPT
92186 + bool "EPT/RVI Processor Support"
92187 + depends on X86
92188 + help
92189 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
92190 + hardware virtualization. This allows for additional kernel hardening protections
92191 + to operate without additional performance impact.
92192 +
92193 + To see if your Intel processor supports EPT, see:
92194 + http://ark.intel.com/Products/VirtualizationTechnology
92195 + (Most Core i3/5/7 support EPT)
92196 +
92197 + To see if your AMD processor supports RVI, see:
92198 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
92199 +
92200 +config GRKERNSEC_CONFIG_VIRT_SOFT
92201 + bool "First-gen/No Hardware Virtualization"
92202 + help
92203 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
92204 + support hardware virtualization or doesn't support the EPT/RVI extensions.
92205 +
92206 +endchoice
92207 +
92208 +choice
92209 + prompt "Virtualization Software"
92210 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
92211 + help
92212 +
92213 +config GRKERNSEC_CONFIG_VIRT_XEN
92214 + bool "Xen"
92215 + help
92216 + Choose this option if this kernel is running as a Xen guest or host.
92217 +
92218 +config GRKERNSEC_CONFIG_VIRT_VMWARE
92219 + bool "VMWare"
92220 + help
92221 + Choose this option if this kernel is running as a VMWare guest or host.
92222 +
92223 +config GRKERNSEC_CONFIG_VIRT_KVM
92224 + bool "KVM"
92225 + help
92226 + Choose this option if this kernel is running as a KVM guest or host.
92227 +
92228 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
92229 + bool "VirtualBox"
92230 + help
92231 + Choose this option if this kernel is running as a VirtualBox guest or host.
92232 +
92233 +endchoice
92234 +
92235 +choice
92236 + prompt "Required Priorities"
92237 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92238 + default GRKERNSEC_CONFIG_PRIORITY_PERF
92239 + help
92240 +
92241 +config GRKERNSEC_CONFIG_PRIORITY_PERF
92242 + bool "Performance"
92243 + help
92244 + Choose this option if performance is of highest priority for this deployment
92245 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
92246 + clearing of structures intended for userland, and freed memory sanitizing will
92247 + be disabled.
92248 +
92249 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
92250 + bool "Security"
92251 + help
92252 + Choose this option if security is of highest priority for this deployment of
92253 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
92254 + for userland, and freed memory sanitizing will be enabled for this kernel.
92255 + In a worst-case scenario, these features can introduce a 20% performance hit
92256 + (UDEREF on x64 contributing half of this hit).
92257 +
92258 +endchoice
92259 +
92260 +menu "Default Special Groups"
92261 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
92262 +
92263 +config GRKERNSEC_PROC_GID
92264 + int "GID exempted from /proc restrictions"
92265 + default 1001
92266 + help
92267 + Setting this GID determines which group will be exempted from
92268 + grsecurity's /proc restrictions, allowing users of the specified
92269 + group to view network statistics and the existence of other users'
92270 + processes on the system. This GID may also be chosen at boot time
92271 + via "grsec_proc_gid=" on the kernel commandline.
92272 +
92273 +config GRKERNSEC_TPE_UNTRUSTED_GID
92274 + int "GID for TPE-untrusted users"
92275 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
92276 + default 1005
92277 + help
92278 + Setting this GID determines which group untrusted users should
92279 + be added to. These users will be placed under grsecurity's Trusted Path
92280 + Execution mechanism, preventing them from executing their own binaries.
92281 + The users will only be able to execute binaries in directories owned and
92282 + writable only by the root user. If the sysctl option is enabled, a sysctl
92283 + option with name "tpe_gid" is created.
92284 +
92285 +config GRKERNSEC_TPE_TRUSTED_GID
92286 + int "GID for TPE-trusted users"
92287 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
92288 + default 1005
92289 + help
92290 + Setting this GID determines what group TPE restrictions will be
92291 + *disabled* for. If the sysctl option is enabled, a sysctl option
92292 + with name "tpe_gid" is created.
92293 +
92294 +config GRKERNSEC_SYMLINKOWN_GID
92295 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
92296 + depends on GRKERNSEC_CONFIG_SERVER
92297 + default 1006
92298 + help
92299 + Setting this GID determines what group kernel-enforced
92300 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
92301 + is enabled, a sysctl option with name "symlinkown_gid" is created.
92302 +
92303 +
92304 +endmenu
92305 +
92306 +menu "Customize Configuration"
92307 +depends on GRKERNSEC
92308 +
92309 +menu "PaX"
92310 +
92311 +config PAX
92312 + bool "Enable various PaX features"
92313 + default y if GRKERNSEC_CONFIG_AUTO
92314 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
92315 + help
92316 + This allows you to enable various PaX features. PaX adds
92317 + intrusion prevention mechanisms to the kernel that reduce
92318 + the risks posed by exploitable memory corruption bugs.
92319 +
92320 +menu "PaX Control"
92321 + depends on PAX
92322 +
92323 +config PAX_SOFTMODE
92324 + bool 'Support soft mode'
92325 + help
92326 + Enabling this option will allow you to run PaX in soft mode, that
92327 + is, PaX features will not be enforced by default, only on executables
92328 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
92329 + support as they are the only way to mark executables for soft mode use.
92330 +
92331 + Soft mode can be activated by using the "pax_softmode=1" kernel command
92332 + line option on boot. Furthermore you can control various PaX features
92333 + at runtime via the entries in /proc/sys/kernel/pax.
92334 +
92335 +config PAX_EI_PAX
92336 + bool 'Use legacy ELF header marking'
92337 + default y if GRKERNSEC_CONFIG_AUTO
92338 + help
92339 + Enabling this option will allow you to control PaX features on
92340 + a per executable basis via the 'chpax' utility available at
92341 + http://pax.grsecurity.net/. The control flags will be read from
92342 + an otherwise reserved part of the ELF header. This marking has
92343 + numerous drawbacks (no support for soft-mode, toolchain does not
92344 + know about the non-standard use of the ELF header) therefore it
92345 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
92346 + support.
92347 +
92348 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
92349 + support as well, they will override the legacy EI_PAX marks.
92350 +
92351 + If you enable none of the marking options then all applications
92352 + will run with PaX enabled on them by default.
92353 +
92354 +config PAX_PT_PAX_FLAGS
92355 + bool 'Use ELF program header marking'
92356 + default y if GRKERNSEC_CONFIG_AUTO
92357 + help
92358 + Enabling this option will allow you to control PaX features on
92359 + a per executable basis via the 'paxctl' utility available at
92360 + http://pax.grsecurity.net/. The control flags will be read from
92361 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
92362 + has the benefits of supporting both soft mode and being fully
92363 + integrated into the toolchain (the binutils patch is available
92364 + from http://pax.grsecurity.net).
92365 +
92366 + Note that if you enable the legacy EI_PAX marking support as well,
92367 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
92368 +
92369 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92370 + must make sure that the marks are the same if a binary has both marks.
92371 +
92372 + If you enable none of the marking options then all applications
92373 + will run with PaX enabled on them by default.
92374 +
92375 +config PAX_XATTR_PAX_FLAGS
92376 + bool 'Use filesystem extended attributes marking'
92377 + default y if GRKERNSEC_CONFIG_AUTO
92378 + select CIFS_XATTR if CIFS
92379 + select EXT2_FS_XATTR if EXT2_FS
92380 + select EXT3_FS_XATTR if EXT3_FS
92381 + select EXT4_FS_XATTR if EXT4_FS
92382 + select JFFS2_FS_XATTR if JFFS2_FS
92383 + select REISERFS_FS_XATTR if REISERFS_FS
92384 + select SQUASHFS_XATTR if SQUASHFS
92385 + select TMPFS_XATTR if TMPFS
92386 + select UBIFS_FS_XATTR if UBIFS_FS
92387 + help
92388 + Enabling this option will allow you to control PaX features on
92389 + a per executable basis via the 'setfattr' utility. The control
92390 + flags will be read from the user.pax.flags extended attribute of
92391 + the file. This marking has the benefit of supporting binary-only
92392 + applications that self-check themselves (e.g., skype) and would
92393 + not tolerate chpax/paxctl changes. The main drawback is that
92394 + extended attributes are not supported by some filesystems (e.g.,
92395 + isofs, udf, vfat) so copying files through such filesystems will
92396 + lose the extended attributes and these PaX markings.
92397 +
92398 + Note that if you enable the legacy EI_PAX marking support as well,
92399 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
92400 +
92401 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92402 + must make sure that the marks are the same if a binary has both marks.
92403 +
92404 + If you enable none of the marking options then all applications
92405 + will run with PaX enabled on them by default.
92406 +
92407 +choice
92408 + prompt 'MAC system integration'
92409 + default PAX_HAVE_ACL_FLAGS
92410 + help
92411 + Mandatory Access Control systems have the option of controlling
92412 + PaX flags on a per executable basis, choose the method supported
92413 + by your particular system.
92414 +
92415 + - "none": if your MAC system does not interact with PaX,
92416 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
92417 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
92418 +
92419 + NOTE: this option is for developers/integrators only.
92420 +
92421 + config PAX_NO_ACL_FLAGS
92422 + bool 'none'
92423 +
92424 + config PAX_HAVE_ACL_FLAGS
92425 + bool 'direct'
92426 +
92427 + config PAX_HOOK_ACL_FLAGS
92428 + bool 'hook'
92429 +endchoice
92430 +
92431 +endmenu
92432 +
92433 +menu "Non-executable pages"
92434 + depends on PAX
92435 +
92436 +config PAX_NOEXEC
92437 + bool "Enforce non-executable pages"
92438 + default y if GRKERNSEC_CONFIG_AUTO
92439 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
92440 + help
92441 + By design some architectures do not allow for protecting memory
92442 + pages against execution or even if they do, Linux does not make
92443 + use of this feature. In practice this means that if a page is
92444 + readable (such as the stack or heap) it is also executable.
92445 +
92446 + There is a well known exploit technique that makes use of this
92447 + fact and a common programming mistake where an attacker can
92448 + introduce code of his choice somewhere in the attacked program's
92449 + memory (typically the stack or the heap) and then execute it.
92450 +
92451 + If the attacked program was running with different (typically
92452 + higher) privileges than that of the attacker, then he can elevate
92453 + his own privilege level (e.g. get a root shell, write to files for
92454 + which he does not have write access to, etc).
92455 +
92456 + Enabling this option will let you choose from various features
92457 + that prevent the injection and execution of 'foreign' code in
92458 + a program.
92459 +
92460 + This will also break programs that rely on the old behaviour and
92461 + expect that dynamically allocated memory via the malloc() family
92462 + of functions is executable (which it is not). Notable examples
92463 + are the XFree86 4.x server, the java runtime and wine.
92464 +
92465 +config PAX_PAGEEXEC
92466 + bool "Paging based non-executable pages"
92467 + default y if GRKERNSEC_CONFIG_AUTO
92468 + 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)
92469 + select S390_SWITCH_AMODE if S390
92470 + select S390_EXEC_PROTECT if S390
92471 + select ARCH_TRACK_EXEC_LIMIT if X86_32
92472 + help
92473 + This implementation is based on the paging feature of the CPU.
92474 + On i386 without hardware non-executable bit support there is a
92475 + variable but usually low performance impact, however on Intel's
92476 + P4 core based CPUs it is very high so you should not enable this
92477 + for kernels meant to be used on such CPUs.
92478 +
92479 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
92480 + with hardware non-executable bit support there is no performance
92481 + impact, on ppc the impact is negligible.
92482 +
92483 + Note that several architectures require various emulations due to
92484 + badly designed userland ABIs, this will cause a performance impact
92485 + but will disappear as soon as userland is fixed. For example, ppc
92486 + userland MUST have been built with secure-plt by a recent toolchain.
92487 +
92488 +config PAX_SEGMEXEC
92489 + bool "Segmentation based non-executable pages"
92490 + default y if GRKERNSEC_CONFIG_AUTO
92491 + depends on PAX_NOEXEC && X86_32
92492 + help
92493 + This implementation is based on the segmentation feature of the
92494 + CPU and has a very small performance impact, however applications
92495 + will be limited to a 1.5 GB address space instead of the normal
92496 + 3 GB.
92497 +
92498 +config PAX_EMUTRAMP
92499 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
92500 + default y if PARISC
92501 + help
92502 + There are some programs and libraries that for one reason or
92503 + another attempt to execute special small code snippets from
92504 + non-executable memory pages. Most notable examples are the
92505 + signal handler return code generated by the kernel itself and
92506 + the GCC trampolines.
92507 +
92508 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
92509 + such programs will no longer work under your kernel.
92510 +
92511 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
92512 + utilities to enable trampoline emulation for the affected programs
92513 + yet still have the protection provided by the non-executable pages.
92514 +
92515 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
92516 + your system will not even boot.
92517 +
92518 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
92519 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
92520 + for the affected files.
92521 +
92522 + NOTE: enabling this feature *may* open up a loophole in the
92523 + protection provided by non-executable pages that an attacker
92524 + could abuse. Therefore the best solution is to not have any
92525 + files on your system that would require this option. This can
92526 + be achieved by not using libc5 (which relies on the kernel
92527 + signal handler return code) and not using or rewriting programs
92528 + that make use of the nested function implementation of GCC.
92529 + Skilled users can just fix GCC itself so that it implements
92530 + nested function calls in a way that does not interfere with PaX.
92531 +
92532 +config PAX_EMUSIGRT
92533 + bool "Automatically emulate sigreturn trampolines"
92534 + depends on PAX_EMUTRAMP && PARISC
92535 + default y
92536 + help
92537 + Enabling this option will have the kernel automatically detect
92538 + and emulate signal return trampolines executing on the stack
92539 + that would otherwise lead to task termination.
92540 +
92541 + This solution is intended as a temporary one for users with
92542 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
92543 + Modula-3 runtime, etc) or executables linked to such, basically
92544 + everything that does not specify its own SA_RESTORER function in
92545 + normal executable memory like glibc 2.1+ does.
92546 +
92547 + On parisc you MUST enable this option, otherwise your system will
92548 + not even boot.
92549 +
92550 + NOTE: this feature cannot be disabled on a per executable basis
92551 + and since it *does* open up a loophole in the protection provided
92552 + by non-executable pages, the best solution is to not have any
92553 + files on your system that would require this option.
92554 +
92555 +config PAX_MPROTECT
92556 + bool "Restrict mprotect()"
92557 + default y if GRKERNSEC_CONFIG_AUTO
92558 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
92559 + help
92560 + Enabling this option will prevent programs from
92561 + - changing the executable status of memory pages that were
92562 + not originally created as executable,
92563 + - making read-only executable pages writable again,
92564 + - creating executable pages from anonymous memory,
92565 + - making read-only-after-relocations (RELRO) data pages writable again.
92566 +
92567 + You should say Y here to complete the protection provided by
92568 + the enforcement of non-executable pages.
92569 +
92570 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92571 + this feature on a per file basis.
92572 +
92573 +config PAX_MPROTECT_COMPAT
92574 + bool "Use legacy/compat protection demoting (read help)"
92575 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92576 + depends on PAX_MPROTECT
92577 + help
92578 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
92579 + by sending the proper error code to the application. For some broken
92580 + userland, this can cause problems with Python or other applications. The
92581 + current implementation however allows for applications like clamav to
92582 + detect if JIT compilation/execution is allowed and to fall back gracefully
92583 + to an interpreter-based mode if it does not. While we encourage everyone
92584 + to use the current implementation as-is and push upstream to fix broken
92585 + userland (note that the RWX logging option can assist with this), in some
92586 + environments this may not be possible. Having to disable MPROTECT
92587 + completely on certain binaries reduces the security benefit of PaX,
92588 + so this option is provided for those environments to revert to the old
92589 + behavior.
92590 +
92591 +config PAX_ELFRELOCS
92592 + bool "Allow ELF text relocations (read help)"
92593 + depends on PAX_MPROTECT
92594 + default n
92595 + help
92596 + Non-executable pages and mprotect() restrictions are effective
92597 + in preventing the introduction of new executable code into an
92598 + attacked task's address space. There remain only two venues
92599 + for this kind of attack: if the attacker can execute already
92600 + existing code in the attacked task then he can either have it
92601 + create and mmap() a file containing his code or have it mmap()
92602 + an already existing ELF library that does not have position
92603 + independent code in it and use mprotect() on it to make it
92604 + writable and copy his code there. While protecting against
92605 + the former approach is beyond PaX, the latter can be prevented
92606 + by having only PIC ELF libraries on one's system (which do not
92607 + need to relocate their code). If you are sure this is your case,
92608 + as is the case with all modern Linux distributions, then leave
92609 + this option disabled. You should say 'n' here.
92610 +
92611 +config PAX_ETEXECRELOCS
92612 + bool "Allow ELF ET_EXEC text relocations"
92613 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
92614 + select PAX_ELFRELOCS
92615 + default y
92616 + help
92617 + On some architectures there are incorrectly created applications
92618 + that require text relocations and would not work without enabling
92619 + this option. If you are an alpha, ia64 or parisc user, you should
92620 + enable this option and disable it once you have made sure that
92621 + none of your applications need it.
92622 +
92623 +config PAX_EMUPLT
92624 + bool "Automatically emulate ELF PLT"
92625 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
92626 + default y
92627 + help
92628 + Enabling this option will have the kernel automatically detect
92629 + and emulate the Procedure Linkage Table entries in ELF files.
92630 + On some architectures such entries are in writable memory, and
92631 + become non-executable leading to task termination. Therefore
92632 + it is mandatory that you enable this option on alpha, parisc,
92633 + sparc and sparc64, otherwise your system would not even boot.
92634 +
92635 + NOTE: this feature *does* open up a loophole in the protection
92636 + provided by the non-executable pages, therefore the proper
92637 + solution is to modify the toolchain to produce a PLT that does
92638 + not need to be writable.
92639 +
92640 +config PAX_DLRESOLVE
92641 + bool 'Emulate old glibc resolver stub'
92642 + depends on PAX_EMUPLT && SPARC
92643 + default n
92644 + help
92645 + This option is needed if userland has an old glibc (before 2.4)
92646 + that puts a 'save' instruction into the runtime generated resolver
92647 + stub that needs special emulation.
92648 +
92649 +config PAX_KERNEXEC
92650 + bool "Enforce non-executable kernel pages"
92651 + 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))
92652 + depends on ((X86 && (!X86_32 || X86_WP_WORKS_OK)) || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92653 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92654 + select PAX_KERNEXEC_PLUGIN if X86_64
92655 + help
92656 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92657 + that is, enabling this option will make it harder to inject
92658 + and execute 'foreign' code in kernel memory itself.
92659 +
92660 +choice
92661 + prompt "Return Address Instrumentation Method"
92662 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92663 + depends on PAX_KERNEXEC_PLUGIN
92664 + help
92665 + Select the method used to instrument function pointer dereferences.
92666 + Note that binary modules cannot be instrumented by this approach.
92667 +
92668 + Note that the implementation requires a gcc with plugin support,
92669 + i.e., gcc 4.5 or newer. You may need to install the supporting
92670 + headers explicitly in addition to the normal gcc package.
92671 +
92672 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92673 + bool "bts"
92674 + help
92675 + This method is compatible with binary only modules but has
92676 + a higher runtime overhead.
92677 +
92678 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92679 + bool "or"
92680 + depends on !PARAVIRT
92681 + help
92682 + This method is incompatible with binary only modules but has
92683 + a lower runtime overhead.
92684 +endchoice
92685 +
92686 +config PAX_KERNEXEC_PLUGIN_METHOD
92687 + string
92688 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92689 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92690 + default ""
92691 +
92692 +config PAX_KERNEXEC_MODULE_TEXT
92693 + int "Minimum amount of memory reserved for module code"
92694 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92695 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92696 + depends on PAX_KERNEXEC && X86_32 && MODULES
92697 + help
92698 + Due to implementation details the kernel must reserve a fixed
92699 + amount of memory for module code at compile time that cannot be
92700 + changed at runtime. Here you can specify the minimum amount
92701 + in MB that will be reserved. Due to the same implementation
92702 + details this size will always be rounded up to the next 2/4 MB
92703 + boundary (depends on PAE) so the actually available memory for
92704 + module code will usually be more than this minimum.
92705 +
92706 + The default 4 MB should be enough for most users but if you have
92707 + an excessive number of modules (e.g., most distribution configs
92708 + compile many drivers as modules) or use huge modules such as
92709 + nvidia's kernel driver, you will need to adjust this amount.
92710 + A good rule of thumb is to look at your currently loaded kernel
92711 + modules and add up their sizes.
92712 +
92713 +endmenu
92714 +
92715 +menu "Address Space Layout Randomization"
92716 + depends on PAX
92717 +
92718 +config PAX_ASLR
92719 + bool "Address Space Layout Randomization"
92720 + default y if GRKERNSEC_CONFIG_AUTO
92721 + help
92722 + Many if not most exploit techniques rely on the knowledge of
92723 + certain addresses in the attacked program. The following options
92724 + will allow the kernel to apply a certain amount of randomization
92725 + to specific parts of the program thereby forcing an attacker to
92726 + guess them in most cases. Any failed guess will most likely crash
92727 + the attacked program which allows the kernel to detect such attempts
92728 + and react on them. PaX itself provides no reaction mechanisms,
92729 + instead it is strongly encouraged that you make use of Nergal's
92730 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92731 + (http://www.grsecurity.net/) built-in crash detection features or
92732 + develop one yourself.
92733 +
92734 + By saying Y here you can choose to randomize the following areas:
92735 + - top of the task's kernel stack
92736 + - top of the task's userland stack
92737 + - base address for mmap() requests that do not specify one
92738 + (this includes all libraries)
92739 + - base address of the main executable
92740 +
92741 + It is strongly recommended to say Y here as address space layout
92742 + randomization has negligible impact on performance yet it provides
92743 + a very effective protection.
92744 +
92745 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92746 + this feature on a per file basis.
92747 +
92748 +config PAX_RANDKSTACK
92749 + bool "Randomize kernel stack base"
92750 + default y if GRKERNSEC_CONFIG_AUTO
92751 + depends on X86_TSC && X86
92752 + help
92753 + By saying Y here the kernel will randomize every task's kernel
92754 + stack on every system call. This will not only force an attacker
92755 + to guess it but also prevent him from making use of possible
92756 + leaked information about it.
92757 +
92758 + Since the kernel stack is a rather scarce resource, randomization
92759 + may cause unexpected stack overflows, therefore you should very
92760 + carefully test your system. Note that once enabled in the kernel
92761 + configuration, this feature cannot be disabled on a per file basis.
92762 +
92763 +config PAX_RANDUSTACK
92764 + bool "Randomize user stack base"
92765 + default y if GRKERNSEC_CONFIG_AUTO
92766 + depends on PAX_ASLR
92767 + help
92768 + By saying Y here the kernel will randomize every task's userland
92769 + stack. The randomization is done in two steps where the second
92770 + one may apply a big amount of shift to the top of the stack and
92771 + cause problems for programs that want to use lots of memory (more
92772 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92773 + For this reason the second step can be controlled by 'chpax' or
92774 + 'paxctl' on a per file basis.
92775 +
92776 +config PAX_RANDMMAP
92777 + bool "Randomize mmap() base"
92778 + default y if GRKERNSEC_CONFIG_AUTO
92779 + depends on PAX_ASLR
92780 + help
92781 + By saying Y here the kernel will use a randomized base address for
92782 + mmap() requests that do not specify one themselves. As a result
92783 + all dynamically loaded libraries will appear at random addresses
92784 + and therefore be harder to exploit by a technique where an attacker
92785 + attempts to execute library code for his purposes (e.g. spawn a
92786 + shell from an exploited program that is running at an elevated
92787 + privilege level).
92788 +
92789 + Furthermore, if a program is relinked as a dynamic ELF file, its
92790 + base address will be randomized as well, completing the full
92791 + randomization of the address space layout. Attacking such programs
92792 + becomes a guess game. You can find an example of doing this at
92793 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92794 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92795 +
92796 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92797 + feature on a per file basis.
92798 +
92799 +endmenu
92800 +
92801 +menu "Miscellaneous hardening features"
92802 +
92803 +config PAX_MEMORY_SANITIZE
92804 + bool "Sanitize all freed memory"
92805 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92806 + depends on !HIBERNATION
92807 + help
92808 + By saying Y here the kernel will erase memory pages as soon as they
92809 + are freed. This in turn reduces the lifetime of data stored in the
92810 + pages, making it less likely that sensitive information such as
92811 + passwords, cryptographic secrets, etc stay in memory for too long.
92812 +
92813 + This is especially useful for programs whose runtime is short, long
92814 + lived processes and the kernel itself benefit from this as long as
92815 + they operate on whole memory pages and ensure timely freeing of pages
92816 + that may hold sensitive information.
92817 +
92818 + The tradeoff is performance impact, on a single CPU system kernel
92819 + compilation sees a 3% slowdown, other systems and workloads may vary
92820 + and you are advised to test this feature on your expected workload
92821 + before deploying it.
92822 +
92823 + Note that this feature does not protect data stored in live pages,
92824 + e.g., process memory swapped to disk may stay there for a long time.
92825 +
92826 +config PAX_MEMORY_STACKLEAK
92827 + bool "Sanitize kernel stack"
92828 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92829 + depends on X86
92830 + help
92831 + By saying Y here the kernel will erase the kernel stack before it
92832 + returns from a system call. This in turn reduces the information
92833 + that a kernel stack leak bug can reveal.
92834 +
92835 + Note that such a bug can still leak information that was put on
92836 + the stack by the current system call (the one eventually triggering
92837 + the bug) but traces of earlier system calls on the kernel stack
92838 + cannot leak anymore.
92839 +
92840 + The tradeoff is performance impact: on a single CPU system kernel
92841 + compilation sees a 1% slowdown, other systems and workloads may vary
92842 + and you are advised to test this feature on your expected workload
92843 + before deploying it.
92844 +
92845 + Note that the full feature requires a gcc with plugin support,
92846 + i.e., gcc 4.5 or newer. You may need to install the supporting
92847 + headers explicitly in addition to the normal gcc package. Using
92848 + older gcc versions means that functions with large enough stack
92849 + frames may leave uninitialized memory behind that may be exposed
92850 + to a later syscall leaking the stack.
92851 +
92852 +config PAX_MEMORY_STRUCTLEAK
92853 + bool "Forcibly initialize local variables copied to userland"
92854 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92855 + help
92856 + By saying Y here the kernel will zero initialize some local
92857 + variables that are going to be copied to userland. This in
92858 + turn prevents unintended information leakage from the kernel
92859 + stack should later code forget to explicitly set all parts of
92860 + the copied variable.
92861 +
92862 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92863 + at a much smaller coverage.
92864 +
92865 + Note that the implementation requires a gcc with plugin support,
92866 + i.e., gcc 4.5 or newer. You may need to install the supporting
92867 + headers explicitly in addition to the normal gcc package.
92868 +
92869 +config PAX_MEMORY_UDEREF
92870 + bool "Prevent invalid userland pointer dereference"
92871 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92872 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92873 + select PAX_PER_CPU_PGD if X86_64
92874 + help
92875 + By saying Y here the kernel will be prevented from dereferencing
92876 + userland pointers in contexts where the kernel expects only kernel
92877 + pointers. This is both a useful runtime debugging feature and a
92878 + security measure that prevents exploiting a class of kernel bugs.
92879 +
92880 + The tradeoff is that some virtualization solutions may experience
92881 + a huge slowdown and therefore you should not enable this feature
92882 + for kernels meant to run in such environments. Whether a given VM
92883 + solution is affected or not is best determined by simply trying it
92884 + out, the performance impact will be obvious right on boot as this
92885 + mechanism engages from very early on. A good rule of thumb is that
92886 + VMs running on CPUs without hardware virtualization support (i.e.,
92887 + the majority of IA-32 CPUs) will likely experience the slowdown.
92888 +
92889 +config PAX_REFCOUNT
92890 + bool "Prevent various kernel object reference counter overflows"
92891 + default y if GRKERNSEC_CONFIG_AUTO
92892 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92893 + help
92894 + By saying Y here the kernel will detect and prevent overflowing
92895 + various (but not all) kinds of object reference counters. Such
92896 + overflows can normally occur due to bugs only and are often, if
92897 + not always, exploitable.
92898 +
92899 + The tradeoff is that data structures protected by an overflowed
92900 + refcount will never be freed and therefore will leak memory. Note
92901 + that this leak also happens even without this protection but in
92902 + that case the overflow can eventually trigger the freeing of the
92903 + data structure while it is still being used elsewhere, resulting
92904 + in the exploitable situation that this feature prevents.
92905 +
92906 + Since this has a negligible performance impact, you should enable
92907 + this feature.
92908 +
92909 +config PAX_CONSTIFY_PLUGIN
92910 + bool "Automatically constify eligible structures"
92911 + default y
92912 + depends on !UML && PAX_KERNEXEC
92913 + help
92914 + By saying Y here the compiler will automatically constify a class
92915 + of types that contain only function pointers. This reduces the
92916 + kernel's attack surface and also produces a better memory layout.
92917 +
92918 + Note that the implementation requires a gcc with plugin support,
92919 + i.e., gcc 4.5 or newer. You may need to install the supporting
92920 + headers explicitly in addition to the normal gcc package.
92921 +
92922 + Note that if some code really has to modify constified variables
92923 + then the source code will have to be patched to allow it. Examples
92924 + can be found in PaX itself (the no_const attribute) and for some
92925 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92926 +
92927 +config PAX_USERCOPY
92928 + bool "Harden heap object copies between kernel and userland"
92929 + default y if GRKERNSEC_CONFIG_AUTO
92930 + depends on ARM || IA64 || PPC || SPARC || X86
92931 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92932 + select PAX_USERCOPY_SLABS
92933 + help
92934 + By saying Y here the kernel will enforce the size of heap objects
92935 + when they are copied in either direction between the kernel and
92936 + userland, even if only a part of the heap object is copied.
92937 +
92938 + Specifically, this checking prevents information leaking from the
92939 + kernel heap during kernel to userland copies (if the kernel heap
92940 + object is otherwise fully initialized) and prevents kernel heap
92941 + overflows during userland to kernel copies.
92942 +
92943 + Note that the current implementation provides the strictest bounds
92944 + checks for the SLUB allocator.
92945 +
92946 + Enabling this option also enables per-slab cache protection against
92947 + data in a given cache being copied into/out of via userland
92948 + accessors. Though the whitelist of regions will be reduced over
92949 + time, it notably protects important data structures like task structs.
92950 +
92951 + If frame pointers are enabled on x86, this option will also restrict
92952 + copies into and out of the kernel stack to local variables within a
92953 + single frame.
92954 +
92955 + Since this has a negligible performance impact, you should enable
92956 + this feature.
92957 +
92958 +config PAX_USERCOPY_DEBUG
92959 + bool
92960 + depends on X86 && PAX_USERCOPY
92961 + default n
92962 +
92963 +config PAX_SIZE_OVERFLOW
92964 + bool "Prevent various integer overflows in function size parameters"
92965 + default y if GRKERNSEC_CONFIG_AUTO
92966 + depends on X86
92967 + help
92968 + By saying Y here the kernel recomputes expressions of function
92969 + arguments marked by a size_overflow attribute with double integer
92970 + precision (DImode/TImode for 32/64 bit integer types).
92971 +
92972 + The recomputed argument is checked against TYPE_MAX and an event
92973 + is logged on overflow and the triggering process is killed.
92974 +
92975 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92976 +
92977 + Note that the implementation requires a gcc with plugin support,
92978 + i.e., gcc 4.5 or newer. You may need to install the supporting
92979 + headers explicitly in addition to the normal gcc package.
92980 +
92981 +config PAX_LATENT_ENTROPY
92982 + bool "Generate some entropy during boot"
92983 + default y if GRKERNSEC_CONFIG_AUTO
92984 + help
92985 + By saying Y here the kernel will instrument early boot code to
92986 + extract some entropy from both original and artificially created
92987 + program state. This will help especially embedded systems where
92988 + there is little 'natural' source of entropy normally. The cost
92989 + is some slowdown of the boot process.
92990 +
92991 + When pax_extra_latent_entropy is passed on the kernel command line,
92992 + entropy will be extracted from up to the first 4GB of RAM while the
92993 + runtime memory allocator is being initialized. This costs even more
92994 + slowdown of the boot process.
92995 +
92996 + Note that the implementation requires a gcc with plugin support,
92997 + i.e., gcc 4.5 or newer. You may need to install the supporting
92998 + headers explicitly in addition to the normal gcc package.
92999 +
93000 + Note that entropy extracted this way is not cryptographically
93001 + secure!
93002 +
93003 +endmenu
93004 +
93005 +endmenu
93006 +
93007 +source grsecurity/Kconfig
93008 +
93009 +endmenu
93010 +
93011 +endmenu
93012 +
93013 source security/keys/Kconfig
93014
93015 config SECURITY_DMESG_RESTRICT
93016 @@ -103,7 +1040,7 @@ config INTEL_TXT
93017 config LSM_MMAP_MIN_ADDR
93018 int "Low address space for LSM to protect from user allocation"
93019 depends on SECURITY && SECURITY_SELINUX
93020 - default 32768 if ARM
93021 + default 32768 if ALPHA || ARM || PARISC || SPARC32
93022 default 65536
93023 help
93024 This is the portion of low virtual memory which should be protected
93025 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
93026 index 8c2a7f6..b133ac9 100644
93027 --- a/security/apparmor/lsm.c
93028 +++ b/security/apparmor/lsm.c
93029 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
93030 return error;
93031 }
93032
93033 -static struct security_operations apparmor_ops = {
93034 +static struct security_operations apparmor_ops __read_only = {
93035 .name = "apparmor",
93036
93037 .ptrace_access_check = apparmor_ptrace_access_check,
93038 diff --git a/security/commoncap.c b/security/commoncap.c
93039 index 7ee08c7..8d1a9d6 100644
93040 --- a/security/commoncap.c
93041 +++ b/security/commoncap.c
93042 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
93043 return 0;
93044 }
93045
93046 +/* returns:
93047 + 1 for suid privilege
93048 + 2 for sgid privilege
93049 + 3 for fscap privilege
93050 +*/
93051 +int is_privileged_binary(const struct dentry *dentry)
93052 +{
93053 + struct cpu_vfs_cap_data capdata;
93054 + struct inode *inode = dentry->d_inode;
93055 +
93056 + if (!inode || S_ISDIR(inode->i_mode))
93057 + return 0;
93058 +
93059 + if (inode->i_mode & S_ISUID)
93060 + return 1;
93061 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
93062 + return 2;
93063 +
93064 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
93065 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
93066 + return 3;
93067 + }
93068 +
93069 + return 0;
93070 +}
93071 +
93072 /*
93073 * Attempt to get the on-exec apply capability sets for an executable file from
93074 * its xattrs and, if present, apply them to the proposed credentials being
93075 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
93076 const struct cred *cred = current_cred();
93077 kuid_t root_uid = make_kuid(cred->user_ns, 0);
93078
93079 + if (gr_acl_enable_at_secure())
93080 + return 1;
93081 +
93082 if (!uid_eq(cred->uid, root_uid)) {
93083 if (bprm->cap_effective)
93084 return 1;
93085 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
93086 index 079a85d..12e93f8 100644
93087 --- a/security/integrity/ima/ima.h
93088 +++ b/security/integrity/ima/ima.h
93089 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
93090 extern spinlock_t ima_queue_lock;
93091
93092 struct ima_h_table {
93093 - atomic_long_t len; /* number of stored measurements in the list */
93094 - atomic_long_t violations;
93095 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
93096 + atomic_long_unchecked_t violations;
93097 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
93098 };
93099 extern struct ima_h_table ima_htable;
93100 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
93101 index 0cea3db..2f0ef77 100644
93102 --- a/security/integrity/ima/ima_api.c
93103 +++ b/security/integrity/ima/ima_api.c
93104 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
93105 int result;
93106
93107 /* can overflow, only indicator */
93108 - atomic_long_inc(&ima_htable.violations);
93109 + atomic_long_inc_unchecked(&ima_htable.violations);
93110
93111 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
93112 if (!entry) {
93113 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
93114 index 38477c9..87a60c7 100644
93115 --- a/security/integrity/ima/ima_fs.c
93116 +++ b/security/integrity/ima/ima_fs.c
93117 @@ -28,12 +28,12 @@
93118 static int valid_policy = 1;
93119 #define TMPBUFLEN 12
93120 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
93121 - loff_t *ppos, atomic_long_t *val)
93122 + loff_t *ppos, atomic_long_unchecked_t *val)
93123 {
93124 char tmpbuf[TMPBUFLEN];
93125 ssize_t len;
93126
93127 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
93128 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
93129 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
93130 }
93131
93132 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
93133 index 55a6271..ad829c3 100644
93134 --- a/security/integrity/ima/ima_queue.c
93135 +++ b/security/integrity/ima/ima_queue.c
93136 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
93137 INIT_LIST_HEAD(&qe->later);
93138 list_add_tail_rcu(&qe->later, &ima_measurements);
93139
93140 - atomic_long_inc(&ima_htable.len);
93141 + atomic_long_inc_unchecked(&ima_htable.len);
93142 key = ima_hash_key(entry->digest);
93143 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
93144 return 0;
93145 diff --git a/security/keys/compat.c b/security/keys/compat.c
93146 index d65fa7f..cbfe366 100644
93147 --- a/security/keys/compat.c
93148 +++ b/security/keys/compat.c
93149 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
93150 if (ret == 0)
93151 goto no_payload_free;
93152
93153 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93154 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93155 err:
93156 if (iov != iovstack)
93157 kfree(iov);
93158 diff --git a/security/keys/key.c b/security/keys/key.c
93159 index 8fb7c7b..ba3610d 100644
93160 --- a/security/keys/key.c
93161 +++ b/security/keys/key.c
93162 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
93163
93164 atomic_set(&key->usage, 1);
93165 init_rwsem(&key->sem);
93166 - lockdep_set_class(&key->sem, &type->lock_class);
93167 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
93168 key->type = type;
93169 key->user = user;
93170 key->quotalen = quotalen;
93171 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
93172 struct key_type *p;
93173 int ret;
93174
93175 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
93176 + pax_open_kernel();
93177 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
93178 + pax_close_kernel();
93179
93180 ret = -EEXIST;
93181 down_write(&key_types_sem);
93182 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
93183 }
93184
93185 /* store the type */
93186 - list_add(&ktype->link, &key_types_list);
93187 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
93188
93189 pr_notice("Key type %s registered\n", ktype->name);
93190 ret = 0;
93191 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
93192 void unregister_key_type(struct key_type *ktype)
93193 {
93194 down_write(&key_types_sem);
93195 - list_del_init(&ktype->link);
93196 + pax_list_del_init((struct list_head *)&ktype->link);
93197 downgrade_write(&key_types_sem);
93198 key_gc_keytype(ktype);
93199 pr_notice("Key type %s unregistered\n", ktype->name);
93200 @@ -1084,10 +1086,10 @@ void __init key_init(void)
93201 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
93202
93203 /* add the special key types */
93204 - list_add_tail(&key_type_keyring.link, &key_types_list);
93205 - list_add_tail(&key_type_dead.link, &key_types_list);
93206 - list_add_tail(&key_type_user.link, &key_types_list);
93207 - list_add_tail(&key_type_logon.link, &key_types_list);
93208 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
93209 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
93210 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
93211 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
93212
93213 /* record the root user tracking */
93214 rb_link_node(&root_key_user.node,
93215 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
93216 index 4b5c948..2054dc1 100644
93217 --- a/security/keys/keyctl.c
93218 +++ b/security/keys/keyctl.c
93219 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
93220 /*
93221 * Copy the iovec data from userspace
93222 */
93223 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93224 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
93225 unsigned ioc)
93226 {
93227 for (; ioc > 0; ioc--) {
93228 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93229 * If successful, 0 will be returned.
93230 */
93231 long keyctl_instantiate_key_common(key_serial_t id,
93232 - const struct iovec *payload_iov,
93233 + const struct iovec __user *payload_iov,
93234 unsigned ioc,
93235 size_t plen,
93236 key_serial_t ringid)
93237 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
93238 [0].iov_len = plen
93239 };
93240
93241 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
93242 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
93243 }
93244
93245 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
93246 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
93247 if (ret == 0)
93248 goto no_payload_free;
93249
93250 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93251 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93252 err:
93253 if (iov != iovstack)
93254 kfree(iov);
93255 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
93256 index 6ece7f2..ecdb55c 100644
93257 --- a/security/keys/keyring.c
93258 +++ b/security/keys/keyring.c
93259 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
93260 ret = -EFAULT;
93261
93262 for (loop = 0; loop < klist->nkeys; loop++) {
93263 + key_serial_t serial;
93264 key = rcu_deref_link_locked(klist, loop,
93265 keyring);
93266 + serial = key->serial;
93267
93268 tmp = sizeof(key_serial_t);
93269 if (tmp > buflen)
93270 tmp = buflen;
93271
93272 - if (copy_to_user(buffer,
93273 - &key->serial,
93274 - tmp) != 0)
93275 + if (copy_to_user(buffer, &serial, tmp))
93276 goto error;
93277
93278 buflen -= tmp;
93279 diff --git a/security/min_addr.c b/security/min_addr.c
93280 index f728728..6457a0c 100644
93281 --- a/security/min_addr.c
93282 +++ b/security/min_addr.c
93283 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
93284 */
93285 static void update_mmap_min_addr(void)
93286 {
93287 +#ifndef SPARC
93288 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
93289 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
93290 mmap_min_addr = dac_mmap_min_addr;
93291 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
93292 #else
93293 mmap_min_addr = dac_mmap_min_addr;
93294 #endif
93295 +#endif
93296 }
93297
93298 /*
93299 diff --git a/security/security.c b/security/security.c
93300 index 7b88c6a..1e3ea8f 100644
93301 --- a/security/security.c
93302 +++ b/security/security.c
93303 @@ -20,6 +20,7 @@
93304 #include <linux/ima.h>
93305 #include <linux/evm.h>
93306 #include <linux/fsnotify.h>
93307 +#include <linux/mm.h>
93308 #include <linux/mman.h>
93309 #include <linux/mount.h>
93310 #include <linux/personality.h>
93311 @@ -32,8 +33,8 @@
93312 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
93313 CONFIG_DEFAULT_SECURITY;
93314
93315 -static struct security_operations *security_ops;
93316 -static struct security_operations default_security_ops = {
93317 +static struct security_operations *security_ops __read_only;
93318 +static struct security_operations default_security_ops __read_only = {
93319 .name = "default",
93320 };
93321
93322 @@ -74,7 +75,9 @@ int __init security_init(void)
93323
93324 void reset_security_ops(void)
93325 {
93326 + pax_open_kernel();
93327 security_ops = &default_security_ops;
93328 + pax_close_kernel();
93329 }
93330
93331 /* Save user chosen LSM */
93332 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
93333 index ef26e96..642fb78 100644
93334 --- a/security/selinux/hooks.c
93335 +++ b/security/selinux/hooks.c
93336 @@ -95,8 +95,6 @@
93337
93338 #define NUM_SEL_MNT_OPTS 5
93339
93340 -extern struct security_operations *security_ops;
93341 -
93342 /* SECMARK reference count */
93343 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
93344
93345 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
93346
93347 #endif
93348
93349 -static struct security_operations selinux_ops = {
93350 +static struct security_operations selinux_ops __read_only = {
93351 .name = "selinux",
93352
93353 .ptrace_access_check = selinux_ptrace_access_check,
93354 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
93355 index 65f67cb..3f141ef 100644
93356 --- a/security/selinux/include/xfrm.h
93357 +++ b/security/selinux/include/xfrm.h
93358 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
93359
93360 static inline void selinux_xfrm_notify_policyload(void)
93361 {
93362 - atomic_inc(&flow_cache_genid);
93363 + atomic_inc_unchecked(&flow_cache_genid);
93364 rt_genid_bump(&init_net);
93365 }
93366 #else
93367 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
93368 index 38be92c..21f49ee 100644
93369 --- a/security/smack/smack_lsm.c
93370 +++ b/security/smack/smack_lsm.c
93371 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
93372 return 0;
93373 }
93374
93375 -struct security_operations smack_ops = {
93376 +struct security_operations smack_ops __read_only = {
93377 .name = "smack",
93378
93379 .ptrace_access_check = smack_ptrace_access_check,
93380 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
93381 index 390c646..f2f8db3 100644
93382 --- a/security/tomoyo/mount.c
93383 +++ b/security/tomoyo/mount.c
93384 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
93385 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
93386 need_dev = -1; /* dev_name is a directory */
93387 } else {
93388 + if (!capable(CAP_SYS_ADMIN)) {
93389 + error = -EPERM;
93390 + goto out;
93391 + }
93392 fstype = get_fs_type(type);
93393 if (!fstype) {
93394 error = -ENODEV;
93395 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
93396 index a2ee362..5754f34 100644
93397 --- a/security/tomoyo/tomoyo.c
93398 +++ b/security/tomoyo/tomoyo.c
93399 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
93400 * tomoyo_security_ops is a "struct security_operations" which is used for
93401 * registering TOMOYO.
93402 */
93403 -static struct security_operations tomoyo_security_ops = {
93404 +static struct security_operations tomoyo_security_ops __read_only = {
93405 .name = "tomoyo",
93406 .cred_alloc_blank = tomoyo_cred_alloc_blank,
93407 .cred_prepare = tomoyo_cred_prepare,
93408 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
93409 index 20ef514..4182bed 100644
93410 --- a/security/yama/Kconfig
93411 +++ b/security/yama/Kconfig
93412 @@ -1,6 +1,6 @@
93413 config SECURITY_YAMA
93414 bool "Yama support"
93415 - depends on SECURITY
93416 + depends on SECURITY && !GRKERNSEC
93417 select SECURITYFS
93418 select SECURITY_PATH
93419 default n
93420 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
93421 index 23414b9..f8c115e 100644
93422 --- a/security/yama/yama_lsm.c
93423 +++ b/security/yama/yama_lsm.c
93424 @@ -347,10 +347,8 @@ int yama_ptrace_traceme(struct task_struct *parent)
93425 /* Only disallow PTRACE_TRACEME on more aggressive settings. */
93426 switch (ptrace_scope) {
93427 case YAMA_SCOPE_CAPABILITY:
93428 - rcu_read_lock();
93429 - if (!ns_capable(__task_cred(parent)->user_ns, CAP_SYS_PTRACE))
93430 + if (!has_ns_capability(parent, current_user_ns(), CAP_SYS_PTRACE))
93431 rc = -EPERM;
93432 - rcu_read_unlock();
93433 break;
93434 case YAMA_SCOPE_NO_ATTACH:
93435 rc = -EPERM;
93436 @@ -367,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
93437 }
93438
93439 #ifndef CONFIG_SECURITY_YAMA_STACKED
93440 -static struct security_operations yama_ops = {
93441 +static struct security_operations yama_ops __read_only = {
93442 .name = "yama",
93443
93444 .ptrace_access_check = yama_ptrace_access_check,
93445 @@ -378,28 +376,24 @@ static struct security_operations yama_ops = {
93446 #endif
93447
93448 #ifdef CONFIG_SYSCTL
93449 +static int zero __read_only;
93450 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
93451 +
93452 static int yama_dointvec_minmax(struct ctl_table *table, int write,
93453 void __user *buffer, size_t *lenp, loff_t *ppos)
93454 {
93455 - int rc;
93456 + ctl_table_no_const yama_table;
93457
93458 if (write && !capable(CAP_SYS_PTRACE))
93459 return -EPERM;
93460
93461 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
93462 - if (rc)
93463 - return rc;
93464 -
93465 + yama_table = *table;
93466 /* Lock the max value if it ever gets set. */
93467 - if (write && *(int *)table->data == *(int *)table->extra2)
93468 - table->extra1 = table->extra2;
93469 -
93470 - return rc;
93471 + if (ptrace_scope == max_scope)
93472 + yama_table.extra1 = &max_scope;
93473 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
93474 }
93475
93476 -static int zero;
93477 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
93478 -
93479 struct ctl_path yama_sysctl_path[] = {
93480 { .procname = "kernel", },
93481 { .procname = "yama", },
93482 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
93483 index 4cedc69..e59d8a3 100644
93484 --- a/sound/aoa/codecs/onyx.c
93485 +++ b/sound/aoa/codecs/onyx.c
93486 @@ -54,7 +54,7 @@ struct onyx {
93487 spdif_locked:1,
93488 analog_locked:1,
93489 original_mute:2;
93490 - int open_count;
93491 + local_t open_count;
93492 struct codec_info *codec_info;
93493
93494 /* mutex serializes concurrent access to the device
93495 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
93496 struct onyx *onyx = cii->codec_data;
93497
93498 mutex_lock(&onyx->mutex);
93499 - onyx->open_count++;
93500 + local_inc(&onyx->open_count);
93501 mutex_unlock(&onyx->mutex);
93502
93503 return 0;
93504 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
93505 struct onyx *onyx = cii->codec_data;
93506
93507 mutex_lock(&onyx->mutex);
93508 - onyx->open_count--;
93509 - if (!onyx->open_count)
93510 + if (local_dec_and_test(&onyx->open_count))
93511 onyx->spdif_locked = onyx->analog_locked = 0;
93512 mutex_unlock(&onyx->mutex);
93513
93514 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
93515 index ffd2025..df062c9 100644
93516 --- a/sound/aoa/codecs/onyx.h
93517 +++ b/sound/aoa/codecs/onyx.h
93518 @@ -11,6 +11,7 @@
93519 #include <linux/i2c.h>
93520 #include <asm/pmac_low_i2c.h>
93521 #include <asm/prom.h>
93522 +#include <asm/local.h>
93523
93524 /* PCM3052 register definitions */
93525
93526 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
93527 index 4c1cc51..16040040 100644
93528 --- a/sound/core/oss/pcm_oss.c
93529 +++ b/sound/core/oss/pcm_oss.c
93530 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
93531 if (in_kernel) {
93532 mm_segment_t fs;
93533 fs = snd_enter_user();
93534 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93535 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93536 snd_leave_user(fs);
93537 } else {
93538 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93539 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93540 }
93541 if (ret != -EPIPE && ret != -ESTRPIPE)
93542 break;
93543 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
93544 if (in_kernel) {
93545 mm_segment_t fs;
93546 fs = snd_enter_user();
93547 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93548 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93549 snd_leave_user(fs);
93550 } else {
93551 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93552 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93553 }
93554 if (ret == -EPIPE) {
93555 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
93556 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
93557 struct snd_pcm_plugin_channel *channels;
93558 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
93559 if (!in_kernel) {
93560 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
93561 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
93562 return -EFAULT;
93563 buf = runtime->oss.buffer;
93564 }
93565 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
93566 }
93567 } else {
93568 tmp = snd_pcm_oss_write2(substream,
93569 - (const char __force *)buf,
93570 + (const char __force_kernel *)buf,
93571 runtime->oss.period_bytes, 0);
93572 if (tmp <= 0)
93573 goto err;
93574 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
93575 struct snd_pcm_runtime *runtime = substream->runtime;
93576 snd_pcm_sframes_t frames, frames1;
93577 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
93578 - char __user *final_dst = (char __force __user *)buf;
93579 + char __user *final_dst = (char __force_user *)buf;
93580 if (runtime->oss.plugin_first) {
93581 struct snd_pcm_plugin_channel *channels;
93582 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
93583 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
93584 xfer += tmp;
93585 runtime->oss.buffer_used -= tmp;
93586 } else {
93587 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
93588 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
93589 runtime->oss.period_bytes, 0);
93590 if (tmp <= 0)
93591 goto err;
93592 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
93593 size1);
93594 size1 /= runtime->channels; /* frames */
93595 fs = snd_enter_user();
93596 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
93597 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
93598 snd_leave_user(fs);
93599 }
93600 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
93601 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
93602 index af49721..e85058e 100644
93603 --- a/sound/core/pcm_compat.c
93604 +++ b/sound/core/pcm_compat.c
93605 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
93606 int err;
93607
93608 fs = snd_enter_user();
93609 - err = snd_pcm_delay(substream, &delay);
93610 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
93611 snd_leave_user(fs);
93612 if (err < 0)
93613 return err;
93614 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
93615 index f4aaf5a..3b04e3b 100644
93616 --- a/sound/core/pcm_native.c
93617 +++ b/sound/core/pcm_native.c
93618 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
93619 switch (substream->stream) {
93620 case SNDRV_PCM_STREAM_PLAYBACK:
93621 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
93622 - (void __user *)arg);
93623 + (void __force_user *)arg);
93624 break;
93625 case SNDRV_PCM_STREAM_CAPTURE:
93626 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
93627 - (void __user *)arg);
93628 + (void __force_user *)arg);
93629 break;
93630 default:
93631 result = -EINVAL;
93632 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
93633 index 040c60e..989a19a 100644
93634 --- a/sound/core/seq/seq_device.c
93635 +++ b/sound/core/seq/seq_device.c
93636 @@ -64,7 +64,7 @@ struct ops_list {
93637 int argsize; /* argument size */
93638
93639 /* operators */
93640 - struct snd_seq_dev_ops ops;
93641 + struct snd_seq_dev_ops *ops;
93642
93643 /* registered devices */
93644 struct list_head dev_list; /* list of devices */
93645 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
93646
93647 mutex_lock(&ops->reg_mutex);
93648 /* copy driver operators */
93649 - ops->ops = *entry;
93650 + ops->ops = entry;
93651 ops->driver |= DRIVER_LOADED;
93652 ops->argsize = argsize;
93653
93654 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
93655 dev->name, ops->id, ops->argsize, dev->argsize);
93656 return -EINVAL;
93657 }
93658 - if (ops->ops.init_device(dev) >= 0) {
93659 + if (ops->ops->init_device(dev) >= 0) {
93660 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
93661 ops->num_init_devices++;
93662 } else {
93663 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
93664 dev->name, ops->id, ops->argsize, dev->argsize);
93665 return -EINVAL;
93666 }
93667 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
93668 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
93669 dev->status = SNDRV_SEQ_DEVICE_FREE;
93670 dev->driver_data = NULL;
93671 ops->num_init_devices--;
93672 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
93673 index 4e0dd22..7a1f32c 100644
93674 --- a/sound/drivers/mts64.c
93675 +++ b/sound/drivers/mts64.c
93676 @@ -29,6 +29,7 @@
93677 #include <sound/initval.h>
93678 #include <sound/rawmidi.h>
93679 #include <sound/control.h>
93680 +#include <asm/local.h>
93681
93682 #define CARD_NAME "Miditerminal 4140"
93683 #define DRIVER_NAME "MTS64"
93684 @@ -67,7 +68,7 @@ struct mts64 {
93685 struct pardevice *pardev;
93686 int pardev_claimed;
93687
93688 - int open_count;
93689 + local_t open_count;
93690 int current_midi_output_port;
93691 int current_midi_input_port;
93692 u8 mode[MTS64_NUM_INPUT_PORTS];
93693 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93694 {
93695 struct mts64 *mts = substream->rmidi->private_data;
93696
93697 - if (mts->open_count == 0) {
93698 + if (local_read(&mts->open_count) == 0) {
93699 /* We don't need a spinlock here, because this is just called
93700 if the device has not been opened before.
93701 So there aren't any IRQs from the device */
93702 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93703
93704 msleep(50);
93705 }
93706 - ++(mts->open_count);
93707 + local_inc(&mts->open_count);
93708
93709 return 0;
93710 }
93711 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93712 struct mts64 *mts = substream->rmidi->private_data;
93713 unsigned long flags;
93714
93715 - --(mts->open_count);
93716 - if (mts->open_count == 0) {
93717 + if (local_dec_return(&mts->open_count) == 0) {
93718 /* We need the spinlock_irqsave here because we can still
93719 have IRQs at this point */
93720 spin_lock_irqsave(&mts->lock, flags);
93721 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93722
93723 msleep(500);
93724
93725 - } else if (mts->open_count < 0)
93726 - mts->open_count = 0;
93727 + } else if (local_read(&mts->open_count) < 0)
93728 + local_set(&mts->open_count, 0);
93729
93730 return 0;
93731 }
93732 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93733 index b953fb4..1999c01 100644
93734 --- a/sound/drivers/opl4/opl4_lib.c
93735 +++ b/sound/drivers/opl4/opl4_lib.c
93736 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93737 MODULE_DESCRIPTION("OPL4 driver");
93738 MODULE_LICENSE("GPL");
93739
93740 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93741 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93742 {
93743 int timeout = 10;
93744 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93745 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93746 index 991018d..8984740 100644
93747 --- a/sound/drivers/portman2x4.c
93748 +++ b/sound/drivers/portman2x4.c
93749 @@ -48,6 +48,7 @@
93750 #include <sound/initval.h>
93751 #include <sound/rawmidi.h>
93752 #include <sound/control.h>
93753 +#include <asm/local.h>
93754
93755 #define CARD_NAME "Portman 2x4"
93756 #define DRIVER_NAME "portman"
93757 @@ -85,7 +86,7 @@ struct portman {
93758 struct pardevice *pardev;
93759 int pardev_claimed;
93760
93761 - int open_count;
93762 + local_t open_count;
93763 int mode[PORTMAN_NUM_INPUT_PORTS];
93764 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93765 };
93766 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93767 index ea995af..f1bfa37 100644
93768 --- a/sound/firewire/amdtp.c
93769 +++ b/sound/firewire/amdtp.c
93770 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93771 ptr = s->pcm_buffer_pointer + data_blocks;
93772 if (ptr >= pcm->runtime->buffer_size)
93773 ptr -= pcm->runtime->buffer_size;
93774 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93775 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93776
93777 s->pcm_period_pointer += data_blocks;
93778 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93779 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93780 */
93781 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93782 {
93783 - ACCESS_ONCE(s->source_node_id_field) =
93784 + ACCESS_ONCE_RW(s->source_node_id_field) =
93785 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93786 }
93787 EXPORT_SYMBOL(amdtp_out_stream_update);
93788 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93789 index b680c5e..061b7a0 100644
93790 --- a/sound/firewire/amdtp.h
93791 +++ b/sound/firewire/amdtp.h
93792 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93793 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93794 struct snd_pcm_substream *pcm)
93795 {
93796 - ACCESS_ONCE(s->pcm) = pcm;
93797 + ACCESS_ONCE_RW(s->pcm) = pcm;
93798 }
93799
93800 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93801 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93802 index d428ffe..751ef78 100644
93803 --- a/sound/firewire/isight.c
93804 +++ b/sound/firewire/isight.c
93805 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93806 ptr += count;
93807 if (ptr >= runtime->buffer_size)
93808 ptr -= runtime->buffer_size;
93809 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93810 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93811
93812 isight->period_counter += count;
93813 if (isight->period_counter >= runtime->period_size) {
93814 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93815 if (err < 0)
93816 return err;
93817
93818 - ACCESS_ONCE(isight->pcm_active) = true;
93819 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93820
93821 return 0;
93822 }
93823 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93824 {
93825 struct isight *isight = substream->private_data;
93826
93827 - ACCESS_ONCE(isight->pcm_active) = false;
93828 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93829
93830 mutex_lock(&isight->mutex);
93831 isight_stop_streaming(isight);
93832 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93833
93834 switch (cmd) {
93835 case SNDRV_PCM_TRIGGER_START:
93836 - ACCESS_ONCE(isight->pcm_running) = true;
93837 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93838 break;
93839 case SNDRV_PCM_TRIGGER_STOP:
93840 - ACCESS_ONCE(isight->pcm_running) = false;
93841 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93842 break;
93843 default:
93844 return -EINVAL;
93845 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93846 index 844a555..985ab83 100644
93847 --- a/sound/firewire/scs1x.c
93848 +++ b/sound/firewire/scs1x.c
93849 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93850 {
93851 struct scs *scs = stream->rmidi->private_data;
93852
93853 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93854 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93855 if (up) {
93856 scs->output_idle = false;
93857 tasklet_schedule(&scs->tasklet);
93858 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93859 {
93860 struct scs *scs = stream->rmidi->private_data;
93861
93862 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93863 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93864 }
93865
93866 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93867 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93868
93869 snd_card_disconnect(scs->card);
93870
93871 - ACCESS_ONCE(scs->output) = NULL;
93872 - ACCESS_ONCE(scs->input) = NULL;
93873 + ACCESS_ONCE_RW(scs->output) = NULL;
93874 + ACCESS_ONCE_RW(scs->input) = NULL;
93875
93876 wait_event(scs->idle_wait, scs->output_idle);
93877
93878 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93879 index 048439a..3be9f6f 100644
93880 --- a/sound/oss/sb_audio.c
93881 +++ b/sound/oss/sb_audio.c
93882 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93883 buf16 = (signed short *)(localbuf + localoffs);
93884 while (c)
93885 {
93886 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93887 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93888 if (copy_from_user(lbuf8,
93889 userbuf+useroffs + p,
93890 locallen))
93891 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93892 index 7d8803a..559f8d0 100644
93893 --- a/sound/oss/swarm_cs4297a.c
93894 +++ b/sound/oss/swarm_cs4297a.c
93895 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93896 {
93897 struct cs4297a_state *s;
93898 u32 pwr, id;
93899 - mm_segment_t fs;
93900 int rval;
93901 #ifndef CONFIG_BCM_CS4297A_CSWARM
93902 u64 cfg;
93903 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93904 if (!rval) {
93905 char *sb1250_duart_present;
93906
93907 +#if 0
93908 + mm_segment_t fs;
93909 fs = get_fs();
93910 set_fs(KERNEL_DS);
93911 -#if 0
93912 val = SOUND_MASK_LINE;
93913 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93914 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93915 val = initvol[i].vol;
93916 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93917 }
93918 + set_fs(fs);
93919 // cs4297a_write_ac97(s, 0x18, 0x0808);
93920 #else
93921 // cs4297a_write_ac97(s, 0x5e, 0x180);
93922 cs4297a_write_ac97(s, 0x02, 0x0808);
93923 cs4297a_write_ac97(s, 0x18, 0x0808);
93924 #endif
93925 - set_fs(fs);
93926
93927 list_add(&s->list, &cs4297a_devs);
93928
93929 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93930 index 4631a23..001ae57 100644
93931 --- a/sound/pci/ymfpci/ymfpci.h
93932 +++ b/sound/pci/ymfpci/ymfpci.h
93933 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93934 spinlock_t reg_lock;
93935 spinlock_t voice_lock;
93936 wait_queue_head_t interrupt_sleep;
93937 - atomic_t interrupt_sleep_count;
93938 + atomic_unchecked_t interrupt_sleep_count;
93939 struct snd_info_entry *proc_entry;
93940 const struct firmware *dsp_microcode;
93941 const struct firmware *controller_microcode;
93942 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93943 index 22056c5..25d3244 100644
93944 --- a/sound/pci/ymfpci/ymfpci_main.c
93945 +++ b/sound/pci/ymfpci/ymfpci_main.c
93946 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93947 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93948 break;
93949 }
93950 - if (atomic_read(&chip->interrupt_sleep_count)) {
93951 - atomic_set(&chip->interrupt_sleep_count, 0);
93952 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93953 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93954 wake_up(&chip->interrupt_sleep);
93955 }
93956 __end:
93957 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93958 continue;
93959 init_waitqueue_entry(&wait, current);
93960 add_wait_queue(&chip->interrupt_sleep, &wait);
93961 - atomic_inc(&chip->interrupt_sleep_count);
93962 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93963 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93964 remove_wait_queue(&chip->interrupt_sleep, &wait);
93965 }
93966 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93967 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93968 spin_unlock(&chip->reg_lock);
93969
93970 - if (atomic_read(&chip->interrupt_sleep_count)) {
93971 - atomic_set(&chip->interrupt_sleep_count, 0);
93972 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93973 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93974 wake_up(&chip->interrupt_sleep);
93975 }
93976 }
93977 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93978 spin_lock_init(&chip->reg_lock);
93979 spin_lock_init(&chip->voice_lock);
93980 init_waitqueue_head(&chip->interrupt_sleep);
93981 - atomic_set(&chip->interrupt_sleep_count, 0);
93982 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93983 chip->card = card;
93984 chip->pci = pci;
93985 chip->irq = -1;
93986 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93987 new file mode 100644
93988 index 0000000..50f2f2f
93989 --- /dev/null
93990 +++ b/tools/gcc/.gitignore
93991 @@ -0,0 +1 @@
93992 +size_overflow_hash.h
93993 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93994 new file mode 100644
93995 index 0000000..144dbee
93996 --- /dev/null
93997 +++ b/tools/gcc/Makefile
93998 @@ -0,0 +1,45 @@
93999 +#CC := gcc
94000 +#PLUGIN_SOURCE_FILES := pax_plugin.c
94001 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
94002 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
94003 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
94004 +
94005 +ifeq ($(PLUGINCC),$(HOSTCC))
94006 +HOSTLIBS := hostlibs
94007 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
94008 +else
94009 +HOSTLIBS := hostcxxlibs
94010 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
94011 +endif
94012 +
94013 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
94014 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
94015 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
94016 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
94017 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
94018 +$(HOSTLIBS)-y += colorize_plugin.so
94019 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
94020 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
94021 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
94022 +
94023 +always := $($(HOSTLIBS)-y)
94024 +
94025 +constify_plugin-objs := constify_plugin.o
94026 +stackleak_plugin-objs := stackleak_plugin.o
94027 +kallocstat_plugin-objs := kallocstat_plugin.o
94028 +kernexec_plugin-objs := kernexec_plugin.o
94029 +checker_plugin-objs := checker_plugin.o
94030 +colorize_plugin-objs := colorize_plugin.o
94031 +size_overflow_plugin-objs := size_overflow_plugin.o
94032 +latent_entropy_plugin-objs := latent_entropy_plugin.o
94033 +structleak_plugin-objs := structleak_plugin.o
94034 +
94035 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
94036 +
94037 +quiet_cmd_build_size_overflow_hash = GENHASH $@
94038 + cmd_build_size_overflow_hash = \
94039 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
94040 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
94041 + $(call if_changed,build_size_overflow_hash)
94042 +
94043 +targets += size_overflow_hash.h
94044 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
94045 new file mode 100644
94046 index 0000000..d41b5af
94047 --- /dev/null
94048 +++ b/tools/gcc/checker_plugin.c
94049 @@ -0,0 +1,171 @@
94050 +/*
94051 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
94052 + * Licensed under the GPL v2
94053 + *
94054 + * Note: the choice of the license means that the compilation process is
94055 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94056 + * but for the kernel it doesn't matter since it doesn't link against
94057 + * any of the gcc libraries
94058 + *
94059 + * gcc plugin to implement various sparse (source code checker) features
94060 + *
94061 + * TODO:
94062 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
94063 + *
94064 + * BUGS:
94065 + * - none known
94066 + */
94067 +#include "gcc-plugin.h"
94068 +#include "config.h"
94069 +#include "system.h"
94070 +#include "coretypes.h"
94071 +#include "tree.h"
94072 +#include "tree-pass.h"
94073 +#include "flags.h"
94074 +#include "intl.h"
94075 +#include "toplev.h"
94076 +#include "plugin.h"
94077 +//#include "expr.h" where are you...
94078 +#include "diagnostic.h"
94079 +#include "plugin-version.h"
94080 +#include "tm.h"
94081 +#include "function.h"
94082 +#include "basic-block.h"
94083 +#include "gimple.h"
94084 +#include "rtl.h"
94085 +#include "emit-rtl.h"
94086 +#include "tree-flow.h"
94087 +#include "target.h"
94088 +
94089 +extern void c_register_addr_space (const char *str, addr_space_t as);
94090 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
94091 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
94092 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
94093 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
94094 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
94095 +
94096 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94097 +extern rtx emit_move_insn(rtx x, rtx y);
94098 +
94099 +int plugin_is_GPL_compatible;
94100 +
94101 +static struct plugin_info checker_plugin_info = {
94102 + .version = "201111150100",
94103 +};
94104 +
94105 +#define ADDR_SPACE_KERNEL 0
94106 +#define ADDR_SPACE_FORCE_KERNEL 1
94107 +#define ADDR_SPACE_USER 2
94108 +#define ADDR_SPACE_FORCE_USER 3
94109 +#define ADDR_SPACE_IOMEM 0
94110 +#define ADDR_SPACE_FORCE_IOMEM 0
94111 +#define ADDR_SPACE_PERCPU 0
94112 +#define ADDR_SPACE_FORCE_PERCPU 0
94113 +#define ADDR_SPACE_RCU 0
94114 +#define ADDR_SPACE_FORCE_RCU 0
94115 +
94116 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
94117 +{
94118 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
94119 +}
94120 +
94121 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
94122 +{
94123 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
94124 +}
94125 +
94126 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
94127 +{
94128 + return default_addr_space_valid_pointer_mode(mode, as);
94129 +}
94130 +
94131 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
94132 +{
94133 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
94134 +}
94135 +
94136 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
94137 +{
94138 + return default_addr_space_legitimize_address(x, oldx, mode, as);
94139 +}
94140 +
94141 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
94142 +{
94143 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
94144 + return true;
94145 +
94146 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
94147 + return true;
94148 +
94149 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
94150 + return true;
94151 +
94152 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
94153 + return true;
94154 +
94155 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
94156 + return true;
94157 +
94158 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
94159 + return true;
94160 +
94161 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
94162 + return true;
94163 +
94164 + return subset == superset;
94165 +}
94166 +
94167 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
94168 +{
94169 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
94170 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
94171 +
94172 + return op;
94173 +}
94174 +
94175 +static void register_checker_address_spaces(void *event_data, void *data)
94176 +{
94177 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
94178 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
94179 + c_register_addr_space("__user", ADDR_SPACE_USER);
94180 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
94181 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
94182 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
94183 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
94184 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
94185 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
94186 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
94187 +
94188 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
94189 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
94190 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
94191 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
94192 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
94193 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
94194 + targetm.addr_space.convert = checker_addr_space_convert;
94195 +}
94196 +
94197 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94198 +{
94199 + const char * const plugin_name = plugin_info->base_name;
94200 + const int argc = plugin_info->argc;
94201 + const struct plugin_argument * const argv = plugin_info->argv;
94202 + int i;
94203 +
94204 + if (!plugin_default_version_check(version, &gcc_version)) {
94205 + error(G_("incompatible gcc/plugin versions"));
94206 + return 1;
94207 + }
94208 +
94209 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
94210 +
94211 + for (i = 0; i < argc; ++i)
94212 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94213 +
94214 + if (TARGET_64BIT == 0)
94215 + return 0;
94216 +
94217 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
94218 +
94219 + return 0;
94220 +}
94221 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
94222 new file mode 100644
94223 index 0000000..414fe5e
94224 --- /dev/null
94225 +++ b/tools/gcc/colorize_plugin.c
94226 @@ -0,0 +1,151 @@
94227 +/*
94228 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
94229 + * Licensed under the GPL v2
94230 + *
94231 + * Note: the choice of the license means that the compilation process is
94232 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94233 + * but for the kernel it doesn't matter since it doesn't link against
94234 + * any of the gcc libraries
94235 + *
94236 + * gcc plugin to colorize diagnostic output
94237 + *
94238 + */
94239 +
94240 +#include "gcc-plugin.h"
94241 +#include "config.h"
94242 +#include "system.h"
94243 +#include "coretypes.h"
94244 +#include "tree.h"
94245 +#include "tree-pass.h"
94246 +#include "flags.h"
94247 +#include "intl.h"
94248 +#include "toplev.h"
94249 +#include "plugin.h"
94250 +#include "diagnostic.h"
94251 +#include "plugin-version.h"
94252 +#include "tm.h"
94253 +
94254 +int plugin_is_GPL_compatible;
94255 +
94256 +static struct plugin_info colorize_plugin_info = {
94257 + .version = "201302112000",
94258 + .help = NULL,
94259 +};
94260 +
94261 +#define GREEN "\033[32m\033[2m"
94262 +#define LIGHTGREEN "\033[32m\033[1m"
94263 +#define YELLOW "\033[33m\033[2m"
94264 +#define LIGHTYELLOW "\033[33m\033[1m"
94265 +#define RED "\033[31m\033[2m"
94266 +#define LIGHTRED "\033[31m\033[1m"
94267 +#define BLUE "\033[34m\033[2m"
94268 +#define LIGHTBLUE "\033[34m\033[1m"
94269 +#define BRIGHT "\033[m\033[1m"
94270 +#define NORMAL "\033[m"
94271 +
94272 +static diagnostic_starter_fn old_starter;
94273 +static diagnostic_finalizer_fn old_finalizer;
94274 +
94275 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94276 +{
94277 + const char *color;
94278 + char *newprefix;
94279 +
94280 + switch (diagnostic->kind) {
94281 + case DK_NOTE:
94282 + color = LIGHTBLUE;
94283 + break;
94284 +
94285 + case DK_PEDWARN:
94286 + case DK_WARNING:
94287 + color = LIGHTYELLOW;
94288 + break;
94289 +
94290 + case DK_ERROR:
94291 + case DK_FATAL:
94292 + case DK_ICE:
94293 + case DK_PERMERROR:
94294 + case DK_SORRY:
94295 + color = LIGHTRED;
94296 + break;
94297 +
94298 + default:
94299 + color = NORMAL;
94300 + }
94301 +
94302 + old_starter(context, diagnostic);
94303 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
94304 + return;
94305 + pp_destroy_prefix(context->printer);
94306 + pp_set_prefix(context->printer, newprefix);
94307 +}
94308 +
94309 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94310 +{
94311 + old_finalizer(context, diagnostic);
94312 +}
94313 +
94314 +static void colorize_arm(void)
94315 +{
94316 + old_starter = diagnostic_starter(global_dc);
94317 + old_finalizer = diagnostic_finalizer(global_dc);
94318 +
94319 + diagnostic_starter(global_dc) = start_colorize;
94320 + diagnostic_finalizer(global_dc) = finalize_colorize;
94321 +}
94322 +
94323 +static unsigned int execute_colorize_rearm(void)
94324 +{
94325 + if (diagnostic_starter(global_dc) == start_colorize)
94326 + return 0;
94327 +
94328 + colorize_arm();
94329 + return 0;
94330 +}
94331 +
94332 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
94333 + .pass = {
94334 + .type = SIMPLE_IPA_PASS,
94335 + .name = "colorize_rearm",
94336 +#if BUILDING_GCC_VERSION >= 4008
94337 + .optinfo_flags = OPTGROUP_NONE,
94338 +#endif
94339 + .gate = NULL,
94340 + .execute = execute_colorize_rearm,
94341 + .sub = NULL,
94342 + .next = NULL,
94343 + .static_pass_number = 0,
94344 + .tv_id = TV_NONE,
94345 + .properties_required = 0,
94346 + .properties_provided = 0,
94347 + .properties_destroyed = 0,
94348 + .todo_flags_start = 0,
94349 + .todo_flags_finish = 0
94350 + }
94351 +};
94352 +
94353 +static void colorize_start_unit(void *gcc_data, void *user_data)
94354 +{
94355 + colorize_arm();
94356 +}
94357 +
94358 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94359 +{
94360 + const char * const plugin_name = plugin_info->base_name;
94361 + struct register_pass_info colorize_rearm_pass_info = {
94362 + .pass = &pass_ipa_colorize_rearm.pass,
94363 + .reference_pass_name = "*free_lang_data",
94364 + .ref_pass_instance_number = 1,
94365 + .pos_op = PASS_POS_INSERT_AFTER
94366 + };
94367 +
94368 + if (!plugin_default_version_check(version, &gcc_version)) {
94369 + error(G_("incompatible gcc/plugin versions"));
94370 + return 1;
94371 + }
94372 +
94373 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
94374 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
94375 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
94376 + return 0;
94377 +}
94378 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
94379 new file mode 100644
94380 index 0000000..bee0acb
94381 --- /dev/null
94382 +++ b/tools/gcc/constify_plugin.c
94383 @@ -0,0 +1,518 @@
94384 +/*
94385 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
94386 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
94387 + * Licensed under the GPL v2, or (at your option) v3
94388 + *
94389 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
94390 + *
94391 + * Homepage:
94392 + * http://www.grsecurity.net/~ephox/const_plugin/
94393 + *
94394 + * Usage:
94395 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
94396 + * $ gcc -fplugin=constify_plugin.so test.c -O2
94397 + */
94398 +
94399 +#include "gcc-plugin.h"
94400 +#include "config.h"
94401 +#include "system.h"
94402 +#include "coretypes.h"
94403 +#include "tree.h"
94404 +#include "tree-pass.h"
94405 +#include "flags.h"
94406 +#include "intl.h"
94407 +#include "toplev.h"
94408 +#include "plugin.h"
94409 +#include "diagnostic.h"
94410 +#include "plugin-version.h"
94411 +#include "tm.h"
94412 +#include "function.h"
94413 +#include "basic-block.h"
94414 +#include "gimple.h"
94415 +#include "rtl.h"
94416 +#include "emit-rtl.h"
94417 +#include "tree-flow.h"
94418 +#include "target.h"
94419 +#include "langhooks.h"
94420 +
94421 +// should come from c-tree.h if only it were installed for gcc 4.5...
94422 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
94423 +
94424 +// unused type flag in all versions 4.5-4.8
94425 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
94426 +
94427 +int plugin_is_GPL_compatible;
94428 +
94429 +static struct plugin_info const_plugin_info = {
94430 + .version = "201303270300",
94431 + .help = "no-constify\tturn off constification\n",
94432 +};
94433 +
94434 +typedef struct {
94435 + bool has_fptr_field;
94436 + bool has_writable_field;
94437 + bool has_do_const_field;
94438 + bool has_no_const_field;
94439 +} constify_info;
94440 +
94441 +static const_tree get_field_type(const_tree field)
94442 +{
94443 + return strip_array_types(TREE_TYPE(field));
94444 +}
94445 +
94446 +static bool is_fptr(const_tree field)
94447 +{
94448 + const_tree ptr = get_field_type(field);
94449 +
94450 + if (TREE_CODE(ptr) != POINTER_TYPE)
94451 + return false;
94452 +
94453 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
94454 +}
94455 +
94456 +/*
94457 + * determine whether the given structure type meets the requirements for automatic constification,
94458 + * including the constification attributes on nested structure types
94459 + */
94460 +static void constifiable(const_tree node, constify_info *cinfo)
94461 +{
94462 + const_tree field;
94463 +
94464 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94465 +
94466 + // e.g., pointer to structure fields while still constructing the structure type
94467 + if (TYPE_FIELDS(node) == NULL_TREE)
94468 + return;
94469 +
94470 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
94471 + const_tree type = get_field_type(field);
94472 + enum tree_code code = TREE_CODE(type);
94473 +
94474 + if (node == type)
94475 + continue;
94476 +
94477 + if (is_fptr(field))
94478 + cinfo->has_fptr_field = true;
94479 + else if (!TREE_READONLY(field))
94480 + cinfo->has_writable_field = true;
94481 +
94482 + if (code == RECORD_TYPE || code == UNION_TYPE) {
94483 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94484 + cinfo->has_do_const_field = true;
94485 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
94486 + cinfo->has_no_const_field = true;
94487 + else
94488 + constifiable(type, cinfo);
94489 + }
94490 + }
94491 +}
94492 +
94493 +static bool constified(const_tree node)
94494 +{
94495 + constify_info cinfo = {
94496 + .has_fptr_field = false,
94497 + .has_writable_field = false,
94498 + .has_do_const_field = false,
94499 + .has_no_const_field = false
94500 + };
94501 +
94502 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94503 +
94504 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
94505 + gcc_assert(!TYPE_READONLY(node));
94506 + return false;
94507 + }
94508 +
94509 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
94510 + gcc_assert(TYPE_READONLY(node));
94511 + return true;
94512 + }
94513 +
94514 + constifiable(node, &cinfo);
94515 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
94516 + return false;
94517 +
94518 + return TYPE_READONLY(node);
94519 +}
94520 +
94521 +static void deconstify_tree(tree node);
94522 +
94523 +static void deconstify_type(tree type)
94524 +{
94525 + tree field;
94526 +
94527 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
94528 +
94529 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
94530 + const_tree fieldtype = get_field_type(field);
94531 +
94532 + // special case handling of simple ptr-to-same-array-type members
94533 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
94534 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
94535 +
94536 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
94537 + continue;
94538 + if (TREE_TYPE(TREE_TYPE(field)) == type)
94539 + continue;
94540 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
94541 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
94542 + TREE_TYPE(TREE_TYPE(field)) = type;
94543 + }
94544 + continue;
94545 + }
94546 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
94547 + continue;
94548 + if (!constified(fieldtype))
94549 + continue;
94550 +
94551 + deconstify_tree(field);
94552 + TREE_READONLY(field) = 0;
94553 + }
94554 + TYPE_READONLY(type) = 0;
94555 + C_TYPE_FIELDS_READONLY(type) = 0;
94556 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94557 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
94558 +}
94559 +
94560 +static void deconstify_tree(tree node)
94561 +{
94562 + tree old_type, new_type, field;
94563 +
94564 + old_type = TREE_TYPE(node);
94565 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
94566 + node = TREE_TYPE(node) = copy_node(old_type);
94567 + old_type = TREE_TYPE(old_type);
94568 + }
94569 +
94570 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
94571 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
94572 +
94573 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
94574 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
94575 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
94576 + DECL_FIELD_CONTEXT(field) = new_type;
94577 +
94578 + deconstify_type(new_type);
94579 +
94580 + TREE_TYPE(node) = new_type;
94581 +}
94582 +
94583 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94584 +{
94585 + tree type;
94586 + constify_info cinfo = {
94587 + .has_fptr_field = false,
94588 + .has_writable_field = false,
94589 + .has_do_const_field = false,
94590 + .has_no_const_field = false
94591 + };
94592 +
94593 + *no_add_attrs = true;
94594 + if (TREE_CODE(*node) == FUNCTION_DECL) {
94595 + error("%qE attribute does not apply to functions", name);
94596 + return NULL_TREE;
94597 + }
94598 +
94599 + if (TREE_CODE(*node) == PARM_DECL) {
94600 + error("%qE attribute does not apply to function parameters", name);
94601 + return NULL_TREE;
94602 + }
94603 +
94604 + if (TREE_CODE(*node) == VAR_DECL) {
94605 + error("%qE attribute does not apply to variables", name);
94606 + return NULL_TREE;
94607 + }
94608 +
94609 + if (TYPE_P(*node)) {
94610 + *no_add_attrs = false;
94611 + type = *node;
94612 + } else {
94613 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
94614 + type = TREE_TYPE(*node);
94615 + }
94616 +
94617 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
94618 + error("%qE attribute applies to struct and union types only", name);
94619 + return NULL_TREE;
94620 + }
94621 +
94622 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
94623 + error("%qE attribute is already applied to the type", name);
94624 + return NULL_TREE;
94625 + }
94626 +
94627 + if (TYPE_P(*node)) {
94628 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94629 + error("%qE attribute is incompatible with 'do_const'", name);
94630 + return NULL_TREE;
94631 + }
94632 +
94633 + constifiable(type, &cinfo);
94634 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94635 + deconstify_tree(*node);
94636 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
94637 + return NULL_TREE;
94638 + }
94639 +
94640 + error("%qE attribute used on type that is not constified", name);
94641 + return NULL_TREE;
94642 +}
94643 +
94644 +static void constify_type(tree type)
94645 +{
94646 + TYPE_READONLY(type) = 1;
94647 + C_TYPE_FIELDS_READONLY(type) = 1;
94648 + TYPE_CONSTIFY_VISITED(type) = 1;
94649 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
94650 +}
94651 +
94652 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94653 +{
94654 + *no_add_attrs = true;
94655 + if (!TYPE_P(*node)) {
94656 + error("%qE attribute applies to types only", name);
94657 + return NULL_TREE;
94658 + }
94659 +
94660 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94661 + error("%qE attribute applies to struct and union types only", name);
94662 + return NULL_TREE;
94663 + }
94664 +
94665 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94666 + error("%qE attribute is already applied to the type", name);
94667 + return NULL_TREE;
94668 + }
94669 +
94670 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
94671 + error("%qE attribute is incompatible with 'no_const'", name);
94672 + return NULL_TREE;
94673 + }
94674 +
94675 + *no_add_attrs = false;
94676 + return NULL_TREE;
94677 +}
94678 +
94679 +static struct attribute_spec no_const_attr = {
94680 + .name = "no_const",
94681 + .min_length = 0,
94682 + .max_length = 0,
94683 + .decl_required = false,
94684 + .type_required = false,
94685 + .function_type_required = false,
94686 + .handler = handle_no_const_attribute,
94687 +#if BUILDING_GCC_VERSION >= 4007
94688 + .affects_type_identity = true
94689 +#endif
94690 +};
94691 +
94692 +static struct attribute_spec do_const_attr = {
94693 + .name = "do_const",
94694 + .min_length = 0,
94695 + .max_length = 0,
94696 + .decl_required = false,
94697 + .type_required = false,
94698 + .function_type_required = false,
94699 + .handler = handle_do_const_attribute,
94700 +#if BUILDING_GCC_VERSION >= 4007
94701 + .affects_type_identity = true
94702 +#endif
94703 +};
94704 +
94705 +static void register_attributes(void *event_data, void *data)
94706 +{
94707 + register_attribute(&no_const_attr);
94708 + register_attribute(&do_const_attr);
94709 +}
94710 +
94711 +static void finish_type(void *event_data, void *data)
94712 +{
94713 + tree type = (tree)event_data;
94714 + constify_info cinfo = {
94715 + .has_fptr_field = false,
94716 + .has_writable_field = false,
94717 + .has_do_const_field = false,
94718 + .has_no_const_field = false
94719 + };
94720 +
94721 + if (type == NULL_TREE || type == error_mark_node)
94722 + return;
94723 +
94724 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94725 + return;
94726 +
94727 + constifiable(type, &cinfo);
94728 +
94729 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94730 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94731 + return;
94732 + if (cinfo.has_writable_field)
94733 + return;
94734 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94735 + return;
94736 + }
94737 +
94738 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94739 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94740 + deconstify_type(type);
94741 + TYPE_CONSTIFY_VISITED(type) = 1;
94742 + } else
94743 + error("'no_const' attribute used on type that is not constified");
94744 + return;
94745 + }
94746 +
94747 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94748 + constify_type(type);
94749 + return;
94750 + }
94751 +
94752 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94753 + constify_type(type);
94754 + return;
94755 + }
94756 +
94757 + deconstify_type(type);
94758 + TYPE_CONSTIFY_VISITED(type) = 1;
94759 +}
94760 +
94761 +static unsigned int check_local_variables(void)
94762 +{
94763 + unsigned int ret = 0;
94764 + tree var;
94765 +
94766 +#if BUILDING_GCC_VERSION == 4005
94767 + tree vars;
94768 +#else
94769 + unsigned int i;
94770 +#endif
94771 +
94772 +#if BUILDING_GCC_VERSION == 4005
94773 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94774 + var = TREE_VALUE(vars);
94775 +#else
94776 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94777 +#endif
94778 + tree type = TREE_TYPE(var);
94779 +
94780 + gcc_assert(DECL_P(var));
94781 + if (is_global_var(var))
94782 + continue;
94783 +
94784 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94785 + continue;
94786 +
94787 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94788 + continue;
94789 +
94790 + if (!TYPE_CONSTIFY_VISITED(type))
94791 + continue;
94792 +
94793 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94794 + ret = 1;
94795 + }
94796 + return ret;
94797 +}
94798 +
94799 +static struct gimple_opt_pass pass_local_variable = {
94800 + {
94801 + .type = GIMPLE_PASS,
94802 + .name = "check_local_variables",
94803 +#if BUILDING_GCC_VERSION >= 4008
94804 + .optinfo_flags = OPTGROUP_NONE,
94805 +#endif
94806 + .gate = NULL,
94807 + .execute = check_local_variables,
94808 + .sub = NULL,
94809 + .next = NULL,
94810 + .static_pass_number = 0,
94811 + .tv_id = TV_NONE,
94812 + .properties_required = 0,
94813 + .properties_provided = 0,
94814 + .properties_destroyed = 0,
94815 + .todo_flags_start = 0,
94816 + .todo_flags_finish = 0
94817 + }
94818 +};
94819 +
94820 +static struct {
94821 + const char *name;
94822 + const char *asm_op;
94823 +} sections[] = {
94824 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94825 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94826 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94827 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94828 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94829 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94830 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94831 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94832 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94833 +};
94834 +
94835 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94836 +
94837 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94838 +{
94839 + size_t i;
94840 +
94841 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94842 + if (!strcmp(sections[i].name, name))
94843 + return 0;
94844 + return old_section_type_flags(decl, name, reloc);
94845 +}
94846 +
94847 +static void constify_start_unit(void *gcc_data, void *user_data)
94848 +{
94849 +// size_t i;
94850 +
94851 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94852 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94853 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94854 +
94855 + old_section_type_flags = targetm.section_type_flags;
94856 + targetm.section_type_flags = constify_section_type_flags;
94857 +}
94858 +
94859 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94860 +{
94861 + const char * const plugin_name = plugin_info->base_name;
94862 + const int argc = plugin_info->argc;
94863 + const struct plugin_argument * const argv = plugin_info->argv;
94864 + int i;
94865 + bool constify = true;
94866 +
94867 + struct register_pass_info local_variable_pass_info = {
94868 + .pass = &pass_local_variable.pass,
94869 + .reference_pass_name = "ssa",
94870 + .ref_pass_instance_number = 1,
94871 + .pos_op = PASS_POS_INSERT_BEFORE
94872 + };
94873 +
94874 + if (!plugin_default_version_check(version, &gcc_version)) {
94875 + error(G_("incompatible gcc/plugin versions"));
94876 + return 1;
94877 + }
94878 +
94879 + for (i = 0; i < argc; ++i) {
94880 + if (!(strcmp(argv[i].key, "no-constify"))) {
94881 + constify = false;
94882 + continue;
94883 + }
94884 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94885 + }
94886 +
94887 + if (strcmp(lang_hooks.name, "GNU C")) {
94888 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94889 + constify = false;
94890 + }
94891 +
94892 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94893 + if (constify) {
94894 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94895 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94896 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94897 + }
94898 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94899 +
94900 + return 0;
94901 +}
94902 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94903 new file mode 100644
94904 index 0000000..e518932
94905 --- /dev/null
94906 +++ b/tools/gcc/generate_size_overflow_hash.sh
94907 @@ -0,0 +1,94 @@
94908 +#!/bin/bash
94909 +
94910 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94911 +
94912 +header1="size_overflow_hash.h"
94913 +database="size_overflow_hash.data"
94914 +n=65536
94915 +
94916 +usage() {
94917 +cat <<EOF
94918 +usage: $0 options
94919 +OPTIONS:
94920 + -h|--help help
94921 + -o header file
94922 + -d database file
94923 + -n hash array size
94924 +EOF
94925 + return 0
94926 +}
94927 +
94928 +while true
94929 +do
94930 + case "$1" in
94931 + -h|--help) usage && exit 0;;
94932 + -n) n=$2; shift 2;;
94933 + -o) header1="$2"; shift 2;;
94934 + -d) database="$2"; shift 2;;
94935 + --) shift 1; break ;;
94936 + *) break ;;
94937 + esac
94938 +done
94939 +
94940 +create_defines() {
94941 + for i in `seq 0 31`
94942 + do
94943 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94944 + done
94945 + echo >> "$header1"
94946 +}
94947 +
94948 +create_structs() {
94949 + rm -f "$header1"
94950 +
94951 + create_defines
94952 +
94953 + cat "$database" | while read data
94954 + do
94955 + data_array=($data)
94956 + struct_hash_name="${data_array[0]}"
94957 + funcn="${data_array[1]}"
94958 + params="${data_array[2]}"
94959 + next="${data_array[4]}"
94960 +
94961 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94962 +
94963 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94964 + echo -en "\t.param\t= " >> "$header1"
94965 + line=
94966 + for param_num in ${params//-/ };
94967 + do
94968 + line="${line}PARAM"$param_num"|"
94969 + done
94970 +
94971 + echo -e "${line%?},\n};\n" >> "$header1"
94972 + done
94973 +}
94974 +
94975 +create_headers() {
94976 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94977 +}
94978 +
94979 +create_array_elements() {
94980 + index=0
94981 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94982 + do
94983 + data_array=($data)
94984 + i="${data_array[3]}"
94985 + hash="${data_array[0]}"
94986 + while [[ $index -lt $i ]]
94987 + do
94988 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94989 + index=$(($index + 1))
94990 + done
94991 + index=$(($index + 1))
94992 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94993 + done
94994 + echo '};' >> $header1
94995 +}
94996 +
94997 +create_structs
94998 +create_headers
94999 +create_array_elements
95000 +
95001 +exit 0
95002 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
95003 new file mode 100644
95004 index 0000000..568b360
95005 --- /dev/null
95006 +++ b/tools/gcc/kallocstat_plugin.c
95007 @@ -0,0 +1,170 @@
95008 +/*
95009 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95010 + * Licensed under the GPL v2
95011 + *
95012 + * Note: the choice of the license means that the compilation process is
95013 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95014 + * but for the kernel it doesn't matter since it doesn't link against
95015 + * any of the gcc libraries
95016 + *
95017 + * gcc plugin to find the distribution of k*alloc sizes
95018 + *
95019 + * TODO:
95020 + *
95021 + * BUGS:
95022 + * - none known
95023 + */
95024 +#include "gcc-plugin.h"
95025 +#include "config.h"
95026 +#include "system.h"
95027 +#include "coretypes.h"
95028 +#include "tree.h"
95029 +#include "tree-pass.h"
95030 +#include "flags.h"
95031 +#include "intl.h"
95032 +#include "toplev.h"
95033 +#include "plugin.h"
95034 +//#include "expr.h" where are you...
95035 +#include "diagnostic.h"
95036 +#include "plugin-version.h"
95037 +#include "tm.h"
95038 +#include "function.h"
95039 +#include "basic-block.h"
95040 +#include "gimple.h"
95041 +#include "rtl.h"
95042 +#include "emit-rtl.h"
95043 +
95044 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95045 +
95046 +int plugin_is_GPL_compatible;
95047 +
95048 +static const char * const kalloc_functions[] = {
95049 + "__kmalloc",
95050 + "kmalloc",
95051 + "kmalloc_large",
95052 + "kmalloc_node",
95053 + "kmalloc_order",
95054 + "kmalloc_order_trace",
95055 + "kmalloc_slab",
95056 + "kzalloc",
95057 + "kzalloc_node",
95058 +};
95059 +
95060 +static struct plugin_info kallocstat_plugin_info = {
95061 + .version = "201302112000",
95062 +};
95063 +
95064 +static unsigned int execute_kallocstat(void);
95065 +
95066 +static struct gimple_opt_pass kallocstat_pass = {
95067 + .pass = {
95068 + .type = GIMPLE_PASS,
95069 + .name = "kallocstat",
95070 +#if BUILDING_GCC_VERSION >= 4008
95071 + .optinfo_flags = OPTGROUP_NONE,
95072 +#endif
95073 + .gate = NULL,
95074 + .execute = execute_kallocstat,
95075 + .sub = NULL,
95076 + .next = NULL,
95077 + .static_pass_number = 0,
95078 + .tv_id = TV_NONE,
95079 + .properties_required = 0,
95080 + .properties_provided = 0,
95081 + .properties_destroyed = 0,
95082 + .todo_flags_start = 0,
95083 + .todo_flags_finish = 0
95084 + }
95085 +};
95086 +
95087 +static bool is_kalloc(const char *fnname)
95088 +{
95089 + size_t i;
95090 +
95091 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
95092 + if (!strcmp(fnname, kalloc_functions[i]))
95093 + return true;
95094 + return false;
95095 +}
95096 +
95097 +static unsigned int execute_kallocstat(void)
95098 +{
95099 + basic_block bb;
95100 +
95101 + // 1. loop through BBs and GIMPLE statements
95102 + FOR_EACH_BB(bb) {
95103 + gimple_stmt_iterator gsi;
95104 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95105 + // gimple match:
95106 + tree fndecl, size;
95107 + gimple call_stmt;
95108 + const char *fnname;
95109 +
95110 + // is it a call
95111 + call_stmt = gsi_stmt(gsi);
95112 + if (!is_gimple_call(call_stmt))
95113 + continue;
95114 + fndecl = gimple_call_fndecl(call_stmt);
95115 + if (fndecl == NULL_TREE)
95116 + continue;
95117 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
95118 + continue;
95119 +
95120 + // is it a call to k*alloc
95121 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
95122 + if (!is_kalloc(fnname))
95123 + continue;
95124 +
95125 + // is the size arg the result of a simple const assignment
95126 + size = gimple_call_arg(call_stmt, 0);
95127 + while (true) {
95128 + gimple def_stmt;
95129 + expanded_location xloc;
95130 + size_t size_val;
95131 +
95132 + if (TREE_CODE(size) != SSA_NAME)
95133 + break;
95134 + def_stmt = SSA_NAME_DEF_STMT(size);
95135 + if (!def_stmt || !is_gimple_assign(def_stmt))
95136 + break;
95137 + if (gimple_num_ops(def_stmt) != 2)
95138 + break;
95139 + size = gimple_assign_rhs1(def_stmt);
95140 + if (!TREE_CONSTANT(size))
95141 + continue;
95142 + xloc = expand_location(gimple_location(def_stmt));
95143 + if (!xloc.file)
95144 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
95145 + size_val = TREE_INT_CST_LOW(size);
95146 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
95147 + break;
95148 + }
95149 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95150 +//debug_tree(gimple_call_fn(call_stmt));
95151 +//print_node(stderr, "pax", fndecl, 4);
95152 + }
95153 + }
95154 +
95155 + return 0;
95156 +}
95157 +
95158 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95159 +{
95160 + const char * const plugin_name = plugin_info->base_name;
95161 + struct register_pass_info kallocstat_pass_info = {
95162 + .pass = &kallocstat_pass.pass,
95163 + .reference_pass_name = "ssa",
95164 + .ref_pass_instance_number = 1,
95165 + .pos_op = PASS_POS_INSERT_AFTER
95166 + };
95167 +
95168 + if (!plugin_default_version_check(version, &gcc_version)) {
95169 + error(G_("incompatible gcc/plugin versions"));
95170 + return 1;
95171 + }
95172 +
95173 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
95174 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
95175 +
95176 + return 0;
95177 +}
95178 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
95179 new file mode 100644
95180 index 0000000..0408e06
95181 --- /dev/null
95182 +++ b/tools/gcc/kernexec_plugin.c
95183 @@ -0,0 +1,465 @@
95184 +/*
95185 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95186 + * Licensed under the GPL v2
95187 + *
95188 + * Note: the choice of the license means that the compilation process is
95189 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95190 + * but for the kernel it doesn't matter since it doesn't link against
95191 + * any of the gcc libraries
95192 + *
95193 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
95194 + *
95195 + * TODO:
95196 + *
95197 + * BUGS:
95198 + * - none known
95199 + */
95200 +#include "gcc-plugin.h"
95201 +#include "config.h"
95202 +#include "system.h"
95203 +#include "coretypes.h"
95204 +#include "tree.h"
95205 +#include "tree-pass.h"
95206 +#include "flags.h"
95207 +#include "intl.h"
95208 +#include "toplev.h"
95209 +#include "plugin.h"
95210 +//#include "expr.h" where are you...
95211 +#include "diagnostic.h"
95212 +#include "plugin-version.h"
95213 +#include "tm.h"
95214 +#include "function.h"
95215 +#include "basic-block.h"
95216 +#include "gimple.h"
95217 +#include "rtl.h"
95218 +#include "emit-rtl.h"
95219 +#include "tree-flow.h"
95220 +
95221 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95222 +extern rtx emit_move_insn(rtx x, rtx y);
95223 +
95224 +#if BUILDING_GCC_VERSION <= 4006
95225 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
95226 +#endif
95227 +
95228 +#if BUILDING_GCC_VERSION >= 4008
95229 +#define TODO_dump_func 0
95230 +#endif
95231 +
95232 +int plugin_is_GPL_compatible;
95233 +
95234 +static struct plugin_info kernexec_plugin_info = {
95235 + .version = "201302112000",
95236 + .help = "method=[bts|or]\tinstrumentation method\n"
95237 +};
95238 +
95239 +static unsigned int execute_kernexec_reload(void);
95240 +static unsigned int execute_kernexec_fptr(void);
95241 +static unsigned int execute_kernexec_retaddr(void);
95242 +static bool kernexec_cmodel_check(void);
95243 +
95244 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
95245 +static void (*kernexec_instrument_retaddr)(rtx);
95246 +
95247 +static struct gimple_opt_pass kernexec_reload_pass = {
95248 + .pass = {
95249 + .type = GIMPLE_PASS,
95250 + .name = "kernexec_reload",
95251 +#if BUILDING_GCC_VERSION >= 4008
95252 + .optinfo_flags = OPTGROUP_NONE,
95253 +#endif
95254 + .gate = kernexec_cmodel_check,
95255 + .execute = execute_kernexec_reload,
95256 + .sub = NULL,
95257 + .next = NULL,
95258 + .static_pass_number = 0,
95259 + .tv_id = TV_NONE,
95260 + .properties_required = 0,
95261 + .properties_provided = 0,
95262 + .properties_destroyed = 0,
95263 + .todo_flags_start = 0,
95264 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95265 + }
95266 +};
95267 +
95268 +static struct gimple_opt_pass kernexec_fptr_pass = {
95269 + .pass = {
95270 + .type = GIMPLE_PASS,
95271 + .name = "kernexec_fptr",
95272 +#if BUILDING_GCC_VERSION >= 4008
95273 + .optinfo_flags = OPTGROUP_NONE,
95274 +#endif
95275 + .gate = kernexec_cmodel_check,
95276 + .execute = execute_kernexec_fptr,
95277 + .sub = NULL,
95278 + .next = NULL,
95279 + .static_pass_number = 0,
95280 + .tv_id = TV_NONE,
95281 + .properties_required = 0,
95282 + .properties_provided = 0,
95283 + .properties_destroyed = 0,
95284 + .todo_flags_start = 0,
95285 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95286 + }
95287 +};
95288 +
95289 +static struct rtl_opt_pass kernexec_retaddr_pass = {
95290 + .pass = {
95291 + .type = RTL_PASS,
95292 + .name = "kernexec_retaddr",
95293 +#if BUILDING_GCC_VERSION >= 4008
95294 + .optinfo_flags = OPTGROUP_NONE,
95295 +#endif
95296 + .gate = kernexec_cmodel_check,
95297 + .execute = execute_kernexec_retaddr,
95298 + .sub = NULL,
95299 + .next = NULL,
95300 + .static_pass_number = 0,
95301 + .tv_id = TV_NONE,
95302 + .properties_required = 0,
95303 + .properties_provided = 0,
95304 + .properties_destroyed = 0,
95305 + .todo_flags_start = 0,
95306 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
95307 + }
95308 +};
95309 +
95310 +static bool kernexec_cmodel_check(void)
95311 +{
95312 + tree section;
95313 +
95314 + if (ix86_cmodel != CM_KERNEL)
95315 + return false;
95316 +
95317 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
95318 + if (!section || !TREE_VALUE(section))
95319 + return true;
95320 +
95321 + section = TREE_VALUE(TREE_VALUE(section));
95322 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
95323 + return true;
95324 +
95325 + return false;
95326 +}
95327 +
95328 +/*
95329 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
95330 + */
95331 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
95332 +{
95333 + gimple asm_movabs_stmt;
95334 +
95335 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
95336 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
95337 + gimple_asm_set_volatile(asm_movabs_stmt, true);
95338 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
95339 + update_stmt(asm_movabs_stmt);
95340 +}
95341 +
95342 +/*
95343 + * find all asm() stmts that clobber r10 and add a reload of r10
95344 + */
95345 +static unsigned int execute_kernexec_reload(void)
95346 +{
95347 + basic_block bb;
95348 +
95349 + // 1. loop through BBs and GIMPLE statements
95350 + FOR_EACH_BB(bb) {
95351 + gimple_stmt_iterator gsi;
95352 +
95353 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95354 + // gimple match: __asm__ ("" : : : "r10");
95355 + gimple asm_stmt;
95356 + size_t nclobbers;
95357 +
95358 + // is it an asm ...
95359 + asm_stmt = gsi_stmt(gsi);
95360 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
95361 + continue;
95362 +
95363 + // ... clobbering r10
95364 + nclobbers = gimple_asm_nclobbers(asm_stmt);
95365 + while (nclobbers--) {
95366 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
95367 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
95368 + continue;
95369 + kernexec_reload_fptr_mask(&gsi);
95370 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
95371 + break;
95372 + }
95373 + }
95374 + }
95375 +
95376 + return 0;
95377 +}
95378 +
95379 +/*
95380 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
95381 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
95382 + */
95383 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
95384 +{
95385 + gimple assign_intptr, assign_new_fptr, call_stmt;
95386 + tree intptr, old_fptr, new_fptr, kernexec_mask;
95387 +
95388 + call_stmt = gsi_stmt(*gsi);
95389 + old_fptr = gimple_call_fn(call_stmt);
95390 +
95391 + // create temporary unsigned long variable used for bitops and cast fptr to it
95392 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
95393 +#if BUILDING_GCC_VERSION <= 4007
95394 + add_referenced_var(intptr);
95395 + mark_sym_for_renaming(intptr);
95396 +#endif
95397 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
95398 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95399 + update_stmt(assign_intptr);
95400 +
95401 + // apply logical or to temporary unsigned long and bitmask
95402 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
95403 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
95404 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
95405 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95406 + update_stmt(assign_intptr);
95407 +
95408 + // cast temporary unsigned long back to a temporary fptr variable
95409 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
95410 +#if BUILDING_GCC_VERSION <= 4007
95411 + add_referenced_var(new_fptr);
95412 + mark_sym_for_renaming(new_fptr);
95413 +#endif
95414 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
95415 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
95416 + update_stmt(assign_new_fptr);
95417 +
95418 + // replace call stmt fn with the new fptr
95419 + gimple_call_set_fn(call_stmt, new_fptr);
95420 + update_stmt(call_stmt);
95421 +}
95422 +
95423 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
95424 +{
95425 + gimple asm_or_stmt, call_stmt;
95426 + tree old_fptr, new_fptr, input, output;
95427 +#if BUILDING_GCC_VERSION <= 4007
95428 + VEC(tree, gc) *inputs = NULL;
95429 + VEC(tree, gc) *outputs = NULL;
95430 +#else
95431 + vec<tree, va_gc> *inputs = NULL;
95432 + vec<tree, va_gc> *outputs = NULL;
95433 +#endif
95434 +
95435 + call_stmt = gsi_stmt(*gsi);
95436 + old_fptr = gimple_call_fn(call_stmt);
95437 +
95438 + // create temporary fptr variable
95439 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
95440 +#if BUILDING_GCC_VERSION <= 4007
95441 + add_referenced_var(new_fptr);
95442 + mark_sym_for_renaming(new_fptr);
95443 +#endif
95444 +
95445 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
95446 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
95447 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
95448 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
95449 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
95450 +#if BUILDING_GCC_VERSION <= 4007
95451 + VEC_safe_push(tree, gc, inputs, input);
95452 + VEC_safe_push(tree, gc, outputs, output);
95453 +#else
95454 + vec_safe_push(inputs, input);
95455 + vec_safe_push(outputs, output);
95456 +#endif
95457 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
95458 + gimple_asm_set_volatile(asm_or_stmt, true);
95459 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
95460 + update_stmt(asm_or_stmt);
95461 +
95462 + // replace call stmt fn with the new fptr
95463 + gimple_call_set_fn(call_stmt, new_fptr);
95464 + update_stmt(call_stmt);
95465 +}
95466 +
95467 +/*
95468 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
95469 + */
95470 +static unsigned int execute_kernexec_fptr(void)
95471 +{
95472 + basic_block bb;
95473 +
95474 + // 1. loop through BBs and GIMPLE statements
95475 + FOR_EACH_BB(bb) {
95476 + gimple_stmt_iterator gsi;
95477 +
95478 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95479 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
95480 + tree fn;
95481 + gimple call_stmt;
95482 +
95483 + // is it a call ...
95484 + call_stmt = gsi_stmt(gsi);
95485 + if (!is_gimple_call(call_stmt))
95486 + continue;
95487 + fn = gimple_call_fn(call_stmt);
95488 + if (TREE_CODE(fn) == ADDR_EXPR)
95489 + continue;
95490 + if (TREE_CODE(fn) != SSA_NAME)
95491 + gcc_unreachable();
95492 +
95493 + // ... through a function pointer
95494 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
95495 + fn = SSA_NAME_VAR(fn);
95496 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
95497 + debug_tree(fn);
95498 + gcc_unreachable();
95499 + }
95500 + }
95501 + fn = TREE_TYPE(fn);
95502 + if (TREE_CODE(fn) != POINTER_TYPE)
95503 + continue;
95504 + fn = TREE_TYPE(fn);
95505 + if (TREE_CODE(fn) != FUNCTION_TYPE)
95506 + continue;
95507 +
95508 + kernexec_instrument_fptr(&gsi);
95509 +
95510 +//debug_tree(gimple_call_fn(call_stmt));
95511 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95512 + }
95513 + }
95514 +
95515 + return 0;
95516 +}
95517 +
95518 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
95519 +static void kernexec_instrument_retaddr_bts(rtx insn)
95520 +{
95521 + rtx btsq;
95522 + rtvec argvec, constraintvec, labelvec;
95523 + int line;
95524 +
95525 + // create asm volatile("btsq $63,(%%rsp)":::)
95526 + argvec = rtvec_alloc(0);
95527 + constraintvec = rtvec_alloc(0);
95528 + labelvec = rtvec_alloc(0);
95529 + line = expand_location(RTL_LOCATION(insn)).line;
95530 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95531 + MEM_VOLATILE_P(btsq) = 1;
95532 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
95533 + emit_insn_before(btsq, insn);
95534 +}
95535 +
95536 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
95537 +static void kernexec_instrument_retaddr_or(rtx insn)
95538 +{
95539 + rtx orq;
95540 + rtvec argvec, constraintvec, labelvec;
95541 + int line;
95542 +
95543 + // create asm volatile("orq %%r10,(%%rsp)":::)
95544 + argvec = rtvec_alloc(0);
95545 + constraintvec = rtvec_alloc(0);
95546 + labelvec = rtvec_alloc(0);
95547 + line = expand_location(RTL_LOCATION(insn)).line;
95548 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95549 + MEM_VOLATILE_P(orq) = 1;
95550 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
95551 + emit_insn_before(orq, insn);
95552 +}
95553 +
95554 +/*
95555 + * find all asm level function returns and forcibly set the highest bit of the return address
95556 + */
95557 +static unsigned int execute_kernexec_retaddr(void)
95558 +{
95559 + rtx insn;
95560 +
95561 + // 1. find function returns
95562 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
95563 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
95564 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
95565 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
95566 + rtx body;
95567 +
95568 + // is it a retn
95569 + if (!JUMP_P(insn))
95570 + continue;
95571 + body = PATTERN(insn);
95572 + if (GET_CODE(body) == PARALLEL)
95573 + body = XVECEXP(body, 0, 0);
95574 + if (!ANY_RETURN_P(body))
95575 + continue;
95576 + kernexec_instrument_retaddr(insn);
95577 + }
95578 +
95579 +// print_simple_rtl(stderr, get_insns());
95580 +// print_rtl(stderr, get_insns());
95581 +
95582 + return 0;
95583 +}
95584 +
95585 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95586 +{
95587 + const char * const plugin_name = plugin_info->base_name;
95588 + const int argc = plugin_info->argc;
95589 + const struct plugin_argument * const argv = plugin_info->argv;
95590 + int i;
95591 + struct register_pass_info kernexec_reload_pass_info = {
95592 + .pass = &kernexec_reload_pass.pass,
95593 + .reference_pass_name = "ssa",
95594 + .ref_pass_instance_number = 1,
95595 + .pos_op = PASS_POS_INSERT_AFTER
95596 + };
95597 + struct register_pass_info kernexec_fptr_pass_info = {
95598 + .pass = &kernexec_fptr_pass.pass,
95599 + .reference_pass_name = "ssa",
95600 + .ref_pass_instance_number = 1,
95601 + .pos_op = PASS_POS_INSERT_AFTER
95602 + };
95603 + struct register_pass_info kernexec_retaddr_pass_info = {
95604 + .pass = &kernexec_retaddr_pass.pass,
95605 + .reference_pass_name = "pro_and_epilogue",
95606 + .ref_pass_instance_number = 1,
95607 + .pos_op = PASS_POS_INSERT_AFTER
95608 + };
95609 +
95610 + if (!plugin_default_version_check(version, &gcc_version)) {
95611 + error(G_("incompatible gcc/plugin versions"));
95612 + return 1;
95613 + }
95614 +
95615 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
95616 +
95617 + if (TARGET_64BIT == 0)
95618 + return 0;
95619 +
95620 + for (i = 0; i < argc; ++i) {
95621 + if (!strcmp(argv[i].key, "method")) {
95622 + if (!argv[i].value) {
95623 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95624 + continue;
95625 + }
95626 + if (!strcmp(argv[i].value, "bts")) {
95627 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
95628 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
95629 + } else if (!strcmp(argv[i].value, "or")) {
95630 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
95631 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
95632 + fix_register("r10", 1, 1);
95633 + } else
95634 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
95635 + continue;
95636 + }
95637 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95638 + }
95639 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
95640 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
95641 +
95642 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
95643 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
95644 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
95645 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
95646 +
95647 + return 0;
95648 +}
95649 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
95650 new file mode 100644
95651 index 0000000..b5395ba
95652 --- /dev/null
95653 +++ b/tools/gcc/latent_entropy_plugin.c
95654 @@ -0,0 +1,327 @@
95655 +/*
95656 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
95657 + * Licensed under the GPL v2
95658 + *
95659 + * Note: the choice of the license means that the compilation process is
95660 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95661 + * but for the kernel it doesn't matter since it doesn't link against
95662 + * any of the gcc libraries
95663 + *
95664 + * gcc plugin to help generate a little bit of entropy from program state,
95665 + * used during boot in the kernel
95666 + *
95667 + * TODO:
95668 + * - add ipa pass to identify not explicitly marked candidate functions
95669 + * - mix in more program state (function arguments/return values, loop variables, etc)
95670 + * - more instrumentation control via attribute parameters
95671 + *
95672 + * BUGS:
95673 + * - LTO needs -flto-partition=none for now
95674 + */
95675 +#include "gcc-plugin.h"
95676 +#include "config.h"
95677 +#include "system.h"
95678 +#include "coretypes.h"
95679 +#include "tree.h"
95680 +#include "tree-pass.h"
95681 +#include "flags.h"
95682 +#include "intl.h"
95683 +#include "toplev.h"
95684 +#include "plugin.h"
95685 +//#include "expr.h" where are you...
95686 +#include "diagnostic.h"
95687 +#include "plugin-version.h"
95688 +#include "tm.h"
95689 +#include "function.h"
95690 +#include "basic-block.h"
95691 +#include "gimple.h"
95692 +#include "rtl.h"
95693 +#include "emit-rtl.h"
95694 +#include "tree-flow.h"
95695 +#include "langhooks.h"
95696 +
95697 +#if BUILDING_GCC_VERSION >= 4008
95698 +#define TODO_dump_func 0
95699 +#endif
95700 +
95701 +int plugin_is_GPL_compatible;
95702 +
95703 +static tree latent_entropy_decl;
95704 +
95705 +static struct plugin_info latent_entropy_plugin_info = {
95706 + .version = "201303102320",
95707 + .help = NULL
95708 +};
95709 +
95710 +static unsigned int execute_latent_entropy(void);
95711 +static bool gate_latent_entropy(void);
95712 +
95713 +static struct gimple_opt_pass latent_entropy_pass = {
95714 + .pass = {
95715 + .type = GIMPLE_PASS,
95716 + .name = "latent_entropy",
95717 +#if BUILDING_GCC_VERSION >= 4008
95718 + .optinfo_flags = OPTGROUP_NONE,
95719 +#endif
95720 + .gate = gate_latent_entropy,
95721 + .execute = execute_latent_entropy,
95722 + .sub = NULL,
95723 + .next = NULL,
95724 + .static_pass_number = 0,
95725 + .tv_id = TV_NONE,
95726 + .properties_required = PROP_gimple_leh | PROP_cfg,
95727 + .properties_provided = 0,
95728 + .properties_destroyed = 0,
95729 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95730 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95731 + }
95732 +};
95733 +
95734 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95735 +{
95736 + if (TREE_CODE(*node) != FUNCTION_DECL) {
95737 + *no_add_attrs = true;
95738 + error("%qE attribute only applies to functions", name);
95739 + }
95740 + return NULL_TREE;
95741 +}
95742 +
95743 +static struct attribute_spec latent_entropy_attr = {
95744 + .name = "latent_entropy",
95745 + .min_length = 0,
95746 + .max_length = 0,
95747 + .decl_required = true,
95748 + .type_required = false,
95749 + .function_type_required = false,
95750 + .handler = handle_latent_entropy_attribute,
95751 +#if BUILDING_GCC_VERSION >= 4007
95752 + .affects_type_identity = false
95753 +#endif
95754 +};
95755 +
95756 +static void register_attributes(void *event_data, void *data)
95757 +{
95758 + register_attribute(&latent_entropy_attr);
95759 +}
95760 +
95761 +static bool gate_latent_entropy(void)
95762 +{
95763 + tree latent_entropy_attr;
95764 +
95765 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95766 + return latent_entropy_attr != NULL_TREE;
95767 +}
95768 +
95769 +static unsigned HOST_WIDE_INT seed;
95770 +static unsigned HOST_WIDE_INT get_random_const(void)
95771 +{
95772 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95773 + return seed;
95774 +}
95775 +
95776 +static enum tree_code get_op(tree *rhs)
95777 +{
95778 + static enum tree_code op;
95779 + unsigned HOST_WIDE_INT random_const;
95780 +
95781 + random_const = get_random_const();
95782 +
95783 + switch (op) {
95784 + case BIT_XOR_EXPR:
95785 + op = PLUS_EXPR;
95786 + break;
95787 +
95788 + case PLUS_EXPR:
95789 + if (rhs) {
95790 + op = LROTATE_EXPR;
95791 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95792 + break;
95793 + }
95794 +
95795 + case LROTATE_EXPR:
95796 + default:
95797 + op = BIT_XOR_EXPR;
95798 + break;
95799 + }
95800 + if (rhs)
95801 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95802 + return op;
95803 +}
95804 +
95805 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95806 +{
95807 + gimple_stmt_iterator gsi;
95808 + gimple assign;
95809 + tree addxorrol, rhs;
95810 + enum tree_code op;
95811 +
95812 + op = get_op(&rhs);
95813 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95814 + assign = gimple_build_assign(local_entropy, addxorrol);
95815 +#if BUILDING_GCC_VERSION <= 4007
95816 + find_referenced_vars_in(assign);
95817 +#endif
95818 +//debug_bb(bb);
95819 + gsi = gsi_after_labels(bb);
95820 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95821 + update_stmt(assign);
95822 +}
95823 +
95824 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95825 +{
95826 + gimple_stmt_iterator gsi;
95827 + gimple assign;
95828 + tree addxorrol, temp;
95829 +
95830 + // 1. create temporary copy of latent_entropy
95831 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95832 +#if BUILDING_GCC_VERSION <= 4007
95833 + add_referenced_var(temp);
95834 + mark_sym_for_renaming(temp);
95835 +#endif
95836 +
95837 + // 2. read...
95838 + assign = gimple_build_assign(temp, latent_entropy_decl);
95839 +#if BUILDING_GCC_VERSION <= 4007
95840 + find_referenced_vars_in(assign);
95841 +#endif
95842 + gsi = gsi_after_labels(bb);
95843 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95844 + update_stmt(assign);
95845 +
95846 + // 3. ...modify...
95847 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95848 + assign = gimple_build_assign(temp, addxorrol);
95849 +#if BUILDING_GCC_VERSION <= 4007
95850 + find_referenced_vars_in(assign);
95851 +#endif
95852 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95853 + update_stmt(assign);
95854 +
95855 + // 4. ...write latent_entropy
95856 + assign = gimple_build_assign(latent_entropy_decl, temp);
95857 +#if BUILDING_GCC_VERSION <= 4007
95858 + find_referenced_vars_in(assign);
95859 +#endif
95860 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95861 + update_stmt(assign);
95862 +}
95863 +
95864 +static unsigned int execute_latent_entropy(void)
95865 +{
95866 + basic_block bb;
95867 + gimple assign;
95868 + gimple_stmt_iterator gsi;
95869 + tree local_entropy;
95870 +
95871 + if (!latent_entropy_decl) {
95872 + struct varpool_node *node;
95873 +
95874 +#if BUILDING_GCC_VERSION <= 4007
95875 + for (node = varpool_nodes; node; node = node->next) {
95876 + tree var = node->decl;
95877 +#else
95878 + FOR_EACH_VARIABLE(node) {
95879 + tree var = node->symbol.decl;
95880 +#endif
95881 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95882 + continue;
95883 + latent_entropy_decl = var;
95884 +// debug_tree(var);
95885 + break;
95886 + }
95887 + if (!latent_entropy_decl) {
95888 +// debug_tree(current_function_decl);
95889 + return 0;
95890 + }
95891 + }
95892 +
95893 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95894 +
95895 + // 1. create local entropy variable
95896 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95897 +#if BUILDING_GCC_VERSION <= 4007
95898 + add_referenced_var(local_entropy);
95899 + mark_sym_for_renaming(local_entropy);
95900 +#endif
95901 +
95902 + // 2. initialize local entropy variable
95903 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95904 + if (dom_info_available_p(CDI_DOMINATORS))
95905 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95906 + gsi = gsi_start_bb(bb);
95907 +
95908 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95909 +// gimple_set_location(assign, loc);
95910 +#if BUILDING_GCC_VERSION <= 4007
95911 + find_referenced_vars_in(assign);
95912 +#endif
95913 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95914 + update_stmt(assign);
95915 + bb = bb->next_bb;
95916 +
95917 + // 3. instrument each BB with an operation on the local entropy variable
95918 + while (bb != EXIT_BLOCK_PTR) {
95919 + perturb_local_entropy(bb, local_entropy);
95920 + bb = bb->next_bb;
95921 + };
95922 +
95923 + // 4. mix local entropy into the global entropy variable
95924 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95925 + return 0;
95926 +}
95927 +
95928 +static void start_unit_callback(void *gcc_data, void *user_data)
95929 +{
95930 + tree latent_entropy_type;
95931 +
95932 +#if BUILDING_GCC_VERSION >= 4007
95933 + seed = get_random_seed(false);
95934 +#else
95935 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95936 + seed *= seed;
95937 +#endif
95938 +
95939 + if (in_lto_p)
95940 + return;
95941 +
95942 + // extern volatile u64 latent_entropy
95943 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95944 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95945 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95946 +
95947 + TREE_STATIC(latent_entropy_decl) = 1;
95948 + TREE_PUBLIC(latent_entropy_decl) = 1;
95949 + TREE_USED(latent_entropy_decl) = 1;
95950 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95951 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95952 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95953 + DECL_INITIAL(latent_entropy_decl) = NULL;
95954 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95955 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95956 +// varpool_finalize_decl(latent_entropy_decl);
95957 +// varpool_mark_needed_node(latent_entropy_decl);
95958 +}
95959 +
95960 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95961 +{
95962 + const char * const plugin_name = plugin_info->base_name;
95963 + struct register_pass_info latent_entropy_pass_info = {
95964 + .pass = &latent_entropy_pass.pass,
95965 + .reference_pass_name = "optimized",
95966 + .ref_pass_instance_number = 1,
95967 + .pos_op = PASS_POS_INSERT_BEFORE
95968 + };
95969 +
95970 + if (!plugin_default_version_check(version, &gcc_version)) {
95971 + error(G_("incompatible gcc/plugin versions"));
95972 + return 1;
95973 + }
95974 +
95975 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95976 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95977 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95978 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95979 +
95980 + return 0;
95981 +}
95982 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95983 new file mode 100644
95984 index 0000000..ddd5b2e
95985 --- /dev/null
95986 +++ b/tools/gcc/size_overflow_hash.data
95987 @@ -0,0 +1,5876 @@
95988 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95989 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95990 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95991 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95992 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95993 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95994 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95995 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95996 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95997 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
95998 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
95999 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
96000 +load_msg_95 load_msg 2 95 NULL
96001 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
96002 +init_q_132 init_q 4 132 NULL
96003 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
96004 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
96005 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
96006 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
96007 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
96008 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
96009 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
96010 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
96011 +br_port_info_size_268 br_port_info_size 0 268 NULL
96012 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
96013 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
96014 +syslog_print_307 syslog_print 2 307 NULL
96015 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
96016 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
96017 +next_node_allowed_318 next_node_allowed 1 318 NULL
96018 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
96019 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
96020 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
96021 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
96022 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
96023 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
96024 +pidlist_resize_496 pidlist_resize 2 496 NULL
96025 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
96026 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
96027 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
96028 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
96029 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
96030 +dle_count_543 dle_count 0 543 NULL
96031 +devres_alloc_551 devres_alloc 2 551 NULL
96032 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
96033 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
96034 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
96035 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
96036 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
96037 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
96038 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
96039 +isp1760_register_628 isp1760_register 1-2 628 NULL
96040 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
96041 +unlink_queued_645 unlink_queued 3-4 645 NULL
96042 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
96043 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
96044 +div_u64_rem_672 div_u64_rem 0 672 NULL
96045 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
96046 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
96047 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
96048 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
96049 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
96050 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
96051 +dvb_video_write_754 dvb_video_write 3 754 NULL
96052 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
96053 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
96054 +if_writecmd_815 if_writecmd 2 815 NULL
96055 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
96056 +read_fifo_826 read_fifo 3 826 NULL
96057 +read_tree_block_841 read_tree_block 3 841 NULL
96058 +um_idi_read_850 um_idi_read 3 850 NULL
96059 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
96060 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
96061 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
96062 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
96063 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
96064 +readw_931 readw 0 931 NULL
96065 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
96066 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
96067 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
96068 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
96069 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
96070 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
96071 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
96072 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
96073 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
96074 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
96075 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
96076 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
96077 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
96078 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
96079 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
96080 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
96081 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
96082 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
96083 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
96084 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
96085 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
96086 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
96087 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
96088 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
96089 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
96090 +thin_status_1239 thin_status 5 1239 NULL
96091 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
96092 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
96093 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
96094 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
96095 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
96096 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
96097 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
96098 +ffs_1322 ffs 0 1322 NULL
96099 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
96100 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
96101 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
96102 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
96103 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
96104 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
96105 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
96106 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
96107 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
96108 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
96109 +zone_page_state_1393 zone_page_state 0 1393 NULL
96110 +file_read_actor_1401 file_read_actor 4 1401 NULL
96111 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
96112 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
96113 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
96114 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
96115 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
96116 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
96117 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
96118 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
96119 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
96120 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
96121 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
96122 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
96123 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
96124 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
96125 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
96126 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
96127 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
96128 +rmap_add_1677 rmap_add 3 1677 NULL
96129 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
96130 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
96131 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
96132 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
96133 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
96134 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
96135 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
96136 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
96137 +cosa_write_1774 cosa_write 3 1774 NULL
96138 +update_macheader_1775 update_macheader 7 1775 NULL
96139 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
96140 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
96141 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
96142 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
96143 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
96144 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
96145 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
96146 +read_swap_header_1957 read_swap_header 0 1957 NULL
96147 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
96148 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
96149 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
96150 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
96151 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
96152 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
96153 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
96154 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
96155 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
96156 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
96157 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
96158 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
96159 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
96160 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
96161 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
96162 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
96163 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
96164 +audit_expand_2098 audit_expand 2 2098 NULL
96165 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
96166 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
96167 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
96168 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
96169 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
96170 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
96171 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
96172 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
96173 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
96174 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
96175 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
96176 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
96177 +u32_array_read_2219 u32_array_read 3 2219 NULL
96178 +vhci_write_2224 vhci_write 3 2224 NULL
96179 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
96180 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
96181 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
96182 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
96183 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
96184 +do_update_counters_2259 do_update_counters 4 2259 NULL
96185 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
96186 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
96187 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
96188 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
96189 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
96190 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
96191 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
96192 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
96193 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
96194 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
96195 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
96196 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
96197 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
96198 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
96199 +raid1_size_2419 raid1_size 0-2 2419 NULL
96200 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
96201 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
96202 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
96203 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
96204 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
96205 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
96206 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
96207 +update_pmkid_2481 update_pmkid 4 2481 NULL
96208 +wiphy_new_2482 wiphy_new 2 2482 NULL
96209 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
96210 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
96211 +dm_write_2513 dm_write 3 2513 NULL
96212 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
96213 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
96214 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
96215 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
96216 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
96217 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
96218 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
96219 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
96220 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
96221 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
96222 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
96223 +__next_cpu_2782 __next_cpu 1 2782 NULL
96224 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
96225 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
96226 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
96227 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
96228 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
96229 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
96230 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
96231 +__swab64p_2875 __swab64p 0 2875 NULL
96232 +nla_padlen_2883 nla_padlen 1 2883 NULL
96233 +cmm_write_2896 cmm_write 3 2896 NULL
96234 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
96235 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
96236 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
96237 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
96238 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
96239 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
96240 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
96241 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
96242 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
96243 +depth_write_3021 depth_write 3 3021 NULL
96244 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
96245 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
96246 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
96247 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
96248 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
96249 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
96250 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
96251 +free_coherent_3082 free_coherent 4-2 3082 NULL
96252 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
96253 +rb_alloc_3102 rb_alloc 1 3102 NULL
96254 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
96255 +print_time_3132 print_time 0 3132 NULL
96256 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
96257 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
96258 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
96259 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
96260 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
96261 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
96262 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
96263 +alloc_context_3194 alloc_context 1 3194 NULL
96264 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
96265 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
96266 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
96267 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
96268 +key_key_read_3241 key_key_read 3 3241 NULL
96269 +number_3243 number 0 3243 NULL
96270 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
96271 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
96272 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
96273 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
96274 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
96275 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
96276 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
96277 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
96278 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
96279 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
96280 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
96281 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
96282 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
96283 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
96284 +send_stream_3397 send_stream 4 3397 NULL
96285 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
96286 +msix_map_region_3411 msix_map_region 3 3411 NULL
96287 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
96288 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
96289 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
96290 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
96291 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
96292 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
96293 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
96294 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
96295 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
96296 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
96297 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
96298 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
96299 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
96300 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
96301 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
96302 +evtchn_read_3569 evtchn_read 3 3569 NULL
96303 +vc_resize_3585 vc_resize 2-3 3585 NULL
96304 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
96305 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
96306 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
96307 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
96308 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
96309 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
96310 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
96311 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
96312 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
96313 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
96314 +create_irq_3703 create_irq 0 3703 NULL nohasharray
96315 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
96316 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
96317 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
96318 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
96319 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
96320 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
96321 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
96322 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
96323 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
96324 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
96325 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
96326 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
96327 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
96328 +get_fd_set_3866 get_fd_set 1 3866 NULL
96329 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
96330 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
96331 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
96332 +nvram_write_3894 nvram_write 3 3894 NULL
96333 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
96334 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
96335 +vcs_write_3910 vcs_write 3 3910 NULL
96336 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
96337 +do_add_counters_3992 do_add_counters 3 3992 NULL
96338 +userspace_status_4004 userspace_status 4 4004 NULL
96339 +mei_write_4005 mei_write 3 4005 NULL nohasharray
96340 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
96341 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
96342 +blk_end_request_4024 blk_end_request 3 4024 NULL
96343 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
96344 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
96345 +read_file_queues_4078 read_file_queues 3 4078 NULL
96346 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
96347 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
96348 +tm6000_read_4151 tm6000_read 3 4151 NULL
96349 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
96350 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
96351 +get_alua_req_4166 get_alua_req 3 4166 NULL
96352 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
96353 +read_file_bool_4180 read_file_bool 3 4180 NULL
96354 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
96355 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
96356 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
96357 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
96358 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
96359 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
96360 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
96361 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
96362 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
96363 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
96364 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
96365 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
96366 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
96367 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
96368 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
96369 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
96370 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
96371 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
96372 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
96373 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
96374 +set_link_security_4502 set_link_security 4 4502 NULL
96375 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
96376 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
96377 +tty_register_device_4544 tty_register_device 2 4544 NULL
96378 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
96379 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
96380 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
96381 +bch_alloc_4593 bch_alloc 1 4593 NULL
96382 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
96383 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
96384 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
96385 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
96386 +kone_receive_4690 kone_receive 4 4690 NULL
96387 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
96388 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
96389 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
96390 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
96391 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
96392 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
96393 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
96394 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
96395 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
96396 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
96397 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
96398 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
96399 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
96400 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
96401 +sys_ipc_4889 sys_ipc 3 4889 NULL
96402 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
96403 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
96404 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
96405 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
96406 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
96407 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
96408 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
96409 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
96410 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
96411 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
96412 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
96413 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
96414 +do_mincore_5018 do_mincore 0-1 5018 NULL
96415 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
96416 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
96417 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
96418 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
96419 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
96420 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
96421 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
96422 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
96423 +sound_write_5102 sound_write 3 5102 NULL
96424 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
96425 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
96426 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
96427 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
96428 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
96429 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
96430 +skb_network_header_5203 skb_network_header 0 5203 NULL
96431 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
96432 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
96433 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
96434 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
96435 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
96436 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
96437 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
96438 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
96439 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
96440 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
96441 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
96442 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
96443 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
96444 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
96445 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
96446 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
96447 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
96448 +tty_write_5494 tty_write 3 5494 NULL
96449 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
96450 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
96451 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
96452 +spidev_message_5518 spidev_message 3 5518 NULL
96453 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
96454 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
96455 +le_readq_5557 le_readq 0 5557 NULL
96456 +inw_5558 inw 0 5558 NULL
96457 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
96458 +fir16_create_5574 fir16_create 3 5574 NULL
96459 +bioset_create_5580 bioset_create 1 5580 NULL
96460 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
96461 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
96462 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
96463 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
96464 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
96465 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
96466 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
96467 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
96468 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
96469 +get_arg_5694 get_arg 3 5694 NULL
96470 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
96471 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
96472 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
96473 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
96474 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
96475 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
96476 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
96477 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
96478 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
96479 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
96480 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
96481 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
96482 +setup_req_5848 setup_req 3 5848 NULL
96483 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
96484 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
96485 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
96486 +port_show_regs_5904 port_show_regs 3 5904 NULL
96487 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
96488 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
96489 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
96490 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
96491 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
96492 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
96493 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
96494 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
96495 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
96496 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
96497 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
96498 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
96499 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
96500 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
96501 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
96502 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
96503 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
96504 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
96505 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
96506 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
96507 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
96508 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
96509 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
96510 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
96511 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
96512 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
96513 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
96514 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
96515 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
96516 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
96517 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
96518 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
96519 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
96520 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
96521 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
96522 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
96523 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
96524 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
96525 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
96526 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
96527 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
96528 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
96529 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
96530 +mei_read_6507 mei_read 3 6507 NULL
96531 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
96532 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
96533 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
96534 +wdm_read_6549 wdm_read 3 6549 NULL
96535 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
96536 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
96537 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
96538 +usemap_size_6601 usemap_size 0-1 6601 NULL
96539 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
96540 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
96541 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
96542 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
96543 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
96544 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
96545 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
96546 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
96547 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
96548 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
96549 +mpeg_read_6708 mpeg_read 3 6708 NULL
96550 +video_proc_write_6724 video_proc_write 3 6724 NULL
96551 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
96552 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
96553 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
96554 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
96555 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
96556 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
96557 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
96558 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
96559 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
96560 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
96561 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
96562 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
96563 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
96564 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
96565 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
96566 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
96567 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
96568 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
96569 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
96570 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
96571 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
96572 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
96573 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
96574 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
96575 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
96576 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
96577 +request_key_async_6990 request_key_async 4 6990 NULL
96578 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
96579 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
96580 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
96581 +wimax_msg_7030 wimax_msg 4 7030 NULL
96582 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
96583 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
96584 +event_enable_read_7074 event_enable_read 3 7074 NULL
96585 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
96586 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
96587 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
96588 +check_header_7108 check_header 0 7108 NULL
96589 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
96590 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
96591 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
96592 +get_param_h_7247 get_param_h 0 7247 NULL
96593 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
96594 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
96595 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
96596 +mgmt_control_7349 mgmt_control 3 7349 NULL
96597 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
96598 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
96599 +hweight_long_7388 hweight_long 0-1 7388 NULL
96600 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
96601 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
96602 +readb_7401 readb 0 7401 NULL
96603 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
96604 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
96605 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
96606 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
96607 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
96608 +garp_request_join_7471 garp_request_join 4 7471 NULL
96609 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
96610 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
96611 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
96612 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
96613 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
96614 +setup_usemap_7524 setup_usemap 3 7524 NULL
96615 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
96616 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
96617 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
96618 +groups_alloc_7614 groups_alloc 1 7614 NULL
96619 +sg_virt_7616 sg_virt 0 7616 NULL
96620 +cpumask_first_7648 cpumask_first 0 7648 NULL
96621 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
96622 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
96623 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
96624 +dev_write_7708 dev_write 3 7708 NULL
96625 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
96626 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
96627 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
96628 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
96629 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
96630 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
96631 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
96632 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
96633 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
96634 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
96635 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
96636 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
96637 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
96638 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
96639 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
96640 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
96641 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
96642 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
96643 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
96644 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
96645 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
96646 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
96647 +sys_mbind_7990 sys_mbind 5 7990 NULL
96648 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
96649 +vcs_read_8017 vcs_read 3 8017 NULL
96650 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
96651 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
96652 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
96653 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
96654 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
96655 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
96656 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
96657 +venus_lookup_8121 venus_lookup 4 8121 NULL
96658 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
96659 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
96660 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
96661 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
96662 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
96663 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
96664 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
96665 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
96666 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
96667 +play_iframe_8219 play_iframe 3 8219 NULL
96668 +create_log_8225 create_log 2 8225 NULL nohasharray
96669 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
96670 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
96671 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
96672 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
96673 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
96674 +init_cdev_8274 init_cdev 1 8274 NULL
96675 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
96676 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
96677 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
96678 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
96679 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
96680 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
96681 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
96682 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
96683 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
96684 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
96685 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
96686 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
96687 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
96688 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
96689 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96690 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96691 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
96692 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96693 +dev_config_8506 dev_config 3 8506 NULL
96694 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96695 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
96696 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96697 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96698 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96699 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96700 +profile_remove_8556 profile_remove 3 8556 NULL
96701 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96702 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96703 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96704 +tower_write_8580 tower_write 3 8580 NULL
96705 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96706 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96707 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96708 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96709 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96710 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96711 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96712 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96713 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96714 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96715 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96716 +arcfb_write_8702 arcfb_write 3 8702 NULL
96717 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96718 +init_header_8703 init_header 0 8703 &i_size_read_8703
96719 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96720 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
96721 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
96722 +f_dupfd_8730 f_dupfd 1 8730 NULL
96723 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
96724 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
96725 +sys_prctl_8766 sys_prctl 4 8766 NULL
96726 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
96727 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
96728 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
96729 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
96730 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
96731 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
96732 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
96733 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
96734 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
96735 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
96736 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
96737 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
96738 +send_pages_8872 send_pages 3 8872 NULL
96739 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
96740 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96741 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96742 +layout_commit_8926 layout_commit 3 8926 NULL
96743 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96744 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96745 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96746 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96747 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96748 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96749 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96750 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96751 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96752 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96753 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
96754 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
96755 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96756 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96757 +nla_put_9042 nla_put 3 9042 NULL
96758 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96759 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96760 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96761 +string_9080 string 0 9080 NULL
96762 +create_queues_9088 create_queues 2-3 9088 NULL
96763 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96764 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96765 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96766 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96767 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96768 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96769 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96770 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96771 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96772 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96773 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96774 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96775 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96776 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96777 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96778 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96779 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96780 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96781 +flakey_status_9274 flakey_status 5 9274 NULL
96782 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96783 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96784 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96785 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96786 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96787 +read_9397 read 3 9397 NULL
96788 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96789 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
96790 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96791 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96792 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96793 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96794 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96795 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96796 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96797 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
96798 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96799 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96800 +lp_write_9511 lp_write 3 9511 NULL
96801 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96802 +lm3533_update_9529 lm3533_update 2 9529 NULL
96803 +read_file_dma_9530 read_file_dma 3 9530 NULL
96804 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96805 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
96806 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96807 +readl_9557 readl 0 9557 NULL
96808 +fw_node_create_9559 fw_node_create 2 9559 NULL
96809 +kobj_map_9566 kobj_map 2-3 9566 NULL
96810 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96811 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96812 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96813 +do_sync_9604 do_sync 1 9604 NULL
96814 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96815 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96816 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96817 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96818 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96819 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96820 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96821 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96822 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96823 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96824 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96825 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
96826 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
96827 +fnb_9703 fnb 2-3 9703 NULL
96828 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
96829 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96830 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96831 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96832 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96833 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96834 +do_sigpending_9766 do_sigpending 2 9766 NULL
96835 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96836 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96837 +_regmap_write_9803 _regmap_write 2 9803 NULL
96838 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96839 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96840 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96841 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96842 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96843 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96844 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96845 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96846 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96847 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96848 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96849 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96850 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96851 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96852 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
96853 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96854 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96855 +read_file_misc_9948 read_file_misc 3 9948 NULL
96856 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96857 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96858 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96859 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96860 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96861 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96862 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
96863 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96864 +handle_request_10024 handle_request 9 10024 NULL
96865 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96866 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96867 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
96868 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96869 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
96870 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96871 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96872 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96873 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
96874 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96875 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96876 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96877 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96878 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96879 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96880 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96881 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96882 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96883 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96884 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96885 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96886 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96887 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
96888 +read_emulate_10310 read_emulate 2-4 10310 NULL
96889 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96890 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96891 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96892 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96893 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96894 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96895 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96896 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96897 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96898 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96899 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96900 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96901 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96902 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96903 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96904 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96905 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96906 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
96907 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96908 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96909 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96910 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96911 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96912 +otp_read_10594 otp_read 2-4-5 10594 NULL
96913 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96914 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
96915 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96916 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96917 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96918 +parport_write_10669 parport_write 0 10669 NULL
96919 +inl_10708 inl 0 10708 NULL nohasharray
96920 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96921 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96922 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96923 +spi_sync_10731 spi_sync 0 10731 NULL
96924 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96925 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96926 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96927 +sys_syslog_10746 sys_syslog 3 10746 NULL
96928 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96929 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96930 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
96931 +sys_bind_10799 sys_bind 3 10799 NULL
96932 +compat_put_int_10828 compat_put_int 1 10828 NULL
96933 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96934 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96935 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96936 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96937 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
96938 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96939 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96940 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96941 +get_scq_10897 get_scq 2 10897 NULL
96942 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96943 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96944 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96945 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96946 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96947 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96948 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96949 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96950 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96951 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96952 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96953 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96954 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
96955 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96956 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
96957 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96958 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
96959 +count_argc_11083 count_argc 0 11083 NULL
96960 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96961 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96962 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96963 +page_offset_11120 page_offset 0 11120 NULL
96964 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96965 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
96966 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96967 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96968 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96969 +__swab16p_11220 __swab16p 0 11220 NULL
96970 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96971 +of_irq_count_11253 of_irq_count 0 11253 NULL
96972 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96973 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96974 +cru_detect_11272 cru_detect 1 11272 NULL
96975 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96976 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96977 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96978 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96979 +next_segment_11330 next_segment 0-2-1 11330 NULL
96980 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96981 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96982 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96983 +sel_write_create_11353 sel_write_create 3 11353 NULL
96984 +handle_unit_11355 handle_unit 0-1 11355 NULL
96985 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96986 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96987 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96988 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96989 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
96990 +str_to_user_11411 str_to_user 2 11411 NULL
96991 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
96992 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
96993 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96994 +trace_options_read_11419 trace_options_read 3 11419 NULL
96995 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96996 +prepare_image_11424 prepare_image 0 11424 NULL
96997 +vring_size_11426 vring_size 0-1-2 11426 NULL
96998 +bttv_read_11432 bttv_read 3 11432 NULL
96999 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
97000 +swp_offset_11475 swp_offset 0 11475 NULL
97001 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
97002 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
97003 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
97004 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
97005 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
97006 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
97007 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
97008 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
97009 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
97010 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
97011 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
97012 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
97013 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
97014 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
97015 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
97016 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
97017 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
97018 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
97019 +split_11691 split 2 11691 NULL
97020 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
97021 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
97022 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
97023 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
97024 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
97025 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
97026 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
97027 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
97028 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
97029 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
97030 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
97031 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
97032 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
97033 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
97034 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
97035 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
97036 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
97037 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
97038 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
97039 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
97040 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
97041 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
97042 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
97043 +atmel_read16_11981 atmel_read16 0 11981 NULL
97044 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
97045 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
97046 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
97047 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
97048 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
97049 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
97050 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
97051 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
97052 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
97053 +set_powered_12129 set_powered 4 12129 NULL
97054 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
97055 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
97056 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
97057 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
97058 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
97059 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
97060 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
97061 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
97062 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
97063 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
97064 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
97065 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
97066 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
97067 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
97068 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
97069 +receive_copy_12216 receive_copy 3 12216 NULL
97070 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
97071 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
97072 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
97073 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
97074 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
97075 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
97076 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
97077 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
97078 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
97079 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
97080 +split_bvec_12312 split_bvec 6 12312 NULL
97081 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
97082 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
97083 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
97084 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
97085 +receive_packet_12367 receive_packet 2 12367 NULL
97086 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
97087 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
97088 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
97089 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
97090 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
97091 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
97092 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
97093 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
97094 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
97095 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
97096 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
97097 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
97098 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
97099 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
97100 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
97101 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
97102 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
97103 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
97104 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
97105 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
97106 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
97107 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
97108 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
97109 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
97110 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
97111 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
97112 +ivtv_write_12721 ivtv_write 3 12721 NULL
97113 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
97114 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
97115 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
97116 +listxattr_12769 listxattr 3 12769 NULL
97117 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
97118 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
97119 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
97120 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
97121 +readq_12825 readq 0 12825 NULL
97122 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
97123 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
97124 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
97125 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
97126 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
97127 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
97128 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
97129 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
97130 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
97131 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
97132 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
97133 +bm_status_write_12964 bm_status_write 3 12964 NULL
97134 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
97135 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
97136 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
97137 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
97138 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
97139 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
97140 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
97141 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
97142 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
97143 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
97144 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
97145 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
97146 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
97147 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
97148 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
97149 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
97150 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
97151 +blk_update_request_13146 blk_update_request 3 13146 NULL
97152 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
97153 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
97154 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
97155 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
97156 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
97157 +comedi_read_13199 comedi_read 3 13199 NULL
97158 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
97159 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
97160 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
97161 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
97162 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
97163 +fw_download_code_13249 fw_download_code 3 13249 NULL
97164 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
97165 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
97166 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
97167 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
97168 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
97169 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
97170 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
97171 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
97172 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
97173 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
97174 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
97175 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
97176 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
97177 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
97178 +sky2_receive_13407 sky2_receive 2 13407 NULL
97179 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
97180 +keyring_read_13438 keyring_read 3 13438 NULL
97181 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
97182 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
97183 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
97184 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
97185 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
97186 +core_status_13515 core_status 4 13515 NULL
97187 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
97188 +bm_init_13529 bm_init 2 13529 NULL
97189 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
97190 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
97191 +alloc_tio_13564 alloc_tio 3 13564 NULL
97192 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
97193 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
97194 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
97195 +cache_write_13589 cache_write 3 13589 NULL
97196 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
97197 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
97198 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
97199 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
97200 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
97201 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
97202 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
97203 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
97204 +packet_snd_13634 packet_snd 3 13634 NULL
97205 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
97206 +cache_downcall_13666 cache_downcall 3 13666 NULL
97207 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
97208 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
97209 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
97210 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
97211 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
97212 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
97213 +random_read_13815 random_read 3 13815 NULL
97214 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
97215 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
97216 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
97217 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
97218 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
97219 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
97220 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
97221 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
97222 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
97223 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
97224 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
97225 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
97226 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
97227 +com90xx_found_13974 com90xx_found 3 13974 NULL
97228 +qcam_read_13977 qcam_read 3 13977 NULL
97229 +dsp_read_13980 dsp_read 2 13980 NULL
97230 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
97231 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
97232 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
97233 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
97234 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
97235 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
97236 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
97237 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
97238 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
97239 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
97240 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
97241 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
97242 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
97243 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
97244 +em_canid_change_14150 em_canid_change 3 14150 NULL
97245 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
97246 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
97247 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
97248 +alloc_async_14208 alloc_async 1 14208 NULL
97249 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
97250 +pool_status_14230 pool_status 5 14230 NULL
97251 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
97252 +inode_to_path_14235 inode_to_path 2 14235 NULL
97253 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
97254 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
97255 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
97256 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
97257 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
97258 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
97259 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
97260 +rr_status_14293 rr_status 5 14293 NULL
97261 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
97262 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
97263 +oo_objects_14319 oo_objects 0 14319 NULL
97264 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
97265 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
97266 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
97267 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
97268 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
97269 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
97270 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
97271 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
97272 +block_size_14443 block_size 0 14443 NULL
97273 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
97274 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
97275 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
97276 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
97277 +stripe_status_14506 stripe_status 5 14506 NULL
97278 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
97279 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
97280 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
97281 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
97282 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
97283 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
97284 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
97285 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
97286 +dbJoin_14644 dbJoin 0 14644 NULL
97287 +profile_replace_14652 profile_replace 3 14652 NULL
97288 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
97289 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
97290 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
97291 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
97292 +vfd_write_14717 vfd_write 3 14717 NULL
97293 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
97294 +raid1_resize_14740 raid1_resize 2 14740 NULL
97295 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
97296 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
97297 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
97298 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
97299 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
97300 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
97301 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
97302 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
97303 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
97304 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
97305 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
97306 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
97307 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
97308 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
97309 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
97310 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
97311 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
97312 +unifi_read_14899 unifi_read 3 14899 NULL
97313 +krealloc_14908 krealloc 2 14908 NULL
97314 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
97315 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
97316 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
97317 +queue_cnt_14951 queue_cnt 0 14951 NULL
97318 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
97319 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
97320 +setkey_14987 setkey 3 14987 NULL nohasharray
97321 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
97322 +vmap_15025 vmap 2 15025 NULL
97323 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
97324 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
97325 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
97326 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
97327 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
97328 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
97329 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
97330 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
97331 +start_port_15124 start_port 0 15124 NULL
97332 +memchr_15126 memchr 0 15126 NULL
97333 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
97334 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
97335 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
97336 +reserve_resources_15194 reserve_resources 3 15194 NULL
97337 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
97338 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
97339 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
97340 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
97341 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
97342 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
97343 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
97344 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
97345 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
97346 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
97347 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
97348 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
97349 +ioread16_15342 ioread16 0 15342 NULL
97350 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
97351 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
97352 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
97353 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
97354 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
97355 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
97356 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
97357 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
97358 +get_modalias_15406 get_modalias 2 15406 NULL
97359 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
97360 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
97361 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
97362 +memweight_15450 memweight 2 15450 NULL
97363 +vmalloc_15464 vmalloc 1 15464 NULL
97364 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
97365 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
97366 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
97367 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
97368 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
97369 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
97370 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
97371 +persistent_status_15574 persistent_status 4 15574 NULL
97372 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
97373 +vme_user_write_15587 vme_user_write 3 15587 NULL
97374 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
97375 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
97376 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
97377 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
97378 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
97379 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
97380 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
97381 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
97382 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
97383 +fs_path_add_15648 fs_path_add 3 15648 NULL
97384 +xsd_read_15653 xsd_read 3 15653 NULL
97385 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
97386 +unix_bind_15668 unix_bind 3 15668 NULL
97387 +dm_read_15674 dm_read 3 15674 NULL
97388 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
97389 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
97390 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
97391 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
97392 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
97393 +do_test_15766 do_test 1 15766 NULL
97394 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
97395 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
97396 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
97397 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
97398 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
97399 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
97400 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
97401 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
97402 +table_size_15851 table_size 0-1-2 15851 NULL
97403 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
97404 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
97405 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
97406 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
97407 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
97408 +native_read_msr_15905 native_read_msr 0 15905 NULL
97409 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
97410 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
97411 +power_read_15939 power_read 3 15939 NULL
97412 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
97413 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
97414 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
97415 +set_spte_15977 set_spte 7-6 15977 NULL
97416 +frame_alloc_15981 frame_alloc 4 15981 NULL
97417 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
97418 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
97419 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
97420 +got_frame_16028 got_frame 2 16028 NULL
97421 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
97422 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
97423 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
97424 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
97425 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
97426 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
97427 +fsm_init_16134 fsm_init 2 16134 NULL
97428 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
97429 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
97430 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
97431 +mapping_level_16188 mapping_level 2 16188 NULL
97432 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
97433 +create_table_16213 create_table 2 16213 NULL
97434 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
97435 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
97436 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
97437 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
97438 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
97439 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
97440 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
97441 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
97442 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
97443 +account_16283 account 0-2-4 16283 NULL nohasharray
97444 +mirror_status_16283 mirror_status 5 16283 &account_16283
97445 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
97446 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
97447 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
97448 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
97449 +tps80031_update_16360 tps80031_update 3 16360 NULL
97450 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
97451 +rbd_add_16366 rbd_add 3 16366 NULL
97452 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
97453 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
97454 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
97455 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
97456 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
97457 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
97458 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
97459 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
97460 +raid10_resize_16537 raid10_resize 2 16537 NULL
97461 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
97462 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
97463 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
97464 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
97465 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
97466 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
97467 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
97468 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
97469 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
97470 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
97471 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
97472 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
97473 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
97474 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
97475 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
97476 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
97477 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
97478 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
97479 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
97480 +st_write_16874 st_write 3 16874 NULL
97481 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
97482 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
97483 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
97484 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
97485 +random32_16937 random32 0 16937 NULL
97486 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
97487 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
97488 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
97489 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
97490 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
97491 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
97492 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
97493 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
97494 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
97495 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
97496 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
97497 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
97498 +mac_address_string_17091 mac_address_string 0 17091 NULL
97499 +entry_length_17093 entry_length 0 17093 NULL
97500 +sys_preadv_17100 sys_preadv 3 17100 NULL
97501 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
97502 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
97503 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
97504 +sep_read_17161 sep_read 3 17161 NULL
97505 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
97506 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
97507 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
97508 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
97509 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
97510 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
97511 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
97512 +ms_rw_17220 ms_rw 3-4 17220 NULL
97513 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
97514 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
97515 +alloc_ep_17269 alloc_ep 1 17269 NULL
97516 +pg_read_17276 pg_read 3 17276 NULL
97517 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
97518 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
97519 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
97520 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
97521 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
97522 +skb_pad_17302 skb_pad 2 17302 NULL
97523 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
97524 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
97525 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
97526 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
97527 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
97528 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
97529 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
97530 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
97531 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
97532 +compat_cmd_17465 compat_cmd 2 17465 NULL
97533 +probe_bios_17467 probe_bios 1 17467 NULL
97534 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
97535 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
97536 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
97537 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
97538 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
97539 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
97540 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
97541 +copy_from_user_17559 copy_from_user 3 17559 NULL
97542 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
97543 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
97544 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
97545 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
97546 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
97547 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
97548 +osst_execute_17607 osst_execute 7-6 17607 NULL
97549 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
97550 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
97551 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
97552 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
97553 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
97554 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
97555 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
97556 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
97557 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
97558 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
97559 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
97560 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
97561 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
97562 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
97563 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
97564 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
97565 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
97566 +count_leafs_17842 count_leafs 0 17842 NULL
97567 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
97568 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
97569 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
97570 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
97571 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
97572 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
97573 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
97574 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
97575 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
97576 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
97577 +recover_head_17904 recover_head 3 17904 NULL
97578 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
97579 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
97580 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
97581 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
97582 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
97583 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
97584 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
97585 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
97586 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
97587 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
97588 +prandom32_18007 prandom32 0 18007 NULL
97589 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
97590 +fill_read_18019 fill_read 0 18019 NULL
97591 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
97592 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
97593 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
97594 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
97595 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
97596 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
97597 +packet_came_18072 packet_came 3 18072 NULL
97598 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
97599 +get_vm_area_18080 get_vm_area 1 18080 NULL
97600 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
97601 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
97602 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
97603 +svc_getnl_18120 svc_getnl 0 18120 NULL
97604 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
97605 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
97606 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
97607 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
97608 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
97609 +_has_tag_18169 _has_tag 2 18169 NULL
97610 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
97611 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
97612 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
97613 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
97614 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
97615 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
97616 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
97617 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
97618 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
97619 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
97620 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
97621 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
97622 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
97623 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
97624 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
97625 +um_idi_write_18293 um_idi_write 3 18293 NULL
97626 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
97627 +vga_r_18310 vga_r 0 18310 NULL
97628 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
97629 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
97630 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
97631 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
97632 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
97633 +ep_io_18367 ep_io 0 18367 NULL
97634 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
97635 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
97636 +__video_register_device_18399 __video_register_device 3 18399 NULL
97637 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
97638 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
97639 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
97640 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
97641 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
97642 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
97643 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
97644 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
97645 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
97646 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
97647 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
97648 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
97649 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
97650 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
97651 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
97652 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
97653 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
97654 +debug_output_18575 debug_output 3 18575 NULL
97655 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
97656 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
97657 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
97658 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
97659 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
97660 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
97661 +from_buffer_18625 from_buffer 3 18625 NULL
97662 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
97663 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
97664 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
97665 +unmap_page_18665 unmap_page 2-3 18665 NULL
97666 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
97667 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
97668 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
97669 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
97670 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
97671 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
97672 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
97673 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
97674 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
97675 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
97676 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
97677 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
97678 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
97679 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
97680 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
97681 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
97682 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
97683 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
97684 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
97685 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
97686 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
97687 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
97688 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
97689 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97690 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97691 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97692 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97693 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97694 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97695 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
97696 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97697 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97698 +huge_page_size_19008 huge_page_size 0 19008 NULL
97699 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97700 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97701 +revalidate_19043 revalidate 2 19043 NULL
97702 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97703 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97704 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97705 +copy_and_check_19089 copy_and_check 3 19089 NULL
97706 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97707 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97708 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97709 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97710 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97711 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97712 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97713 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97714 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97715 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97716 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97717 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97718 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97719 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97720 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97721 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97722 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97723 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
97724 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97725 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97726 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97727 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97728 +qc_capture_19298 qc_capture 3 19298 NULL
97729 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97730 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97731 +debug_read_19322 debug_read 3 19322 NULL
97732 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
97733 +read_zero_19366 read_zero 3 19366 NULL
97734 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
97735 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
97736 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
97737 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
97738 +__phys_addr_19434 __phys_addr 0 19434 NULL
97739 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
97740 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97741 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97742 +sky2_read16_19475 sky2_read16 0 19475 NULL
97743 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97744 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97745 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97746 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97747 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97748 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97749 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97750 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97751 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97752 +nfsd_read_19568 nfsd_read 5 19568 NULL
97753 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97754 +bm_status_read_19583 bm_status_read 3 19583 NULL
97755 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97756 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97757 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97758 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97759 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97760 +read_reg_19723 read_reg 0 19723 NULL
97761 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97762 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97763 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97764 +p9_client_read_19750 p9_client_read 5 19750 NULL
97765 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97766 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97767 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97768 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97769 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97770 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97771 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97772 +vip_read_19832 vip_read 3 19832 NULL nohasharray
97773 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
97774 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97775 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97776 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97777 +__nla_put_19857 __nla_put 3 19857 NULL
97778 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97779 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97780 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97781 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97782 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97783 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97784 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97785 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97786 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
97787 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97788 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97789 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97790 +team_options_register_20091 team_options_register 3 20091 NULL
97791 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97792 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97793 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97794 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97795 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97796 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97797 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97798 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97799 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97800 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97801 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97802 +resource_size_20256 resource_size 0 20256 NULL
97803 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97804 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97805 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97806 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97807 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97808 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
97809 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97810 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97811 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97812 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97813 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
97814 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97815 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
97816 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97817 +read_buf_20469 read_buf 2 20469 NULL
97818 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97819 +fast_user_write_20494 fast_user_write 5 20494 NULL
97820 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97821 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97822 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97823 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97824 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97825 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97826 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97827 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97828 +venus_create_20555 venus_create 4 20555 NULL
97829 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97830 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97831 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
97832 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97833 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97834 +lirc_write_20604 lirc_write 3 20604 NULL
97835 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97836 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97837 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97838 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97839 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97840 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
97841 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97842 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
97843 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
97844 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97845 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
97846 +cpumask_size_20683 cpumask_size 0 20683 NULL
97847 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97848 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97849 +__maestro_read_20700 __maestro_read 0 20700 NULL
97850 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97851 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97852 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97853 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97854 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97855 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97856 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97857 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97858 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97859 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97860 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97861 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97862 +sys_sendto_20809 sys_sendto 6 20809 NULL
97863 +strndup_user_20819 strndup_user 2 20819 NULL
97864 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97865 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
97866 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97867 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97868 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97869 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97870 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97871 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97872 +htable_bits_20933 htable_bits 0 20933 NULL
97873 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97874 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97875 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97876 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97877 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97878 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97879 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97880 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97881 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97882 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97883 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97884 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97885 +multipath_status_21094 multipath_status 5 21094 NULL
97886 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97887 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97888 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97889 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97890 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97891 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97892 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
97893 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
97894 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97895 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97896 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97897 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97898 +input_ff_create_21240 input_ff_create 2 21240 NULL
97899 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97900 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97901 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97902 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
97903 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97904 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97905 +add_res_range_21310 add_res_range 4 21310 NULL
97906 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97907 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97908 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97909 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97910 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97911 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97912 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97913 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97914 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97915 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97916 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97917 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97918 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
97919 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97920 +concat_writev_21451 concat_writev 3 21451 NULL
97921 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
97922 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97923 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97924 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97925 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97926 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97927 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97928 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97929 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97930 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97931 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
97932 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97933 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
97934 +validate_nnode_21638 validate_nnode 0 21638 NULL
97935 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97936 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97937 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
97938 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97939 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97940 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97941 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97942 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97943 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97944 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97945 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97946 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97947 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97948 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97949 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97950 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97951 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97952 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97953 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97954 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97955 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97956 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97957 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97958 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97959 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97960 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97961 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
97962 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97963 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97964 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97965 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97966 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97967 +ti_recv_22027 ti_recv 4 22027 NULL
97968 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
97969 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97970 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97971 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97972 +mem_rw_22085 mem_rw 3 22085 NULL
97973 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
97974 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97975 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97976 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97977 +compat_insn_22142 compat_insn 2 22142 NULL
97978 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
97979 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97980 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
97981 +fls_22210 fls 0 22210 NULL
97982 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
97983 +mem_write_22232 mem_write 3 22232 NULL
97984 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97985 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97986 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97987 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97988 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97989 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97990 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97991 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97992 +get_segment_base_22324 get_segment_base 0 22324 NULL
97993 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97994 +atomic_read_22342 atomic_read 0 22342 NULL
97995 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97996 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
97997 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97998 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
97999 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
98000 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
98001 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
98002 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
98003 +zoran_write_22404 zoran_write 3 22404 NULL
98004 +queue_reply_22416 queue_reply 3 22416 NULL
98005 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
98006 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
98007 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
98008 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
98009 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
98010 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
98011 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
98012 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
98013 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
98014 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
98015 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
98016 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
98017 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
98018 +snapshot_read_22601 snapshot_read 3 22601 NULL
98019 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
98020 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
98021 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
98022 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
98023 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
98024 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
98025 +fill_gap_22681 fill_gap 0 22681 NULL
98026 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
98027 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
98028 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
98029 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
98030 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
98031 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
98032 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
98033 +print_frame_22769 print_frame 0 22769 NULL
98034 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
98035 +retu_write_22800 retu_write 2 22800 NULL
98036 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
98037 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
98038 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
98039 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
98040 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
98041 +create_attr_set_22861 create_attr_set 1 22861 NULL
98042 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
98043 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
98044 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
98045 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
98046 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
98047 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
98048 +vme_get_size_22964 vme_get_size 0 22964 NULL
98049 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
98050 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
98051 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
98052 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
98053 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
98054 +st_status_23032 st_status 5 23032 NULL
98055 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
98056 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
98057 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
98058 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
98059 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
98060 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
98061 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
98062 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
98063 +fls_long_23096 fls_long 0 23096 NULL
98064 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
98065 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
98066 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
98067 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
98068 +__clear_user_23118 __clear_user 0 23118 NULL
98069 +dm_write_async_23120 dm_write_async 3 23120 NULL
98070 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
98071 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
98072 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
98073 +read_file_ani_23161 read_file_ani 3 23161 NULL
98074 +ioremap_23172 ioremap 1-2 23172 NULL
98075 +usblp_write_23178 usblp_write 3 23178 NULL
98076 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
98077 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
98078 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
98079 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
98080 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
98081 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
98082 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
98083 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
98084 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
98085 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
98086 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
98087 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
98088 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
98089 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
98090 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
98091 +doc_probe_23285 doc_probe 1 23285 NULL
98092 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
98093 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
98094 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
98095 +page_readlink_23346 page_readlink 3 23346 NULL
98096 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
98097 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
98098 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
98099 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
98100 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
98101 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
98102 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
98103 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
98104 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
98105 +event_filter_read_23494 event_filter_read 3 23494 NULL
98106 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
98107 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
98108 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
98109 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
98110 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
98111 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
98112 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
98113 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
98114 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
98115 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
98116 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
98117 +sInW_23663 sInW 0 23663 NULL
98118 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
98119 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
98120 +cx18_read_23699 cx18_read 3 23699 NULL
98121 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
98122 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
98123 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
98124 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
98125 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
98126 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
98127 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
98128 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
98129 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
98130 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
98131 +p54_init_common_23850 p54_init_common 1 23850 NULL
98132 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
98133 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
98134 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
98135 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
98136 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
98137 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
98138 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
98139 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
98140 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
98141 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
98142 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
98143 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
98144 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
98145 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
98146 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
98147 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
98148 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
98149 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
98150 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
98151 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
98152 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
98153 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
98154 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
98155 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
98156 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
98157 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
98158 +mpu401_read_24126 mpu401_read 3 24126 NULL
98159 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
98160 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
98161 +adu_read_24177 adu_read 3 24177 NULL
98162 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
98163 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
98164 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
98165 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
98166 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
98167 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
98168 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
98169 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
98170 +thin_status_24278 thin_status 5 24278 NULL
98171 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
98172 +msg_size_24288 msg_size 0 24288 NULL
98173 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
98174 +map_page_24298 map_page 3-4 24298 NULL
98175 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
98176 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
98177 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
98178 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
98179 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
98180 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
98181 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
98182 +igetword_24373 igetword 0 24373 NULL
98183 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
98184 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
98185 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
98186 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
98187 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
98188 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
98189 +smk_user_access_24440 smk_user_access 3 24440 NULL
98190 +page_address_24444 page_address 0 24444 NULL
98191 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
98192 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
98193 +pd_video_read_24510 pd_video_read 3 24510 NULL
98194 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
98195 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
98196 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
98197 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
98198 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
98199 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
98200 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
98201 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
98202 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
98203 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
98204 +context_alloc_24645 context_alloc 3 24645 NULL
98205 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
98206 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
98207 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
98208 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
98209 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
98210 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
98211 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
98212 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
98213 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
98214 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
98215 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
98216 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
98217 +cache_read_24790 cache_read 3 24790 NULL
98218 +unpack_str_24798 unpack_str 0 24798 NULL
98219 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
98220 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
98221 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
98222 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
98223 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
98224 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
98225 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
98226 +queues_read_24877 queues_read 3 24877 NULL
98227 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
98228 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
98229 +next_token_24929 next_token 0 24929 NULL
98230 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
98231 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
98232 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
98233 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
98234 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
98235 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
98236 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
98237 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
98238 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
98239 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
98240 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
98241 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
98242 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
98243 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
98244 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
98245 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
98246 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
98247 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
98248 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
98249 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
98250 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
98251 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
98252 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
98253 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
98254 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
98255 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
98256 +stripe_status_25259 stripe_status 5 25259 NULL
98257 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
98258 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
98259 +vfs_writev_25278 vfs_writev 3 25278 NULL
98260 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
98261 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
98262 +help_25316 help 5 25316 NULL nohasharray
98263 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
98264 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
98265 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
98266 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
98267 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
98268 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
98269 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
98270 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
98271 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
98272 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
98273 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
98274 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
98275 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
98276 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
98277 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
98278 +sb_permission_25523 sb_permission 0 25523 NULL
98279 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
98280 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
98281 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
98282 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
98283 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
98284 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
98285 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
98286 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
98287 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
98288 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
98289 +__direct_map_25647 __direct_map 5-6 25647 NULL
98290 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
98291 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
98292 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
98293 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
98294 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
98295 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
98296 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
98297 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
98298 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
98299 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
98300 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
98301 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
98302 +sg_read_25799 sg_read 3 25799 NULL
98303 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
98304 +system_enable_read_25815 system_enable_read 3 25815 NULL
98305 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
98306 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
98307 +parport_read_25855 parport_read 0 25855 NULL
98308 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
98309 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
98310 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
98311 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
98312 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
98313 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
98314 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
98315 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
98316 +rcname_read_25919 rcname_read 3 25919 NULL
98317 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
98318 +key_flags_read_25931 key_flags_read 3 25931 NULL
98319 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
98320 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
98321 +flush_25957 flush 2 25957 NULL
98322 +video_register_device_25971 video_register_device 3 25971 NULL
98323 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
98324 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
98325 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
98326 +mirror_status_26010 mirror_status 5 26010 NULL
98327 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
98328 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
98329 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
98330 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
98331 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
98332 +tun_do_read_26047 tun_do_read 5 26047 NULL
98333 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
98334 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
98335 +cpumask_next_26096 cpumask_next 1 26096 NULL
98336 +skb_cow_26138 skb_cow 2 26138 NULL
98337 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
98338 +__fswab64_26155 __fswab64 0 26155 NULL
98339 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
98340 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
98341 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
98342 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
98343 +disk_devt_26180 disk_devt 0 26180 NULL
98344 +get_registers_26187 get_registers 3 26187 NULL
98345 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
98346 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
98347 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
98348 +mce_write_26201 mce_write 3 26201 NULL
98349 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
98350 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
98351 +bio_split_26235 bio_split 2 26235 NULL
98352 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
98353 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
98354 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
98355 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
98356 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
98357 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
98358 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
98359 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
98360 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
98361 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
98362 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
98363 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
98364 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
98365 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
98366 +read_vmcore_26501 read_vmcore 3 26501 NULL
98367 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
98368 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
98369 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
98370 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
98371 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
98372 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
98373 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
98374 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
98375 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
98376 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
98377 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
98378 +mmap_region_26649 mmap_region 0-2 26649 NULL
98379 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
98380 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
98381 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
98382 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
98383 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
98384 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
98385 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
98386 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
98387 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
98388 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
98389 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
98390 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
98391 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
98392 +smk_write_load_26829 smk_write_load 3 26829 NULL
98393 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
98394 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
98395 +scnprint_id_26842 scnprint_id 3 26842 NULL
98396 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
98397 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
98398 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
98399 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
98400 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
98401 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
98402 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
98403 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
98404 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
98405 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
98406 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
98407 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
98408 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
98409 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
98410 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
98411 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
98412 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
98413 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
98414 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
98415 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
98416 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
98417 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
98418 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
98419 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
98420 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
98421 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
98422 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
98423 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
98424 +pms_capture_27142 pms_capture 4 27142 NULL
98425 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
98426 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
98427 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
98428 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
98429 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
98430 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
98431 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
98432 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
98433 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
98434 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
98435 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
98436 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
98437 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
98438 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
98439 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
98440 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
98441 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
98442 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
98443 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
98444 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
98445 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
98446 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
98447 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
98448 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
98449 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
98450 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
98451 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
98452 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
98453 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
98454 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
98455 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
98456 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
98457 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
98458 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
98459 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
98460 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
98461 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
98462 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
98463 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
98464 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
98465 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
98466 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
98467 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
98468 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
98469 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
98470 +qword_get_27670 qword_get 0 27670 NULL
98471 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
98472 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
98473 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
98474 +evm_write_key_27715 evm_write_key 3 27715 NULL
98475 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
98476 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
98477 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
98478 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
98479 +kcalloc_27770 kcalloc 1-2 27770 NULL
98480 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
98481 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
98482 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
98483 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
98484 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
98485 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
98486 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
98487 +read_profile_27859 read_profile 3 27859 NULL
98488 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
98489 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
98490 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
98491 +gluebi_write_27905 gluebi_write 3 27905 NULL
98492 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
98493 +bm_find_next_27929 bm_find_next 2 27929 NULL
98494 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
98495 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
98496 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
98497 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
98498 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
98499 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
98500 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
98501 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
98502 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
98503 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
98504 +pool_status_28055 pool_status 5 28055 NULL
98505 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
98506 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
98507 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
98508 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
98509 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
98510 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
98511 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
98512 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
98513 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
98514 +video_read_28148 video_read 3 28148 NULL
98515 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
98516 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
98517 +vread_28173 vread 0 28173 NULL
98518 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
98519 +d_path_28198 d_path 0 28198 NULL
98520 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
98521 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
98522 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
98523 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
98524 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
98525 +usemap_size_28281 usemap_size 0 28281 NULL
98526 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
98527 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
98528 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
98529 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
98530 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
98531 +snapshot_write_28351 snapshot_write 3 28351 NULL
98532 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
98533 +sys_writev_28384 sys_writev 3 28384 NULL
98534 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
98535 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
98536 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
98537 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
98538 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
98539 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
98540 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
98541 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
98542 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
98543 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
98544 +max_response_pages_28492 max_response_pages 0 28492 NULL
98545 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
98546 +__next_node_28521 __next_node 1 28521 NULL
98547 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
98548 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
98549 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
98550 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
98551 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
98552 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
98553 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
98554 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
98555 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
98556 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
98557 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
98558 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
98559 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
98560 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
98561 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
98562 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
98563 +_set_range_28627 _set_range 3 28627 NULL
98564 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
98565 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
98566 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
98567 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
98568 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
98569 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
98570 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
98571 +spi_execute_28736 spi_execute 5 28736 NULL
98572 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
98573 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
98574 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
98575 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
98576 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
98577 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
98578 +sel_write_member_28800 sel_write_member 3 28800 NULL
98579 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
98580 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
98581 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
98582 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
98583 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
98584 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
98585 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
98586 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
98587 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
98588 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
98589 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
98590 +push_rx_28939 push_rx 3 28939 NULL
98591 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
98592 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
98593 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
98594 +bin_uuid_28999 bin_uuid 3 28999 NULL
98595 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
98596 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
98597 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
98598 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
98599 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
98600 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
98601 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
98602 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
98603 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
98604 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
98605 +snprintf_29125 snprintf 0 29125 NULL
98606 +iov_shorten_29130 iov_shorten 0 29130 NULL
98607 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
98608 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
98609 +reshape_ring_29147 reshape_ring 2 29147 NULL
98610 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
98611 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
98612 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
98613 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
98614 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
98615 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
98616 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
98617 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
98618 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
98619 +recover_peb_29238 recover_peb 6-7 29238 NULL
98620 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
98621 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
98622 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
98623 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
98624 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
98625 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
98626 +tun_put_user_29337 tun_put_user 5 29337 NULL
98627 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
98628 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
98629 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
98630 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
98631 +mempool_create_29437 mempool_create 1 29437 NULL
98632 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
98633 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
98634 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
98635 +do_register_entry_29478 do_register_entry 4 29478 NULL
98636 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
98637 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
98638 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
98639 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
98640 +ftrace_write_29551 ftrace_write 3 29551 NULL
98641 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
98642 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
98643 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
98644 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
98645 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
98646 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
98647 +slots_per_page_29601 slots_per_page 0 29601 NULL
98648 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
98649 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
98650 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
98651 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
98652 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
98653 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
98654 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
98655 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
98656 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
98657 +probes_write_29711 probes_write 3 29711 NULL
98658 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
98659 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
98660 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
98661 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
98662 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
98663 +dbAlloc_29794 dbAlloc 0 29794 NULL
98664 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
98665 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
98666 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
98667 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
98668 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
98669 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
98670 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
98671 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
98672 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
98673 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
98674 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
98675 +check586_29914 check586 2 29914 NULL
98676 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
98677 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
98678 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
98679 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
98680 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
98681 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
98682 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
98683 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
98684 +drp_wmove_30043 drp_wmove 4 30043 NULL
98685 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
98686 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
98687 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
98688 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
98689 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98690 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98691 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98692 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98693 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98694 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98695 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98696 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98697 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
98698 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98699 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98700 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98701 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98702 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98703 +compat_readv_30273 compat_readv 3 30273 NULL
98704 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98705 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
98706 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98707 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98708 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98709 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98710 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98711 +resource_from_user_30341 resource_from_user 3 30341 NULL
98712 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98713 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
98714 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98715 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98716 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98717 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98718 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98719 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98720 +enable_write_30456 enable_write 3 30456 NULL
98721 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98722 +urandom_read_30462 urandom_read 3 30462 NULL
98723 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98724 +write_head_30481 write_head 4 30481 NULL
98725 +adu_write_30487 adu_write 3 30487 NULL
98726 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
98727 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98728 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98729 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98730 +set_le_30581 set_le 4 30581 NULL
98731 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98732 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
98733 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
98734 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
98735 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
98736 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
98737 +agp_remap_30665 agp_remap 2 30665 NULL
98738 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
98739 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
98740 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98741 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98742 +snapshot_status_30744 snapshot_status 5 30744 NULL
98743 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
98744 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98745 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
98746 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98747 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98748 +create_subvol_30836 create_subvol 4 30836 NULL
98749 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98750 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
98751 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
98752 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98753 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98754 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
98755 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
98756 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98757 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98758 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98759 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98760 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98761 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98762 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98763 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98764 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98765 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98766 +sys_mincore_31079 sys_mincore 1 31079 NULL
98767 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98768 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98769 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
98770 +depth_read_31112 depth_read 3 31112 NULL
98771 +ssb_read16_31139 ssb_read16 0 31139 NULL
98772 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98773 +size_inside_page_31141 size_inside_page 0 31141 NULL
98774 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98775 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98776 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98777 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98778 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98779 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98780 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98781 +__read_reg_31216 __read_reg 0 31216 NULL
98782 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98783 +cyy_readb_31240 cyy_readb 0 31240 NULL
98784 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98785 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98786 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
98787 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98788 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98789 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98790 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
98791 +command_file_write_31318 command_file_write 3 31318 NULL
98792 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
98793 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98794 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
98795 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98796 +inb_31388 inb 0 31388 NULL
98797 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98798 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98799 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98800 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98801 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98802 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98803 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
98804 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98805 +do_fcntl_31468 do_fcntl 3 31468 NULL
98806 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98807 +alg_setkey_31485 alg_setkey 3 31485 NULL
98808 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98809 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98810 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
98811 +hidraw_write_31536 hidraw_write 3 31536 NULL
98812 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98813 +usbvision_read_31555 usbvision_read 3 31555 NULL
98814 +normalize_31566 normalize 0-1-2 31566 NULL
98815 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98816 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98817 +osst_write_31581 osst_write 3 31581 NULL
98818 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98819 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98820 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98821 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98822 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98823 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98824 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98825 +__lgread_31668 __lgread 4 31668 NULL
98826 +symbol_string_31670 symbol_string 0 31670 NULL
98827 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98828 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98829 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98830 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98831 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
98832 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98833 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98834 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98835 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98836 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98837 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
98838 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98839 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98840 +get_count_order_31800 get_count_order 0 31800 NULL
98841 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98842 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98843 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98844 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98845 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98846 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98847 +xattr_permission_31907 xattr_permission 0 31907 NULL
98848 +new_dir_31919 new_dir 3 31919 NULL
98849 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98850 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98851 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98852 +vb2_write_31948 vb2_write 3 31948 NULL
98853 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98854 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
98855 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98856 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98857 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98858 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98859 +calc_hmac_32010 calc_hmac 3 32010 NULL
98860 +aead_len_32021 aead_len 0 32021 NULL
98861 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98862 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98863 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98864 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98865 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98866 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98867 +bio_alloc_32095 bio_alloc 2 32095 NULL
98868 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98869 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98870 +disk_status_32120 disk_status 4 32120 NULL
98871 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
98872 +venus_link_32165 venus_link 5 32165 NULL
98873 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
98874 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98875 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98876 +load_header_32183 load_header 0 32183 NULL
98877 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98878 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98879 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98880 +lm3533_write_32236 lm3533_write 2 32236 NULL
98881 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98882 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98883 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98884 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98885 +hex_string_32310 hex_string 0 32310 NULL
98886 +flakey_status_32315 flakey_status 5 32315 NULL
98887 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98888 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98889 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98890 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98891 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
98892 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98893 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98894 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
98895 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98896 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98897 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98898 +log_text_32428 log_text 0 32428 NULL
98899 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98900 +hid_input_report_32458 hid_input_report 4 32458 NULL
98901 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
98902 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98903 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98904 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98905 +disconnect_32521 disconnect 4 32521 NULL
98906 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98907 +ilo_read_32531 ilo_read 3 32531 NULL
98908 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
98909 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
98910 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98911 +__first_node_32558 __first_node 0 32558 NULL
98912 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98913 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98914 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98915 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98916 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98917 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98918 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98919 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98920 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98921 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98922 +kvmalloc_32646 kvmalloc 1 32646 NULL
98923 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98924 +generic_readlink_32654 generic_readlink 3 32654 NULL
98925 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98926 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
98927 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98928 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98929 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98930 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98931 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98932 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98933 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98934 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98935 +vga_rseq_32848 vga_rseq 0 32848 NULL
98936 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98937 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98938 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98939 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98940 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98941 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98942 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98943 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98944 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98945 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98946 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98947 +compat_filldir_32999 compat_filldir 3 32999 NULL
98948 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98949 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
98950 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98951 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98952 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98953 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98954 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98955 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98956 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98957 +write_node_33121 write_node 4 33121 NULL
98958 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98959 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98960 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98961 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98962 +pp_read_33210 pp_read 3 33210 NULL
98963 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98964 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98965 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98966 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98967 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98968 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
98969 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98970 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98971 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98972 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98973 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98974 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98975 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98976 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
98977 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98978 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98979 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98980 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98981 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98982 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98983 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98984 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98985 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98986 +create_entry_33479 create_entry 2 33479 NULL
98987 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98988 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98989 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98990 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98991 +res_counter_read_33499 res_counter_read 4 33499 NULL
98992 +fb_read_33506 fb_read 3 33506 NULL
98993 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98994 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98995 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98996 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98997 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98998 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98999 +dup_array_33551 dup_array 3 33551 NULL
99000 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
99001 +count_subheaders_33591 count_subheaders 0 33591 NULL
99002 +scsi_execute_33596 scsi_execute 5 33596 NULL
99003 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
99004 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
99005 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
99006 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
99007 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
99008 +inw_p_33668 inw_p 0 33668 NULL
99009 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
99010 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
99011 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
99012 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
99013 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
99014 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
99015 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
99016 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
99017 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
99018 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
99019 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
99020 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
99021 +Read_hfc_33755 Read_hfc 0 33755 NULL
99022 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
99023 +hashtab_create_33769 hashtab_create 3 33769 NULL
99024 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
99025 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
99026 +find_next_offset_33804 find_next_offset 3 33804 NULL
99027 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
99028 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
99029 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
99030 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
99031 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
99032 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
99033 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
99034 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
99035 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
99036 +config_proc_write_33878 config_proc_write 3 33878 NULL
99037 +get_user_pages_33908 get_user_pages 0 33908 NULL
99038 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
99039 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
99040 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
99041 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
99042 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
99043 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
99044 +ppp_write_34034 ppp_write 3 34034 NULL
99045 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
99046 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
99047 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
99048 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
99049 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
99050 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
99051 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
99052 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
99053 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
99054 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
99055 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
99056 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
99057 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
99058 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
99059 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
99060 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
99061 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
99062 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
99063 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
99064 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
99065 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
99066 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
99067 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
99068 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
99069 +ea_read_34378 ea_read 0 34378 NULL
99070 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
99071 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
99072 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
99073 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
99074 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
99075 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
99076 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
99077 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
99078 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
99079 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
99080 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
99081 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
99082 +alloc_buf_34532 alloc_buf 1 34532 NULL
99083 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
99084 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
99085 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
99086 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
99087 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
99088 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
99089 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
99090 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
99091 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
99092 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
99093 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
99094 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
99095 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
99096 +port_print_34704 port_print 3 34704 NULL
99097 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
99098 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
99099 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
99100 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
99101 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
99102 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
99103 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
99104 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
99105 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
99106 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
99107 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
99108 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
99109 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
99110 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
99111 +msg_print_text_34889 msg_print_text 0 34889 NULL
99112 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
99113 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
99114 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
99115 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
99116 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
99117 +Realloc_34961 Realloc 2 34961 NULL
99118 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
99119 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
99120 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
99121 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
99122 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
99123 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
99124 +store_ifalias_35088 store_ifalias 4 35088 NULL
99125 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
99126 +capi_write_35104 capi_write 3 35104 NULL nohasharray
99127 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
99128 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
99129 +pointer_35138 pointer 0 35138 NULL
99130 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
99131 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
99132 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
99133 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
99134 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
99135 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
99136 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
99137 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
99138 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
99139 +set_fd_set_35249 set_fd_set 1 35249 NULL
99140 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
99141 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
99142 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
99143 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
99144 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
99145 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
99146 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
99147 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
99148 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
99149 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
99150 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
99151 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
99152 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
99153 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
99154 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
99155 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
99156 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
99157 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
99158 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
99159 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
99160 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
99161 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
99162 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
99163 +async_setkey_35521 async_setkey 3 35521 NULL
99164 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
99165 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
99166 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
99167 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
99168 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
99169 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
99170 +ReadZReg_35604 ReadZReg 0 35604 NULL
99171 +kernel_readv_35617 kernel_readv 3 35617 NULL
99172 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
99173 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
99174 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
99175 +store_debug_level_35652 store_debug_level 3 35652 NULL
99176 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
99177 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
99178 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
99179 +dm_table_create_35687 dm_table_create 3 35687 NULL
99180 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
99181 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
99182 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
99183 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
99184 +read_file_stations_35795 read_file_stations 3 35795 NULL
99185 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
99186 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
99187 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
99188 +fls64_35862 fls64 0 35862 NULL
99189 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
99190 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
99191 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
99192 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
99193 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
99194 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
99195 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
99196 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
99197 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
99198 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
99199 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
99200 +acl_alloc_35979 acl_alloc 1 35979 NULL
99201 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
99202 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
99203 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
99204 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
99205 +sys_init_module_36047 sys_init_module 2 36047 NULL
99206 +account_shadowed_36048 account_shadowed 2 36048 NULL
99207 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
99208 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
99209 +write_emulate_36065 write_emulate 2-4 36065 NULL
99210 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
99211 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
99212 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
99213 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
99214 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
99215 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
99216 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
99217 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
99218 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
99219 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
99220 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
99221 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
99222 +twl_set_36154 twl_set 2 36154 NULL
99223 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
99224 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
99225 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
99226 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
99227 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
99228 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
99229 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
99230 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
99231 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
99232 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
99233 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
99234 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
99235 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
99236 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
99237 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
99238 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
99239 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
99240 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
99241 +lc_create_36332 lc_create 4 36332 NULL
99242 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
99243 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
99244 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
99245 +to_sector_36361 to_sector 0-1 36361 NULL
99246 +tunables_read_36385 tunables_read 3 36385 NULL
99247 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
99248 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
99249 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
99250 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
99251 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
99252 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
99253 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
99254 +get_param_l_36518 get_param_l 0 36518 NULL
99255 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
99256 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
99257 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
99258 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
99259 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
99260 +get_entry_len_36549 get_entry_len 0 36549 NULL
99261 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
99262 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
99263 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
99264 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
99265 +__erst_read_36579 __erst_read 0 36579 NULL
99266 +put_cmsg_36589 put_cmsg 4 36589 NULL
99267 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
99268 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
99269 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
99270 +format_decode_36638 format_decode 0 36638 NULL
99271 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
99272 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
99273 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
99274 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
99275 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
99276 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
99277 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
99278 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
99279 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
99280 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
99281 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
99282 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
99283 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
99284 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
99285 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
99286 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
99287 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
99288 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
99289 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
99290 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
99291 +cm_write_36858 cm_write 3 36858 NULL
99292 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
99293 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
99294 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
99295 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
99296 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
99297 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
99298 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
99299 +div_u64_36951 div_u64 0 36951 NULL
99300 +write_leb_36957 write_leb 5 36957 NULL
99301 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
99302 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
99303 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
99304 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
99305 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
99306 +setxattr_37006 setxattr 4 37006 NULL
99307 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
99308 +parse_command_37079 parse_command 2 37079 NULL
99309 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
99310 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
99311 +tun_get_user_37094 tun_get_user 5 37094 NULL
99312 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
99313 +msg_word_37164 msg_word 0 37164 NULL
99314 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
99315 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
99316 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
99317 +__do_replace_37227 __do_replace 5 37227 NULL
99318 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
99319 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
99320 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
99321 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
99322 +c101_run_37279 c101_run 2 37279 NULL
99323 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
99324 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
99325 +send_msg_37323 send_msg 4 37323 NULL
99326 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
99327 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
99328 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
99329 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
99330 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
99331 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
99332 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
99333 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
99334 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
99335 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
99336 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
99337 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
99338 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
99339 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
99340 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
99341 +get_est_timing_37484 get_est_timing 0 37484 NULL
99342 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
99343 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
99344 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
99345 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
99346 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
99347 +hdr_size_37536 hdr_size 0 37536 NULL
99348 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
99349 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
99350 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
99351 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
99352 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
99353 +alloc_fd_37637 alloc_fd 1 37637 NULL
99354 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
99355 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
99356 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
99357 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
99358 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
99359 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
99360 +nametbl_header_37698 nametbl_header 2 37698 NULL
99361 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
99362 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
99363 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
99364 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
99365 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
99366 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
99367 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
99368 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
99369 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
99370 +deny_write_access_37813 deny_write_access 0 37813 NULL
99371 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
99372 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
99373 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
99374 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
99375 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
99376 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
99377 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
99378 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
99379 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
99380 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
99381 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
99382 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
99383 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
99384 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
99385 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
99386 +vfs_readv_38011 vfs_readv 3 38011 NULL
99387 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
99388 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
99389 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
99390 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
99391 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
99392 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
99393 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
99394 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
99395 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
99396 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
99397 +ep0_read_38095 ep0_read 3 38095 NULL
99398 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
99399 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
99400 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
99401 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
99402 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
99403 +cdev_add_38176 cdev_add 2-3 38176 NULL
99404 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
99405 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
99406 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
99407 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
99408 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
99409 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
99410 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
99411 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
99412 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
99413 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
99414 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
99415 +verity_status_38273 verity_status 5 38273 NULL
99416 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
99417 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
99418 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
99419 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
99420 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
99421 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
99422 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
99423 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
99424 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
99425 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
99426 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
99427 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
99428 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
99429 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
99430 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
99431 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
99432 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
99433 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
99434 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
99435 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
99436 +dev_names_read_38509 dev_names_read 3 38509 NULL
99437 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
99438 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
99439 +set_queue_count_38519 set_queue_count 0 38519 NULL
99440 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
99441 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
99442 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
99443 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
99444 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
99445 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
99446 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
99447 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
99448 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
99449 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
99450 +delay_status_38606 delay_status 5 38606 NULL
99451 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
99452 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
99453 +cma_create_area_38642 cma_create_area 2 38642 NULL
99454 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
99455 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
99456 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
99457 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
99458 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
99459 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
99460 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
99461 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
99462 +udf_readpages_38761 udf_readpages 4 38761 NULL
99463 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
99464 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
99465 +err_decode_38804 err_decode 2 38804 NULL
99466 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
99467 +sys_select_38827 sys_select 1 38827 NULL
99468 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
99469 +direct_entry_38836 direct_entry 3 38836 NULL
99470 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
99471 +interfaces_38859 interfaces 2 38859 NULL
99472 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
99473 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
99474 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
99475 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
99476 +__fswab16_38898 __fswab16 0 38898 NULL
99477 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
99478 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
99479 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
99480 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
99481 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
99482 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
99483 +udf_new_block_38999 udf_new_block 4 38999 NULL
99484 +get_nodes_39012 get_nodes 3 39012 NULL
99485 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
99486 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
99487 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
99488 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
99489 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
99490 +tun_get_user_39099 tun_get_user 4 39099 NULL
99491 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
99492 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
99493 +ea_foreach_39133 ea_foreach 0 39133 NULL
99494 +generic_permission_39150 generic_permission 0 39150 NULL
99495 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
99496 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
99497 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
99498 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
99499 +init_list_set_39188 init_list_set 2-3 39188 NULL
99500 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
99501 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
99502 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
99503 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
99504 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
99505 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
99506 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
99507 +drm_order_39244 drm_order 0 39244 NULL
99508 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
99509 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
99510 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
99511 +__skb_cow_39254 __skb_cow 2 39254 NULL
99512 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
99513 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
99514 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
99515 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
99516 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
99517 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
99518 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
99519 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
99520 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
99521 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
99522 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
99523 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
99524 +__send_to_port_39386 __send_to_port 3 39386 NULL
99525 +user_power_read_39414 user_power_read 3 39414 NULL
99526 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
99527 +sys_semop_39457 sys_semop 3 39457 NULL
99528 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
99529 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
99530 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
99531 +int_proc_write_39542 int_proc_write 3 39542 NULL
99532 +pp_write_39554 pp_write 3 39554 NULL
99533 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
99534 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
99535 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
99536 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
99537 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
99538 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
99539 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
99540 +ext_depth_39607 ext_depth 0 39607 NULL
99541 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
99542 +sdio_readb_39618 sdio_readb 0 39618 NULL
99543 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
99544 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
99545 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
99546 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
99547 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
99548 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
99549 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
99550 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
99551 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
99552 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
99553 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
99554 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
99555 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
99556 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
99557 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
99558 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
99559 +pkt_add_39897 pkt_add 3 39897 NULL
99560 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
99561 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
99562 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
99563 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
99564 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
99565 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
99566 +__spi_async_39932 __spi_async 0 39932 NULL
99567 +__get_order_39935 __get_order 0 39935 NULL
99568 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
99569 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
99570 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
99571 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
99572 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
99573 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
99574 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
99575 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
99576 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
99577 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
99578 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
99579 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
99580 +add_tty_40055 add_tty 1 40055 NULL nohasharray
99581 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
99582 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
99583 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
99584 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
99585 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
99586 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
99587 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
99588 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
99589 +pt_write_40159 pt_write 3 40159 NULL
99590 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
99591 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
99592 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
99593 +allocate_probes_40204 allocate_probes 1 40204 NULL
99594 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
99595 +compat_put_long_40214 compat_put_long 1 40214 NULL
99596 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
99597 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
99598 +osst_read_40237 osst_read 3 40237 NULL
99599 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
99600 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
99601 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
99602 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
99603 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
99604 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
99605 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
99606 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
99607 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
99608 +mmio_read_40348 mmio_read 4 40348 NULL
99609 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
99610 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
99611 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
99612 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
99613 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
99614 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
99615 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
99616 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
99617 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
99618 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
99619 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
99620 +tty_write_room_40495 tty_write_room 0 40495 NULL
99621 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
99622 +sg_phys_40507 sg_phys 0 40507 NULL
99623 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
99624 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
99625 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
99626 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
99627 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
99628 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
99629 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
99630 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
99631 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
99632 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
99633 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
99634 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
99635 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
99636 +fops_read_40672 fops_read 3 40672 NULL
99637 +tps80031_write_40678 tps80031_write 3 40678 NULL
99638 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
99639 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
99640 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
99641 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
99642 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
99643 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
99644 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
99645 +card_send_command_40757 card_send_command 3 40757 NULL
99646 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
99647 +pg_write_40766 pg_write 3 40766 NULL
99648 +show_list_40775 show_list 3 40775 NULL
99649 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
99650 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
99651 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
99652 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
99653 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
99654 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
99655 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
99656 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
99657 +read_file_queue_40895 read_file_queue 3 40895 NULL
99658 +waiters_read_40902 waiters_read 3 40902 NULL
99659 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
99660 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
99661 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
99662 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
99663 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
99664 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
99665 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
99666 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
99667 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
99668 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
99669 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
99670 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
99671 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
99672 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
99673 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
99674 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
99675 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
99676 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
99677 +dma_attach_41094 dma_attach 5-6 41094 NULL
99678 +provide_user_output_41105 provide_user_output 3 41105 NULL
99679 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
99680 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
99681 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
99682 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
99683 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
99684 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
99685 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
99686 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
99687 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
99688 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
99689 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99690 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99691 +erst_read_41260 erst_read 0 41260 NULL
99692 +__fprog_create_41263 __fprog_create 2 41263 NULL
99693 +alloc_context_41283 alloc_context 1 41283 NULL
99694 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99695 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99696 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99697 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99698 +kmp_init_41373 kmp_init 2 41373 NULL
99699 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99700 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99701 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99702 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99703 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99704 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99705 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
99706 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99707 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99708 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99709 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99710 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
99711 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99712 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99713 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99714 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99715 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99716 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99717 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99718 +gserial_setup_41558 gserial_setup 2 41558 NULL
99719 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99720 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99721 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99722 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99723 +vga_io_r_41609 vga_io_r 0 41609 NULL
99724 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99725 +a2mp_send_41615 a2mp_send 4 41615 NULL
99726 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99727 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99728 +get_std_timing_41654 get_std_timing 0 41654 NULL
99729 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99730 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
99731 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
99732 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
99733 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
99734 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
99735 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
99736 +fillonedir_41746 fillonedir 3 41746 NULL
99737 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
99738 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
99739 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
99740 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99741 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99742 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99743 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
99744 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99745 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99746 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99747 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
99748 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99749 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99750 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99751 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99752 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99753 +portnames_read_41958 portnames_read 3 41958 NULL
99754 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99755 +dst_mtu_41969 dst_mtu 0 41969 NULL
99756 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99757 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99758 +lguest_map_42008 lguest_map 1-2 42008 NULL
99759 +pool_allocate_42012 pool_allocate 3 42012 NULL
99760 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99761 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99762 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99763 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99764 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99765 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99766 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99767 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99768 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99769 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99770 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99771 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
99772 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99773 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
99774 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99775 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99776 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99777 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99778 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99779 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99780 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99781 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99782 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99783 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99784 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99785 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99786 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99787 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99788 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
99789 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99790 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99791 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99792 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99793 +krng_get_random_42420 krng_get_random 3 42420 NULL
99794 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99795 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99796 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99797 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99798 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99799 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99800 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99801 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99802 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99803 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99804 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99805 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99806 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99807 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99808 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99809 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99810 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99811 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99812 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99813 +map_state_42602 map_state 1 42602 NULL nohasharray
99814 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99815 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99816 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99817 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99818 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99819 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
99820 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99821 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99822 +vb2_read_42703 vb2_read 3 42703 NULL
99823 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99824 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99825 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99826 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99827 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99828 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99829 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99830 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99831 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99832 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99833 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99834 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99835 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99836 +set_arg_42824 set_arg 3 42824 NULL
99837 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99838 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
99839 +prandom_u32_42853 prandom_u32 0 42853 NULL
99840 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99841 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99842 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99843 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99844 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99845 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99846 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99847 +hd_end_request_42904 hd_end_request 2 42904 NULL
99848 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99849 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99850 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99851 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99852 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99853 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99854 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99855 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99856 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99857 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99858 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99859 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99860 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99861 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99862 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99863 +uuid_string_43154 uuid_string 0 43154 NULL
99864 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99865 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99866 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99867 +process_measurement_43190 process_measurement 0 43190 NULL
99868 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99869 +uio_write_43202 uio_write 3 43202 NULL
99870 +iso_callback_43208 iso_callback 3 43208 NULL
99871 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99872 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99873 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99874 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99875 +fixup_leb_43256 fixup_leb 3 43256 NULL
99876 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99877 +evtchn_write_43278 evtchn_write 3 43278 NULL
99878 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99879 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99880 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99881 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99882 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99883 +xenfb_write_43412 xenfb_write 3 43412 NULL
99884 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
99885 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
99886 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99887 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99888 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99889 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99890 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99891 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99892 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99893 +do_readlink_43518 do_readlink 2 43518 NULL
99894 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99895 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99896 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99897 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99898 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99899 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99900 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99901 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99902 +proc_read_43614 proc_read 3 43614 NULL
99903 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99904 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
99905 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
99906 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99907 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99908 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99909 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
99910 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99911 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99912 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99913 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99914 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99915 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99916 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99917 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99918 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99919 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99920 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99921 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99922 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99923 +read_flush_43851 read_flush 3 43851 NULL
99924 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99925 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
99926 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
99927 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99928 +SendString_43928 SendString 3 43928 NULL
99929 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99930 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99931 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99932 +nla_reserve_43984 nla_reserve 3 43984 NULL
99933 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99934 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99935 +emit_flags_44006 emit_flags 4-3 44006 NULL
99936 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99937 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99938 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99939 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99940 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99941 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99942 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99943 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99944 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99945 +__set_free_44211 __set_free 2 44211 NULL
99946 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99947 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99948 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99949 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99950 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99951 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
99952 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
99953 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99954 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99955 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99956 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
99957 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99958 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99959 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99960 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99961 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99962 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99963 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99964 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99965 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99966 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99967 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99968 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99969 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99970 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99971 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99972 +spidev_write_44510 spidev_write 3 44510 NULL
99973 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99974 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99975 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
99976 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
99977 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99978 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99979 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
99980 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99981 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99982 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99983 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99984 +mpi_resize_44674 mpi_resize 2 44674 NULL
99985 +ts_read_44687 ts_read 3 44687 NULL
99986 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99987 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99988 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
99989 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
99990 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99991 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99992 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99993 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99994 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99995 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99996 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99997 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99998 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99999 +sisusb_write_44834 sisusb_write 3 44834 NULL
100000 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
100001 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
100002 +skb_availroom_44883 skb_availroom 0 44883 NULL
100003 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
100004 +do_tty_write_44896 do_tty_write 5 44896 NULL
100005 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
100006 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
100007 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
100008 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
100009 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
100010 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
100011 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
100012 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
100013 +sel_write_user_45060 sel_write_user 3 45060 NULL
100014 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
100015 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
100016 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
100017 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
100018 +usbdev_read_45114 usbdev_read 3 45114 NULL
100019 +send_to_tty_45141 send_to_tty 3 45141 NULL
100020 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
100021 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
100022 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
100023 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
100024 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
100025 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
100026 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
100027 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
100028 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
100029 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
100030 +add_child_45201 add_child 4 45201 NULL
100031 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
100032 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
100033 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
100034 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
100035 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
100036 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
100037 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
100038 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
100039 +keymap_store_45406 keymap_store 4 45406 NULL
100040 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
100041 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
100042 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
100043 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
100044 +__node_remap_45458 __node_remap 4 45458 NULL
100045 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
100046 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
100047 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
100048 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
100049 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
100050 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
100051 +clone_bio_45516 clone_bio 6 45516 NULL
100052 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
100053 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
100054 +copy_macs_45534 copy_macs 4 45534 NULL
100055 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
100056 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
100057 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
100058 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
100059 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
100060 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
100061 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
100062 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
100063 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
100064 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
100065 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
100066 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
100067 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
100068 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
100069 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
100070 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
100071 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
100072 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
100073 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
100074 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
100075 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
100076 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
100077 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
100078 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
100079 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
100080 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
100081 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
100082 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
100083 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
100084 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
100085 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
100086 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
100087 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
100088 +amthi_read_45831 amthi_read 4 45831 NULL
100089 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
100090 +isdn_write_45863 isdn_write 3 45863 NULL
100091 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
100092 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
100093 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
100094 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
100095 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
100096 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
100097 +alloc_mr_45935 alloc_mr 1 45935 NULL
100098 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
100099 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
100100 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
100101 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
100102 +get_free_entries_46030 get_free_entries 1 46030 NULL
100103 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
100104 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
100105 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
100106 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
100107 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
100108 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
100109 +slhc_toss_46066 slhc_toss 0 46066 NULL
100110 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
100111 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
100112 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
100113 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
100114 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
100115 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
100116 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
100117 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
100118 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
100119 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
100120 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
100121 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
100122 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
100123 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
100124 +dsp_write_46218 dsp_write 2 46218 NULL
100125 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
100126 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
100127 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
100128 +ReadReg_46277 ReadReg 0 46277 NULL
100129 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
100130 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
100131 +twl6040_write_46351 twl6040_write 2 46351 NULL
100132 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
100133 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
100134 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
100135 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
100136 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
100137 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
100138 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
100139 +filldir64_46469 filldir64 3 46469 NULL
100140 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
100141 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
100142 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
100143 +kmsg_read_46514 kmsg_read 3 46514 NULL
100144 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
100145 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
100146 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
100147 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
100148 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
100149 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
100150 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
100151 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
100152 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
100153 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
100154 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
100155 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
100156 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
100157 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
100158 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
100159 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
100160 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
100161 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
100162 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
100163 +prepare_copy_46725 prepare_copy 2 46725 NULL
100164 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
100165 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
100166 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
100167 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
100168 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
100169 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
100170 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
100171 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
100172 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
100173 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
100174 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
100175 +spi_async_46857 spi_async 0 46857 NULL
100176 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
100177 +vsnprintf_46863 vsnprintf 0 46863 NULL
100178 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
100179 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
100180 +rvmalloc_46873 rvmalloc 1 46873 NULL
100181 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
100182 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
100183 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
100184 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
100185 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
100186 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
100187 +fb_write_46924 fb_write 3 46924 NULL
100188 +raid_status_46930 raid_status 5 46930 NULL
100189 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
100190 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
100191 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
100192 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
100193 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
100194 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
100195 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
100196 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
100197 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
100198 +__map_single_47020 __map_single 3-4-7 47020 NULL
100199 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
100200 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
100201 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
100202 +fs_path_len_47060 fs_path_len 0 47060 NULL
100203 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
100204 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
100205 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
100206 +mousedev_read_47123 mousedev_read 3 47123 NULL
100207 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
100208 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
100209 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
100210 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
100211 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
100212 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
100213 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
100214 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
100215 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
100216 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
100217 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
100218 +l2headersize_47238 l2headersize 0 47238 NULL
100219 +options_write_47243 options_write 3 47243 NULL
100220 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
100221 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
100222 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
100223 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
100224 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
100225 +vsnprintf_47291 vsnprintf 0 47291 NULL
100226 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
100227 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
100228 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
100229 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
100230 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
100231 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
100232 +nametbl_list_47391 nametbl_list 2 47391 NULL
100233 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
100234 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
100235 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
100236 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
100237 +vzalloc_47421 vzalloc 1 47421 NULL
100238 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
100239 +newpart_47485 newpart 6 47485 NULL
100240 +core_sys_select_47494 core_sys_select 1 47494 NULL
100241 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
100242 +unlink_simple_47506 unlink_simple 3 47506 NULL
100243 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
100244 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
100245 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
100246 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
100247 +oz_events_read_47535 oz_events_read 3 47535 NULL
100248 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
100249 +cycx_setup_47562 cycx_setup 4 47562 NULL
100250 +read_ldt_47570 read_ldt 2 47570 NULL
100251 +pci_iomap_47575 pci_iomap 3 47575 NULL
100252 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
100253 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
100254 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
100255 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
100256 +uea_request_47613 uea_request 4 47613 NULL
100257 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
100258 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
100259 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
100260 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
100261 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
100262 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
100263 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
100264 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
100265 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
100266 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
100267 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
100268 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
100269 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
100270 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
100271 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
100272 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
100273 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
100274 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
100275 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
100276 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
100277 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
100278 +vhci_read_47878 vhci_read 3 47878 NULL
100279 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
100280 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
100281 +timeout_read_47915 timeout_read 3 47915 NULL
100282 +comedi_write_47926 comedi_write 3 47926 NULL
100283 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
100284 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
100285 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
100286 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
100287 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
100288 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
100289 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
100290 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
100291 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
100292 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
100293 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
100294 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
100295 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
100296 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
100297 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
100298 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
100299 +set_discoverable_48141 set_discoverable 4 48141 NULL
100300 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
100301 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
100302 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
100303 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
100304 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
100305 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
100306 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
100307 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
100308 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
100309 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
100310 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
100311 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
100312 +read_file_recv_48232 read_file_recv 3 48232 NULL
100313 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
100314 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
100315 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
100316 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
100317 +send_set_info_48288 send_set_info 7 48288 NULL
100318 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
100319 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
100320 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
100321 +hash_setkey_48310 hash_setkey 3 48310 NULL
100322 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
100323 +skb_add_data_48363 skb_add_data 3 48363 NULL
100324 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
100325 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
100326 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
100327 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
100328 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
100329 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
100330 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
100331 +send_control_msg_48498 send_control_msg 6 48498 NULL
100332 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
100333 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
100334 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
100335 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
100336 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
100337 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
100338 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
100339 +named_distribute_48544 named_distribute 4 48544 NULL
100340 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
100341 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
100342 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
100343 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
100344 +mtd_read_48655 mtd_read 0 48655 NULL
100345 +lc_create_48662 lc_create 3 48662 NULL
100346 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
100347 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
100348 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
100349 +altera_drscan_48698 altera_drscan 2 48698 NULL
100350 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
100351 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
100352 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
100353 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
100354 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
100355 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
100356 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
100357 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
100358 +azx_get_position_48841 azx_get_position 0 48841 NULL
100359 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
100360 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
100361 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
100362 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
100363 +get_num_ops_48886 get_num_ops 0 48886 NULL
100364 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
100365 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
100366 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
100367 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
100368 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
100369 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
100370 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
100371 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
100372 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
100373 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
100374 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
100375 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
100376 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
100377 +xd_rw_49020 xd_rw 3-4 49020 NULL
100378 +transient_status_49027 transient_status 4 49027 NULL
100379 +ubi_read_49061 ubi_read 0 49061 NULL
100380 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
100381 +calc_layout_49074 calc_layout 4 49074 NULL
100382 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
100383 +scsi_register_49094 scsi_register 2 49094 NULL
100384 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
100385 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
100386 +pt_read_49136 pt_read 3 49136 NULL
100387 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
100388 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
100389 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
100390 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
100391 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
100392 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
100393 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
100394 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
100395 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
100396 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
100397 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
100398 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
100399 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
100400 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
100401 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
100402 +uio_read_49300 uio_read 3 49300 NULL
100403 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
100404 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
100405 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
100406 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
100407 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
100408 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
100409 +px_raw_event_49371 px_raw_event 4 49371 NULL
100410 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
100411 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
100412 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
100413 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
100414 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
100415 +md_domain_init_49432 md_domain_init 2 49432 NULL
100416 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
100417 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
100418 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
100419 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
100420 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
100421 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
100422 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
100423 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
100424 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
100425 +smk_write_access_49561 smk_write_access 3 49561 NULL
100426 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
100427 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
100428 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
100429 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
100430 +heap_init_49617 heap_init 2 49617 NULL
100431 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
100432 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
100433 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
100434 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
100435 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
100436 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
100437 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
100438 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
100439 +check_frame_49741 check_frame 0 49741 NULL
100440 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
100441 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
100442 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
100443 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
100444 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
100445 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
100446 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
100447 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
100448 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
100449 +add_uuid_49831 add_uuid 4 49831 NULL
100450 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
100451 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
100452 +twl4030_write_49846 twl4030_write 2 49846 NULL
100453 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
100454 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
100455 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
100456 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
100457 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
100458 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
100459 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
100460 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
100461 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
100462 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
100463 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
100464 +__module_alloc_50004 __module_alloc 1 50004 NULL
100465 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
100466 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
100467 +isdn_read_50021 isdn_read 3 50021 NULL
100468 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
100469 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
100470 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
100471 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
100472 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
100473 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
100474 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
100475 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
100476 +read_file_slot_50111 read_file_slot 3 50111 NULL
100477 +copy_items_50140 copy_items 6 50140 NULL
100478 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
100479 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
100480 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
100481 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
100482 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
100483 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
100484 +odev_update_50169 odev_update 2 50169 NULL
100485 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
100486 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
100487 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
100488 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
100489 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
100490 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
100491 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
100492 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
100493 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
100494 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
100495 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
100496 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
100497 +do_launder_page_50329 do_launder_page 0 50329 NULL
100498 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
100499 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
100500 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
100501 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
100502 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
100503 +tpm_read_50344 tpm_read 3 50344 NULL
100504 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
100505 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
100506 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
100507 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
100508 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
100509 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
100510 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
100511 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
100512 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
100513 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
100514 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
100515 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
100516 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
100517 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
100518 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
100519 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
100520 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
100521 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
100522 +fat_readpages_50582 fat_readpages 4 50582 NULL
100523 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
100524 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
100525 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
100526 +__ffs_50625 __ffs 0 50625 NULL
100527 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
100528 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
100529 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
100530 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
100531 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
100532 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
100533 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
100534 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
100535 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
100536 +skb_padto_50759 skb_padto 2 50759 NULL
100537 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
100538 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
100539 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
100540 +tpm_write_50798 tpm_write 3 50798 NULL
100541 +tun_do_read_50800 tun_do_read 4 50800 NULL
100542 +write_flush_50803 write_flush 3 50803 NULL
100543 +dvb_play_50814 dvb_play 3 50814 NULL
100544 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
100545 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
100546 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
100547 +dma_attach_50831 dma_attach 6-7 50831 NULL
100548 +SetArea_50835 SetArea 4 50835 NULL nohasharray
100549 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
100550 +self_check_write_50856 self_check_write 5 50856 NULL
100551 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
100552 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
100553 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
100554 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
100555 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
100556 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
100557 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
100558 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
100559 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
100560 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
100561 +timeout_write_50991 timeout_write 3 50991 NULL
100562 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
100563 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
100564 +proc_write_51003 proc_write 3 51003 NULL
100565 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
100566 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
100567 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
100568 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
100569 +dump_midi_51040 dump_midi 3 51040 NULL
100570 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
100571 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
100572 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
100573 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
100574 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
100575 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
100576 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
100577 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
100578 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
100579 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
100580 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
100581 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
100582 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
100583 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
100584 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
100585 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
100586 +tipc_send_51238 tipc_send 4 51238 NULL
100587 +drm_property_create_51239 drm_property_create 4 51239 NULL
100588 +st_read_51251 st_read 3 51251 NULL
100589 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
100590 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
100591 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
100592 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
100593 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
100594 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
100595 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
100596 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
100597 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
100598 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
100599 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
100600 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
100601 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
100602 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
100603 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
100604 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
100605 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
100606 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
100607 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
100608 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
100609 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
100610 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
100611 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
100612 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
100613 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
100614 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
100615 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
100616 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
100617 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
100618 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
100619 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
100620 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
100621 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
100622 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
100623 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
100624 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
100625 +sel_write_access_51704 sel_write_access 3 51704 NULL
100626 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
100627 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
100628 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
100629 +msg_set_51725 msg_set 3 51725 NULL
100630 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
100631 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
100632 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
100633 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
100634 +if_write_51756 if_write 3 51756 NULL
100635 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
100636 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
100637 +__fswab32_51781 __fswab32 0 51781 NULL
100638 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
100639 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
100640 +wm2000_write_51834 wm2000_write 2 51834 NULL
100641 +ioread32_51847 ioread32 0 51847 NULL nohasharray
100642 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
100643 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
100644 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
100645 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
100646 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
100647 +user_read_51881 user_read 3 51881 NULL
100648 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
100649 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
100650 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
100651 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
100652 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
100653 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
100654 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
100655 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
100656 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
100657 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
100658 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
100659 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
100660 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
100661 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
100662 +rdmalt_52022 rdmalt 0 52022 NULL
100663 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
100664 +override_release_52032 override_release 2 52032 NULL
100665 +end_port_52042 end_port 0 52042 NULL
100666 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
100667 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
100668 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
100669 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
100670 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
100671 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
100672 +retry_count_read_52129 retry_count_read 3 52129 NULL
100673 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
100674 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
100675 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
100676 +htable_size_52148 htable_size 0-1 52148 NULL
100677 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
100678 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
100679 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
100680 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
100681 +print_prefix_52176 print_prefix 0 52176 NULL
100682 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
100683 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
100684 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
100685 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
100686 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
100687 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
100688 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
100689 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100690 +read_file_reset_52310 read_file_reset 3 52310 NULL
100691 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
100692 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100693 +hwflags_read_52318 hwflags_read 3 52318 NULL
100694 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
100695 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100696 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100697 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100698 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100699 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
100700 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100701 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100702 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100703 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
100704 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100705 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100706 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100707 +delay_status_52431 delay_status 5 52431 NULL
100708 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100709 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100710 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100711 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100712 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100713 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100714 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100715 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100716 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100717 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100718 +emit_code_52583 emit_code 0-3 52583 NULL
100719 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
100720 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100721 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
100722 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100723 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100724 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100725 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100726 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100727 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100728 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
100729 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100730 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100731 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100732 +twlreg_write_52880 twlreg_write 3 52880 NULL
100733 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
100734 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
100735 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
100736 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
100737 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
100738 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
100739 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
100740 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100741 +send_packet_52960 send_packet 4 52960 NULL
100742 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100743 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
100744 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100745 +num_node_state_52989 num_node_state 0 52989 NULL
100746 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100747 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100748 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100749 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100750 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100751 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100752 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100753 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100754 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100755 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100756 +verity_status_53120 verity_status 5 53120 NULL
100757 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
100758 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100759 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100760 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100761 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100762 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100763 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100764 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100765 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100766 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
100767 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100768 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100769 +vm_mmap_53339 vm_mmap 0 53339 NULL
100770 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100771 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100772 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100773 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
100774 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100775 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100776 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100777 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100778 +n2_run_53459 n2_run 3 53459 NULL
100779 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100780 +wm831x_write_53469 wm831x_write 2 53469 NULL
100781 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100782 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100783 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100784 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100785 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100786 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100787 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100788 +check_acl_53512 check_acl 0 53512 NULL
100789 +set_registers_53582 set_registers 3 53582 NULL
100790 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100791 +__readw_53594 __readw 0 53594 NULL
100792 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
100793 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100794 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100795 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100796 +_preload_range_53676 _preload_range 2-3 53676 NULL
100797 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100798 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100799 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
100800 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
100801 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100802 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100803 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100804 +wdm_write_53735 wdm_write 3 53735 NULL
100805 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100806 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100807 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100808 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100809 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100810 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100811 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100812 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
100813 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100814 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100815 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
100816 +pms_read_53873 pms_read 3 53873 NULL
100817 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100818 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100819 +proc_file_read_53905 proc_file_read 3 53905 NULL
100820 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
100821 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100822 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100823 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100824 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100825 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100826 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100827 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100828 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100829 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100830 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100831 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100832 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100833 +_malloc_54077 _malloc 1 54077 NULL
100834 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100835 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100836 +create_xattr_54106 create_xattr 5 54106 NULL
100837 +strn_len_54122 strn_len 0 54122 NULL
100838 +isku_receive_54130 isku_receive 4 54130 NULL
100839 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100840 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100841 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100842 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100843 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100844 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100845 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100846 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100847 +reada_add_block_54247 reada_add_block 2 54247 NULL
100848 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100849 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100850 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100851 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100852 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100853 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100854 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100855 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100856 +sprintf_54306 sprintf 0 54306 NULL
100857 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100858 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100859 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100860 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100861 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100862 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100863 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100864 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100865 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100866 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100867 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100868 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100869 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100870 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100871 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100872 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100873 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100874 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100875 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
100876 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100877 +viacam_read_54526 viacam_read 3 54526 NULL
100878 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100879 +setsockopt_54539 setsockopt 5 54539 NULL
100880 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100881 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100882 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100883 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100884 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100885 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
100886 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100887 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100888 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100889 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100890 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100891 +evm_read_key_54674 evm_read_key 3 54674 NULL
100892 +resource_string_54699 resource_string 0 54699 NULL
100893 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100894 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100895 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100896 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100897 +kzalloc_54740 kzalloc 1 54740 NULL
100898 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100899 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100900 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100901 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100902 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100903 +domain_init_54797 domain_init 2 54797 NULL
100904 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100905 +nfsd_write_54809 nfsd_write 6 54809 NULL
100906 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100907 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100908 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100909 +write_rio_54837 write_rio 3 54837 NULL
100910 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100911 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100912 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100913 +printer_read_54851 printer_read 3 54851 NULL
100914 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100915 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100916 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100917 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100918 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
100919 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100920 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100921 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100922 +add_port_54941 add_port 2 54941 NULL
100923 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100924 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100925 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100926 +c4_add_card_54968 c4_add_card 3 54968 NULL
100927 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100928 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100929 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100930 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
100931 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100932 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100933 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100934 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100935 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100936 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
100937 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100938 +corrupt_data_55120 corrupt_data 0 55120 NULL
100939 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100940 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100941 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100942 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100943 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100944 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100945 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100946 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100947 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
100948 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
100949 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
100950 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
100951 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100952 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100953 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100954 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100955 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100956 +ptrace_request_55288 ptrace_request 3 55288 NULL
100957 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100958 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
100959 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100960 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
100961 +vme_user_read_55338 vme_user_read 3 55338 NULL
100962 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100963 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100964 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100965 +__send_to_port_55383 __send_to_port 3 55383 NULL
100966 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100967 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100968 +alloc_skb_55439 alloc_skb 1 55439 NULL
100969 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100970 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100971 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100972 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100973 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100974 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100975 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
100976 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100977 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100978 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100979 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100980 +ea_get_55522 ea_get 0 55522 NULL
100981 +buffer_size_55534 buffer_size 0 55534 NULL
100982 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100983 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100984 +add_partition_55588 add_partition 2 55588 NULL
100985 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100986 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
100987 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100988 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100989 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100990 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100991 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100992 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100993 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100994 +read_oldmem_55658 read_oldmem 3 55658 NULL
100995 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100996 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100997 +get_info_55681 get_info 3 55681 NULL
100998 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
100999 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
101000 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
101001 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
101002 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
101003 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
101004 +set_local_name_55757 set_local_name 4 55757 NULL
101005 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
101006 +strlen_55778 strlen 0 55778 NULL nohasharray
101007 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
101008 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
101009 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
101010 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
101011 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
101012 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
101013 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
101014 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
101015 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
101016 +hsc_write_55875 hsc_write 3 55875 NULL
101017 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
101018 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
101019 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
101020 +handle_response_55951 handle_response 5 55951 NULL
101021 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
101022 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
101023 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
101024 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
101025 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
101026 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
101027 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
101028 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
101029 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
101030 +map_addr_56144 map_addr 7 56144 NULL
101031 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
101032 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
101033 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
101034 +skb_headroom_56200 skb_headroom 0 56200 NULL
101035 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
101036 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
101037 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
101038 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
101039 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
101040 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
101041 +fd_copyin_56247 fd_copyin 3 56247 NULL
101042 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
101043 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
101044 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
101045 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
101046 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
101047 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
101048 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
101049 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
101050 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
101051 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
101052 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
101053 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
101054 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
101055 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
101056 +dev_read_56369 dev_read 3 56369 NULL
101057 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
101058 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
101059 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
101060 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
101061 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
101062 +store_msg_56417 store_msg 3 56417 NULL
101063 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
101064 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
101065 +fl_create_56435 fl_create 5 56435 NULL
101066 +gnttab_map_56439 gnttab_map 2 56439 NULL
101067 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
101068 +set_connectable_56458 set_connectable 4 56458 NULL
101069 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
101070 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
101071 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
101072 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
101073 +ip_options_get_56538 ip_options_get 4 56538 NULL
101074 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
101075 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
101076 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
101077 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
101078 +event_filter_write_56609 event_filter_write 3 56609 NULL
101079 +gather_array_56641 gather_array 3 56641 NULL
101080 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
101081 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
101082 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
101083 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
101084 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
101085 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
101086 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
101087 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
101088 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
101089 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
101090 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
101091 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
101092 +do_syslog_56807 do_syslog 3 56807 NULL
101093 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
101094 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
101095 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
101096 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
101097 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
101098 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
101099 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
101100 +strcspn_56913 strcspn 0 56913 NULL
101101 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
101102 +check_header_56930 check_header 2 56930 NULL
101103 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
101104 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
101105 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
101106 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
101107 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
101108 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
101109 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
101110 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
101111 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
101112 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
101113 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
101114 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
101115 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
101116 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
101117 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
101118 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
101119 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
101120 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
101121 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
101122 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
101123 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
101124 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
101125 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
101126 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
101127 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
101128 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
101129 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
101130 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
101131 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
101132 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
101133 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
101134 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
101135 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
101136 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
101137 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
101138 +fw_file_size_57307 fw_file_size 0 57307 NULL
101139 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
101140 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
101141 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
101142 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
101143 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
101144 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
101145 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
101146 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
101147 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
101148 +read_file_blob_57406 read_file_blob 3 57406 NULL
101149 +enclosure_register_57412 enclosure_register 3 57412 NULL
101150 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
101151 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
101152 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
101153 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
101154 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
101155 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
101156 +ReadReg_57453 ReadReg 0 57453 NULL
101157 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
101158 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
101159 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
101160 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
101161 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
101162 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
101163 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
101164 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
101165 +skb_headlen_57501 skb_headlen 0 57501 NULL
101166 +copy_in_user_57502 copy_in_user 3 57502 NULL
101167 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
101168 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
101169 +init_tag_map_57515 init_tag_map 3 57515 NULL
101170 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
101171 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
101172 +inode_permission_57531 inode_permission 0 57531 NULL
101173 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
101174 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
101175 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
101176 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
101177 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
101178 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
101179 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
101180 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
101181 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
101182 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
101183 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
101184 +mem_read_57631 mem_read 3 57631 NULL
101185 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
101186 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
101187 +r3964_write_57662 r3964_write 4 57662 NULL
101188 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
101189 +__lgwrite_57669 __lgwrite 4 57669 NULL
101190 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
101191 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
101192 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
101193 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
101194 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
101195 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
101196 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
101197 +ld2_57794 ld2 0 57794 NULL
101198 +ivtv_read_57796 ivtv_read 3 57796 NULL
101199 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
101200 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
101201 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
101202 +copy_to_user_57835 copy_to_user 3 57835 NULL
101203 +flash_read_57843 flash_read 3 57843 NULL
101204 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
101205 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
101206 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
101207 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
101208 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
101209 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
101210 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
101211 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
101212 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
101213 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
101214 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
101215 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
101216 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
101217 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
101218 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
101219 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
101220 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
101221 +mc13783_write_58033 mc13783_write 2 58033 NULL
101222 +mce_async_out_58056 mce_async_out 3 58056 NULL
101223 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
101224 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
101225 +cm4040_write_58079 cm4040_write 3 58079 NULL
101226 +udi_log_event_58105 udi_log_event 3 58105 NULL
101227 +savemem_58129 savemem 3 58129 NULL
101228 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
101229 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
101230 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
101231 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
101232 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
101233 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
101234 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
101235 +read_file_debug_58256 read_file_debug 3 58256 NULL
101236 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
101237 +profile_load_58267 profile_load 3 58267 NULL
101238 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
101239 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
101240 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
101241 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
101242 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
101243 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
101244 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
101245 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
101246 +next_pidmap_58347 next_pidmap 2 58347 NULL
101247 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
101248 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
101249 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
101250 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
101251 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
101252 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
101253 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
101254 +capabilities_read_58457 capabilities_read 3 58457 NULL
101255 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
101256 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
101257 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
101258 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
101259 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
101260 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
101261 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
101262 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
101263 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
101264 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
101265 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
101266 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
101267 +xip_file_read_58592 xip_file_read 3 58592 NULL
101268 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
101269 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
101270 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
101271 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
101272 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
101273 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
101274 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
101275 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
101276 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
101277 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
101278 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
101279 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
101280 +acpi_map_58725 acpi_map 1-2 58725 NULL
101281 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
101282 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
101283 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
101284 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
101285 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
101286 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
101287 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
101288 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
101289 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
101290 +ep_read_58813 ep_read 3 58813 NULL
101291 +command_write_58841 command_write 3 58841 NULL
101292 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
101293 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
101294 +hw_write_58881 hw_write 2 58881 NULL
101295 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
101296 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
101297 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
101298 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
101299 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
101300 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
101301 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
101302 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
101303 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
101304 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
101305 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
101306 +ep_write_59008 ep_write 3 59008 NULL
101307 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
101308 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
101309 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
101310 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
101311 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
101312 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
101313 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
101314 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
101315 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
101316 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
101317 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
101318 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
101319 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
101320 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
101321 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
101322 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
101323 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
101324 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
101325 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
101326 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
101327 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
101328 +dt3155_read_59226 dt3155_read 3 59226 NULL
101329 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
101330 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
101331 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
101332 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
101333 +nla_len_59258 nla_len 0 59258 NULL
101334 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
101335 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
101336 +fd_copyout_59323 fd_copyout 3 59323 NULL
101337 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
101338 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
101339 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
101340 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
101341 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
101342 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
101343 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
101344 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
101345 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
101346 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
101347 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
101348 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
101349 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
101350 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
101351 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
101352 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
101353 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
101354 +tunables_write_59563 tunables_write 3 59563 NULL
101355 +memdup_user_59590 memdup_user 2 59590 NULL
101356 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
101357 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
101358 +mtrr_write_59622 mtrr_write 3 59622 NULL
101359 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
101360 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
101361 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
101362 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
101363 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
101364 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
101365 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
101366 +wm8400_write_59675 wm8400_write 2 59675 NULL
101367 +sriov_enable_59689 sriov_enable 2 59689 NULL
101368 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
101369 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
101370 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
101371 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
101372 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
101373 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
101374 +strnlen_59746 strnlen 0 59746 NULL
101375 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
101376 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
101377 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
101378 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
101379 +venus_remove_59781 venus_remove 4 59781 NULL
101380 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
101381 +ipw_write_59807 ipw_write 3 59807 NULL
101382 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
101383 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
101384 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
101385 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
101386 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
101387 +tun_put_user_59849 tun_put_user 4 59849 NULL
101388 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
101389 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
101390 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
101391 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
101392 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
101393 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
101394 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
101395 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
101396 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
101397 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
101398 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
101399 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
101400 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
101401 +register_device_60015 register_device 2-3 60015 NULL
101402 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
101403 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
101404 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
101405 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
101406 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
101407 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
101408 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
101409 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
101410 +load_module_60056 load_module 2 60056 NULL nohasharray
101411 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
101412 +compat_writev_60063 compat_writev 3 60063 NULL
101413 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
101414 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
101415 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
101416 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
101417 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
101418 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
101419 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
101420 +init_state_60165 init_state 2 60165 NULL
101421 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
101422 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
101423 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
101424 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
101425 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
101426 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
101427 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
101428 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
101429 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
101430 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
101431 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
101432 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
101433 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
101434 +printer_write_60276 printer_write 3 60276 NULL
101435 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
101436 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
101437 +getDataLength_60301 getDataLength 0 60301 NULL
101438 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
101439 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
101440 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
101441 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
101442 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
101443 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
101444 +driver_names_read_60399 driver_names_read 3 60399 NULL
101445 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
101446 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
101447 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
101448 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
101449 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
101450 +rx_data_60442 rx_data 4 60442 NULL
101451 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
101452 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
101453 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
101454 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
101455 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
101456 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
101457 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
101458 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
101459 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
101460 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
101461 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
101462 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
101463 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
101464 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
101465 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
101466 +init_data_container_60709 init_data_container 1 60709 NULL
101467 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
101468 +raid_status_60755 raid_status 5 60755 NULL
101469 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
101470 +opticon_write_60775 opticon_write 4 60775 NULL
101471 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
101472 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
101473 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
101474 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
101475 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
101476 +generic_writepages_60871 generic_writepages 0 60871 NULL
101477 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
101478 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
101479 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
101480 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
101481 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
101482 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
101483 +pti_char_write_60960 pti_char_write 3 60960 NULL
101484 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
101485 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
101486 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
101487 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
101488 +symtab_init_61050 symtab_init 2 61050 NULL
101489 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
101490 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
101491 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
101492 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
101493 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
101494 +get_derived_key_61100 get_derived_key 4 61100 NULL
101495 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
101496 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
101497 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
101498 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
101499 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
101500 +__vmalloc_61168 __vmalloc 1 61168 NULL
101501 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
101502 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
101503 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
101504 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
101505 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
101506 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
101507 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
101508 +sys_add_key_61288 sys_add_key 4 61288 NULL
101509 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
101510 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
101511 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
101512 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
101513 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
101514 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
101515 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
101516 +change_xattr_61390 change_xattr 5 61390 NULL
101517 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
101518 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
101519 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
101520 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
101521 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
101522 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
101523 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
101524 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
101525 +erst_errno_61526 erst_errno 0 61526 NULL
101526 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
101527 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
101528 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
101529 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
101530 +seq_open_private_61589 seq_open_private 3 61589 NULL
101531 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
101532 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
101533 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
101534 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
101535 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
101536 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
101537 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
101538 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
101539 +resize_stripes_61650 resize_stripes 2 61650 NULL
101540 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
101541 +insert_one_name_61668 insert_one_name 7 61668 NULL
101542 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
101543 +lock_loop_61681 lock_loop 1 61681 NULL
101544 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
101545 +filter_read_61692 filter_read 3 61692 NULL
101546 +iov_length_61716 iov_length 0 61716 NULL
101547 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
101548 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
101549 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
101550 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
101551 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
101552 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
101553 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
101554 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
101555 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
101556 +get_fw_name_61874 get_fw_name 3 61874 NULL
101557 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
101558 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
101559 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
101560 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
101561 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
101562 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
101563 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
101564 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
101565 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
101566 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
101567 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
101568 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
101569 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
101570 +cow_file_range_61979 cow_file_range 3 61979 NULL
101571 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
101572 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
101573 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
101574 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
101575 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
101576 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
101577 +do_pselect_62061 do_pselect 1 62061 NULL
101578 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
101579 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
101580 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
101581 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
101582 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
101583 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
101584 +ql_status_62135 ql_status 5 62135 NULL
101585 +video_usercopy_62151 video_usercopy 2 62151 NULL
101586 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
101587 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
101588 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
101589 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
101590 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
101591 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
101592 +allocate_partition_62245 allocate_partition 4 62245 NULL
101593 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
101594 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
101595 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
101596 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
101597 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
101598 +subseq_list_62332 subseq_list 3-0 62332 NULL
101599 +flash_write_62354 flash_write 3 62354 NULL
101600 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
101601 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
101602 +altera_irscan_62396 altera_irscan 2 62396 NULL
101603 +set_ssp_62411 set_ssp 4 62411 NULL
101604 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
101605 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
101606 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
101607 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
101608 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
101609 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
101610 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
101611 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
101612 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
101613 +debugfs_read_62535 debugfs_read 3 62535 NULL
101614 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
101615 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
101616 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
101617 +get_subdir_62581 get_subdir 3 62581 NULL
101618 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
101619 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
101620 +get_desc_base_62617 get_desc_base 0 62617 NULL
101621 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
101622 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
101623 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
101624 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
101625 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
101626 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
101627 +write_62671 write 3 62671 NULL
101628 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
101629 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
101630 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
101631 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
101632 +rdm_62719 rdm 0 62719 NULL
101633 +key_replays_read_62746 key_replays_read 3 62746 NULL
101634 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
101635 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
101636 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
101637 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
101638 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
101639 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
101640 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
101641 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
101642 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
101643 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
101644 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
101645 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
101646 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
101647 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
101648 +getdqbuf_62908 getdqbuf 1 62908 NULL
101649 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
101650 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
101651 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
101652 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
101653 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
101654 +unlink1_63059 unlink1 3 63059 NULL
101655 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
101656 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
101657 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
101658 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
101659 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
101660 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
101661 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
101662 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
101663 +vme_master_read_63221 vme_master_read 0 63221 NULL
101664 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
101665 +ptp_read_63251 ptp_read 4 63251 NULL
101666 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
101667 +raid5_resize_63306 raid5_resize 2 63306 NULL
101668 +proc_info_read_63344 proc_info_read 3 63344 NULL
101669 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
101670 +idmouse_read_63374 idmouse_read 3 63374 NULL
101671 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
101672 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
101673 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
101674 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
101675 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
101676 +kone_send_63435 kone_send 4 63435 NULL
101677 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
101678 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
101679 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
101680 +read_kcore_63488 read_kcore 3 63488 NULL
101681 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
101682 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
101683 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
101684 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
101685 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
101686 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
101687 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
101688 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
101689 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101690 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101691 +module_alloc_63630 module_alloc 1 63630 NULL
101692 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101693 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101694 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101695 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101696 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101697 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101698 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101699 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101700 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101701 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101702 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101703 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101704 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101705 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101706 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101707 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
101708 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101709 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101710 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101711 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101712 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101713 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101714 +sel_write_load_63830 sel_write_load 3 63830 NULL
101715 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101716 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
101717 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101718 +divas_write_63901 divas_write 3 63901 NULL
101719 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101720 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101721 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101722 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101723 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101724 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
101725 +__team_options_register_63941 __team_options_register 3 63941 NULL
101726 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
101727 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
101728 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
101729 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
101730 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
101731 +kmemdup_64015 kmemdup 2 64015 NULL
101732 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
101733 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
101734 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
101735 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
101736 +get_u8_64076 get_u8 0 64076 NULL
101737 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
101738 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
101739 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
101740 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101741 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101742 +init_bch_64130 init_bch 1-2 64130 NULL
101743 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101744 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101745 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101746 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101747 +read_pulse_64227 read_pulse 0-3 64227 NULL
101748 +header_len_64232 header_len 0 64232 NULL
101749 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101750 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101751 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101752 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101753 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101754 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101755 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101756 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101757 +ffz_64324 ffz 0 64324 NULL
101758 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101759 +ts_write_64336 ts_write 3 64336 NULL
101760 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101761 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101762 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101763 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101764 +ilo_write_64378 ilo_write 3 64378 NULL
101765 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101766 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101767 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101768 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101769 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101770 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101771 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101772 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101773 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101774 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
101775 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
101776 +cap_capable_64462 cap_capable 0 64462 NULL
101777 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101778 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101779 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101780 +remove_uuid_64505 remove_uuid 4 64505 NULL
101781 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101782 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101783 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101784 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101785 +__spi_sync_64561 __spi_sync 0 64561 NULL
101786 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101787 +fanotify_write_64623 fanotify_write 3 64623 NULL
101788 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101789 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101790 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101791 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101792 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101793 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101794 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101795 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101796 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101797 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101798 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101799 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101800 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101801 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101802 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101803 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101804 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
101805 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101806 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101807 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101808 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101809 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101810 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101811 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101812 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101813 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101814 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101815 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101816 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101817 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101818 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101819 +pskb_pull_65005 pskb_pull 2 65005 NULL
101820 +unifi_write_65012 unifi_write 3 65012 NULL
101821 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101822 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101823 +insert_dent_65034 insert_dent 7 65034 NULL
101824 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101825 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101826 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101827 +make_idx_node_65068 make_idx_node 0 65068 NULL
101828 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101829 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101830 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
101831 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101832 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101833 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101834 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101835 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
101836 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101837 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101838 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101839 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101840 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
101841 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101842 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101843 +get_var_len_65304 get_var_len 0 65304 NULL
101844 +unpack_array_65318 unpack_array 0 65318 NULL
101845 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101846 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101847 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101848 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101849 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101850 +strchr_65372 strchr 0 65372 NULL
101851 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
101852 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101853 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101854 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101855 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101856 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101857 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101858 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
101859 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101860 +regmap_write_65478 regmap_write 2 65478 NULL
101861 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101862 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101863 +alloc_dr_65495 alloc_dr 2 65495 NULL
101864 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101865 new file mode 100644
101866 index 0000000..9db0d0e
101867 --- /dev/null
101868 +++ b/tools/gcc/size_overflow_plugin.c
101869 @@ -0,0 +1,2114 @@
101870 +/*
101871 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101872 + * Licensed under the GPL v2, or (at your option) v3
101873 + *
101874 + * Homepage:
101875 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101876 + *
101877 + * Documentation:
101878 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101879 + *
101880 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101881 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101882 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101883 + *
101884 + * Usage:
101885 + * $ 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
101886 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101887 + */
101888 +
101889 +#include "gcc-plugin.h"
101890 +#include "config.h"
101891 +#include "system.h"
101892 +#include "coretypes.h"
101893 +#include "tree.h"
101894 +#include "tree-pass.h"
101895 +#include "intl.h"
101896 +#include "plugin-version.h"
101897 +#include "tm.h"
101898 +#include "toplev.h"
101899 +#include "function.h"
101900 +#include "tree-flow.h"
101901 +#include "plugin.h"
101902 +#include "gimple.h"
101903 +#include "diagnostic.h"
101904 +#include "cfgloop.h"
101905 +
101906 +#if BUILDING_GCC_VERSION >= 4008
101907 +#define TODO_dump_func 0
101908 +#endif
101909 +
101910 +struct size_overflow_hash {
101911 + const struct size_overflow_hash * const next;
101912 + const char * const name;
101913 + const unsigned int param;
101914 +};
101915 +
101916 +#include "size_overflow_hash.h"
101917 +
101918 +enum mark {
101919 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101920 +};
101921 +
101922 +enum err_code_conditions {
101923 + CAST_ONLY, FROM_CONST
101924 +};
101925 +
101926 +static unsigned int call_count = 0;
101927 +
101928 +#define __unused __attribute__((__unused__))
101929 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101930 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101931 +#define BEFORE_STMT true
101932 +#define AFTER_STMT false
101933 +#define CREATE_NEW_VAR NULL_TREE
101934 +#define CODES_LIMIT 32
101935 +#define MAX_PARAM 31
101936 +#define MY_STMT GF_PLF_1
101937 +#define NO_CAST_CHECK GF_PLF_2
101938 +#define FROM_ARG true
101939 +#define FROM_RET false
101940 +
101941 +#if BUILDING_GCC_VERSION == 4005
101942 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101943 +#endif
101944 +
101945 +int plugin_is_GPL_compatible;
101946 +void debug_gimple_stmt(gimple gs);
101947 +
101948 +static tree expand(struct pointer_set_t *visited, tree lhs);
101949 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101950 +static tree report_size_overflow_decl;
101951 +static const_tree const_char_ptr_type_node;
101952 +static unsigned int handle_function(void);
101953 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101954 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101955 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101956 +static void print_missing_msg(tree func, unsigned int argnum);
101957 +
101958 +static struct plugin_info size_overflow_plugin_info = {
101959 + .version = "20130410beta",
101960 + .help = "no-size-overflow\tturn off size overflow checking\n",
101961 +};
101962 +
101963 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101964 +{
101965 + unsigned int arg_count;
101966 + enum tree_code code = TREE_CODE(*node);
101967 +
101968 + switch (code) {
101969 + case FUNCTION_DECL:
101970 + arg_count = type_num_arguments(TREE_TYPE(*node));
101971 + break;
101972 + case FUNCTION_TYPE:
101973 + case METHOD_TYPE:
101974 + arg_count = type_num_arguments(*node);
101975 + break;
101976 + default:
101977 + *no_add_attrs = true;
101978 + error("%s: %qE attribute only applies to functions", __func__, name);
101979 + return NULL_TREE;
101980 + }
101981 +
101982 + for (; args; args = TREE_CHAIN(args)) {
101983 + tree position = TREE_VALUE(args);
101984 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101985 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101986 + *no_add_attrs = true;
101987 + }
101988 + }
101989 + return NULL_TREE;
101990 +}
101991 +
101992 +static const char* get_asm_name(tree node)
101993 +{
101994 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101995 +}
101996 +
101997 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101998 +{
101999 + unsigned int arg_count, arg_num;
102000 + enum tree_code code = TREE_CODE(*node);
102001 +
102002 + switch (code) {
102003 + case FUNCTION_DECL:
102004 + arg_count = type_num_arguments(TREE_TYPE(*node));
102005 + break;
102006 + case FUNCTION_TYPE:
102007 + case METHOD_TYPE:
102008 + arg_count = type_num_arguments(*node);
102009 + break;
102010 + case FIELD_DECL:
102011 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
102012 + if (arg_num != 0) {
102013 + *no_add_attrs = true;
102014 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
102015 + }
102016 + return NULL_TREE;
102017 + default:
102018 + *no_add_attrs = true;
102019 + error("%qE attribute only applies to functions", name);
102020 + return NULL_TREE;
102021 + }
102022 +
102023 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
102024 + return NULL_TREE;
102025 +
102026 + for (; args; args = TREE_CHAIN(args)) {
102027 + tree position = TREE_VALUE(args);
102028 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102029 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102030 + *no_add_attrs = true;
102031 + }
102032 + }
102033 + return NULL_TREE;
102034 +}
102035 +
102036 +static struct attribute_spec size_overflow_attr = {
102037 + .name = "size_overflow",
102038 + .min_length = 1,
102039 + .max_length = -1,
102040 + .decl_required = true,
102041 + .type_required = false,
102042 + .function_type_required = false,
102043 + .handler = handle_size_overflow_attribute,
102044 +#if BUILDING_GCC_VERSION >= 4007
102045 + .affects_type_identity = false
102046 +#endif
102047 +};
102048 +
102049 +static struct attribute_spec intentional_overflow_attr = {
102050 + .name = "intentional_overflow",
102051 + .min_length = 1,
102052 + .max_length = -1,
102053 + .decl_required = true,
102054 + .type_required = false,
102055 + .function_type_required = false,
102056 + .handler = handle_intentional_overflow_attribute,
102057 +#if BUILDING_GCC_VERSION >= 4007
102058 + .affects_type_identity = false
102059 +#endif
102060 +};
102061 +
102062 +static void register_attributes(void __unused *event_data, void __unused *data)
102063 +{
102064 + register_attribute(&size_overflow_attr);
102065 + register_attribute(&intentional_overflow_attr);
102066 +}
102067 +
102068 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
102069 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
102070 +{
102071 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
102072 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
102073 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
102074 +
102075 + unsigned int m = 0x57559429;
102076 + unsigned int n = 0x5052acdb;
102077 + const unsigned int *key4 = (const unsigned int *)key;
102078 + unsigned int h = len;
102079 + unsigned int k = len + seed + n;
102080 + unsigned long long p;
102081 +
102082 + while (len >= 8) {
102083 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
102084 + len -= 8;
102085 + }
102086 + if (len >= 4) {
102087 + cwmixb(key4[0]) key4 += 1;
102088 + len -= 4;
102089 + }
102090 + if (len)
102091 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
102092 + cwmixb(h ^ (k + n));
102093 + return k ^ h;
102094 +
102095 +#undef cwfold
102096 +#undef cwmixa
102097 +#undef cwmixb
102098 +}
102099 +
102100 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
102101 +{
102102 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
102103 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
102104 + return fn ^ codes;
102105 +}
102106 +
102107 +static inline tree get_original_function_decl(tree fndecl)
102108 +{
102109 + if (DECL_ABSTRACT_ORIGIN(fndecl))
102110 + return DECL_ABSTRACT_ORIGIN(fndecl);
102111 + return fndecl;
102112 +}
102113 +
102114 +static inline gimple get_def_stmt(const_tree node)
102115 +{
102116 + gcc_assert(node != NULL_TREE);
102117 + if (TREE_CODE(node) != SSA_NAME)
102118 + return NULL;
102119 + return SSA_NAME_DEF_STMT(node);
102120 +}
102121 +
102122 +static unsigned char get_tree_code(const_tree type)
102123 +{
102124 + switch (TREE_CODE(type)) {
102125 + case ARRAY_TYPE:
102126 + return 0;
102127 + case BOOLEAN_TYPE:
102128 + return 1;
102129 + case ENUMERAL_TYPE:
102130 + return 2;
102131 + case FUNCTION_TYPE:
102132 + return 3;
102133 + case INTEGER_TYPE:
102134 + return 4;
102135 + case POINTER_TYPE:
102136 + return 5;
102137 + case RECORD_TYPE:
102138 + return 6;
102139 + case UNION_TYPE:
102140 + return 7;
102141 + case VOID_TYPE:
102142 + return 8;
102143 + case REAL_TYPE:
102144 + return 9;
102145 + case VECTOR_TYPE:
102146 + return 10;
102147 + case REFERENCE_TYPE:
102148 + return 11;
102149 + case OFFSET_TYPE:
102150 + return 12;
102151 + case COMPLEX_TYPE:
102152 + return 13;
102153 + default:
102154 + debug_tree((tree)type);
102155 + gcc_unreachable();
102156 + }
102157 +}
102158 +
102159 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
102160 +{
102161 + gcc_assert(type != NULL_TREE);
102162 +
102163 + while (type && len < CODES_LIMIT) {
102164 + tree_codes[len] = get_tree_code(type);
102165 + len++;
102166 + type = TREE_TYPE(type);
102167 + }
102168 + return len;
102169 +}
102170 +
102171 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
102172 +{
102173 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
102174 + enum tree_code code = TREE_CODE(type);
102175 + size_t len = 0;
102176 +
102177 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
102178 +
102179 + arg = TYPE_ARG_TYPES(type);
102180 + // skip builtins __builtin_constant_p
102181 + if (!arg && DECL_BUILT_IN(fndecl))
102182 + return 0;
102183 +
102184 + if (TREE_CODE_CLASS(code) == tcc_type)
102185 + result = type;
102186 + else
102187 + result = DECL_RESULT(fndecl);
102188 +
102189 + gcc_assert(result != NULL_TREE);
102190 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
102191 +
102192 + if (arg == NULL_TREE) {
102193 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
102194 + arg_field = DECL_ARGUMENT_FLD(fndecl);
102195 + if (arg_field == NULL_TREE)
102196 + return 0;
102197 + arg = TREE_TYPE(arg_field);
102198 + len = add_type_codes(arg, tree_codes, len);
102199 + gcc_assert(len != 0);
102200 + return len;
102201 + }
102202 +
102203 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
102204 + while (arg && len < CODES_LIMIT) {
102205 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
102206 + arg = TREE_CHAIN(arg);
102207 + }
102208 +
102209 + gcc_assert(len != 0);
102210 + return len;
102211 +}
102212 +
102213 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
102214 +{
102215 + unsigned int hash;
102216 + const struct size_overflow_hash *entry;
102217 + unsigned char tree_codes[CODES_LIMIT];
102218 + size_t len;
102219 + const char *func_name;
102220 +
102221 + fndecl = get_original_function_decl(fndecl);
102222 + len = get_function_decl(fndecl, tree_codes);
102223 + if (len == 0)
102224 + return NULL;
102225 +
102226 + func_name = get_asm_name(fndecl);
102227 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
102228 +
102229 + entry = size_overflow_hash[hash];
102230 + while (entry) {
102231 + if (!strcmp(entry->name, func_name))
102232 + return entry;
102233 + entry = entry->next;
102234 + }
102235 +
102236 + return NULL;
102237 +}
102238 +
102239 +static bool is_bool(const_tree node)
102240 +{
102241 + const_tree type;
102242 +
102243 + if (node == NULL_TREE)
102244 + return false;
102245 +
102246 + type = TREE_TYPE(node);
102247 + if (!INTEGRAL_TYPE_P(type))
102248 + return false;
102249 + if (TREE_CODE(type) == BOOLEAN_TYPE)
102250 + return true;
102251 + if (TYPE_PRECISION(type) == 1)
102252 + return true;
102253 + return false;
102254 +}
102255 +
102256 +static bool skip_types(const_tree var)
102257 +{
102258 + tree type;
102259 +
102260 + if (is_gimple_constant(var))
102261 + return true;
102262 +
102263 + switch (TREE_CODE(var)) {
102264 + case ADDR_EXPR:
102265 +#if BUILDING_GCC_VERSION >= 4006
102266 + case MEM_REF:
102267 +#endif
102268 + case ARRAY_REF:
102269 + case BIT_FIELD_REF:
102270 + case INDIRECT_REF:
102271 + case TARGET_MEM_REF:
102272 + return true;
102273 + case PARM_DECL:
102274 + case VAR_DECL:
102275 + case COMPONENT_REF:
102276 + return false;
102277 + default:
102278 + break;
102279 + }
102280 +
102281 + gcc_assert(TREE_CODE(var) == SSA_NAME);
102282 +
102283 + type = TREE_TYPE(var);
102284 + switch (TREE_CODE(type)) {
102285 + case INTEGER_TYPE:
102286 + case ENUMERAL_TYPE:
102287 + return false;
102288 + case BOOLEAN_TYPE:
102289 + return is_bool(var);
102290 + default:
102291 + break;
102292 + }
102293 +
102294 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
102295 +
102296 + type = TREE_TYPE(type);
102297 + gcc_assert(type != NULL_TREE);
102298 + switch (TREE_CODE(type)) {
102299 + case RECORD_TYPE:
102300 + case POINTER_TYPE:
102301 + case ARRAY_TYPE:
102302 + return true;
102303 + case VOID_TYPE:
102304 + case INTEGER_TYPE:
102305 + case UNION_TYPE:
102306 + return false;
102307 + default:
102308 + break;
102309 + }
102310 +
102311 + debug_tree((tree)var);
102312 + gcc_unreachable();
102313 +}
102314 +
102315 +static unsigned int find_arg_number(const_tree arg, tree func)
102316 +{
102317 + tree var;
102318 + unsigned int argnum = 1;
102319 +
102320 + if (TREE_CODE(arg) == SSA_NAME)
102321 + arg = SSA_NAME_VAR(arg);
102322 +
102323 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
102324 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
102325 + continue;
102326 + if (!skip_types(var))
102327 + return argnum;
102328 + }
102329 +
102330 + return 0;
102331 +}
102332 +
102333 +static tree create_new_var(tree type)
102334 +{
102335 + tree new_var = create_tmp_var(type, "cicus");
102336 +
102337 +#if BUILDING_GCC_VERSION <= 4007
102338 + add_referenced_var(new_var);
102339 + mark_sym_for_renaming(new_var);
102340 +#endif
102341 + return new_var;
102342 +}
102343 +
102344 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
102345 +{
102346 + gimple assign;
102347 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102348 + tree type = TREE_TYPE(rhs1);
102349 + tree lhs = create_new_var(type);
102350 +
102351 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
102352 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
102353 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102354 +
102355 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102356 + update_stmt(assign);
102357 + gimple_set_plf(assign, MY_STMT, true);
102358 + return assign;
102359 +}
102360 +
102361 +static tree cast_a_tree(tree type, tree var)
102362 +{
102363 + gcc_assert(type != NULL_TREE);
102364 + gcc_assert(var != NULL_TREE);
102365 + gcc_assert(fold_convertible_p(type, var));
102366 +
102367 + return fold_convert(type, var);
102368 +}
102369 +
102370 +static tree get_lhs(const_gimple stmt)
102371 +{
102372 + switch (gimple_code(stmt)) {
102373 + case GIMPLE_ASSIGN:
102374 + return gimple_get_lhs(stmt);
102375 + case GIMPLE_PHI:
102376 + return gimple_phi_result(stmt);
102377 + case GIMPLE_CALL:
102378 + return gimple_call_lhs(stmt);
102379 + default:
102380 + return NULL_TREE;
102381 + }
102382 +}
102383 +
102384 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
102385 +{
102386 + const_gimple def_stmt = get_def_stmt(rhs);
102387 +
102388 + if (force)
102389 + return false;
102390 +
102391 + if (is_gimple_constant(rhs))
102392 + return false;
102393 +
102394 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102395 + return false;
102396 +
102397 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
102398 + return false;
102399 +
102400 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
102401 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102402 + return false;
102403 +
102404 + return true;
102405 +}
102406 +
102407 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
102408 +{
102409 + gimple assign, def_stmt;
102410 +
102411 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
102412 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
102413 + gcc_unreachable();
102414 +
102415 + def_stmt = get_def_stmt(rhs);
102416 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
102417 + return def_stmt;
102418 +
102419 + if (lhs == CREATE_NEW_VAR)
102420 + lhs = create_new_var(dst_type);
102421 +
102422 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
102423 +
102424 + if (!gsi_end_p(*gsi)) {
102425 + location_t loc = gimple_location(gsi_stmt(*gsi));
102426 + gimple_set_location(assign, loc);
102427 + }
102428 +
102429 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102430 +
102431 + if (before)
102432 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
102433 + else
102434 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
102435 + update_stmt(assign);
102436 + gimple_set_plf(assign, MY_STMT, true);
102437 +
102438 + return assign;
102439 +}
102440 +
102441 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
102442 +{
102443 + gimple_stmt_iterator gsi;
102444 + tree lhs;
102445 + const_gimple new_stmt;
102446 +
102447 + if (rhs == NULL_TREE)
102448 + return NULL_TREE;
102449 +
102450 + gsi = gsi_for_stmt(stmt);
102451 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
102452 +
102453 + lhs = get_lhs(new_stmt);
102454 + gcc_assert(lhs != NULL_TREE);
102455 + return lhs;
102456 +}
102457 +
102458 +static tree cast_to_TI_type(gimple stmt, tree node)
102459 +{
102460 + gimple_stmt_iterator gsi;
102461 + gimple cast_stmt;
102462 + tree type = TREE_TYPE(node);
102463 +
102464 + if (types_compatible_p(type, intTI_type_node))
102465 + return node;
102466 +
102467 + gsi = gsi_for_stmt(stmt);
102468 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102469 + return gimple_get_lhs(cast_stmt);
102470 +}
102471 +
102472 +static void check_function_hash(const_gimple stmt)
102473 +{
102474 + tree func;
102475 + const struct size_overflow_hash *hash;
102476 +
102477 + if (gimple_code(stmt) != GIMPLE_CALL)
102478 + return;
102479 +
102480 + func = gimple_call_fndecl(stmt);
102481 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
102482 + if (func == NULL_TREE)
102483 + return;
102484 +
102485 + hash = get_function_hash(func);
102486 + if (!hash)
102487 + print_missing_msg(func, 0);
102488 +}
102489 +
102490 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
102491 +{
102492 + tree lhs, new_lhs;
102493 + gimple_stmt_iterator gsi;
102494 +
102495 + if (rhs1 == NULL_TREE) {
102496 + debug_gimple_stmt(oldstmt);
102497 + error("%s: rhs1 is NULL_TREE", __func__);
102498 + gcc_unreachable();
102499 + }
102500 +
102501 + switch (gimple_code(oldstmt)) {
102502 + case GIMPLE_ASM:
102503 + lhs = rhs1;
102504 + break;
102505 + case GIMPLE_CALL:
102506 + lhs = gimple_call_lhs(oldstmt);
102507 + break;
102508 + case GIMPLE_ASSIGN:
102509 + lhs = gimple_get_lhs(oldstmt);
102510 + break;
102511 + default:
102512 + debug_gimple_stmt(oldstmt);
102513 + gcc_unreachable();
102514 + }
102515 +
102516 + gsi = gsi_for_stmt(oldstmt);
102517 + pointer_set_insert(visited, oldstmt);
102518 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
102519 + basic_block next_bb, cur_bb;
102520 + const_edge e;
102521 +
102522 + gcc_assert(before == false);
102523 + gcc_assert(stmt_can_throw_internal(oldstmt));
102524 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
102525 + gcc_assert(!gsi_end_p(gsi));
102526 +
102527 + cur_bb = gimple_bb(oldstmt);
102528 + next_bb = cur_bb->next_bb;
102529 + e = find_edge(cur_bb, next_bb);
102530 + gcc_assert(e != NULL);
102531 + gcc_assert(e->flags & EDGE_FALLTHRU);
102532 +
102533 + gsi = gsi_after_labels(next_bb);
102534 + gcc_assert(!gsi_end_p(gsi));
102535 +
102536 + before = true;
102537 + oldstmt = gsi_stmt(gsi);
102538 + }
102539 +
102540 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
102541 + return new_lhs;
102542 +}
102543 +
102544 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
102545 +{
102546 + gimple stmt;
102547 + gimple_stmt_iterator gsi;
102548 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
102549 +
102550 + if (gimple_plf(oldstmt, MY_STMT))
102551 + return lhs;
102552 +
102553 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
102554 + rhs1 = gimple_assign_rhs1(oldstmt);
102555 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
102556 + }
102557 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
102558 + rhs2 = gimple_assign_rhs2(oldstmt);
102559 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
102560 + }
102561 +
102562 + stmt = gimple_copy(oldstmt);
102563 + gimple_set_location(stmt, gimple_location(oldstmt));
102564 + gimple_set_plf(stmt, MY_STMT, true);
102565 +
102566 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
102567 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
102568 +
102569 + size_overflow_type = get_size_overflow_type(oldstmt, node);
102570 +
102571 + new_var = create_new_var(size_overflow_type);
102572 + new_var = make_ssa_name(new_var, stmt);
102573 + gimple_set_lhs(stmt, new_var);
102574 +
102575 + if (rhs1 != NULL_TREE)
102576 + gimple_assign_set_rhs1(stmt, rhs1);
102577 +
102578 + if (rhs2 != NULL_TREE)
102579 + gimple_assign_set_rhs2(stmt, rhs2);
102580 +#if BUILDING_GCC_VERSION >= 4007
102581 + if (rhs3 != NULL_TREE)
102582 + gimple_assign_set_rhs3(stmt, rhs3);
102583 +#endif
102584 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
102585 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
102586 +
102587 + gsi = gsi_for_stmt(oldstmt);
102588 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
102589 + update_stmt(stmt);
102590 + pointer_set_insert(visited, oldstmt);
102591 + return gimple_get_lhs(stmt);
102592 +}
102593 +
102594 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
102595 +{
102596 + basic_block first_bb;
102597 + gimple assign;
102598 + gimple_stmt_iterator gsi;
102599 +
102600 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102601 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102602 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
102603 +
102604 + gsi = gsi_start_bb(first_bb);
102605 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102606 + return gimple_get_lhs(assign);
102607 +}
102608 +
102609 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
102610 +{
102611 + gimple_stmt_iterator gsi;
102612 + const_gimple assign;
102613 + gimple def_stmt = get_def_stmt(new_arg);
102614 +
102615 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
102616 + gsi = gsi_after_labels(gimple_bb(def_stmt));
102617 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
102618 + } else {
102619 + gsi = gsi_for_stmt(def_stmt);
102620 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
102621 + }
102622 +
102623 + return gimple_get_lhs(assign);
102624 +}
102625 +
102626 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
102627 +{
102628 + basic_block bb;
102629 + gimple_stmt_iterator gsi;
102630 + const_gimple assign, def_stmt;
102631 +
102632 + def_stmt = get_def_stmt(arg);
102633 + bb = gimple_bb(def_stmt);
102634 + gcc_assert(bb->index != 0);
102635 + gsi = gsi_after_labels(bb);
102636 +
102637 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102638 + return gimple_get_lhs(assign);
102639 +}
102640 +
102641 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
102642 +{
102643 + tree size_overflow_type;
102644 + const_gimple def_stmt = get_def_stmt(arg);
102645 +
102646 + if (phi_ssa_name != NULL_TREE)
102647 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
102648 +
102649 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
102650 +
102651 + if (new_arg != NULL_TREE) {
102652 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
102653 + return use_phi_ssa_name(phi_ssa_name, new_arg);
102654 + }
102655 +
102656 + switch(gimple_code(def_stmt)) {
102657 + case GIMPLE_PHI:
102658 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
102659 + case GIMPLE_NOP:
102660 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
102661 + default:
102662 + debug_gimple_stmt((gimple)def_stmt);
102663 + gcc_unreachable();
102664 + }
102665 +}
102666 +
102667 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
102668 +{
102669 + basic_block bb;
102670 + gimple phi;
102671 + gimple_seq seq;
102672 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
102673 +
102674 + bb = gsi_bb(gsi);
102675 +
102676 + phi = create_phi_node(result, bb);
102677 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
102678 + seq = phi_nodes(bb);
102679 + gsi = gsi_last(seq);
102680 + gsi_remove(&gsi, false);
102681 +
102682 + gsi = gsi_for_stmt(oldstmt);
102683 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
102684 + gimple_set_bb(phi, bb);
102685 + gimple_set_plf(phi, MY_STMT, true);
102686 + return phi;
102687 +}
102688 +
102689 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102690 +{
102691 + gimple new_phi = NULL;
102692 + gimple oldstmt = get_def_stmt(orig_result);
102693 + tree phi_ssa_name = NULL_TREE;
102694 + unsigned int i;
102695 +
102696 + pointer_set_insert(visited, oldstmt);
102697 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102698 + tree arg, new_arg;
102699 +
102700 + arg = gimple_phi_arg_def(oldstmt, i);
102701 +
102702 + new_arg = expand(visited, arg);
102703 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102704 + if (i == 0) {
102705 + phi_ssa_name = new_arg;
102706 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102707 + }
102708 +
102709 + gcc_assert(new_phi != NULL);
102710 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102711 + }
102712 +
102713 + gcc_assert(new_phi != NULL);
102714 + update_stmt(new_phi);
102715 + return gimple_phi_result(new_phi);
102716 +}
102717 +
102718 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
102719 +{
102720 + const_gimple assign;
102721 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102722 + tree origtype = TREE_TYPE(orig_rhs);
102723 +
102724 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
102725 +
102726 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102727 + return gimple_get_lhs(assign);
102728 +}
102729 +
102730 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
102731 +{
102732 + const_tree rhs1, lhs, rhs1_type, lhs_type;
102733 + enum machine_mode lhs_mode, rhs_mode;
102734 + gimple def_stmt = get_def_stmt(no_const_rhs);
102735 +
102736 + if (!gimple_assign_cast_p(def_stmt))
102737 + return false;
102738 +
102739 + rhs1 = gimple_assign_rhs1(def_stmt);
102740 + lhs = gimple_get_lhs(def_stmt);
102741 + rhs1_type = TREE_TYPE(rhs1);
102742 + lhs_type = TREE_TYPE(lhs);
102743 + rhs_mode = TYPE_MODE(rhs1_type);
102744 + lhs_mode = TYPE_MODE(lhs_type);
102745 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102746 + return false;
102747 +
102748 + return true;
102749 +}
102750 +
102751 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102752 +{
102753 + tree rhs1 = gimple_assign_rhs1(stmt);
102754 + tree lhs = gimple_get_lhs(stmt);
102755 + const_tree rhs1_type = TREE_TYPE(rhs1);
102756 + const_tree lhs_type = TREE_TYPE(lhs);
102757 +
102758 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102759 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102760 +
102761 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102762 +}
102763 +
102764 +static bool no_uses(tree node)
102765 +{
102766 + imm_use_iterator imm_iter;
102767 + use_operand_p use_p;
102768 +
102769 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102770 + const_gimple use_stmt = USE_STMT(use_p);
102771 + if (use_stmt == NULL)
102772 + return true;
102773 + if (is_gimple_debug(use_stmt))
102774 + continue;
102775 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102776 + continue;
102777 + return false;
102778 + }
102779 + return true;
102780 +}
102781 +
102782 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102783 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102784 +{
102785 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102786 + gimple def_stmt = get_def_stmt(lhs);
102787 +
102788 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102789 + return false;
102790 +
102791 + rhs1 = gimple_assign_rhs1(def_stmt);
102792 + rhs_type = TREE_TYPE(rhs1);
102793 + lhs_type = TREE_TYPE(lhs);
102794 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102795 + return false;
102796 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102797 + return false;
102798 +
102799 + def_stmt = get_def_stmt(rhs1);
102800 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102801 + return false;
102802 +
102803 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102804 + return false;
102805 +
102806 + rhs1 = gimple_assign_rhs1(def_stmt);
102807 + rhs2 = gimple_assign_rhs2(def_stmt);
102808 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102809 + return false;
102810 +
102811 + if (is_gimple_constant(rhs2))
102812 + not_const_rhs = rhs1;
102813 + else
102814 + not_const_rhs = rhs2;
102815 +
102816 + return no_uses(not_const_rhs);
102817 +}
102818 +
102819 +static bool skip_lhs_cast_check(const_gimple stmt)
102820 +{
102821 + const_tree rhs = gimple_assign_rhs1(stmt);
102822 + const_gimple def_stmt = get_def_stmt(rhs);
102823 +
102824 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102825 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102826 + return true;
102827 +
102828 + if (is_const_plus_unsigned_signed_truncation(rhs))
102829 + return true;
102830 +
102831 + return false;
102832 +}
102833 +
102834 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102835 +{
102836 + bool cast_lhs, cast_rhs;
102837 + tree lhs = gimple_get_lhs(stmt);
102838 + tree rhs = gimple_assign_rhs1(stmt);
102839 + const_tree lhs_type = TREE_TYPE(lhs);
102840 + const_tree rhs_type = TREE_TYPE(rhs);
102841 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102842 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102843 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102844 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102845 +
102846 + static bool check_lhs[3][4] = {
102847 + // ss su us uu
102848 + { false, true, true, false }, // lhs > rhs
102849 + { false, false, false, false }, // lhs = rhs
102850 + { true, true, true, true }, // lhs < rhs
102851 + };
102852 +
102853 + static bool check_rhs[3][4] = {
102854 + // ss su us uu
102855 + { true, false, true, true }, // lhs > rhs
102856 + { true, false, true, true }, // lhs = rhs
102857 + { true, false, true, true }, // lhs < rhs
102858 + };
102859 +
102860 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102861 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102862 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102863 +
102864 + if (lhs_size > rhs_size) {
102865 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102866 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102867 + } else if (lhs_size == rhs_size) {
102868 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102869 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102870 + } else {
102871 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102872 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102873 + }
102874 +
102875 + if (!cast_lhs && !cast_rhs)
102876 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102877 +
102878 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102879 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102880 +
102881 + if (cast_rhs)
102882 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102883 +
102884 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102885 +}
102886 +
102887 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102888 +{
102889 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102890 +
102891 + if (gimple_plf(stmt, MY_STMT))
102892 + return lhs;
102893 +
102894 + rhs1 = gimple_assign_rhs1(stmt);
102895 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102896 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102897 +
102898 + new_rhs1 = expand(visited, rhs1);
102899 +
102900 + if (new_rhs1 == NULL_TREE)
102901 + return create_cast_assign(visited, stmt);
102902 +
102903 + if (gimple_plf(stmt, NO_CAST_CHECK))
102904 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102905 +
102906 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102907 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102908 +
102909 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102910 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102911 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102912 + }
102913 +
102914 + if (!gimple_assign_cast_p(stmt))
102915 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102916 +
102917 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102918 +}
102919 +
102920 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102921 +{
102922 + tree rhs1, lhs = gimple_get_lhs(stmt);
102923 + gimple def_stmt = get_def_stmt(lhs);
102924 +
102925 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102926 + rhs1 = gimple_assign_rhs1(def_stmt);
102927 +
102928 + if (is_gimple_constant(rhs1))
102929 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102930 +
102931 + switch (TREE_CODE(rhs1)) {
102932 + case SSA_NAME:
102933 + return handle_unary_rhs(visited, def_stmt);
102934 + case ARRAY_REF:
102935 + case BIT_FIELD_REF:
102936 + case ADDR_EXPR:
102937 + case COMPONENT_REF:
102938 + case INDIRECT_REF:
102939 +#if BUILDING_GCC_VERSION >= 4006
102940 + case MEM_REF:
102941 +#endif
102942 + case TARGET_MEM_REF:
102943 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102944 + case PARM_DECL:
102945 + case VAR_DECL:
102946 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102947 +
102948 + default:
102949 + debug_gimple_stmt(def_stmt);
102950 + debug_tree(rhs1);
102951 + gcc_unreachable();
102952 + }
102953 +}
102954 +
102955 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102956 +{
102957 + gimple cond_stmt;
102958 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102959 +
102960 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102961 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102962 + update_stmt(cond_stmt);
102963 +}
102964 +
102965 +static tree create_string_param(tree string)
102966 +{
102967 + tree i_type, a_type;
102968 + const int length = TREE_STRING_LENGTH(string);
102969 +
102970 + gcc_assert(length > 0);
102971 +
102972 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102973 + a_type = build_array_type(char_type_node, i_type);
102974 +
102975 + TREE_TYPE(string) = a_type;
102976 + TREE_CONSTANT(string) = 1;
102977 + TREE_READONLY(string) = 1;
102978 +
102979 + return build1(ADDR_EXPR, ptr_type_node, string);
102980 +}
102981 +
102982 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
102983 +{
102984 + gimple func_stmt;
102985 + const_gimple def_stmt;
102986 + const_tree loc_line;
102987 + tree loc_file, ssa_name, current_func;
102988 + expanded_location xloc;
102989 + char *ssa_name_buf;
102990 + int len;
102991 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102992 +
102993 + def_stmt = get_def_stmt(arg);
102994 + xloc = expand_location(gimple_location(def_stmt));
102995 +
102996 + if (!gimple_has_location(def_stmt)) {
102997 + xloc = expand_location(gimple_location(stmt));
102998 + if (!gimple_has_location(stmt))
102999 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
103000 + }
103001 +
103002 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
103003 +
103004 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
103005 + loc_file = create_string_param(loc_file);
103006 +
103007 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
103008 + current_func = create_string_param(current_func);
103009 +
103010 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
103011 + call_count++;
103012 + 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);
103013 + gcc_assert(len > 0);
103014 + ssa_name = build_string(len + 1, ssa_name_buf);
103015 + free(ssa_name_buf);
103016 + ssa_name = create_string_param(ssa_name);
103017 +
103018 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
103019 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
103020 +
103021 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
103022 +}
103023 +
103024 +static void __unused print_the_code_insertions(const_gimple stmt)
103025 +{
103026 + location_t loc = gimple_location(stmt);
103027 +
103028 + inform(loc, "Integer size_overflow check applied here.");
103029 +}
103030 +
103031 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
103032 +{
103033 + basic_block cond_bb, join_bb, bb_true;
103034 + edge e;
103035 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103036 +
103037 + cond_bb = gimple_bb(stmt);
103038 + if (before)
103039 + gsi_prev(&gsi);
103040 + if (gsi_end_p(gsi))
103041 + e = split_block_after_labels(cond_bb);
103042 + else
103043 + e = split_block(cond_bb, gsi_stmt(gsi));
103044 + cond_bb = e->src;
103045 + join_bb = e->dest;
103046 + e->flags = EDGE_FALSE_VALUE;
103047 + e->probability = REG_BR_PROB_BASE;
103048 +
103049 + bb_true = create_empty_bb(cond_bb);
103050 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
103051 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
103052 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
103053 +
103054 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
103055 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
103056 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
103057 +
103058 + if (current_loops != NULL) {
103059 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
103060 + add_bb_to_loop(bb_true, cond_bb->loop_father);
103061 + }
103062 +
103063 + insert_cond(cond_bb, arg, cond_code, type_value);
103064 + insert_cond_result(bb_true, stmt, arg, min);
103065 +
103066 +// print_the_code_insertions(stmt);
103067 +}
103068 +
103069 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
103070 +{
103071 + const_tree rhs_type = TREE_TYPE(rhs);
103072 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
103073 +
103074 + gcc_assert(rhs_type != NULL_TREE);
103075 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
103076 + return;
103077 +
103078 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
103079 +
103080 + if (is_const_plus_unsigned_signed_truncation(rhs))
103081 + return;
103082 +
103083 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
103084 + // typemax (-1) < typemin (0)
103085 + if (TREE_OVERFLOW(type_max))
103086 + return;
103087 +
103088 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
103089 +
103090 + cast_rhs_type = TREE_TYPE(cast_rhs);
103091 + type_max_type = TREE_TYPE(type_max);
103092 + type_min_type = TREE_TYPE(type_min);
103093 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
103094 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
103095 +
103096 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
103097 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
103098 +}
103099 +
103100 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
103101 +{
103102 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
103103 + return false;
103104 + if (!is_gimple_constant(rhs))
103105 + return false;
103106 + return true;
103107 +}
103108 +
103109 +static tree get_def_stmt_rhs(const_tree var)
103110 +{
103111 + tree rhs1, def_stmt_rhs1;
103112 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
103113 +
103114 + def_stmt = get_def_stmt(var);
103115 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
103116 +
103117 + rhs1 = gimple_assign_rhs1(def_stmt);
103118 + rhs1_def_stmt = get_def_stmt(rhs1);
103119 + if (!gimple_assign_cast_p(rhs1_def_stmt))
103120 + return rhs1;
103121 +
103122 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103123 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
103124 +
103125 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
103126 + case GIMPLE_CALL:
103127 + case GIMPLE_NOP:
103128 + case GIMPLE_ASM:
103129 + case GIMPLE_PHI:
103130 + return def_stmt_rhs1;
103131 + case GIMPLE_ASSIGN:
103132 + return rhs1;
103133 + default:
103134 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
103135 + gcc_unreachable();
103136 + }
103137 +}
103138 +
103139 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
103140 +{
103141 + tree new_rhs, orig_rhs;
103142 + void (*gimple_assign_set_rhs)(gimple, tree);
103143 + tree rhs1 = gimple_assign_rhs1(stmt);
103144 + tree rhs2 = gimple_assign_rhs2(stmt);
103145 + tree lhs = gimple_get_lhs(stmt);
103146 +
103147 + if (!check_overflow)
103148 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103149 +
103150 + if (change_rhs == NULL_TREE)
103151 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103152 +
103153 + if (new_rhs2 == NULL_TREE) {
103154 + orig_rhs = rhs1;
103155 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
103156 + } else {
103157 + orig_rhs = rhs2;
103158 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
103159 + }
103160 +
103161 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
103162 +
103163 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
103164 + gimple_assign_set_rhs(stmt, new_rhs);
103165 + update_stmt(stmt);
103166 +
103167 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103168 +}
103169 +
103170 +static bool is_subtraction_special(const_gimple stmt)
103171 +{
103172 + gimple rhs1_def_stmt, rhs2_def_stmt;
103173 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
103174 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
103175 + const_tree rhs1 = gimple_assign_rhs1(stmt);
103176 + const_tree rhs2 = gimple_assign_rhs2(stmt);
103177 +
103178 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
103179 + return false;
103180 +
103181 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
103182 +
103183 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
103184 + return false;
103185 +
103186 + rhs1_def_stmt = get_def_stmt(rhs1);
103187 + rhs2_def_stmt = get_def_stmt(rhs2);
103188 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
103189 + return false;
103190 +
103191 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103192 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
103193 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
103194 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
103195 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
103196 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
103197 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
103198 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
103199 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
103200 + return false;
103201 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
103202 + return false;
103203 +
103204 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
103205 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
103206 + return true;
103207 +}
103208 +
103209 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
103210 +{
103211 + tree new_rhs1, new_rhs2;
103212 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
103213 + gimple assign, stmt = get_def_stmt(lhs);
103214 + tree rhs1 = gimple_assign_rhs1(stmt);
103215 + tree rhs2 = gimple_assign_rhs2(stmt);
103216 +
103217 + if (!is_subtraction_special(stmt))
103218 + return NULL_TREE;
103219 +
103220 + new_rhs1 = expand(visited, rhs1);
103221 + new_rhs2 = expand(visited, rhs2);
103222 +
103223 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
103224 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
103225 +
103226 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
103227 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
103228 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
103229 + }
103230 +
103231 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
103232 + new_lhs = gimple_get_lhs(assign);
103233 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
103234 +
103235 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103236 +}
103237 +
103238 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
103239 +{
103240 + const_gimple def_stmt;
103241 +
103242 + if (TREE_CODE(rhs) != SSA_NAME)
103243 + return false;
103244 +
103245 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
103246 + return false;
103247 +
103248 + def_stmt = get_def_stmt(rhs);
103249 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
103250 + return false;
103251 +
103252 + return true;
103253 +}
103254 +
103255 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
103256 +{
103257 + tree rhs1, rhs2, new_lhs;
103258 + gimple def_stmt = get_def_stmt(lhs);
103259 + tree new_rhs1 = NULL_TREE;
103260 + tree new_rhs2 = NULL_TREE;
103261 +
103262 + rhs1 = gimple_assign_rhs1(def_stmt);
103263 + rhs2 = gimple_assign_rhs2(def_stmt);
103264 +
103265 + /* no DImode/TImode division in the 32/64 bit kernel */
103266 + switch (gimple_assign_rhs_code(def_stmt)) {
103267 + case RDIV_EXPR:
103268 + case TRUNC_DIV_EXPR:
103269 + case CEIL_DIV_EXPR:
103270 + case FLOOR_DIV_EXPR:
103271 + case ROUND_DIV_EXPR:
103272 + case TRUNC_MOD_EXPR:
103273 + case CEIL_MOD_EXPR:
103274 + case FLOOR_MOD_EXPR:
103275 + case ROUND_MOD_EXPR:
103276 + case EXACT_DIV_EXPR:
103277 + case POINTER_PLUS_EXPR:
103278 + case BIT_AND_EXPR:
103279 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103280 + default:
103281 + break;
103282 + }
103283 +
103284 + new_lhs = handle_integer_truncation(visited, lhs);
103285 + if (new_lhs != NULL_TREE)
103286 + return new_lhs;
103287 +
103288 + if (TREE_CODE(rhs1) == SSA_NAME)
103289 + new_rhs1 = expand(visited, rhs1);
103290 + if (TREE_CODE(rhs2) == SSA_NAME)
103291 + new_rhs2 = expand(visited, rhs2);
103292 +
103293 + if (is_a_neg_overflow(def_stmt, rhs2))
103294 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
103295 + if (is_a_neg_overflow(def_stmt, rhs1))
103296 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
103297 +
103298 +
103299 + if (is_a_constant_overflow(def_stmt, rhs2))
103300 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
103301 + if (is_a_constant_overflow(def_stmt, rhs1))
103302 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
103303 +
103304 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103305 +}
103306 +
103307 +#if BUILDING_GCC_VERSION >= 4007
103308 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
103309 +{
103310 + if (is_gimple_constant(rhs))
103311 + return cast_a_tree(size_overflow_type, rhs);
103312 + if (TREE_CODE(rhs) != SSA_NAME)
103313 + return NULL_TREE;
103314 + return expand(visited, rhs);
103315 +}
103316 +
103317 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
103318 +{
103319 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
103320 + gimple def_stmt = get_def_stmt(lhs);
103321 +
103322 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
103323 +
103324 + rhs1 = gimple_assign_rhs1(def_stmt);
103325 + rhs2 = gimple_assign_rhs2(def_stmt);
103326 + rhs3 = gimple_assign_rhs3(def_stmt);
103327 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
103328 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
103329 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
103330 +
103331 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
103332 +}
103333 +#endif
103334 +
103335 +static tree get_size_overflow_type(gimple stmt, const_tree node)
103336 +{
103337 + const_tree type;
103338 + tree new_type;
103339 +
103340 + gcc_assert(node != NULL_TREE);
103341 +
103342 + type = TREE_TYPE(node);
103343 +
103344 + if (gimple_plf(stmt, MY_STMT))
103345 + return TREE_TYPE(node);
103346 +
103347 + switch (TYPE_MODE(type)) {
103348 + case QImode:
103349 + new_type = intHI_type_node;
103350 + break;
103351 + case HImode:
103352 + new_type = intSI_type_node;
103353 + break;
103354 + case SImode:
103355 + new_type = intDI_type_node;
103356 + break;
103357 + case DImode:
103358 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
103359 + new_type = intDI_type_node;
103360 + else
103361 + new_type = intTI_type_node;
103362 + break;
103363 + default:
103364 + debug_tree((tree)node);
103365 + error("%s: unsupported gcc configuration.", __func__);
103366 + gcc_unreachable();
103367 + }
103368 +
103369 + if (TYPE_QUALS(type) != 0)
103370 + return build_qualified_type(new_type, TYPE_QUALS(type));
103371 + return new_type;
103372 +}
103373 +
103374 +static tree expand_visited(gimple def_stmt)
103375 +{
103376 + const_gimple next_stmt;
103377 + gimple_stmt_iterator gsi;
103378 + enum gimple_code code = gimple_code(def_stmt);
103379 +
103380 + if (code == GIMPLE_ASM)
103381 + return NULL_TREE;
103382 +
103383 + gsi = gsi_for_stmt(def_stmt);
103384 + gsi_next(&gsi);
103385 +
103386 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
103387 + return NULL_TREE;
103388 + gcc_assert(!gsi_end_p(gsi));
103389 + next_stmt = gsi_stmt(gsi);
103390 +
103391 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
103392 + return NULL_TREE;
103393 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
103394 +
103395 + return get_lhs(next_stmt);
103396 +}
103397 +
103398 +static tree expand(struct pointer_set_t *visited, tree lhs)
103399 +{
103400 + gimple def_stmt;
103401 +
103402 + if (skip_types(lhs))
103403 + return NULL_TREE;
103404 +
103405 + def_stmt = get_def_stmt(lhs);
103406 +
103407 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
103408 + return NULL_TREE;
103409 +
103410 + if (gimple_plf(def_stmt, MY_STMT))
103411 + return lhs;
103412 +
103413 + if (pointer_set_contains(visited, def_stmt))
103414 + return expand_visited(def_stmt);
103415 +
103416 + switch (gimple_code(def_stmt)) {
103417 + case GIMPLE_PHI:
103418 + return handle_phi(visited, lhs);
103419 + case GIMPLE_CALL:
103420 + case GIMPLE_ASM:
103421 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103422 + case GIMPLE_ASSIGN:
103423 + switch (gimple_num_ops(def_stmt)) {
103424 + case 2:
103425 + return handle_unary_ops(visited, def_stmt);
103426 + case 3:
103427 + return handle_binary_ops(visited, lhs);
103428 +#if BUILDING_GCC_VERSION >= 4007
103429 + case 4:
103430 + return handle_ternary_ops(visited, lhs);
103431 +#endif
103432 + }
103433 + default:
103434 + debug_gimple_stmt(def_stmt);
103435 + error("%s: unknown gimple code", __func__);
103436 + gcc_unreachable();
103437 + }
103438 +}
103439 +
103440 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
103441 +{
103442 + const_gimple assign;
103443 + tree orig_type = TREE_TYPE(orig_node);
103444 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103445 +
103446 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
103447 + return gimple_get_lhs(assign);
103448 +}
103449 +
103450 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
103451 +{
103452 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
103453 + update_stmt(stmt);
103454 +}
103455 +
103456 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
103457 +{
103458 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
103459 + update_stmt(stmt);
103460 +}
103461 +
103462 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
103463 +{
103464 + tree arg;
103465 + const_tree origarg;
103466 +
103467 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
103468 + return true;
103469 +
103470 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
103471 + while (origarg && *argnum) {
103472 + (*argnum)--;
103473 + origarg = TREE_CHAIN(origarg);
103474 + }
103475 +
103476 + gcc_assert(*argnum == 0);
103477 +
103478 + gcc_assert(origarg != NULL_TREE);
103479 + *argnum = 0;
103480 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
103481 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
103482 + return true;
103483 + return false;
103484 +}
103485 +
103486 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
103487 +{
103488 + gimple phi = get_def_stmt(result);
103489 + unsigned int i, n = gimple_phi_num_args(phi);
103490 +
103491 + if (!phi)
103492 + return MARK_NO;
103493 +
103494 + pointer_set_insert(visited, phi);
103495 + for (i = 0; i < n; i++) {
103496 + enum mark marked;
103497 + const_tree arg = gimple_phi_arg_def(phi, i);
103498 + marked = pre_expand(visited, search_err_code, arg);
103499 + if (marked != MARK_NO)
103500 + return marked;
103501 + }
103502 + return MARK_NO;
103503 +}
103504 +
103505 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103506 +{
103507 + gimple def_stmt = get_def_stmt(lhs);
103508 + const_tree rhs;
103509 +
103510 + if (!def_stmt)
103511 + return MARK_NO;
103512 +
103513 + rhs = gimple_assign_rhs1(def_stmt);
103514 +
103515 + def_stmt = get_def_stmt(rhs);
103516 + if (is_gimple_constant(rhs))
103517 + search_err_code[FROM_CONST] = true;
103518 +
103519 + return pre_expand(visited, search_err_code, rhs);
103520 +}
103521 +
103522 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103523 +{
103524 + gimple def_stmt = get_def_stmt(lhs);
103525 + const_tree rhs1, rhs2;
103526 + enum mark marked;
103527 +
103528 + if (!def_stmt)
103529 + return MARK_NO;
103530 +
103531 + search_err_code[CAST_ONLY] = false;
103532 +
103533 + rhs1 = gimple_assign_rhs1(def_stmt);
103534 + rhs2 = gimple_assign_rhs2(def_stmt);
103535 + marked = pre_expand(visited, search_err_code, rhs1);
103536 + if (marked != MARK_NO)
103537 + return marked;
103538 + return pre_expand(visited, search_err_code, rhs2);
103539 +}
103540 +
103541 +static const_tree search_field_decl(const_tree comp_ref)
103542 +{
103543 + const_tree field = NULL_TREE;
103544 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
103545 +
103546 + for (i = 0; i < len; i++) {
103547 + field = TREE_OPERAND(comp_ref, i);
103548 + if (TREE_CODE(field) == FIELD_DECL)
103549 + break;
103550 + }
103551 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
103552 + return field;
103553 +}
103554 +
103555 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
103556 +{
103557 + const_tree attr, p;
103558 +
103559 + // 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);
103560 + if (fndecl == NULL_TREE)
103561 + return MARK_NO;
103562 +
103563 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
103564 + if (!attr || !TREE_VALUE(attr))
103565 + return MARK_NO;
103566 +
103567 + p = TREE_VALUE(attr);
103568 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
103569 + return MARK_TURN_OFF;
103570 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
103571 + return MARK_NOT_INTENTIONAL;
103572 + if (argnum == 0) {
103573 + gcc_assert(current_function_decl == fndecl);
103574 + return MARK_NO;
103575 + }
103576 +
103577 + do {
103578 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
103579 + return MARK_YES;
103580 + p = TREE_CHAIN(p);
103581 + } while (p);
103582 +
103583 + return MARK_NO;
103584 +}
103585 +
103586 +static void print_missing_msg(tree func, unsigned int argnum)
103587 +{
103588 + unsigned int new_hash;
103589 + size_t len;
103590 + unsigned char tree_codes[CODES_LIMIT];
103591 + location_t loc;
103592 + const char *curfunc;
103593 +
103594 + func = get_original_function_decl(func);
103595 + loc = DECL_SOURCE_LOCATION(func);
103596 + curfunc = get_asm_name(func);
103597 +
103598 + len = get_function_decl(func, tree_codes);
103599 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
103600 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
103601 +}
103602 +
103603 +static unsigned int search_missing_attribute(const_tree arg)
103604 +{
103605 + unsigned int argnum;
103606 + const struct size_overflow_hash *hash;
103607 + const_tree type = TREE_TYPE(arg);
103608 + tree func = get_original_function_decl(current_function_decl);
103609 +
103610 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
103611 +
103612 + if (TREE_CODE(type) == POINTER_TYPE)
103613 + return 0;
103614 +
103615 + argnum = find_arg_number(arg, func);
103616 + if (argnum == 0)
103617 + return 0;
103618 +
103619 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
103620 + return argnum;
103621 +
103622 + hash = get_function_hash(func);
103623 + if (!hash || !(hash->param & (1U << argnum))) {
103624 + print_missing_msg(func, argnum);
103625 + return 0;
103626 + }
103627 + return argnum;
103628 +}
103629 +
103630 +static enum mark is_already_marked(const_tree lhs)
103631 +{
103632 + unsigned int argnum;
103633 + const_tree fndecl;
103634 +
103635 + argnum = search_missing_attribute(lhs);
103636 + fndecl = get_original_function_decl(current_function_decl);
103637 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
103638 + return MARK_YES;
103639 + return MARK_NO;
103640 +}
103641 +
103642 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103643 +{
103644 + const_gimple def_stmt;
103645 +
103646 + if (skip_types(lhs))
103647 + return MARK_NO;
103648 +
103649 + if (TREE_CODE(lhs) == PARM_DECL)
103650 + return is_already_marked(lhs);
103651 +
103652 + if (TREE_CODE(lhs) == COMPONENT_REF) {
103653 + const_tree field, attr;
103654 +
103655 + field = search_field_decl(lhs);
103656 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
103657 + if (!attr || !TREE_VALUE(attr))
103658 + return MARK_NO;
103659 + return MARK_YES;
103660 + }
103661 +
103662 + def_stmt = get_def_stmt(lhs);
103663 +
103664 + if (!def_stmt)
103665 + return MARK_NO;
103666 +
103667 + if (pointer_set_contains(visited, def_stmt))
103668 + return MARK_NO;
103669 +
103670 + switch (gimple_code(def_stmt)) {
103671 + case GIMPLE_NOP:
103672 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
103673 + return is_already_marked(lhs);
103674 + return MARK_NO;
103675 + case GIMPLE_PHI:
103676 + return walk_phi(visited, search_err_code, lhs);
103677 + case GIMPLE_CALL:
103678 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
103679 + return MARK_TURN_OFF;
103680 + check_function_hash(def_stmt);
103681 + return MARK_NO;
103682 + case GIMPLE_ASM:
103683 + search_err_code[CAST_ONLY] = false;
103684 + return MARK_NO;
103685 + case GIMPLE_ASSIGN:
103686 + switch (gimple_num_ops(def_stmt)) {
103687 + case 2:
103688 + return walk_unary_ops(visited, search_err_code, lhs);
103689 + case 3:
103690 + return walk_binary_ops(visited, search_err_code, lhs);
103691 + }
103692 + default:
103693 + debug_gimple_stmt((gimple)def_stmt);
103694 + error("%s: unknown gimple code", __func__);
103695 + gcc_unreachable();
103696 + }
103697 +}
103698 +
103699 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103700 +static bool skip_asm(const_tree arg)
103701 +{
103702 + gimple def_stmt = get_def_stmt(arg);
103703 +
103704 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103705 + return false;
103706 +
103707 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103708 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103709 +}
103710 +
103711 +/*
103712 +0</MARK_YES: no dup, search attributes (so, int)
103713 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103714 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103715 +*/
103716 +
103717 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
103718 +{
103719 + struct pointer_set_t *visited;
103720 + enum mark is_marked, is_found;
103721 + location_t loc;
103722 + bool search_err_code[2] = {true, false};
103723 +
103724 + is_marked = mark_status(current_function_decl, 0);
103725 + if (is_marked == MARK_TURN_OFF)
103726 + return true;
103727 +
103728 + is_marked = mark_status(fndecl, argnum + 1);
103729 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
103730 + return true;
103731 +
103732 + visited = pointer_set_create();
103733 + is_found = pre_expand(visited, search_err_code, arg);
103734 + pointer_set_destroy(visited);
103735 +
103736 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
103737 + return true;
103738 +
103739 + if (where == FROM_ARG && skip_asm(arg))
103740 + return true;
103741 +
103742 + if (is_found == MARK_TURN_OFF)
103743 + return true;
103744 +
103745 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103746 + return true;
103747 +
103748 + if (is_found == MARK_YES) {
103749 + loc = DECL_SOURCE_LOCATION(fndecl);
103750 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103751 + return true;
103752 + }
103753 + return false;
103754 +}
103755 +
103756 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103757 +{
103758 + struct pointer_set_t *visited;
103759 + tree arg, new_arg;
103760 + bool match;
103761 +
103762 + if (argnum == 0)
103763 + return;
103764 +
103765 + argnum--;
103766 +
103767 + match = get_function_arg(&argnum, fndecl);
103768 + if (!match)
103769 + return;
103770 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103771 + arg = gimple_call_arg(stmt, argnum);
103772 + if (arg == NULL_TREE)
103773 + return;
103774 +
103775 + if (skip_types(arg))
103776 + return;
103777 +
103778 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103779 + return;
103780 +
103781 + visited = pointer_set_create();
103782 + new_arg = expand(visited, arg);
103783 + pointer_set_destroy(visited);
103784 +
103785 + if (new_arg == NULL_TREE)
103786 + return;
103787 +
103788 + change_function_arg(stmt, arg, argnum, new_arg);
103789 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103790 +}
103791 +
103792 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103793 +{
103794 + tree p = TREE_VALUE(attr);
103795 + do {
103796 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103797 + p = TREE_CHAIN(p);
103798 + } while (p);
103799 +}
103800 +
103801 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103802 +{
103803 + unsigned int num;
103804 + const struct size_overflow_hash *hash;
103805 +
103806 + hash = get_function_hash(fndecl);
103807 + if (!hash)
103808 + return;
103809 +
103810 + for (num = 0; num <= MAX_PARAM; num++)
103811 + if (hash->param & (1U << num))
103812 + handle_function_arg(stmt, fndecl, num);
103813 +}
103814 +
103815 +static bool check_return_value(void)
103816 +{
103817 + const struct size_overflow_hash *hash;
103818 +
103819 + hash = get_function_hash(current_function_decl);
103820 + if (!hash || !(hash->param & 1U << 0))
103821 + return false;
103822 +
103823 + return true;
103824 +}
103825 +
103826 +static void handle_return_value(gimple ret_stmt)
103827 +{
103828 + struct pointer_set_t *visited;
103829 + tree ret, new_ret;
103830 +
103831 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103832 + return;
103833 +
103834 + ret = gimple_return_retval(ret_stmt);
103835 +
103836 + if (skip_types(ret))
103837 + return;
103838 +
103839 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103840 + return;
103841 +
103842 + visited = pointer_set_create();
103843 + new_ret = expand(visited, ret);
103844 + pointer_set_destroy(visited);
103845 +
103846 + change_function_return(ret_stmt, ret, new_ret);
103847 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103848 +}
103849 +
103850 +static void set_plf_false(void)
103851 +{
103852 + basic_block bb;
103853 +
103854 + FOR_ALL_BB(bb) {
103855 + gimple_stmt_iterator si;
103856 +
103857 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103858 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103859 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103860 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103861 + }
103862 +}
103863 +
103864 +static unsigned int handle_function(void)
103865 +{
103866 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103867 + bool check_ret;
103868 +
103869 + set_plf_false();
103870 +
103871 + check_ret = check_return_value();
103872 +
103873 + do {
103874 + gimple_stmt_iterator gsi;
103875 + next = bb->next_bb;
103876 +
103877 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103878 + tree fndecl, attr;
103879 + gimple stmt = gsi_stmt(gsi);
103880 +
103881 + if (check_ret)
103882 + handle_return_value(stmt);
103883 +
103884 + if (!(is_gimple_call(stmt)))
103885 + continue;
103886 + fndecl = gimple_call_fndecl(stmt);
103887 + if (fndecl == NULL_TREE)
103888 + continue;
103889 + if (gimple_call_num_args(stmt) == 0)
103890 + continue;
103891 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103892 + if (!attr || !TREE_VALUE(attr))
103893 + handle_function_by_hash(stmt, fndecl);
103894 + else
103895 + handle_function_by_attribute(stmt, attr, fndecl);
103896 + gsi = gsi_for_stmt(stmt);
103897 + next = gimple_bb(stmt)->next_bb;
103898 + }
103899 + bb = next;
103900 + } while (bb);
103901 + return 0;
103902 +}
103903 +
103904 +static struct gimple_opt_pass size_overflow_pass = {
103905 + .pass = {
103906 + .type = GIMPLE_PASS,
103907 + .name = "size_overflow",
103908 +#if BUILDING_GCC_VERSION >= 4008
103909 + .optinfo_flags = OPTGROUP_NONE,
103910 +#endif
103911 + .gate = NULL,
103912 + .execute = handle_function,
103913 + .sub = NULL,
103914 + .next = NULL,
103915 + .static_pass_number = 0,
103916 + .tv_id = TV_NONE,
103917 + .properties_required = PROP_cfg,
103918 + .properties_provided = 0,
103919 + .properties_destroyed = 0,
103920 + .todo_flags_start = 0,
103921 + .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
103922 + }
103923 +};
103924 +
103925 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103926 +{
103927 + tree fntype;
103928 +
103929 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103930 +
103931 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103932 + fntype = build_function_type_list(void_type_node,
103933 + const_char_ptr_type_node,
103934 + unsigned_type_node,
103935 + const_char_ptr_type_node,
103936 + const_char_ptr_type_node,
103937 + NULL_TREE);
103938 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103939 +
103940 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103941 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103942 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103943 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103944 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103945 +}
103946 +
103947 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103948 +{
103949 + int i;
103950 + const char * const plugin_name = plugin_info->base_name;
103951 + const int argc = plugin_info->argc;
103952 + const struct plugin_argument * const argv = plugin_info->argv;
103953 + bool enable = true;
103954 +
103955 + struct register_pass_info size_overflow_pass_info = {
103956 + .pass = &size_overflow_pass.pass,
103957 + .reference_pass_name = "ssa",
103958 + .ref_pass_instance_number = 1,
103959 + .pos_op = PASS_POS_INSERT_AFTER
103960 + };
103961 +
103962 + if (!plugin_default_version_check(version, &gcc_version)) {
103963 + error(G_("incompatible gcc/plugin versions"));
103964 + return 1;
103965 + }
103966 +
103967 + for (i = 0; i < argc; ++i) {
103968 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103969 + enable = false;
103970 + continue;
103971 + }
103972 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103973 + }
103974 +
103975 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103976 + if (enable) {
103977 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103978 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103979 + }
103980 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103981 +
103982 + return 0;
103983 +}
103984 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103985 new file mode 100644
103986 index 0000000..ac2901e
103987 --- /dev/null
103988 +++ b/tools/gcc/stackleak_plugin.c
103989 @@ -0,0 +1,327 @@
103990 +/*
103991 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103992 + * Licensed under the GPL v2
103993 + *
103994 + * Note: the choice of the license means that the compilation process is
103995 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103996 + * but for the kernel it doesn't matter since it doesn't link against
103997 + * any of the gcc libraries
103998 + *
103999 + * gcc plugin to help implement various PaX features
104000 + *
104001 + * - track lowest stack pointer
104002 + *
104003 + * TODO:
104004 + * - initialize all local variables
104005 + *
104006 + * BUGS:
104007 + * - none known
104008 + */
104009 +#include "gcc-plugin.h"
104010 +#include "config.h"
104011 +#include "system.h"
104012 +#include "coretypes.h"
104013 +#include "tree.h"
104014 +#include "tree-pass.h"
104015 +#include "flags.h"
104016 +#include "intl.h"
104017 +#include "toplev.h"
104018 +#include "plugin.h"
104019 +//#include "expr.h" where are you...
104020 +#include "diagnostic.h"
104021 +#include "plugin-version.h"
104022 +#include "tm.h"
104023 +#include "function.h"
104024 +#include "basic-block.h"
104025 +#include "gimple.h"
104026 +#include "rtl.h"
104027 +#include "emit-rtl.h"
104028 +
104029 +#if BUILDING_GCC_VERSION >= 4008
104030 +#define TODO_dump_func 0
104031 +#endif
104032 +
104033 +extern void print_gimple_stmt(FILE *, gimple, int, int);
104034 +
104035 +int plugin_is_GPL_compatible;
104036 +
104037 +static int track_frame_size = -1;
104038 +static const char track_function[] = "pax_track_stack";
104039 +static const char check_function[] = "pax_check_alloca";
104040 +static bool init_locals;
104041 +
104042 +static struct plugin_info stackleak_plugin_info = {
104043 + .version = "201302112000",
104044 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
104045 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
104046 +};
104047 +
104048 +static bool gate_stackleak_track_stack(void);
104049 +static unsigned int execute_stackleak_tree_instrument(void);
104050 +static unsigned int execute_stackleak_final(void);
104051 +
104052 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
104053 + .pass = {
104054 + .type = GIMPLE_PASS,
104055 + .name = "stackleak_tree_instrument",
104056 +#if BUILDING_GCC_VERSION >= 4008
104057 + .optinfo_flags = OPTGROUP_NONE,
104058 +#endif
104059 + .gate = gate_stackleak_track_stack,
104060 + .execute = execute_stackleak_tree_instrument,
104061 + .sub = NULL,
104062 + .next = NULL,
104063 + .static_pass_number = 0,
104064 + .tv_id = TV_NONE,
104065 + .properties_required = PROP_gimple_leh | PROP_cfg,
104066 + .properties_provided = 0,
104067 + .properties_destroyed = 0,
104068 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
104069 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
104070 + }
104071 +};
104072 +
104073 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
104074 + .pass = {
104075 + .type = RTL_PASS,
104076 + .name = "stackleak_final",
104077 +#if BUILDING_GCC_VERSION >= 4008
104078 + .optinfo_flags = OPTGROUP_NONE,
104079 +#endif
104080 + .gate = gate_stackleak_track_stack,
104081 + .execute = execute_stackleak_final,
104082 + .sub = NULL,
104083 + .next = NULL,
104084 + .static_pass_number = 0,
104085 + .tv_id = TV_NONE,
104086 + .properties_required = 0,
104087 + .properties_provided = 0,
104088 + .properties_destroyed = 0,
104089 + .todo_flags_start = 0,
104090 + .todo_flags_finish = TODO_dump_func
104091 + }
104092 +};
104093 +
104094 +static bool gate_stackleak_track_stack(void)
104095 +{
104096 + return track_frame_size >= 0;
104097 +}
104098 +
104099 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
104100 +{
104101 + gimple check_alloca;
104102 + tree fntype, fndecl, alloca_size;
104103 +
104104 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
104105 + fndecl = build_fn_decl(check_function, fntype);
104106 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104107 +
104108 + // insert call to void pax_check_alloca(unsigned long size)
104109 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
104110 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
104111 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
104112 +}
104113 +
104114 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
104115 +{
104116 + gimple track_stack;
104117 + tree fntype, fndecl;
104118 +
104119 + fntype = build_function_type_list(void_type_node, NULL_TREE);
104120 + fndecl = build_fn_decl(track_function, fntype);
104121 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104122 +
104123 + // insert call to void pax_track_stack(void)
104124 + track_stack = gimple_build_call(fndecl, 0);
104125 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
104126 +}
104127 +
104128 +#if BUILDING_GCC_VERSION == 4005
104129 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
104130 +{
104131 + tree fndecl;
104132 +
104133 + if (!is_gimple_call(stmt))
104134 + return false;
104135 + fndecl = gimple_call_fndecl(stmt);
104136 + if (!fndecl)
104137 + return false;
104138 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
104139 + return false;
104140 +// print_node(stderr, "pax", fndecl, 4);
104141 + return DECL_FUNCTION_CODE(fndecl) == code;
104142 +}
104143 +#endif
104144 +
104145 +static bool is_alloca(gimple stmt)
104146 +{
104147 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
104148 + return true;
104149 +
104150 +#if BUILDING_GCC_VERSION >= 4007
104151 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
104152 + return true;
104153 +#endif
104154 +
104155 + return false;
104156 +}
104157 +
104158 +static unsigned int execute_stackleak_tree_instrument(void)
104159 +{
104160 + basic_block bb, entry_bb;
104161 + bool prologue_instrumented = false, is_leaf = true;
104162 +
104163 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
104164 +
104165 + // 1. loop through BBs and GIMPLE statements
104166 + FOR_EACH_BB(bb) {
104167 + gimple_stmt_iterator gsi;
104168 +
104169 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104170 + gimple stmt;
104171 +
104172 + stmt = gsi_stmt(gsi);
104173 +
104174 + if (is_gimple_call(stmt))
104175 + is_leaf = false;
104176 +
104177 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
104178 + if (!is_alloca(stmt))
104179 + continue;
104180 +
104181 + // 2. insert stack overflow check before each __builtin_alloca call
104182 + stackleak_check_alloca(&gsi);
104183 +
104184 + // 3. insert track call after each __builtin_alloca call
104185 + stackleak_add_instrumentation(&gsi);
104186 + if (bb == entry_bb)
104187 + prologue_instrumented = true;
104188 + }
104189 + }
104190 +
104191 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
104192 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
104193 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
104194 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
104195 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
104196 + return 0;
104197 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
104198 + return 0;
104199 +
104200 + // 4. insert track call at the beginning
104201 + if (!prologue_instrumented) {
104202 + gimple_stmt_iterator gsi;
104203 +
104204 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104205 + if (dom_info_available_p(CDI_DOMINATORS))
104206 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104207 + gsi = gsi_start_bb(bb);
104208 + stackleak_add_instrumentation(&gsi);
104209 + }
104210 +
104211 + return 0;
104212 +}
104213 +
104214 +static unsigned int execute_stackleak_final(void)
104215 +{
104216 + rtx insn, next;
104217 +
104218 + if (cfun->calls_alloca)
104219 + return 0;
104220 +
104221 + // keep calls only if function frame is big enough
104222 + if (get_frame_size() >= track_frame_size)
104223 + return 0;
104224 +
104225 + // 1. find pax_track_stack calls
104226 + for (insn = get_insns(); insn; insn = next) {
104227 + // 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))
104228 + rtx body;
104229 +
104230 + next = NEXT_INSN(insn);
104231 + if (!CALL_P(insn))
104232 + continue;
104233 + body = PATTERN(insn);
104234 + if (GET_CODE(body) != CALL)
104235 + continue;
104236 + body = XEXP(body, 0);
104237 + if (GET_CODE(body) != MEM)
104238 + continue;
104239 + body = XEXP(body, 0);
104240 + if (GET_CODE(body) != SYMBOL_REF)
104241 + continue;
104242 + if (strcmp(XSTR(body, 0), track_function))
104243 + continue;
104244 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104245 + // 2. delete call
104246 + delete_insn_and_edges(insn);
104247 +#if BUILDING_GCC_VERSION >= 4007
104248 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
104249 + insn = next;
104250 + next = NEXT_INSN(insn);
104251 + delete_insn_and_edges(insn);
104252 + }
104253 +#endif
104254 + }
104255 +
104256 +// print_simple_rtl(stderr, get_insns());
104257 +// print_rtl(stderr, get_insns());
104258 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104259 +
104260 + return 0;
104261 +}
104262 +
104263 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104264 +{
104265 + const char * const plugin_name = plugin_info->base_name;
104266 + const int argc = plugin_info->argc;
104267 + const struct plugin_argument * const argv = plugin_info->argv;
104268 + int i;
104269 + struct register_pass_info stackleak_tree_instrument_pass_info = {
104270 + .pass = &stackleak_tree_instrument_pass.pass,
104271 +// .reference_pass_name = "tree_profile",
104272 + .reference_pass_name = "optimized",
104273 + .ref_pass_instance_number = 1,
104274 + .pos_op = PASS_POS_INSERT_BEFORE
104275 + };
104276 + struct register_pass_info stackleak_final_pass_info = {
104277 + .pass = &stackleak_final_rtl_opt_pass.pass,
104278 + .reference_pass_name = "final",
104279 + .ref_pass_instance_number = 1,
104280 + .pos_op = PASS_POS_INSERT_BEFORE
104281 + };
104282 +
104283 + if (!plugin_default_version_check(version, &gcc_version)) {
104284 + error(G_("incompatible gcc/plugin versions"));
104285 + return 1;
104286 + }
104287 +
104288 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
104289 +
104290 + for (i = 0; i < argc; ++i) {
104291 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
104292 + if (!argv[i].value) {
104293 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104294 + continue;
104295 + }
104296 + track_frame_size = atoi(argv[i].value);
104297 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
104298 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104299 + continue;
104300 + }
104301 + if (!strcmp(argv[i].key, "initialize-locals")) {
104302 + if (argv[i].value) {
104303 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104304 + continue;
104305 + }
104306 + init_locals = true;
104307 + continue;
104308 + }
104309 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104310 + }
104311 +
104312 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
104313 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
104314 +
104315 + return 0;
104316 +}
104317 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
104318 new file mode 100644
104319 index 0000000..41770fc
104320 --- /dev/null
104321 +++ b/tools/gcc/structleak_plugin.c
104322 @@ -0,0 +1,272 @@
104323 +/*
104324 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
104325 + * Licensed under the GPL v2
104326 + *
104327 + * Note: the choice of the license means that the compilation process is
104328 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104329 + * but for the kernel it doesn't matter since it doesn't link against
104330 + * any of the gcc libraries
104331 + *
104332 + * gcc plugin to forcibly initialize certain local variables that could
104333 + * otherwise leak kernel stack to userland if they aren't properly initialized
104334 + * by later code
104335 + *
104336 + * Homepage: http://pax.grsecurity.net/
104337 + *
104338 + * Usage:
104339 + * $ # for 4.5/4.6/C based 4.7
104340 + * $ 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
104341 + * $ # for C++ based 4.7/4.8+
104342 + * $ 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
104343 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
104344 + *
104345 + * TODO: eliminate redundant initializers
104346 + * increase type coverage
104347 + */
104348 +
104349 +#include "gcc-plugin.h"
104350 +#include "config.h"
104351 +#include "system.h"
104352 +#include "coretypes.h"
104353 +#include "tree.h"
104354 +#include "tree-pass.h"
104355 +#include "intl.h"
104356 +#include "plugin-version.h"
104357 +#include "tm.h"
104358 +#include "toplev.h"
104359 +#include "function.h"
104360 +#include "tree-flow.h"
104361 +#include "plugin.h"
104362 +#include "gimple.h"
104363 +#include "diagnostic.h"
104364 +#include "cfgloop.h"
104365 +#include "langhooks.h"
104366 +
104367 +#if BUILDING_GCC_VERSION >= 4008
104368 +#define TODO_dump_func 0
104369 +#endif
104370 +
104371 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
104372 +
104373 +// unused type flag in all versions 4.5-4.8
104374 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
104375 +
104376 +int plugin_is_GPL_compatible;
104377 +void debug_gimple_stmt(gimple gs);
104378 +
104379 +static struct plugin_info structleak_plugin_info = {
104380 + .version = "201304082245",
104381 + .help = "disable\tdo not activate plugin\n",
104382 +};
104383 +
104384 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
104385 +{
104386 + *no_add_attrs = true;
104387 +
104388 + // check for types? for now accept everything linux has to offer
104389 + if (TREE_CODE(*node) != FIELD_DECL)
104390 + return NULL_TREE;
104391 +
104392 + *no_add_attrs = false;
104393 + return NULL_TREE;
104394 +}
104395 +
104396 +static struct attribute_spec user_attr = {
104397 + .name = "user",
104398 + .min_length = 0,
104399 + .max_length = 0,
104400 + .decl_required = false,
104401 + .type_required = false,
104402 + .function_type_required = false,
104403 + .handler = handle_user_attribute,
104404 +#if BUILDING_GCC_VERSION >= 4007
104405 + .affects_type_identity = true
104406 +#endif
104407 +};
104408 +
104409 +static void register_attributes(void *event_data, void *data)
104410 +{
104411 + register_attribute(&user_attr);
104412 +// register_attribute(&force_attr);
104413 +}
104414 +
104415 +static tree get_field_type(tree field)
104416 +{
104417 + return strip_array_types(TREE_TYPE(field));
104418 +}
104419 +
104420 +static bool is_userspace_type(tree type)
104421 +{
104422 + tree field;
104423 +
104424 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
104425 + tree fieldtype = get_field_type(field);
104426 + enum tree_code code = TREE_CODE(fieldtype);
104427 +
104428 + if (code == RECORD_TYPE || code == UNION_TYPE)
104429 + if (is_userspace_type(fieldtype))
104430 + return true;
104431 +
104432 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
104433 + return true;
104434 + }
104435 + return false;
104436 +}
104437 +
104438 +static void finish_type(void *event_data, void *data)
104439 +{
104440 + tree type = (tree)event_data;
104441 +
104442 + if (TYPE_USERSPACE(type))
104443 + return;
104444 +
104445 + if (is_userspace_type(type))
104446 + TYPE_USERSPACE(type) = 1;
104447 +}
104448 +
104449 +static void initialize(tree var)
104450 +{
104451 + basic_block bb;
104452 + gimple_stmt_iterator gsi;
104453 + tree initializer;
104454 + gimple init_stmt;
104455 +
104456 + // this is the original entry bb before the forced split
104457 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
104458 +
104459 + // first check if the variable is already initialized, warn otherwise
104460 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104461 + gimple stmt = gsi_stmt(gsi);
104462 + tree rhs1 = gimple_assign_rhs1(stmt);
104463 +
104464 + // we're looking for an assignment of a single rhs...
104465 + if (!gimple_assign_single_p(stmt))
104466 + continue;
104467 +#if BUILDING_GCC_VERSION >= 4007
104468 + // ... of a non-clobbering expression...
104469 + if (TREE_CLOBBER_P(rhs1))
104470 + continue;
104471 +#endif
104472 + // ... to our variable...
104473 + if (gimple_get_lhs(stmt) != var)
104474 + continue;
104475 + // if it's an initializer then we're good
104476 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
104477 + return;
104478 + }
104479 +
104480 + // build the initializer expression
104481 + initializer = build_constructor(TREE_TYPE(var), NULL);
104482 +
104483 + // build the initializer stmt
104484 + init_stmt = gimple_build_assign(var, initializer);
104485 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
104486 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
104487 + update_stmt(init_stmt);
104488 +}
104489 +
104490 +static unsigned int handle_function(void)
104491 +{
104492 + basic_block bb;
104493 + unsigned int ret = 0;
104494 + tree var;
104495 +
104496 +#if BUILDING_GCC_VERSION == 4005
104497 + tree vars;
104498 +#else
104499 + unsigned int i;
104500 +#endif
104501 +
104502 + // split the first bb where we can put the forced initializers
104503 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104504 + if (dom_info_available_p(CDI_DOMINATORS))
104505 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104506 +
104507 + // enumarate all local variables and forcibly initialize our targets
104508 +#if BUILDING_GCC_VERSION == 4005
104509 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
104510 + var = TREE_VALUE(vars);
104511 +#else
104512 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
104513 +#endif
104514 + tree type = TREE_TYPE(var);
104515 +
104516 + gcc_assert(DECL_P(var));
104517 + if (!auto_var_in_fn_p(var, current_function_decl))
104518 + continue;
104519 +
104520 + // only care about structure types
104521 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
104522 + continue;
104523 +
104524 + // if the type is of interest, examine the variable
104525 + if (TYPE_USERSPACE(type))
104526 + initialize(var);
104527 + }
104528 +
104529 + return ret;
104530 +}
104531 +
104532 +static struct gimple_opt_pass structleak_pass = {
104533 + .pass = {
104534 + .type = GIMPLE_PASS,
104535 + .name = "structleak",
104536 +#if BUILDING_GCC_VERSION >= 4008
104537 + .optinfo_flags = OPTGROUP_NONE,
104538 +#endif
104539 + .gate = NULL,
104540 + .execute = handle_function,
104541 + .sub = NULL,
104542 + .next = NULL,
104543 + .static_pass_number = 0,
104544 + .tv_id = TV_NONE,
104545 + .properties_required = PROP_cfg,
104546 + .properties_provided = 0,
104547 + .properties_destroyed = 0,
104548 + .todo_flags_start = 0,
104549 + .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
104550 + }
104551 +};
104552 +
104553 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104554 +{
104555 + int i;
104556 + const char * const plugin_name = plugin_info->base_name;
104557 + const int argc = plugin_info->argc;
104558 + const struct plugin_argument * const argv = plugin_info->argv;
104559 + bool enable = true;
104560 +
104561 + struct register_pass_info structleak_pass_info = {
104562 + .pass = &structleak_pass.pass,
104563 + .reference_pass_name = "ssa",
104564 + .ref_pass_instance_number = 1,
104565 + .pos_op = PASS_POS_INSERT_AFTER
104566 + };
104567 +
104568 + if (!plugin_default_version_check(version, &gcc_version)) {
104569 + error(G_("incompatible gcc/plugin versions"));
104570 + return 1;
104571 + }
104572 +
104573 + if (strcmp(lang_hooks.name, "GNU C")) {
104574 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
104575 + enable = false;
104576 + }
104577 +
104578 + for (i = 0; i < argc; ++i) {
104579 + if (!strcmp(argv[i].key, "disable")) {
104580 + enable = false;
104581 + continue;
104582 + }
104583 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104584 + }
104585 +
104586 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
104587 + if (enable) {
104588 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
104589 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
104590 + }
104591 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104592 +
104593 + return 0;
104594 +}
104595 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
104596 index 6789d78..4afd019e 100644
104597 --- a/tools/perf/util/include/asm/alternative-asm.h
104598 +++ b/tools/perf/util/include/asm/alternative-asm.h
104599 @@ -5,4 +5,7 @@
104600
104601 #define altinstruction_entry #
104602
104603 + .macro pax_force_retaddr rip=0, reload=0
104604 + .endm
104605 +
104606 #endif
104607 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
104608 index 96b919d..c49bb74 100644
104609 --- a/tools/perf/util/include/linux/compiler.h
104610 +++ b/tools/perf/util/include/linux/compiler.h
104611 @@ -18,4 +18,12 @@
104612 #define __force
104613 #endif
104614
104615 +#ifndef __size_overflow
104616 +# define __size_overflow(...)
104617 +#endif
104618 +
104619 +#ifndef __intentional_overflow
104620 +# define __intentional_overflow(...)
104621 +#endif
104622 +
104623 #endif
104624 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
104625 index 10afa34..f29c524 100644
104626 --- a/virt/kvm/kvm_main.c
104627 +++ b/virt/kvm/kvm_main.c
104628 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
104629
104630 static cpumask_var_t cpus_hardware_enabled;
104631 static int kvm_usage_count = 0;
104632 -static atomic_t hardware_enable_failed;
104633 +static atomic_unchecked_t hardware_enable_failed;
104634
104635 struct kmem_cache *kvm_vcpu_cache;
104636 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
104637
104638 -static __read_mostly struct preempt_ops kvm_preempt_ops;
104639 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
104640 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
104641 +static struct preempt_ops kvm_preempt_ops = {
104642 + .sched_in = kvm_sched_in,
104643 + .sched_out = kvm_sched_out,
104644 +};
104645
104646 struct dentry *kvm_debugfs_dir;
104647
104648 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
104649 /* We can read the guest memory with __xxx_user() later on. */
104650 if (user_alloc &&
104651 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
104652 - !access_ok(VERIFY_WRITE,
104653 + !__access_ok(VERIFY_WRITE,
104654 (void __user *)(unsigned long)mem->userspace_addr,
104655 mem->memory_size)))
104656 goto out;
104657 @@ -1810,7 +1815,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
104658 return 0;
104659 }
104660
104661 -static struct file_operations kvm_vcpu_fops = {
104662 +static file_operations_no_const kvm_vcpu_fops __read_only = {
104663 .release = kvm_vcpu_release,
104664 .unlocked_ioctl = kvm_vcpu_ioctl,
104665 #ifdef CONFIG_COMPAT
104666 @@ -2331,7 +2336,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
104667 return 0;
104668 }
104669
104670 -static struct file_operations kvm_vm_fops = {
104671 +static file_operations_no_const kvm_vm_fops __read_only = {
104672 .release = kvm_vm_release,
104673 .unlocked_ioctl = kvm_vm_ioctl,
104674 #ifdef CONFIG_COMPAT
104675 @@ -2429,7 +2434,7 @@ out:
104676 return r;
104677 }
104678
104679 -static struct file_operations kvm_chardev_ops = {
104680 +static file_operations_no_const kvm_chardev_ops __read_only = {
104681 .unlocked_ioctl = kvm_dev_ioctl,
104682 .compat_ioctl = kvm_dev_ioctl,
104683 .llseek = noop_llseek,
104684 @@ -2455,7 +2460,7 @@ static void hardware_enable_nolock(void *junk)
104685
104686 if (r) {
104687 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104688 - atomic_inc(&hardware_enable_failed);
104689 + atomic_inc_unchecked(&hardware_enable_failed);
104690 printk(KERN_INFO "kvm: enabling virtualization on "
104691 "CPU%d failed\n", cpu);
104692 }
104693 @@ -2509,10 +2514,10 @@ static int hardware_enable_all(void)
104694
104695 kvm_usage_count++;
104696 if (kvm_usage_count == 1) {
104697 - atomic_set(&hardware_enable_failed, 0);
104698 + atomic_set_unchecked(&hardware_enable_failed, 0);
104699 on_each_cpu(hardware_enable_nolock, NULL, 1);
104700
104701 - if (atomic_read(&hardware_enable_failed)) {
104702 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104703 hardware_disable_all_nolock();
104704 r = -EBUSY;
104705 }
104706 @@ -2870,7 +2875,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104707 kvm_arch_vcpu_put(vcpu);
104708 }
104709
104710 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104711 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104712 struct module *module)
104713 {
104714 int r;
104715 @@ -2906,7 +2911,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104716 if (!vcpu_align)
104717 vcpu_align = __alignof__(struct kvm_vcpu);
104718 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
104719 - 0, NULL);
104720 + SLAB_USERCOPY, NULL);
104721 if (!kvm_vcpu_cache) {
104722 r = -ENOMEM;
104723 goto out_free_3;
104724 @@ -2916,9 +2921,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104725 if (r)
104726 goto out_free;
104727
104728 + pax_open_kernel();
104729 kvm_chardev_ops.owner = module;
104730 kvm_vm_fops.owner = module;
104731 kvm_vcpu_fops.owner = module;
104732 + pax_close_kernel();
104733
104734 r = misc_register(&kvm_dev);
104735 if (r) {
104736 @@ -2928,9 +2935,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104737
104738 register_syscore_ops(&kvm_syscore_ops);
104739
104740 - kvm_preempt_ops.sched_in = kvm_sched_in;
104741 - kvm_preempt_ops.sched_out = kvm_sched_out;
104742 -
104743 r = kvm_init_debug();
104744 if (r) {
104745 printk(KERN_ERR "kvm: create debugfs files failed\n");